@tiptap/extension-ordered-list 2.0.0-beta.21 → 2.0.0-beta.211
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 +67 -0
- package/dist/{packages/extension-ordered-list/src/ordered-list.d.ts → index.d.ts} +20 -16
- package/dist/index.js +67 -0
- package/package.json +30 -7
- package/src/ordered-list.ts +7 -3
- package/LICENSE.md +0 -21
- package/dist/packages/extension-ordered-list/src/index.d.ts +0 -3
- package/dist/tiptap-extension-ordered-list.cjs.js +0 -69
- package/dist/tiptap-extension-ordered-list.cjs.js.map +0 -1
- package/dist/tiptap-extension-ordered-list.esm.js +0 -63
- package/dist/tiptap-extension-ordered-list.esm.js.map +0 -1
- package/dist/tiptap-extension-ordered-list.umd.js +0 -73
- package/dist/tiptap-extension-ordered-list.umd.js.map +0 -1
package/dist/index.cjs
ADDED
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
"use strict";Object.defineProperty(exports, "__esModule", {value: true});// src/ordered-list.ts
|
|
2
|
+
var _core = require('@tiptap/core');
|
|
3
|
+
var inputRegex = /^(\d+)\.\s$/;
|
|
4
|
+
var OrderedList = _core.Node.create({
|
|
5
|
+
name: "orderedList",
|
|
6
|
+
addOptions() {
|
|
7
|
+
return {
|
|
8
|
+
itemTypeName: "listItem",
|
|
9
|
+
HTMLAttributes: {}
|
|
10
|
+
};
|
|
11
|
+
},
|
|
12
|
+
group: "block list",
|
|
13
|
+
content() {
|
|
14
|
+
return `${this.options.itemTypeName}+`;
|
|
15
|
+
},
|
|
16
|
+
addAttributes() {
|
|
17
|
+
return {
|
|
18
|
+
start: {
|
|
19
|
+
default: 1,
|
|
20
|
+
parseHTML: (element) => {
|
|
21
|
+
return element.hasAttribute("start") ? parseInt(element.getAttribute("start") || "", 10) : 1;
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
};
|
|
25
|
+
},
|
|
26
|
+
parseHTML() {
|
|
27
|
+
return [
|
|
28
|
+
{
|
|
29
|
+
tag: "ol"
|
|
30
|
+
}
|
|
31
|
+
];
|
|
32
|
+
},
|
|
33
|
+
renderHTML({ HTMLAttributes }) {
|
|
34
|
+
const { start, ...attributesWithoutStart } = HTMLAttributes;
|
|
35
|
+
return start === 1 ? ["ol", _core.mergeAttributes.call(void 0, this.options.HTMLAttributes, attributesWithoutStart), 0] : ["ol", _core.mergeAttributes.call(void 0, this.options.HTMLAttributes, HTMLAttributes), 0];
|
|
36
|
+
},
|
|
37
|
+
addCommands() {
|
|
38
|
+
return {
|
|
39
|
+
toggleOrderedList: () => ({ commands }) => {
|
|
40
|
+
return commands.toggleList(this.name, this.options.itemTypeName);
|
|
41
|
+
}
|
|
42
|
+
};
|
|
43
|
+
},
|
|
44
|
+
addKeyboardShortcuts() {
|
|
45
|
+
return {
|
|
46
|
+
"Mod-Shift-7": () => this.editor.commands.toggleOrderedList()
|
|
47
|
+
};
|
|
48
|
+
},
|
|
49
|
+
addInputRules() {
|
|
50
|
+
return [
|
|
51
|
+
_core.wrappingInputRule.call(void 0, {
|
|
52
|
+
find: inputRegex,
|
|
53
|
+
type: this.type,
|
|
54
|
+
getAttributes: (match) => ({ start: +match[1] }),
|
|
55
|
+
joinPredicate: (match, node) => node.childCount + node.attrs.start === +match[1]
|
|
56
|
+
})
|
|
57
|
+
];
|
|
58
|
+
}
|
|
59
|
+
});
|
|
60
|
+
|
|
61
|
+
// src/index.ts
|
|
62
|
+
var src_default = OrderedList;
|
|
63
|
+
|
|
64
|
+
|
|
65
|
+
|
|
66
|
+
|
|
67
|
+
exports.OrderedList = OrderedList; exports.default = src_default; exports.inputRegex = inputRegex;
|
|
@@ -1,16 +1,20 @@
|
|
|
1
|
-
import { Node } from '@tiptap/core';
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
}
|
|
15
|
-
|
|
16
|
-
|
|
1
|
+
import { Node } from '@tiptap/core';
|
|
2
|
+
|
|
3
|
+
interface OrderedListOptions {
|
|
4
|
+
itemTypeName: string;
|
|
5
|
+
HTMLAttributes: Record<string, any>;
|
|
6
|
+
}
|
|
7
|
+
declare module '@tiptap/core' {
|
|
8
|
+
interface Commands<ReturnType> {
|
|
9
|
+
orderedList: {
|
|
10
|
+
/**
|
|
11
|
+
* Toggle an ordered list
|
|
12
|
+
*/
|
|
13
|
+
toggleOrderedList: () => ReturnType;
|
|
14
|
+
};
|
|
15
|
+
}
|
|
16
|
+
}
|
|
17
|
+
declare const inputRegex: RegExp;
|
|
18
|
+
declare const OrderedList: Node<OrderedListOptions, any>;
|
|
19
|
+
|
|
20
|
+
export { OrderedList, OrderedListOptions, OrderedList as default, inputRegex };
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
// src/ordered-list.ts
|
|
2
|
+
import { mergeAttributes, Node, wrappingInputRule } from "@tiptap/core";
|
|
3
|
+
var inputRegex = /^(\d+)\.\s$/;
|
|
4
|
+
var OrderedList = Node.create({
|
|
5
|
+
name: "orderedList",
|
|
6
|
+
addOptions() {
|
|
7
|
+
return {
|
|
8
|
+
itemTypeName: "listItem",
|
|
9
|
+
HTMLAttributes: {}
|
|
10
|
+
};
|
|
11
|
+
},
|
|
12
|
+
group: "block list",
|
|
13
|
+
content() {
|
|
14
|
+
return `${this.options.itemTypeName}+`;
|
|
15
|
+
},
|
|
16
|
+
addAttributes() {
|
|
17
|
+
return {
|
|
18
|
+
start: {
|
|
19
|
+
default: 1,
|
|
20
|
+
parseHTML: (element) => {
|
|
21
|
+
return element.hasAttribute("start") ? parseInt(element.getAttribute("start") || "", 10) : 1;
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
};
|
|
25
|
+
},
|
|
26
|
+
parseHTML() {
|
|
27
|
+
return [
|
|
28
|
+
{
|
|
29
|
+
tag: "ol"
|
|
30
|
+
}
|
|
31
|
+
];
|
|
32
|
+
},
|
|
33
|
+
renderHTML({ HTMLAttributes }) {
|
|
34
|
+
const { start, ...attributesWithoutStart } = HTMLAttributes;
|
|
35
|
+
return start === 1 ? ["ol", mergeAttributes(this.options.HTMLAttributes, attributesWithoutStart), 0] : ["ol", mergeAttributes(this.options.HTMLAttributes, HTMLAttributes), 0];
|
|
36
|
+
},
|
|
37
|
+
addCommands() {
|
|
38
|
+
return {
|
|
39
|
+
toggleOrderedList: () => ({ commands }) => {
|
|
40
|
+
return commands.toggleList(this.name, this.options.itemTypeName);
|
|
41
|
+
}
|
|
42
|
+
};
|
|
43
|
+
},
|
|
44
|
+
addKeyboardShortcuts() {
|
|
45
|
+
return {
|
|
46
|
+
"Mod-Shift-7": () => this.editor.commands.toggleOrderedList()
|
|
47
|
+
};
|
|
48
|
+
},
|
|
49
|
+
addInputRules() {
|
|
50
|
+
return [
|
|
51
|
+
wrappingInputRule({
|
|
52
|
+
find: inputRegex,
|
|
53
|
+
type: this.type,
|
|
54
|
+
getAttributes: (match) => ({ start: +match[1] }),
|
|
55
|
+
joinPredicate: (match, node) => node.childCount + node.attrs.start === +match[1]
|
|
56
|
+
})
|
|
57
|
+
];
|
|
58
|
+
}
|
|
59
|
+
});
|
|
60
|
+
|
|
61
|
+
// src/index.ts
|
|
62
|
+
var src_default = OrderedList;
|
|
63
|
+
export {
|
|
64
|
+
OrderedList,
|
|
65
|
+
src_default as default,
|
|
66
|
+
inputRegex
|
|
67
|
+
};
|
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": "2.0.0-beta.
|
|
4
|
+
"version": "2.0.0-beta.211",
|
|
5
5
|
"homepage": "https://tiptap.dev",
|
|
6
6
|
"keywords": [
|
|
7
7
|
"tiptap",
|
|
@@ -12,21 +12,44 @@
|
|
|
12
12
|
"type": "github",
|
|
13
13
|
"url": "https://github.com/sponsors/ueberdosis"
|
|
14
14
|
},
|
|
15
|
-
"
|
|
16
|
-
"
|
|
17
|
-
|
|
18
|
-
|
|
15
|
+
"type": "module",
|
|
16
|
+
"exports": {
|
|
17
|
+
".": {
|
|
18
|
+
"types": "./dist/index.d.ts",
|
|
19
|
+
"import": "./dist/index.js",
|
|
20
|
+
"require": "./dist/index.cjs"
|
|
21
|
+
}
|
|
22
|
+
},
|
|
23
|
+
"main": "dist/index.cjs",
|
|
24
|
+
"module": "dist/index.js",
|
|
25
|
+
"types": "dist/index.d.ts",
|
|
19
26
|
"files": [
|
|
20
27
|
"src",
|
|
21
28
|
"dist"
|
|
22
29
|
],
|
|
23
30
|
"peerDependencies": {
|
|
24
|
-
"@tiptap/core": "^2.0.0-beta.
|
|
31
|
+
"@tiptap/core": "^2.0.0-beta.209"
|
|
32
|
+
},
|
|
33
|
+
"devDependencies": {
|
|
34
|
+
"@tiptap/core": "^2.0.0-beta.211"
|
|
25
35
|
},
|
|
26
36
|
"repository": {
|
|
27
37
|
"type": "git",
|
|
28
38
|
"url": "https://github.com/ueberdosis/tiptap",
|
|
29
39
|
"directory": "packages/extension-ordered-list"
|
|
30
40
|
},
|
|
31
|
-
"
|
|
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
|
+
]
|
|
54
|
+
}
|
|
32
55
|
}
|
package/src/ordered-list.ts
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { mergeAttributes, Node, wrappingInputRule } from '@tiptap/core'
|
|
2
2
|
|
|
3
3
|
export interface OrderedListOptions {
|
|
4
|
+
itemTypeName: string,
|
|
4
5
|
HTMLAttributes: Record<string, any>,
|
|
5
6
|
}
|
|
6
7
|
|
|
@@ -22,13 +23,16 @@ export const OrderedList = Node.create<OrderedListOptions>({
|
|
|
22
23
|
|
|
23
24
|
addOptions() {
|
|
24
25
|
return {
|
|
26
|
+
itemTypeName: 'listItem',
|
|
25
27
|
HTMLAttributes: {},
|
|
26
28
|
}
|
|
27
29
|
},
|
|
28
30
|
|
|
29
31
|
group: 'block list',
|
|
30
32
|
|
|
31
|
-
content
|
|
33
|
+
content() {
|
|
34
|
+
return `${this.options.itemTypeName}+`
|
|
35
|
+
},
|
|
32
36
|
|
|
33
37
|
addAttributes() {
|
|
34
38
|
return {
|
|
@@ -62,7 +66,7 @@ export const OrderedList = Node.create<OrderedListOptions>({
|
|
|
62
66
|
addCommands() {
|
|
63
67
|
return {
|
|
64
68
|
toggleOrderedList: () => ({ commands }) => {
|
|
65
|
-
return commands.toggleList(
|
|
69
|
+
return commands.toggleList(this.name, this.options.itemTypeName)
|
|
66
70
|
},
|
|
67
71
|
}
|
|
68
72
|
},
|
package/LICENSE.md
DELETED
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
MIT License
|
|
2
|
-
|
|
3
|
-
Copyright (c) 2021, überdosis GbR
|
|
4
|
-
|
|
5
|
-
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
-
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
-
in the Software without restriction, including without limitation the rights
|
|
8
|
-
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
-
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
-
furnished to do so, subject to the following conditions:
|
|
11
|
-
|
|
12
|
-
The above copyright notice and this permission notice shall be included in all
|
|
13
|
-
copies or substantial portions of the Software.
|
|
14
|
-
|
|
15
|
-
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
-
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
-
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
-
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
-
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
-
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
-
SOFTWARE.
|
|
@@ -1,69 +0,0 @@
|
|
|
1
|
-
'use strict';
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
|
-
|
|
5
|
-
var core = require('@tiptap/core');
|
|
6
|
-
|
|
7
|
-
const inputRegex = /^(\d+)\.\s$/;
|
|
8
|
-
const OrderedList = core.Node.create({
|
|
9
|
-
name: 'orderedList',
|
|
10
|
-
addOptions() {
|
|
11
|
-
return {
|
|
12
|
-
HTMLAttributes: {},
|
|
13
|
-
};
|
|
14
|
-
},
|
|
15
|
-
group: 'block list',
|
|
16
|
-
content: 'listItem+',
|
|
17
|
-
addAttributes() {
|
|
18
|
-
return {
|
|
19
|
-
start: {
|
|
20
|
-
default: 1,
|
|
21
|
-
parseHTML: element => {
|
|
22
|
-
return element.hasAttribute('start')
|
|
23
|
-
? parseInt(element.getAttribute('start') || '', 10)
|
|
24
|
-
: 1;
|
|
25
|
-
},
|
|
26
|
-
},
|
|
27
|
-
};
|
|
28
|
-
},
|
|
29
|
-
parseHTML() {
|
|
30
|
-
return [
|
|
31
|
-
{
|
|
32
|
-
tag: 'ol',
|
|
33
|
-
},
|
|
34
|
-
];
|
|
35
|
-
},
|
|
36
|
-
renderHTML({ HTMLAttributes }) {
|
|
37
|
-
const { start, ...attributesWithoutStart } = HTMLAttributes;
|
|
38
|
-
return start === 1
|
|
39
|
-
? ['ol', core.mergeAttributes(this.options.HTMLAttributes, attributesWithoutStart), 0]
|
|
40
|
-
: ['ol', core.mergeAttributes(this.options.HTMLAttributes, HTMLAttributes), 0];
|
|
41
|
-
},
|
|
42
|
-
addCommands() {
|
|
43
|
-
return {
|
|
44
|
-
toggleOrderedList: () => ({ commands }) => {
|
|
45
|
-
return commands.toggleList('orderedList', 'listItem');
|
|
46
|
-
},
|
|
47
|
-
};
|
|
48
|
-
},
|
|
49
|
-
addKeyboardShortcuts() {
|
|
50
|
-
return {
|
|
51
|
-
'Mod-Shift-7': () => this.editor.commands.toggleOrderedList(),
|
|
52
|
-
};
|
|
53
|
-
},
|
|
54
|
-
addInputRules() {
|
|
55
|
-
return [
|
|
56
|
-
core.wrappingInputRule({
|
|
57
|
-
find: inputRegex,
|
|
58
|
-
type: this.type,
|
|
59
|
-
getAttributes: match => ({ start: +match[1] }),
|
|
60
|
-
joinPredicate: (match, node) => node.childCount + node.attrs.start === +match[1],
|
|
61
|
-
}),
|
|
62
|
-
];
|
|
63
|
-
},
|
|
64
|
-
});
|
|
65
|
-
|
|
66
|
-
exports.OrderedList = OrderedList;
|
|
67
|
-
exports["default"] = OrderedList;
|
|
68
|
-
exports.inputRegex = inputRegex;
|
|
69
|
-
//# sourceMappingURL=tiptap-extension-ordered-list.cjs.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"tiptap-extension-ordered-list.cjs.js","sources":["../src/ordered-list.ts"],"sourcesContent":["import { Node, mergeAttributes, wrappingInputRule } from '@tiptap/core'\n\nexport interface OrderedListOptions {\n HTMLAttributes: Record<string, any>,\n}\n\ndeclare module '@tiptap/core' {\n interface Commands<ReturnType> {\n orderedList: {\n /**\n * Toggle an ordered list\n */\n toggleOrderedList: () => ReturnType,\n }\n }\n}\n\nexport const inputRegex = /^(\\d+)\\.\\s$/\n\nexport const OrderedList = Node.create<OrderedListOptions>({\n name: 'orderedList',\n\n addOptions() {\n return {\n HTMLAttributes: {},\n }\n },\n\n group: 'block list',\n\n content: 'listItem+',\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 }\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 }) => {\n return commands.toggleList('orderedList', 'listItem')\n },\n }\n },\n\n addKeyboardShortcuts() {\n return {\n 'Mod-Shift-7': () => this.editor.commands.toggleOrderedList(),\n }\n },\n\n addInputRules() {\n return [\n 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 },\n})\n"],"names":["Node","mergeAttributes","wrappingInputRule"],"mappings":";;;;;;MAiBa,UAAU,GAAG,cAAa;MAE1B,WAAW,GAAGA,SAAI,CAAC,MAAM,CAAqB;IACzD,IAAI,EAAE,aAAa;IAEnB,UAAU;QACR,OAAO;YACL,cAAc,EAAE,EAAE;SACnB,CAAA;KACF;IAED,KAAK,EAAE,YAAY;IAEnB,OAAO,EAAE,WAAW;IAEpB,aAAa;QACX,OAAO;YACL,KAAK,EAAE;gBACL,OAAO,EAAE,CAAC;gBACV,SAAS,EAAE,OAAO;oBAChB,OAAO,OAAO,CAAC,YAAY,CAAC,OAAO,CAAC;0BAChC,QAAQ,CAAC,OAAO,CAAC,YAAY,CAAC,OAAO,CAAC,IAAI,EAAE,EAAE,EAAE,CAAC;0BACjD,CAAC,CAAA;iBACN;aACF;SACF,CAAA;KACF;IAED,SAAS;QACP,OAAO;YACL;gBACE,GAAG,EAAE,IAAI;aACV;SACF,CAAA;KACF;IAED,UAAU,CAAC,EAAE,cAAc,EAAE;QAC3B,MAAM,EAAE,KAAK,EAAE,GAAG,sBAAsB,EAAE,GAAG,cAAc,CAAA;QAE3D,OAAO,KAAK,KAAK,CAAC;cACd,CAAC,IAAI,EAAEC,oBAAe,CAAC,IAAI,CAAC,OAAO,CAAC,cAAc,EAAE,sBAAsB,CAAC,EAAE,CAAC,CAAC;cAC/E,CAAC,IAAI,EAAEA,oBAAe,CAAC,IAAI,CAAC,OAAO,CAAC,cAAc,EAAE,cAAc,CAAC,EAAE,CAAC,CAAC,CAAA;KAC5E;IAED,WAAW;QACT,OAAO;YACL,iBAAiB,EAAE,MAAM,CAAC,EAAE,QAAQ,EAAE;gBACpC,OAAO,QAAQ,CAAC,UAAU,CAAC,aAAa,EAAE,UAAU,CAAC,CAAA;aACtD;SACF,CAAA;KACF;IAED,oBAAoB;QAClB,OAAO;YACL,aAAa,EAAE,MAAM,IAAI,CAAC,MAAM,CAAC,QAAQ,CAAC,iBAAiB,EAAE;SAC9D,CAAA;KACF;IAED,aAAa;QACX,OAAO;YACLC,sBAAiB,CAAC;gBAChB,IAAI,EAAE,UAAU;gBAChB,IAAI,EAAE,IAAI,CAAC,IAAI;gBACf,aAAa,EAAE,KAAK,KAAK,EAAE,KAAK,EAAE,CAAC,KAAK,CAAC,CAAC,CAAC,EAAE,CAAC;gBAC9C,aAAa,EAAE,CAAC,KAAK,EAAE,IAAI,KAAK,IAAI,CAAC,UAAU,GAAG,IAAI,CAAC,KAAK,CAAC,KAAK,KAAK,CAAC,KAAK,CAAC,CAAC,CAAC;aACjF,CAAC;SACH,CAAA;KACF;CACF;;;;;;"}
|
|
@@ -1,63 +0,0 @@
|
|
|
1
|
-
import { Node, mergeAttributes, wrappingInputRule } from '@tiptap/core';
|
|
2
|
-
|
|
3
|
-
const inputRegex = /^(\d+)\.\s$/;
|
|
4
|
-
const OrderedList = Node.create({
|
|
5
|
-
name: 'orderedList',
|
|
6
|
-
addOptions() {
|
|
7
|
-
return {
|
|
8
|
-
HTMLAttributes: {},
|
|
9
|
-
};
|
|
10
|
-
},
|
|
11
|
-
group: 'block list',
|
|
12
|
-
content: 'listItem+',
|
|
13
|
-
addAttributes() {
|
|
14
|
-
return {
|
|
15
|
-
start: {
|
|
16
|
-
default: 1,
|
|
17
|
-
parseHTML: element => {
|
|
18
|
-
return element.hasAttribute('start')
|
|
19
|
-
? parseInt(element.getAttribute('start') || '', 10)
|
|
20
|
-
: 1;
|
|
21
|
-
},
|
|
22
|
-
},
|
|
23
|
-
};
|
|
24
|
-
},
|
|
25
|
-
parseHTML() {
|
|
26
|
-
return [
|
|
27
|
-
{
|
|
28
|
-
tag: 'ol',
|
|
29
|
-
},
|
|
30
|
-
];
|
|
31
|
-
},
|
|
32
|
-
renderHTML({ HTMLAttributes }) {
|
|
33
|
-
const { start, ...attributesWithoutStart } = HTMLAttributes;
|
|
34
|
-
return start === 1
|
|
35
|
-
? ['ol', mergeAttributes(this.options.HTMLAttributes, attributesWithoutStart), 0]
|
|
36
|
-
: ['ol', mergeAttributes(this.options.HTMLAttributes, HTMLAttributes), 0];
|
|
37
|
-
},
|
|
38
|
-
addCommands() {
|
|
39
|
-
return {
|
|
40
|
-
toggleOrderedList: () => ({ commands }) => {
|
|
41
|
-
return commands.toggleList('orderedList', 'listItem');
|
|
42
|
-
},
|
|
43
|
-
};
|
|
44
|
-
},
|
|
45
|
-
addKeyboardShortcuts() {
|
|
46
|
-
return {
|
|
47
|
-
'Mod-Shift-7': () => this.editor.commands.toggleOrderedList(),
|
|
48
|
-
};
|
|
49
|
-
},
|
|
50
|
-
addInputRules() {
|
|
51
|
-
return [
|
|
52
|
-
wrappingInputRule({
|
|
53
|
-
find: inputRegex,
|
|
54
|
-
type: this.type,
|
|
55
|
-
getAttributes: match => ({ start: +match[1] }),
|
|
56
|
-
joinPredicate: (match, node) => node.childCount + node.attrs.start === +match[1],
|
|
57
|
-
}),
|
|
58
|
-
];
|
|
59
|
-
},
|
|
60
|
-
});
|
|
61
|
-
|
|
62
|
-
export { OrderedList, OrderedList as default, inputRegex };
|
|
63
|
-
//# sourceMappingURL=tiptap-extension-ordered-list.esm.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"tiptap-extension-ordered-list.esm.js","sources":["../src/ordered-list.ts"],"sourcesContent":["import { Node, mergeAttributes, wrappingInputRule } from '@tiptap/core'\n\nexport interface OrderedListOptions {\n HTMLAttributes: Record<string, any>,\n}\n\ndeclare module '@tiptap/core' {\n interface Commands<ReturnType> {\n orderedList: {\n /**\n * Toggle an ordered list\n */\n toggleOrderedList: () => ReturnType,\n }\n }\n}\n\nexport const inputRegex = /^(\\d+)\\.\\s$/\n\nexport const OrderedList = Node.create<OrderedListOptions>({\n name: 'orderedList',\n\n addOptions() {\n return {\n HTMLAttributes: {},\n }\n },\n\n group: 'block list',\n\n content: 'listItem+',\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 }\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 }) => {\n return commands.toggleList('orderedList', 'listItem')\n },\n }\n },\n\n addKeyboardShortcuts() {\n return {\n 'Mod-Shift-7': () => this.editor.commands.toggleOrderedList(),\n }\n },\n\n addInputRules() {\n return [\n 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 },\n})\n"],"names":[],"mappings":";;MAiBa,UAAU,GAAG,cAAa;MAE1B,WAAW,GAAG,IAAI,CAAC,MAAM,CAAqB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AAE,KAAK,KAAK,EAAE,KAAK,EAAE,CAAC,KAAK,CAAC,CAAC,CAAC,EAAE,CAAC;gBAC9C,aAAa,EAAE,CAAC,KAAK,EAAE,IAAI,KAAK,IAAI,CAAC,UAAU,GAAG,IAAI,CAAC,KAAK,CAAC,KAAK,KAAK,CAAC,KAAK,CAAC,CAAC,CAAC;aACjF,CAAC;SACH,CAAA;KACF;CACF;;;;"}
|
|
@@ -1,73 +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
|
-
const inputRegex = /^(\d+)\.\s$/;
|
|
8
|
-
const OrderedList = core.Node.create({
|
|
9
|
-
name: 'orderedList',
|
|
10
|
-
addOptions() {
|
|
11
|
-
return {
|
|
12
|
-
HTMLAttributes: {},
|
|
13
|
-
};
|
|
14
|
-
},
|
|
15
|
-
group: 'block list',
|
|
16
|
-
content: 'listItem+',
|
|
17
|
-
addAttributes() {
|
|
18
|
-
return {
|
|
19
|
-
start: {
|
|
20
|
-
default: 1,
|
|
21
|
-
parseHTML: element => {
|
|
22
|
-
return element.hasAttribute('start')
|
|
23
|
-
? parseInt(element.getAttribute('start') || '', 10)
|
|
24
|
-
: 1;
|
|
25
|
-
},
|
|
26
|
-
},
|
|
27
|
-
};
|
|
28
|
-
},
|
|
29
|
-
parseHTML() {
|
|
30
|
-
return [
|
|
31
|
-
{
|
|
32
|
-
tag: 'ol',
|
|
33
|
-
},
|
|
34
|
-
];
|
|
35
|
-
},
|
|
36
|
-
renderHTML({ HTMLAttributes }) {
|
|
37
|
-
const { start, ...attributesWithoutStart } = HTMLAttributes;
|
|
38
|
-
return start === 1
|
|
39
|
-
? ['ol', core.mergeAttributes(this.options.HTMLAttributes, attributesWithoutStart), 0]
|
|
40
|
-
: ['ol', core.mergeAttributes(this.options.HTMLAttributes, HTMLAttributes), 0];
|
|
41
|
-
},
|
|
42
|
-
addCommands() {
|
|
43
|
-
return {
|
|
44
|
-
toggleOrderedList: () => ({ commands }) => {
|
|
45
|
-
return commands.toggleList('orderedList', 'listItem');
|
|
46
|
-
},
|
|
47
|
-
};
|
|
48
|
-
},
|
|
49
|
-
addKeyboardShortcuts() {
|
|
50
|
-
return {
|
|
51
|
-
'Mod-Shift-7': () => this.editor.commands.toggleOrderedList(),
|
|
52
|
-
};
|
|
53
|
-
},
|
|
54
|
-
addInputRules() {
|
|
55
|
-
return [
|
|
56
|
-
core.wrappingInputRule({
|
|
57
|
-
find: inputRegex,
|
|
58
|
-
type: this.type,
|
|
59
|
-
getAttributes: match => ({ start: +match[1] }),
|
|
60
|
-
joinPredicate: (match, node) => node.childCount + node.attrs.start === +match[1],
|
|
61
|
-
}),
|
|
62
|
-
];
|
|
63
|
-
},
|
|
64
|
-
});
|
|
65
|
-
|
|
66
|
-
exports.OrderedList = OrderedList;
|
|
67
|
-
exports["default"] = OrderedList;
|
|
68
|
-
exports.inputRegex = inputRegex;
|
|
69
|
-
|
|
70
|
-
Object.defineProperty(exports, '__esModule', { value: true });
|
|
71
|
-
|
|
72
|
-
}));
|
|
73
|
-
//# sourceMappingURL=tiptap-extension-ordered-list.umd.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"tiptap-extension-ordered-list.umd.js","sources":["../src/ordered-list.ts"],"sourcesContent":["import { Node, mergeAttributes, wrappingInputRule } from '@tiptap/core'\n\nexport interface OrderedListOptions {\n HTMLAttributes: Record<string, any>,\n}\n\ndeclare module '@tiptap/core' {\n interface Commands<ReturnType> {\n orderedList: {\n /**\n * Toggle an ordered list\n */\n toggleOrderedList: () => ReturnType,\n }\n }\n}\n\nexport const inputRegex = /^(\\d+)\\.\\s$/\n\nexport const OrderedList = Node.create<OrderedListOptions>({\n name: 'orderedList',\n\n addOptions() {\n return {\n HTMLAttributes: {},\n }\n },\n\n group: 'block list',\n\n content: 'listItem+',\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 }\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 }) => {\n return commands.toggleList('orderedList', 'listItem')\n },\n }\n },\n\n addKeyboardShortcuts() {\n return {\n 'Mod-Shift-7': () => this.editor.commands.toggleOrderedList(),\n }\n },\n\n addInputRules() {\n return [\n 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 },\n})\n"],"names":["Node","mergeAttributes","wrappingInputRule"],"mappings":";;;;;;QAiBa,UAAU,GAAG,cAAa;QAE1B,WAAW,GAAGA,SAAI,CAAC,MAAM,CAAqB;MACzD,IAAI,EAAE,aAAa;MAEnB,UAAU;UACR,OAAO;cACL,cAAc,EAAE,EAAE;WACnB,CAAA;OACF;MAED,KAAK,EAAE,YAAY;MAEnB,OAAO,EAAE,WAAW;MAEpB,aAAa;UACX,OAAO;cACL,KAAK,EAAE;kBACL,OAAO,EAAE,CAAC;kBACV,SAAS,EAAE,OAAO;sBAChB,OAAO,OAAO,CAAC,YAAY,CAAC,OAAO,CAAC;4BAChC,QAAQ,CAAC,OAAO,CAAC,YAAY,CAAC,OAAO,CAAC,IAAI,EAAE,EAAE,EA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