@tiptap/extension-text-align 2.0.0-beta.3 → 2.0.0-beta.31

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 CHANGED
@@ -1,6 +1,6 @@
1
1
  MIT License
2
2
 
3
- Copyright (c) 2020, überdosis GbR
3
+ Copyright (c) 2021, überdosis GbR
4
4
 
5
5
  Permission is hereby granted, free of charge, to any person obtaining a copy
6
6
  of this software and associated documentation files (the "Software"), to deal
package/README.md CHANGED
@@ -7,8 +7,8 @@
7
7
  ## Introduction
8
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
10
+ ## Official Documentation
11
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-next/blob/main/LICENSE.md).
14
+ tiptap is open sourced software licensed under the [MIT license](https://github.com/ueberdosis/tiptap/blob/main/LICENSE.md).
@@ -1,22 +1,21 @@
1
- import { Command, Extension } from '@tiptap/core';
2
- declare type TextAlignOptions = {
1
+ import { Extension } from '@tiptap/core';
2
+ export interface TextAlignOptions {
3
3
  types: string[];
4
4
  alignments: string[];
5
5
  defaultAlignment: string;
6
- };
6
+ }
7
7
  declare module '@tiptap/core' {
8
- interface Commands {
8
+ interface Commands<ReturnType> {
9
9
  textAlign: {
10
10
  /**
11
11
  * Set the text align attribute
12
12
  */
13
- setTextAlign: (alignment: string) => Command;
13
+ setTextAlign: (alignment: string) => ReturnType;
14
14
  /**
15
15
  * Unset the text align attribute
16
16
  */
17
- unsetTextAlign: () => Command;
17
+ unsetTextAlign: () => ReturnType;
18
18
  };
19
19
  }
20
20
  }
21
- export declare const TextAlign: Extension<TextAlignOptions>;
22
- export {};
21
+ export declare const TextAlign: Extension<TextAlignOptions, any>;
@@ -6,10 +6,12 @@ var core = require('@tiptap/core');
6
6
 
7
7
  const TextAlign = core.Extension.create({
8
8
  name: 'textAlign',
9
- defaultOptions: {
10
- types: ['heading', 'paragraph'],
11
- alignments: ['left', 'center', 'right', 'justify'],
12
- defaultAlignment: 'left',
9
+ addOptions() {
10
+ return {
11
+ types: [],
12
+ alignments: ['left', 'center', 'right', 'justify'],
13
+ defaultAlignment: 'left',
14
+ };
13
15
  },
14
16
  addGlobalAttributes() {
15
17
  return [
@@ -18,12 +20,13 @@ const TextAlign = core.Extension.create({
18
20
  attributes: {
19
21
  textAlign: {
20
22
  default: this.options.defaultAlignment,
21
- renderHTML: attributes => ({
22
- style: `text-align: ${attributes.textAlign}`,
23
- }),
24
- parseHTML: element => ({
25
- textAlign: element.style.textAlign || this.options.defaultAlignment,
26
- }),
23
+ parseHTML: element => element.style.textAlign || this.options.defaultAlignment,
24
+ renderHTML: attributes => {
25
+ if (attributes.textAlign === this.options.defaultAlignment) {
26
+ return {};
27
+ }
28
+ return { style: `text-align: ${attributes.textAlign}` };
29
+ },
27
30
  },
28
31
  },
29
32
  },
@@ -53,5 +56,5 @@ const TextAlign = core.Extension.create({
53
56
  });
54
57
 
55
58
  exports.TextAlign = TextAlign;
56
- exports.default = TextAlign;
59
+ exports["default"] = TextAlign;
57
60
  //# sourceMappingURL=tiptap-extension-text-align.cjs.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"tiptap-extension-text-align.cjs.js","sources":["../src/text-align.ts"],"sourcesContent":["import { Command, Extension } from '@tiptap/core'\n\ntype TextAlignOptions = {\n types: string[],\n alignments: string[],\n defaultAlignment: string,\n}\n\ndeclare module '@tiptap/core' {\n interface Commands {\n textAlign: {\n /**\n * Set the text align attribute\n */\n setTextAlign: (alignment: string) => Command,\n /**\n * Unset the text align attribute\n */\n unsetTextAlign: () => Command,\n }\n }\n}\n\nexport const TextAlign = Extension.create<TextAlignOptions>({\n name: 'textAlign',\n\n defaultOptions: {\n types: ['heading', 'paragraph'],\n alignments: ['left', 'center', 'right', 'justify'],\n defaultAlignment: 'left',\n },\n\n addGlobalAttributes() {\n return [\n {\n types: this.options.types,\n attributes: {\n textAlign: {\n default: this.options.defaultAlignment,\n renderHTML: attributes => ({\n style: `text-align: ${attributes.textAlign}`,\n }),\n parseHTML: element => ({\n textAlign: element.style.textAlign || this.options.defaultAlignment,\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.every(type => commands.updateAttributes(type, { textAlign: alignment }))\n },\n unsetTextAlign: () => ({ commands }) => {\n return this.options.types.every(type => commands.resetAttributes(type, 'textAlign'))\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":";;;;;;MAuBa,SAAS,GAAGA,cAAS,CAAC,MAAM,CAAmB;IAC1D,IAAI,EAAE,WAAW;IAEjB,cAAc,EAAE;QACd,KAAK,EAAE,CAAC,SAAS,EAAE,WAAW,CAAC;QAC/B,UAAU,EAAE,CAAC,MAAM,EAAE,QAAQ,EAAE,OAAO,EAAE,SAAS,CAAC;QAClD,gBAAgB,EAAE,MAAM;KACzB;IAED,mBAAmB;QACjB,OAAO;YACL;gBACE,KAAK,EAAE,IAAI,CAAC,OAAO,CAAC,KAAK;gBACzB,UAAU,EAAE;oBACV,SAAS,EAAE;wBACT,OAAO,EAAE,IAAI,CAAC,OAAO,CAAC,gBAAgB;wBACtC,UAAU,EAAE,UAAU,KAAK;4BACzB,KAAK,EAAE,eAAe,UAAU,CAAC,SAAS,EAAE;yBAC7C,CAAC;wBACF,SAAS,EAAE,OAAO,KAAK;4BACrB,SAAS,EAAE,OAAO,CAAC,KAAK,CAAC,SAAS,IAAI,IAAI,CAAC,OAAO,CAAC,gBAAgB;yBACpE,CAAC;qBACH;iBACF;aACF;SACF,CAAA;KACF;IAED,WAAW;QACT,OAAO;YACL,YAAY,EAAE,CAAC,SAAiB,KAAK,CAAC,EAAE,QAAQ,EAAE;gBAChD,IAAI,CAAC,IAAI,CAAC,OAAO,CAAC,UAAU,CAAC,QAAQ,CAAC,SAAS,CAAC,EAAE;oBAChD,OAAO,KAAK,CAAA;iBACb;gBAED,OAAO,IAAI,CAAC,OAAO,CAAC,KAAK,CAAC,KAAK,CAAC,IAAI,IAAI,QAAQ,CAAC,gBAAgB,CAAC,IAAI,EAAE,EAAE,SAAS,EAAE,SAAS,EAAE,CAAC,CAAC,CAAA;aACnG;YACD,cAAc,EAAE,MAAM,CAAC,EAAE,QAAQ,EAAE;gBACjC,OAAO,IAAI,CAAC,OAAO,CAAC,KAAK,CAAC,KAAK,CAAC,IAAI,IAAI,QAAQ,CAAC,eAAe,CAAC,IAAI,EAAE,WAAW,CAAC,CAAC,CAAA;aACrF;SACF,CAAA;KACF;IAED,oBAAoB;QAClB,OAAO;YACL,aAAa,EAAE,MAAM,IAAI,CAAC,MAAM,CAAC,QAAQ,CAAC,YAAY,CAAC,MAAM,CAAC;YAC9D,aAAa,EAAE,MAAM,IAAI,CAAC,MAAM,CAAC,QAAQ,CAAC,YAAY,CAAC,QAAQ,CAAC;YAChE,aAAa,EAAE,MAAM,IAAI,CAAC,MAAM,CAAC,QAAQ,CAAC,YAAY,CAAC,OAAO,CAAC;YAC/D,aAAa,EAAE,MAAM,IAAI,CAAC,MAAM,CAAC,QAAQ,CAAC,YAAY,CAAC,SAAS,CAAC;SAClE,CAAA;KACF;CACF;;;;;"}
1
+ {"version":3,"file":"tiptap-extension-text-align.cjs.js","sources":["../src/text-align.ts"],"sourcesContent":["import { Extension } from '@tiptap/core'\n\nexport interface TextAlignOptions {\n types: string[],\n alignments: string[],\n defaultAlignment: string,\n}\n\ndeclare module '@tiptap/core' {\n interface Commands<ReturnType> {\n textAlign: {\n /**\n * Set the text align attribute\n */\n setTextAlign: (alignment: string) => ReturnType,\n /**\n * Unset the text align attribute\n */\n unsetTextAlign: () => ReturnType,\n }\n }\n}\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: 'left',\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 => element.style.textAlign || this.options.defaultAlignment,\n renderHTML: attributes => {\n if (attributes.textAlign === this.options.defaultAlignment) {\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.every(type => commands.updateAttributes(type, { textAlign: alignment }))\n },\n\n unsetTextAlign: () => ({ commands }) => {\n return this.options.types.every(type => commands.resetAttributes(type, 'textAlign'))\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":";;;;;;AAuBa,MAAA,SAAS,GAAGA,cAAS,CAAC,MAAM,CAAmB;AAC1D,IAAA,IAAI,EAAE,WAAW;IAEjB,UAAU,GAAA;QACR,OAAO;AACL,YAAA,KAAK,EAAE,EAAE;YACT,UAAU,EAAE,CAAC,MAAM,EAAE,QAAQ,EAAE,OAAO,EAAE,SAAS,CAAC;AAClD,YAAA,gBAAgB,EAAE,MAAM;SACzB,CAAA;KACF;IAED,m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AO;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,CAAA;KACF;AACF,CAAA;;;;;"}
@@ -2,10 +2,12 @@ import { Extension } from '@tiptap/core';
2
2
 
3
3
  const TextAlign = Extension.create({
4
4
  name: 'textAlign',
5
- defaultOptions: {
6
- types: ['heading', 'paragraph'],
7
- alignments: ['left', 'center', 'right', 'justify'],
8
- defaultAlignment: 'left',
5
+ addOptions() {
6
+ return {
7
+ types: [],
8
+ alignments: ['left', 'center', 'right', 'justify'],
9
+ defaultAlignment: 'left',
10
+ };
9
11
  },
10
12
  addGlobalAttributes() {
11
13
  return [
@@ -14,12 +16,13 @@ const TextAlign = Extension.create({
14
16
  attributes: {
15
17
  textAlign: {
16
18
  default: this.options.defaultAlignment,
17
- renderHTML: attributes => ({
18
- style: `text-align: ${attributes.textAlign}`,
19
- }),
20
- parseHTML: element => ({
21
- textAlign: element.style.textAlign || this.options.defaultAlignment,
22
- }),
19
+ parseHTML: element => element.style.textAlign || this.options.defaultAlignment,
20
+ renderHTML: attributes => {
21
+ if (attributes.textAlign === this.options.defaultAlignment) {
22
+ return {};
23
+ }
24
+ return { style: `text-align: ${attributes.textAlign}` };
25
+ },
23
26
  },
24
27
  },
25
28
  },
@@ -48,6 +51,5 @@ const TextAlign = Extension.create({
48
51
  },
49
52
  });
50
53
 
51
- export default TextAlign;
52
- export { TextAlign };
54
+ export { TextAlign, TextAlign as default };
53
55
  //# sourceMappingURL=tiptap-extension-text-align.esm.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"tiptap-extension-text-align.esm.js","sources":["../src/text-align.ts"],"sourcesContent":["import { Command, Extension } from '@tiptap/core'\n\ntype TextAlignOptions = {\n types: string[],\n alignments: string[],\n defaultAlignment: string,\n}\n\ndeclare module '@tiptap/core' {\n interface Commands {\n textAlign: {\n /**\n * Set the text align attribute\n */\n setTextAlign: (alignment: string) => Command,\n /**\n * Unset the text align attribute\n */\n unsetTextAlign: () => Command,\n }\n }\n}\n\nexport const TextAlign = Extension.create<TextAlignOptions>({\n name: 'textAlign',\n\n defaultOptions: {\n types: ['heading', 'paragraph'],\n alignments: ['left', 'center', 'right', 'justify'],\n defaultAlignment: 'left',\n },\n\n addGlobalAttributes() {\n return [\n {\n types: this.options.types,\n attributes: {\n textAlign: {\n default: this.options.defaultAlignment,\n renderHTML: attributes => ({\n style: `text-align: ${attributes.textAlign}`,\n }),\n parseHTML: element => ({\n textAlign: element.style.textAlign || this.options.defaultAlignment,\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.every(type => commands.updateAttributes(type, { textAlign: alignment }))\n },\n unsetTextAlign: () => ({ commands }) => {\n return this.options.types.every(type => commands.resetAttributes(type, 'textAlign'))\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":";;MAuBa,SAAS,GAAG,SAAS,CAAC,MAAM,CAAmB;IAC1D,IAAI,EAAE,WAAW;IAEjB,cAAc,EAAE;QACd,KAAK,EAAE,CAAC,SAAS,EAAE,WAAW,CAAC;QAC/B,UAAU,EAAE,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AAM,CAAC,QAAQ,CAAC,YAAY,CAAC,QAAQ,CAAC;YAChE,aAAa,EAAE,MAAM,IAAI,CAAC,MAAM,CAAC,QAAQ,CAAC,YAAY,CAAC,OAAO,CAAC;YAC/D,aAAa,EAAE,MAAM,IAAI,CAAC,MAAM,CAAC,QAAQ,CAAC,YAAY,CAAC,SAAS,CAAC;SAClE,CAAA;KACF;CACF;;;;;"}
1
+ {"version":3,"file":"tiptap-extension-text-align.esm.js","sources":["../src/text-align.ts"],"sourcesContent":["import { Extension } from '@tiptap/core'\n\nexport interface TextAlignOptions {\n types: string[],\n alignments: string[],\n defaultAlignment: string,\n}\n\ndeclare module '@tiptap/core' {\n interface Commands<ReturnType> {\n textAlign: {\n /**\n * Set the text align attribute\n */\n setTextAlign: (alignment: string) => ReturnType,\n /**\n * Unset the text align attribute\n */\n unsetTextAlign: () => ReturnType,\n }\n }\n}\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: 'left',\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 => element.style.textAlign || this.options.defaultAlignment,\n renderHTML: attributes => {\n if (attributes.textAlign === this.options.defaultAlignment) {\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.every(type => commands.updateAttributes(type, { textAlign: alignment }))\n },\n\n unsetTextAlign: () => ({ commands }) => {\n return this.options.types.every(type => commands.resetAttributes(type, 'textAlign'))\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":";;AAuBa,MAAA,SAAS,GAAG,SAAS,CAAC,MAAM,CAAmB;AAC1D,IAAA,IAAI,EAAE,WAAW;IAEjB,UAAU,GAAA;QACR,OAAO;AACL,YAAA,KAAK,EAAE,EAAE;YACT,UAAU,EAAE,CAAC,MAAM,EAAE,QAAQ,EAAE,OAAO,EAAE,SAAS,CAAC;AAClD,YAAA,gBAAgB,EAAE,MAAM;SACzB,CAAA;KACF;IAED,mBAAmB,GAAA;QACjB,OAAO;AACL,YAAA;AACE,gBAAA,KAAK,EAAE,IAAI,CAAC,OAAO,CAAC,KAAK;AACzB,gBAAA,UAAU,EAAE;AACV,oBAAA,SAAS,EAAE;AACT,wBAAA,OAAO,EAAE,IAAI,CAAC,OAAO,CAAC,gBAAgB;AACtC,wBAAA,SAAS,EAAE,OAAO,IAAI,OAAO,CAAC,KAAK,CAAC,SAAS,IAAI,IAAI,CAAC,OAAO,CAAC,gBAAgB;wBAC9E,UAAU,EAAE,UAAU,IAAG;4BACvB,IAAI,UAAU,CAAC,SAAS,KAAK,IAAI,CAAC,OAAO,CAAC,gBAAgB,EAAE;AAC1D,gCAAA,OAAO,EAAE,CAAA;AACV,6BAAA;4BAED,OAAO,EAAE,KAAK,EAAE,CAAA,YAAA,EAAe,UAAU,CAAC,SAAS,CAAE,CAAA,EAAE,CAAA;yBACxD;AACF,qBAAA;AACF,iBAAA;AACF,aAAA;SACF,CAAA;KACF;IAED,WAAW,GAAA;QACT,OAAO;YACL,YAAY,EAAE,CAAC,SAAiB,KAAK,CAAC,EAAE,QAAQ,EAAE,KAAI;gBACpD,IAAI,CAAC,IAAI,CAAC,OAAO,CAAC,UAAU,CAAC,QAAQ,CAAC,SAAS,CAAC,EAAE;AAChD,oBAAA,OAAO,KAAK,CAAA;AACb,iBAAA;gBAED,OAAO,IAAI,CAAC,OAAO,CAAC,KAAK,CAAC,KAAK,CAAC,IAAI,IAAI,QAAQ,CAAC,gBAAgB,CAAC,IAAI,EAAE,EAAE,SAAS,EAAE,SAAS,EAAE,CAAC,CAAC,CAAA;aACnG;YAED,cAAc,EAAE,MAAM,CAAC,EAAE,QAAQ,EAAE,KAAI;gBACrC,OAAO,IAAI,CAAC,OAAO,CAAC,KAAK,CAAC,KAAK,CAAC,IAAI,IAAI,QAAQ,CAAC,eAAe,CAAC,IAAI,EAAE,WAAW,CAAC,CAAC,CAAA;aACrF;SACF,CAAA;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,CAAA;KACF;AACF,CAAA;;;;"}
@@ -1,15 +1,17 @@
1
1
  (function (global, factory) {
2
2
  typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports, require('@tiptap/core')) :
3
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';
4
+ (global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory(global["@tiptap/extension-text-align"] = {}, global.core));
5
+ })(this, (function (exports, core) { 'use strict';
6
6
 
7
7
  const TextAlign = core.Extension.create({
8
8
  name: 'textAlign',
9
- defaultOptions: {
10
- types: ['heading', 'paragraph'],
11
- alignments: ['left', 'center', 'right', 'justify'],
12
- defaultAlignment: 'left',
9
+ addOptions() {
10
+ return {
11
+ types: [],
12
+ alignments: ['left', 'center', 'right', 'justify'],
13
+ defaultAlignment: 'left',
14
+ };
13
15
  },
14
16
  addGlobalAttributes() {
15
17
  return [
@@ -18,12 +20,13 @@
18
20
  attributes: {
19
21
  textAlign: {
20
22
  default: this.options.defaultAlignment,
21
- renderHTML: attributes => ({
22
- style: `text-align: ${attributes.textAlign}`,
23
- }),
24
- parseHTML: element => ({
25
- textAlign: element.style.textAlign || this.options.defaultAlignment,
26
- }),
23
+ parseHTML: element => element.style.textAlign || this.options.defaultAlignment,
24
+ renderHTML: attributes => {
25
+ if (attributes.textAlign === this.options.defaultAlignment) {
26
+ return {};
27
+ }
28
+ return { style: `text-align: ${attributes.textAlign}` };
29
+ },
27
30
  },
28
31
  },
29
32
  },
@@ -53,9 +56,9 @@
53
56
  });
54
57
 
55
58
  exports.TextAlign = TextAlign;
56
- exports.default = TextAlign;
59
+ exports["default"] = TextAlign;
57
60
 
58
61
  Object.defineProperty(exports, '__esModule', { value: true });
59
62
 
60
- })));
63
+ }));
61
64
  //# sourceMappingURL=tiptap-extension-text-align.umd.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"tiptap-extension-text-align.umd.js","sources":["../src/text-align.ts"],"sourcesContent":["import { Command, Extension } from '@tiptap/core'\n\ntype TextAlignOptions = {\n types: string[],\n alignments: string[],\n defaultAlignment: string,\n}\n\ndeclare module '@tiptap/core' {\n interface Commands {\n textAlign: {\n /**\n * Set the text align attribute\n */\n setTextAlign: (alignment: string) => Command,\n /**\n * Unset the text align attribute\n */\n unsetTextAlign: () => Command,\n }\n }\n}\n\nexport const TextAlign = Extension.create<TextAlignOptions>({\n name: 'textAlign',\n\n defaultOptions: {\n types: ['heading', 'paragraph'],\n alignments: ['left', 'center', 'right', 'justify'],\n defaultAlignment: 'left',\n },\n\n addGlobalAttributes() {\n return [\n {\n types: this.options.types,\n attributes: {\n textAlign: {\n default: this.options.defaultAlignment,\n renderHTML: attributes => ({\n style: `text-align: ${attributes.textAlign}`,\n }),\n parseHTML: element => ({\n textAlign: element.style.textAlign || this.options.defaultAlignment,\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.every(type => commands.updateAttributes(type, { textAlign: alignment }))\n },\n unsetTextAlign: () => ({ commands }) => {\n return this.options.types.every(type => commands.resetAttributes(type, 'textAlign'))\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":";;;;;;QAuBa,SAAS,GAAGA,cAAS,CAAC,MAAM,CAAmB;MAC1D,IAAI,EAAE,WAAW;MAEjB,cAAc,EAAE;UACd,KAAK,EAAE,CAAC,SAAS,EAAE,WAAW,CAAC;UAC/B,UAAU,EAAE,CAAC,MAAM,EAAE,QAAQ,EAAE,OAAO,EAAE,SAAS,CAAC;UAClD,gBAAgB,EAAE,MAAM;OACzB;MAED,mBAAmB;UACjB,OAAO;cACL;kBACE,KAAK,EAAE,IAAI,CAAC,OAAO,CAAC,KAAK;kBACzB,UAAU,EAAE;sBACV,SAAS,EAAE;0BACT,OAAO,EAAE,IAAI,CAAC,OAAO,CAAC,gBAAgB;0BACtC,UAAU,EAAE,UAAU,KAAK;8BACzB,KAAK,EAAE,eAAe,UAAU,CAAC,SAAS,EAAE;2BAC7C,CAAC;0BACF,SAAS,EAAE,OAAO,KAAK;8BACrB,SAAS,EAAE,OAAO,CAAC,KAAK,CAAC,SAAS,IAAI,IAAI,CAAC,OAAO,CAAC,gBAAgB;2BACpE,CAAC;uBACH;mBACF;eACF;WACF,CAAA;OACF;MAED,WAAW;UACT,OAAO;cACL,YAAY,EAAE,CAAC,SAAiB,KAAK,CAAC,EAAE,QAAQ,EAAE;kBAChD,IAAI,CAAC,IAAI,CAAC,OAAO,CAAC,UAAU,CAAC,QAAQ,CAAC,SAAS,CAAC,EAAE;sBAChD,OAAO,KAAK,CAAA;mBACb;kBAED,OAAO,IAAI,CAAC,OAAO,CAAC,KAAK,CAAC,KAAK,CAAC,IAAI,IAAI,QAAQ,CAAC,gBAAgB,CAAC,IAAI,EAAE,EAAE,SAAS,EAAE,SAAS,EAAE,CAAC,CAAC,CAAA;eACnG;cACD,cAAc,EAAE,MAAM,CAAC,EAAE,QAAQ,EAAE;kBACjC,OAAO,IAAI,CAAC,OAAO,CAAC,KAAK,CAAC,KAAK,CAAC,IAAI,IAAI,QAAQ,CAAC,eAAe,CAAC,IAAI,EAAE,WAAW,CAAC,CAAC,CAAA;eACrF;WACF,CAAA;OACF;MAED,oBAAoB;UAClB,OAAO;cACL,aAAa,EAAE,MAAM,IAAI,CAAC,MAAM,CAAC,QAAQ,CAAC,YAAY,CAAC,MAAM,CAAC;cAC9D,aAAa,EAAE,MAAM,IAAI,CAAC,MAAM,CAAC,QAAQ,CAAC,YAAY,CAAC,QAAQ,CAAC;cAChE,aAAa,EAAE,MAAM,IAAI,CAAC,MAAM,CAAC,QAAQ,CAAC,YAAY,CAAC,OAAO,CAAC;cAC/D,aAAa,EAAE,MAAM,IAAI,CAAC,MAAM,CAAC,QAAQ,CAAC,YAAY,CAAC,SAAS,CAAC;WAClE,CAAA;OACF;GACF;;;;;;;;;;;"}
1
+ {"version":3,"file":"tiptap-extension-text-align.umd.js","sources":["../src/text-align.ts"],"sourcesContent":["import { Extension } from '@tiptap/core'\n\nexport interface TextAlignOptions {\n types: string[],\n alignments: string[],\n defaultAlignment: string,\n}\n\ndeclare module '@tiptap/core' {\n interface Commands<ReturnType> {\n textAlign: {\n /**\n * Set the text align attribute\n */\n setTextAlign: (alignment: string) => ReturnType,\n /**\n * Unset the text align attribute\n */\n unsetTextAlign: () => ReturnType,\n }\n }\n}\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: 'left',\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 => element.style.textAlign || this.options.defaultAlignment,\n renderHTML: attributes => {\n if (attributes.textAlign === this.options.defaultAlignment) {\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.every(type => commands.updateAttributes(type, { textAlign: alignment }))\n },\n\n unsetTextAlign: () => ({ commands }) => {\n return this.options.types.every(type => commands.resetAttributes(type, 'textAlign'))\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":";;;;;;AAuBa,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,MAAM;WACzB,CAAA;OACF;MAED,mBAAmB,GAAA;UACjB,OAAO;EACL,YAAA;EACE,gBAAA,KAAK,EAAE,IAAI,CAAC,OAAO,CAAC,KAAK;EACzB,gBAAA,UAAU,EAAE;EACV,oB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M,IAAI,CAAC,MAAM,CAAC,QAAQ,CAAC,YAAY,CAAC,QAAQ,CAAC;EAChE,YAAA,aAAa,EAAE,MAAM,IAAI,CAAC,MAAM,CAAC,QAAQ,CAAC,YAAY,CAAC,OAAO,CAAC;EAC/D,YAAA,aAAa,EAAE,MAAM,IAAI,CAAC,MAAM,CAAC,QAAQ,CAAC,YAAY,CAAC,SAAS,CAAC;WAClE,CAAA;OACF;EACF,CAAA;;;;;;;;;;;"}
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.0.0-beta.3",
4
+ "version": "2.0.0-beta.31",
5
5
  "homepage": "https://tiptap.dev",
6
6
  "keywords": [
7
7
  "tiptap",
@@ -15,7 +15,6 @@
15
15
  "main": "dist/tiptap-extension-text-align.cjs.js",
16
16
  "umd": "dist/tiptap-extension-text-align.umd.js",
17
17
  "module": "dist/tiptap-extension-text-align.esm.js",
18
- "unpkg": "dist/tiptap-extension-text-align.bundle.umd.min.js",
19
18
  "types": "dist/packages/extension-text-align/src/index.d.ts",
20
19
  "files": [
21
20
  "src",
@@ -24,5 +23,10 @@
24
23
  "peerDependencies": {
25
24
  "@tiptap/core": "^2.0.0-beta.1"
26
25
  },
27
- "gitHead": "7b1d8d103c9d74263fd5c8a6dc146ac5ec4077f5"
26
+ "repository": {
27
+ "type": "git",
28
+ "url": "https://github.com/ueberdosis/tiptap",
29
+ "directory": "packages/extension-text-align"
30
+ },
31
+ "gitHead": "591c0807a2ab5c34b4b7fe12c12511fe4f493ebd"
28
32
  }
package/src/text-align.ts CHANGED
@@ -1,22 +1,22 @@
1
- import { Command, Extension } from '@tiptap/core'
1
+ import { Extension } from '@tiptap/core'
2
2
 
3
- type TextAlignOptions = {
3
+ export interface TextAlignOptions {
4
4
  types: string[],
5
5
  alignments: string[],
6
6
  defaultAlignment: string,
7
7
  }
8
8
 
9
9
  declare module '@tiptap/core' {
10
- interface Commands {
10
+ interface Commands<ReturnType> {
11
11
  textAlign: {
12
12
  /**
13
13
  * Set the text align attribute
14
14
  */
15
- setTextAlign: (alignment: string) => Command,
15
+ setTextAlign: (alignment: string) => ReturnType,
16
16
  /**
17
17
  * Unset the text align attribute
18
18
  */
19
- unsetTextAlign: () => Command,
19
+ unsetTextAlign: () => ReturnType,
20
20
  }
21
21
  }
22
22
  }
@@ -24,10 +24,12 @@ declare module '@tiptap/core' {
24
24
  export const TextAlign = Extension.create<TextAlignOptions>({
25
25
  name: 'textAlign',
26
26
 
27
- defaultOptions: {
28
- types: ['heading', 'paragraph'],
29
- alignments: ['left', 'center', 'right', 'justify'],
30
- defaultAlignment: 'left',
27
+ addOptions() {
28
+ return {
29
+ types: [],
30
+ alignments: ['left', 'center', 'right', 'justify'],
31
+ defaultAlignment: 'left',
32
+ }
31
33
  },
32
34
 
33
35
  addGlobalAttributes() {
@@ -37,12 +39,14 @@ export const TextAlign = Extension.create<TextAlignOptions>({
37
39
  attributes: {
38
40
  textAlign: {
39
41
  default: this.options.defaultAlignment,
40
- renderHTML: attributes => ({
41
- style: `text-align: ${attributes.textAlign}`,
42
- }),
43
- parseHTML: element => ({
44
- textAlign: element.style.textAlign || this.options.defaultAlignment,
45
- }),
42
+ parseHTML: element => element.style.textAlign || this.options.defaultAlignment,
43
+ renderHTML: attributes => {
44
+ if (attributes.textAlign === this.options.defaultAlignment) {
45
+ return {}
46
+ }
47
+
48
+ return { style: `text-align: ${attributes.textAlign}` }
49
+ },
46
50
  },
47
51
  },
48
52
  },
@@ -58,6 +62,7 @@ export const TextAlign = Extension.create<TextAlignOptions>({
58
62
 
59
63
  return this.options.types.every(type => commands.updateAttributes(type, { textAlign: alignment }))
60
64
  },
65
+
61
66
  unsetTextAlign: () => ({ commands }) => {
62
67
  return this.options.types.every(type => commands.resetAttributes(type, 'textAlign'))
63
68
  },
package/CHANGELOG.md DELETED
@@ -1,145 +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.3](https://github.com/ueberdosis/tiptap-next/compare/@tiptap/extension-text-align@2.0.0-beta.2...@tiptap/extension-text-align@2.0.0-beta.3) (2021-04-07)
7
-
8
-
9
- ### Features
10
-
11
- * add resetAttributes() command, deprecate resetNodeAttributes() ([3334d93](https://github.com/ueberdosis/tiptap-next/commit/3334d930f30bd4acb5c314b4ec1934b6a1e0b712))
12
-
13
-
14
-
15
-
16
-
17
- # [2.0.0-beta.2](https://github.com/ueberdosis/tiptap-next/compare/@tiptap/extension-text-align@2.0.0-beta.1...@tiptap/extension-text-align@2.0.0-beta.2) (2021-04-07)
18
-
19
-
20
- ### Features
21
-
22
- * add updateAttributes() command, deprecate updateNodeAttributes(), fix [#254](https://github.com/ueberdosis/tiptap-next/issues/254) ([aac32b4](https://github.com/ueberdosis/tiptap-next/commit/aac32b4df6a1dfd93500e09d3433fcd8acad5fbe))
23
-
24
-
25
-
26
-
27
-
28
- # [2.0.0-beta.1](https://github.com/ueberdosis/tiptap-next/compare/@tiptap/extension-text-align@2.0.0-alpha.12...@tiptap/extension-text-align@2.0.0-beta.1) (2021-03-05)
29
-
30
- **Note:** Version bump only for package @tiptap/extension-text-align
31
-
32
-
33
-
34
-
35
-
36
- # [2.0.0-alpha.12](https://github.com/ueberdosis/tiptap-next/compare/@tiptap/extension-text-align@2.0.0-alpha.11...@tiptap/extension-text-align@2.0.0-alpha.12) (2021-02-16)
37
-
38
- **Note:** Version bump only for package @tiptap/extension-text-align
39
-
40
-
41
-
42
-
43
-
44
- # [2.0.0-alpha.11](https://github.com/ueberdosis/tiptap-next/compare/@tiptap/extension-text-align@2.0.0-alpha.10...@tiptap/extension-text-align@2.0.0-alpha.11) (2021-02-07)
45
-
46
- **Note:** Version bump only for package @tiptap/extension-text-align
47
-
48
-
49
-
50
-
51
-
52
- # [2.0.0-alpha.10](https://github.com/ueberdosis/tiptap-next/compare/@tiptap/extension-text-align@2.0.0-alpha.9...@tiptap/extension-text-align@2.0.0-alpha.10) (2021-02-05)
53
-
54
- **Note:** Version bump only for package @tiptap/extension-text-align
55
-
56
-
57
-
58
-
59
-
60
- # [2.0.0-alpha.9](https://github.com/ueberdosis/tiptap-next/compare/@tiptap/extension-text-align@2.0.0-alpha.8...@tiptap/extension-text-align@2.0.0-alpha.9) (2021-01-29)
61
-
62
- **Note:** Version bump only for package @tiptap/extension-text-align
63
-
64
-
65
-
66
-
67
-
68
- # [2.0.0-alpha.8](https://github.com/ueberdosis/tiptap-next/compare/@tiptap/extension-text-align@2.0.0-alpha.7...@tiptap/extension-text-align@2.0.0-alpha.8) (2021-01-29)
69
-
70
- **Note:** Version bump only for package @tiptap/extension-text-align
71
-
72
-
73
-
74
-
75
-
76
- # [2.0.0-alpha.7](https://github.com/ueberdosis/tiptap-next/compare/@tiptap/extension-text-align@2.0.0-alpha.6...@tiptap/extension-text-align@2.0.0-alpha.7) (2021-01-28)
77
-
78
- **Note:** Version bump only for package @tiptap/extension-text-align
79
-
80
-
81
-
82
-
83
-
84
- # [2.0.0-alpha.6](https://github.com/ueberdosis/tiptap-next/compare/@tiptap/extension-text-align@2.0.0-alpha.5...@tiptap/extension-text-align@2.0.0-alpha.6) (2021-01-06)
85
-
86
- **Note:** Version bump only for package @tiptap/extension-text-align
87
-
88
-
89
-
90
-
91
-
92
- # [2.0.0-alpha.5](https://github.com/ueberdosis/tiptap-next/compare/@tiptap/extension-text-align@2.0.0-alpha.4...@tiptap/extension-text-align@2.0.0-alpha.5) (2020-12-18)
93
-
94
- **Note:** Version bump only for package @tiptap/extension-text-align
95
-
96
-
97
-
98
-
99
-
100
- # [2.0.0-alpha.4](https://github.com/ueberdosis/tiptap-next/compare/@tiptap/extension-text-align@2.0.0-alpha.3...@tiptap/extension-text-align@2.0.0-alpha.4) (2020-12-02)
101
-
102
- **Note:** Version bump only for package @tiptap/extension-text-align
103
-
104
-
105
-
106
-
107
-
108
- # [2.0.0-alpha.3](https://github.com/ueberdosis/tiptap-next/compare/@tiptap/extension-text-align@2.0.0-alpha.2...@tiptap/extension-text-align@2.0.0-alpha.3) (2020-11-19)
109
-
110
- **Note:** Version bump only for package @tiptap/extension-text-align
111
-
112
-
113
-
114
-
115
-
116
- # [2.0.0-alpha.2](https://github.com/ueberdosis/tiptap-next/compare/@tiptap/extension-text-align@2.0.0-alpha.1...@tiptap/extension-text-align@2.0.0-alpha.2) (2020-11-19)
117
-
118
- **Note:** Version bump only for package @tiptap/extension-text-align
119
-
120
-
121
-
122
-
123
-
124
- # [2.0.0-alpha.1](https://github.com/ueberdosis/tiptap-next/compare/@tiptap/extension-text-align@1.0.0-alpha.2...@tiptap/extension-text-align@2.0.0-alpha.1) (2020-11-18)
125
-
126
- **Note:** Version bump only for package @tiptap/extension-text-align
127
-
128
-
129
-
130
-
131
-
132
- # [1.0.0-alpha.2](https://github.com/ueberdosis/tiptap-next/compare/@tiptap/extension-text-align@1.0.0-alpha.1...@tiptap/extension-text-align@1.0.0-alpha.2) (2020-11-16)
133
-
134
- **Note:** Version bump only for package @tiptap/extension-text-align
135
-
136
-
137
-
138
-
139
-
140
- # 1.0.0-alpha.1 (2020-11-16)
141
-
142
-
143
- ### Reverts
144
-
145
- * Revert "use global namespace" ([0c9ce26](https://github.com/ueberdosis/tiptap-next/commit/0c9ce26c02c07d88a757c01b0a9d7f9e2b0b7502))
@@ -1,2 +0,0 @@
1
- !function(t,e){"object"==typeof exports&&"undefined"!=typeof module?e(exports,require("@tiptap/core")):"function"==typeof define&&define.amd?define(["exports","@tiptap/core"],e):e((t="undefined"!=typeof globalThis?globalThis:t||self)["@tiptap/extension-text-align"]={},t["@tiptap/core"])}(this,(function(t,e){"use strict";const i=e.Extension.create({name:"textAlign",defaultOptions:{types:["heading","paragraph"],alignments:["left","center","right","justify"],defaultAlignment:"left"},addGlobalAttributes(){return[{types:this.options.types,attributes:{textAlign:{default:this.options.defaultAlignment,renderHTML:t=>({style:`text-align: ${t.textAlign}`}),parseHTML:t=>({textAlign:t.style.textAlign||this.options.defaultAlignment})}}}]},addCommands(){return{setTextAlign:t=>({commands:e})=>!!this.options.alignments.includes(t)&&this.options.types.every((i=>e.updateAttributes(i,{textAlign:t}))),unsetTextAlign:()=>({commands:t})=>this.options.types.every((e=>t.resetAttributes(e,"textAlign")))}},addKeyboardShortcuts(){return{"Mod-Shift-l":()=>this.editor.commands.setTextAlign("left"),"Mod-Shift-e":()=>this.editor.commands.setTextAlign("center"),"Mod-Shift-r":()=>this.editor.commands.setTextAlign("right"),"Mod-Shift-j":()=>this.editor.commands.setTextAlign("justify")}}});t.TextAlign=i,t.default=i,Object.defineProperty(t,"__esModule",{value:!0})}));
2
- //# sourceMappingURL=tiptap-extension-text-align.bundle.umd.min.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"tiptap-extension-text-align.bundle.umd.min.js","sources":["../src/text-align.ts"],"sourcesContent":["import { Command, Extension } from '@tiptap/core'\n\ntype TextAlignOptions = {\n types: string[],\n alignments: string[],\n defaultAlignment: string,\n}\n\ndeclare module '@tiptap/core' {\n interface Commands {\n textAlign: {\n /**\n * Set the text align attribute\n */\n setTextAlign: (alignment: string) => Command,\n /**\n * Unset the text align attribute\n */\n unsetTextAlign: () => Command,\n }\n }\n}\n\nexport const TextAlign = Extension.create<TextAlignOptions>({\n name: 'textAlign',\n\n defaultOptions: {\n types: ['heading', 'paragraph'],\n alignments: ['left', 'center', 'right', 'justify'],\n defaultAlignment: 'left',\n },\n\n addGlobalAttributes() {\n return [\n {\n types: this.options.types,\n attributes: {\n textAlign: {\n default: this.options.defaultAlignment,\n renderHTML: attributes => ({\n style: `text-align: ${attributes.textAlign}`,\n }),\n parseHTML: element => ({\n textAlign: element.style.textAlign || this.options.defaultAlignment,\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.every(type => commands.updateAttributes(type, { textAlign: alignment }))\n },\n unsetTextAlign: () => ({ commands }) => {\n return this.options.types.every(type => commands.resetAttributes(type, 'textAlign'))\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":["TextAlign","Extension","create","name","defaultOptions","types","alignments","defaultAlignment","[object Object]","this","options","attributes","textAlign","default","renderHTML","style","parseHTML","element","setTextAlign","alignment","commands","includes","every","type","updateAttributes","unsetTextAlign","resetAttributes","Mod-Shift-l","editor","Mod-Shift-e","Mod-Shift-r","Mod-Shift-j"],"mappings":"wUAuBaA,EAAYC,YAAUC,OAAyB,CAC1DC,KAAM,YAENC,eAAgB,CACdC,MAAO,CAAC,UAAW,aACnBC,WAAY,CAAC,OAAQ,SAAU,QAAS,WACxCC,iBAAkB,QAGpBC,sBACE,MAAO,CACL,CACEH,MAAOI,KAAKC,QAAQL,MACpBM,WAAY,CACVC,UAAW,CACTC,QAASJ,KAAKC,QAAQH,iBACtBO,WAAYH,KACVI,MAAO,eAAeJ,EAAWC,cAEnCI,UAAWC,KACTL,UAAWK,EAAQF,MAAMH,WAAaH,KAAKC,QAAQH,wBAQ/DC,cACE,MAAO,CACLU,aAAeC,GAAsB,EAAGC,SAAAA,OACjCX,KAAKC,QAAQJ,WAAWe,SAASF,IAI/BV,KAAKC,QAAQL,MAAMiB,OAAMC,GAAQH,EAASI,iBAAiBD,EAAM,CAAEX,UAAWO,MAEvFM,eAAgB,IAAM,EAAGL,SAAAA,KAChBX,KAAKC,QAAQL,MAAMiB,OAAMC,GAAQH,EAASM,gBAAgBH,EAAM,iBAK7Ef,uBACE,MAAO,CACLmB,cAAe,IAAMlB,KAAKmB,OAAOR,SAASF,aAAa,QACvDW,cAAe,IAAMpB,KAAKmB,OAAOR,SAASF,aAAa,UACvDY,cAAe,IAAMrB,KAAKmB,OAAOR,SAASF,aAAa,SACvDa,cAAe,IAAMtB,KAAKmB,OAAOR,SAASF,aAAa"}