@tiptap/extension-text-align 3.10.7 → 3.11.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/dist/index.cjs CHANGED
@@ -64,10 +64,10 @@ var TextAlign = import_core.Extension.create({
64
64
  if (!this.options.alignments.includes(alignment)) {
65
65
  return false;
66
66
  }
67
- return this.options.types.map((type) => commands.updateAttributes(type, { textAlign: alignment })).every((response) => response);
67
+ return this.options.types.map((type) => commands.updateAttributes(type, { textAlign: alignment })).some((response) => response);
68
68
  },
69
69
  unsetTextAlign: () => ({ commands }) => {
70
- return this.options.types.map((type) => commands.resetAttributes(type, "textAlign")).every((response) => response);
70
+ return this.options.types.map((type) => commands.resetAttributes(type, "textAlign")).some((response) => response);
71
71
  },
72
72
  toggleTextAlign: (alignment) => ({ editor, commands }) => {
73
73
  if (!this.options.alignments.includes(alignment)) {
@@ -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 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 .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 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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AAA,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":[]}
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,U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AAM,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.js CHANGED
@@ -37,10 +37,10 @@ var TextAlign = Extension.create({
37
37
  if (!this.options.alignments.includes(alignment)) {
38
38
  return false;
39
39
  }
40
- return this.options.types.map((type) => commands.updateAttributes(type, { textAlign: alignment })).every((response) => response);
40
+ return this.options.types.map((type) => commands.updateAttributes(type, { textAlign: alignment })).some((response) => response);
41
41
  },
42
42
  unsetTextAlign: () => ({ commands }) => {
43
- return this.options.types.map((type) => commands.resetAttributes(type, "textAlign")).every((response) => response);
43
+ return this.options.types.map((type) => commands.resetAttributes(type, "textAlign")).some((response) => response);
44
44
  },
45
45
  toggleTextAlign: (alignment) => ({ editor, commands }) => {
46
46
  if (!this.options.alignments.includes(alignment)) {
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 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 .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 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,EAE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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":[]}
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,WA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AAK,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":[]}
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.10.7",
4
+ "version": "3.11.0",
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.10.7"
34
+ "@tiptap/core": "^3.11.0"
35
35
  },
36
36
  "peerDependencies": {
37
- "@tiptap/core": "^3.10.7"
37
+ "@tiptap/core": "^3.11.0"
38
38
  },
39
39
  "repository": {
40
40
  "type": "git",
package/src/text-align.ts CHANGED
@@ -98,13 +98,13 @@ export const TextAlign = Extension.create<TextAlignOptions>({
98
98
 
99
99
  return this.options.types
100
100
  .map(type => commands.updateAttributes(type, { textAlign: alignment }))
101
- .every(response => response)
101
+ .some(response => response)
102
102
  },
103
103
 
104
104
  unsetTextAlign:
105
105
  () =>
106
106
  ({ commands }) => {
107
- return this.options.types.map(type => commands.resetAttributes(type, 'textAlign')).every(response => response)
107
+ return this.options.types.map(type => commands.resetAttributes(type, 'textAlign')).some(response => response)
108
108
  },
109
109
 
110
110
  toggleTextAlign: