@tiptap/extension-text-style
Advanced tools
Comparing version 3.0.0-next.0 to 3.0.0-next.1
@@ -1,47 +0,52 @@ | ||
import { Mark, mergeAttributes, getMarkAttributes } from '@tiptap/core'; | ||
/** | ||
* This extension allows you to create text styles. It is required by default | ||
* for the `textColor` and `backgroundColor` extensions. | ||
* @see https://www.tiptap.dev/api/marks/text-style | ||
*/ | ||
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/text-style.ts | ||
import { | ||
getMarkAttributes, | ||
Mark, | ||
mergeAttributes | ||
} from "@tiptap/core"; | ||
var TextStyle = Mark.create({ | ||
name: "textStyle", | ||
priority: 101, | ||
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); | ||
} | ||
}; | ||
} | ||
}); | ||
export { TextStyle, TextStyle as default }; | ||
//# sourceMappingURL=index.js.map | ||
// src/index.ts | ||
var src_default = TextStyle; | ||
export { | ||
TextStyle, | ||
src_default as default | ||
}; | ||
//# sourceMappingURL=index.js.map |
{ | ||
"name": "@tiptap/extension-text-style", | ||
"description": "text style 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-text-style/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-text-style/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" | ||
} | ||
} |
@@ -36,2 +36,4 @@ import { | ||
priority: 101, | ||
addOptions() { | ||
@@ -38,0 +40,0 @@ return { |
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
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
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
14352
10
218
1