@tiptap/extension-bold
Advanced tools
Comparing version 2.0.0-alpha.4 to 2.0.0-alpha.5
@@ -6,2 +6,10 @@ # Change Log | ||
# [2.0.0-alpha.5](https://github.com/ueberdosis/tiptap-next/compare/@tiptap/extension-bold@2.0.0-alpha.4...@tiptap/extension-bold@2.0.0-alpha.5) (2020-12-18) | ||
**Note:** Version bump only for package @tiptap/extension-bold | ||
# [2.0.0-alpha.4](https://github.com/ueberdosis/tiptap-next/compare/@tiptap/extension-bold@2.0.0-alpha.3...@tiptap/extension-bold@2.0.0-alpha.4) (2020-12-02) | ||
@@ -8,0 +16,0 @@ |
@@ -1,30 +0,3 @@ | ||
import { Command, Mark } from '@tiptap/core'; | ||
export interface BoldOptions { | ||
HTMLAttributes: { | ||
[key: string]: any; | ||
}; | ||
} | ||
export declare const starInputRegex: RegExp; | ||
export declare const starPasteRegex: RegExp; | ||
export declare const underscoreInputRegex: RegExp; | ||
export declare const underscorePasteRegex: RegExp; | ||
declare const Bold: Mark<BoldOptions, { | ||
/** | ||
* Set a bold mark | ||
*/ | ||
setBold: () => Command; | ||
/** | ||
* Toggle a bold mark | ||
*/ | ||
toggleBold: () => Command; | ||
/** | ||
* Unset a bold mark | ||
*/ | ||
unsetBold: () => Command; | ||
}>; | ||
import { Bold } from './bold'; | ||
export * from './bold'; | ||
export default Bold; | ||
declare module '@tiptap/core' { | ||
interface AllExtensions { | ||
Bold: typeof Bold; | ||
} | ||
} |
@@ -1,2 +0,2 @@ | ||
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports,require("@tiptap/core")):"function"==typeof define&&define.amd?define(["exports","@tiptap/core"],t):t((e="undefined"!=typeof globalThis?globalThis:e||self)["@tiptap/extension-bold"]={},e["@tiptap/core"])}(this,(function(e,t){"use strict";const s=/(?:^|\s)((?:\*\*)((?:[^*]+))(?:\*\*))$/gm,o=/(?:^|\s)((?:\*\*)((?:[^*]+))(?:\*\*))/gm,r=/(?:^|\s)((?:__)((?:[^__]+))(?:__))$/gm,n=/(?:^|\s)((?:__)((?:[^__]+))(?:__))/gm,d=t.Mark.create({name:"bold",defaultOptions:{HTMLAttributes:{}},parseHTML:()=>[{tag:"strong"},{tag:"b",getAttrs:e=>"normal"!==e.style.fontWeight&&null},{style:"font-weight",getAttrs:e=>/^(bold(er)?|[5-9]\d{2,})$/.test(e)&&null}],renderHTML({HTMLAttributes:e}){return["strong",t.mergeAttributes(this.options.HTMLAttributes,e),0]},addCommands:()=>({setBold:()=>({commands:e})=>e.setMark("bold"),toggleBold:()=>({commands:e})=>e.toggleMark("bold"),unsetBold:()=>({commands:e})=>e.unsetMark("bold")}),addKeyboardShortcuts(){return{"Mod-b":()=>this.editor.commands.toggleBold()}},addInputRules(){return[t.markInputRule(s,this.type),t.markInputRule(r,this.type)]},addPasteRules(){return[t.markPasteRule(o,this.type),t.markPasteRule(n,this.type)]}});e.default=d,e.starInputRegex=s,e.starPasteRegex=o,e.underscoreInputRegex=r,e.underscorePasteRegex=n,Object.defineProperty(e,"__esModule",{value:!0})})); | ||
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports,require("@tiptap/core")):"function"==typeof define&&define.amd?define(["exports","@tiptap/core"],t):t((e="undefined"!=typeof globalThis?globalThis:e||self)["@tiptap/extension-bold"]={},e["@tiptap/core"])}(this,(function(e,t){"use strict";const s=/(?:^|\s)((?:\*\*)((?:[^*]+))(?:\*\*))$/gm,o=/(?:^|\s)((?:\*\*)((?:[^*]+))(?:\*\*))/gm,r=/(?:^|\s)((?:__)((?:[^__]+))(?:__))$/gm,n=/(?:^|\s)((?:__)((?:[^__]+))(?:__))/gm,d=t.Mark.create({name:"bold",defaultOptions:{HTMLAttributes:{}},parseHTML:()=>[{tag:"strong"},{tag:"b",getAttrs:e=>"normal"!==e.style.fontWeight&&null},{style:"font-weight",getAttrs:e=>/^(bold(er)?|[5-9]\d{2,})$/.test(e)&&null}],renderHTML({HTMLAttributes:e}){return["strong",t.mergeAttributes(this.options.HTMLAttributes,e),0]},addCommands:()=>({setBold:()=>({commands:e})=>e.setMark("bold"),toggleBold:()=>({commands:e})=>e.toggleMark("bold"),unsetBold:()=>({commands:e})=>e.unsetMark("bold")}),addKeyboardShortcuts(){return{"Mod-b":()=>this.editor.commands.toggleBold()}},addInputRules(){return[t.markInputRule(s,this.type),t.markInputRule(r,this.type)]},addPasteRules(){return[t.markPasteRule(o,this.type),t.markPasteRule(n,this.type)]}});e.Bold=d,e.default=d,e.starInputRegex=s,e.starPasteRegex=o,e.underscoreInputRegex=r,e.underscorePasteRegex=n,Object.defineProperty(e,"__esModule",{value:!0})})); | ||
//# sourceMappingURL=tiptap-extension-bold.bundle.umd.min.js.map |
@@ -75,2 +75,3 @@ 'use strict'; | ||
exports.Bold = Bold; | ||
exports.default = Bold; | ||
@@ -77,0 +78,0 @@ exports.starInputRegex = starInputRegex; |
@@ -72,3 +72,3 @@ import { Mark, mergeAttributes, markInputRule, markPasteRule } from '@tiptap/core'; | ||
export default Bold; | ||
export { starInputRegex, starPasteRegex, underscoreInputRegex, underscorePasteRegex }; | ||
export { Bold, starInputRegex, starPasteRegex, underscoreInputRegex, underscorePasteRegex }; | ||
//# sourceMappingURL=tiptap-extension-bold.esm.js.map |
@@ -75,2 +75,3 @@ (function (global, factory) { | ||
exports.Bold = Bold; | ||
exports.default = Bold; | ||
@@ -77,0 +78,0 @@ exports.starInputRegex = starInputRegex; |
{ | ||
"name": "@tiptap/extension-bold", | ||
"description": "bold extension for tiptap", | ||
"version": "2.0.0-alpha.4", | ||
"version": "2.0.0-alpha.5", | ||
"homepage": "https://tiptap.dev", | ||
@@ -27,3 +27,3 @@ "keywords": [ | ||
}, | ||
"gitHead": "a884cb81de8783d0097741c1ddb97a82ea88ae0e" | ||
"gitHead": "0371cb0a5d803a44d93532aa34419ec7ffffdc24" | ||
} |
@@ -1,97 +0,5 @@ | ||
import { | ||
Command, | ||
Mark, | ||
markInputRule, | ||
markPasteRule, | ||
mergeAttributes, | ||
} from '@tiptap/core' | ||
import { Bold } from './bold' | ||
export interface BoldOptions { | ||
HTMLAttributes: { | ||
[key: string]: any | ||
}, | ||
} | ||
export * from './bold' | ||
export const starInputRegex = /(?:^|\s)((?:\*\*)((?:[^*]+))(?:\*\*))$/gm | ||
export const starPasteRegex = /(?:^|\s)((?:\*\*)((?:[^*]+))(?:\*\*))/gm | ||
export const underscoreInputRegex = /(?:^|\s)((?:__)((?:[^__]+))(?:__))$/gm | ||
export const underscorePasteRegex = /(?:^|\s)((?:__)((?:[^__]+))(?:__))/gm | ||
const Bold = Mark.create({ | ||
name: 'bold', | ||
defaultOptions: <BoldOptions>{ | ||
HTMLAttributes: {}, | ||
}, | ||
parseHTML() { | ||
return [ | ||
{ | ||
tag: 'strong', | ||
}, | ||
{ | ||
tag: 'b', | ||
getAttrs: node => (node as HTMLElement).style.fontWeight !== 'normal' && null, | ||
}, | ||
{ | ||
style: 'font-weight', | ||
getAttrs: value => /^(bold(er)?|[5-9]\d{2,})$/.test(value as string) && null, | ||
}, | ||
] | ||
}, | ||
renderHTML({ HTMLAttributes }) { | ||
return ['strong', mergeAttributes(this.options.HTMLAttributes, HTMLAttributes), 0] | ||
}, | ||
addCommands() { | ||
return { | ||
/** | ||
* Set a bold mark | ||
*/ | ||
setBold: (): Command => ({ commands }) => { | ||
return commands.setMark('bold') | ||
}, | ||
/** | ||
* Toggle a bold mark | ||
*/ | ||
toggleBold: (): Command => ({ commands }) => { | ||
return commands.toggleMark('bold') | ||
}, | ||
/** | ||
* Unset a bold mark | ||
*/ | ||
unsetBold: (): Command => ({ commands }) => { | ||
return commands.unsetMark('bold') | ||
}, | ||
} | ||
}, | ||
addKeyboardShortcuts() { | ||
return { | ||
'Mod-b': () => this.editor.commands.toggleBold(), | ||
} | ||
}, | ||
addInputRules() { | ||
return [ | ||
markInputRule(starInputRegex, this.type), | ||
markInputRule(underscoreInputRegex, this.type), | ||
] | ||
}, | ||
addPasteRules() { | ||
return [ | ||
markPasteRule(starPasteRegex, this.type), | ||
markPasteRule(underscorePasteRegex, this.type), | ||
] | ||
}, | ||
}) | ||
export default Bold | ||
declare module '@tiptap/core' { | ||
interface AllExtensions { | ||
Bold: typeof Bold, | ||
} | ||
} |
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
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
30968
16
355