@tiptap/extension-bullet-list 2.11.6 → 3.0.0-beta.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE.md +21 -0
- package/README.md +5 -1
- package/dist/index.cjs +32 -78
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +2 -0
- package/dist/index.d.ts +2 -4
- package/dist/index.js +9 -74
- package/dist/index.js.map +1 -1
- package/package.json +10 -8
- package/src/index.ts +3 -2
- package/dist/bullet-list.d.ts +0 -49
- package/dist/bullet-list.d.ts.map +0 -1
- package/dist/index.d.ts.map +0 -1
- package/dist/index.umd.js +0 -84
- package/dist/index.umd.js.map +0 -1
- package/src/bullet-list.ts +0 -123
package/LICENSE.md
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2025, Tiptap GmbH
|
|
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.
|
package/README.md
CHANGED
|
@@ -1,14 +1,18 @@
|
|
|
1
1
|
# @tiptap/extension-bullet-list
|
|
2
|
+
|
|
2
3
|
[](https://www.npmjs.com/package/@tiptap/extension-bullet-list)
|
|
3
4
|
[](https://npmcharts.com/compare/tiptap?minimal=true)
|
|
4
5
|
[](https://www.npmjs.com/package/@tiptap/extension-bullet-list)
|
|
5
6
|
[](https://github.com/sponsors/ueberdosis)
|
|
6
7
|
|
|
7
8
|
## Introduction
|
|
8
|
-
|
|
9
|
+
|
|
10
|
+
Tiptap is a headless wrapper around [ProseMirror](https://ProseMirror.net) – a toolkit for building rich text WYSIWYG editors, which is already in use at many well-known companies such as _New York Times_, _The Guardian_ or _Atlassian_.
|
|
9
11
|
|
|
10
12
|
## Official Documentation
|
|
13
|
+
|
|
11
14
|
Documentation can be found on the [Tiptap website](https://tiptap.dev).
|
|
12
15
|
|
|
13
16
|
## License
|
|
17
|
+
|
|
14
18
|
Tiptap is open sourced software licensed under the [MIT license](https://github.com/ueberdosis/tiptap/blob/main/LICENSE.md).
|
package/dist/index.cjs
CHANGED
|
@@ -1,80 +1,34 @@
|
|
|
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
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
const TextStyleName = 'textStyle';
|
|
9
|
-
/**
|
|
10
|
-
* Matches a bullet list to a dash or asterisk.
|
|
11
|
-
*/
|
|
12
|
-
const inputRegex = /^\s*([-+*])\s$/;
|
|
13
|
-
/**
|
|
14
|
-
* This extension allows you to create bullet lists.
|
|
15
|
-
* This requires the ListItem extension
|
|
16
|
-
* @see https://tiptap.dev/api/nodes/bullet-list
|
|
17
|
-
* @see https://tiptap.dev/api/nodes/list-item.
|
|
18
|
-
*/
|
|
19
|
-
const BulletList = core.Node.create({
|
|
20
|
-
name: 'bulletList',
|
|
21
|
-
addOptions() {
|
|
22
|
-
return {
|
|
23
|
-
itemTypeName: 'listItem',
|
|
24
|
-
HTMLAttributes: {},
|
|
25
|
-
keepMarks: false,
|
|
26
|
-
keepAttributes: false,
|
|
27
|
-
};
|
|
28
|
-
},
|
|
29
|
-
group: 'block list',
|
|
30
|
-
content() {
|
|
31
|
-
return `${this.options.itemTypeName}+`;
|
|
32
|
-
},
|
|
33
|
-
parseHTML() {
|
|
34
|
-
return [
|
|
35
|
-
{ tag: 'ul' },
|
|
36
|
-
];
|
|
37
|
-
},
|
|
38
|
-
renderHTML({ HTMLAttributes }) {
|
|
39
|
-
return ['ul', core.mergeAttributes(this.options.HTMLAttributes, HTMLAttributes), 0];
|
|
40
|
-
},
|
|
41
|
-
addCommands() {
|
|
42
|
-
return {
|
|
43
|
-
toggleBulletList: () => ({ commands, chain }) => {
|
|
44
|
-
if (this.options.keepAttributes) {
|
|
45
|
-
return chain().toggleList(this.name, this.options.itemTypeName, this.options.keepMarks).updateAttributes(ListItemName, this.editor.getAttributes(TextStyleName)).run();
|
|
46
|
-
}
|
|
47
|
-
return commands.toggleList(this.name, this.options.itemTypeName, this.options.keepMarks);
|
|
48
|
-
},
|
|
49
|
-
};
|
|
50
|
-
},
|
|
51
|
-
addKeyboardShortcuts() {
|
|
52
|
-
return {
|
|
53
|
-
'Mod-Shift-8': () => this.editor.commands.toggleBulletList(),
|
|
54
|
-
};
|
|
55
|
-
},
|
|
56
|
-
addInputRules() {
|
|
57
|
-
let inputRule = core.wrappingInputRule({
|
|
58
|
-
find: inputRegex,
|
|
59
|
-
type: this.type,
|
|
60
|
-
});
|
|
61
|
-
if (this.options.keepMarks || this.options.keepAttributes) {
|
|
62
|
-
inputRule = core.wrappingInputRule({
|
|
63
|
-
find: inputRegex,
|
|
64
|
-
type: this.type,
|
|
65
|
-
keepMarks: this.options.keepMarks,
|
|
66
|
-
keepAttributes: this.options.keepAttributes,
|
|
67
|
-
getAttributes: () => { return this.editor.getAttributes(TextStyleName); },
|
|
68
|
-
editor: this.editor,
|
|
69
|
-
});
|
|
70
|
-
}
|
|
71
|
-
return [
|
|
72
|
-
inputRule,
|
|
73
|
-
];
|
|
74
|
-
},
|
|
20
|
+
// src/index.ts
|
|
21
|
+
var index_exports = {};
|
|
22
|
+
__export(index_exports, {
|
|
23
|
+
BulletList: () => import_extension_list2.BulletList,
|
|
24
|
+
default: () => index_default
|
|
75
25
|
});
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
26
|
+
module.exports = __toCommonJS(index_exports);
|
|
27
|
+
var import_extension_list = require("@tiptap/extension-list");
|
|
28
|
+
var import_extension_list2 = require("@tiptap/extension-list");
|
|
29
|
+
var index_default = import_extension_list.BulletList;
|
|
30
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
31
|
+
0 && (module.exports = {
|
|
32
|
+
BulletList
|
|
33
|
+
});
|
|
34
|
+
//# sourceMappingURL=index.cjs.map
|
package/dist/index.cjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"
|
|
1
|
+
{"version":3,"sources":["../src/index.ts"],"sourcesContent":["import { BulletList } from '@tiptap/extension-list'\n\nexport type { BulletListOptions } from '@tiptap/extension-list'\nexport { BulletList } from '@tiptap/extension-list'\n\nexport default BulletList\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,4BAA2B;AAG3B,IAAAA,yBAA2B;AAE3B,IAAO,gBAAQ;","names":["import_extension_list"]}
|
package/dist/index.d.cts
ADDED
package/dist/index.d.ts
CHANGED
|
@@ -1,4 +1,2 @@
|
|
|
1
|
-
import { BulletList } from '
|
|
2
|
-
export
|
|
3
|
-
export default BulletList;
|
|
4
|
-
//# sourceMappingURL=index.d.ts.map
|
|
1
|
+
import { BulletList } from '@tiptap/extension-list';
|
|
2
|
+
export { BulletList, BulletListOptions, BulletList as default } from '@tiptap/extension-list';
|
package/dist/index.js
CHANGED
|
@@ -1,74 +1,9 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
* This extension allows you to create bullet lists.
|
|
11
|
-
* This requires the ListItem extension
|
|
12
|
-
* @see https://tiptap.dev/api/nodes/bullet-list
|
|
13
|
-
* @see https://tiptap.dev/api/nodes/list-item.
|
|
14
|
-
*/
|
|
15
|
-
const BulletList = Node.create({
|
|
16
|
-
name: 'bulletList',
|
|
17
|
-
addOptions() {
|
|
18
|
-
return {
|
|
19
|
-
itemTypeName: 'listItem',
|
|
20
|
-
HTMLAttributes: {},
|
|
21
|
-
keepMarks: false,
|
|
22
|
-
keepAttributes: false,
|
|
23
|
-
};
|
|
24
|
-
},
|
|
25
|
-
group: 'block list',
|
|
26
|
-
content() {
|
|
27
|
-
return `${this.options.itemTypeName}+`;
|
|
28
|
-
},
|
|
29
|
-
parseHTML() {
|
|
30
|
-
return [
|
|
31
|
-
{ tag: 'ul' },
|
|
32
|
-
];
|
|
33
|
-
},
|
|
34
|
-
renderHTML({ HTMLAttributes }) {
|
|
35
|
-
return ['ul', mergeAttributes(this.options.HTMLAttributes, HTMLAttributes), 0];
|
|
36
|
-
},
|
|
37
|
-
addCommands() {
|
|
38
|
-
return {
|
|
39
|
-
toggleBulletList: () => ({ commands, chain }) => {
|
|
40
|
-
if (this.options.keepAttributes) {
|
|
41
|
-
return chain().toggleList(this.name, this.options.itemTypeName, this.options.keepMarks).updateAttributes(ListItemName, this.editor.getAttributes(TextStyleName)).run();
|
|
42
|
-
}
|
|
43
|
-
return commands.toggleList(this.name, this.options.itemTypeName, this.options.keepMarks);
|
|
44
|
-
},
|
|
45
|
-
};
|
|
46
|
-
},
|
|
47
|
-
addKeyboardShortcuts() {
|
|
48
|
-
return {
|
|
49
|
-
'Mod-Shift-8': () => this.editor.commands.toggleBulletList(),
|
|
50
|
-
};
|
|
51
|
-
},
|
|
52
|
-
addInputRules() {
|
|
53
|
-
let inputRule = wrappingInputRule({
|
|
54
|
-
find: inputRegex,
|
|
55
|
-
type: this.type,
|
|
56
|
-
});
|
|
57
|
-
if (this.options.keepMarks || this.options.keepAttributes) {
|
|
58
|
-
inputRule = wrappingInputRule({
|
|
59
|
-
find: inputRegex,
|
|
60
|
-
type: this.type,
|
|
61
|
-
keepMarks: this.options.keepMarks,
|
|
62
|
-
keepAttributes: this.options.keepAttributes,
|
|
63
|
-
getAttributes: () => { return this.editor.getAttributes(TextStyleName); },
|
|
64
|
-
editor: this.editor,
|
|
65
|
-
});
|
|
66
|
-
}
|
|
67
|
-
return [
|
|
68
|
-
inputRule,
|
|
69
|
-
];
|
|
70
|
-
},
|
|
71
|
-
});
|
|
72
|
-
|
|
73
|
-
export { BulletList, BulletList as default, inputRegex };
|
|
74
|
-
//# sourceMappingURL=index.js.map
|
|
1
|
+
// src/index.ts
|
|
2
|
+
import { BulletList } from "@tiptap/extension-list";
|
|
3
|
+
import { BulletList as BulletList2 } from "@tiptap/extension-list";
|
|
4
|
+
var index_default = BulletList;
|
|
5
|
+
export {
|
|
6
|
+
BulletList2 as BulletList,
|
|
7
|
+
index_default as default
|
|
8
|
+
};
|
|
9
|
+
//# sourceMappingURL=index.js.map
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"
|
|
1
|
+
{"version":3,"sources":["../src/index.ts"],"sourcesContent":["import { BulletList } from '@tiptap/extension-list'\n\nexport type { BulletListOptions } from '@tiptap/extension-list'\nexport { BulletList } from '@tiptap/extension-list'\n\nexport default BulletList\n"],"mappings":";AAAA,SAAS,kBAAkB;AAG3B,SAAS,cAAAA,mBAAkB;AAE3B,IAAO,gBAAQ;","names":["BulletList"]}
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@tiptap/extension-bullet-list",
|
|
3
3
|
"description": "bullet list extension for tiptap",
|
|
4
|
-
"version": "
|
|
4
|
+
"version": "3.0.0-beta.0",
|
|
5
5
|
"homepage": "https://tiptap.dev",
|
|
6
6
|
"keywords": [
|
|
7
7
|
"tiptap",
|
|
@@ -15,24 +15,26 @@
|
|
|
15
15
|
"type": "module",
|
|
16
16
|
"exports": {
|
|
17
17
|
".": {
|
|
18
|
-
"types":
|
|
18
|
+
"types": {
|
|
19
|
+
"import": "./dist/index.d.ts",
|
|
20
|
+
"require": "./dist/index.d.cts"
|
|
21
|
+
},
|
|
19
22
|
"import": "./dist/index.js",
|
|
20
23
|
"require": "./dist/index.cjs"
|
|
21
24
|
}
|
|
22
25
|
},
|
|
23
26
|
"main": "dist/index.cjs",
|
|
24
27
|
"module": "dist/index.js",
|
|
25
|
-
"umd": "dist/index.umd.js",
|
|
26
28
|
"types": "dist/index.d.ts",
|
|
27
29
|
"files": [
|
|
28
30
|
"src",
|
|
29
31
|
"dist"
|
|
30
32
|
],
|
|
31
33
|
"devDependencies": {
|
|
32
|
-
"@tiptap/
|
|
34
|
+
"@tiptap/extension-list": "^3.0.0-beta.0"
|
|
33
35
|
},
|
|
34
36
|
"peerDependencies": {
|
|
35
|
-
"@tiptap/
|
|
37
|
+
"@tiptap/extension-list": "^3.0.0-beta.0"
|
|
36
38
|
},
|
|
37
39
|
"repository": {
|
|
38
40
|
"type": "git",
|
|
@@ -40,7 +42,7 @@
|
|
|
40
42
|
"directory": "packages/extension-bullet-list"
|
|
41
43
|
},
|
|
42
44
|
"scripts": {
|
|
43
|
-
"
|
|
44
|
-
"
|
|
45
|
+
"build": "tsup",
|
|
46
|
+
"lint": "prettier ./src/ --check && eslint --cache --quiet --no-error-on-unmatched-pattern ./src/"
|
|
45
47
|
}
|
|
46
|
-
}
|
|
48
|
+
}
|
package/src/index.ts
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
|
-
import { BulletList } from '
|
|
1
|
+
import { BulletList } from '@tiptap/extension-list'
|
|
2
2
|
|
|
3
|
-
export
|
|
3
|
+
export type { BulletListOptions } from '@tiptap/extension-list'
|
|
4
|
+
export { BulletList } from '@tiptap/extension-list'
|
|
4
5
|
|
|
5
6
|
export default BulletList
|
package/dist/bullet-list.d.ts
DELETED
|
@@ -1,49 +0,0 @@
|
|
|
1
|
-
import { Node } from '@tiptap/core';
|
|
2
|
-
export interface BulletListOptions {
|
|
3
|
-
/**
|
|
4
|
-
* The node name for the list items
|
|
5
|
-
* @default 'listItem'
|
|
6
|
-
* @example 'paragraph'
|
|
7
|
-
*/
|
|
8
|
-
itemTypeName: string;
|
|
9
|
-
/**
|
|
10
|
-
* HTML attributes to add to the bullet list element
|
|
11
|
-
* @default {}
|
|
12
|
-
* @example { class: 'foo' }
|
|
13
|
-
*/
|
|
14
|
-
HTMLAttributes: Record<string, any>;
|
|
15
|
-
/**
|
|
16
|
-
* Keep the marks when splitting the list
|
|
17
|
-
* @default false
|
|
18
|
-
* @example true
|
|
19
|
-
*/
|
|
20
|
-
keepMarks: boolean;
|
|
21
|
-
/**
|
|
22
|
-
* Keep the attributes when splitting the list
|
|
23
|
-
* @default false
|
|
24
|
-
* @example true
|
|
25
|
-
*/
|
|
26
|
-
keepAttributes: boolean;
|
|
27
|
-
}
|
|
28
|
-
declare module '@tiptap/core' {
|
|
29
|
-
interface Commands<ReturnType> {
|
|
30
|
-
bulletList: {
|
|
31
|
-
/**
|
|
32
|
-
* Toggle a bullet list
|
|
33
|
-
*/
|
|
34
|
-
toggleBulletList: () => ReturnType;
|
|
35
|
-
};
|
|
36
|
-
}
|
|
37
|
-
}
|
|
38
|
-
/**
|
|
39
|
-
* Matches a bullet list to a dash or asterisk.
|
|
40
|
-
*/
|
|
41
|
-
export declare const inputRegex: RegExp;
|
|
42
|
-
/**
|
|
43
|
-
* This extension allows you to create bullet lists.
|
|
44
|
-
* This requires the ListItem extension
|
|
45
|
-
* @see https://tiptap.dev/api/nodes/bullet-list
|
|
46
|
-
* @see https://tiptap.dev/api/nodes/list-item.
|
|
47
|
-
*/
|
|
48
|
-
export declare const BulletList: Node<BulletListOptions, any>;
|
|
49
|
-
//# sourceMappingURL=bullet-list.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"bullet-list.d.ts","sourceRoot":"","sources":["../src/bullet-list.ts"],"names":[],"mappings":"AAAA,OAAO,EAAmB,IAAI,EAAqB,MAAM,cAAc,CAAA;AAKvE,MAAM,WAAW,iBAAiB;IAChC;;;;OAIG;IACH,YAAY,EAAE,MAAM,CAAC;IAErB;;;;OAIG;IACH,cAAc,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC;IAEpC;;;;OAIG;IACH,SAAS,EAAE,OAAO,CAAC;IAEnB;;;;OAIG;IACH,cAAc,EAAE,OAAO,CAAC;CACzB;AAED,OAAO,QAAQ,cAAc,CAAC;IAC5B,UAAU,QAAQ,CAAC,UAAU;QAC3B,UAAU,EAAE;YACV;;eAEG;YACH,gBAAgB,EAAE,MAAM,UAAU,CAAC;SACpC,CAAA;KACF;CACF;AAED;;GAEG;AACH,eAAO,MAAM,UAAU,QAAmB,CAAA;AAE1C;;;;;GAKG;AACH,eAAO,MAAM,UAAU,8BAiErB,CAAA"}
|
package/dist/index.d.ts.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAAA;AAE7C,cAAc,kBAAkB,CAAA;AAEhC,eAAe,UAAU,CAAA"}
|
package/dist/index.umd.js
DELETED
|
@@ -1,84 +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-bullet-list"] = {}, global.core));
|
|
5
|
-
})(this, (function (exports, core) { 'use strict';
|
|
6
|
-
|
|
7
|
-
const ListItemName = 'listItem';
|
|
8
|
-
const TextStyleName = 'textStyle';
|
|
9
|
-
/**
|
|
10
|
-
* Matches a bullet list to a dash or asterisk.
|
|
11
|
-
*/
|
|
12
|
-
const inputRegex = /^\s*([-+*])\s$/;
|
|
13
|
-
/**
|
|
14
|
-
* This extension allows you to create bullet lists.
|
|
15
|
-
* This requires the ListItem extension
|
|
16
|
-
* @see https://tiptap.dev/api/nodes/bullet-list
|
|
17
|
-
* @see https://tiptap.dev/api/nodes/list-item.
|
|
18
|
-
*/
|
|
19
|
-
const BulletList = core.Node.create({
|
|
20
|
-
name: 'bulletList',
|
|
21
|
-
addOptions() {
|
|
22
|
-
return {
|
|
23
|
-
itemTypeName: 'listItem',
|
|
24
|
-
HTMLAttributes: {},
|
|
25
|
-
keepMarks: false,
|
|
26
|
-
keepAttributes: false,
|
|
27
|
-
};
|
|
28
|
-
},
|
|
29
|
-
group: 'block list',
|
|
30
|
-
content() {
|
|
31
|
-
return `${this.options.itemTypeName}+`;
|
|
32
|
-
},
|
|
33
|
-
parseHTML() {
|
|
34
|
-
return [
|
|
35
|
-
{ tag: 'ul' },
|
|
36
|
-
];
|
|
37
|
-
},
|
|
38
|
-
renderHTML({ HTMLAttributes }) {
|
|
39
|
-
return ['ul', core.mergeAttributes(this.options.HTMLAttributes, HTMLAttributes), 0];
|
|
40
|
-
},
|
|
41
|
-
addCommands() {
|
|
42
|
-
return {
|
|
43
|
-
toggleBulletList: () => ({ commands, chain }) => {
|
|
44
|
-
if (this.options.keepAttributes) {
|
|
45
|
-
return chain().toggleList(this.name, this.options.itemTypeName, this.options.keepMarks).updateAttributes(ListItemName, this.editor.getAttributes(TextStyleName)).run();
|
|
46
|
-
}
|
|
47
|
-
return commands.toggleList(this.name, this.options.itemTypeName, this.options.keepMarks);
|
|
48
|
-
},
|
|
49
|
-
};
|
|
50
|
-
},
|
|
51
|
-
addKeyboardShortcuts() {
|
|
52
|
-
return {
|
|
53
|
-
'Mod-Shift-8': () => this.editor.commands.toggleBulletList(),
|
|
54
|
-
};
|
|
55
|
-
},
|
|
56
|
-
addInputRules() {
|
|
57
|
-
let inputRule = core.wrappingInputRule({
|
|
58
|
-
find: inputRegex,
|
|
59
|
-
type: this.type,
|
|
60
|
-
});
|
|
61
|
-
if (this.options.keepMarks || this.options.keepAttributes) {
|
|
62
|
-
inputRule = core.wrappingInputRule({
|
|
63
|
-
find: inputRegex,
|
|
64
|
-
type: this.type,
|
|
65
|
-
keepMarks: this.options.keepMarks,
|
|
66
|
-
keepAttributes: this.options.keepAttributes,
|
|
67
|
-
getAttributes: () => { return this.editor.getAttributes(TextStyleName); },
|
|
68
|
-
editor: this.editor,
|
|
69
|
-
});
|
|
70
|
-
}
|
|
71
|
-
return [
|
|
72
|
-
inputRule,
|
|
73
|
-
];
|
|
74
|
-
},
|
|
75
|
-
});
|
|
76
|
-
|
|
77
|
-
exports.BulletList = BulletList;
|
|
78
|
-
exports.default = BulletList;
|
|
79
|
-
exports.inputRegex = inputRegex;
|
|
80
|
-
|
|
81
|
-
Object.defineProperty(exports, '__esModule', { value: true });
|
|
82
|
-
|
|
83
|
-
}));
|
|
84
|
-
//# sourceMappingURL=index.umd.js.map
|
package/dist/index.umd.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.umd.js","sources":["../src/bullet-list.ts"],"sourcesContent":["import { mergeAttributes, Node, wrappingInputRule } from '@tiptap/core'\n\nconst ListItemName = 'listItem'\nconst TextStyleName = 'textStyle'\n\nexport interface BulletListOptions {\n /**\n * The node name for the list items\n * @default 'listItem'\n * @example 'paragraph'\n */\n itemTypeName: string,\n\n /**\n * HTML attributes to add to the bullet list element\n * @default {}\n * @example { class: 'foo' }\n */\n HTMLAttributes: Record<string, any>,\n\n /**\n * Keep the marks when splitting the list\n * @default false\n * @example true\n */\n keepMarks: boolean,\n\n /**\n * Keep the attributes when splitting the list\n * @default false\n * @example true\n */\n keepAttributes: boolean,\n}\n\ndeclare module '@tiptap/core' {\n interface Commands<ReturnType> {\n bulletList: {\n /**\n * Toggle a bullet list\n */\n toggleBulletList: () => ReturnType,\n }\n }\n}\n\n/**\n * Matches a bullet list to a dash or asterisk.\n */\nexport const inputRegex = /^\\s*([-+*])\\s$/\n\n/**\n * This extension allows you to create bullet lists.\n * This requires the ListItem extension\n * @see https://tiptap.dev/api/nodes/bullet-list\n * @see https://tiptap.dev/api/nodes/list-item.\n */\nexport const BulletList = Node.create<BulletListOptions>({\n name: 'bulletList',\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 parseHTML() {\n return [\n { tag: 'ul' },\n ]\n },\n\n renderHTML({ HTMLAttributes }) {\n return ['ul', mergeAttributes(this.options.HTMLAttributes, HTMLAttributes), 0]\n },\n\n addCommands() {\n return {\n toggleBulletList: () => ({ 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-8': () => this.editor.commands.toggleBulletList(),\n }\n },\n\n addInputRules() {\n let inputRule = wrappingInputRule({\n find: inputRegex,\n type: this.type,\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: () => { return this.editor.getAttributes(TextStyleName) },\n editor: this.editor,\n })\n }\n return [\n inputRule,\n ]\n },\n})\n"],"names":["Node","mergeAttributes","wrappingInputRule"],"mappings":";;;;;;EAEA,MAAM,YAAY,GAAG,UAAU;EAC/B,MAAM,aAAa,GAAG,WAAW;EA2CjC;;EAEG;AACI,QAAM,UAAU,GAAG;EAE1B;;;;;EAKG;AACU,QAAA,UAAU,GAAGA,SAAI,CAAC,MAAM,CAAoB;EACvD,IAAA,IAAI,EAAE,YAAY;MAElB,UAAU,GAAA;UACR,OAAO;EACL,YAAA,YAAY,EAAE,UAAU;EACxB,YAAA,cAAc,EAAE,EAAE;EAClB,YAAA,SAAS,EAAE,KAAK;EAChB,YAAA,cAAc,EAAE,KAAK;WACtB;OACF;EAED,IAAA,KAAK,EAAE,YAAY;MAEnB,OAAO,GAAA;EACL,QAAA,OAAO,GAAG,IAAI,CAAC,OAAO,CAAC,YAAY,GAAG;OACvC;MAED,SAAS,GAAA;UACP,OAAO;cACL,EAAE,GAAG,EAAE,IAAI,EAAE;WACd;OACF;MAED,UAAU,CAAC,EAAE,cAAc,EAAE,EAAA;EAC3B,QAAA,OAAO,CAAC,IAAI,EAAEC,oBAAe,CAAC,IAAI,CAAC,OAAO,CAAC,cAAc,EAAE,cAAc,CAAC,EAAE,CAAC,CAAC;OAC/E;MAED,WAAW,GAAA;UACT,OAAO;cACL,gBAAgB,EAAE,MAAM,CAAC,EAAE,QAAQ,EAAE,KAAK,EAAE,KAAI;EAC9C,gBAAA,IAAI,IAAI,CAAC,OAAO,CAAC,cAAc,EAAE;EAC/B,oBAAA,OAAO,KAAK,EAAE,CAAC,UAAU,CAAC,IAAI,CAAC,IAAI,EAAE,IAAI,CAAC,OAAO,CAAC,YAAY,EAAE,IAAI,CAAC,OAAO,CAAC,SAAS,CAAC,CAAC,gBAAgB,CAAC,YAAY,EAAE,IAAI,CAAC,MAAM,CAAC,aAAa,CAAC,aAAa,CAAC,CAAC,CAAC,GAAG,EAAE;;kBAExK,OAAO,QAAQ,CAAC,UAAU,CAAC,IAAI,CAAC,IAAI,EAAE,IAAI,CAAC,OAAO,CAAC,YAAY,EAAE,IAAI,CAAC,OAAO,CAAC,SAAS,CAAC;eACzF;WACF;OACF;MAED,oBAAoB,GAAA;UAClB,OAAO;cACL,aAAa,EAAE,MAAM,IAAI,CAAC,MAAM,CAAC,QAAQ,CAAC,gBAAgB,EAAE;WAC7D;OACF;MAED,aAAa,GAAA;UACX,IAAI,SAAS,GAAGC,sBAAiB,CAAC;EAChC,YAAA,IAAI,EAAE,UAAU;cAChB,IAAI,EAAE,IAAI,CAAC,IAAI;EAChB,SAAA,CAAC;EAEF,QAAA,IAAI,IAAI,CAAC,OAAO,CAAC,SAAS,IAAI,IAAI,CAAC,OAAO,CAAC,cAAc,EAAE;cACzD,SAAS,GAAGA,sBAAiB,CAAC;EAC5B,gBAAA,IAAI,EAAE,UAAU;kBAChB,IAAI,EAAE,IAAI,CAAC,IAAI;EACf,gBAAA,SAAS,EAAE,IAAI,CAAC,OAAO,CAAC,SAAS;EACjC,gBAAA,cAAc,EAAE,IAAI,CAAC,OAAO,CAAC,cAAc;EAC3C,gBAAA,aAAa,EAAE,MAAK,EAAG,OAAO,IAAI,CAAC,MAAM,CAAC,aAAa,CAAC,aAAa,CAAC,CAAA,EAAE;kBACxE,MAAM,EAAE,IAAI,CAAC,MAAM;EACpB,aAAA,CAAC;;UAEJ,OAAO;cACL,SAAS;WACV;OACF;EACF,CAAA;;;;;;;;;;;;"}
|
package/src/bullet-list.ts
DELETED
|
@@ -1,123 +0,0 @@
|
|
|
1
|
-
import { mergeAttributes, Node, wrappingInputRule } from '@tiptap/core'
|
|
2
|
-
|
|
3
|
-
const ListItemName = 'listItem'
|
|
4
|
-
const TextStyleName = 'textStyle'
|
|
5
|
-
|
|
6
|
-
export interface BulletListOptions {
|
|
7
|
-
/**
|
|
8
|
-
* The node name for the list items
|
|
9
|
-
* @default 'listItem'
|
|
10
|
-
* @example 'paragraph'
|
|
11
|
-
*/
|
|
12
|
-
itemTypeName: string,
|
|
13
|
-
|
|
14
|
-
/**
|
|
15
|
-
* HTML attributes to add to the bullet list element
|
|
16
|
-
* @default {}
|
|
17
|
-
* @example { class: 'foo' }
|
|
18
|
-
*/
|
|
19
|
-
HTMLAttributes: Record<string, any>,
|
|
20
|
-
|
|
21
|
-
/**
|
|
22
|
-
* Keep the marks when splitting the list
|
|
23
|
-
* @default false
|
|
24
|
-
* @example true
|
|
25
|
-
*/
|
|
26
|
-
keepMarks: boolean,
|
|
27
|
-
|
|
28
|
-
/**
|
|
29
|
-
* Keep the attributes when splitting the list
|
|
30
|
-
* @default false
|
|
31
|
-
* @example true
|
|
32
|
-
*/
|
|
33
|
-
keepAttributes: boolean,
|
|
34
|
-
}
|
|
35
|
-
|
|
36
|
-
declare module '@tiptap/core' {
|
|
37
|
-
interface Commands<ReturnType> {
|
|
38
|
-
bulletList: {
|
|
39
|
-
/**
|
|
40
|
-
* Toggle a bullet list
|
|
41
|
-
*/
|
|
42
|
-
toggleBulletList: () => ReturnType,
|
|
43
|
-
}
|
|
44
|
-
}
|
|
45
|
-
}
|
|
46
|
-
|
|
47
|
-
/**
|
|
48
|
-
* Matches a bullet list to a dash or asterisk.
|
|
49
|
-
*/
|
|
50
|
-
export const inputRegex = /^\s*([-+*])\s$/
|
|
51
|
-
|
|
52
|
-
/**
|
|
53
|
-
* This extension allows you to create bullet lists.
|
|
54
|
-
* This requires the ListItem extension
|
|
55
|
-
* @see https://tiptap.dev/api/nodes/bullet-list
|
|
56
|
-
* @see https://tiptap.dev/api/nodes/list-item.
|
|
57
|
-
*/
|
|
58
|
-
export const BulletList = Node.create<BulletListOptions>({
|
|
59
|
-
name: 'bulletList',
|
|
60
|
-
|
|
61
|
-
addOptions() {
|
|
62
|
-
return {
|
|
63
|
-
itemTypeName: 'listItem',
|
|
64
|
-
HTMLAttributes: {},
|
|
65
|
-
keepMarks: false,
|
|
66
|
-
keepAttributes: false,
|
|
67
|
-
}
|
|
68
|
-
},
|
|
69
|
-
|
|
70
|
-
group: 'block list',
|
|
71
|
-
|
|
72
|
-
content() {
|
|
73
|
-
return `${this.options.itemTypeName}+`
|
|
74
|
-
},
|
|
75
|
-
|
|
76
|
-
parseHTML() {
|
|
77
|
-
return [
|
|
78
|
-
{ tag: 'ul' },
|
|
79
|
-
]
|
|
80
|
-
},
|
|
81
|
-
|
|
82
|
-
renderHTML({ HTMLAttributes }) {
|
|
83
|
-
return ['ul', mergeAttributes(this.options.HTMLAttributes, HTMLAttributes), 0]
|
|
84
|
-
},
|
|
85
|
-
|
|
86
|
-
addCommands() {
|
|
87
|
-
return {
|
|
88
|
-
toggleBulletList: () => ({ commands, chain }) => {
|
|
89
|
-
if (this.options.keepAttributes) {
|
|
90
|
-
return chain().toggleList(this.name, this.options.itemTypeName, this.options.keepMarks).updateAttributes(ListItemName, this.editor.getAttributes(TextStyleName)).run()
|
|
91
|
-
}
|
|
92
|
-
return commands.toggleList(this.name, this.options.itemTypeName, this.options.keepMarks)
|
|
93
|
-
},
|
|
94
|
-
}
|
|
95
|
-
},
|
|
96
|
-
|
|
97
|
-
addKeyboardShortcuts() {
|
|
98
|
-
return {
|
|
99
|
-
'Mod-Shift-8': () => this.editor.commands.toggleBulletList(),
|
|
100
|
-
}
|
|
101
|
-
},
|
|
102
|
-
|
|
103
|
-
addInputRules() {
|
|
104
|
-
let inputRule = wrappingInputRule({
|
|
105
|
-
find: inputRegex,
|
|
106
|
-
type: this.type,
|
|
107
|
-
})
|
|
108
|
-
|
|
109
|
-
if (this.options.keepMarks || this.options.keepAttributes) {
|
|
110
|
-
inputRule = wrappingInputRule({
|
|
111
|
-
find: inputRegex,
|
|
112
|
-
type: this.type,
|
|
113
|
-
keepMarks: this.options.keepMarks,
|
|
114
|
-
keepAttributes: this.options.keepAttributes,
|
|
115
|
-
getAttributes: () => { return this.editor.getAttributes(TextStyleName) },
|
|
116
|
-
editor: this.editor,
|
|
117
|
-
})
|
|
118
|
-
}
|
|
119
|
-
return [
|
|
120
|
-
inputRule,
|
|
121
|
-
]
|
|
122
|
-
},
|
|
123
|
-
})
|