@tiptap/extension-font-family 2.0.0-beta.9 → 2.0.0-rc.2

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/README.md CHANGED
@@ -5,10 +5,10 @@
5
5
  [![Sponsor](https://img.shields.io/static/v1?label=Sponsor&message=%E2%9D%A4&logo=GitHub)](https://github.com/sponsors/ueberdosis)
6
6
 
7
7
  ## Introduction
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*.
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
- ## Offical Documentation
11
- Documentation can be found on the [tiptap website](https://tiptap.dev).
10
+ ## Official Documentation
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/blob/main/LICENSE.md).
14
+ Tiptap is open sourced software licensed under the [MIT license](https://github.com/ueberdosis/tiptap/blob/main/LICENSE.md).
@@ -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
- defaultOptions: {
11
- types: ['textStyle'],
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.default = FontFamily;
55
- //# sourceMappingURL=tiptap-extension-font-family.cjs.js.map
54
+ exports["default"] = FontFamily;
55
+ //# sourceMappingURL=index.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.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,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
- defaultOptions: {
7
- types: ['textStyle'],
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 FontFamily;
50
- export { FontFamily };
51
- //# sourceMappingURL=tiptap-extension-font-family.esm.js.map
49
+ export { FontFamily, FontFamily as default };
50
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.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/core'), require('@tiptap/extension-text-style')) :
3
- typeof define === 'function' && define.amd ? define(['exports', '@tiptap/core', '@tiptap/extension-text-style'], factory) :
4
- (global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory(global['@tiptap/extension-font-family'] = {}, global.core));
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
- defaultOptions: {
10
- types: ['textStyle'],
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.default = FontFamily;
53
+ exports["default"] = FontFamily;
54
54
 
55
55
  Object.defineProperty(exports, '__esModule', { value: true });
56
56
 
57
- })));
58
- //# sourceMappingURL=tiptap-extension-font-family.umd.js.map
57
+ }));
58
+ //# sourceMappingURL=index.umd.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.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;;;;;;;;;;;"}
@@ -1,21 +1,20 @@
1
- import { Command, Extension } from '@tiptap/core';
2
1
  import '@tiptap/extension-text-style';
3
- declare type FontFamilyOptions = {
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) => Command;
12
+ setFontFamily: (fontFamily: string) => ReturnType;
13
13
  /**
14
14
  * Unset the font family
15
15
  */
16
- unsetFontFamily: () => Command;
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>;
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.9",
4
+ "version": "2.0.0-rc.2",
5
5
  "homepage": "https://tiptap.dev",
6
6
  "keywords": [
7
7
  "tiptap",
@@ -12,24 +12,37 @@
12
12
  "type": "github",
13
13
  "url": "https://github.com/sponsors/ueberdosis"
14
14
  },
15
- "main": "dist/tiptap-extension-font-family.cjs.js",
16
- "umd": "dist/tiptap-extension-font-family.umd.js",
17
- "module": "dist/tiptap-extension-font-family.esm.js",
18
- "types": "dist/packages/extension-font-family/src/index.d.ts",
15
+ "type": "module",
19
16
  "exports": {
20
17
  ".": {
21
- "import": "./dist/tiptap-extension-font-family.esm.js",
22
- "require": "./dist/tiptap-extension-font-family.cjs.js",
23
- "default": "./dist/tiptap-extension-font-family.esm.js"
18
+ "types": "./dist/packages/extension-font-family/src/index.d.ts",
19
+ "import": "./dist/index.js",
20
+ "require": "./dist/index.cjs"
24
21
  }
25
22
  },
23
+ "main": "dist/index.cjs",
24
+ "module": "dist/index.js",
25
+ "umd": "dist/index.umd.js",
26
+ "types": "dist/packages/extension-font-family/src/index.d.ts",
26
27
  "files": [
27
28
  "src",
28
29
  "dist"
29
30
  ],
30
31
  "peerDependencies": {
31
- "@tiptap/core": "^2.0.0-beta.1",
32
- "@tiptap/extension-text-style": "^2.0.0-beta.1"
32
+ "@tiptap/core": "^2.0.0-rc.1",
33
+ "@tiptap/extension-text-style": "^2.0.0-rc.1"
34
+ },
35
+ "devDependencies": {
36
+ "@tiptap/core": "^2.0.0-rc.1",
37
+ "@tiptap/extension-text-style": "^2.0.0-rc.1"
38
+ },
39
+ "repository": {
40
+ "type": "git",
41
+ "url": "https://github.com/ueberdosis/tiptap",
42
+ "directory": "packages/extension-font-family"
33
43
  },
