@tiptap/extension-text-align 2.11.6 → 3.0.0-beta.0

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 ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2025, Tiptap GmbH
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.
package/README.md CHANGED
@@ -1,14 +1,18 @@
1
1
  # @tiptap/extension-text-align
2
+
2
3
  [![Version](https://img.shields.io/npm/v/@tiptap/extension-text-align.svg?label=version)](https://www.npmjs.com/package/@tiptap/extension-text-align)
3
4
  [![Downloads](https://img.shields.io/npm/dm/@tiptap/extension-text-align.svg)](https://npmcharts.com/compare/tiptap?minimal=true)
4
5
  [![License](https://img.shields.io/npm/l/@tiptap/extension-text-align.svg)](https://www.npmjs.com/package/@tiptap/extension-text-align)
5
6
  [![Sponsor](https://img.shields.io/static/v1?label=Sponsor&message=%E2%9D%A4&logo=GitHub)](https://github.com/sponsors/ueberdosis)
6
7
 
7
8
  ## 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*.
9
+
10
+ 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
11
 
10
12
  ## Official Documentation
13
+
11
14
  Documentation can be found on the [Tiptap website](https://tiptap.dev).
12
15
 
13
16
  ## License
17
+
14
18
  Tiptap is open sourced software licensed under the [MIT license](https://github.com/ueberdosis/tiptap/blob/main/LICENSE.md).
package/dist/index.cjs CHANGED
@@ -1,71 +1,90 @@
1
- 'use strict';
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);
2
19
 
3
- Object.defineProperty(exports, '__esModule', { value: true });
4
-
5
- var core = require('@tiptap/core');
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);
6
27
 
7
- /**
8
- * This extension allows you to align text.
9
- * @see https://www.tiptap.dev/api/extensions/text-align
10
- */
11
- const TextAlign = core.Extension.create({
12
- name: 'textAlign',
13
- addOptions() {
14
- return {
15
- types: [],
16
- alignments: ['left', 'center', 'right', 'justify'],
17
- defaultAlignment: null,
18
- };
19
- },
20
- addGlobalAttributes() {
21
- return [
22
- {
23
- types: this.options.types,
24
- attributes: {
25
- textAlign: {
26
- default: this.options.defaultAlignment,
27
- parseHTML: element => {
28
- const alignment = element.style.textAlign;
29
- return this.options.alignments.includes(alignment) ? alignment : this.options.defaultAlignment;
30
- },
31
- renderHTML: attributes => {
32
- if (!attributes.textAlign) {
33
- return {};
34
- }
35
- return { style: `text-align: ${attributes.textAlign}` };
36
- },
37
- },
38
- },
39
- },
40
- ];
41
- },
42
- addCommands() {
43
- return {
44
- setTextAlign: (alignment) => ({ commands }) => {
45
- if (!this.options.alignments.includes(alignment)) {
46
- return false;
47
- }
48
- return this.options.types
49
- .map(type => commands.updateAttributes(type, { textAlign: alignment }))
50
- .every(response => response);
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;
51
49
  },
52
- unsetTextAlign: () => ({ commands }) => {
53
- return this.options.types
54
- .map(type => commands.resetAttributes(type, 'textAlign'))
55
- .every(response => response);
56
- },
57
- };
58
- },
59
- addKeyboardShortcuts() {
60
- return {
61
- 'Mod-Shift-l': () => this.editor.commands.setTextAlign('left'),
62
- 'Mod-Shift-e': () => this.editor.commands.setTextAlign('center'),
63
- 'Mod-Shift-r': () => this.editor.commands.setTextAlign('right'),
64
- 'Mod-Shift-j': () => this.editor.commands.setTextAlign('justify'),
65
- };
66
- },
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 })).every((response) => response);
68
+ },
69
+ unsetTextAlign: () => ({ commands }) => {
70
+ return this.options.types.map((type) => commands.resetAttributes(type, "textAlign")).every((response) => response);
71
+ }
72
+ };
73
+ },
74
+ addKeyboardShortcuts() {
75
+ return {
76
+ "Mod-Shift-l": () => this.editor.commands.setTextAlign("left"),
77
+ "Mod-Shift-e": () => this.editor.commands.setTextAlign("center"),
78
+ "Mod-Shift-r": () => this.editor.commands.setTextAlign("right"),
79
+ "Mod-Shift-j": () => this.editor.commands.setTextAlign("justify")
80
+ };
81
+ }
67
82
  });
68
83
 
69
- exports.TextAlign = TextAlign;
70
- exports.default = TextAlign;
71
- //# sourceMappingURL=index.cjs.map
84
+ // src/index.ts
85
+ var index_default = TextAlign;
86
+ // Annotate the CommonJS export names for ESM import in node:
87
+ 0 && (module.exports = {
88
+ TextAlign
89
+ });
90
+ //# sourceMappingURL=index.cjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.cjs","sources":["../src/text-align.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 }\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: (alignment: string) => ({ 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 .every(response => response)\n },\n\n unsetTextAlign: () => ({ commands }) => {\n return this.options.types\n .map(type => commands.resetAttributes(type, 'textAlign'))\n .every(response => response)\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"],"names":["Extension"],"mappings":";;;;;;AA2CA;;;AAGG;AACU,MAAA,SAAS,GAAGA,cAAS,CAAC,MAAM,CAAmB;AAC1D,IAAA,IAAI,EAAE,WAAW;IAEjB,UAAU,GAAA;QAC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I,QAAQ,CAAC;aAC/B;YAED,cAAc,EAAE,MAAM,CAAC,EAAE,QAAQ,EAAE,KAAI;AACrC,gBAAA,OAAO,IAAI,CAAC,OAAO,CAAC;AACjB,qBAAA,GAAG,CAAC,IAAI,IAAI,QAAQ,CAAC,eAAe,CAAC,IAAI,EAAE,WAAW,CAAC;AACvD,qBAAA,KAAK,CAAC,QAAQ,IAAI,QAAQ,CAAC;aAC/B;SACF;KACF;IAED,oBAAoB,GAAA;QAClB,OAAO;AACL,YAAA,aAAa,EAAE,MAAM,IAAI,CAAC,MAAM,CAAC,QAAQ,CAAC,YAAY,CAAC,MAAM,CAAC;AAC9D,YAAA,aAAa,EAAE,MAAM,IAAI,CAAC,MAAM,CAAC,QAAQ,CAAC,YAAY,CAAC,QAAQ,CAAC;AAChE,YAAA,aAAa,EAAE,MAAM,IAAI,CAAC,MAAM,CAAC,QAAQ,CAAC,YAAY,CAAC,OAAO,CAAC;AAC/D,YAAA,aAAa,EAAE,MAAM,IAAI,CAAC,MAAM,CAAC,QAAQ,CAAC,YAAY,CAAC,SAAS,CAAC;SAClE;KACF;AACF,CAAA;;;;;"}
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 }\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 .every(response => response)\n },\n\n unsetTextAlign:\n () =>\n ({ commands }) => {\n return this.options.types.map(type => commands.resetAttributes(type, 'textAlign')).every(response => response)\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;AA+CnB,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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AQ;","names":[]}
@@ -1,5 +1,6 @@
1
1
  import { Extension } from '@tiptap/core';
2
- export interface TextAlignOptions {
2
+
3
+ interface TextAlignOptions {
3
4
  /**
4
5
  * The types where the text align attribute can be applied.
5
6
  * @default []
@@ -40,5 +41,6 @@ declare module '@tiptap/core' {
40
41
  * This extension allows you to align text.
41
42
  * @see https://www.tiptap.dev/api/extensions/text-align
42
43
  */
43
- export declare const TextAlign: Extension<TextAlignOptions, any>;
44
- //# sourceMappingURL=text-align.d.ts.map
44
+ declare const TextAlign: Extension<TextAlignOptions, any>;
45
+
46
+ export { TextAlign, type TextAlignOptions, TextAlign as default };
package/dist/index.d.ts CHANGED
@@ -1,4 +1,46 @@
1
- import { TextAlign } from './text-align.js';
2
- export * from './text-align.js';
3
- export default TextAlign;
4
- //# sourceMappingURL=index.d.ts.map
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
+ }
39
+ }
40
+ /**
41
+ * This extension allows you to align text.
42
+ * @see https://www.tiptap.dev/api/extensions/text-align
43
+ */
44
+ declare const TextAlign: Extension<TextAlignOptions, any>;
45
+
46
+ export { TextAlign, type TextAlignOptions, TextAlign as default };
package/dist/index.js CHANGED
@@ -1,66 +1,63 @@
1
- import { Extension } from '@tiptap/core';
2
-
3
- /**
4
- * This extension allows you to align text.
5
- * @see https://www.tiptap.dev/api/extensions/text-align
6
- */
7
- const TextAlign = Extension.create({
8
- name: 'textAlign',
9
- addOptions() {
10
- return {
11
- types: [],
12
- alignments: ['left', 'center', 'right', 'justify'],
13
- defaultAlignment: null,
14
- };
15
- },
16
- addGlobalAttributes() {
17
- return [
18
- {
19
- types: this.options.types,
20
- attributes: {
21
- textAlign: {
22
- default: this.options.defaultAlignment,
23
- parseHTML: element => {
24
- const alignment = element.style.textAlign;
25
- return this.options.alignments.includes(alignment) ? alignment : this.options.defaultAlignment;
26
- },
27
- renderHTML: attributes => {
28
- if (!attributes.textAlign) {
29
- return {};
30
- }
31
- return { style: `text-align: ${attributes.textAlign}` };
32
- },
33
- },
34
- },
35
- },
36
- ];
37
- },
38
- addCommands() {
39
- return {
40
- setTextAlign: (alignment) => ({ commands }) => {
41
- if (!this.options.alignments.includes(alignment)) {
42
- return false;
43
- }
44
- return this.options.types
45
- .map(type => commands.updateAttributes(type, { textAlign: alignment }))
46
- .every(response => response);
47
- },
48
- unsetTextAlign: () => ({ commands }) => {
49
- return this.options.types
50
- .map(type => commands.resetAttributes(type, 'textAlign'))
51
- .every(response => response);
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;
52
22
  },
53
- };
54
- },
55
- addKeyboardShortcuts() {
56
- return {
57
- 'Mod-Shift-l': () => this.editor.commands.setTextAlign('left'),
58
- 'Mod-Shift-e': () => this.editor.commands.setTextAlign('center'),
59
- 'Mod-Shift-r': () => this.editor.commands.setTextAlign('right'),
60
- 'Mod-Shift-j': () => this.editor.commands.setTextAlign('justify'),
61
- };
62
- },
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 })).every((response) => response);
41
+ },
42
+ unsetTextAlign: () => ({ commands }) => {
43
+ return this.options.types.map((type) => commands.resetAttributes(type, "textAlign")).every((response) => response);
44
+ }
45
+ };
46
+ },
47
+ addKeyboardShortcuts() {
48
+ return {
49
+ "Mod-Shift-l": () => this.editor.commands.setTextAlign("left"),
50
+ "Mod-Shift-e": () => this.editor.commands.setTextAlign("center"),
51
+ "Mod-Shift-r": () => this.editor.commands.setTextAlign("right"),
52
+ "Mod-Shift-j": () => this.editor.commands.setTextAlign("justify")
53
+ };
54
+ }
63
55
  });
