@tiptap/extension-text-align 3.0.0-next.1 → 3.0.0-next.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/dist/index.cjs +3 -3
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.js +3 -3
- package/dist/index.js.map +1 -1
- package/package.json +2 -2
- package/src/text-align.ts +4 -4
package/dist/index.cjs
CHANGED
|
@@ -33,7 +33,7 @@ var TextAlign = import_core.Extension.create({
|
|
|
33
33
|
return {
|
|
34
34
|
types: [],
|
|
35
35
|
alignments: ["left", "center", "right", "justify"],
|
|
36
|
-
defaultAlignment:
|
|
36
|
+
defaultAlignment: null
|
|
37
37
|
};
|
|
38
38
|
},
|
|
39
39
|
addGlobalAttributes() {
|
|
@@ -44,11 +44,11 @@ var TextAlign = import_core.Extension.create({
|
|
|
44
44
|
textAlign: {
|
|
45
45
|
default: this.options.defaultAlignment,
|
|
46
46
|
parseHTML: (element) => {
|
|
47
|
-
const alignment = element.style.textAlign
|
|
47
|
+
const alignment = element.style.textAlign;
|
|
48
48
|
return this.options.alignments.includes(alignment) ? alignment : this.options.defaultAlignment;
|
|
49
49
|
},
|
|
50
50
|
renderHTML: (attributes) => {
|
|
51
|
-
if (attributes.textAlign
|
|
51
|
+
if (!attributes.textAlign) {
|
|
52
52
|
return {};
|
|
53
53
|
}
|
|
54
54
|
return { style: `text-align: ${attributes.textAlign}` };
|
package/dist/index.cjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
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 'left'\n * @example 'center'\n */\n defaultAlignment: string,\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:
|
|
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 'left'\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"],"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;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,cAAc,CAAC,cAAsB,CAAC,EAAE,SAAS,MAAM;AACrD,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,MAAM,cAAY,QAAQ;AAAA,MAC/B;AAAA,MAEA,gBAAgB,MAAM,CAAC,EAAE,SAAS,MAAM;AACtC,eAAO,KAAK,QAAQ,MACjB,IAAI,UAAQ,SAAS,gBAAgB,MAAM,WAAW,CAAC,EACvD,MAAM,cAAY,QAAQ;AAAA,MAC/B;AAAA,IACF;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;;;AD3GD,IAAO,cAAQ;","names":[]}
|
package/dist/index.d.cts
CHANGED
package/dist/index.d.ts
CHANGED
package/dist/index.js
CHANGED
|
@@ -6,7 +6,7 @@ var TextAlign = Extension.create({
|
|
|
6
6
|
return {
|
|
7
7
|
types: [],
|
|
8
8
|
alignments: ["left", "center", "right", "justify"],
|
|
9
|
-
defaultAlignment:
|
|
9
|
+
defaultAlignment: null
|
|
10
10
|
};
|
|
11
11
|
},
|
|
12
12
|
addGlobalAttributes() {
|
|
@@ -17,11 +17,11 @@ var TextAlign = Extension.create({
|
|
|
17
17
|
textAlign: {
|
|
18
18
|
default: this.options.defaultAlignment,
|
|
19
19
|
parseHTML: (element) => {
|
|
20
|
-
const alignment = element.style.textAlign
|
|
20
|
+
const alignment = element.style.textAlign;
|
|
21
21
|
return this.options.alignments.includes(alignment) ? alignment : this.options.defaultAlignment;
|
|
22
22
|
},
|
|
23
23
|
renderHTML: (attributes) => {
|
|
24
|
-
if (attributes.textAlign
|
|
24
|
+
if (!attributes.textAlign) {
|
|
25
25
|
return {};
|
|
26
26
|
}
|
|
27
27
|
return { style: `text-align: ${attributes.textAlign}` };
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
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 'left'\n * @example 'center'\n */\n defaultAlignment: string,\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:
|
|
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 'left'\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","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,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,cAAc,CAAC,cAAsB,CAAC,EAAE,SAAS,MAAM;AACrD,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,MAAM,cAAY,QAAQ;AAAA,MAC/B;AAAA,MAEA,gBAAgB,MAAM,CAAC,EAAE,SAAS,MAAM;AACtC,eAAO,KAAK,QAAQ,MACjB,IAAI,UAAQ,SAAS,gBAAgB,MAAM,WAAW,CAAC,EACvD,MAAM,cAAY,QAAQ;AAAA,MAC/B;AAAA,IACF;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;;;AC3GD,IAAO,cAAQ;","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": "3.0.0-next.
|
|
4
|
+
"version": "3.0.0-next.2",
|
|
5
5
|
"homepage": "https://tiptap.dev",
|
|
6
6
|
"keywords": [
|
|
7
7
|
"tiptap",
|
|
@@ -28,7 +28,7 @@
|
|
|
28
28
|
"dist"
|
|
29
29
|
],
|
|
30
30
|
"devDependencies": {
|
|
31
|
-
"@tiptap/core": "^3.0.0-next.
|
|
31
|
+
"@tiptap/core": "^3.0.0-next.2"
|
|
32
32
|
},
|
|
33
33
|
"peerDependencies": {
|
|
34
34
|
"@tiptap/core": "^3.0.0-next.1"
|
package/src/text-align.ts
CHANGED
|
@@ -20,7 +20,7 @@ export interface TextAlignOptions {
|
|
|
20
20
|
* @default 'left'
|
|
21
21
|
* @example 'center'
|
|
22
22
|
*/
|
|
23
|
-
defaultAlignment: string,
|
|
23
|
+
defaultAlignment: string | null,
|
|
24
24
|
}
|
|
25
25
|
|
|
26
26
|
declare module '@tiptap/core' {
|
|
@@ -52,7 +52,7 @@ export const TextAlign = Extension.create<TextAlignOptions>({
|
|
|
52
52
|
return {
|
|
53
53
|
types: [],
|
|
54
54
|
alignments: ['left', 'center', 'right', 'justify'],
|
|
55
|
-
defaultAlignment:
|
|
55
|
+
defaultAlignment: null,
|
|
56
56
|
}
|
|
57
57
|
},
|
|
58
58
|
|
|
@@ -64,12 +64,12 @@ export const TextAlign = Extension.create<TextAlignOptions>({
|
|
|
64
64
|
textAlign: {
|
|
65
65
|
default: this.options.defaultAlignment,
|
|
66
66
|
parseHTML: element => {
|
|
67
|
-
const alignment = element.style.textAlign
|
|
67
|
+
const alignment = element.style.textAlign
|
|
68
68
|
|
|
69
69
|
return this.options.alignments.includes(alignment) ? alignment : this.options.defaultAlignment
|
|
70
70
|
},
|
|
71
71
|
renderHTML: attributes => {
|
|
72
|
-
if (attributes.textAlign
|
|
72
|
+
if (!attributes.textAlign) {
|
|
73
73
|
return {}
|
|
74
74
|
}
|
|
75
75
|
|