@tiptap/extension-font-family 2.0.0-beta.2 → 2.0.0-beta.24
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/LICENSE.md +1 -1
- package/README.md +2 -2
- package/dist/packages/extension-font-family/src/font-family.d.ts +6 -7
- package/dist/tiptap-extension-font-family.cjs.js +7 -7
- package/dist/tiptap-extension-font-family.cjs.js.map +1 -1
- package/dist/tiptap-extension-font-family.esm.js +7 -8
- package/dist/tiptap-extension-font-family.esm.js.map +1 -1
- package/dist/tiptap-extension-font-family.umd.js +11 -11
- package/dist/tiptap-extension-font-family.umd.js.map +1 -1
- package/package.json +7 -3
- package/src/font-family.ts +11 -10
- package/CHANGELOG.md +0 -123
- package/dist/tiptap-extension-font-family.bundle.umd.min.js +0 -2
- package/dist/tiptap-extension-font-family.bundle.umd.min.js.map +0 -1
package/LICENSE.md
CHANGED
package/README.md
CHANGED
|
@@ -7,8 +7,8 @@
|
|
|
7
7
|
## Introduction
|
|
8
8
|
tiptap is a headless wrapper around [ProseMirror](https://ProseMirror.net) – a toolkit for building rich text WYSIWYG editors, which is already in use at many well-known companies such as *New York Times*, *The Guardian* or *Atlassian*.
|
|
9
9
|
|
|
10
|
-
##
|
|
10
|
+
## Official Documentation
|
|
11
11
|
Documentation can be found on the [tiptap website](https://tiptap.dev).
|
|
12
12
|
|
|
13
13
|
## License
|
|
14
|
-
tiptap is open sourced software licensed under the [MIT license](https://github.com/ueberdosis/tiptap
|
|
14
|
+
tiptap is open sourced software licensed under the [MIT license](https://github.com/ueberdosis/tiptap/blob/main/LICENSE.md).
|
|
@@ -1,21 +1,20 @@
|
|
|
1
|
-
import { Command, Extension } from '@tiptap/core';
|
|
2
1
|
import '@tiptap/extension-text-style';
|
|
3
|
-
|
|
2
|
+
import { Extension } from '@tiptap/core';
|
|
3
|
+
export declare type FontFamilyOptions = {
|
|
4
4
|
types: string[];
|
|
5
5
|
};
|
|
6
6
|
declare module '@tiptap/core' {
|
|
7
|
-
interface Commands {
|
|
7
|
+
interface Commands<ReturnType> {
|
|
8
8
|
fontFamily: {
|
|
9
9
|
/**
|
|
10
10
|
* Set the font family
|
|
11
11
|
*/
|
|
12
|
-
setFontFamily: (fontFamily: string) =>
|
|
12
|
+
setFontFamily: (fontFamily: string) => ReturnType;
|
|
13
13
|
/**
|
|
14
14
|
* Unset the font family
|
|
15
15
|
*/
|
|
16
|
-
unsetFontFamily: () =>
|
|
16
|
+
unsetFontFamily: () => ReturnType;
|
|
17
17
|
};
|
|
18
18
|
}
|
|
19
19
|
}
|
|
20
|
-
export declare const FontFamily: Extension<FontFamilyOptions>;
|
|
21
|
-
export {};
|
|
20
|
+
export declare const FontFamily: Extension<FontFamilyOptions, any>;
|
|
@@ -2,13 +2,15 @@
|
|
|
2
2
|
|
|
3
3
|
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
4
|
|
|
5
|
-
var core = require('@tiptap/core');
|
|
6
5
|
require('@tiptap/extension-text-style');
|
|
6
|
+
var core = require('@tiptap/core');
|
|
7
7
|
|
|
8
8
|
const FontFamily = core.Extension.create({
|
|
9
9
|
name: 'fontFamily',
|
|
10
|
-
|
|
11
|
-
|
|
10
|
+
addOptions() {
|
|
11
|
+
return {
|
|
12
|
+
types: ['textStyle'],
|
|
13
|
+
};
|
|
12
14
|
},
|
|
13
15
|
addGlobalAttributes() {
|
|
14
16
|
return [
|
|
@@ -17,6 +19,7 @@ const FontFamily = core.Extension.create({
|
|
|
17
19
|
attributes: {
|
|
18
20
|
fontFamily: {
|
|
19
21
|
default: null,
|
|
22
|
+
parseHTML: element => { var _a; return (_a = element.style.fontFamily) === null || _a === void 0 ? void 0 : _a.replace(/['"]+/g, ''); },
|
|
20
23
|
renderHTML: attributes => {
|
|
21
24
|
if (!attributes.fontFamily) {
|
|
22
25
|
return {};
|
|
@@ -25,9 +28,6 @@ const FontFamily = core.Extension.create({
|
|
|
25
28
|
style: `font-family: ${attributes.fontFamily}`,
|
|
26
29
|
};
|
|
27
30
|
},
|
|
28
|
-
parseHTML: element => ({
|
|
29
|
-
fontFamily: element.style.fontFamily.replace(/['"]+/g, ''),
|
|
30
|
-
}),
|
|
31
31
|
},
|
|
32
32
|
},
|
|
33
33
|
},
|
|
@@ -51,5 +51,5 @@ const FontFamily = core.Extension.create({
|
|
|
51
51
|
});
|
|
52
52
|
|
|
53
53
|
exports.FontFamily = FontFamily;
|
|
54
|
-
exports
|
|
54
|
+
exports["default"] = FontFamily;
|
|
55
55
|
//# sourceMappingURL=tiptap-extension-font-family.cjs.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"tiptap-extension-font-family.cjs.js","sources":["../src/font-family.ts"],"sourcesContent":["import {
|
|
1
|
+
{"version":3,"file":"tiptap-extension-font-family.cjs.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,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,10 +1,12 @@
|
|
|
1
|
-
import { Extension } from '@tiptap/core';
|
|
2
1
|
import '@tiptap/extension-text-style';
|
|
2
|
+
import { Extension } from '@tiptap/core';
|
|
3
3
|
|
|
4
4
|
const FontFamily = Extension.create({
|
|
5
5
|
name: 'fontFamily',
|
|
6
|
-
|
|
7
|
-
|
|
6
|
+
addOptions() {
|
|
7
|
+
return {
|
|
8
|
+
types: ['textStyle'],
|
|
9
|
+
};
|
|
8
10
|
},
|
|
9
11
|
addGlobalAttributes() {
|
|
10
12
|
return [
|
|
@@ -13,6 +15,7 @@ const FontFamily = Extension.create({
|
|
|
13
15
|
attributes: {
|
|
14
16
|
fontFamily: {
|
|
15
17
|
default: null,
|
|
18
|
+
parseHTML: element => { var _a; return (_a = element.style.fontFamily) === null || _a === void 0 ? void 0 : _a.replace(/['"]+/g, ''); },
|
|
16
19
|
renderHTML: attributes => {
|
|
17
20
|
if (!attributes.fontFamily) {
|
|
18
21
|
return {};
|
|
@@ -21,9 +24,6 @@ const FontFamily = Extension.create({
|
|
|
21
24
|
style: `font-family: ${attributes.fontFamily}`,
|
|
22
25
|
};
|
|
23
26
|
},
|
|
24
|
-
parseHTML: element => ({
|
|
25
|
-
fontFamily: element.style.fontFamily.replace(/['"]+/g, ''),
|
|
26
|
-
}),
|
|
27
27
|
},
|
|
28
28
|
},
|
|
29
29
|
},
|
|
@@ -46,6 +46,5 @@ const FontFamily = Extension.create({
|
|
|
46
46
|
},
|
|
47
47
|
});
|
|
48
48
|
|
|
49
|
-
export default
|
|
50
|
-
export { FontFamily };
|
|
49
|
+
export { FontFamily, FontFamily as default };
|
|
51
50
|
//# sourceMappingURL=tiptap-extension-font-family.esm.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"tiptap-extension-font-family.esm.js","sources":["../src/font-family.ts"],"sourcesContent":["import {
|
|
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,13 +1,15 @@
|
|
|
1
1
|
(function (global, factory) {
|
|
2
|
-
typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports, require('@tiptap/
|
|
3
|
-
typeof define === 'function' && define.amd ? define(['exports', '@tiptap/
|
|
4
|
-
(global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory(global[
|
|
5
|
-
}(this, (function (exports, core) { 'use strict';
|
|
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
6
|
|
|
7
7
|
const FontFamily = core.Extension.create({
|
|
8
8
|
name: 'fontFamily',
|
|
9
|
-
|
|
10
|
-
|
|
9
|
+
addOptions() {
|
|
10
|
+
return {
|
|
11
|
+
types: ['textStyle'],
|
|
12
|
+
};
|
|
11
13
|
},
|
|
12
14
|
addGlobalAttributes() {
|
|
13
15
|
return [
|
|
@@ -16,6 +18,7 @@
|
|
|
16
18
|
attributes: {
|
|
17
19
|
fontFamily: {
|
|
18
20
|
default: null,
|
|
21
|
+
parseHTML: element => { var _a; return (_a = element.style.fontFamily) === null || _a === void 0 ? void 0 : _a.replace(/['"]+/g, ''); },
|
|
19
22
|
renderHTML: attributes => {
|
|
20
23
|
if (!attributes.fontFamily) {
|
|
21
24
|
return {};
|
|
@@ -24,9 +27,6 @@
|
|
|
24
27
|
style: `font-family: ${attributes.fontFamily}`,
|
|
25
28
|
};
|
|
26
29
|
},
|
|
27
|
-
parseHTML: element => ({
|
|
28
|
-
fontFamily: element.style.fontFamily.replace(/['"]+/g, ''),
|
|
29
|
-
}),
|
|
30
30
|
},
|
|
31
31
|
},
|
|
32
32
|
},
|
|
@@ -50,9 +50,9 @@
|
|
|
50
50
|
});
|
|
51
51
|
|
|
52
52
|
exports.FontFamily = FontFamily;
|
|
53
|
-
exports
|
|
53
|
+
exports["default"] = FontFamily;
|
|
54
54
|
|
|
55
55
|
Object.defineProperty(exports, '__esModule', { value: true });
|
|
56
56
|
|
|
57
|
-
}))
|
|
57
|
+
}));
|
|
58
58
|
//# sourceMappingURL=tiptap-extension-font-family.umd.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"tiptap-extension-font-family.umd.js","sources":["../src/font-family.ts"],"sourcesContent":["import {
|
|
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;;;;;;;;;;;"}
|
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.24",
|
|
5
5
|
"homepage": "https://tiptap.dev",
|
|
6
6
|
"keywords": [
|
|
7
7
|
"tiptap",
|
|
@@ -15,7 +15,6 @@
|
|
|
15
15
|
"main": "dist/tiptap-extension-font-family.cjs.js",
|
|
16
16
|
"umd": "dist/tiptap-extension-font-family.umd.js",
|
|
17
17
|
"module": "dist/tiptap-extension-font-family.esm.js",
|
|
18
|
-
"unpkg": "dist/tiptap-extension-font-family.bundle.umd.min.js",
|
|
19
18
|
"types": "dist/packages/extension-font-family/src/index.d.ts",
|
|
20
19
|
"files": [
|
|
21
20
|
"src",
|
|
@@ -25,5 +24,10 @@
|
|
|
25
24
|
"@tiptap/core": "^2.0.0-beta.1",
|
|
26
25
|
"@tiptap/extension-text-style": "^2.0.0-beta.1"
|
|
27
26
|
},
|
|
28
|
-
"
|
|
27
|
+
"repository": {
|
|
28
|
+
"type": "git",
|
|
29
|
+
"url": "https://github.com/ueberdosis/tiptap",
|
|
30
|
+
"directory": "packages/extension-font-family"
|
|
31
|
+
},
|
|
32
|
+
"gitHead": "591c0807a2ab5c34b4b7fe12c12511fe4f493ebd"
|
|
29
33
|
}
|
package/src/font-family.ts
CHANGED
|
@@ -1,21 +1,22 @@
|
|
|
1
|
-
import { Command, Extension } from '@tiptap/core'
|
|
2
1
|
import '@tiptap/extension-text-style'
|
|
3
2
|
|
|
4
|
-
|
|
3
|
+
import { Extension } from '@tiptap/core'
|
|
4
|
+
|
|
5
|
+
export type FontFamilyOptions = {
|
|
5
6
|
types: string[],
|
|
6
7
|
}
|
|
7
8
|
|
|
8
9
|
declare module '@tiptap/core' {
|
|
9
|
-
interface Commands {
|
|
10
|
+
interface Commands<ReturnType> {
|
|
10
11
|
fontFamily: {
|
|
11
12
|
/**
|
|
12
13
|
* Set the font family
|
|
13
14
|
*/
|
|
14
|
-
setFontFamily: (fontFamily: string) =>
|
|
15
|
+
setFontFamily: (fontFamily: string) => ReturnType,
|
|
15
16
|
/**
|
|
16
17
|
* Unset the font family
|
|
17
18
|
*/
|
|
18
|
-
unsetFontFamily: () =>
|
|
19
|
+
unsetFontFamily: () => ReturnType,
|
|
19
20
|
}
|
|
20
21
|
}
|
|
21
22
|
}
|
|
@@ -23,8 +24,10 @@ declare module '@tiptap/core' {
|
|
|
23
24
|
export const FontFamily = Extension.create<FontFamilyOptions>({
|
|
24
25
|
name: 'fontFamily',
|
|
25
26
|
|
|
26
|
-
|
|
27
|
-
|
|
27
|
+
addOptions() {
|
|
28
|
+
return {
|
|
29
|
+
types: ['textStyle'],
|
|
30
|
+
}
|
|
28
31
|
},
|
|
29
32
|
|
|
30
33
|
addGlobalAttributes() {
|
|
@@ -34,6 +37,7 @@ export const FontFamily = Extension.create<FontFamilyOptions>({
|
|
|
34
37
|
attributes: {
|
|
35
38
|
fontFamily: {
|
|
36
39
|
default: null,
|
|
40
|
+
parseHTML: element => element.style.fontFamily?.replace(/['"]+/g, ''),
|
|
37
41
|
renderHTML: attributes => {
|
|
38
42
|
if (!attributes.fontFamily) {
|
|
39
43
|
return {}
|
|
@@ -43,9 +47,6 @@ export const FontFamily = Extension.create<FontFamilyOptions>({
|
|
|
43
47
|
style: `font-family: ${attributes.fontFamily}`,
|
|
44
48
|
}
|
|
45
49
|
},
|
|
46
|
-
parseHTML: element => ({
|
|
47
|
-
fontFamily: element.style.fontFamily.replace(/['"]+/g, ''),
|
|
48
|
-
}),
|
|
49
50
|
},
|
|
50
51
|
},
|
|
51
52
|
},
|
package/CHANGELOG.md
DELETED
|
@@ -1,123 +0,0 @@
|
|
|
1
|
-
# Change Log
|
|
2
|
-
|
|
3
|
-
All notable changes to this project will be documented in this file.
|
|
4
|
-
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
|
|
5
|
-
|
|
6
|
-
# [2.0.0-beta.2](https://github.com/ueberdosis/tiptap-next/compare/@tiptap/extension-font-family@2.0.0-beta.1...@tiptap/extension-font-family@2.0.0-beta.2) (2021-04-15)
|
|
7
|
-
|
|
8
|
-
**Note:** Version bump only for package @tiptap/extension-font-family
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
# [2.0.0-beta.1](https://github.com/ueberdosis/tiptap-next/compare/@tiptap/extension-font-family@2.0.0-alpha.11...@tiptap/extension-font-family@2.0.0-beta.1) (2021-03-05)
|
|
15
|
-
|
|
16
|
-
**Note:** Version bump only for package @tiptap/extension-font-family
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
# [2.0.0-alpha.11](https://github.com/ueberdosis/tiptap-next/compare/@tiptap/extension-font-family@2.0.0-alpha.10...@tiptap/extension-font-family@2.0.0-alpha.11) (2021-02-16)
|
|
23
|
-
|
|
24
|
-
**Note:** Version bump only for package @tiptap/extension-font-family
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
# [2.0.0-alpha.10](https://github.com/ueberdosis/tiptap-next/compare/@tiptap/extension-font-family@2.0.0-alpha.9...@tiptap/extension-font-family@2.0.0-alpha.10) (2021-02-07)
|
|
31
|
-
|
|
32
|
-
**Note:** Version bump only for package @tiptap/extension-font-family
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
# [2.0.0-alpha.9](https://github.com/ueberdosis/tiptap-next/compare/@tiptap/extension-font-family@2.0.0-alpha.8...@tiptap/extension-font-family@2.0.0-alpha.9) (2021-02-05)
|
|
39
|
-
|
|
40
|
-
**Note:** Version bump only for package @tiptap/extension-font-family
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
# [2.0.0-alpha.8](https://github.com/ueberdosis/tiptap-next/compare/@tiptap/extension-font-family@2.0.0-alpha.7...@tiptap/extension-font-family@2.0.0-alpha.8) (2021-01-29)
|
|
47
|
-
|
|
48
|
-
**Note:** Version bump only for package @tiptap/extension-font-family
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
# [2.0.0-alpha.7](https://github.com/ueberdosis/tiptap-next/compare/@tiptap/extension-font-family@2.0.0-alpha.6...@tiptap/extension-font-family@2.0.0-alpha.7) (2021-01-29)
|
|
55
|
-
|
|
56
|
-
**Note:** Version bump only for package @tiptap/extension-font-family
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
# [2.0.0-alpha.6](https://github.com/ueberdosis/tiptap-next/compare/@tiptap/extension-font-family@2.0.0-alpha.5...@tiptap/extension-font-family@2.0.0-alpha.6) (2021-01-28)
|
|
63
|
-
|
|
64
|
-
**Note:** Version bump only for package @tiptap/extension-font-family
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
# [2.0.0-alpha.5](https://github.com/ueberdosis/tiptap-next/compare/@tiptap/extension-font-family@2.0.0-alpha.4...@tiptap/extension-font-family@2.0.0-alpha.5) (2020-12-18)
|
|
71
|
-
|
|
72
|
-
**Note:** Version bump only for package @tiptap/extension-font-family
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
# [2.0.0-alpha.4](https://github.com/ueberdosis/tiptap-next/compare/@tiptap/extension-font-family@2.0.0-alpha.3...@tiptap/extension-font-family@2.0.0-alpha.4) (2020-12-02)
|
|
79
|
-
|
|
80
|
-
**Note:** Version bump only for package @tiptap/extension-font-family
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
# [2.0.0-alpha.3](https://github.com/ueberdosis/tiptap-next/compare/@tiptap/extension-font-family@2.0.0-alpha.2...@tiptap/extension-font-family@2.0.0-alpha.3) (2020-11-19)
|
|
87
|
-
|
|
88
|
-
**Note:** Version bump only for package @tiptap/extension-font-family
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
# [2.0.0-alpha.2](https://github.com/ueberdosis/tiptap-next/compare/@tiptap/extension-font-family@2.0.0-alpha.1...@tiptap/extension-font-family@2.0.0-alpha.2) (2020-11-19)
|
|
95
|
-
|
|
96
|
-
**Note:** Version bump only for package @tiptap/extension-font-family
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
# [2.0.0-alpha.1](https://github.com/ueberdosis/tiptap-next/compare/@tiptap/extension-font-family@1.0.0-alpha.2...@tiptap/extension-font-family@2.0.0-alpha.1) (2020-11-18)
|
|
103
|
-
|
|
104
|
-
**Note:** Version bump only for package @tiptap/extension-font-family
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
# [1.0.0-alpha.2](https://github.com/ueberdosis/tiptap-next/compare/@tiptap/extension-font-family@1.0.0-alpha.1...@tiptap/extension-font-family@1.0.0-alpha.2) (2020-11-16)
|
|
111
|
-
|
|
112
|
-
**Note:** Version bump only for package @tiptap/extension-font-family
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
# 1.0.0-alpha.1 (2020-11-16)
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
### Reverts
|
|
122
|
-
|
|
123
|
-
* Revert "use global namespace" ([0c9ce26](https://github.com/ueberdosis/tiptap-next/commit/0c9ce26c02c07d88a757c01b0a9d7f9e2b0b7502))
|
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
!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-font-family"]={},t["@tiptap/core"])}(this,(function(t,e){"use strict";e.Mark.create({name:"textStyle",defaultOptions:{HTMLAttributes:{}},parseHTML:()=>[{tag:"span",getAttrs:t=>!!t.hasAttribute("style")&&{}}],renderHTML({HTMLAttributes:t}){return["span",e.mergeAttributes(this.options.HTMLAttributes,t),0]},addCommands(){return{removeEmptyTextStyle:()=>({state:t,commands:n})=>{const a=e.getMarkAttributes(t,this.type);return!!Object.entries(a).every((([,t])=>!!t))||n.unsetMark("textStyle")}}}});const n=e.Extension.create({name:"fontFamily",defaultOptions:{types:["textStyle"]},addGlobalAttributes(){return[{types:this.options.types,attributes:{fontFamily:{default:null,renderHTML:t=>t.fontFamily?{style:`font-family: ${t.fontFamily}`}:{},parseHTML:t=>({fontFamily:t.style.fontFamily.replace(/['"]+/g,"")})}}}]},addCommands:()=>({setFontFamily:t=>({chain:e})=>e().setMark("textStyle",{fontFamily:t}).run(),unsetFontFamily:()=>({chain:t})=>t().setMark("textStyle",{fontFamily:null}).removeEmptyTextStyle().run()})});t.FontFamily=n,t.default=n,Object.defineProperty(t,"__esModule",{value:!0})}));
|
|
2
|
-
//# sourceMappingURL=tiptap-extension-font-family.bundle.umd.min.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"tiptap-extension-font-family.bundle.umd.min.js","sources":["../../extension-text-style/src/text-style.ts","../src/font-family.ts"],"sourcesContent":["import {\n Command,\n Mark,\n getMarkAttributes,\n mergeAttributes,\n} from '@tiptap/core'\n\nexport interface TextStyleOptions {\n HTMLAttributes: {\n [key: string]: any\n },\n}\n\ndeclare module '@tiptap/core' {\n interface Commands {\n textStyle: {\n /**\n * Remove spans without inline style attributes.\n */\n removeEmptyTextStyle: () => Command,\n }\n }\n}\n\nexport const TextStyle = Mark.create<TextStyleOptions>({\n name: 'textStyle',\n\n defaultOptions: {\n HTMLAttributes: {},\n },\n\n parseHTML() {\n return [\n {\n tag: 'span',\n getAttrs: element => {\n const hasStyles = (element as HTMLElement).hasAttribute('style')\n\n if (!hasStyles) {\n return false\n }\n\n return {}\n },\n },\n ]\n },\n\n renderHTML({ HTMLAttributes }) {\n return ['span', mergeAttributes(this.options.HTMLAttributes, HTMLAttributes), 0]\n },\n\n addCommands() {\n return {\n removeEmptyTextStyle: () => ({ state, commands }) => {\n const attributes = getMarkAttributes(state, this.type)\n const hasStyles = Object.entries(attributes).every(([, value]) => !!value)\n\n if (hasStyles) {\n return true\n }\n\n return commands.unsetMark('textStyle')\n },\n }\n },\n\n})\n","import { Command, Extension } from '@tiptap/core'\nimport '@tiptap/extension-text-style'\n\ntype FontFamilyOptions = {\n types: string[],\n}\n\ndeclare module '@tiptap/core' {\n interface Commands {\n fontFamily: {\n /**\n * Set the font family\n */\n setFontFamily: (fontFamily: string) => Command,\n /**\n * Unset the font family\n */\n unsetFontFamily: () => Command,\n }\n }\n}\n\nexport const FontFamily = Extension.create<FontFamilyOptions>({\n name: 'fontFamily',\n\n defaultOptions: {\n types: ['textStyle'],\n },\n\n addGlobalAttributes() {\n return [\n {\n types: this.options.types,\n attributes: {\n fontFamily: {\n default: null,\n renderHTML: attributes => {\n if (!attributes.fontFamily) {\n return {}\n }\n\n return {\n style: `font-family: ${attributes.fontFamily}`,\n }\n },\n parseHTML: element => ({\n fontFamily: element.style.fontFamily.replace(/['\"]+/g, ''),\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":["create","name","defaultOptions","HTMLAttributes","parseHTML","tag","getAttrs","element","hasAttribute","[object Object]","mergeAttributes","this","options","removeEmptyTextStyle","state","commands","attributes","getMarkAttributes","type","Object","entries","every","value","unsetMark","FontFamily","Extension","types","fontFamily","default","renderHTML","style","replace","addCommands","setFontFamily","chain","setMark","run","unsetFontFamily"],"mappings":"0UAwB8BA,OAAyB,CACrDC,KAAM,YAENC,eAAgB,CACdC,eAAgB,IAGlBC,UAAS,IACA,CACL,CACEC,IAAK,OACLC,SAAUC,KACWA,EAAwBC,aAAa,UAMjD,KAMfC,YAAWN,eAAEA,IACX,MAAO,CAAC,OAAQO,kBAAgBC,KAAKC,QAAQT,eAAgBA,GAAiB,IAGhFM,cACE,MAAO,CACLI,qBAAsB,IAAM,EAAGC,MAAAA,EAAOC,SAAAA,MACpC,MAAMC,EAAaC,oBAAkBH,EAAOH,KAAKO,MAGjD,QAFkBC,OAAOC,QAAQJ,GAAYK,OAAM,GAAIC,OAAaA,KAM7DP,EAASQ,UAAU,wBCxCrBC,EAAaC,YAAUzB,OAA0B,CAC5DC,KAAM,aAENC,eAAgB,CACdwB,MAAO,CAAC,cAGVjB,sBACE,MAAO,CACL,CACEiB,MAAOf,KAAKC,QAAQc,MACpBV,WAAY,CACVW,WAAY,CACVC,QAAS,KACTC,WAAYb,GACLA,EAAWW,WAIT,CACLG,MAAO,gBAAgBd,EAAWW,cAJ3B,GAOXvB,UAAWG,KACToB,WAAYpB,EAAQuB,MAAMH,WAAWI,QAAQ,SAAU,WAQnEC,YAAW,KACF,CACLC,cAAeN,GAAc,EAAGO,MAAAA,KACvBA,IACJC,QAAQ,YAAa,CAAER,WAAAA,IACvBS,MAELC,gBAAiB,IAAM,EAAGH,MAAAA,KACjBA,IACJC,QAAQ,YAAa,CAAER,WAAY,OACnCd,uBACAuB"}
|