64
56
 
65
- export { TextAlign, TextAlign as default };
66
- //# sourceMappingURL=index.js.map
57
+ // src/index.ts
58
+ var index_default = TextAlign;
59
+ export {
60
+ TextAlign,
61
+ index_default as default
62
+ };
63
+ //# sourceMappingURL=index.js.map
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sources":["../src/text-align.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 }\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: (alignment: string) => ({ 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 .every(response => response)\n },\n\n unsetTextAlign: () => ({ commands }) => {\n return this.options.types\n .map(type => commands.resetAttributes(type, 'textAlign'))\n .every(response => response)\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"],"names":[],"mappings":";;AA2CA;;;AAGG;AACU,MAAA,SAAS,GAAG,SAAS,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EAAE,SAAS,EAAE,SAAS,EAAE,CAAC;AACrE,qBAAA,KAAK,CAAC,QAAQ,IAAI,QAAQ,CAAC;aAC/B;YAED,cAAc,EAAE,MAAM,CAAC,EAAE,QAAQ,EAAE,KAAI;AACrC,gBAAA,OAAO,IAAI,CAAC,OAAO,CAAC;AACjB,qBAAA,GAAG,CAAC,IAAI,IAAI,QAAQ,CAAC,eAAe,CAAC,IAAI,EAAE,WAAW,CAAC;AACvD,qBAAA,KAAK,CAAC,QAAQ,IAAI,QAAQ,CAAC;aAC/B;SACF;KACF;IAED,oBAAoB,GAAA;QAClB,OAAO;AACL,YAAA,aAAa,EAAE,MAAM,IAAI,CAAC,MAAM,CAAC,QAAQ,CAAC,YAAY,CAAC,MAAM,CAAC;AAC9D,YAAA,aAAa,EAAE,MAAM,IAAI,CAAC,MAAM,CAAC,QAAQ,CAAC,YAAY,CAAC,QAAQ,CAAC;AAChE,YAAA,aAAa,EAAE,MAAM,IAAI,CAAC,MAAM,CAAC,QAAQ,CAAC,YAAY,CAAC,OAAO,CAAC;AAC/D,YAAA,aAAa,EAAE,MAAM,IAAI,CAAC,MAAM,CAAC,QAAQ,CAAC,YAAY,CAAC,SAAS,CAAC;SAClE;KACF;AACF,CAAA;;;;"}
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 }\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 .every(response => response)\n },\n\n unsetTextAlign:\n () =>\n ({ commands }) => {\n return this.options.types.map(type => commands.resetAttributes(type, 'textAlign')).every(response => response)\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;AA+CnB,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,sBAA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7GD,IAAO,gBAAQ;","names":[]}
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": "2.11.6",
4
+ "version": "3.0.0-beta.0",
5
5
  "homepage": "https://tiptap.dev",
6
6
  "keywords": [
7
7
  "tiptap",
@@ -15,24 +15,26 @@
15
15
  "type": "module",
16
16
  "exports": {
17
17
  ".": {
18
- "types": "./dist/index.d.ts",
18
+ "types": {
19
+ "import": "./dist/index.d.ts",
20
+ "require": "./dist/index.d.cts"
21
+ },
19
22
  "import": "./dist/index.js",
20
23
  "require": "./dist/index.cjs"
21
24
  }
22
25
  },
23
26
  "main": "dist/index.cjs",
24
27
  "module": "dist/index.js",
25
- "umd": "dist/index.umd.js",
26
28
  "types": "dist/index.d.ts",
27
29
  "files": [
28
30
  "src",
29
31
  "dist"
30
32
  ],
31
33
  "devDependencies": {
32
- "@tiptap/core": "^2.11.6"
34
+ "@tiptap/core": "^3.0.0-beta.0"
33
35
  },
34
36
  "peerDependencies": {
35
- "@tiptap/core": "^2.7.0"
37
+ "@tiptap/core": "^3.0.0-beta.0"
36
38
  },
37
39
  "repository": {
38
40
  "type": "git",
@@ -40,7 +42,7 @@
40
42
  "directory": "packages/extension-text-align"
41
43
  },
42
44
  "scripts": {
43
- "clean": "rm -rf dist",
44
- "build": "npm run clean && rollup -c"
45
+ "build": "tsup",
46
+ "lint": "prettier ./src/ --check && eslint --cache --quiet --no-error-on-unmatched-pattern ./src/"
45
47
  }
46
- }
48
+ }
package/src/text-align.ts CHANGED
@@ -6,21 +6,21 @@ export interface TextAlignOptions {
6
6
  * @default []
7
7
  * @example ['heading', 'paragraph']
8
8
  */
9
- types: string[],
9
+ types: string[]
10
10
 
11
11
  /**
12
12
  * The alignments which are allowed.
13
13
  * @default ['left', 'center', 'right', 'justify']
14
14
  * @example ['left', 'right']
15
15
  */
16
- alignments: string[],
16
+ alignments: string[]
17
17
 
18
18
  /**
19
19
  * The default alignment.
20
20
  * @default null
21
21
  * @example 'center'
22
22
  */
23
- defaultAlignment: string | null,
23
+ defaultAlignment: string | null
24
24
  }
