@tiptap/extension-italic
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-italic@2.0.0-alpha.4...@tiptap/extension-italic@2.0.0-alpha.5) (2020-12-18) | ||
**Note:** Version bump only for package @tiptap/extension-italic | ||
# [2.0.0-alpha.4](https://github.com/ueberdosis/tiptap-next/compare/@tiptap/extension-italic@2.0.0-alpha.3...@tiptap/extension-italic@2.0.0-alpha.4) (2020-12-02) | ||
@@ -8,0 +16,0 @@ |
@@ -1,30 +0,3 @@ | ||
import { Command, Mark } from '@tiptap/core'; | ||
export interface ItalicOptions { | ||
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 Italic: Mark<ItalicOptions, { | ||
/** | ||
* Set an italic mark | ||
*/ | ||
setItalic: () => Command; | ||
/** | ||
* Toggle an italic mark | ||
*/ | ||
toggleItalic: () => Command; | ||
/** | ||
* Unset an italic mark | ||
*/ | ||
unsetItalic: () => Command; | ||
}>; | ||
import { Italic } from './italic'; | ||
export * from './italic'; | ||
export default Italic; | ||
declare module '@tiptap/core' { | ||
interface AllExtensions { | ||
Italic: typeof Italic; | ||
} | ||
} |
@@ -1,2 +0,2 @@ | ||
!function(t,e){"object"==typeof exports&&"undefined"!=typeof module?e(exports,require("@tiptap/core")):"function"==typeof define&&define.amd?define(["exports","@tiptap/core"],e):e((t="undefined"!=typeof globalThis?globalThis:t||self)["@tiptap/extension-italic"]={},t["@tiptap/core"])}(this,(function(t,e){"use strict";const s=/(?:^|\s)((?:\*)((?:[^*]+))(?:\*))$/gm,a=/(?:^|\s)((?:\*)((?:[^*]+))(?:\*))/gm,i=/(?:^|\s)((?:_)((?:[^_]+))(?:_))$/gm,r=/(?:^|\s)((?:_)((?:[^_]+))(?:_))/gm,n=e.Mark.create({name:"italic",defaultOptions:{HTMLAttributes:{}},parseHTML:()=>[{tag:"em"},{tag:"i",getAttrs:t=>"normal"!==t.style.fontStyle&&null},{style:"font-style=italic"}],renderHTML({HTMLAttributes:t}){return["em",e.mergeAttributes(this.options.HTMLAttributes,t),0]},addCommands:()=>({setItalic:()=>({commands:t})=>t.setMark("italic"),toggleItalic:()=>({commands:t})=>t.toggleMark("italic"),unsetItalic:()=>({commands:t})=>t.unsetMark("italic")}),addKeyboardShortcuts(){return{"Mod-i":()=>this.editor.commands.toggleItalic()}},addInputRules(){return[e.markInputRule(s,this.type),e.markInputRule(i,this.type)]},addPasteRules(){return[e.markPasteRule(a,this.type),e.markPasteRule(r,this.type)]}});t.default=n,t.starInputRegex=s,t.starPasteRegex=a,t.underscoreInputRegex=i,t.underscorePasteRegex=r,Object.defineProperty(t,"__esModule",{value:!0})})); | ||
!function(t,e){"object"==typeof exports&&"undefined"!=typeof module?e(exports,require("@tiptap/core")):"function"==typeof define&&define.amd?define(["exports","@tiptap/core"],e):e((t="undefined"!=typeof globalThis?globalThis:t||self)["@tiptap/extension-italic"]={},t["@tiptap/core"])}(this,(function(t,e){"use strict";const s=/(?:^|\s)((?:\*)((?:[^*]+))(?:\*))$/gm,a=/(?:^|\s)((?:\*)((?:[^*]+))(?:\*))/gm,i=/(?:^|\s)((?:_)((?:[^_]+))(?:_))$/gm,r=/(?:^|\s)((?:_)((?:[^_]+))(?:_))/gm,n=e.Mark.create({name:"italic",defaultOptions:{HTMLAttributes:{}},parseHTML:()=>[{tag:"em"},{tag:"i",getAttrs:t=>"normal"!==t.style.fontStyle&&null},{style:"font-style=italic"}],renderHTML({HTMLAttributes:t}){return["em",e.mergeAttributes(this.options.HTMLAttributes,t),0]},addCommands:()=>({setItalic:()=>({commands:t})=>t.setMark("italic"),toggleItalic:()=>({commands:t})=>t.toggleMark("italic"),unsetItalic:()=>({commands:t})=>t.unsetMark("italic")}),addKeyboardShortcuts(){return{"Mod-i":()=>this.editor.commands.toggleItalic()}},addInputRules(){return[e.markInputRule(s,this.type),e.markInputRule(i,this.type)]},addPasteRules(){return[e.markPasteRule(a,this.type),e.markPasteRule(r,this.type)]}});t.Italic=n,t.default=n,t.starInputRegex=s,t.starPasteRegex=a,t.underscoreInputRegex=i,t.underscorePasteRegex=r,Object.defineProperty(t,"__esModule",{value:!0})})); | ||
//# sourceMappingURL=tiptap-extension-italic.bundle.umd.min.js.map |
@@ -74,2 +74,3 @@ 'use strict'; | ||
exports.Italic = Italic; | ||
exports.default = Italic; | ||
@@ -76,0 +77,0 @@ exports.starInputRegex = starInputRegex; |
@@ -71,3 +71,3 @@ import { Mark, mergeAttributes, markInputRule, markPasteRule } from '@tiptap/core'; | ||
export default Italic; | ||
export { starInputRegex, starPasteRegex, underscoreInputRegex, underscorePasteRegex }; | ||
export { Italic, starInputRegex, starPasteRegex, underscoreInputRegex, underscorePasteRegex }; | ||
//# sourceMappingURL=tiptap-extension-italic.esm.js.map |
@@ -74,2 +74,3 @@ (function (global, factory) { | ||
exports.Italic = Italic; | ||
exports.default = Italic; | ||
@@ -76,0 +77,0 @@ exports.starInputRegex = starInputRegex; |
{ | ||
"name": "@tiptap/extension-italic", | ||
"description": "italic 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,96 +0,5 @@ | ||
import { | ||
Command, | ||
Mark, | ||
markInputRule, | ||
markPasteRule, | ||
mergeAttributes, | ||
} from '@tiptap/core' | ||
import { Italic } from './italic' | ||
export interface ItalicOptions { | ||
HTMLAttributes: { | ||
[key: string]: any | ||
}, | ||
} | ||
export * from './italic' | ||
export const starInputRegex = /(?:^|\s)((?:\*)((?:[^*]+))(?:\*))$/gm | ||
export const starPasteRegex = /(?:^|\s)((?:\*)((?:[^*]+))(?:\*))/gm | ||
export const underscoreInputRegex = /(?:^|\s)((?:_)((?:[^_]+))(?:_))$/gm | ||
export const underscorePasteRegex = /(?:^|\s)((?:_)((?:[^_]+))(?:_))/gm | ||
const Italic = Mark.create({ | ||
name: 'italic', | ||
defaultOptions: <ItalicOptions>{ | ||
HTMLAttributes: {}, | ||
}, | ||
parseHTML() { | ||
return [ | ||
{ | ||
tag: 'em', | ||
}, | ||
{ | ||
tag: 'i', | ||
getAttrs: node => (node as HTMLElement).style.fontStyle !== 'normal' && null, | ||
}, | ||
{ | ||
style: 'font-style=italic', | ||
}, | ||
] | ||
}, | ||
renderHTML({ HTMLAttributes }) { | ||
return ['em', mergeAttributes(this.options.HTMLAttributes, HTMLAttributes), 0] | ||
}, | ||
addCommands() { | ||
return { | ||
/** | ||
* Set an italic mark | ||
*/ | ||
setItalic: (): Command => ({ commands }) => { | ||
return commands.setMark('italic') | ||
}, | ||
/** | ||
* Toggle an italic mark | ||
*/ | ||
toggleItalic: (): Command => ({ commands }) => { | ||
return commands.toggleMark('italic') | ||
}, | ||
/** | ||
* Unset an italic mark | ||
*/ | ||
unsetItalic: (): Command => ({ commands }) => { | ||
return commands.unsetMark('italic') | ||
}, | ||
} | ||
}, | ||
addKeyboardShortcuts() { | ||
return { | ||
'Mod-i': () => this.editor.commands.toggleItalic(), | ||
} | ||
}, | ||
addInputRules() { | ||
return [ | ||
markInputRule(starInputRegex, this.type), | ||
markInputRule(underscoreInputRegex, this.type), | ||
] | ||
}, | ||
addPasteRules() { | ||
return [ | ||
markPasteRule(starPasteRegex, this.type), | ||
markPasteRule(underscorePasteRegex, this.type), | ||
] | ||
}, | ||
}) | ||
export default Italic | ||
declare module '@tiptap/core' { | ||
interface AllExtensions { | ||
Italic: typeof Italic, | ||
} | ||
} |
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
30228
16
351