@tiptap/extension-text-align 3.0.0-next.0 → 3.0.0-next.1
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 +85 -66
- package/dist/index.cjs.map +1 -1
- package/dist/{packages/extension-text-align/src/text-align.d.ts → index.d.cts} +5 -2
- package/dist/index.d.ts +46 -0
- package/dist/index.js +60 -63
- package/dist/index.js.map +1 -1
- package/package.json +6 -8
- package/dist/index.umd.js +0 -75
- package/dist/index.umd.js.map +0 -1
- package/dist/packages/core/src/CommandManager.d.ts +0 -20
- package/dist/packages/core/src/Editor.d.ts +0 -159
- package/dist/packages/core/src/EventEmitter.d.ts +0 -11
- package/dist/packages/core/src/Extension.d.ts +0 -343
- package/dist/packages/core/src/ExtensionManager.d.ts +0 -55
- package/dist/packages/core/src/InputRule.d.ts +0 -42
- package/dist/packages/core/src/Mark.d.ts +0 -451
- package/dist/packages/core/src/Node.d.ts +0 -611
- package/dist/packages/core/src/NodePos.d.ts +0 -44
- package/dist/packages/core/src/NodeView.d.ts +0 -31
- package/dist/packages/core/src/PasteRule.d.ts +0 -50
- package/dist/packages/core/src/Tracker.d.ts +0 -11
- package/dist/packages/core/src/commands/blur.d.ts +0 -13
- package/dist/packages/core/src/commands/clearContent.d.ts +0 -14
- package/dist/packages/core/src/commands/clearNodes.d.ts +0 -13
- package/dist/packages/core/src/commands/command.d.ts +0 -18
- package/dist/packages/core/src/commands/createParagraphNear.d.ts +0 -13
- package/dist/packages/core/src/commands/cut.d.ts +0 -20
- package/dist/packages/core/src/commands/deleteCurrentNode.d.ts +0 -13
- package/dist/packages/core/src/commands/deleteNode.d.ts +0 -15
- package/dist/packages/core/src/commands/deleteRange.d.ts +0 -14
- package/dist/packages/core/src/commands/deleteSelection.d.ts +0 -13
- package/dist/packages/core/src/commands/enter.d.ts +0 -13
- package/dist/packages/core/src/commands/exitCode.d.ts +0 -13
- package/dist/packages/core/src/commands/extendMarkRange.d.ts +0 -25
- package/dist/packages/core/src/commands/first.d.ts +0 -14
- package/dist/packages/core/src/commands/focus.d.ts +0 -27
- package/dist/packages/core/src/commands/forEach.d.ts +0 -14
- package/dist/packages/core/src/commands/index.d.ts +0 -55
- package/dist/packages/core/src/commands/insertContent.d.ts +0 -34
- package/dist/packages/core/src/commands/insertContentAt.d.ts +0 -47
- package/dist/packages/core/src/commands/join.d.ts +0 -41
- package/dist/packages/core/src/commands/joinItemBackward.d.ts +0 -13
- package/dist/packages/core/src/commands/joinItemForward.d.ts +0 -13
- package/dist/packages/core/src/commands/joinTextblockBackward.d.ts +0 -12
- package/dist/packages/core/src/commands/joinTextblockForward.d.ts +0 -12
- package/dist/packages/core/src/commands/keyboardShortcut.d.ts +0 -14
- package/dist/packages/core/src/commands/lift.d.ts +0 -17
- package/dist/packages/core/src/commands/liftEmptyBlock.d.ts +0 -13
- package/dist/packages/core/src/commands/liftListItem.d.ts +0 -15
- package/dist/packages/core/src/commands/newlineInCode.d.ts +0 -13
- package/dist/packages/core/src/commands/resetAttributes.d.ts +0 -16
- package/dist/packages/core/src/commands/scrollIntoView.d.ts +0 -13
- package/dist/packages/core/src/commands/selectAll.d.ts +0 -13
- package/dist/packages/core/src/commands/selectNodeBackward.d.ts +0 -13
- package/dist/packages/core/src/commands/selectNodeForward.d.ts +0 -13
- package/dist/packages/core/src/commands/selectParentNode.d.ts +0 -13
- package/dist/packages/core/src/commands/selectTextblockEnd.d.ts +0 -13
- package/dist/packages/core/src/commands/selectTextblockStart.d.ts +0 -13
- package/dist/packages/core/src/commands/setContent.d.ts +0 -40
- package/dist/packages/core/src/commands/setMark.d.ts +0 -15
- package/dist/packages/core/src/commands/setMeta.d.ts +0 -15
- package/dist/packages/core/src/commands/setNode.d.ts +0 -16
- package/dist/packages/core/src/commands/setNodeSelection.d.ts +0 -14
- package/dist/packages/core/src/commands/setTextSelection.d.ts +0 -14
- package/dist/packages/core/src/commands/sinkListItem.d.ts +0 -15
- package/dist/packages/core/src/commands/splitBlock.d.ts +0 -17
- package/dist/packages/core/src/commands/splitListItem.d.ts +0 -15
- package/dist/packages/core/src/commands/toggleList.d.ts +0 -18
- package/dist/packages/core/src/commands/toggleMark.d.ts +0 -30
- package/dist/packages/core/src/commands/toggleNode.d.ts +0 -17
- package/dist/packages/core/src/commands/toggleWrap.d.ts +0 -16
- package/dist/packages/core/src/commands/undoInputRule.d.ts +0 -13
- package/dist/packages/core/src/commands/unsetAllMarks.d.ts +0 -13
- package/dist/packages/core/src/commands/unsetMark.d.ts +0 -25
- package/dist/packages/core/src/commands/updateAttributes.d.ts +0 -24
- package/dist/packages/core/src/commands/wrapIn.d.ts +0 -16
- package/dist/packages/core/src/commands/wrapInList.d.ts +0 -16
- package/dist/packages/core/src/extensions/clipboardTextSerializer.d.ts +0 -5
- package/dist/packages/core/src/extensions/commands.d.ts +0 -3
- package/dist/packages/core/src/extensions/editable.d.ts +0 -2
- package/dist/packages/core/src/extensions/focusEvents.d.ts +0 -2
- package/dist/packages/core/src/extensions/index.d.ts +0 -6
- package/dist/packages/core/src/extensions/keymap.d.ts +0 -2
- package/dist/packages/core/src/extensions/tabindex.d.ts +0 -2
- package/dist/packages/core/src/helpers/combineTransactionSteps.d.ts +0 -10
- package/dist/packages/core/src/helpers/createChainableState.d.ts +0 -10
- package/dist/packages/core/src/helpers/createDocument.d.ts +0 -12
- package/dist/packages/core/src/helpers/createNodeFromContent.d.ts +0 -15
- package/dist/packages/core/src/helpers/defaultBlockAt.d.ts +0 -7
- package/dist/packages/core/src/helpers/findChildren.d.ts +0 -9
- package/dist/packages/core/src/helpers/findChildrenInRange.d.ts +0 -10
- package/dist/packages/core/src/helpers/findParentNode.d.ts +0 -16
- package/dist/packages/core/src/helpers/findParentNodeClosestToPos.d.ts +0 -17
- package/dist/packages/core/src/helpers/generateHTML.d.ts +0 -8
- package/dist/packages/core/src/helpers/generateJSON.d.ts +0 -8
- package/dist/packages/core/src/helpers/generateText.d.ts +0 -12
- package/dist/packages/core/src/helpers/getAttributes.d.ts +0 -9
- package/dist/packages/core/src/helpers/getAttributesFromExtensions.d.ts +0 -6
- package/dist/packages/core/src/helpers/getChangedRanges.d.ts +0 -11
- package/dist/packages/core/src/helpers/getDebugJSON.d.ts +0 -8
- package/dist/packages/core/src/helpers/getExtensionField.d.ts +0 -9
- package/dist/packages/core/src/helpers/getHTMLFromFragment.d.ts +0 -2
- package/dist/packages/core/src/helpers/getMarkAttributes.d.ts +0 -3
- package/dist/packages/core/src/helpers/getMarkRange.d.ts +0 -3
- package/dist/packages/core/src/helpers/getMarkType.d.ts +0 -2
- package/dist/packages/core/src/helpers/getMarksBetween.d.ts +0 -3
- package/dist/packages/core/src/helpers/getNodeAtPosition.d.ts +0 -11
- package/dist/packages/core/src/helpers/getNodeAttributes.d.ts +0 -3
- package/dist/packages/core/src/helpers/getNodeType.d.ts +0 -2
- package/dist/packages/core/src/helpers/getRenderedAttributes.d.ts +0 -3
- package/dist/packages/core/src/helpers/getSchema.d.ts +0 -4
- package/dist/packages/core/src/helpers/getSchemaByResolvedExtensions.d.ts +0 -10
- package/dist/packages/core/src/helpers/getSchemaTypeByName.d.ts +0 -8
- package/dist/packages/core/src/helpers/getSchemaTypeNameByName.d.ts +0 -8
- package/dist/packages/core/src/helpers/getSplittedAttributes.d.ts +0 -9
- package/dist/packages/core/src/helpers/getText.d.ts +0 -15
- package/dist/packages/core/src/helpers/getTextBetween.d.ts +0 -14
- package/dist/packages/core/src/helpers/getTextContentFromNodes.d.ts +0 -8
- package/dist/packages/core/src/helpers/getTextSerializersFromSchema.d.ts +0 -8
- package/dist/packages/core/src/helpers/index.d.ts +0 -50
- package/dist/packages/core/src/helpers/injectExtensionAttributesToParseRule.d.ts +0 -9
- package/dist/packages/core/src/helpers/isActive.d.ts +0 -2
- package/dist/packages/core/src/helpers/isAtEndOfNode.d.ts +0 -2
- package/dist/packages/core/src/helpers/isAtStartOfNode.d.ts +0 -2
- package/dist/packages/core/src/helpers/isExtensionRulesEnabled.d.ts +0 -2
- package/dist/packages/core/src/helpers/isList.d.ts +0 -2
- package/dist/packages/core/src/helpers/isMarkActive.d.ts +0 -3
- package/dist/packages/core/src/helpers/isNodeActive.d.ts +0 -3
- package/dist/packages/core/src/helpers/isNodeEmpty.d.ts +0 -8
- package/dist/packages/core/src/helpers/isNodeSelection.d.ts +0 -2
- package/dist/packages/core/src/helpers/isTextSelection.d.ts +0 -2
- package/dist/packages/core/src/helpers/posToDOMRect.d.ts +0 -2
- package/dist/packages/core/src/helpers/resolveFocusPosition.d.ts +0 -4
- package/dist/packages/core/src/helpers/selectionToInsertionEnd.d.ts +0 -2
- package/dist/packages/core/src/helpers/splitExtensions.d.ts +0 -9
- package/dist/packages/core/src/index.d.ts +0 -24
- package/dist/packages/core/src/inputRules/index.d.ts +0 -5
- package/dist/packages/core/src/inputRules/markInputRule.d.ts +0 -13
- package/dist/packages/core/src/inputRules/nodeInputRule.d.ts +0 -23
- package/dist/packages/core/src/inputRules/textInputRule.d.ts +0 -10
- package/dist/packages/core/src/inputRules/textblockTypeInputRule.d.ts +0 -15
- package/dist/packages/core/src/inputRules/wrappingInputRule.d.ts +0 -28
- package/dist/packages/core/src/pasteRules/index.d.ts +0 -3
- package/dist/packages/core/src/pasteRules/markPasteRule.d.ts +0 -13
- package/dist/packages/core/src/pasteRules/nodePasteRule.d.ts +0 -13
- package/dist/packages/core/src/pasteRules/textPasteRule.d.ts +0 -10
- package/dist/packages/core/src/style.d.ts +0 -1
- package/dist/packages/core/src/types.d.ts +0 -253
- package/dist/packages/core/src/utilities/callOrReturn.d.ts +0 -9
- package/dist/packages/core/src/utilities/createStyleTag.d.ts +0 -1
- package/dist/packages/core/src/utilities/deleteProps.d.ts +0 -6
- package/dist/packages/core/src/utilities/elementFromString.d.ts +0 -1
- package/dist/packages/core/src/utilities/escapeForRegEx.d.ts +0 -1
- package/dist/packages/core/src/utilities/findDuplicates.d.ts +0 -1
- package/dist/packages/core/src/utilities/fromString.d.ts +0 -1
- package/dist/packages/core/src/utilities/index.d.ts +0 -20
- package/dist/packages/core/src/utilities/isAndroid.d.ts +0 -1
- package/dist/packages/core/src/utilities/isEmptyObject.d.ts +0 -1
- package/dist/packages/core/src/utilities/isFunction.d.ts +0 -1
- package/dist/packages/core/src/utilities/isMacOS.d.ts +0 -1
- package/dist/packages/core/src/utilities/isNumber.d.ts +0 -1
- package/dist/packages/core/src/utilities/isPlainObject.d.ts +0 -1
- package/dist/packages/core/src/utilities/isRegExp.d.ts +0 -1
- package/dist/packages/core/src/utilities/isString.d.ts +0 -1
- package/dist/packages/core/src/utilities/isiOS.d.ts +0 -1
- package/dist/packages/core/src/utilities/mergeAttributes.d.ts +0 -1
- package/dist/packages/core/src/utilities/mergeDeep.d.ts +0 -1
- package/dist/packages/core/src/utilities/minMax.d.ts +0 -1
- package/dist/packages/core/src/utilities/objectIncludes.d.ts +0 -8
- package/dist/packages/core/src/utilities/removeDuplicates.d.ts +0 -8
- package/dist/packages/extension-text-align/src/index.d.ts +0 -3
package/dist/index.cjs
CHANGED
|
@@ -1,71 +1,90 @@
|
|
|
1
|
-
|
|
1
|
+
"use strict";
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
var __export = (target, all) => {
|
|
7
|
+
for (var name in all)
|
|
8
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
+
};
|
|
10
|
+
var __copyProps = (to, from, except, desc) => {
|
|
11
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
+
for (let key of __getOwnPropNames(from))
|
|
13
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
+
}
|
|
16
|
+
return to;
|
|
17
|
+
};
|
|
18
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
2
19
|
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
20
|
+
// src/index.ts
|
|
21
|
+
var src_exports = {};
|
|
22
|
+
__export(src_exports, {
|
|
23
|
+
TextAlign: () => TextAlign,
|
|
24
|
+
default: () => src_default
|
|
25
|
+
});
|
|
26
|
+
module.exports = __toCommonJS(src_exports);
|
|
6
27
|
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
const alignment = element.style.textAlign || this.options.defaultAlignment;
|
|
29
|
-
return this.options.alignments.includes(alignment) ? alignment : this.options.defaultAlignment;
|
|
30
|
-
},
|
|
31
|
-
renderHTML: attributes => {
|
|
32
|
-
if (attributes.textAlign === this.options.defaultAlignment) {
|
|
33
|
-
return {};
|
|
34
|
-
}
|
|
35
|
-
return { style: `text-align: ${attributes.textAlign}` };
|
|
36
|
-
},
|
|
37
|
-
},
|
|
38
|
-
},
|
|
39
|
-
},
|
|
40
|
-
];
|
|
41
|
-
},
|
|
42
|
-
addCommands() {
|
|
43
|
-
return {
|
|
44
|
-
setTextAlign: (alignment) => ({ commands }) => {
|
|
45
|
-
if (!this.options.alignments.includes(alignment)) {
|
|
46
|
-
return false;
|
|
47
|
-
}
|
|
48
|
-
return this.options.types
|
|
49
|
-
.map(type => commands.updateAttributes(type, { textAlign: alignment }))
|
|
50
|
-
.every(response => response);
|
|
28
|
+
// src/text-align.ts
|
|
29
|
+
var import_core = require("@tiptap/core");
|
|
30
|
+
var TextAlign = import_core.Extension.create({
|
|
31
|
+
name: "textAlign",
|
|
32
|
+
addOptions() {
|
|
33
|
+
return {
|
|
34
|
+
types: [],
|
|
35
|
+
alignments: ["left", "center", "right", "justify"],
|
|
36
|
+
defaultAlignment: "left"
|
|
37
|
+
};
|
|
38
|
+
},
|
|
39
|
+
addGlobalAttributes() {
|
|
40
|
+
return [
|
|
41
|
+
{
|
|
42
|
+
types: this.options.types,
|
|
43
|
+
attributes: {
|
|
44
|
+
textAlign: {
|
|
45
|
+
default: this.options.defaultAlignment,
|
|
46
|
+
parseHTML: (element) => {
|
|
47
|
+
const alignment = element.style.textAlign || this.options.defaultAlignment;
|
|
48
|
+
return this.options.alignments.includes(alignment) ? alignment : this.options.defaultAlignment;
|
|
51
49
|
},
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
50
|
+
renderHTML: (attributes) => {
|
|
51
|
+
if (attributes.textAlign === this.options.defaultAlignment) {
|
|
52
|
+
return {};
|
|
53
|
+
}
|
|
54
|
+
return { style: `text-align: ${attributes.textAlign}` };
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
];
|
|
60
|
+
},
|
|
61
|
+
addCommands() {
|
|
62
|
+
return {
|
|
63
|
+
setTextAlign: (alignment) => ({ commands }) => {
|
|
64
|
+
if (!this.options.alignments.includes(alignment)) {
|
|
65
|
+
return false;
|
|
66
|
+
}
|
|
67
|
+
return this.options.types.map((type) => commands.updateAttributes(type, { textAlign: alignment })).every((response) => response);
|
|
68
|
+
},
|
|
69
|
+
unsetTextAlign: () => ({ commands }) => {
|
|
70
|
+
return this.options.types.map((type) => commands.resetAttributes(type, "textAlign")).every((response) => response);
|
|
71
|
+
}
|
|
72
|
+
};
|
|
73
|
+
},
|
|
74
|
+
addKeyboardShortcuts() {
|
|
75
|
+
return {
|
|
76
|
+
"Mod-Shift-l": () => this.editor.commands.setTextAlign("left"),
|
|
77
|
+
"Mod-Shift-e": () => this.editor.commands.setTextAlign("center"),
|
|
78
|
+
"Mod-Shift-r": () => this.editor.commands.setTextAlign("right"),
|
|
79
|
+
"Mod-Shift-j": () => this.editor.commands.setTextAlign("justify")
|
|
80
|
+
};
|
|
81
|
+
}
|
|
67
82
|
});
|
|
68
83
|
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
84
|
+
// src/index.ts
|
|
85
|
+
var src_default = TextAlign;
|
|
86
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
87
|
+
0 && (module.exports = {
|
|
88
|
+
TextAlign
|
|
89
|
+
});
|
|
90
|
+
//# sourceMappingURL=index.cjs.map
|
package/dist/index.cjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"
|
|
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: '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 => {\n const alignment = element.style.textAlign || this.options.defaultAlignment\n\n return this.options.alignments.includes(alignment) ? alignment : this.options.defaultAlignment\n },\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\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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
|
|
2
|
-
|
|
2
|
+
|
|
3
|
+
interface TextAlignOptions {
|
|
3
4
|
/**
|
|
4
5
|
* The types where the text align attribute can be applied.
|
|
5
6
|
* @default []
|
|
@@ -40,4 +41,6 @@ declare module '@tiptap/core' {
|
|
|
40
41
|
* This extension allows you to align text.
|
|
41
42
|
* @see https://www.tiptap.dev/api/extensions/text-align
|
|
42
43
|
*/
|
|
43
|
-
|
|
44
|
+
declare const TextAlign: Extension<TextAlignOptions, any>;
|
|
45
|
+
|
|
46
|
+
export { TextAlign, type TextAlignOptions, TextAlign as default };
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
import { Extension } from '@tiptap/core';
|
|
2
|
+
|
|
3
|
+
interface TextAlignOptions {
|
|
4
|
+
/**
|
|
5
|
+
* The types where the text align attribute can be applied.
|
|
6
|
+
* @default []
|
|
7
|
+
* @example ['heading', 'paragraph']
|
|
8
|
+
*/
|
|
9
|
+
types: string[];
|
|
10
|
+
/**
|
|
11
|
+
* The alignments which are allowed.
|
|
12
|
+
* @default ['left', 'center', 'right', 'justify']
|
|
13
|
+
* @example ['left', 'right']
|
|
14
|
+
*/
|
|
15
|
+
alignments: string[];
|
|
16
|
+
/**
|
|
17
|
+
* The default alignment.
|
|
18
|
+
* @default 'left'
|
|
19
|
+
* @example 'center'
|
|
20
|
+
*/
|
|
21
|
+
defaultAlignment: string;
|
|
22
|
+
}
|
|
23
|
+
declare module '@tiptap/core' {
|
|
24
|
+
interface Commands<ReturnType> {
|
|
25
|
+
textAlign: {
|
|
26
|
+
/**
|
|
27
|
+
* Set the text align attribute
|
|
28
|
+
* @param alignment The alignment
|
|
29
|
+
* @example editor.commands.setTextAlign('left')
|
|
30
|
+
*/
|
|
31
|
+
setTextAlign: (alignment: string) => ReturnType;
|
|
32
|
+
/**
|
|
33
|
+
* Unset the text align attribute
|
|
34
|
+
* @example editor.commands.unsetTextAlign()
|
|
35
|
+
*/
|
|
36
|
+
unsetTextAlign: () => ReturnType;
|
|
37
|
+
};
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
/**
|
|
41
|
+
* This extension allows you to align text.
|
|
42
|
+
* @see https://www.tiptap.dev/api/extensions/text-align
|
|
43
|
+
*/
|
|
44
|
+
declare const TextAlign: Extension<TextAlignOptions, any>;
|
|
45
|
+
|
|
46
|
+
export { TextAlign, type TextAlignOptions, TextAlign as default };
|
package/dist/index.js
CHANGED
|
@@ -1,66 +1,63 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
default: this.options.defaultAlignment,
|
|
23
|
-
parseHTML: element => {
|
|
24
|
-
const alignment = element.style.textAlign || this.options.defaultAlignment;
|
|
25
|
-
return this.options.alignments.includes(alignment) ? alignment : this.options.defaultAlignment;
|
|
26
|
-
},
|
|
27
|
-
renderHTML: attributes => {
|
|
28
|
-
if (attributes.textAlign === this.options.defaultAlignment) {
|
|
29
|
-
return {};
|
|
30
|
-
}
|
|
31
|
-
return { style: `text-align: ${attributes.textAlign}` };
|
|
32
|
-
},
|
|
33
|
-
},
|
|
34
|
-
},
|
|
35
|
-
},
|
|
36
|
-
];
|
|
37
|
-
},
|
|
38
|
-
addCommands() {
|
|
39
|
-
return {
|
|
40
|
-
setTextAlign: (alignment) => ({ commands }) => {
|
|
41
|
-
if (!this.options.alignments.includes(alignment)) {
|
|
42
|
-
return false;
|
|
43
|
-
}
|
|
44
|
-
return this.options.types
|
|
45
|
-
.map(type => commands.updateAttributes(type, { textAlign: alignment }))
|
|
46
|
-
.every(response => response);
|
|
47
|
-
},
|
|
48
|
-
unsetTextAlign: () => ({ commands }) => {
|
|
49
|
-
return this.options.types
|
|
50
|
-
.map(type => commands.resetAttributes(type, 'textAlign'))
|
|
51
|
-
.every(response => response);
|
|
1
|
+
// src/text-align.ts
|
|
2
|
+
import { Extension } from "@tiptap/core";
|
|
3
|
+
var TextAlign = Extension.create({
|
|
4
|
+
name: "textAlign",
|
|
5
|
+
addOptions() {
|
|
6
|
+
return {
|
|
7
|
+
types: [],
|
|
8
|
+
alignments: ["left", "center", "right", "justify"],
|
|
9
|
+
defaultAlignment: "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) => {
|
|
20
|
+
const alignment = element.style.textAlign || this.options.defaultAlignment;
|
|
21
|
+
return this.options.alignments.includes(alignment) ? alignment : this.options.defaultAlignment;
|
|
52
22
|
},
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
23
|
+
renderHTML: (attributes) => {
|
|
24
|
+
if (attributes.textAlign === this.options.defaultAlignment) {
|
|
25
|
+
return {};
|
|
26
|
+
}
|
|
27
|
+
return { style: `text-align: ${attributes.textAlign}` };
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
];
|
|
33
|
+
},
|
|
34
|
+
addCommands() {
|
|
35
|
+
return {
|
|
36
|
+
setTextAlign: (alignment) => ({ commands }) => {
|
|
37
|
+
if (!this.options.alignments.includes(alignment)) {
|
|
38
|
+
return false;
|
|
39
|
+
}
|
|
40
|
+
return this.options.types.map((type) => commands.updateAttributes(type, { textAlign: alignment })).every((response) => response);
|
|
41
|
+
},
|
|
42
|
+
unsetTextAlign: () => ({ commands }) => {
|
|
43
|
+
return this.options.types.map((type) => commands.resetAttributes(type, "textAlign")).every((response) => response);
|
|
44
|
+
}
|
|
45
|
+
};
|
|
46
|
+
},
|
|
47
|
+
addKeyboardShortcuts() {
|
|
48
|
+
return {
|
|
49
|
+
"Mod-Shift-l": () => this.editor.commands.setTextAlign("left"),
|
|
50
|
+
"Mod-Shift-e": () => this.editor.commands.setTextAlign("center"),
|
|
51
|
+
"Mod-Shift-r": () => this.editor.commands.setTextAlign("right"),
|
|
52
|
+
"Mod-Shift-j": () => this.editor.commands.setTextAlign("justify")
|
|
53
|
+
};
|
|
54
|
+
}
|
|
63
55
|
});
|
|
64
56
|
|
|
65
|
-
|
|
66
|
-
|
|
57
|
+
// src/index.ts
|
|
58
|
+
var src_default = TextAlign;
|
|
59
|
+
export {
|
|
60
|
+
TextAlign,
|
|
61
|
+
src_default as default
|
|
62
|
+
};
|
|
63
|
+
//# sourceMappingURL=index.js.map
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"
|
|
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: '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 => {\n const alignment = element.style.textAlign || this.options.defaultAlignment\n\n return this.options.alignments.includes(alignment) ? alignment : this.options.defaultAlignment\n },\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\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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 +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.1",
|
|
5
5
|
"homepage": "https://tiptap.dev",
|
|
6
6
|
"keywords": [
|
|
7
7
|
"tiptap",
|
|
@@ -15,24 +15,23 @@
|
|
|
15
15
|
"type": "module",
|
|
16
16
|
"exports": {
|
|
17
17
|
".": {
|
|
18
|
-
"types": "./dist/
|
|
18
|
+
"types": "./dist/index.d.ts",
|
|
19
19
|
"import": "./dist/index.js",
|
|
20
20
|
"require": "./dist/index.cjs"
|
|
21
21
|
}
|
|
22
22
|
},
|
|
23
23
|
"main": "dist/index.cjs",
|
|
24
24
|
"module": "dist/index.js",
|
|
25
|
-
"
|
|
26
|
-
"types": "dist/packages/extension-text-align/src/index.d.ts",
|
|
25
|
+
"types": "dist/index.d.ts",
|
|
27
26
|
"files": [
|
|
28
27
|
"src",
|
|
29
28
|
"dist"
|
|
30
29
|
],
|
|
31
30
|
"devDependencies": {
|
|
32
|
-
"@tiptap/core": "^3.0.0-next.
|
|
31
|
+
"@tiptap/core": "^3.0.0-next.1"
|
|
33
32
|
},
|
|
34
33
|
"peerDependencies": {
|
|
35
|
-
"@tiptap/core": "^3.0.0-next.
|
|
34
|
+
"@tiptap/core": "^3.0.0-next.1"
|
|
36
35
|
},
|
|
37
36
|
"repository": {
|
|
38
37
|
"type": "git",
|
|
@@ -40,7 +39,6 @@
|
|
|
40
39
|
"directory": "packages/extension-text-align"
|
|
41
40
|
},
|
|
42
41
|
"scripts": {
|
|
43
|
-
"
|
|
44
|
-
"build": "npm run clean && rollup -c"
|
|
42
|
+
"build": "tsup"
|
|
45
43
|
}
|
|
46
44
|
}
|
package/dist/index.umd.js
DELETED
|
@@ -1,75 +0,0 @@
|
|
|
1
|
-
(function (global, factory) {
|
|
2
|
-
typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports, require('@tiptap/core')) :
|
|
3
|
-
typeof define === 'function' && define.amd ? define(['exports', '@tiptap/core'], factory) :
|
|
4
|
-
(global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory(global["@tiptap/extension-text-align"] = {}, global.core));
|
|
5
|
-
})(this, (function (exports, core) { 'use strict';
|
|
6
|
-
|
|
7
|
-
/**
|
|
8
|
-
* This extension allows you to align text.
|
|
9
|
-
* @see https://www.tiptap.dev/api/extensions/text-align
|
|
10
|
-
*/
|
|
11
|
-
const TextAlign = core.Extension.create({
|
|
12
|
-
name: 'textAlign',
|
|
13
|
-
addOptions() {
|
|
14
|
-
return {
|
|
15
|
-
types: [],
|
|
16
|
-
alignments: ['left', 'center', 'right', 'justify'],
|
|
17
|
-
defaultAlignment: 'left',
|
|
18
|
-
};
|
|
19
|
-
},
|
|
20
|
-
addGlobalAttributes() {
|
|
21
|
-
return [
|
|
22
|
-
{
|
|
23
|
-
types: this.options.types,
|
|
24
|
-
attributes: {
|
|
25
|
-
textAlign: {
|
|
26
|
-
default: this.options.defaultAlignment,
|
|
27
|
-
parseHTML: element => {
|
|
28
|
-
const alignment = element.style.textAlign || this.options.defaultAlignment;
|
|
29
|
-
return this.options.alignments.includes(alignment) ? alignment : this.options.defaultAlignment;
|
|
30
|
-
},
|
|
31
|
-
renderHTML: attributes => {
|
|
32
|
-
if (attributes.textAlign === this.options.defaultAlignment) {
|
|
33
|
-
return {};
|
|
34
|
-
}
|
|
35
|
-
return { style: `text-align: ${attributes.textAlign}` };
|
|
36
|
-
},
|
|
37
|
-
},
|
|
38
|
-
},
|
|
39
|
-
},
|
|
40
|
-
];
|
|
41
|
-
},
|
|
42
|
-
addCommands() {
|
|
43
|
-
return {
|
|
44
|
-
setTextAlign: (alignment) => ({ commands }) => {
|
|
45
|
-
if (!this.options.alignments.includes(alignment)) {
|
|
46
|
-
return false;
|
|
47
|
-
}
|
|
48
|
-
return this.options.types
|
|
49
|
-
.map(type => commands.updateAttributes(type, { textAlign: alignment }))
|
|
50
|
-
.every(response => response);
|
|
51
|
-
},
|
|
52
|
-
unsetTextAlign: () => ({ commands }) => {
|
|
53
|
-
return this.options.types
|
|
54
|
-
.map(type => commands.resetAttributes(type, 'textAlign'))
|
|
55
|
-
.every(response => response);
|
|
56
|
-
},
|
|
57
|
-
};
|
|
58
|
-
},
|
|
59
|
-
addKeyboardShortcuts() {
|
|
60
|
-
return {
|
|
61
|
-
'Mod-Shift-l': () => this.editor.commands.setTextAlign('left'),
|
|
62
|
-
'Mod-Shift-e': () => this.editor.commands.setTextAlign('center'),
|
|
63
|
-
'Mod-Shift-r': () => this.editor.commands.setTextAlign('right'),
|
|
64
|
-
'Mod-Shift-j': () => this.editor.commands.setTextAlign('justify'),
|
|
65
|
-
};
|
|
66
|
-
},
|
|
67
|
-
});
|
|
68
|
-
|
|
69
|
-
exports.TextAlign = TextAlign;
|
|
70
|
-
exports.default = TextAlign;
|
|
71
|
-
|
|
72
|
-
Object.defineProperty(exports, '__esModule', { value: true });
|
|
73
|
-
|
|
74
|
-
}));
|
|
75
|
-
//# sourceMappingURL=index.umd.js.map
|
package/dist/index.umd.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.umd.js","sources":["../src/text-align.ts"],"sourcesContent":["import { Extension } from '@tiptap/core'\n\nexport interface TextAlignOptions {\n /**\n * The types where the text align attribute can be applied.\n * @default []\n * @example ['heading', 'paragraph']\n */\n types: string[],\n\n /**\n * The alignments which are allowed.\n * @default ['left', 'center', 'right', 'justify']\n * @example ['left', 'right']\n */\n alignments: string[],\n\n /**\n * The default alignment.\n * @default '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: '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 => {\n const alignment = element.style.textAlign || this.options.defaultAlignment\n\n return this.options.alignments.includes(alignment) ? alignment : this.options.defaultAlignment\n },\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\n .map(type => commands.updateAttributes(type, { textAlign: alignment }))\n .every(response => response)\n },\n\n unsetTextAlign: () => ({ commands }) => {\n return this.options.types\n .map(type => commands.resetAttributes(type, 'textAlign'))\n .every(response => response)\n },\n }\n },\n\n addKeyboardShortcuts() {\n return {\n 'Mod-Shift-l': () => this.editor.commands.setTextAlign('left'),\n 'Mod-Shift-e': () => this.editor.commands.setTextAlign('center'),\n 'Mod-Shift-r': () => this.editor.commands.setTextAlign('right'),\n 'Mod-Shift-j': () => this.editor.commands.setTextAlign('justify'),\n }\n },\n})\n"],"names":["Extension"],"mappings":";;;;;;EA2CA;;;EAGG;AACU,QAAA,SAAS,GAAGA,cAAS,CAAC,MAAM,CAAmB;EAC1D,IAAA,IAAI,EAAE,WAAW;MAEjB,UAAU,GAAA;UACR,OAAO;EACL,YAAA,KAAK,EAAE,EAAE;cACT,UAAU,EAAE,CAAC,MAAM,EAAE,QAAQ,EAAE,OAAO,EAAE,SAAS,CAAC;EAClD,YAAA,gBAAgB,EAAE,MAAM;WACzB,CAAA;OACF;MAED,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Ac,EAAE,MAAM,CAAC,EAAE,QAAQ,EAAE,KAAI;EACrC,gBAAA,OAAO,IAAI,CAAC,OAAO,CAAC,KAAK;EACtB,qBAAA,GAAG,CAAC,IAAI,IAAI,QAAQ,CAAC,eAAe,CAAC,IAAI,EAAE,WAAW,CAAC,CAAC;EACxD,qBAAA,KAAK,CAAC,QAAQ,IAAI,QAAQ,CAAC,CAAA;eAC/B;WACF,CAAA;OACF;MAED,oBAAoB,GAAA;UAClB,OAAO;EACL,YAAA,aAAa,EAAE,MAAM,IAAI,CAAC,MAAM,CAAC,QAAQ,CAAC,YAAY,CAAC,MAAM,CAAC;EAC9D,YAAA,aAAa,EAAE,MAAM,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;;;;;;;;;;;"}
|
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
import { EditorState, Transaction } from '@tiptap/pm/state';
|
|
2
|
-
import { Editor } from './Editor.js';
|
|
3
|
-
import { AnyCommands, CanCommands, ChainedCommands, CommandProps, SingleCommands } from './types.js';
|
|
4
|
-
export declare class CommandManager {
|
|
5
|
-
editor: Editor;
|
|
6
|
-
rawCommands: AnyCommands;
|
|
7
|
-
customState?: EditorState;
|
|
8
|
-
constructor(props: {
|
|
9
|
-
editor: Editor;
|
|
10
|
-
state?: EditorState;
|
|
11
|
-
});
|
|
12
|
-
get hasCustomState(): boolean;
|
|
13
|
-
get state(): EditorState;
|
|
14
|
-
get commands(): SingleCommands;
|
|
15
|
-
get chain(): () => ChainedCommands;
|
|
16
|
-
get can(): () => CanCommands;
|
|
17
|
-
createChain(startTr?: Transaction, shouldDispatch?: boolean): ChainedCommands;
|
|
18
|
-
createCan(startTr?: Transaction): CanCommands;
|
|
19
|
-
buildProps(tr: Transaction, shouldDispatch?: boolean): CommandProps;
|
|
20
|
-
}
|