@tiptap/extension-font-family
Advanced tools
Comparing version 3.0.0-next.0 to 3.0.0-next.1
@@ -1,54 +0,53 @@ | ||
import '@tiptap/extension-text-style'; | ||
import { Extension } from '@tiptap/core'; | ||
/** | ||
* This extension allows you to set a font family for text. | ||
* @see https://www.tiptap.dev/api/extensions/font-family | ||
*/ | ||
const FontFamily = Extension.create({ | ||
name: 'fontFamily', | ||
addOptions() { | ||
return { | ||
types: ['textStyle'], | ||
}; | ||
}, | ||
addGlobalAttributes() { | ||
return [ | ||
{ | ||
types: this.options.types, | ||
attributes: { | ||
fontFamily: { | ||
default: null, | ||
parseHTML: element => { var _a; return (_a = element.style.fontFamily) === null || _a === void 0 ? void 0 : _a.replace(/['"]+/g, ''); }, | ||
renderHTML: attributes => { | ||
if (!attributes.fontFamily) { | ||
return {}; | ||
} | ||
return { | ||
style: `font-family: ${attributes.fontFamily}`, | ||
}; | ||
}, | ||
}, | ||
}, | ||
// src/font-family.ts | ||
import "@tiptap/extension-text-style"; | ||
import { Extension } from "@tiptap/core"; | ||
var FontFamily = Extension.create({ | ||
name: "fontFamily", | ||
addOptions() { | ||
return { | ||
types: ["textStyle"] | ||
}; | ||
}, | ||
addGlobalAttributes() { | ||
return [ | ||
{ | ||
types: this.options.types, | ||
attributes: { | ||
fontFamily: { | ||
default: null, | ||
parseHTML: (element) => { | ||
var _a; | ||
return (_a = element.style.fontFamily) == null ? void 0 : _a.replace(/['"]+/g, ""); | ||
}, | ||
]; | ||
}, | ||
addCommands() { | ||
return { | ||
setFontFamily: fontFamily => ({ chain }) => { | ||
return chain() | ||
.setMark('textStyle', { fontFamily }) | ||
.run(); | ||
}, | ||
unsetFontFamily: () => ({ chain }) => { | ||
return chain() | ||
.setMark('textStyle', { fontFamily: null }) | ||
.removeEmptyTextStyle() | ||
.run(); | ||
}, | ||
}; | ||
}, | ||
renderHTML: (attributes) => { | ||
if (!attributes.fontFamily) { | ||
return {}; | ||
} | ||
return { | ||
style: `font-family: ${attributes.fontFamily}` | ||
}; | ||
} | ||
} | ||
} | ||
} | ||
]; | ||
}, | ||
addCommands() { | ||
return { | ||
setFontFamily: (fontFamily) => ({ chain }) => { | ||
return chain().setMark("textStyle", { fontFamily }).run(); | ||
}, | ||
unsetFontFamily: () => ({ chain }) => { | ||
return chain().setMark("textStyle", { fontFamily: null }).removeEmptyTextStyle().run(); | ||
} | ||
}; | ||
} | ||
}); | ||
export { FontFamily, FontFamily as default }; | ||
//# sourceMappingURL=index.js.map | ||
// src/index.ts | ||
var src_default = FontFamily; | ||
export { | ||
FontFamily, | ||
src_default as default | ||
}; | ||
//# sourceMappingURL=index.js.map |
{ | ||
"name": "@tiptap/extension-font-family", | ||
"description": "font family 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-font-family/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-font-family/src/index.d.ts", | ||
"types": "dist/index.d.ts", | ||
"files": [ | ||
@@ -34,8 +33,8 @@ "src", | ||
"devDependencies": { | ||
"@tiptap/core": "^3.0.0-next.0", | ||
"@tiptap/extension-text-style": "^3.0.0-next.0" | ||
"@tiptap/core": "^3.0.0-next.1", | ||
"@tiptap/extension-text-style": "^3.0.0-next.1" | ||
}, | ||
"peerDependencies": { | ||
"@tiptap/core": "^3.0.0-next.0", | ||
"@tiptap/extension-text-style": "^3.0.0-next.0" | ||
"@tiptap/core": "^3.0.0-next.1", | ||
"@tiptap/extension-text-style": "^3.0.0-next.1" | ||
}, | ||
@@ -48,5 +47,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
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
16039
10
237
1