@tiptap/extension-text-align 3.20.2 → 3.20.3

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/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@tiptap/extension-text-align",
3
3
  "description": "text align extension for tiptap",
4
- "version": "3.20.2",
4
+ "version": "3.20.3",
5
5
  "homepage": "https://tiptap.dev",
6
6
  "keywords": [
7
7
  "tiptap",
@@ -31,10 +31,10 @@
31
31
  "dist"
32
32
  ],
33
33
  "devDependencies": {
34
- "@tiptap/core": "^3.20.2"
34
+ "@tiptap/core": "^3.20.3"
35
35
  },
36
36
  "peerDependencies": {
37
- "@tiptap/core": "^3.20.2"
37
+ "@tiptap/core": "^3.20.3"
38
38
  },
39
39
  "repository": {
40
40
  "type": "git",
package/dist/index.cjs DELETED
@@ -1,99 +0,0 @@
1
- "use strict";
2
- var __defProp = Object.defineProperty;
3
- var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
- var __getOwnPropNames = Object.getOwnPropertyNames;
5
- var __hasOwnProp = Object.prototype.hasOwnProperty;
6
- var __export = (target, all) => {
7
- for (var name in all)
8
- __defProp(target, name, { get: all[name], enumerable: true });
9
- };
10
- var __copyProps = (to, from, except, desc) => {
11
- if (from && typeof from === "object" || typeof from === "function") {
12
- for (let key of __getOwnPropNames(from))
13
- if (!__hasOwnProp.call(to, key) && key !== except)
14
- __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
15
- }
16
- return to;
17
- };
18
- var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
-
20
- // src/index.ts
21
- var index_exports = {};
22
- __export(index_exports, {
23
- TextAlign: () => TextAlign,
24
- default: () => index_default
25
- });
26
- module.exports = __toCommonJS(index_exports);
27
-
28
- // src/text-align.ts
29
- var import_core = require("@tiptap/core");
30
- var TextAlign = import_core.Extension.create({
31
- name: "textAlign",
32
- addOptions() {
33
- return {
34
- types: [],
35
- alignments: ["left", "center", "right", "justify"],
36
- defaultAlignment: null
37
- };
38
- },
39
- addGlobalAttributes() {
40
- return [
41
- {
42
- types: this.options.types,
43
- attributes: {
44
- textAlign: {
45
- default: this.options.defaultAlignment,
46
- parseHTML: (element) => {
47
- const alignment = element.style.textAlign;
48
- return this.options.alignments.includes(alignment) ? alignment : this.options.defaultAlignment;
49
- },
50
- renderHTML: (attributes) => {
51
- if (!attributes.textAlign) {
52
- return {};
53
- }
54
- return { style: `text-align: ${attributes.textAlign}` };
55
- }
56
- }
57
- }
58
- }
59
- ];
60
- },
61
- addCommands() {
62
- return {
63
- setTextAlign: (alignment) => ({ commands }) => {
64
- if (!this.options.alignments.includes(alignment)) {
65
- return false;
66
- }
67
- return this.options.types.map((type) => commands.updateAttributes(type, { textAlign: alignment })).some((response) => response);
68
- },
69
- unsetTextAlign: () => ({ commands }) => {
70
- return this.options.types.map((type) => commands.resetAttributes(type, "textAlign")).some((response) => response);
71
- },
72
- toggleTextAlign: (alignment) => ({ editor, commands }) => {
73
- if (!this.options.alignments.includes(alignment)) {
74
- return false;
75
- }
76
- if (editor.isActive({ textAlign: alignment })) {
77
- return commands.unsetTextAlign();
78
- }
79
- return commands.setTextAlign(alignment);
80
- }
81
- };
82
- },
83
- addKeyboardShortcuts() {
84
- return {
85
- "Mod-Shift-l": () => this.editor.commands.setTextAlign("left"),
86
- "Mod-Shift-e": () => this.editor.commands.setTextAlign("center"),
87
- "Mod-Shift-r": () => this.editor.commands.setTextAlign("right"),
88
- "Mod-Shift-j": () => this.editor.commands.setTextAlign("justify")
89
- };
90
- }
91
- });
92
-
93
- // src/index.ts
94
- var index_default = TextAlign;
95
- // Annotate the CommonJS export names for ESM import in node:
96
- 0 && (module.exports = {
97
- TextAlign
98
- });
99
- //# sourceMappingURL=index.cjs.map
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../src/index.ts","../src/text-align.ts"],"sourcesContent":["import { TextAlign } from './text-align.js'\n\nexport * from './text-align.js'\n\nexport default TextAlign\n","import { Extension } from '@tiptap/core'\n\nexport interface TextAlignOptions {\n /**\n * The types where the text align attribute can be applied.\n * @default []\n * @example ['heading', 'paragraph']\n */\n types: string[]\n\n /**\n * The alignments which are allowed.\n * @default ['left', 'center', 'right', 'justify']\n * @example ['left', 'right']\n */\n alignments: string[]\n\n /**\n * The default alignment.\n * @default null\n * @example 'center'\n */\n defaultAlignment: string | null\n}\n\ndeclare module '@tiptap/core' {\n interface Commands<ReturnType> {\n textAlign: {\n /**\n * Set the text align attribute\n * @param alignment The alignment\n * @example editor.commands.setTextAlign('left')\n */\n setTextAlign: (alignment: string) => ReturnType\n /**\n * Unset the text align attribute\n * @example editor.commands.unsetTextAlign()\n */\n unsetTextAlign: () => ReturnType\n /**\n * Toggle the text align attribute\n * @param alignment The alignment\n * @example editor.commands.toggleTextAlign('right')\n */\n toggleTextAlign: (alignment: string) => ReturnType\n }\n }\n}\n\n/**\n * This extension allows you to align text.\n * @see https://www.tiptap.dev/api/extensions/text-align\n */\nexport const TextAlign = Extension.create<TextAlignOptions>({\n name: 'textAlign',\n\n addOptions() {\n return {\n types: [],\n alignments: ['left', 'center', 'right', 'justify'],\n defaultAlignment: null,\n }\n },\n\n addGlobalAttributes() {\n return [\n {\n types: this.options.types,\n attributes: {\n textAlign: {\n default: this.options.defaultAlignment,\n parseHTML: element => {\n const alignment = element.style.textAlign\n\n return this.options.alignments.includes(alignment) ? alignment : this.options.defaultAlignment\n },\n renderHTML: attributes => {\n if (!attributes.textAlign) {\n return {}\n }\n\n return { style: `text-align: ${attributes.textAlign}` }\n },\n },\n },\n },\n ]\n },\n\n addCommands() {\n return {\n setTextAlign:\n (alignment: string) =>\n ({ commands }) => {\n if (!this.options.alignments.includes(alignment)) {\n return false\n }\n\n return this.options.types\n .map(type => commands.updateAttributes(type, { textAlign: alignment }))\n .some(response => response)\n },\n\n unsetTextAlign:\n () =>\n ({ commands }) => {\n return this.options.types.map(type => commands.resetAttributes(type, 'textAlign')).some(response => response)\n },\n\n toggleTextAlign:\n alignment =>\n ({ editor, commands }) => {\n if (!this.options.alignments.includes(alignment)) {\n return false\n }\n\n if (editor.isActive({ textAlign: alignment })) {\n return commands.unsetTextAlign()\n }\n return commands.setTextAlign(alignment)\n },\n }\n },\n\n addKeyboardShortcuts() {\n return {\n 'Mod-Shift-l': () => this.editor.commands.setTextAlign('left'),\n 'Mod-Shift-e': () => this.editor.commands.setTextAlign('center'),\n 'Mod-Shift-r': () => this.editor.commands.setTextAlign('right'),\n 'Mod-Shift-j': () => this.editor.commands.setTextAlign('justify'),\n }\n },\n})\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;;;ACAA,kBAA0B;AAqDnB,IAAM,YAAY,sBAAU,OAAyB;AAAA,EAC1D,MAAM;AAAA,EAEN,aAAa;AACX,WAAO;AAAA,MACL,OAAO,CAAC;AAAA,MACR,YAAY,CAAC,QAAQ,UAAU,SAAS,SAAS;AAAA,MACjD,kBAAkB;AAAA,IACpB;AAAA,EACF;AAAA,EAEA,sBAAsB;AACpB,WAAO;AAAA,MACL;AAAA,QACE,OAAO,KAAK,QAAQ;AAAA,QACpB,YAAY;AAAA,UACV,WAAW;AAAA,YACT,SAAS,KAAK,QAAQ;AAAA,YACtB,WAAW,aAAW;AACpB,oBAAM,YAAY,QAAQ,MAAM;AAEhC,qBAAO,KAAK,QAAQ,WAAW,SAAS,SAAS,IAAI,YAAY,KAAK,QAAQ;AAAA,YAChF;AAAA,YACA,YAAY,gBAAc;AACxB,kBAAI,CAAC,WAAW,WAAW;AACzB,uBAAO,CAAC;AAAA,cACV;AAEA,qBAAO,EAAE,OAAO,eAAe,WAAW,SAAS,GAAG;AAAA,YACxD;AAAA,UACF;AAAA,QACF;AAAA,MACF;AAAA,IACF;AAAA,EACF;AAAA,EAEA,cAAc;AACZ,WAAO;AAAA,MACL,cACE,CAAC,cACD,CAAC,EAAE,SAAS,MAAM;AAChB,YAAI,CAAC,KAAK,QAAQ,WAAW,SAAS,SAAS,GAAG;AAChD,iBAAO;AAAA,QACT;AAEA,eAAO,KAAK,QAAQ,MACjB,IAAI,UAAQ,SAAS,iBAAiB,MAAM,EAAE,WAAW,UAAU,CAAC,CAAC,EACrE,KAAK,cAAY,QAAQ;AAAA,MAC9B;AAAA,MAEF,gBACE,MACA,CAAC,EAAE,SAAS,MAAM;AAChB,eAAO,KAAK,QAAQ,MAAM,IAAI,UAAQ,SAAS,gBAAgB,MAAM,WAAW,CAAC,EAAE,KAAK,cAAY,QAAQ;AAAA,MAC9G;AAAA,MAEF,iBACE,eACA,CAAC,EAAE,QAAQ,SAAS,MAAM;AACxB,YAAI,CAAC,KAAK,QAAQ,WAAW,SAAS,SAAS,GAAG;AAChD,iBAAO;AAAA,QACT;AAEA,YAAI,OAAO,SAAS,EAAE,WAAW,UAAU,CAAC,GAAG;AAC7C,iBAAO,SAAS,eAAe;AAAA,QACjC;AACA,eAAO,SAAS,aAAa,SAAS;AAAA,MACxC;AAAA,IACJ;AAAA,EACF;AAAA,EAEA,uBAAuB;AACrB,WAAO;AAAA,MACL,eAAe,MAAM,KAAK,OAAO,SAAS,aAAa,MAAM;AAAA,MAC7D,eAAe,MAAM,KAAK,OAAO,SAAS,aAAa,QAAQ;AAAA,MAC/D,eAAe,MAAM,KAAK,OAAO,SAAS,aAAa,OAAO;AAAA,MAC9D,eAAe,MAAM,KAAK,OAAO,SAAS,aAAa,SAAS;AAAA,IAClE;AAAA,EACF;AACF,CAAC;;;ADhID,IAAO,gBAAQ;","names":[]}
package/dist/index.d.cts DELETED
@@ -1,52 +0,0 @@
1
- import { Extension } from '@tiptap/core';
2
-
3
- interface TextAlignOptions {
4
- /**
5
- * The types where the text align attribute can be applied.
6
- * @default []
7
- * @example ['heading', 'paragraph']
8
- */
9
- types: string[];
10
- /**
11
- * The alignments which are allowed.
12
- * @default ['left', 'center', 'right', 'justify']
13
- * @example ['left', 'right']
14
- */
15
- alignments: string[];
16
- /**
17
- * The default alignment.
18
- * @default null
19
- * @example 'center'
20
- */
21
- defaultAlignment: string | null;
22
- }
23
- declare module '@tiptap/core' {
24
- interface Commands<ReturnType> {
25
- textAlign: {
26
- /**
27
- * Set the text align attribute
28
- * @param alignment The alignment
29
- * @example editor.commands.setTextAlign('left')
30
- */
31
- setTextAlign: (alignment: string) => ReturnType;
32
- /**
33
- * Unset the text align attribute
34
- * @example editor.commands.unsetTextAlign()
35
- */
36
- unsetTextAlign: () => ReturnType;
37
- /**
38
- * Toggle the text align attribute
39
- * @param alignment The alignment
40
- * @example editor.commands.toggleTextAlign('right')
41
- */
42
- toggleTextAlign: (alignment: string) => ReturnType;
43
- };
44
- }
45
- }
46
- /**
47
- * This extension allows you to align text.
48
- * @see https://www.tiptap.dev/api/extensions/text-align
49
- */
50
- declare const TextAlign: Extension<TextAlignOptions, any>;
51
-
52
- export { TextAlign, type TextAlignOptions, TextAlign as default };
package/dist/index.d.ts DELETED
@@ -1,52 +0,0 @@
1
- import { Extension } from '@tiptap/core';
2
-
3
- interface TextAlignOptions {
4
- /**
5
- * The types where the text align attribute can be applied.
6
- * @default []
7
- * @example ['heading', 'paragraph']
8
- */
9
- types: string[];
10
- /**
11
- * The alignments which are allowed.
12
- * @default ['left', 'center', 'right', 'justify']
13
- * @example ['left', 'right']
14
- */
15
- alignments: string[];
16
- /**
17
- * The default alignment.
18
- * @default null
19
- * @example 'center'
20
- */
21
- defaultAlignment: string | null;
22
- }
23
- declare module '@tiptap/core' {
24
- interface Commands<ReturnType> {
25
- textAlign: {
26
- /**
27
- * Set the text align attribute
28
- * @param alignment The alignment
29
- * @example editor.commands.setTextAlign('left')
30
- */
31
- setTextAlign: (alignment: string) => ReturnType;
32
- /**
33
- * Unset the text align attribute
34
- * @example editor.commands.unsetTextAlign()
35
- */
36
- unsetTextAlign: () => ReturnType;
37
- /**
38
- * Toggle the text align attribute
39
- * @param alignment The alignment
40
- * @example editor.commands.toggleTextAlign('right')
41
- */
42
- toggleTextAlign: (alignment: string) => ReturnType;
43
- };
44
- }
45
- }
46
- /**
47
- * This extension allows you to align text.
48
- * @see https://www.tiptap.dev/api/extensions/text-align
49
- */
50
- declare const TextAlign: Extension<TextAlignOptions, any>;
51
-
52
- export { TextAlign, type TextAlignOptions, TextAlign as default };
package/dist/index.js DELETED
@@ -1,72 +0,0 @@
1
- // src/text-align.ts
2
- import { Extension } from "@tiptap/core";
3
- var TextAlign = Extension.create({
4
- name: "textAlign",
5
- addOptions() {
6
- return {
7
- types: [],
8
- alignments: ["left", "center", "right", "justify"],
9
- defaultAlignment: null
10
- };
11
- },
12
- addGlobalAttributes() {
13
- return [
14
- {
15
- types: this.options.types,
16
- attributes: {
17
- textAlign: {
18
- default: this.options.defaultAlignment,
19
- parseHTML: (element) => {
20
- const alignment = element.style.textAlign;
21
- return this.options.alignments.includes(alignment) ? alignment : this.options.defaultAlignment;
22
- },
23
- renderHTML: (attributes) => {
24
- if (!attributes.textAlign) {
25
- return {};
26
- }
27
- return { style: `text-align: ${attributes.textAlign}` };
28
- }
29
- }
30
- }
31
- }
32
- ];
33
- },
34
- addCommands() {
35
- return {
36
- setTextAlign: (alignment) => ({ commands }) => {
37
- if (!this.options.alignments.includes(alignment)) {
38
- return false;
39
- }
40
- return this.options.types.map((type) => commands.updateAttributes(type, { textAlign: alignment })).some((response) => response);
41
- },
42
- unsetTextAlign: () => ({ commands }) => {
43
- return this.options.types.map((type) => commands.resetAttributes(type, "textAlign")).some((response) => response);
44
- },
45
- toggleTextAlign: (alignment) => ({ editor, commands }) => {
46
- if (!this.options.alignments.includes(alignment)) {
47
- return false;
48
- }
49
- if (editor.isActive({ textAlign: alignment })) {
50
- return commands.unsetTextAlign();
51
- }
52
- return commands.setTextAlign(alignment);
53
- }
54
- };
55
- },
56
- addKeyboardShortcuts() {
57
- return {
58
- "Mod-Shift-l": () => this.editor.commands.setTextAlign("left"),
59
- "Mod-Shift-e": () => this.editor.commands.setTextAlign("center"),
60
- "Mod-Shift-r": () => this.editor.commands.setTextAlign("right"),
61
- "Mod-Shift-j": () => this.editor.commands.setTextAlign("justify")
62
- };
63
- }
64
- });
65
-
66
- // src/index.ts
67
- var index_default = TextAlign;
68
- export {
69
- TextAlign,
70
- index_default as default
71
- };
72
- //# sourceMappingURL=index.js.map
package/dist/index.js.map DELETED
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../src/text-align.ts","../src/index.ts"],"sourcesContent":["import { Extension } from '@tiptap/core'\n\nexport interface TextAlignOptions {\n /**\n * The types where the text align attribute can be applied.\n * @default []\n * @example ['heading', 'paragraph']\n */\n types: string[]\n\n /**\n * The alignments which are allowed.\n * @default ['left', 'center', 'right', 'justify']\n * @example ['left', 'right']\n */\n alignments: string[]\n\n /**\n * The default alignment.\n * @default null\n * @example 'center'\n */\n defaultAlignment: string | null\n}\n\ndeclare module '@tiptap/core' {\n interface Commands<ReturnType> {\n textAlign: {\n /**\n * Set the text align attribute\n * @param alignment The alignment\n * @example editor.commands.setTextAlign('left')\n */\n setTextAlign: (alignment: string) => ReturnType\n /**\n * Unset the text align attribute\n * @example editor.commands.unsetTextAlign()\n */\n unsetTextAlign: () => ReturnType\n /**\n * Toggle the text align attribute\n * @param alignment The alignment\n * @example editor.commands.toggleTextAlign('right')\n */\n toggleTextAlign: (alignment: string) => ReturnType\n }\n }\n}\n\n/**\n * This extension allows you to align text.\n * @see https://www.tiptap.dev/api/extensions/text-align\n */\nexport const TextAlign = Extension.create<TextAlignOptions>({\n name: 'textAlign',\n\n addOptions() {\n return {\n types: [],\n alignments: ['left', 'center', 'right', 'justify'],\n defaultAlignment: null,\n }\n },\n\n addGlobalAttributes() {\n return [\n {\n types: this.options.types,\n attributes: {\n textAlign: {\n default: this.options.defaultAlignment,\n parseHTML: element => {\n const alignment = element.style.textAlign\n\n return this.options.alignments.includes(alignment) ? alignment : this.options.defaultAlignment\n },\n renderHTML: attributes => {\n if (!attributes.textAlign) {\n return {}\n }\n\n return { style: `text-align: ${attributes.textAlign}` }\n },\n },\n },\n },\n ]\n },\n\n addCommands() {\n return {\n setTextAlign:\n (alignment: string) =>\n ({ commands }) => {\n if (!this.options.alignments.includes(alignment)) {\n return false\n }\n\n return this.options.types\n .map(type => commands.updateAttributes(type, { textAlign: alignment }))\n .some(response => response)\n },\n\n unsetTextAlign:\n () =>\n ({ commands }) => {\n return this.options.types.map(type => commands.resetAttributes(type, 'textAlign')).some(response => response)\n },\n\n toggleTextAlign:\n alignment =>\n ({ editor, commands }) => {\n if (!this.options.alignments.includes(alignment)) {\n return false\n }\n\n if (editor.isActive({ textAlign: alignment })) {\n return commands.unsetTextAlign()\n }\n return commands.setTextAlign(alignment)\n },\n }\n },\n\n addKeyboardShortcuts() {\n return {\n 'Mod-Shift-l': () => this.editor.commands.setTextAlign('left'),\n 'Mod-Shift-e': () => this.editor.commands.setTextAlign('center'),\n 'Mod-Shift-r': () => this.editor.commands.setTextAlign('right'),\n 'Mod-Shift-j': () => this.editor.commands.setTextAlign('justify'),\n }\n },\n})\n","import { TextAlign } from './text-align.js'\n\nexport * from './text-align.js'\n\nexport default TextAlign\n"],"mappings":";AAAA,SAAS,iBAAiB;AAqDnB,IAAM,YAAY,UAAU,OAAyB;AAAA,EAC1D,MAAM;AAAA,EAEN,aAAa;AACX,WAAO;AAAA,MACL,OAAO,CAAC;AAAA,MACR,YAAY,CAAC,QAAQ,UAAU,SAAS,SAAS;AAAA,MACjD,kBAAkB;AAAA,IACpB;AAAA,EACF;AAAA,EAEA,sBAAsB;AACpB,WAAO;AAAA,MACL;AAAA,QACE,OAAO,KAAK,QAAQ;AAAA,QACpB,YAAY;AAAA,UACV,WAAW;AAAA,YACT,SAAS,KAAK,QAAQ;AAAA,YACtB,WAAW,aAAW;AACpB,oBAAM,YAAY,QAAQ,MAAM;AAEhC,qBAAO,KAAK,QAAQ,WAAW,SAAS,SAAS,IAAI,YAAY,KAAK,QAAQ;AAAA,YAChF;AAAA,YACA,YAAY,gBAAc;AACxB,kBAAI,CAAC,WAAW,WAAW;AACzB,uBAAO,CAAC;AAAA,cACV;AAEA,qBAAO,EAAE,OAAO,eAAe,WAAW,SAAS,GAAG;AAAA,YACxD;AAAA,UACF;AAAA,QACF;AAAA,MACF;AAAA,IACF;AAAA,EACF;AAAA,EAEA,cAAc;AACZ,WAAO;AAAA,MACL,cACE,CAAC,cACD,CAAC,EAAE,SAAS,MAAM;AAChB,YAAI,CAAC,KAAK,QAAQ,WAAW,SAAS,SAAS,GAAG;AAChD,iBAAO;AAAA,QACT;AAEA,eAAO,KAAK,QAAQ,MACjB,IAAI,UAAQ,SAAS,iBAAiB,MAAM,EAAE,WAAW,UAAU,CAAC,CAAC,EACrE,KAAK,cAAY,QAAQ;AAAA,MAC9B;AAAA,MAEF,gBACE,MACA,CAAC,EAAE,SAAS,MAAM;AAChB,eAAO,KAAK,QAAQ,MAAM,IAAI,UAAQ,SAAS,gBAAgB,MAAM,WAAW,CAAC,EAAE,KAAK,cAAY,QAAQ;AAAA,MAC9G;AAAA,MAEF,iBACE,eACA,CAAC,EAAE,QAAQ,SAAS,MAAM;AACxB,YAAI,CAAC,KAAK,QAAQ,WAAW,SAAS,SAAS,GAAG;AAChD,iBAAO;AAAA,QACT;AAEA,YAAI,OAAO,SAAS,EAAE,WAAW,UAAU,CAAC,GAAG;AAC7C,iBAAO,SAAS,eAAe;AAAA,QACjC;AACA,eAAO,SAAS,aAAa,SAAS;AAAA,MACxC;AAAA,IACJ;AAAA,EACF;AAAA,EAEA,uBAAuB;AACrB,WAAO;AAAA,MACL,eAAe,MAAM,KAAK,OAAO,SAAS,aAAa,MAAM;AAAA,MAC7D,eAAe,MAAM,KAAK,OAAO,SAAS,aAAa,QAAQ;AAAA,MAC/D,eAAe,MAAM,KAAK,OAAO,SAAS,aAAa,OAAO;AAAA,MAC9D,eAAe,MAAM,KAAK,OAAO,SAAS,aAAa,SAAS;AAAA,IAClE;AAAA,EACF;AACF,CAAC;;;AChID,IAAO,gBAAQ;","names":[]}