@tiptap/extension-text-align 2.0.0-beta.209 → 2.0.0-beta.210
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 +59 -0
- package/dist/{packages/extension-text-align/src/text-align.d.ts → index.d.ts} +24 -21
- package/dist/index.js +59 -0
- package/package.json +23 -10
- package/dist/packages/extension-text-align/src/index.d.ts +0 -3
- package/dist/tiptap-extension-text-align.cjs +0 -60
- package/dist/tiptap-extension-text-align.cjs.map +0 -1
- package/dist/tiptap-extension-text-align.esm.js +0 -55
- package/dist/tiptap-extension-text-align.esm.js.map +0 -1
- package/dist/tiptap-extension-text-align.umd.js +0 -64
- package/dist/tiptap-extension-text-align.umd.js.map +0 -1
package/dist/index.cjs
ADDED
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
"use strict";Object.defineProperty(exports, "__esModule", {value: true});// src/text-align.ts
|
|
2
|
+
var _core = require('@tiptap/core');
|
|
3
|
+
var TextAlign = _core.Extension.create({
|
|
4
|
+
name: "textAlign",
|
|
5
|
+
addOptions() {
|
|
6
|
+
return {
|
|
7
|
+
types: [],
|
|
8
|
+
alignments: ["left", "center", "right", "justify"],
|
|
9
|
+
defaultAlignment: "left"
|
|
10
|
+
};
|
|
11
|
+
},
|
|
12
|
+
addGlobalAttributes() {
|
|
13
|
+
return [
|
|
14
|
+
{
|
|
15
|
+
types: this.options.types,
|
|
16
|
+
attributes: {
|
|
17
|
+
textAlign: {
|
|
18
|
+
default: this.options.defaultAlignment,
|
|
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
|
+
}
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
];
|
|
30
|
+
},
|
|
31
|
+
addCommands() {
|
|
32
|
+
return {
|
|
33
|
+
setTextAlign: (alignment) => ({ commands }) => {
|
|
34
|
+
if (!this.options.alignments.includes(alignment)) {
|
|
35
|
+
return false;
|
|
36
|
+
}
|
|
37
|
+
return this.options.types.every((type) => commands.updateAttributes(type, { textAlign: alignment }));
|
|
38
|
+
},
|
|
39
|
+
unsetTextAlign: () => ({ commands }) => {
|
|
40
|
+
return this.options.types.every((type) => commands.resetAttributes(type, "textAlign"));
|
|
41
|
+
}
|
|
42
|
+
};
|
|
43
|
+
},
|
|
44
|
+
addKeyboardShortcuts() {
|
|
45
|
+
return {
|
|
46
|
+
"Mod-Shift-l": () => this.editor.commands.setTextAlign("left"),
|
|
47
|
+
"Mod-Shift-e": () => this.editor.commands.setTextAlign("center"),
|
|
48
|
+
"Mod-Shift-r": () => this.editor.commands.setTextAlign("right"),
|
|
49
|
+
"Mod-Shift-j": () => this.editor.commands.setTextAlign("justify")
|
|
50
|
+
};
|
|
51
|
+
}
|
|
52
|
+
});
|
|
53
|
+
|
|
54
|
+
// src/index.ts
|
|
55
|
+
var src_default = TextAlign;
|
|
56
|
+
|
|
57
|
+
|
|
58
|
+
|
|
59
|
+
exports.TextAlign = TextAlign; exports.default = src_default;
|
|
@@ -1,21 +1,24 @@
|
|
|
1
|
-
import { Extension } from '@tiptap/core';
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
}
|
|
21
|
-
|
|
1
|
+
import { Extension } from '@tiptap/core';
|
|
2
|
+
|
|
3
|
+
interface TextAlignOptions {
|
|
4
|
+
types: string[];
|
|
5
|
+
alignments: string[];
|
|
6
|
+
defaultAlignment: string;
|
|
7
|
+
}
|
|
8
|
+
declare module '@tiptap/core' {
|
|
9
|
+
interface Commands<ReturnType> {
|
|
10
|
+
textAlign: {
|
|
11
|
+
/**
|
|
12
|
+
* Set the text align attribute
|
|
13
|
+
*/
|
|
14
|
+
setTextAlign: (alignment: string) => ReturnType;
|
|
15
|
+
/**
|
|
16
|
+
* Unset the text align attribute
|
|
17
|
+
*/
|
|
18
|
+
unsetTextAlign: () => ReturnType;
|
|
19
|
+
};
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
declare const TextAlign: Extension<TextAlignOptions, any>;
|
|
23
|
+
|
|
24
|
+
export { TextAlign, TextAlignOptions, TextAlign as default };
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,59 @@
|
|
|
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: "left"
|
|
10
|
+
};
|
|
11
|
+
},
|
|
12
|
+
addGlobalAttributes() {
|
|
13
|
+
return [
|
|
14
|
+
{
|
|
15
|
+
types: this.options.types,
|
|
16
|
+
attributes: {
|
|
17
|
+
textAlign: {
|
|
18
|
+
default: this.options.defaultAlignment,
|
|
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
|
+
}
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
];
|
|
30
|
+
},
|
|
31
|
+
addCommands() {
|
|
32
|
+
return {
|
|
33
|
+
setTextAlign: (alignment) => ({ commands }) => {
|
|
34
|
+
if (!this.options.alignments.includes(alignment)) {
|
|
35
|
+
return false;
|
|
36
|
+
}
|
|
37
|
+
return this.options.types.every((type) => commands.updateAttributes(type, { textAlign: alignment }));
|
|
38
|
+
},
|
|
39
|
+
unsetTextAlign: () => ({ commands }) => {
|
|
40
|
+
return this.options.types.every((type) => commands.resetAttributes(type, "textAlign"));
|
|
41
|
+
}
|
|
42
|
+
};
|
|
43
|
+
},
|
|
44
|
+
addKeyboardShortcuts() {
|
|
45
|
+
return {
|
|
46
|
+
"Mod-Shift-l": () => this.editor.commands.setTextAlign("left"),
|
|
47
|
+
"Mod-Shift-e": () => this.editor.commands.setTextAlign("center"),
|
|
48
|
+
"Mod-Shift-r": () => this.editor.commands.setTextAlign("right"),
|
|
49
|
+
"Mod-Shift-j": () => this.editor.commands.setTextAlign("justify")
|
|
50
|
+
};
|
|
51
|
+
}
|
|
52
|
+
});
|
|
53
|
+
|
|
54
|
+
// src/index.ts
|
|
55
|
+
var src_default = TextAlign;
|
|
56
|
+
export {
|
|
57
|
+
TextAlign,
|
|
58
|
+
src_default as default
|
|
59
|
+
};
|
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.
|
|
4
|
+
"version": "2.0.0-beta.210",
|
|
5
5
|
"homepage": "https://tiptap.dev",
|
|
6
6
|
"keywords": [
|
|
7
7
|
"tiptap",
|
|
@@ -15,28 +15,41 @@
|
|
|
15
15
|
"type": "module",
|
|
16
16
|
"exports": {
|
|
17
17
|
".": {
|
|
18
|
-
"types": "./dist/
|
|
19
|
-
"import": "./dist/
|
|
20
|
-
"require": "./dist/
|
|
18
|
+
"types": "./dist/index.d.ts",
|
|
19
|
+
"import": "./dist/index.js",
|
|
20
|
+
"require": "./dist/index.cjs"
|
|
21
21
|
}
|
|
22
22
|
},
|
|
23
|
-
"main": "dist/
|
|
24
|
-
"
|
|
25
|
-
"
|
|
26
|
-
"types": "dist/packages/extension-text-align/src/index.d.ts",
|
|
23
|
+
"main": "dist/index.cjs",
|
|
24
|
+
"module": "dist/index.js",
|
|
25
|
+
"types": "dist/index.d.ts",
|
|
27
26
|
"files": [
|
|
28
27
|
"src",
|
|
29
28
|
"dist"
|
|
30
29
|
],
|
|
31
30
|
"peerDependencies": {
|
|
32
|
-
"@tiptap/core": "^2.0.0-beta.
|
|
31
|
+
"@tiptap/core": "^2.0.0-beta.209"
|
|
33
32
|
},
|
|
34
33
|
"devDependencies": {
|
|
35
|
-
"@tiptap/core": "^2.0.0-beta.
|
|
34
|
+
"@tiptap/core": "^2.0.0-beta.210"
|
|
36
35
|
},
|
|
37
36
|
"repository": {
|
|
38
37
|
"type": "git",
|
|
39
38
|
"url": "https://github.com/ueberdosis/tiptap",
|
|
40
39
|
"directory": "packages/extension-text-align"
|
|
40
|
+
},
|
|
41
|
+
"scripts": {
|
|
42
|
+
"build": "tsup"
|
|
43
|
+
},
|
|
44
|
+
"tsup": {
|
|
45
|
+
"entry": [
|
|
46
|
+
"src/index.ts"
|
|
47
|
+
],
|
|
48
|
+
"dts": true,
|
|
49
|
+
"splitting": true,
|
|
50
|
+
"format": [
|
|
51
|
+
"esm",
|
|
52
|
+
"cjs"
|
|
53
|
+
]
|
|
41
54
|
}
|
|
42
55
|
}
|
|
@@ -1,60 +0,0 @@
|
|
|
1
|
-
'use strict';
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
|
-
|
|
5
|
-
var core = require('@tiptap/core');
|
|
6
|
-
|
|
7
|
-
const TextAlign = core.Extension.create({
|
|
8
|
-
name: 'textAlign',
|
|
9
|
-
addOptions() {
|
|
10
|
-
return {
|
|
11
|
-
types: [],
|
|
12
|
-
alignments: ['left', 'center', 'right', 'justify'],
|
|
13
|
-
defaultAlignment: 'left',
|
|
14
|
-
};
|
|
15
|
-
},
|
|
16
|
-
addGlobalAttributes() {
|
|
17
|
-
return [
|
|
18
|
-
{
|
|
19
|
-
types: this.options.types,
|
|
20
|
-
attributes: {
|
|
21
|
-
textAlign: {
|
|
22
|
-
default: this.options.defaultAlignment,
|
|
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
|
-
},
|
|
30
|
-
},
|
|
31
|
-
},
|
|
32
|
-
},
|
|
33
|
-
];
|
|
34
|
-
},
|
|
35
|
-
addCommands() {
|
|
36
|
-
return {
|
|
37
|
-
setTextAlign: (alignment) => ({ commands }) => {
|
|
38
|
-
if (!this.options.alignments.includes(alignment)) {
|
|
39
|
-
return false;
|
|
40
|
-
}
|
|
41
|
-
return this.options.types.every(type => commands.updateAttributes(type, { textAlign: alignment }));
|
|
42
|
-
},
|
|
43
|
-
unsetTextAlign: () => ({ commands }) => {
|
|
44
|
-
return this.options.types.every(type => commands.resetAttributes(type, 'textAlign'));
|
|
45
|
-
},
|
|
46
|
-
};
|
|
47
|
-
},
|
|
48
|
-
addKeyboardShortcuts() {
|
|
49
|
-
return {
|
|
50
|
-
'Mod-Shift-l': () => this.editor.commands.setTextAlign('left'),
|
|
51
|
-
'Mod-Shift-e': () => this.editor.commands.setTextAlign('center'),
|
|
52
|
-
'Mod-Shift-r': () => this.editor.commands.setTextAlign('right'),
|
|
53
|
-
'Mod-Shift-j': () => this.editor.commands.setTextAlign('justify'),
|
|
54
|
-
};
|
|
55
|
-
},
|
|
56
|
-
});
|
|
57
|
-
|
|
58
|
-
exports.TextAlign = TextAlign;
|
|
59
|
-
exports["default"] = TextAlign;
|
|
60
|
-
//# sourceMappingURL=tiptap-extension-text-align.cjs.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"tiptap-extension-text-align.cjs","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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,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,55 +0,0 @@
|
|
|
1
|
-
import { Extension } from '@tiptap/core';
|
|
2
|
-
|
|
3
|
-
const TextAlign = Extension.create({
|
|
4
|
-
name: 'textAlign',
|
|
5
|
-
addOptions() {
|
|
6
|
-
return {
|
|
7
|
-
types: [],
|
|
8
|
-
alignments: ['left', 'center', 'right', 'justify'],
|
|
9
|
-
defaultAlignment: 'left',
|
|
10
|
-
};
|
|
11
|
-
},
|
|
12
|
-
addGlobalAttributes() {
|
|
13
|
-
return [
|
|
14
|
-
{
|
|
15
|
-
types: this.options.types,
|
|
16
|
-
attributes: {
|
|
17
|
-
textAlign: {
|
|
18
|
-
default: this.options.defaultAlignment,
|
|
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
|
-
},
|
|
26
|
-
},
|
|
27
|
-
},
|
|
28
|
-
},
|
|
29
|
-
];
|
|
30
|
-
},
|
|
31
|
-
addCommands() {
|
|
32
|
-
return {
|
|
33
|
-
setTextAlign: (alignment) => ({ commands }) => {
|
|
34
|
-
if (!this.options.alignments.includes(alignment)) {
|
|
35
|
-
return false;
|
|
36
|
-
}
|
|
37
|
-
return this.options.types.every(type => commands.updateAttributes(type, { textAlign: alignment }));
|
|
38
|
-
},
|
|
39
|
-
unsetTextAlign: () => ({ commands }) => {
|
|
40
|
-
return this.options.types.every(type => commands.resetAttributes(type, 'textAlign'));
|
|
41
|
-
},
|
|
42
|
-
};
|
|
43
|
-
},
|
|
44
|
-
addKeyboardShortcuts() {
|
|
45
|
-
return {
|
|
46
|
-
'Mod-Shift-l': () => this.editor.commands.setTextAlign('left'),
|
|
47
|
-
'Mod-Shift-e': () => this.editor.commands.setTextAlign('center'),
|
|
48
|
-
'Mod-Shift-r': () => this.editor.commands.setTextAlign('right'),
|
|
49
|
-
'Mod-Shift-j': () => this.editor.commands.setTextAlign('justify'),
|
|
50
|
-
};
|
|
51
|
-
},
|
|
52
|
-
});
|
|
53
|
-
|
|
54
|
-
export { TextAlign, TextAlign as default };
|
|
55
|
-
//# sourceMappingURL=tiptap-extension-text-align.esm.js.map
|
|
@@ -1 +0,0 @@
|
|
|
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,O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 @@
|
|
|
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
|
-
const TextAlign = core.Extension.create({
|
|
8
|
-
name: 'textAlign',
|
|
9
|
-
addOptions() {
|
|
10
|
-
return {
|
|
11
|
-
types: [],
|
|
12
|
-
alignments: ['left', 'center', 'right', 'justify'],
|
|
13
|
-
defaultAlignment: 'left',
|
|
14
|
-
};
|
|
15
|
-
},
|
|
16
|
-
addGlobalAttributes() {
|
|
17
|
-
return [
|
|
18
|
-
{
|
|
19
|
-
types: this.options.types,
|
|
20
|
-
attributes: {
|
|
21
|
-
textAlign: {
|
|
22
|
-
default: this.options.defaultAlignment,
|
|
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
|
-
},
|
|
30
|
-
},
|
|
31
|
-
},
|
|
32
|
-
},
|
|
33
|
-
];
|
|
34
|
-
},
|
|
35
|
-
addCommands() {
|
|
36
|
-
return {
|
|
37
|
-
setTextAlign: (alignment) => ({ commands }) => {
|
|
38
|
-
if (!this.options.alignments.includes(alignment)) {
|
|
39
|
-
return false;
|
|
40
|
-
}
|
|
41
|
-
return this.options.types.every(type => commands.updateAttributes(type, { textAlign: alignment }));
|
|
42
|
-
},
|
|
43
|
-
unsetTextAlign: () => ({ commands }) => {
|
|
44
|
-
return this.options.types.every(type => commands.resetAttributes(type, 'textAlign'));
|
|
45
|
-
},
|
|
46
|
-
};
|
|
47
|
-
},
|
|
48
|
-
addKeyboardShortcuts() {
|
|
49
|
-
return {
|
|
50
|
-
'Mod-Shift-l': () => this.editor.commands.setTextAlign('left'),
|
|
51
|
-
'Mod-Shift-e': () => this.editor.commands.setTextAlign('center'),
|
|
52
|
-
'Mod-Shift-r': () => this.editor.commands.setTextAlign('right'),
|
|
53
|
-
'Mod-Shift-j': () => this.editor.commands.setTextAlign('justify'),
|
|
54
|
-
};
|
|
55
|
-
},
|
|
56
|
-
});
|
|
57
|
-
|
|
58
|
-
exports.TextAlign = TextAlign;
|
|
59
|
-
exports["default"] = TextAlign;
|
|
60
|
-
|
|
61
|
-
Object.defineProperty(exports, '__esModule', { value: true });
|
|
62
|
-
|
|
63
|
-
}));
|
|
64
|
-
//# sourceMappingURL=tiptap-extension-text-align.umd.js.map
|
|
@@ -1 +0,0 @@
|
|
|
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,oBAAA,SAAS,EAAE;EACT,wBAAA,OAAO,EAAE,IAAI,CAAC,OAAO,CAAC,gBAAgB;EACtC,wBAAA,SAAS,EAAE,OAAO,IAAI,OAAO,CAAC,KAAK,CAAC,SAAS,IAAI,IAAI,CAAC,OAAO,CAAC,gBAAgB;0BAC9E,UAAU,EAAE,UAAU,IAAG;8BACvB,IAAI,UAAU,CAAC,SAAS,KAAK,IAAI,CAAC,OAAO,CAAC,gBAAgB,EAAE;EAC1D,gCAAA,OAAO,EAAE,CAAA;EACV,6BAAA;8BAED,OAAO,EAAE,KAAK,EAAE,CAAA,YAAA,EAAe,UAAU,CAAC,SAAS,CAAE,CAAA,EAAE,CAAA;2BACxD;EACF,q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