@tiptap/extension-font-family 2.0.0-beta.209 → 2.0.0-beta.210
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.cjs +52 -0
- package/dist/{packages/extension-font-family/src/font-family.d.ts → index.d.ts} +22 -20
- package/dist/index.js +52 -0
- package/package.json +25 -12
- package/dist/packages/extension-font-family/src/index.d.ts +0 -3
- package/dist/tiptap-extension-font-family.cjs +0 -55
- package/dist/tiptap-extension-font-family.cjs.map +0 -1
- package/dist/tiptap-extension-font-family.esm.js +0 -50
- package/dist/tiptap-extension-font-family.esm.js.map +0 -1
- package/dist/tiptap-extension-font-family.umd.js +0 -58
- package/dist/tiptap-extension-font-family.umd.js.map +0 -1
package/dist/index.cjs
ADDED
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
"use strict";Object.defineProperty(exports, "__esModule", {value: true});// src/font-family.ts
|
|
2
|
+
require('@tiptap/extension-text-style');
|
|
3
|
+
var _core = require('@tiptap/core');
|
|
4
|
+
var FontFamily = _core.Extension.create({
|
|
5
|
+
name: "fontFamily",
|
|
6
|
+
addOptions() {
|
|
7
|
+
return {
|
|
8
|
+
types: ["textStyle"]
|
|
9
|
+
};
|
|
10
|
+
},
|
|
11
|
+
addGlobalAttributes() {
|
|
12
|
+
return [
|
|
13
|
+
{
|
|
14
|
+
types: this.options.types,
|
|
15
|
+
attributes: {
|
|
16
|
+
fontFamily: {
|
|
17
|
+
default: null,
|
|
18
|
+
parseHTML: (element) => {
|
|
19
|
+
var _a;
|
|
20
|
+
return (_a = element.style.fontFamily) == null ? void 0 : _a.replace(/['"]+/g, "");
|
|
21
|
+
},
|
|
22
|
+
renderHTML: (attributes) => {
|
|
23
|
+
if (!attributes.fontFamily) {
|
|
24
|
+
return {};
|
|
25
|
+
}
|
|
26
|
+
return {
|
|
27
|
+
style: `font-family: ${attributes.fontFamily}`
|
|
28
|
+
};
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
];
|
|
34
|
+
},
|
|
35
|
+
addCommands() {
|
|
36
|
+
return {
|
|
37
|
+
setFontFamily: (fontFamily) => ({ chain }) => {
|
|
38
|
+
return chain().setMark("textStyle", { fontFamily }).run();
|
|
39
|
+
},
|
|
40
|
+
unsetFontFamily: () => ({ chain }) => {
|
|
41
|
+
return chain().setMark("textStyle", { fontFamily: null }).removeEmptyTextStyle().run();
|
|
42
|
+
}
|
|
43
|
+
};
|
|
44
|
+
}
|
|
45
|
+
});
|
|
46
|
+
|
|
47
|
+
// src/index.ts
|
|
48
|
+
var src_default = FontFamily;
|
|
49
|
+
|
|
50
|
+
|
|
51
|
+
|
|
52
|
+
exports.FontFamily = FontFamily; exports.default = src_default;
|
|
@@ -1,20 +1,22 @@
|
|
|
1
|
-
import '@tiptap/
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
types: string[];
|
|
5
|
-
};
|
|
6
|
-
declare module '@tiptap/core' {
|
|
7
|
-
interface Commands<ReturnType> {
|
|
8
|
-
fontFamily: {
|
|
9
|
-
/**
|
|
10
|
-
* Set the font family
|
|
11
|
-
*/
|
|
12
|
-
setFontFamily: (fontFamily: string) => ReturnType;
|
|
13
|
-
/**
|
|
14
|
-
* Unset the font family
|
|
15
|
-
*/
|
|
16
|
-
unsetFontFamily: () => ReturnType;
|
|
17
|
-
};
|
|
18
|
-
}
|
|
19
|
-
}
|
|
20
|
-
|
|
1
|
+
import { Extension } from '@tiptap/core';
|
|
2
|
+
|
|
3
|
+
declare type FontFamilyOptions = {
|
|
4
|
+
types: string[];
|
|
5
|
+
};
|
|
6
|
+
declare module '@tiptap/core' {
|
|
7
|
+
interface Commands<ReturnType> {
|
|
8
|
+
fontFamily: {
|
|
9
|
+
/**
|
|
10
|
+
* Set the font family
|
|
11
|
+
*/
|
|
12
|
+
setFontFamily: (fontFamily: string) => ReturnType;
|
|
13
|
+
/**
|
|
14
|
+
* Unset the font family
|
|
15
|
+
*/
|
|
16
|
+
unsetFontFamily: () => ReturnType;
|
|
17
|
+
};
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
declare const FontFamily: Extension<FontFamilyOptions, any>;
|
|
21
|
+
|
|
22
|
+
export { FontFamily, FontFamilyOptions, FontFamily as default };
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
// src/font-family.ts
|
|
2
|
+
import "@tiptap/extension-text-style";
|
|
3
|
+
import { Extension } from "@tiptap/core";
|
|
4
|
+
var FontFamily = Extension.create({
|
|
5
|
+
name: "fontFamily",
|
|
6
|
+
addOptions() {
|
|
7
|
+
return {
|
|
8
|
+
types: ["textStyle"]
|
|
9
|
+
};
|
|
10
|
+
},
|
|
11
|
+
addGlobalAttributes() {
|
|
12
|
+
return [
|
|
13
|
+
{
|
|
14
|
+
types: this.options.types,
|
|
15
|
+
attributes: {
|
|
16
|
+
fontFamily: {
|
|
17
|
+
default: null,
|
|
18
|
+
parseHTML: (element) => {
|
|
19
|
+
var _a;
|
|
20
|
+
return (_a = element.style.fontFamily) == null ? void 0 : _a.replace(/['"]+/g, "");
|
|
21
|
+
},
|
|
22
|
+
renderHTML: (attributes) => {
|
|
23
|
+
if (!attributes.fontFamily) {
|
|
24
|
+
return {};
|
|
25
|
+
}
|
|
26
|
+
return {
|
|
27
|
+
style: `font-family: ${attributes.fontFamily}`
|
|
28
|
+
};
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
];
|
|
34
|
+
},
|
|
35
|
+
addCommands() {
|
|
36
|
+
return {
|
|
37
|
+
setFontFamily: (fontFamily) => ({ chain }) => {
|
|
38
|
+
return chain().setMark("textStyle", { fontFamily }).run();
|
|
39
|
+
},
|
|
40
|
+
unsetFontFamily: () => ({ chain }) => {
|
|
41
|
+
return chain().setMark("textStyle", { fontFamily: null }).removeEmptyTextStyle().run();
|
|
42
|
+
}
|
|
43
|
+
};
|
|
44
|
+
}
|
|
45
|
+
});
|
|
46
|
+
|
|
47
|
+
// src/index.ts
|
|
48
|
+
var src_default = FontFamily;
|
|
49
|
+
export {
|
|
50
|
+
FontFamily,
|
|
51
|
+
src_default as default
|
|
52
|
+
};
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@tiptap/extension-font-family",
|
|
3
3
|
"description": "font family extension for tiptap",
|
|
4
|
-
"version": "2.0.0-beta.
|
|
4
|
+
"version": "2.0.0-beta.210",
|
|
5
5
|
"homepage": "https://tiptap.dev",
|
|
6
6
|
"keywords": [
|
|
7
7
|
"tiptap",
|
|
@@ -15,30 +15,43 @@
|
|
|
15
15
|
"type": "module",
|
|
16
16
|
"exports": {
|
|
17
17
|
".": {
|
|
18
|
-
"types": "./dist/
|
|
19
|
-
"import": "./dist/
|
|
20
|
-
"require": "./dist/
|
|
18
|
+
"types": "./dist/index.d.ts",
|
|
19
|
+
"import": "./dist/index.js",
|
|
20
|
+
"require": "./dist/index.cjs"
|
|
21
21
|
}
|
|
22
22
|
},
|
|
23
|
-
"main": "dist/
|
|
24
|
-
"
|
|
25
|
-
"
|
|
26
|
-
"types": "dist/packages/extension-font-family/src/index.d.ts",
|
|
23
|
+
"main": "dist/index.cjs",
|
|
24
|
+
"module": "dist/index.js",
|
|
25
|
+
"types": "dist/index.d.ts",
|
|
27
26
|
"files": [
|
|
28
27
|
"src",
|
|
29
28
|
"dist"
|
|
30
29
|
],
|
|
31
30
|
"peerDependencies": {
|
|
32
|
-
"@tiptap/core": "^2.0.0-beta.193",
|
|
33
|
-
"@tiptap/extension-text-style": "^2.0.0-beta.193"
|
|
34
|
-
},
|
|
35
|
-
"devDependencies": {
|
|
36
31
|
"@tiptap/core": "^2.0.0-beta.209",
|
|
37
32
|
"@tiptap/extension-text-style": "^2.0.0-beta.209"
|
|
38
33
|
},
|
|
34
|
+
"devDependencies": {
|
|
35
|
+
"@tiptap/core": "^2.0.0-beta.210",
|
|
36
|
+
"@tiptap/extension-text-style": "^2.0.0-beta.210"
|
|
37
|
+
},
|
|
39
38
|
"repository": {
|
|
40
39
|
"type": "git",
|
|
41
40
|
"url": "https://github.com/ueberdosis/tiptap",
|
|
42
41
|
"directory": "packages/extension-font-family"
|
|
42
|
+
},
|
|
43
|
+
"scripts": {
|
|
44
|
+
"build": "tsup"
|
|
45
|
+
},
|
|
46
|
+
"tsup": {
|
|
47
|
+
"entry": [
|
|
48
|
+
"src/index.ts"
|
|
49
|
+
],
|
|
50
|
+
"dts": true,
|
|
51
|
+
"splitting": true,
|
|
52
|
+
"format": [
|
|
53
|
+
"esm",
|
|
54
|
+
"cjs"
|
|
55
|
+
]
|
|
43
56
|
}
|
|
44
57
|
}
|
|
@@ -1,55 +0,0 @@
|
|
|
1
|
-
'use strict';
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
|
-
|
|
5
|
-
require('@tiptap/extension-text-style');
|
|
6
|
-
var core = require('@tiptap/core');
|
|
7
|
-
|
|
8
|
-
const FontFamily = core.Extension.create({
|
|
9
|
-
name: 'fontFamily',
|
|
10
|
-
addOptions() {
|
|
11
|
-
return {
|
|
12
|
-
types: ['textStyle'],
|
|
13
|
-
};
|
|
14
|
-
},
|
|
15
|
-
addGlobalAttributes() {
|
|
16
|
-
return [
|
|
17
|
-
{
|
|
18
|
-
types: this.options.types,
|
|
19
|
-
attributes: {
|
|
20
|
-
fontFamily: {
|
|
21
|
-
default: null,
|
|
22
|
-
parseHTML: element => { var _a; return (_a = element.style.fontFamily) === null || _a === void 0 ? void 0 : _a.replace(/['"]+/g, ''); },
|
|
23
|
-
renderHTML: attributes => {
|
|
24
|
-
if (!attributes.fontFamily) {
|
|
25
|
-
return {};
|
|
26
|
-
}
|
|
27
|
-
return {
|
|
28
|
-
style: `font-family: ${attributes.fontFamily}`,
|
|
29
|
-
};
|
|
30
|
-
},
|
|
31
|
-
},
|
|
32
|
-
},
|
|
33
|
-
},
|
|
34
|
-
];
|
|
35
|
-
},
|
|
36
|
-
addCommands() {
|
|
37
|
-
return {
|
|
38
|
-
setFontFamily: fontFamily => ({ chain }) => {
|
|
39
|
-
return chain()
|
|
40
|
-
.setMark('textStyle', { fontFamily })
|
|
41
|
-
.run();
|
|
42
|
-
},
|
|
43
|
-
unsetFontFamily: () => ({ chain }) => {
|
|
44
|
-
return chain()
|
|
45
|
-
.setMark('textStyle', { fontFamily: null })
|
|
46
|
-
.removeEmptyTextStyle()
|
|
47
|
-
.run();
|
|
48
|
-
},
|
|
49
|
-
};
|
|
50
|
-
},
|
|
51
|
-
});
|
|
52
|
-
|
|
53
|
-
exports.FontFamily = FontFamily;
|
|
54
|
-
exports["default"] = FontFamily;
|
|
55
|
-
//# sourceMappingURL=tiptap-extension-font-family.cjs.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"tiptap-extension-font-family.cjs","sources":["../src/font-family.ts"],"sourcesContent":["import '@tiptap/extension-text-style'\n\nimport { Extension } from '@tiptap/core'\n\nexport type FontFamilyOptions = {\n types: string[],\n}\n\ndeclare module '@tiptap/core' {\n interface Commands<ReturnType> {\n fontFamily: {\n /**\n * Set the font family\n */\n setFontFamily: (fontFamily: string) => ReturnType,\n /**\n * Unset the font family\n */\n unsetFontFamily: () => ReturnType,\n }\n }\n}\n\nexport const FontFamily = Extension.create<FontFamilyOptions>({\n name: 'fontFamily',\n\n addOptions() {\n return {\n types: ['textStyle'],\n }\n },\n\n addGlobalAttributes() {\n return [\n {\n types: this.options.types,\n attributes: {\n fontFamily: {\n default: null,\n parseHTML: element => element.style.fontFamily?.replace(/['\"]+/g, ''),\n renderHTML: attributes => {\n if (!attributes.fontFamily) {\n return {}\n }\n\n return {\n style: `font-family: ${attributes.fontFamily}`,\n }\n },\n },\n },\n },\n ]\n },\n\n addCommands() {\n return {\n setFontFamily: fontFamily => ({ chain }) => {\n return chain()\n .setMark('textStyle', { fontFamily })\n .run()\n },\n unsetFontFamily: () => ({ chain }) => {\n return chain()\n .setMark('textStyle', { fontFamily: null })\n .removeEmptyTextStyle()\n .run()\n },\n }\n },\n})\n"],"names":["Extension"],"mappings":";;;;;;;AAuBa,MAAA,UAAU,GAAGA,cAAS,CAAC,MAAM,CAAoB;AAC5D,IAAA,IAAI,EAAE,YAAY;IAElB,UAAU,GAAA;QACR,OAAO;YACL,KAAK,EAAE,CAAC,WAAW,CAAC;SACrB,CAAA;KACF;IAED,mBAAmB,GAAA;QACjB,OAAO;AACL,YAAA;AACE,gBAAA,KAAK,EAAE,IAAI,CAAC,OAAO,CAAC,KAAK;AACzB,gBAAA,UAAU,EAAE;AACV,oBAAA,UAAU,EAAE;AACV,wBAAA,OAAO,EAAE,IAAI;wBACb,SAAS,EAAE,OAAO,cAAI,OAAA,CAAA,EAAA,GAAA,OAAO,CAAC,KAAK,CAAC,UAAU,MAAA,IAAA,IAAA,EAAA,KAAA,KAAA,CAAA,GAAA,KAAA,CAAA,GAAA,EAAA,CAAE,OAAO,CAAC,QAAQ,EAAE,EAAE,CAAC,CAAA,EAAA;wBACrE,UAAU,EAAE,UAAU,IAAG;AACvB,4BAAA,IAAI,CAAC,UAAU,CAAC,UAAU,EAAE;AAC1B,gCAAA,OAAO,EAAE,CAAA;AACV,6BAAA;4BAED,OAAO;AACL,gCAAA,KAAK,EAAE,CAAA,aAAA,EAAgB,UAAU,CAAC,UAAU,CAAE,CAAA;6BAC/C,CAAA;yBACF;AACF,qBAAA;AACF,iBAAA;AACF,aAAA;SACF,CAAA;KACF;IAED,WAAW,GAAA;QACT,OAAO;YACL,aAAa,EAAE,UAAU,IAAI,CAAC,EAAE,KAAK,EAAE,KAAI;AACzC,gBAAA,OAAO,KAAK,EAAE;AACX,qBAAA,OAAO,CAAC,WAAW,EAAE,EAAE,UAAU,EAAE,CAAC;AACpC,qBAAA,GAAG,EAAE,CAAA;aACT;YACD,eAAe,EAAE,MAAM,CAAC,EAAE,KAAK,EAAE,KAAI;AACnC,gBAAA,OAAO,KAAK,EAAE;qBACX,OAAO,CAAC,WAAW,EAAE,EAAE,UAAU,EAAE,IAAI,EAAE,CAAC;AAC1C,qBAAA,oBAAoB,EAAE;AACtB,qBAAA,GAAG,EAAE,CAAA;aACT;SACF,CAAA;KACF;AACF,CAAA;;;;;"}
|
|
@@ -1,50 +0,0 @@
|
|
|
1
|
-
import '@tiptap/extension-text-style';
|
|
2
|
-
import { Extension } from '@tiptap/core';
|
|
3
|
-
|
|
4
|
-
const FontFamily = Extension.create({
|
|
5
|
-
name: 'fontFamily',
|
|
6
|
-
addOptions() {
|
|
7
|
-
return {
|
|
8
|
-
types: ['textStyle'],
|
|
9
|
-
};
|
|
10
|
-
},
|
|
11
|
-
addGlobalAttributes() {
|
|
12
|
-
return [
|
|
13
|
-
{
|
|
14
|
-
types: this.options.types,
|
|
15
|
-
attributes: {
|
|
16
|
-
fontFamily: {
|
|
17
|
-
default: null,
|
|
18
|
-
parseHTML: element => { var _a; return (_a = element.style.fontFamily) === null || _a === void 0 ? void 0 : _a.replace(/['"]+/g, ''); },
|
|
19
|
-
renderHTML: attributes => {
|
|
20
|
-
if (!attributes.fontFamily) {
|
|
21
|
-
return {};
|
|
22
|
-
}
|
|
23
|
-
return {
|
|
24
|
-
style: `font-family: ${attributes.fontFamily}`,
|
|
25
|
-
};
|
|
26
|
-
},
|
|
27
|
-
},
|
|
28
|
-
},
|
|
29
|
-
},
|
|
30
|
-
];
|
|
31
|
-
},
|
|
32
|
-
addCommands() {
|
|
33
|
-
return {
|
|
34
|
-
setFontFamily: fontFamily => ({ chain }) => {
|
|
35
|
-
return chain()
|
|
36
|
-
.setMark('textStyle', { fontFamily })
|
|
37
|
-
.run();
|
|
38
|
-
},
|
|
39
|
-
unsetFontFamily: () => ({ chain }) => {
|
|
40
|
-
return chain()
|
|
41
|
-
.setMark('textStyle', { fontFamily: null })
|
|
42
|
-
.removeEmptyTextStyle()
|
|
43
|
-
.run();
|
|
44
|
-
},
|
|
45
|
-
};
|
|
46
|
-
},
|
|
47
|
-
});
|
|
48
|
-
|
|
49
|
-
export { FontFamily, FontFamily as default };
|
|
50
|
-
//# sourceMappingURL=tiptap-extension-font-family.esm.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"tiptap-extension-font-family.esm.js","sources":["../src/font-family.ts"],"sourcesContent":["import '@tiptap/extension-text-style'\n\nimport { Extension } from '@tiptap/core'\n\nexport type FontFamilyOptions = {\n types: string[],\n}\n\ndeclare module '@tiptap/core' {\n interface Commands<ReturnType> {\n fontFamily: {\n /**\n * Set the font family\n */\n setFontFamily: (fontFamily: string) => ReturnType,\n /**\n * Unset the font family\n */\n unsetFontFamily: () => ReturnType,\n }\n }\n}\n\nexport const FontFamily = Extension.create<FontFamilyOptions>({\n name: 'fontFamily',\n\n addOptions() {\n return {\n types: ['textStyle'],\n }\n },\n\n addGlobalAttributes() {\n return [\n {\n types: this.options.types,\n attributes: {\n fontFamily: {\n default: null,\n parseHTML: element => element.style.fontFamily?.replace(/['\"]+/g, ''),\n renderHTML: attributes => {\n if (!attributes.fontFamily) {\n return {}\n }\n\n return {\n style: `font-family: ${attributes.fontFamily}`,\n }\n },\n },\n },\n },\n ]\n },\n\n addCommands() {\n return {\n setFontFamily: fontFamily => ({ chain }) => {\n return chain()\n .setMark('textStyle', { fontFamily })\n .run()\n },\n unsetFontFamily: () => ({ chain }) => {\n return chain()\n .setMark('textStyle', { fontFamily: null })\n .removeEmptyTextStyle()\n .run()\n },\n }\n },\n})\n"],"names":[],"mappings":";;;AAuBa,MAAA,UAAU,GAAG,SAAS,CAAC,MAAM,CAAoB;AAC5D,IAAA,IAAI,EAAE,YAAY;IAElB,UAAU,GAAA;QACR,OAAO;YACL,KAAK,EAAE,CAAC,WAAW,CAAC;SACrB,CAAA;KACF;IAED,mBAAmB,GAAA;QACjB,OAAO;AACL,YAAA;AACE,gBAAA,KAAK,EAAE,IAAI,CAAC,OAAO,CAAC,KAAK;AACzB,gBAAA,UAAU,EAAE;AACV,oBAAA,UAAU,EAAE;AACV,wBAAA,OAAO,EAAE,IAAI;wBACb,SAAS,EAAE,OAAO,cAAI,OAAA,CAAA,EAAA,GAAA,OAAO,CAAC,KAAK,CAAC,UAAU,MAAA,IAAA,IAAA,EAAA,KAAA,KAAA,CAAA,GAAA,KAAA,CAAA,GAAA,EAAA,CAAE,OAAO,CAAC,QAAQ,EAAE,EAAE,CAAC,CAAA,EAAA;wBACrE,UAAU,EAAE,UAAU,IAAG;AACvB,4BAAA,IAAI,CAAC,UAAU,CAAC,UAAU,EAAE;AAC1B,gCAAA,OAAO,EAAE,CAAA;AACV,6BAAA;4BAED,OAAO;AACL,gCAAA,KAAK,EAAE,CAAA,aAAA,EAAgB,UAAU,CAAC,UAAU,CAAE,CAAA;6BAC/C,CAAA;yBACF;AACF,qBAAA;AACF,iBAAA;AACF,aAAA;SACF,CAAA;KACF;IAED,WAAW,GAAA;QACT,OAAO;YACL,aAAa,EAAE,UAAU,IAAI,CAAC,EAAE,KAAK,EAAE,KAAI;AACzC,gBAAA,OAAO,KAAK,EAAE;AACX,qBAAA,OAAO,CAAC,WAAW,EAAE,EAAE,UAAU,EAAE,CAAC;AACpC,qBAAA,GAAG,EAAE,CAAA;aACT;YACD,eAAe,EAAE,MAAM,CAAC,EAAE,KAAK,EAAE,KAAI;AACnC,gBAAA,OAAO,KAAK,EAAE;qBACX,OAAO,CAAC,WAAW,EAAE,EAAE,UAAU,EAAE,IAAI,EAAE,CAAC;AAC1C,qBAAA,oBAAoB,EAAE;AACtB,qBAAA,GAAG,EAAE,CAAA;aACT;SACF,CAAA;KACF;AACF,CAAA;;;;"}
|
|
@@ -1,58 +0,0 @@
|
|
|
1
|
-
(function (global, factory) {
|
|
2
|
-
typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports, require('@tiptap/extension-text-style'), require('@tiptap/core')) :
|
|
3
|
-
typeof define === 'function' && define.amd ? define(['exports', '@tiptap/extension-text-style', '@tiptap/core'], factory) :
|
|
4
|
-
(global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory(global["@tiptap/extension-font-family"] = {}, null, global.core));
|
|
5
|
-
})(this, (function (exports, extensionTextStyle, core) { 'use strict';
|
|
6
|
-
|
|
7
|
-
const FontFamily = core.Extension.create({
|
|
8
|
-
name: 'fontFamily',
|
|
9
|
-
addOptions() {
|
|
10
|
-
return {
|
|
11
|
-
types: ['textStyle'],
|
|
12
|
-
};
|
|
13
|
-
},
|
|
14
|
-
addGlobalAttributes() {
|
|
15
|
-
return [
|
|
16
|
-
{
|
|
17
|
-
types: this.options.types,
|
|
18
|
-
attributes: {
|
|
19
|
-
fontFamily: {
|
|
20
|
-
default: null,
|
|
21
|
-
parseHTML: element => { var _a; return (_a = element.style.fontFamily) === null || _a === void 0 ? void 0 : _a.replace(/['"]+/g, ''); },
|
|
22
|
-
renderHTML: attributes => {
|
|
23
|
-
if (!attributes.fontFamily) {
|
|
24
|
-
return {};
|
|
25
|
-
}
|
|
26
|
-
return {
|
|
27
|
-
style: `font-family: ${attributes.fontFamily}`,
|
|
28
|
-
};
|
|
29
|
-
},
|
|
30
|
-
},
|
|
31
|
-
},
|
|
32
|
-
},
|
|
33
|
-
];
|
|
34
|
-
},
|
|
35
|
-
addCommands() {
|
|
36
|
-
return {
|
|
37
|
-
setFontFamily: fontFamily => ({ chain }) => {
|
|
38
|
-
return chain()
|
|
39
|
-
.setMark('textStyle', { fontFamily })
|
|
40
|
-
.run();
|
|
41
|
-
},
|
|
42
|
-
unsetFontFamily: () => ({ chain }) => {
|
|
43
|
-
return chain()
|
|
44
|
-
.setMark('textStyle', { fontFamily: null })
|
|
45
|
-
.removeEmptyTextStyle()
|
|
46
|
-
.run();
|
|
47
|
-
},
|
|
48
|
-
};
|
|
49
|
-
},
|
|
50
|
-
});
|
|
51
|
-
|
|
52
|
-
exports.FontFamily = FontFamily;
|
|
53
|
-
exports["default"] = FontFamily;
|
|
54
|
-
|
|
55
|
-
Object.defineProperty(exports, '__esModule', { value: true });
|
|
56
|
-
|
|
57
|
-
}));
|
|
58
|
-
//# sourceMappingURL=tiptap-extension-font-family.umd.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"tiptap-extension-font-family.umd.js","sources":["../src/font-family.ts"],"sourcesContent":["import '@tiptap/extension-text-style'\n\nimport { Extension } from '@tiptap/core'\n\nexport type FontFamilyOptions = {\n types: string[],\n}\n\ndeclare module '@tiptap/core' {\n interface Commands<ReturnType> {\n fontFamily: {\n /**\n * Set the font family\n */\n setFontFamily: (fontFamily: string) => ReturnType,\n /**\n * Unset the font family\n */\n unsetFontFamily: () => ReturnType,\n }\n }\n}\n\nexport const FontFamily = Extension.create<FontFamilyOptions>({\n name: 'fontFamily',\n\n addOptions() {\n return {\n types: ['textStyle'],\n }\n },\n\n addGlobalAttributes() {\n return [\n {\n types: this.options.types,\n attributes: {\n fontFamily: {\n default: null,\n parseHTML: element => element.style.fontFamily?.replace(/['\"]+/g, ''),\n renderHTML: attributes => {\n if (!attributes.fontFamily) {\n return {}\n }\n\n return {\n style: `font-family: ${attributes.fontFamily}`,\n }\n },\n },\n },\n },\n ]\n },\n\n addCommands() {\n return {\n setFontFamily: fontFamily => ({ chain }) => {\n return chain()\n .setMark('textStyle', { fontFamily })\n .run()\n },\n unsetFontFamily: () => ({ chain }) => {\n return chain()\n .setMark('textStyle', { fontFamily: null })\n .removeEmptyTextStyle()\n .run()\n },\n }\n },\n})\n"],"names":["Extension"],"mappings":";;;;;;AAuBa,QAAA,UAAU,GAAGA,cAAS,CAAC,MAAM,CAAoB;EAC5D,IAAA,IAAI,EAAE,YAAY;MAElB,UAAU,GAAA;UACR,OAAO;cACL,KAAK,EAAE,CAAC,WAAW,CAAC;WACrB,CAAA;OACF;MAED,mBAAmB,GAAA;UACjB,OAAO;EACL,YAAA;EACE,gBAAA,KAAK,EAAE,IAAI,CAAC,OAAO,CAAC,KAAK;EACzB,gBAAA,UAAU,EAAE;EACV,oBAAA,UAAU,EAAE;EACV,wBAAA,OAAO,EAAE,IAAI;0BACb,SAAS,EAAE,OAAO,cAAI,OAAA,CAAA,EAAA,GAAA,OAAO,CAAC,KAAK,CAAC,UAAU,MAAA,IAAA,IAAA,EAAA,KAAA,KAAA,CAAA,GAAA,KAAA,CAAA,GAAA,EAAA,CAAE,OAAO,CAAC,QAAQ,EAAE,EAAE,CAAC,CAAA,EAAA;0BACrE,UAAU,EAAE,UAAU,IAAG;EACvB,4BAAA,IAAI,CAAC,UAAU,CAAC,UAAU,EAAE;EAC1B,gCAAA,OAAO,EAAE,CAAA;EACV,6BAAA;8BAED,OAAO;EACL,gCAAA,KAAK,EAAE,CAAA,aAAA,EAAgB,UAAU,CAAC,UAAU,CAAE,CAAA;+BAC/C,CAAA;2BACF;EACF,qBAAA;EACF,iBAAA;EACF,aAAA;WACF,CAAA;OACF;MAED,WAAW,GAAA;UACT,OAAO;cACL,aAAa,EAAE,UAAU,IAAI,CAAC,EAAE,KAAK,EAAE,KAAI;EACzC,gBAAA,OAAO,KAAK,EAAE;EACX,qBAAA,OAAO,CAAC,WAAW,EAAE,EAAE,UAAU,EAAE,CAAC;EACpC,qBAAA,GAAG,EAAE,CAAA;eACT;cACD,eAAe,EAAE,MAAM,CAAC,EAAE,KAAK,EAAE,KAAI;EACnC,gBAAA,OAAO,KAAK,EAAE;uBACX,OAAO,CAAC,WAAW,EAAE,EAAE,UAAU,EAAE,IAAI,EAAE,CAAC;EAC1C,qBAAA,oBAAoB,EAAE;EACtB,qBAAA,GAAG,EAAE,CAAA;eACT;WACF,CAAA;OACF;EACF,CAAA;;;;;;;;;;;"}
|