25
25
 
26
26
  declare module '@tiptap/core' {
@@ -31,12 +31,12 @@ declare module '@tiptap/core' {
31
31
  * @param alignment The alignment
32
32
  * @example editor.commands.setTextAlign('left')
33
33
  */
34
- setTextAlign: (alignment: string) => ReturnType,
34
+ setTextAlign: (alignment: string) => ReturnType
35
35
  /**
36
36
  * Unset the text align attribute
37
37
  * @example editor.commands.unsetTextAlign()
38
38
  */
39
- unsetTextAlign: () => ReturnType,
39
+ unsetTextAlign: () => ReturnType
40
40
  }
41
41
  }
42
42
  }
@@ -83,21 +83,23 @@ export const TextAlign = Extension.create<TextAlignOptions>({
83
83
 
84
84
  addCommands() {
85
85
  return {
86
- setTextAlign: (alignment: string) => ({ commands }) => {
87
- if (!this.options.alignments.includes(alignment)) {
88
- return false
89
- }
86
+ setTextAlign:
87
+ (alignment: string) =>
88
+ ({ commands }) => {
89
+ if (!this.options.alignments.includes(alignment)) {
90
+ return false
91
+ }
90
92
 
91
- return this.options.types
92
- .map(type => commands.updateAttributes(type, { textAlign: alignment }))
93
- .every(response => response)
94
- },
93
+ return this.options.types
94
+ .map(type => commands.updateAttributes(type, { textAlign: alignment }))
95
+ .every(response => response)
96
+ },
95
97
 
96
- unsetTextAlign: () => ({ commands }) => {
97
- return this.options.types
98
- .map(type => commands.resetAttributes(type, 'textAlign'))
99
- .every(response => response)
100
- },
98
+ unsetTextAlign:
99
+ () =>
100
+ ({ commands }) => {
101
+ return this.options.types.map(type => commands.resetAttributes(type, 'textAlign')).every(response => response)
102
+ },
101
103
  }
102
104
  },
103
105
 
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAA;AAE3C,cAAc,iBAAiB,CAAA;AAE/B,eAAe,SAAS,CAAA"}
package/dist/index.umd.js DELETED
@@ -1,75 +0,0 @@
1
- (function (global, factory) {
2
- typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports, require('@tiptap/core')) :
3
- typeof define === 'function' && define.amd ? define(['exports', '@tiptap/core'], factory) :
4
- (global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory(global["@tiptap/extension-text-align"] = {}, global.core));
5
- })(this, (function (exports, core) { 'use strict';
6
-
7
- /**
8
- * This extension allows you to align text.
9
- * @see https://www.tiptap.dev/api/extensions/text-align
10
- */
11
- const TextAlign = core.Extension.create({
12
- name: 'textAlign',
13
- addOptions() {
14
- return {
15
- types: [],
16
- alignments: ['left', 'center', 'right', 'justify'],
17
- defaultAlignment: null,
18
- };
19
- },
20
- addGlobalAttributes() {
21
- return [
22
- {
23
- types: this.options.types,
24
- attributes: {
25
- textAlign: {
26
- default: this.options.defaultAlignment,
27
- parseHTML: element => {
28
- const alignment = element.style.textAlign;
29
- return this.options.alignments.includes(alignment) ? alignment : this.options.defaultAlignment;
30
- },
31
- renderHTML: attributes => {
32
- if (!attributes.textAlign) {
33
- return {};
34
- }
35
- return { style: `text-align: ${attributes.textAlign}` };
36
- },
37
- },
38
- },
39
- },
40
- ];
41
- },
42
- addCommands() {
43
- return {
44
- setTextAlign: (alignment) => ({ commands }) => {
45
- if (!this.options.alignments.includes(alignment)) {
46
- return false;
47
- }
48
- return this.options.types
49
- .map(type => commands.updateAttributes(type, { textAlign: alignment }))
50
- .every(response => response);
51
- },
52
- unsetTextAlign: () => ({ commands }) => {
53
- return this.options.types
54
- .map(type => commands.resetAttributes(type, 'textAlign'))
55
- .every(response => response);
56
- },
57
- };
58
- },
59
- addKeyboardShortcuts() {
60
- return {
61
- 'Mod-Shift-l': () => this.editor.commands.setTextAlign('left'),
62
- 'Mod-Shift-e': () => this.editor.commands.setTextAlign('center'),
63
- 'Mod-Shift-r': () => this.editor.commands.setTextAlign('right'),
64
- 'Mod-Shift-j': () => this.editor.commands.setTextAlign('justify'),
65
- };
66
- },
67
- });
68
-
69
- exports.TextAlign = TextAlign;
70
- exports.default = TextAlign;
71
-
72
- Object.defineProperty(exports, '__esModule', { value: true });
73
-
74
- }));
75
- //# sourceMappingURL=index.umd.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.umd.js","sources":["../src/text-align.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 }\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: (alignment: string) => ({ 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 .every(response => response)\n },\n\n unsetTextAlign: () => ({ commands }) => {\n return this.options.types\n .map(type => commands.resetAttributes(type, 'textAlign'))\n .every(response => response)\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"],"names":["Extension"],"mappings":";;;;;;EA2CA;;;EAGG;AACU,QAAA,SAAS,GAAGA,cAAS,CAAC,MAAM,CAAmB;EAC1D,IAAA,IAAI,EAAE,WAAW;MAEjB,UAAU,GAAA;UACR,OAAO;EACL,YAAA,KAAK,EAAE,EAAE;cACT,UAAU,EAAE,CAAC,MAAM,EAAE,QAAQ,EAAE,OAAO,EAAE,SAAS,CAAC;EAClD,YAAA,gBAAgB,EAAE,IAAI;WACvB;OACF;MAED,mBAAmB,GAAA;UACjB,OAAO;EACL,YAAA;EACE,gBAAA,KAAK,EAAE,IAAI,CAAC,OAAO,CAAC,KAAK;EACzB,gBAAA,UAAU,EAAE;EACV,oBAAA,SAAS,EAAE;EACT,wBAAA,OAAO,EAAE,IAAI,CAAC,OAAO,CAAC,gBAAgB;0BACtC,SAAS,EAAE,OAAO,IAAG;EACnB,4BAAA,MAAM,SAAS,GAAG,OAAO,CAAC,KAAK,CAAC,SAAS;8BAEzC,OAAO,IAAI,CAAC,OAAO,CAAC,UAAU,CAAC,QAAQ,CAAC,SAAS,CAAC,GAAG,SAAS,GAAG,IAAI,CAAC,OAAO,CAAC,gBAAgB;2BAC/F;0BACD,UAAU,EAAE,UAAU,IAAG;EACvB,4BAAA,IAAI,CAAC,UAAU,CAAC,SAAS,EAAE;EACzB,gCAAA,OAAO,EAAE;;8BAGX,OAAO,EAAE,KAAK,EAAE,CAAA,YAAA,EAAe,UAAU,CAAC,SAAS,CAAE,CAAA,E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