@tiptap/extension-ordered-list 2.6.2 → 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 +113 -174
- package/dist/index.cjs.map +1 -1
- package/dist/{packages/extension-ordered-list/src/ordered-list.d.ts → index.d.cts} +6 -3
- package/dist/index.d.ts +52 -0
- package/dist/index.js +88 -171
- package/dist/index.js.map +1 -1
- package/package.json +6 -8
- package/src/ordered-list.ts +4 -4
- package/dist/index.umd.js +0 -184
- 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 -163
- package/dist/packages/core/src/EventEmitter.d.ts +0 -11
- package/dist/packages/core/src/Extension.d.ts +0 -344
- 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 -452
- package/dist/packages/core/src/Node.d.ts +0 -612
- 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 -16
- 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 -16
- 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 -14
- 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 -14
- 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-list-item/src/index.d.ts +0 -3
- package/dist/packages/extension-list-item/src/list-item.d.ts +0 -26
- package/dist/packages/extension-ordered-list/src/index.d.ts +0 -3
- package/dist/packages/extension-text-style/src/index.d.ts +0 -3
- package/dist/packages/extension-text-style/src/text-style.d.ts +0 -26
package/dist/index.js
CHANGED
|
@@ -1,174 +1,91 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
const
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
parseHTML() {
|
|
51
|
-
return [
|
|
52
|
-
{
|
|
53
|
-
tag: 'span',
|
|
54
|
-
getAttrs: element => {
|
|
55
|
-
const hasStyles = element.hasAttribute('style');
|
|
56
|
-
if (!hasStyles) {
|
|
57
|
-
return false;
|
|
58
|
-
}
|
|
59
|
-
return {};
|
|
60
|
-
},
|
|
61
|
-
},
|
|
62
|
-
];
|
|
63
|
-
},
|
|
64
|
-
renderHTML({ HTMLAttributes }) {
|
|
65
|
-
return ['span', mergeAttributes(this.options.HTMLAttributes, HTMLAttributes), 0];
|
|
66
|
-
},
|
|
67
|
-
addCommands() {
|
|
68
|
-
return {
|
|
69
|
-
removeEmptyTextStyle: () => ({ state, commands }) => {
|
|
70
|
-
const attributes = getMarkAttributes(state, this.type);
|
|
71
|
-
const hasStyles = Object.entries(attributes).some(([, value]) => !!value);
|
|
72
|
-
if (hasStyles) {
|
|
73
|
-
return true;
|
|
74
|
-
}
|
|
75
|
-
return commands.unsetMark(this.name);
|
|
76
|
-
},
|
|
77
|
-
};
|
|
78
|
-
},
|
|
79
|
-
});
|
|
80
|
-
|
|
81
|
-
/**
|
|
82
|
-
* Matches an ordered list to a 1. on input (or any number followed by a dot).
|
|
83
|
-
*/
|
|
84
|
-
const inputRegex = /^(\d+)\.\s$/;
|
|
85
|
-
/**
|
|
86
|
-
* This extension allows you to create ordered lists.
|
|
87
|
-
* This requires the ListItem extension
|
|
88
|
-
* @see https://www.tiptap.dev/api/nodes/ordered-list
|
|
89
|
-
* @see https://www.tiptap.dev/api/nodes/list-item
|
|
90
|
-
*/
|
|
91
|
-
const OrderedList = Node.create({
|
|
92
|
-
name: 'orderedList',
|
|
93
|
-
addOptions() {
|
|
94
|
-
return {
|
|
95
|
-
itemTypeName: 'listItem',
|
|
96
|
-
HTMLAttributes: {},
|
|
97
|
-
keepMarks: false,
|
|
98
|
-
keepAttributes: false,
|
|
99
|
-
};
|
|
100
|
-
},
|
|
101
|
-
group: 'block list',
|
|
102
|
-
content() {
|
|
103
|
-
return `${this.options.itemTypeName}+`;
|
|
104
|
-
},
|
|
105
|
-
addAttributes() {
|
|
106
|
-
return {
|
|
107
|
-
start: {
|
|
108
|
-
default: 1,
|
|
109
|
-
parseHTML: element => {
|
|
110
|
-
return element.hasAttribute('start')
|
|
111
|
-
? parseInt(element.getAttribute('start') || '', 10)
|
|
112
|
-
: 1;
|
|
113
|
-
},
|
|
114
|
-
},
|
|
115
|
-
type: {
|
|
116
|
-
default: null,
|
|
117
|
-
parseHTML: element => element.getAttribute('type'),
|
|
118
|
-
},
|
|
119
|
-
};
|
|
120
|
-
},
|
|
121
|
-
parseHTML() {
|
|
122
|
-
return [
|
|
123
|
-
{
|
|
124
|
-
tag: 'ol',
|
|
125
|
-
},
|
|
126
|
-
];
|
|
127
|
-
},
|
|
128
|
-
renderHTML({ HTMLAttributes }) {
|
|
129
|
-
const { start, ...attributesWithoutStart } = HTMLAttributes;
|
|
130
|
-
return start === 1
|
|
131
|
-
? ['ol', mergeAttributes(this.options.HTMLAttributes, attributesWithoutStart), 0]
|
|
132
|
-
: ['ol', mergeAttributes(this.options.HTMLAttributes, HTMLAttributes), 0];
|
|
133
|
-
},
|
|
134
|
-
addCommands() {
|
|
135
|
-
return {
|
|
136
|
-
toggleOrderedList: () => ({ commands, chain }) => {
|
|
137
|
-
if (this.options.keepAttributes) {
|
|
138
|
-
return chain().toggleList(this.name, this.options.itemTypeName, this.options.keepMarks).updateAttributes(ListItem.name, this.editor.getAttributes(TextStyle.name)).run();
|
|
139
|
-
}
|
|
140
|
-
return commands.toggleList(this.name, this.options.itemTypeName, this.options.keepMarks);
|
|
141
|
-
},
|
|
142
|
-
};
|
|
143
|
-
},
|
|
144
|
-
addKeyboardShortcuts() {
|
|
145
|
-
return {
|
|
146
|
-
'Mod-Shift-7': () => this.editor.commands.toggleOrderedList(),
|
|
147
|
-
};
|
|
148
|
-
},
|
|
149
|
-
addInputRules() {
|
|
150
|
-
let inputRule = wrappingInputRule({
|
|
151
|
-
find: inputRegex,
|
|
152
|
-
type: this.type,
|
|
153
|
-
getAttributes: match => ({ start: +match[1] }),
|
|
154
|
-
joinPredicate: (match, node) => node.childCount + node.attrs.start === +match[1],
|
|
155
|
-
});
|
|
156
|
-
if (this.options.keepMarks || this.options.keepAttributes) {
|
|
157
|
-
inputRule = wrappingInputRule({
|
|
158
|
-
find: inputRegex,
|
|
159
|
-
type: this.type,
|
|
160
|
-
keepMarks: this.options.keepMarks,
|
|
161
|
-
keepAttributes: this.options.keepAttributes,
|
|
162
|
-
getAttributes: match => ({ start: +match[1], ...this.editor.getAttributes(TextStyle.name) }),
|
|
163
|
-
joinPredicate: (match, node) => node.childCount + node.attrs.start === +match[1],
|
|
164
|
-
editor: this.editor,
|
|
165
|
-
});
|
|
1
|
+
// src/ordered-list.ts
|
|
2
|
+
import { mergeAttributes, Node, wrappingInputRule } from "@tiptap/core";
|
|
3
|
+
var ListItemName = "listItem";
|
|
4
|
+
var TextStyleName = "textStyle";
|
|
5
|
+
var inputRegex = /^(\d+)\.\s$/;
|
|
6
|
+
var OrderedList = Node.create({
|
|
7
|
+
name: "orderedList",
|
|
8
|
+
addOptions() {
|
|
9
|
+
return {
|
|
10
|
+
itemTypeName: "listItem",
|
|
11
|
+
HTMLAttributes: {},
|
|
12
|
+
keepMarks: false,
|
|
13
|
+
keepAttributes: false
|
|
14
|
+
};
|
|
15
|
+
},
|
|
16
|
+
group: "block list",
|
|
17
|
+
content() {
|
|
18
|
+
return `${this.options.itemTypeName}+`;
|
|
19
|
+
},
|
|
20
|
+
addAttributes() {
|
|
21
|
+
return {
|
|
22
|
+
start: {
|
|
23
|
+
default: 1,
|
|
24
|
+
parseHTML: (element) => {
|
|
25
|
+
return element.hasAttribute("start") ? parseInt(element.getAttribute("start") || "", 10) : 1;
|
|
26
|
+
}
|
|
27
|
+
},
|
|
28
|
+
type: {
|
|
29
|
+
default: null,
|
|
30
|
+
parseHTML: (element) => element.getAttribute("type")
|
|
31
|
+
}
|
|
32
|
+
};
|
|
33
|
+
},
|
|
34
|
+
parseHTML() {
|
|
35
|
+
return [
|
|
36
|
+
{
|
|
37
|
+
tag: "ol"
|
|
38
|
+
}
|
|
39
|
+
];
|
|
40
|
+
},
|
|
41
|
+
renderHTML({ HTMLAttributes }) {
|
|
42
|
+
const { start, ...attributesWithoutStart } = HTMLAttributes;
|
|
43
|
+
return start === 1 ? ["ol", mergeAttributes(this.options.HTMLAttributes, attributesWithoutStart), 0] : ["ol", mergeAttributes(this.options.HTMLAttributes, HTMLAttributes), 0];
|
|
44
|
+
},
|
|
45
|
+
addCommands() {
|
|
46
|
+
return {
|
|
47
|
+
toggleOrderedList: () => ({ commands, chain }) => {
|
|
48
|
+
if (this.options.keepAttributes) {
|
|
49
|
+
return chain().toggleList(this.name, this.options.itemTypeName, this.options.keepMarks).updateAttributes(ListItemName, this.editor.getAttributes(TextStyleName)).run();
|
|
166
50
|
}
|
|
167
|
-
return
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
51
|
+
return commands.toggleList(this.name, this.options.itemTypeName, this.options.keepMarks);
|
|
52
|
+
}
|
|
53
|
+
};
|
|
54
|
+
},
|
|
55
|
+
addKeyboardShortcuts() {
|
|
56
|
+
return {
|
|
57
|
+
"Mod-Shift-7": () => this.editor.commands.toggleOrderedList()
|
|
58
|
+
};
|
|
59
|
+
},
|
|
60
|
+
addInputRules() {
|
|
61
|
+
let inputRule = wrappingInputRule({
|
|
62
|
+
find: inputRegex,
|
|
63
|
+
type: this.type,
|
|
64
|
+
getAttributes: (match) => ({ start: +match[1] }),
|
|
65
|
+
joinPredicate: (match, node) => node.childCount + node.attrs.start === +match[1]
|
|
66
|
+
});
|
|
67
|
+
if (this.options.keepMarks || this.options.keepAttributes) {
|
|
68
|
+
inputRule = wrappingInputRule({
|
|
69
|
+
find: inputRegex,
|
|
70
|
+
type: this.type,
|
|
71
|
+
keepMarks: this.options.keepMarks,
|
|
72
|
+
keepAttributes: this.options.keepAttributes,
|
|
73
|
+
getAttributes: (match) => ({ start: +match[1], ...this.editor.getAttributes(TextStyleName) }),
|
|
74
|
+
joinPredicate: (match, node) => node.childCount + node.attrs.start === +match[1],
|
|
75
|
+
editor: this.editor
|
|
76
|
+
});
|
|
77
|
+
}
|
|
78
|
+
return [
|
|
79
|
+
inputRule
|
|
80
|
+
];
|
|
81
|
+
}
|
|
171
82
|
});
|
|
172
83
|
|
|
173
|
-
|
|
174
|
-
|
|
84
|
+
// src/index.ts
|
|
85
|
+
var src_default = OrderedList;
|
|
86
|
+
export {
|
|
87
|
+
OrderedList,
|
|
88
|
+
src_default as default,
|
|
89
|
+
inputRegex
|
|
90
|
+
};
|
|
91
|
+
//# sourceMappingURL=index.js.map
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sources":["../../extension-list-item/src/list-item.ts","../../extension-text-style/src/text-style.ts","../src/ordered-list.ts"],"sourcesContent":["import { mergeAttributes, Node } from '@tiptap/core'\n\nexport interface ListItemOptions {\n /**\n * The HTML attributes for a list item node.\n * @default {}\n * @example { class: 'foo' }\n */\n HTMLAttributes: Record<string, any>,\n\n /**\n * The node type for bulletList nodes\n * @default 'bulletList'\n * @example 'myCustomBulletList'\n */\n bulletListTypeName: string\n\n /**\n * The node type for orderedList nodes\n * @default 'orderedList'\n * @example 'myCustomOrderedList'\n */\n orderedListTypeName: string\n}\n\n/**\n * This extension allows you to create list items.\n * @see https://www.tiptap.dev/api/nodes/list-item\n */\nexport const ListItem = Node.create<ListItemOptions>({\n name: 'listItem',\n\n addOptions() {\n return {\n HTMLAttributes: {},\n bulletListTypeName: 'bulletList',\n orderedListTypeName: 'orderedList',\n }\n },\n\n content: 'paragraph block*',\n\n defining: true,\n\n parseHTML() {\n return [\n {\n tag: 'li',\n },\n ]\n },\n\n renderHTML({ HTMLAttributes }) {\n return ['li', mergeAttributes(this.options.HTMLAttributes, HTMLAttributes), 0]\n },\n\n addKeyboardShortcuts() {\n return {\n Enter: () => this.editor.commands.splitListItem(this.name),\n Tab: () => this.editor.commands.sinkListItem(this.name),\n 'Shift-Tab': () => this.editor.commands.liftListItem(this.name),\n }\n },\n})\n","import {\n getMarkAttributes,\n Mark,\n mergeAttributes,\n} from '@tiptap/core'\n\nexport interface TextStyleOptions {\n /**\n * HTML attributes to add to the span element.\n * @default {}\n * @example { class: 'foo' }\n */\n HTMLAttributes: Record<string, any>,\n}\n\ndeclare module '@tiptap/core' {\n interface Commands<ReturnType> {\n textStyle: {\n /**\n * Remove spans without inline style attributes.\n * @example editor.commands.removeEmptyTextStyle()\n */\n removeEmptyTextStyle: () => ReturnType,\n }\n }\n}\n\n/**\n * This extension allows you to create text styles. It is required by default\n * for the `textColor` and `backgroundColor` extensions.\n * @see https://www.tiptap.dev/api/marks/text-style\n */\nexport const TextStyle = Mark.create<TextStyleOptions>({\n name: 'textStyle',\n\n priority: 101,\n\n addOptions() {\n return {\n HTMLAttributes: {},\n }\n },\n\n parseHTML() {\n return [\n {\n tag: 'span',\n getAttrs: element => {\n const hasStyles = (element as HTMLElement).hasAttribute('style')\n\n if (!hasStyles) {\n return false\n }\n\n return {}\n },\n },\n ]\n },\n\n renderHTML({ HTMLAttributes }) {\n return ['span', mergeAttributes(this.options.HTMLAttributes, HTMLAttributes), 0]\n },\n\n addCommands() {\n return {\n removeEmptyTextStyle: () => ({ state, commands }) => {\n const attributes = getMarkAttributes(state, this.type)\n const hasStyles = Object.entries(attributes).some(([, value]) => !!value)\n\n if (hasStyles) {\n return true\n }\n\n return commands.unsetMark(this.name)\n },\n }\n },\n\n})\n","import { mergeAttributes, Node, wrappingInputRule } from '@tiptap/core'\n\nimport ListItem from '../../extension-list-item/src/index.js'\nimport TextStyle from '../../extension-text-style/src/index.js'\n\nexport interface OrderedListOptions {\n /**\n * The node type name for list items.\n * @default 'listItem'\n * @example 'myListItem'\n */\n itemTypeName: string,\n\n /**\n * The HTML attributes for an ordered list node.\n * @default {}\n * @example { class: 'foo' }\n */\n HTMLAttributes: Record<string, any>,\n\n /**\n * Keep the marks when splitting a list item.\n * @default false\n * @example true\n */\n keepMarks: boolean,\n\n /**\n * Keep the attributes when splitting a list item.\n * @default false\n * @example true\n */\n keepAttributes: boolean,\n}\n\ndeclare module '@tiptap/core' {\n interface Commands<ReturnType> {\n orderedList: {\n /**\n * Toggle an ordered list\n * @example editor.commands.toggleOrderedList()\n */\n toggleOrderedList: () => ReturnType,\n }\n }\n}\n\n/**\n * Matches an ordered list to a 1. on input (or any number followed by a dot).\n */\nexport const inputRegex = /^(\\d+)\\.\\s$/\n\n/**\n * This extension allows you to create ordered lists.\n * This requires the ListItem extension\n * @see https://www.tiptap.dev/api/nodes/ordered-list\n * @see https://www.tiptap.dev/api/nodes/list-item\n */\nexport const OrderedList = Node.create<OrderedListOptions>({\n name: 'orderedList',\n\n addOptions() {\n return {\n itemTypeName: 'listItem',\n HTMLAttributes: {},\n keepMarks: false,\n keepAttributes: false,\n }\n },\n\n group: 'block list',\n\n content() {\n return `${this.options.itemTypeName}+`\n },\n\n addAttributes() {\n return {\n start: {\n default: 1,\n parseHTML: element => {\n return element.hasAttribute('start')\n ? parseInt(element.getAttribute('start') || '', 10)\n : 1\n },\n },\n type: {\n default: null,\n parseHTML: element => element.getAttribute('type'),\n },\n }\n },\n\n parseHTML() {\n return [\n {\n tag: 'ol',\n },\n ]\n },\n\n renderHTML({ HTMLAttributes }) {\n const { start, ...attributesWithoutStart } = HTMLAttributes\n\n return start === 1\n ? ['ol', mergeAttributes(this.options.HTMLAttributes, attributesWithoutStart), 0]\n : ['ol', mergeAttributes(this.options.HTMLAttributes, HTMLAttributes), 0]\n },\n\n addCommands() {\n return {\n toggleOrderedList: () => ({ commands, chain }) => {\n if (this.options.keepAttributes) {\n return chain().toggleList(this.name, this.options.itemTypeName, this.options.keepMarks).updateAttributes(ListItem.name, this.editor.getAttributes(TextStyle.name)).run()\n }\n return commands.toggleList(this.name, this.options.itemTypeName, this.options.keepMarks)\n },\n }\n },\n\n addKeyboardShortcuts() {\n return {\n 'Mod-Shift-7': () => this.editor.commands.toggleOrderedList(),\n }\n },\n\n addInputRules() {\n let inputRule = wrappingInputRule({\n find: inputRegex,\n type: this.type,\n getAttributes: match => ({ start: +match[1] }),\n joinPredicate: (match, node) => node.childCount + node.attrs.start === +match[1],\n })\n\n if (this.options.keepMarks || this.options.keepAttributes) {\n inputRule = wrappingInputRule({\n find: inputRegex,\n type: this.type,\n keepMarks: this.options.keepMarks,\n keepAttributes: this.options.keepAttributes,\n getAttributes: match => ({ start: +match[1], ...this.editor.getAttributes(TextStyle.name) }),\n joinPredicate: (match, node) => node.childCount + node.attrs.start === +match[1],\n editor: this.editor,\n })\n }\n return [\n inputRule,\n ]\n },\n})\n"],"names":[],"mappings":";;AAyBA;;;AAGG;AACI,MAAM,QAAQ,GAAG,IAAI,CAAC,MAAM,CAAkB;AACnD,IAAA,IAAI,EAAE,UAAU;IAEhB,UAAU,GAAA;QACR,OAAO;AACL,YAAA,cAAc,EAAE,EAAE;AAClB,YAAA,kBAAkB,EAAE,YAAY;AAChC,YAAA,mBAAmB,EAAE,aAAa;SACnC,CAAA;KACF;AAED,IAAA,OAAO,EAAE,kBAAkB;AAE3B,IAAA,QAAQ,EAAE,IAAI;IAEd,SAAS,GAAA;QACP,OAAO;AACL,YAAA;AACE,gBAAA,GAAG,EAAE,IAAI;AACV,aAAA;SACF,CAAA;KACF;IAED,UAAU,CAAC,EAAE,cAAc,EAAE,EAAA;AAC3B,QAAA,OAAO,CAAC,IAAI,EAAE,eAAe,CAAC,IAAI,CAAC,OAAO,CAAC,cAAc,EAAE,cAAc,CAAC,EAAE,CAAC,CAAC,CAAA;KAC/E;IAED,oBA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AI,CAAC,IAAI;AACf,YAAA,aAAa,EAAE,KAAK,KAAK,EAAE,KAAK,EAAE,CAAC,KAAK,CAAC,CAAC,CAAC,EAAE,CAAC;YAC9C,aAAa,EAAE,CAAC,KAAK,EAAE,IAAI,KAAK,IAAI,CAAC,UAAU,GAAG,IAAI,CAAC,KAAK,CAAC,KAAK,KAAK,CAAC,KAAK,CAAC,CAAC,CAAC;AACjF,SAAA,CAAC,CAAA;AAEF,QAAA,IAAI,IAAI,CAAC,OAAO,CAAC,SAAS,IAAI,IAAI,CAAC,OAAO,CAAC,cAAc,EAAE;YACzD,SAAS,GAAG,iBAAiB,CAAC;AAC5B,gBAAA,IAAI,EAAE,UAAU;gBAChB,IAAI,EAAE,IAAI,CAAC,IAAI;AACf,gBAAA,SAAS,EAAE,IAAI,CAAC,OAAO,CAAC,SAAS;AACjC,gBAAA,cAAc,EAAE,IAAI,CAAC,OAAO,CAAC,cAAc;gBAC3C,aAAa,EAAE,KAAK,KAAK,EAAE,KAAK,EAAE,CAAC,KAAK,CAAC,CAAC,CAAC,EAAE,GAAG,IAAI,CAAC,MAAM,CAAC,aAAa,CAAC,SAAS,CAAC,IAAI,CAAC,EAAE,CAAC;gBAC5F,aAAa,EAAE,CAAC,KAAK,EAAE,IAAI,KAAK,IAAI,CAAC,UAAU,GAAG,IAAI,CAAC,KAAK,CAAC,KAAK,KAAK,CAAC,KAAK,CAAC,CAAC,CAAC;gBAChF,MAAM,EAAE,IAAI,CAAC,MAAM;AACpB,aAAA,CAAC,CAAA;SACH;QACD,OAAO;YACL,SAAS;SACV,CAAA;KACF;AACF,CAAA;;;;"}
|
|
1
|
+
{"version":3,"sources":["../src/ordered-list.ts","../src/index.ts"],"sourcesContent":["import { mergeAttributes, Node, wrappingInputRule } from '@tiptap/core'\n\nconst ListItemName = 'listItem'\nconst TextStyleName = 'textStyle'\n\nexport interface OrderedListOptions {\n /**\n * The node type name for list items.\n * @default 'listItem'\n * @example 'myListItem'\n */\n itemTypeName: string,\n\n /**\n * The HTML attributes for an ordered list node.\n * @default {}\n * @example { class: 'foo' }\n */\n HTMLAttributes: Record<string, any>,\n\n /**\n * Keep the marks when splitting a list item.\n * @default false\n * @example true\n */\n keepMarks: boolean,\n\n /**\n * Keep the attributes when splitting a list item.\n * @default false\n * @example true\n */\n keepAttributes: boolean,\n}\n\ndeclare module '@tiptap/core' {\n interface Commands<ReturnType> {\n orderedList: {\n /**\n * Toggle an ordered list\n * @example editor.commands.toggleOrderedList()\n */\n toggleOrderedList: () => ReturnType,\n }\n }\n}\n\n/**\n * Matches an ordered list to a 1. on input (or any number followed by a dot).\n */\nexport const inputRegex = /^(\\d+)\\.\\s$/\n\n/**\n * This extension allows you to create ordered lists.\n * This requires the ListItem extension\n * @see https://www.tiptap.dev/api/nodes/ordered-list\n * @see https://www.tiptap.dev/api/nodes/list-item\n */\nexport const OrderedList = Node.create<OrderedListOptions>({\n name: 'orderedList',\n\n addOptions() {\n return {\n itemTypeName: 'listItem',\n HTMLAttributes: {},\n keepMarks: false,\n keepAttributes: false,\n }\n },\n\n group: 'block list',\n\n content() {\n return `${this.options.itemTypeName}+`\n },\n\n addAttributes() {\n return {\n start: {\n default: 1,\n parseHTML: element => {\n return element.hasAttribute('start')\n ? parseInt(element.getAttribute('start') || '', 10)\n : 1\n },\n },\n type: {\n default: null,\n parseHTML: element => element.getAttribute('type'),\n },\n }\n },\n\n parseHTML() {\n return [\n {\n tag: 'ol',\n },\n ]\n },\n\n renderHTML({ HTMLAttributes }) {\n const { start, ...attributesWithoutStart } = HTMLAttributes\n\n return start === 1\n ? ['ol', mergeAttributes(this.options.HTMLAttributes, attributesWithoutStart), 0]\n : ['ol', mergeAttributes(this.options.HTMLAttributes, HTMLAttributes), 0]\n },\n\n addCommands() {\n return {\n toggleOrderedList: () => ({ commands, chain }) => {\n if (this.options.keepAttributes) {\n return chain().toggleList(this.name, this.options.itemTypeName, this.options.keepMarks).updateAttributes(ListItemName, this.editor.getAttributes(TextStyleName)).run()\n }\n return commands.toggleList(this.name, this.options.itemTypeName, this.options.keepMarks)\n },\n }\n },\n\n addKeyboardShortcuts() {\n return {\n 'Mod-Shift-7': () => this.editor.commands.toggleOrderedList(),\n }\n },\n\n addInputRules() {\n let inputRule = wrappingInputRule({\n find: inputRegex,\n type: this.type,\n getAttributes: match => ({ start: +match[1] }),\n joinPredicate: (match, node) => node.childCount + node.attrs.start === +match[1],\n })\n\n if (this.options.keepMarks || this.options.keepAttributes) {\n inputRule = wrappingInputRule({\n find: inputRegex,\n type: this.type,\n keepMarks: this.options.keepMarks,\n keepAttributes: this.options.keepAttributes,\n getAttributes: match => ({ start: +match[1], ...this.editor.getAttributes(TextStyleName) }),\n joinPredicate: (match, node) => node.childCount + node.attrs.start === +match[1],\n editor: this.editor,\n })\n }\n return [\n inputRule,\n ]\n },\n})\n","import { OrderedList } from './ordered-list.js'\n\nexport * from './ordered-list.js'\n\nexport default OrderedList\n"],"mappings":";AAAA,SAAS,iBAAiB,MAAM,yBAAyB;AAEzD,IAAM,eAAe;AACrB,IAAM,gBAAgB;AA+Cf,IAAM,aAAa;AAQnB,IAAM,cAAc,KAAK,OAA2B;AAAA,EACzD,MAAM;AAAA,EAEN,aAAa;AACX,WAAO;AAAA,MACL,cAAc;AAAA,MACd,gBAAgB,CAAC;AAAA,MACjB,WAAW;AAAA,MACX,gBAAgB;AAAA,IAClB;AAAA,EACF;AAAA,EAEA,OAAO;AAAA,EAEP,UAAU;AACR,WAAO,GAAG,KAAK,QAAQ,YAAY;AAAA,EACrC;AAAA,EAEA,gBAAgB;AACd,WAAO;AAAA,MACL,OAAO;AAAA,QACL,SAAS;AAAA,QACT,WAAW,aAAW;AACpB,iBAAO,QAAQ,aAAa,OAAO,IAC/B,SAAS,QAAQ,aAAa,OAAO,KAAK,IAAI,EAAE,IAChD;AAAA,QACN;AAAA,MACF;AAAA,MACA,MAAM;AAAA,QACJ,SAAS;AAAA,QACT,WAAW,aAAW,QAAQ,aAAa,MAAM;AAAA,MACnD;AAA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,QAAQ;AAAA,QACxB,gBAAgB,KAAK,QAAQ;AAAA,QAC7B,eAAe,YAAU,EAAE,OAAO,CAAC,MAAM,CAAC,GAAG,GAAG,KAAK,OAAO,cAAc,aAAa,EAAE;AAAA,QACzF,eAAe,CAAC,OAAO,SAAS,KAAK,aAAa,KAAK,MAAM,UAAU,CAAC,MAAM,CAAC;AAAA,QAC/E,QAAQ,KAAK;AAAA,MACf,CAAC;AAAA,IACH;AACA,WAAO;AAAA,MACL;AAAA,IACF;AAAA,EACF;AACF,CAAC;;;ACjJD,IAAO,cAAQ;","names":[]}
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@tiptap/extension-ordered-list",
|
|
3
3
|
"description": "ordered list extension for tiptap",
|
|
4
|
-
"version": "
|
|
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-ordered-list/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": "^
|
|
31
|
+
"@tiptap/core": "^3.0.0-next.1"
|
|
33
32
|
},
|
|
34
33
|
"peerDependencies": {
|
|
35
|
-
"@tiptap/core": "^
|
|
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-ordered-list"
|
|
41
40
|
},
|
|
42
41
|
"scripts": {
|
|
43
|
-
"
|
|
44
|
-
"build": "npm run clean && rollup -c"
|
|
42
|
+
"build": "tsup"
|
|
45
43
|
}
|
|
46
44
|
}
|
package/src/ordered-list.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { mergeAttributes, Node, wrappingInputRule } from '@tiptap/core'
|
|
2
2
|
|
|
3
|
-
|
|
4
|
-
|
|
3
|
+
const ListItemName = 'listItem'
|
|
4
|
+
const TextStyleName = 'textStyle'
|
|
5
5
|
|
|
6
6
|
export interface OrderedListOptions {
|
|
7
7
|
/**
|
|
@@ -111,7 +111,7 @@ export const OrderedList = Node.create<OrderedListOptions>({
|
|
|
111
111
|
return {
|
|
112
112
|
toggleOrderedList: () => ({ commands, chain }) => {
|
|
113
113
|
if (this.options.keepAttributes) {
|
|
114
|
-
return chain().toggleList(this.name, this.options.itemTypeName, this.options.keepMarks).updateAttributes(
|
|
114
|
+
return chain().toggleList(this.name, this.options.itemTypeName, this.options.keepMarks).updateAttributes(ListItemName, this.editor.getAttributes(TextStyleName)).run()
|
|
115
115
|
}
|
|
116
116
|
return commands.toggleList(this.name, this.options.itemTypeName, this.options.keepMarks)
|
|
117
117
|
},
|
|
@@ -138,7 +138,7 @@ export const OrderedList = Node.create<OrderedListOptions>({
|
|
|
138
138
|
type: this.type,
|
|
139
139
|
keepMarks: this.options.keepMarks,
|
|
140
140
|
keepAttributes: this.options.keepAttributes,
|
|
141
|
-
getAttributes: match => ({ start: +match[1], ...this.editor.getAttributes(
|
|
141
|
+
getAttributes: match => ({ start: +match[1], ...this.editor.getAttributes(TextStyleName) }),
|
|
142
142
|
joinPredicate: (match, node) => node.childCount + node.attrs.start === +match[1],
|
|
143
143
|
editor: this.editor,
|
|
144
144
|
})
|
package/dist/index.umd.js
DELETED
|
@@ -1,184 +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-ordered-list"] = {}, global.core));
|
|
5
|
-
})(this, (function (exports, core) { 'use strict';
|
|
6
|
-
|
|
7
|
-
/**
|
|
8
|
-
* This extension allows you to create list items.
|
|
9
|
-
* @see https://www.tiptap.dev/api/nodes/list-item
|
|
10
|
-
*/
|
|
11
|
-
const ListItem = core.Node.create({
|
|
12
|
-
name: 'listItem',
|
|
13
|
-
addOptions() {
|
|
14
|
-
return {
|
|
15
|
-
HTMLAttributes: {},
|
|
16
|
-
bulletListTypeName: 'bulletList',
|
|
17
|
-
orderedListTypeName: 'orderedList',
|
|
18
|
-
};
|
|
19
|
-
},
|
|
20
|
-
content: 'paragraph block*',
|
|
21
|
-
defining: true,
|
|
22
|
-
parseHTML() {
|
|
23
|
-
return [
|
|
24
|
-
{
|
|
25
|
-
tag: 'li',
|
|
26
|
-
},
|
|
27
|
-
];
|
|
28
|
-
},
|
|
29
|
-
renderHTML({ HTMLAttributes }) {
|
|
30
|
-
return ['li', core.mergeAttributes(this.options.HTMLAttributes, HTMLAttributes), 0];
|
|
31
|
-
},
|
|
32
|
-
addKeyboardShortcuts() {
|
|
33
|
-
return {
|
|
34
|
-
Enter: () => this.editor.commands.splitListItem(this.name),
|
|
35
|
-
Tab: () => this.editor.commands.sinkListItem(this.name),
|
|
36
|
-
'Shift-Tab': () => this.editor.commands.liftListItem(this.name),
|
|
37
|
-
};
|
|
38
|
-
},
|
|
39
|
-
});
|
|
40
|
-
|
|
41
|
-
/**
|
|
42
|
-
* This extension allows you to create text styles. It is required by default
|
|
43
|
-
* for the `textColor` and `backgroundColor` extensions.
|
|
44
|
-
* @see https://www.tiptap.dev/api/marks/text-style
|
|
45
|
-
*/
|
|
46
|
-
const TextStyle = core.Mark.create({
|
|
47
|
-
name: 'textStyle',
|
|
48
|
-
priority: 101,
|
|
49
|
-
addOptions() {
|
|
50
|
-
return {
|
|
51
|
-
HTMLAttributes: {},
|
|
52
|
-
};
|
|
53
|
-
},
|
|
54
|
-
parseHTML() {
|
|
55
|
-
return [
|
|
56
|
-
{
|
|
57
|
-
tag: 'span',
|
|
58
|
-
getAttrs: element => {
|
|
59
|
-
const hasStyles = element.hasAttribute('style');
|
|
60
|
-
if (!hasStyles) {
|
|
61
|
-
return false;
|
|
62
|
-
}
|
|
63
|
-
return {};
|
|
64
|
-
},
|
|
65
|
-
},
|
|
66
|
-
];
|
|
67
|
-
},
|
|
68
|
-
renderHTML({ HTMLAttributes }) {
|
|
69
|
-
return ['span', core.mergeAttributes(this.options.HTMLAttributes, HTMLAttributes), 0];
|
|
70
|
-
},
|
|
71
|
-
addCommands() {
|
|
72
|
-
return {
|
|
73
|
-
removeEmptyTextStyle: () => ({ state, commands }) => {
|
|
74
|
-
const attributes = core.getMarkAttributes(state, this.type);
|
|
75
|
-
const hasStyles = Object.entries(attributes).some(([, value]) => !!value);
|
|
76
|
-
if (hasStyles) {
|
|
77
|
-
return true;
|
|
78
|
-
}
|
|
79
|
-
return commands.unsetMark(this.name);
|
|
80
|
-
},
|
|
81
|
-
};
|
|
82
|
-
},
|
|
83
|
-
});
|
|
84
|
-
|
|
85
|
-
/**
|
|
86
|
-
* Matches an ordered list to a 1. on input (or any number followed by a dot).
|
|
87
|
-
*/
|
|
88
|
-
const inputRegex = /^(\d+)\.\s$/;
|
|
89
|
-
/**
|
|
90
|
-
* This extension allows you to create ordered lists.
|
|
91
|
-
* This requires the ListItem extension
|
|
92
|
-
* @see https://www.tiptap.dev/api/nodes/ordered-list
|
|
93
|
-
* @see https://www.tiptap.dev/api/nodes/list-item
|
|
94
|
-
*/
|
|
95
|
-
const OrderedList = core.Node.create({
|
|
96
|
-
name: 'orderedList',
|
|
97
|
-
addOptions() {
|
|
98
|
-
return {
|
|
99
|
-
itemTypeName: 'listItem',
|
|
100
|
-
HTMLAttributes: {},
|
|
101
|
-
keepMarks: false,
|
|
102
|
-
keepAttributes: false,
|
|
103
|
-
};
|
|
104
|
-
},
|
|
105
|
-
group: 'block list',
|
|
106
|
-
content() {
|
|
107
|
-
return `${this.options.itemTypeName}+`;
|
|
108
|
-
},
|
|
109
|
-
addAttributes() {
|
|
110
|
-
return {
|
|
111
|
-
start: {
|
|
112
|
-
default: 1,
|
|
113
|
-
parseHTML: element => {
|
|
114
|
-
return element.hasAttribute('start')
|
|
115
|
-
? parseInt(element.getAttribute('start') || '', 10)
|
|
116
|
-
: 1;
|
|
117
|
-
},
|
|
118
|
-
},
|
|
119
|
-
type: {
|
|
120
|
-
default: null,
|
|
121
|
-
parseHTML: element => element.getAttribute('type'),
|
|
122
|
-
},
|
|
123
|
-
};
|
|
124
|
-
},
|
|
125
|
-
parseHTML() {
|
|
126
|
-
return [
|
|
127
|
-
{
|
|
128
|
-
tag: 'ol',
|
|
129
|
-
},
|
|
130
|
-
];
|
|
131
|
-
},
|
|
132
|
-
renderHTML({ HTMLAttributes }) {
|
|
133
|
-
const { start, ...attributesWithoutStart } = HTMLAttributes;
|
|
134
|
-
return start === 1
|
|
135
|
-
? ['ol', core.mergeAttributes(this.options.HTMLAttributes, attributesWithoutStart), 0]
|
|
136
|
-
: ['ol', core.mergeAttributes(this.options.HTMLAttributes, HTMLAttributes), 0];
|
|
137
|
-
},
|
|
138
|
-
addCommands() {
|
|
139
|
-
return {
|
|
140
|
-
toggleOrderedList: () => ({ commands, chain }) => {
|
|
141
|
-
if (this.options.keepAttributes) {
|
|
142
|
-
return chain().toggleList(this.name, this.options.itemTypeName, this.options.keepMarks).updateAttributes(ListItem.name, this.editor.getAttributes(TextStyle.name)).run();
|
|
143
|
-
}
|
|
144
|
-
return commands.toggleList(this.name, this.options.itemTypeName, this.options.keepMarks);
|
|
145
|
-
},
|
|
146
|
-
};
|
|
147
|
-
},
|
|
148
|
-
addKeyboardShortcuts() {
|
|
149
|
-
return {
|
|
150
|
-
'Mod-Shift-7': () => this.editor.commands.toggleOrderedList(),
|
|
151
|
-
};
|
|
152
|
-
},
|
|
153
|
-
addInputRules() {
|
|
154
|
-
let inputRule = core.wrappingInputRule({
|
|
155
|
-
find: inputRegex,
|
|
156
|
-
type: this.type,
|
|
157
|
-
getAttributes: match => ({ start: +match[1] }),
|
|
158
|
-
joinPredicate: (match, node) => node.childCount + node.attrs.start === +match[1],
|
|
159
|
-
});
|
|
160
|
-
if (this.options.keepMarks || this.options.keepAttributes) {
|
|
161
|
-
inputRule = core.wrappingInputRule({
|
|
162
|
-
find: inputRegex,
|
|
163
|
-
type: this.type,
|
|
164
|
-
keepMarks: this.options.keepMarks,
|
|
165
|
-
keepAttributes: this.options.keepAttributes,
|
|
166
|
-
getAttributes: match => ({ start: +match[1], ...this.editor.getAttributes(TextStyle.name) }),
|
|
167
|
-
joinPredicate: (match, node) => node.childCount + node.attrs.start === +match[1],
|
|
168
|
-
editor: this.editor,
|
|
169
|
-
});
|
|
170
|
-
}
|
|
171
|
-
return [
|
|
172
|
-
inputRule,
|
|
173
|
-
];
|
|
174
|
-
},
|
|
175
|
-
});
|
|
176
|
-
|
|
177
|
-
exports.OrderedList = OrderedList;
|
|
178
|
-
exports.default = OrderedList;
|
|
179
|
-
exports.inputRegex = inputRegex;
|
|
180
|
-
|
|
181
|
-
Object.defineProperty(exports, '__esModule', { value: true });
|
|
182
|
-
|
|
183
|
-
}));
|
|
184
|
-
//# sourceMappingURL=index.umd.js.map
|
package/dist/index.umd.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.umd.js","sources":["../../extension-list-item/src/list-item.ts","../../extension-text-style/src/text-style.ts","../src/ordered-list.ts"],"sourcesContent":["import { mergeAttributes, Node } from '@tiptap/core'\n\nexport interface ListItemOptions {\n /**\n * The HTML attributes for a list item node.\n * @default {}\n * @example { class: 'foo' }\n */\n HTMLAttributes: Record<string, any>,\n\n /**\n * The node type for bulletList nodes\n * @default 'bulletList'\n * @example 'myCustomBulletList'\n */\n bulletListTypeName: string\n\n /**\n * The node type for orderedList nodes\n * @default 'orderedList'\n * @example 'myCustomOrderedList'\n */\n orderedListTypeName: string\n}\n\n/**\n * This extension allows you to create list items.\n * @see https://www.tiptap.dev/api/nodes/list-item\n */\nexport const ListItem = Node.create<ListItemOptions>({\n name: 'listItem',\n\n addOptions() {\n return {\n HTMLAttributes: {},\n bulletListTypeName: 'bulletList',\n orderedListTypeName: 'orderedList',\n }\n },\n\n content: 'paragraph block*',\n\n defining: true,\n\n parseHTML() {\n return [\n {\n tag: 'li',\n },\n ]\n },\n\n renderHTML({ HTMLAttributes }) {\n return ['li', mergeAttributes(this.options.HTMLAttributes, HTMLAttributes), 0]\n },\n\n addKeyboardShortcuts() {\n return {\n Enter: () => this.editor.commands.splitListItem(this.name),\n Tab: () => this.editor.commands.sinkListItem(this.name),\n 'Shift-Tab': () => this.editor.commands.liftListItem(this.name),\n }\n },\n})\n","import {\n getMarkAttributes,\n Mark,\n mergeAttributes,\n} from '@tiptap/core'\n\nexport interface TextStyleOptions {\n /**\n * HTML attributes to add to the span element.\n * @default {}\n * @example { class: 'foo' }\n */\n HTMLAttributes: Record<string, any>,\n}\n\ndeclare module '@tiptap/core' {\n interface Commands<ReturnType> {\n textStyle: {\n /**\n * Remove spans without inline style attributes.\n * @example editor.commands.removeEmptyTextStyle()\n */\n removeEmptyTextStyle: () => ReturnType,\n }\n }\n}\n\n/**\n * This extension allows you to create text styles. It is required by default\n * for the `textColor` and `backgroundColor` extensions.\n * @see https://www.tiptap.dev/api/marks/text-style\n */\nexport const TextStyle = Mark.create<TextStyleOptions>({\n name: 'textStyle',\n\n priority: 101,\n\n addOptions() {\n return {\n HTMLAttributes: {},\n }\n },\n\n parseHTML() {\n return [\n {\n tag: 'span',\n getAttrs: element => {\n const hasStyles = (element as HTMLElement).hasAttribute('style')\n\n if (!hasStyles) {\n return false\n }\n\n return {}\n },\n },\n ]\n },\n\n renderHTML({ HTMLAttributes }) {\n return ['span', mergeAttributes(this.options.HTMLAttributes, HTMLAttributes), 0]\n },\n\n addCommands() {\n return {\n removeEmptyTextStyle: () => ({ state, commands }) => {\n const attributes = getMarkAttributes(state, this.type)\n const hasStyles = Object.entries(attributes).some(([, value]) => !!value)\n\n if (hasStyles) {\n return true\n }\n\n return commands.unsetMark(this.name)\n },\n }\n },\n\n})\n","import { mergeAttributes, Node, wrappingInputRule } from '@tiptap/core'\n\nimport ListItem from '../../extension-list-item/src/index.js'\nimport TextStyle from '../../extension-text-style/src/index.js'\n\nexport interface OrderedListOptions {\n /**\n * The node type name for list items.\n * @default 'listItem'\n * @example 'myListItem'\n */\n itemTypeName: string,\n\n /**\n * The HTML attributes for an ordered list node.\n * @default {}\n * @example { class: 'foo' }\n */\n HTMLAttributes: Record<string, any>,\n\n /**\n * Keep the marks when splitting a list item.\n * @default false\n * @example true\n */\n keepMarks: boolean,\n\n /**\n * Keep the attributes when splitting a list item.\n * @default false\n * @example true\n */\n keepAttributes: boolean,\n}\n\ndeclare module '@tiptap/core' {\n interface Commands<ReturnType> {\n orderedList: {\n /**\n * Toggle an ordered list\n * @example editor.commands.toggleOrderedList()\n */\n toggleOrderedList: () => ReturnType,\n }\n }\n}\n\n/**\n * Matches an ordered list to a 1. on input (or any number followed by a dot).\n */\nexport const inputRegex = /^(\\d+)\\.\\s$/\n\n/**\n * This extension allows you to create ordered lists.\n * This requires the ListItem extension\n * @see https://www.tiptap.dev/api/nodes/ordered-list\n * @see https://www.tiptap.dev/api/nodes/list-item\n */\nexport const OrderedList = Node.create<OrderedListOptions>({\n name: 'orderedList',\n\n addOptions() {\n return {\n itemTypeName: 'listItem',\n HTMLAttributes: {},\n keepMarks: false,\n keepAttributes: false,\n }\n },\n\n group: 'block list',\n\n content() {\n return `${this.options.itemTypeName}+`\n },\n\n addAttributes() {\n return {\n start: {\n default: 1,\n parseHTML: element => {\n return element.hasAttribute('start')\n ? parseInt(element.getAttribute('start') || '', 10)\n : 1\n },\n },\n type: {\n default: null,\n parseHTML: element => element.getAttribute('type'),\n },\n }\n },\n\n parseHTML() {\n return [\n {\n tag: 'ol',\n },\n ]\n },\n\n renderHTML({ HTMLAttributes }) {\n const { start, ...attributesWithoutStart } = HTMLAttributes\n\n return start === 1\n ? ['ol', mergeAttributes(this.options.HTMLAttributes, attributesWithoutStart), 0]\n : ['ol', mergeAttributes(this.options.HTMLAttributes, HTMLAttributes), 0]\n },\n\n addCommands() {\n return {\n toggleOrderedList: () => ({ commands, chain }) => {\n if (this.options.keepAttributes) {\n return chain().toggleList(this.name, this.options.itemTypeName, this.options.keepMarks).updateAttributes(ListItem.name, this.editor.getAttributes(TextStyle.name)).run()\n }\n return commands.toggleList(this.name, this.options.itemTypeName, this.options.keepMarks)\n },\n }\n },\n\n addKeyboardShortcuts() {\n return {\n 'Mod-Shift-7': () => this.editor.commands.toggleOrderedList(),\n }\n },\n\n addInputRules() {\n let inputRule = wrappingInputRule({\n find: inputRegex,\n type: this.type,\n getAttributes: match => ({ start: +match[1] }),\n joinPredicate: (match, node) => node.childCount + node.attrs.start === +match[1],\n })\n\n if (this.options.keepMarks || this.options.keepAttributes) {\n inputRule = wrappingInputRule({\n find: inputRegex,\n type: this.type,\n keepMarks: this.options.keepMarks,\n keepAttributes: this.options.keepAttributes,\n getAttributes: match => ({ start: +match[1], ...this.editor.getAttributes(TextStyle.name) }),\n joinPredicate: (match, node) => node.childCount + node.attrs.start === +match[1],\n editor: this.editor,\n })\n }\n return [\n inputRule,\n ]\n },\n})\n"],"names":["Node","mergeAttributes","Mark","getMarkAttributes","wrappingInputRule"],"mappings":";;;;;;EAyBA;;;EAGG;EACI,MAAM,QAAQ,GAAGA,SAAI,CAAC,MAAM,CAAkB;EACnD,IAAA,IAAI,EAAE,UAAU;MAEhB,UAAU,GAAA;UACR,OAAO;E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AK,EAAE,IAAI,KAAK,IAAI,CAAC,UAAU,GAAG,IAAI,CAAC,KAAK,CAAC,KAAK,KAAK,CAAC,KAAK,CAAC,CAAC,CAAC;kBAChF,MAAM,EAAE,IAAI,CAAC,MAAM;EACpB,aAAA,CAAC,CAAA;WACH;UACD,OAAO;cACL,SAAS;WACV,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
|
-
}
|