34
- "gitHead": "c86e4119cd680505652e8352e9f39622ee26a999"
35
- }
44
+ "scripts": {
45
+ "clean": "rm -rf dist",
46
+ "build": "npm run clean && rollup -c"
47
+ }
48
+ }
@@ -1,21 +1,22 @@
1
- import { Command, Extension } from '@tiptap/core'
2
1
  import '@tiptap/extension-text-style'
3
2
 
4
- type FontFamilyOptions = {
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) => Command,
15
+ setFontFamily: (fontFamily: string) => ReturnType,
15
16
  /**
16
17
  * Unset the font family
17
18
  */
18
- unsetFontFamily: () => Command,
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
- defaultOptions: {
27
- types: ['textStyle'],
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,185 +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.9](https://github.com/ueberdosis/tiptap/compare/@tiptap/extension-font-family@2.0.0-beta.8...@tiptap/extension-font-family@2.0.0-beta.9) (2021-05-06)
7
-
8
-
9
- ### Bug Fixes
10
-
11
- * revert adding type: module ([f8d6475](https://github.com/ueberdosis/tiptap/commit/f8d6475e2151faea6f96baecdd6bd75880d50d2c))
12
-
13
-
14
-
15
-
16
-
17
- # [2.0.0-beta.8](https://github.com/ueberdosis/tiptap/compare/@tiptap/extension-font-family@2.0.0-beta.7...@tiptap/extension-font-family@2.0.0-beta.8) (2021-05-06)
18
-
19
-
20
- ### Bug Fixes
21
-
22
- * add exports to package.json ([1277fa4](https://github.com/ueberdosis/tiptap/commit/1277fa47151e9c039508cdb219bdd0ffe647f4ee))
23
-
24
-
25
-
26
-
27
-
28
- # [2.0.0-beta.7](https://github.com/ueberdosis/tiptap/compare/@tiptap/extension-font-family@2.0.0-beta.6...@tiptap/extension-font-family@2.0.0-beta.7) (2021-05-06)
29
-
30
- **Note:** Version bump only for package @tiptap/extension-font-family
31
-
32
-
33
-
34
-
35
-
36
- # [2.0.0-beta.6](https://github.com/ueberdosis/tiptap/compare/@tiptap/extension-font-family@2.0.0-beta.5...@tiptap/extension-font-family@2.0.0-beta.6) (2021-05-05)
37
-
38
- **Note:** Version bump only for package @tiptap/extension-font-family
39
-
40
-
41
-
42
-
43
-
44
- # [2.0.0-beta.5](https://github.com/ueberdosis/tiptap/compare/@tiptap/extension-font-family@2.0.0-beta.4...@tiptap/extension-font-family@2.0.0-beta.5) (2021-04-23)
45
-
46
- **Note:** Version bump only for package @tiptap/extension-font-family
47
-
48
-
49
-
50
-
51
-
52
- # [2.0.0-beta.4](https://github.com/ueberdosis/tiptap/compare/@tiptap/extension-font-family@2.0.0-beta.3...@tiptap/extension-font-family@2.0.0-beta.4) (2021-04-22)
53
-
54
- **Note:** Version bump only for package @tiptap/extension-font-family
55
-
56
-
57
-
58
-
59
-
60
- # [2.0.0-beta.3](https://github.com/ueberdosis/tiptap/compare/@tiptap/extension-font-family@2.0.0-beta.2...@tiptap/extension-font-family@2.0.0-beta.3) (2021-04-16)
61
-
62
- **Note:** Version bump only for package @tiptap/extension-font-family
63
-
64
-
65
-
66
-
67
-
68
- # [2.0.0-beta.2](https://github.com/ueberdosis/tiptap/compare/@tiptap/extension-font-family@2.0.0-beta.1...@tiptap/extension-font-family@2.0.0-beta.2) (2021-04-15)
69
-
70
- **Note:** Version bump only for package @tiptap/extension-font-family
71
-
72
-
73
-
74
-
75
-
76
- # [2.0.0-beta.1](https://github.com/ueberdosis/tiptap/compare/@tiptap/extension-font-family@2.0.0-alpha.11...@tiptap/extension-font-family@2.0.0-beta.1) (2021-03-05)
77
-
78
- **Note:** Version bump only for package @tiptap/extension-font-family
79
-
80
-
81
-
82
-
83
-
84
- # [2.0.0-alpha.11](https://github.com/ueberdosis/tiptap/compare/@tiptap/extension-font-family@2.0.0-alpha.10...@tiptap/extension-font-family@2.0.0-alpha.11) (2021-02-16)
85
-
86
- **Note:** Version bump only for package @tiptap/extension-font-family
87
-
88
-
89
-
90
-
91
-
92
- # [2.0.0-alpha.10](https://github.com/ueberdosis/tiptap/compare/@tiptap/extension-font-family@2.0.0-alpha.9...@tiptap/extension-font-family@2.0.0-alpha.10) (2021-02-07)
93
-
94
- **Note:** Version bump only for package @tiptap/extension-font-family
95
-
96
-
97
-
98
-
99
-
100
- # [2.0.0-alpha.9](https://github.com/ueberdosis/tiptap/compare/@tiptap/extension-font-family@2.0.0-alpha.8...@tiptap/extension-font-family@2.0.0-alpha.9) (2021-02-05)
101
-
102
- **Note:** Version bump only for package @tiptap/extension-font-family
103
-
104
-
105
-
106
-
107
-
108
- # [2.0.0-alpha.8](https://github.com/ueberdosis/tiptap/compare/@tiptap/extension-font-family@2.0.0-alpha.7...@tiptap/extension-font-family@2.0.0-alpha.8) (2021-01-29)
109
-
110
- **Note:** Version bump only for package @tiptap/extension-font-family
111
-
112
-
113
-
114
-
115
-
116
- # [2.0.0-alpha.7](https://github.com/ueberdosis/tiptap/compare/@tiptap/extension-font-family@2.0.0-alpha.6...@tiptap/extension-font-family@2.0.0-alpha.7) (2021-01-29)
117
-
118
- **Note:** Version bump only for package @tiptap/extension-font-family
119
-
120
-
121
-
122
-
123
-
124
- # [2.0.0-alpha.6](https://github.com/ueberdosis/tiptap/compare/@tiptap/extension-font-family@2.0.0-alpha.5...@tiptap/extension-font-family@2.0.0-alpha.6) (2021-01-28)
125
-
126
- **Note:** Version bump only for package @tiptap/extension-font-family
127
-
128
-
129
-
130
-
131
-
132
- # [2.0.0-alpha.5](https://github.com/ueberdosis/tiptap/compare/@tiptap/extension-font-family@2.0.0-alpha.4...@tiptap/extension-font-family@2.0.0-alpha.5) (2020-12-18)
133
-
134
- **Note:** Version bump only for package @tiptap/extension-font-family
135
-
136
-
137
-
138
-
139
-
140
- # [2.0.0-alpha.4](https://github.com/ueberdosis/tiptap/compare/@tiptap/extension-font-family@2.0.0-alpha.3...@tiptap/extension-font-family@2.0.0-alpha.4) (2020-12-02)
141
-
142
- **Note:** Version bump only for package @tiptap/extension-font-family
143
-
144
-
145
-
146
-
147
-
148
- # [2.0.0-alpha.3](https://github.com/ueberdosis/tiptap/compare/@tiptap/extension-font-family@2.0.0-alpha.2...@tiptap/extension-font-family@2.0.0-alpha.3) (2020-11-19)
149
-
150
- **Note:** Version bump only for package @tiptap/extension-font-family
151
-
152
-
153
-
154
-
155
-
156
- # [2.0.0-alpha.2](https://github.com/ueberdosis/tiptap/compare/@tiptap/extension-font-family@2.0.0-alpha.1...@tiptap/extension-font-family@2.0.0-alpha.2) (2020-11-19)
157
-
158
- **Note:** Version bump only for package @tiptap/extension-font-family
159
-
160
-
161
-
162
-
163
-
164
- # [2.0.0-alpha.1](https://github.com/ueberdosis/tiptap/compare/@tiptap/extension-font-family@1.0.0-alpha.2...@tiptap/extension-font-family@2.0.0-alpha.1) (2020-11-18)
165
-
166
- **Note:** Version bump only for package @tiptap/extension-font-family
167
-
168
-
169
-
170
-
171
-
172
- # [1.0.0-alpha.2](https://github.com/ueberdosis/tiptap/compare/@tiptap/extension-font-family@1.0.0-alpha.1...@tiptap/extension-font-family@1.0.0-alpha.2) (2020-11-16)
173
-
174
- **Note:** Version bump only for package @tiptap/extension-font-family
175
-
176
-
177
-
178
-
179
-
180
- # 1.0.0-alpha.1 (2020-11-16)
181
-
182
-
183
- ### Reverts
184
-
185
- * Revert "use global namespace" ([0c9ce26](https://github.com/ueberdosis/tiptap/commit/0c9ce26c02c07d88a757c01b0a9d7f9e2b0b7502))
package/LICENSE.md DELETED
@@ -1,21 +0,0 @@
1
- MIT License
2
-
3
- Copyright (c) 2021, überdosis GbR
4
-
5
- Permission is hereby granted, free of charge, to any person obtaining a copy
6
- of this software and associated documentation files (the "Software"), to deal
7
- in the Software without restriction, including without limitation the rights
8
- to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
- copies of the Software, and to permit persons to whom the Software is
10
- furnished to do so, subject to the following conditions:
11
-
12
- The above copyright notice and this permission notice shall be included in all
13
- copies or substantial portions of the Software.
14
-
15
- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
- IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
- FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
- AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
- LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
- OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
- SOFTWARE.
@@ -1 +0,0 @@
1
- {"version":3,"file":"tiptap-extension-font-family.cjs.js","sources":["../src/font-family.ts"],"sourcesContent":["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":["Extension"],"mappings":";;;;;;;MAsBa,UAAU,GAAGA,cAAS,CAAC,MAAM,CAAoB;IAC5D,IAAI,EAAE,YAAY;IAElB,cAAc,EAAE;QACd,KAAK,EAAE,CAAC,WAAW,CAAC;KACrB;IAED,mBAAmB;QACjB,OAAO;YACL;gBACE,KAAK,EAAE,IAAI,CAAC,OAAO,CAAC,KAAK;gBACzB,UAAU,EAAE;oBACV,UAAU,EAAE;wBACV,OAAO,EAAE,IAAI;wBACb,UAAU,EAAE,UAAU;4BACpB,IAAI,CAAC,UAAU,CAAC,UAAU,EAAE;gCAC1B,OAAO,EAAE,CAAA;6BACV;4BAED,OAAO;gCACL,KAAK,EAAE,gBAAgB,UAAU,CAAC,UAAU,EAAE;6BAC/C,CAAA;yBACF;wBACD,SAAS,EAAE,OAAO,KAAK;4BACrB,UAAU,EAAE,OAAO,CAAC,KAAK,CAAC,UAAU,CAAC,OAAO,CAAC,QAAQ,EAAE,EAAE,CAAC;yBAC3D,CAAC;qBACH;iBACF;aACF;SACF,CAAA;KACF;IAED,WAAW;QACT,OAAO;YACL,aAAa,EAAE,UAAU,IAAI,CAAC,EAAE,KAAK,EAAE;gBACrC,OAAO,KAAK,EAAE;qBACX,OAAO,CAAC,WAAW,EAAE,EAAE,UAAU,EAAE,CAAC;qBACpC,GAAG,EAAE,CAAA;aACT;YACD,eAAe,EAAE,MAAM,CAAC,EAAE,KAAK,EAAE;gBAC/B,OAAO,KAAK,EAAE;qBACX,OAAO,CAAC,WAAW,EAAE,EAAE,UAAU,EAAE,IAAI,EAAE,CAAC;qBAC1C,oBAAoB,EAAE;qBACtB,GAAG,EAAE,CAAA;aACT;SACF,CAAA;KACF;CACF;;;;;"}
@@ -1 +0,0 @@
1
- {"version":3,"file":"tiptap-extension-font-family.esm.js","sources":["../src/font-family.ts"],"sourcesContent":["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":[],"mappings":";;;MAsBa,UAAU,GAAG,SAAS,CAAC,MAAM,CAAoB;IAC5D,IAAI,EAAE,YAAY;IAElB,cAAc,EAAE;QACd,KAAK,EAAE,CAAC,WAAW,CAAC;KACrB;IAED,mBAAmB;QACjB,OAAO;YACL;gBACE,KAAK,EAAE,IAAI,CAAC,OAAO,CAAC,KAAK;gBACzB,UAAU,EAAE;oBACV,UAAU,EAAE;wBACV,OAAO,EAAE,IAAI;wBACb,UAAU,EAAE,UAAU;4BACpB,IAAI,CAAC,UAAU,CAAC,UAAU,EAAE;gCAC1B,OAAO,EAAE,CAAA;6BACV;4BAED,OAAO;gCACL,KAAK,EAAE,gBAAgB,UAAU,CAAC,UAAU,EAAE;6BAC/C,CAAA;yBACF;wBACD,SAAS,EAAE,OAAO,KAAK;4BACrB,UAAU,EAAE,OAAO,CAAC,KAAK,CAAC,UAAU,CAAC,OAAO,CAAC,QAAQ,EAAE,EAAE,CAAC;yBAC3D,CAAC;qBACH;iBACF;aACF;SACF,CAAA;KACF;IAED,WAAW;QACT,OAAO;YACL,aAAa,EAAE,UAAU,IAAI,CAAC,EAAE,KAAK,EAAE;gBACrC,OAAO,KAAK,EAAE;qBACX,OAAO,CAAC,WAAW,EAAE,EAAE,UAAU,EAAE,CAAC;qBACpC,GAAG,EAAE,CAAA;aACT;YACD,eAAe,EAAE,MAAM,CAAC,EAAE,KAAK,EAAE;gBAC/B,OAAO,KAAK,EAAE;qBACX,OAAO,CAAC,WAAW,EAAE,EAAE,UAAU,EAAE,IAAI,EAAE,CAAC;qBAC1C,oBAAoB,EAAE;qBACtB,GAAG,EAAE,CAAA;aACT;SACF,CAAA;KACF;CACF;;;;;"}
@@ -1 +0,0 @@
1
- {"version":3,"file":"tiptap-extension-font-family.umd.js","sources":["../src/font-family.ts"],"sourcesContent":["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":["Extension"],"mappings":";;;;;;QAsBa,UAAU,GAAGA,cAAS,CAAC,MAAM,CAAoB;MAC5D,IAAI,EAAE,YAAY;MAElB,cAAc,EAAE;UACd,KAAK,EAAE,CAAC,WAAW,CAAC;OACrB;MAED,mBAAmB;UACjB,OAAO;cACL;kBACE,KAAK,EAAE,IAAI,CAAC,OAAO,CAAC,KAAK;kBACzB,UAAU,EAAE;sBACV,UAAU,EAAE;0BACV,OAAO,EAAE,IAAI;0BACb,UAAU,EAAE,UAAU;8BACpB,IAAI,CAAC,UAAU,CAAC,UAAU,EAAE;kCAC1B,OAAO,EAAE,CAAA;+BACV;8BAED,OAAO;kCACL,KAAK,EAAE,gBAAgB,UAAU,CAAC,UAAU,EAAE;+BAC/C,CAAA;2BACF;0BACD,SAAS,EAAE,OAAO,KAAK;8BACrB,UAAU,EAAE,OAAO,CAAC,KAAK,CAAC,UAAU,CAAC,OAAO,CAAC,QAAQ,EAAE,EAAE,CAAC;2BAC3D,CAAC;uBACH;mBACF;eACF;WACF,CAAA;OACF;MAED,WAAW;UACT,OAAO;cACL,aAAa,EAAE,UAAU,IAAI,CAAC,EAAE,KAAK,EAAE;kBACrC,OAAO,KAAK,EAAE;uBACX,OAAO,CAAC,WAAW,EAAE,EAAE,UAAU,EAAE,CAAC;uBACpC,GAAG,EAAE,CAAA;eACT;cACD,eAAe,EAAE,MAAM,CAAC,EAAE,KAAK,EAAE;kBAC/B,OAAO,KAAK,EAAE;uBACX,OAAO,CAAC,WAAW,EAAE,EAAE,UAAU,EAAE,IAAI,EAAE,CAAC;uBAC1C,oBAAoB,EAAE;uBACtB,GAAG,EAAE,CAAA;eACT;WACF,CAAA;OACF;GACF;;;;;;;;;;;"}