Socket
Socket
Sign inDemoInstall

@tiptap/extension-bold

Package Overview
Dependencies
Maintainers
5
Versions
157
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@tiptap/extension-bold - npm Package Compare versions

Comparing version 3.0.0-next.0 to 3.0.0-next.1

dist/index.d.cts

182

dist/index.js

@@ -1,94 +0,92 @@

import { Mark, mergeAttributes, markInputRule, markPasteRule } from '@tiptap/core';
/**
* Matches bold text via `**` as input.
*/
const starInputRegex = /(?:^|\s)(\*\*(?!\s+\*\*)((?:[^*]+))\*\*(?!\s+\*\*))$/;
/**
* Matches bold text via `**` while pasting.
*/
const starPasteRegex = /(?:^|\s)(\*\*(?!\s+\*\*)((?:[^*]+))\*\*(?!\s+\*\*))/g;
/**
* Matches bold text via `__` as input.
*/
const underscoreInputRegex = /(?:^|\s)(__(?!\s+__)((?:[^_]+))__(?!\s+__))$/;
/**
* Matches bold text via `__` while pasting.
*/
const underscorePasteRegex = /(?:^|\s)(__(?!\s+__)((?:[^_]+))__(?!\s+__))/g;
/**
* This extension allows you to mark text as bold.
* @see https://tiptap.dev/api/marks/bold
*/
const Bold = Mark.create({
name: 'bold',
addOptions() {
return {
HTMLAttributes: {},
};
},
parseHTML() {
return [
{
tag: 'strong',
},
{
tag: 'b',
getAttrs: node => node.style.fontWeight !== 'normal' && null,
},
{
style: 'font-weight',
getAttrs: value => /^(bold(er)?|[5-9]\d{2,})$/.test(value) && null,
},
];
},
renderHTML({ HTMLAttributes }) {
return ['strong', mergeAttributes(this.options.HTMLAttributes, HTMLAttributes), 0];
},
addCommands() {
return {
setBold: () => ({ commands }) => {
return commands.setMark(this.name);
},
toggleBold: () => ({ commands }) => {
return commands.toggleMark(this.name);
},
unsetBold: () => ({ commands }) => {
return commands.unsetMark(this.name);
},
};
},
addKeyboardShortcuts() {
return {
'Mod-b': () => this.editor.commands.toggleBold(),
'Mod-B': () => this.editor.commands.toggleBold(),
};
},
addInputRules() {
return [
markInputRule({
find: starInputRegex,
type: this.type,
}),
markInputRule({
find: underscoreInputRegex,
type: this.type,
}),
];
},
addPasteRules() {
return [
markPasteRule({
find: starPasteRegex,
type: this.type,
}),
markPasteRule({
find: underscorePasteRegex,
type: this.type,
}),
];
},
// src/bold.ts
import {
Mark,
markInputRule,
markPasteRule,
mergeAttributes
} from "@tiptap/core";
var starInputRegex = /(?:^|\s)(\*\*(?!\s+\*\*)((?:[^*]+))\*\*(?!\s+\*\*))$/;
var starPasteRegex = /(?:^|\s)(\*\*(?!\s+\*\*)((?:[^*]+))\*\*(?!\s+\*\*))/g;
var underscoreInputRegex = /(?:^|\s)(__(?!\s+__)((?:[^_]+))__(?!\s+__))$/;
var underscorePasteRegex = /(?:^|\s)(__(?!\s+__)((?:[^_]+))__(?!\s+__))/g;
var Bold = Mark.create({
name: "bold",
addOptions() {
return {
HTMLAttributes: {}
};
},
parseHTML() {
return [
{
tag: "strong"
},
{
tag: "b",
getAttrs: (node) => node.style.fontWeight !== "normal" && null
},
{
style: "font-weight",
getAttrs: (value) => /^(bold(er)?|[5-9]\d{2,})$/.test(value) && null
}
];
},
renderHTML({ HTMLAttributes }) {
return ["strong", mergeAttributes(this.options.HTMLAttributes, HTMLAttributes), 0];
},
addCommands() {
return {
setBold: () => ({ commands }) => {
return commands.setMark(this.name);
},
toggleBold: () => ({ commands }) => {
return commands.toggleMark(this.name);
},
unsetBold: () => ({ commands }) => {
return commands.unsetMark(this.name);
}
};
},
addKeyboardShortcuts() {
return {
"Mod-b": () => this.editor.commands.toggleBold(),
"Mod-B": () => this.editor.commands.toggleBold()
};
},
addInputRules() {
return [
markInputRule({
find: starInputRegex,
type: this.type
}),
markInputRule({
find: underscoreInputRegex,
type: this.type
})
];
},
addPasteRules() {
return [
markPasteRule({
find: starPasteRegex,
type: this.type
}),
markPasteRule({
find: underscorePasteRegex,
type: this.type
})
];
}
});
export { Bold, Bold as default, starInputRegex, starPasteRegex, underscoreInputRegex, underscorePasteRegex };
//# sourceMappingURL=index.js.map
// src/index.ts
var src_default = Bold;
export {
Bold,
src_default as default,
starInputRegex,
starPasteRegex,
underscoreInputRegex,
underscorePasteRegex
};
//# sourceMappingURL=index.js.map
{
"name": "@tiptap/extension-bold",
"description": "bold extension for tiptap",
"version": "3.0.0-next.0",
"version": "3.0.0-next.1",
"homepage": "https://tiptap.dev",

@@ -18,3 +18,3 @@ "keywords": [

".": {
"types": "./dist/packages/extension-bold/src/index.d.ts",
"types": "./dist/index.d.ts",
"import": "./dist/index.js",

@@ -26,4 +26,3 @@ "require": "./dist/index.cjs"

"module": "dist/index.js",
"umd": "dist/index.umd.js",
"types": "dist/packages/extension-bold/src/index.d.ts",
"types": "dist/index.d.ts",
"files": [

@@ -34,6 +33,6 @@ "src",

"devDependencies": {
"@tiptap/core": "^3.0.0-next.0"
"@tiptap/core": "^3.0.0-next.1"
},
"peerDependencies": {
"@tiptap/core": "^3.0.0-next.0"
"@tiptap/core": "^3.0.0-next.1"
},

@@ -46,5 +45,4 @@ "repository": {

"scripts": {
"clean": "rm -rf dist",
"build": "npm run clean && rollup -c"
"build": "tsup"
}
}

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc