@tiptap/extension-text-style
Advanced tools
Comparing version 2.0.0-beta.213 to 2.0.0-beta.214
@@ -1,50 +0,42 @@ | ||
// src/text-style.ts | ||
import { | ||
getMarkAttributes, | ||
Mark, | ||
mergeAttributes | ||
} from "@tiptap/core"; | ||
var TextStyle = Mark.create({ | ||
name: "textStyle", | ||
addOptions() { | ||
return { | ||
HTMLAttributes: {} | ||
}; | ||
}, | ||
parseHTML() { | ||
return [ | ||
{ | ||
tag: "span", | ||
getAttrs: (element) => { | ||
const hasStyles = element.hasAttribute("style"); | ||
if (!hasStyles) { | ||
return false; | ||
} | ||
return {}; | ||
} | ||
} | ||
]; | ||
}, | ||
renderHTML({ HTMLAttributes }) { | ||
return ["span", mergeAttributes(this.options.HTMLAttributes, HTMLAttributes), 0]; | ||
}, | ||
addCommands() { | ||
return { | ||
removeEmptyTextStyle: () => ({ state, commands }) => { | ||
const attributes = getMarkAttributes(state, this.type); | ||
const hasStyles = Object.entries(attributes).some(([, value]) => !!value); | ||
if (hasStyles) { | ||
return true; | ||
} | ||
return commands.unsetMark(this.name); | ||
} | ||
}; | ||
} | ||
import { Mark, mergeAttributes, getMarkAttributes } from '@tiptap/core'; | ||
const TextStyle = Mark.create({ | ||
name: 'textStyle', | ||
addOptions() { | ||
return { | ||
HTMLAttributes: {}, | ||
}; | ||
}, | ||
parseHTML() { | ||
return [ | ||
{ | ||
tag: 'span', | ||
getAttrs: element => { | ||
const hasStyles = element.hasAttribute('style'); | ||
if (!hasStyles) { | ||
return false; | ||
} | ||
return {}; | ||
}, | ||
}, | ||
]; | ||
}, | ||
renderHTML({ HTMLAttributes }) { | ||
return ['span', mergeAttributes(this.options.HTMLAttributes, HTMLAttributes), 0]; | ||
}, | ||
addCommands() { | ||
return { | ||
removeEmptyTextStyle: () => ({ state, commands }) => { | ||
const attributes = getMarkAttributes(state, this.type); | ||
const hasStyles = Object.entries(attributes).some(([, value]) => !!value); | ||
if (hasStyles) { | ||
return true; | ||
} | ||
return commands.unsetMark(this.name); | ||
}, | ||
}; | ||
}, | ||
}); | ||
// src/index.ts | ||
var src_default = TextStyle; | ||
export { | ||
TextStyle, | ||
src_default as default | ||
}; | ||
export { TextStyle, TextStyle as default }; | ||
//# sourceMappingURL=index.js.map |
{ | ||
"name": "@tiptap/extension-text-style", | ||
"description": "text style extension for tiptap", | ||
"version": "2.0.0-beta.213", | ||
"version": "2.0.0-beta.214", | ||
"homepage": "https://tiptap.dev", | ||
@@ -18,3 +18,3 @@ "keywords": [ | ||
".": { | ||
"types": "./dist/index.d.ts", | ||
"types": "./dist/packages/extension-text-style/src/index.d.ts", | ||
"import": "./dist/index.js", | ||
@@ -26,3 +26,4 @@ "require": "./dist/index.cjs" | ||
"module": "dist/index.js", | ||
"types": "dist/index.d.ts", | ||
"umd": "dist/index.umd.js", | ||
"types": "dist/packages/extension-text-style/src/index.d.ts", | ||
"files": [ | ||
@@ -36,3 +37,3 @@ "src", | ||
"devDependencies": { | ||
"@tiptap/core": "^2.0.0-beta.213" | ||
"@tiptap/core": "^2.0.0-beta.214" | ||
}, | ||
@@ -45,15 +46,5 @@ "repository": { | ||
"scripts": { | ||
"build": "tsup" | ||
}, | ||
"tsup": { | ||
"entry": [ | ||
"src/index.ts" | ||
], | ||
"dts": true, | ||
"splitting": true, | ||
"format": [ | ||
"esm", | ||
"cjs" | ||
] | ||
"clean": "rm -rf dist", | ||
"build": "npm run clean && rollup -c" | ||
} | ||
} |
Sorry, the diff of this file is not supported yet
15990
12
206