@tiptap/extension-color 2.0.0-beta.213 → 2.0.0-beta.215

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 CHANGED
@@ -1,52 +1,55 @@
1
- "use strict";Object.defineProperty(exports, "__esModule", {value: true});// src/color.ts
2
- require('@tiptap/extension-text-style');
3
- var _core = require('@tiptap/core');
4
- var Color = _core.Extension.create({
5
- name: "color",
6
- addOptions() {
7
- return {
8
- types: ["textStyle"]
9
- };
10
- },
11
- addGlobalAttributes() {
12
- return [
13
- {
14
- types: this.options.types,
15
- attributes: {
16
- color: {
17
- default: null,
18
- parseHTML: (element) => {
19
- var _a;
20
- return (_a = element.style.color) == null ? void 0 : _a.replace(/['"]+/g, "");
21
- },
22
- renderHTML: (attributes) => {
23
- if (!attributes.color) {
24
- return {};
25
- }
26
- return {
27
- style: `color: ${attributes.color}`
28
- };
29
- }
30
- }
31
- }
32
- }
33
- ];
34
- },
35
- addCommands() {
36
- return {
37
- setColor: (color) => ({ chain }) => {
38
- return chain().setMark("textStyle", { color }).run();
39
- },
40
- unsetColor: () => ({ chain }) => {
41
- return chain().setMark("textStyle", { color: null }).removeEmptyTextStyle().run();
42
- }
43
- };
44
- }
45
- });
1
+ 'use strict';
46
2
 
47
- // src/index.ts
48
- var src_default = Color;
3
+ Object.defineProperty(exports, '__esModule', { value: true });
49
4
 
5
+ require('@tiptap/extension-text-style');
6
+ var core = require('@tiptap/core');
50
7
 
8
+ const Color = core.Extension.create({
9
+ name: 'color',
10
+ addOptions() {
11
+ return {
12
+ types: ['textStyle'],
13
+ };
14
+ },
15
+ addGlobalAttributes() {
16
+ return [
17
+ {
18
+ types: this.options.types,
19
+ attributes: {
20
+ color: {
21
+ default: null,
22
+ parseHTML: element => { var _a; return (_a = element.style.color) === null || _a === void 0 ? void 0 : _a.replace(/['"]+/g, ''); },
23
+ renderHTML: attributes => {
24
+ if (!attributes.color) {
25
+ return {};
26
+ }
27
+ return {
28
+ style: `color: ${attributes.color}`,
29
+ };
30
+ },
31
+ },
32
+ },
33
+ },
34
+ ];
35
+ },
36
+ addCommands() {
37
+ return {
38
+ setColor: color => ({ chain }) => {
39
+ return chain()
40
+ .setMark('textStyle', { color })
41
+ .run();
42
+ },
43
+ unsetColor: () => ({ chain }) => {
44
+ return chain()
45
+ .setMark('textStyle', { color: null })
46
+ .removeEmptyTextStyle()
47
+ .run();
48
+ },
49
+ };
50
+ },
51
+ });
51
52
 
52
- exports.Color = Color; exports.default = src_default;
53
+ exports.Color = Color;
54
+ exports["default"] = Color;
55
+ //# sourceMappingURL=index.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.cjs","sources":["../src/color.ts"],"sourcesContent":["import '@tiptap/extension-text-style'\n\nimport { Extension } from '@tiptap/core'\n\nexport type ColorOptions = {\n types: string[],\n}\n\ndeclare module '@tiptap/core' {\n interface Commands<ReturnType> {\n color: {\n /**\n * Set the text color\n */\n setColor: (color: string) => ReturnType,\n /**\n * Unset the text color\n */\n unsetColor: () => ReturnType,\n }\n }\n}\n\nexport const Color = Extension.create<ColorOptions>({\n name: 'color',\n\n addOptions() {\n return {\n types: ['textStyle'],\n }\n },\n\n addGlobalAttributes() {\n return [\n {\n types: this.options.types,\n attributes: {\n color: {\n default: null,\n parseHTML: element => element.style.color?.replace(/['\"]+/g, ''),\n renderHTML: attributes => {\n if (!attributes.color) {\n return {}\n }\n\n return {\n style: `color: ${attributes.color}`,\n }\n },\n },\n },\n },\n ]\n },\n\n addCommands() {\n return {\n setColor: color => ({ chain }) => {\n return chain()\n .setMark('textStyle', { color })\n .run()\n },\n unsetColor: () => ({ chain }) => {\n return chain()\n .setMark('textStyle', { color: null })\n .removeEmptyTextStyle()\n .run()\n },\n }\n },\n})\n"],"names":["Extension"],"mappings":";;;;;;;AAuBa,MAAA,KAAK,GAAGA,cAAS,CAAC,MAAM,CAAe;AAClD,IAAA,IAAI,EAAE,OAAO;IAEb,UAAU,GAAA;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1
- // src/color.ts
2
- import "@tiptap/extension-text-style";
3
- import { Extension } from "@tiptap/core";
4
- var Color = Extension.create({
5
- name: "color",
6
- addOptions() {
7
- return {
8
- types: ["textStyle"]
9
- };
10
- },
11
- addGlobalAttributes() {
12
- return [
13
- {
14
- types: this.options.types,
15
- attributes: {
16
- color: {
17
- default: null,
18
- parseHTML: (element) => {
19
- var _a;
20
- return (_a = element.style.color) == null ? void 0 : _a.replace(/['"]+/g, "");
21
- },
22
- renderHTML: (attributes) => {
23
- if (!attributes.color) {
24
- return {};
25
- }
26
- return {
27
- style: `color: ${attributes.color}`
28
- };
29
- }
30
- }
31
- }
32
- }
33
- ];
34
- },
35
- addCommands() {
36
- return {
37
- setColor: (color) => ({ chain }) => {
38
- return chain().setMark("textStyle", { color }).run();
39
- },
40
- unsetColor: () => ({ chain }) => {
41
- return chain().setMark("textStyle", { color: null }).removeEmptyTextStyle().run();
42
- }
43
- };
44
- }
1
+ import '@tiptap/extension-text-style';
2
+ import { Extension } from '@tiptap/core';
3
+
4
+ const Color = Extension.create({
5
+ name: 'color',
6
+ addOptions() {
7
+ return {
8
+ types: ['textStyle'],
9
+ };
10
+ },
11
+ addGlobalAttributes() {
12
+ return [
13
+ {
14
+ types: this.options.types,
15
+ attributes: {
16
+ color: {
17
+ default: null,
18
+ parseHTML: element => { var _a; return (_a = element.style.color) === null || _a === void 0 ? void 0 : _a.replace(/['"]+/g, ''); },
19
+ renderHTML: attributes => {
20
+ if (!attributes.color) {
21
+ return {};
22
+ }
23
+ return {
24
+ style: `color: ${attributes.color}`,
25
+ };
26
+ },
27
+ },
28
+ },
29
+ },
30
+ ];
31
+ },
32
+ addCommands() {
33
+ return {
34
+ setColor: color => ({ chain }) => {
35
+ return chain()
36
+ .setMark('textStyle', { color })
37
+ .run();
38
+ },
39
+ unsetColor: () => ({ chain }) => {
40
+ return chain()
41
+ .setMark('textStyle', { color: null })
42
+ .removeEmptyTextStyle()
43
+ .run();
44
+ },
45
+ };
46
+ },
45
47
  });
46
48
 
47
- // src/index.ts
48
- var src_default = Color;
49
- export {
50
- Color,
51
- src_default as default
52
- };
49
+ export { Color, Color as default };
50
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sources":["../src/color.ts"],"sourcesContent":["import '@tiptap/extension-text-style'\n\nimport { Extension } from '@tiptap/core'\n\nexport type ColorOptions = {\n types: string[],\n}\n\ndeclare module '@tiptap/core' {\n interface Commands<ReturnType> {\n color: {\n /**\n * Set the text color\n */\n setColor: (color: string) => ReturnType,\n /**\n * Unset the text color\n */\n unsetColor: () => ReturnType,\n }\n }\n}\n\nexport const Color = Extension.create<ColorOptions>({\n name: 'color',\n\n addOptions() {\n return {\n types: ['textStyle'],\n }\n },\n\n addGlobalAttributes() {\n return [\n {\n types: this.options.types,\n attributes: {\n color: {\n default: null,\n parseHTML: element => element.style.color?.replace(/['\"]+/g, ''),\n renderHTML: attributes => {\n if (!attributes.color) {\n return {}\n }\n\n return {\n style: `color: ${attributes.color}`,\n }\n },\n },\n },\n },\n ]\n },\n\n addCommands() {\n return {\n setColor: color => ({ chain }) => {\n return chain()\n .setMark('textStyle', { color })\n .run()\n },\n unsetColor: () => ({ chain }) => {\n return chain()\n .setMark('textStyle', { color: null })\n .removeEmptyTextStyle()\n .run()\n },\n }\n },\n})\n"],"names":[],"mappings":";;;AAuBa,MAAA,KAAK,GAAG,SAAS,CAAC,MAAM,CAAe;AAClD,IAAA,IAAI,EAAE,OAAO;IAEb,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,KAAK,EAAE;AACL,wBAAA,OAAO,EAAE,IAAI;wBACb,SAAS,EAAE,OAAO,cAAI,OAAA,CAAA,EAAA,GAAA,OAAO,CAAC,KAAK,CAAC,KAAK,MAAA,IAAA,IAAA,EAAA,KAAA,KAAA,CAAA,GAAA,KAAA,CAAA,GAAA,EAAA,CAAE,OAAO,CAAC,QAAQ,EAAE,EAAE,CAAC,CAAA,EAAA;wBAChE,UAAU,EAAE,UAAU,IAAG;AACvB,4BAAA,IAAI,CAAC,UAAU,CAAC,KAAK,EAAE;AACrB,gCAAA,OAAO,EAAE,CAAA;AACV,6BAAA;4BAED,OAAO;AACL,gCAAA,KAAK,EAAE,CAAA,OAAA,EAAU,UAAU,CAAC,KAAK,CAAE,CAAA;6BACpC,CAAA;yBACF;AACF,qBAAA;AACF,iBAAA;AACF,aAAA;SACF,CAAA;KACF;IAED,WAAW,GAAA;QACT,OAAO;YACL,QAAQ,EAAE,KAAK,IAAI,CAAC,EAAE,KAAK,EAAE,KAAI;AAC/B,gBAAA,OAAO,KAAK,EAAE;AACX,qBAAA,OAAO,CAAC,WAAW,EAAE,EAAE,KAAK,EAAE,CAAC;AAC/B,qBAAA,GAAG,EAAE,CAAA;aACT;YACD,UAAU,EAAE,MAAM,CAAC,EAAE,KAAK,EAAE,KAAI;AAC9B,gBAAA,OAAO,KAAK,EAAE;qBACX,OAAO,CAAC,WAAW,EAAE,EAAE,KAAK,EAAE,IAAI,EAAE,CAAC;AACrC,qBAAA,oBAAoB,EAAE;AACtB,qBAAA,GAAG,EAAE,CAAA;aACT;SACF,CAAA;KACF;AACF,CAAA;;;;"}
@@ -0,0 +1,58 @@
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-color"] = {}, null, global.core));
5
+ })(this, (function (exports, extensionTextStyle, core) { 'use strict';
6
+
7
+ const Color = core.Extension.create({
8
+ name: 'color',
9
+ addOptions() {
10
+ return {
11
+ types: ['textStyle'],
12
+ };
13
+ },
14
+ addGlobalAttributes() {
15
+ return [
16
+ {
17
+ types: this.options.types,
18
+ attributes: {
19
+ color: {
20
+ default: null,
21
+ parseHTML: element => { var _a; return (_a = element.style.color) === null || _a === void 0 ? void 0 : _a.replace(/['"]+/g, ''); },
22
+ renderHTML: attributes => {
23
+ if (!attributes.color) {
24
+ return {};
25
+ }
26
+ return {
27
+ style: `color: ${attributes.color}`,
28
+ };
29
+ },
30
+ },
31
+ },
32
+ },
33
+ ];
34
+ },
35
+ addCommands() {
36
+ return {
37
+ setColor: color => ({ chain }) => {
38
+ return chain()
39
+ .setMark('textStyle', { color })
40
+ .run();
41
+ },
42
+ unsetColor: () => ({ chain }) => {
43
+ return chain()
44
+ .setMark('textStyle', { color: null })
45
+ .removeEmptyTextStyle()
46
+ .run();
47
+ },
48
+ };
49
+ },
50
+ });
51
+
52
+ exports.Color = Color;
53
+ exports["default"] = Color;
54
+
55
+ Object.defineProperty(exports, '__esModule', { value: true });
56
+
57
+ }));
58
+ //# sourceMappingURL=index.umd.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.umd.js","sources":["../src/color.ts"],"sourcesContent":["import '@tiptap/extension-text-style'\n\nimport { Extension } from '@tiptap/core'\n\nexport type ColorOptions = {\n types: string[],\n}\n\ndeclare module '@tiptap/core' {\n interface Commands<ReturnType> {\n color: {\n /**\n * Set the text color\n */\n setColor: (color: string) => ReturnType,\n /**\n * Unset the text color\n */\n unsetColor: () => ReturnType,\n }\n }\n}\n\nexport const Color = Extension.create<ColorOptions>({\n name: 'color',\n\n addOptions() {\n return {\n types: ['textStyle'],\n }\n },\n\n addGlobalAttributes() {\n return [\n {\n types: this.options.types,\n attributes: {\n color: {\n default: null,\n parseHTML: element => element.style.color?.replace(/['\"]+/g, ''),\n renderHTML: attributes => {\n if (!attributes.color) {\n return {}\n }\n\n return {\n style: `color: ${attributes.color}`,\n }\n },\n },\n },\n },\n ]\n },\n\n addCommands() {\n return {\n setColor: color => ({ chain }) => {\n return chain()\n .setMark('textStyle', { color })\n .run()\n },\n unsetColor: () => ({ chain }) => {\n return chain()\n .setMark('textStyle', { color: null })\n .removeEmptyTextStyle()\n .run()\n },\n }\n },\n})\n"],"names":["Extension"],"mappings":";;;;;;AAuBa,QAAA,KAAK,GAAGA,cAAS,CAAC,MAAM,CAAe;EAClD,IAAA,IAAI,EAAE,OAAO;MAEb,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,KAAK,EAAE;EACL,wBAAA,OAAO,EAAE,IAAI;0BACb,SAAS,EAAE,OAAO,cAAI,OAAA,CAAA,EAAA,GAAA,OAAO,CAAC,KAAK,CAAC,KAAK,MAAA,IAAA,IAAA,EAAA,KAAA,KAAA,CAAA,GAAA,KAAA,CAAA,GAAA,EAAA,CAAE,OAAO,CAAC,QAAQ,EAAE,EAAE,CAAC,CAAA,EAAA;0BAChE,UAAU,EAAE,UAAU,IAAG;EACvB,4BAAA,IAAI,CAAC,UAAU,CAAC,KAAK,EAAE;EACrB,gCAAA,OAAO,EAAE,CAAA;EACV,6BAAA;8BAED,OAAO;EACL,gCAAA,KAAK,EAAE,CAAA,OAAA,EAAU,UAAU,CAAC,KAAK,CAAE,CAAA;+BACpC,CAAA;2BACF;EACF,qBAAA;EACF,iBAAA;EACF,aAAA;WACF,CAAA;OACF;MAED,WAAW,GAAA;UACT,OAAO;cACL,QAAQ,EAAE,KAAK,IAAI,CAAC,EAAE,KAAK,EAAE,KAAI;EAC/B,gBAAA,OAAO,KAAK,EAAE;EACX,qBAAA,OAAO,CAAC,WAAW,EAAE,EAAE,KAAK,EAAE,CAAC;EAC/B,qBAAA,GAAG,EAAE,CAAA;eACT;cACD,UAAU,EAAE,MAAM,CAAC,EAAE,KAAK,EAAE,KAAI;EAC9B,gBAAA,OAAO,KAAK,EAAE;uBACX,OAAO,CAAC,WAAW,EAAE,EAAE,KAAK,EAAE,IAAI,EAAE,CAAC;EACrC,qBAAA,oBAAoB,EAAE;EACtB,qBAAA,GAAG,EAAE,CAAA;eACT;WACF,CAAA;OACF;EACF,CAAA;;;;;;;;;;;"}
@@ -1,22 +1,20 @@
1
- import { Extension } from '@tiptap/core';
2
-
3
- declare type ColorOptions = {
4
- types: string[];
5
- };
6
- declare module '@tiptap/core' {
7
- interface Commands<ReturnType> {
8
- color: {
9
- /**
10
- * Set the text color
11
- */
12
- setColor: (color: string) => ReturnType;
13
- /**
14
- * Unset the text color
15
- */
16
- unsetColor: () => ReturnType;
17
- };
18
- }
19
- }
20
- declare const Color: Extension<ColorOptions, any>;
21
-
22
- export { Color, ColorOptions, Color as default };
1
+ import '@tiptap/extension-text-style';
2
+ import { Extension } from '@tiptap/core';
3
+ export declare type ColorOptions = {
4
+ types: string[];
5
+ };
6
+ declare module '@tiptap/core' {
7
+ interface Commands<ReturnType> {
8
+ color: {
9
+ /**
10
+ * Set the text color
11
+ */
12
+ setColor: (color: string) => ReturnType;
13
+ /**
14
+ * Unset the text color
15
+ */
16
+ unsetColor: () => ReturnType;
17
+ };
18
+ }
19
+ }
20
+ export declare const Color: Extension<ColorOptions, any>;
@@ -0,0 +1,3 @@
1
+ import { Color } from './color';
2
+ export * from './color';
3
+ export default Color;
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@tiptap/extension-color",
3
3
  "description": "text color extension for tiptap",
4
- "version": "2.0.0-beta.213",
4
+ "version": "2.0.0-beta.215",
5
5
  "homepage": "https://tiptap.dev",
6
6
  "keywords": [
7
7
  "tiptap",
@@ -15,14 +15,15 @@
15
15
  "type": "module",
16
16
  "exports": {
17
17
  ".": {
18
- "types": "./dist/index.d.ts",
18
+ "types": "./dist/packages/extension-color/src/index.d.ts",
19
19
  "import": "./dist/index.js",
20
20
  "require": "./dist/index.cjs"
21
21
  }
22
22
  },
23
23
  "main": "dist/index.cjs",
24
24
  "module": "dist/index.js",
25
- "types": "dist/index.d.ts",
25
+ "umd": "dist/index.umd.js",
26
+ "types": "dist/packages/extension-color/src/index.d.ts",
26
27
  "files": [
27
28
  "src",
28
29
  "dist"
@@ -32,8 +33,8 @@
32
33
  "@tiptap/extension-text-style": "^2.0.0-beta.209"
33
34
  },
34
35
  "devDependencies": {
35
- "@tiptap/core": "^2.0.0-beta.213",
36
- "@tiptap/extension-text-style": "^2.0.0-beta.213"
36
+ "@tiptap/core": "^2.0.0-beta.215",
37
+ "@tiptap/extension-text-style": "^2.0.0-beta.215"
37
38
  },
38
39
  "repository": {
39
40
  "type": "git",
@@ -41,17 +42,7 @@
41
42
  "directory": "packages/extension-color"
42
43
  },
43
44
  "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
- ]
45
+ "clean": "rm -rf dist",
46
+ "build": "npm run clean && rollup -c"
56
47
  }
57
48
  }