@tiptap/extension-bullet-list 2.0.0-beta.8 → 2.0.0-rc.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/README.md CHANGED
@@ -5,10 +5,10 @@
5
5
  [![Sponsor](https://img.shields.io/static/v1?label=Sponsor&message=%E2%9D%A4&logo=GitHub)](https://github.com/sponsors/ueberdosis)
6
6
 
7
7
  ## Introduction
8
- 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*.
8
+ 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
9
 
10
- ## Offical Documentation
11
- Documentation can be found on the [tiptap website](https://tiptap.dev).
10
+ ## Official Documentation
11
+ Documentation can be found on the [Tiptap website](https://tiptap.dev).
12
12
 
13
13
  ## License
14
- tiptap is open sourced software licensed under the [MIT license](https://github.com/ueberdosis/tiptap/blob/main/LICENSE.md).
14
+ Tiptap is open sourced software licensed under the [MIT license](https://github.com/ueberdosis/tiptap/blob/main/LICENSE.md).
package/dist/index.cjs ADDED
@@ -0,0 +1,135 @@
1
+ 'use strict';
2
+
3
+ Object.defineProperty(exports, '__esModule', { value: true });
4
+
5
+ var core = require('@tiptap/core');
6
+
7
+ const ListItem = core.Node.create({
8
+ name: 'listItem',
9
+ addOptions() {
10
+ return {
11
+ HTMLAttributes: {},
12
+ };
13
+ },
14
+ content: 'paragraph block*',
15
+ defining: true,
16
+ parseHTML() {
17
+ return [
18
+ {
19
+ tag: 'li',
20
+ },
21
+ ];
22
+ },
23
+ renderHTML({ HTMLAttributes }) {
24
+ return ['li', core.mergeAttributes(this.options.HTMLAttributes, HTMLAttributes), 0];
25
+ },
26
+ addKeyboardShortcuts() {
27
+ return {
28
+ Enter: () => this.editor.commands.splitListItem(this.name),
29
+ Tab: () => this.editor.commands.sinkListItem(this.name),
30
+ 'Shift-Tab': () => this.editor.commands.liftListItem(this.name),
31
+ };
32
+ },
33
+ });
34
+
35
+ const TextStyle = core.Mark.create({
36
+ name: 'textStyle',
37
+ addOptions() {
38
+ return {
39
+ HTMLAttributes: {},
40
+ };
41
+ },
42
+ parseHTML() {
43
+ return [
44
+ {
45
+ tag: 'span',
46
+ getAttrs: element => {
47
+ const hasStyles = element.hasAttribute('style');
48
+ if (!hasStyles) {
49
+ return false;
50
+ }
51
+ return {};
52
+ },
53
+ },
54
+ ];
55
+ },
56
+ renderHTML({ HTMLAttributes }) {
57
+ return ['span', core.mergeAttributes(this.options.HTMLAttributes, HTMLAttributes), 0];
58
+ },
59
+ addCommands() {
60
+ return {
61
+ removeEmptyTextStyle: () => ({ state, commands }) => {
62
+ const attributes = core.getMarkAttributes(state, this.type);
63
+ const hasStyles = Object.entries(attributes).some(([, value]) => !!value);
64
+ if (hasStyles) {
65
+ return true;
66
+ }
67
+ return commands.unsetMark(this.name);
68
+ },
69
+ };
70
+ },
71
+ });
72
+
73
+ const inputRegex = /^\s*([-+*])\s$/;
74
+ const BulletList = core.Node.create({
75
+ name: 'bulletList',
76
+ addOptions() {
77
+ return {
78
+ itemTypeName: 'listItem',
79
+ HTMLAttributes: {},
80
+ keepMarks: false,
81
+ keepAttributes: false,
82
+ };
83
+ },
84
+ group: 'block list',
85
+ content() {
86
+ return `${this.options.itemTypeName}+`;
87
+ },
88
+ parseHTML() {
89
+ return [
90
+ { tag: 'ul' },
91
+ ];
92
+ },
93
+ renderHTML({ HTMLAttributes }) {
94
+ return ['ul', core.mergeAttributes(this.options.HTMLAttributes, HTMLAttributes), 0];
95
+ },
96
+ addCommands() {
97
+ return {
98
+ toggleBulletList: () => ({ commands, chain }) => {
99
+ if (this.options.keepAttributes) {
100
+ return chain().toggleList(this.name, this.options.itemTypeName, this.options.keepMarks).updateAttributes(ListItem.name, this.editor.getAttributes(TextStyle.name)).run();
101
+ }
102
+ return commands.toggleList(this.name, this.options.itemTypeName, this.options.keepMarks);
103
+ },
104
+ };
105
+ },
106
+ addKeyboardShortcuts() {
107
+ return {
108
+ 'Mod-Shift-8': () => this.editor.commands.toggleBulletList(),
109
+ };
110
+ },
111
+ addInputRules() {
112
+ let inputRule = core.wrappingInputRule({
113
+ find: inputRegex,
114
+ type: this.type,
115
+ });
116
+ if (this.options.keepMarks || this.options.keepAttributes) {
117
+ inputRule = core.wrappingInputRule({
118
+ find: inputRegex,
119
+ type: this.type,
120
+ keepMarks: this.options.keepMarks,
121
+ keepAttributes: this.options.keepAttributes,
122
+ getAttributes: () => { return this.editor.getAttributes(TextStyle.name); },
123
+ editor: this.editor,
124
+ });
125
+ }
126
+ return [
127
+ inputRule,
128
+ ];
129
+ },
130
+ });
131
+
132
+ exports.BulletList = BulletList;
133
+ exports["default"] = BulletList;
134
+ exports.inputRegex = inputRegex;
135
+ //# sourceMappingURL=index.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.cjs","sources":["../../extension-list-item/src/list-item.ts","../../extension-text-style/src/text-style.ts","../src/bullet-list.ts"],"sourcesContent":["import { mergeAttributes, Node } from '@tiptap/core'\n\nexport interface ListItemOptions {\n HTMLAttributes: Record<string, any>,\n}\n\nexport const ListItem = Node.create<ListItemOptions>({\n name: 'listItem',\n\n addOptions() {\n return {\n HTMLAttributes: {},\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 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 */\n removeEmptyTextStyle: () => ReturnType,\n }\n }\n}\n\nexport const TextStyle = Mark.create<TextStyleOptions>({\n name: 'textStyle',\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'\nimport TextStyle from '../../extension-text-style/src'\n\nexport interface BulletListOptions {\n itemTypeName: string,\n HTMLAttributes: Record<string, any>,\n keepMarks: boolean,\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\nexport const inputRegex = /^\\s*([-+*])\\s$/\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(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-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(TextStyle.name) },\n editor: this.editor,\n })\n }\n return [\n inputRule,\n ]\n },\n})\n"],"names":["Node","mergeAttributes","Mark","getMarkAttributes","wrappingInputRule"],"mappings":";;;;;;AAMO,MAAM,QAAQ,GAAGA,SAAI,CAAC,MAAM,CAAkB;AACnD,IAAA,IAAI,EAAE,UAAU;IAEhB,UAAU,GAAA;QACR,OAAO;AACL,YAAA,cAAc,EAAE,EAAE;SACnB,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,EAAEC,oBAAe,CAAC,IAAI,CAAC,OAAO,CAAC,cAAc,EAAE,cAAc,CAAC,EAAE,CAAC,CAAC,CAAA;KAC/E;IAED,oBAAoB,GAAA;QAClB,OAAO;AACL,YAAA,KAAK,EAAE,MAAM,IAAI,CAAC,MAAM,CAAC,QAAQ,CAAC,aAAa,CAAC,IAAI,CAAC,IAAI,CAAC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;AACzK,iBAAA;gBACD,OAAO,QAAQ,CAAC,UAAU,CAAC,IAAI,CAAC,IAAI,EAAE,IAAI,CAAC,OAAO,CAAC,YAAY,EAAE,IAAI,CAAC,OAAO,CAAC,SAAS,CAAC,CAAA;aACzF;SACF,CAAA;KACF;IAED,oBAAoB,GAAA;QAClB,OAAO;YACL,aAAa,EAAE,MAAM,IAAI,CAAC,MAAM,CAAC,QAAQ,CAAC,gBAAgB,EAAE;SAC7D,CAAA;KACF;IAED,aAAa,GAAA;QACX,IAAI,SAAS,GAAGG,sBAAiB,CAAC;AAChC,YAAA,IAAI,EAAE,UAAU;YAChB,IAAI,EAAE,IAAI,CAAC,IAAI;AAChB,SAAA,CAAC,CAAA;QAEF,IAAI,IAAI,CAAC,OAAO,CAAC,SAAS,IAAI,IAAI,CAAC,OAAO,CAAC,cAAc,EAAE;YACzD,SAAS,GAAGA,sBAAiB,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;AAC3C,gBAAA,aAAa,EAAE,MAAQ,EAAA,OAAO,IAAI,CAAC,MAAM,CAAC,aAAa,CAAC,SAAS,CAAC,IAAI,CAAC,CAAA,EAAE;gBACzE,MAAM,EAAE,IAAI,CAAC,MAAM;AACpB,aAAA,CAAC,CAAA;AACH,SAAA;QACD,OAAO;YACL,SAAS;SACV,CAAA;KACF;AACF,CAAA;;;;;;"}
package/dist/index.js ADDED
@@ -0,0 +1,129 @@
1
+ import { Node, mergeAttributes, Mark, getMarkAttributes, wrappingInputRule } from '@tiptap/core';
2
+
3
+ const ListItem = Node.create({
4
+ name: 'listItem',
5
+ addOptions() {
6
+ return {
7
+ HTMLAttributes: {},
8
+ };
9
+ },
10
+ content: 'paragraph block*',
11
+ defining: true,
12
+ parseHTML() {
13
+ return [
14
+ {
15
+ tag: 'li',
16
+ },
17
+ ];
18
+ },
19
+ renderHTML({ HTMLAttributes }) {
20
+ return ['li', mergeAttributes(this.options.HTMLAttributes, HTMLAttributes), 0];
21
+ },
22
+ addKeyboardShortcuts() {
23
+ return {
24
+ Enter: () => this.editor.commands.splitListItem(this.name),
25
+ Tab: () => this.editor.commands.sinkListItem(this.name),
26
+ 'Shift-Tab': () => this.editor.commands.liftListItem(this.name),
27
+ };
28
+ },
29
+ });
30
+
31
+ const TextStyle = Mark.create({
32
+ name: 'textStyle',
33
+ addOptions() {
34
+ return {
35
+ HTMLAttributes: {},
36
+ };
37
+ },
38
+ parseHTML() {
39
+ return [
40
+ {
41
+ tag: 'span',
42
+ getAttrs: element => {
43
+ const hasStyles = element.hasAttribute('style');
44
+ if (!hasStyles) {
45
+ return false;
46
+ }
47
+ return {};
48
+ },
49
+ },
50
+ ];
51
+ },
52
+ renderHTML({ HTMLAttributes }) {
53
+ return ['span', mergeAttributes(this.options.HTMLAttributes, HTMLAttributes), 0];
54
+ },
55
+ addCommands() {
56
+ return {
57
+ removeEmptyTextStyle: () => ({ state, commands }) => {
58
+ const attributes = getMarkAttributes(state, this.type);
59
+ const hasStyles = Object.entries(attributes).some(([, value]) => !!value);
60
+ if (hasStyles) {
61
+ return true;
62
+ }
63
+ return commands.unsetMark(this.name);
64
+ },
65
+ };
66
+ },
67
+ });
68
+
69
+ const inputRegex = /^\s*([-+*])\s$/;
70
+ const BulletList = Node.create({
71
+ name: 'bulletList',
72
+ addOptions() {
73
+ return {
74
+ itemTypeName: 'listItem',
75
+ HTMLAttributes: {},
76
+ keepMarks: false,
77
+ keepAttributes: false,
78
+ };
79
+ },
80
+ group: 'block list',
81
+ content() {
82
+ return `${this.options.itemTypeName}+`;
83
+ },
84
+ parseHTML() {
85
+ return [
86
+ { tag: 'ul' },
87
+ ];
88
+ },
89
+ renderHTML({ HTMLAttributes }) {
90
+ return ['ul', mergeAttributes(this.options.HTMLAttributes, HTMLAttributes), 0];
91
+ },
92
+ addCommands() {
93
+ return {
94
+ toggleBulletList: () => ({ commands, chain }) => {
95
+ if (this.options.keepAttributes) {
96
+ return chain().toggleList(this.name, this.options.itemTypeName, this.options.keepMarks).updateAttributes(ListItem.name, this.editor.getAttributes(TextStyle.name)).run();
97
+ }
98
+ return commands.toggleList(this.name, this.options.itemTypeName, this.options.keepMarks);
99
+ },
100
+ };
101
+ },
102
+ addKeyboardShortcuts() {
103
+ return {
104
+ 'Mod-Shift-8': () => this.editor.commands.toggleBulletList(),
105
+ };
106
+ },
107
+ addInputRules() {
108
+ let inputRule = wrappingInputRule({
109
+ find: inputRegex,
110
+ type: this.type,
111
+ });
112
+ if (this.options.keepMarks || this.options.keepAttributes) {
113
+ inputRule = wrappingInputRule({
114
+ find: inputRegex,
115
+ type: this.type,
116
+ keepMarks: this.options.keepMarks,
117
+ keepAttributes: this.options.keepAttributes,
118
+ getAttributes: () => { return this.editor.getAttributes(TextStyle.name); },
119
+ editor: this.editor,
120
+ });
121
+ }
122
+ return [
123
+ inputRule,
124
+ ];
125
+ },
126
+ });
127
+
128
+ export { BulletList, BulletList as default, inputRegex };
129
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sources":["../../extension-list-item/src/list-item.ts","../../extension-text-style/src/text-style.ts","../src/bullet-list.ts"],"sourcesContent":["import { mergeAttributes, Node } from '@tiptap/core'\n\nexport interface ListItemOptions {\n HTMLAttributes: Record<string, any>,\n}\n\nexport const ListItem = Node.create<ListItemOptions>({\n name: 'listItem',\n\n addOptions() {\n return {\n HTMLAttributes: {},\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 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 */\n removeEmptyTextStyle: () => ReturnType,\n }\n }\n}\n\nexport const TextStyle = Mark.create<TextStyleOptions>({\n name: 'textStyle',\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'\nimport TextStyle from '../../extension-text-style/src'\n\nexport interface BulletListOptions {\n itemTypeName: string,\n HTMLAttributes: Record<string, any>,\n keepMarks: boolean,\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\nexport const inputRegex = /^\\s*([-+*])\\s$/\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(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-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(TextStyle.name) },\n editor: this.editor,\n })\n }\n return [\n inputRule,\n ]\n },\n})\n"],"names":[],"mappings":";;AAMO,MAAM,QAAQ,GAAG,IAAI,CAAC,MAAM,CAAkB;AACnD,IAAA,IAAI,EAAE,UAAU;IAEhB,UAAU,GAAA;QACR,OAAO;AACL,YAAA,cAAc,EAAE,EAAE;SACnB,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,oBAAoB,GAAA;QAClB,OAAO;AACL,YAAA,KA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AC,MAAM,CAAC,aAAa,CAAC,SAAS,CAAC,IAAI,CAAC,CAAC,CAAC,GAAG,EAAE,CAAA;AACzK,iBAAA;gBACD,OAAO,QAAQ,CAAC,UAAU,CAAC,IAAI,CAAC,IAAI,EAAE,IAAI,CAAC,OAAO,CAAC,YAAY,EAAE,IAAI,CAAC,OAAO,CAAC,SAAS,CAAC,CAAA;aACzF;SACF,CAAA;KACF;IAED,oBAAoB,GAAA;QAClB,OAAO;YACL,aAAa,EAAE,MAAM,IAAI,CAAC,MAAM,CAAC,QAAQ,CAAC,gBAAgB,EAAE;SAC7D,CAAA;KACF;IAED,aAAa,GAAA;QACX,IAAI,SAAS,GAAG,iBAAiB,CAAC;AAChC,YAAA,IAAI,EAAE,UAAU;YAChB,IAAI,EAAE,IAAI,CAAC,IAAI;AAChB,SAAA,CAAC,CAAA;QAEF,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;AAC3C,gBAAA,aAAa,EAAE,MAAQ,EAAA,OAAO,IAAI,CAAC,MAAM,CAAC,aAAa,CAAC,SAAS,CAAC,IAAI,CAAC,CAAA,EAAE;gBACzE,MAAM,EAAE,IAAI,CAAC,MAAM;AACpB,aAAA,CAAC,CAAA;AACH,SAAA;QACD,OAAO;YACL,SAAS;SACV,CAAA;KACF;AACF,CAAA;;;;"}
@@ -0,0 +1,139 @@
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 ListItem = core.Node.create({
8
+ name: 'listItem',
9
+ addOptions() {
10
+ return {
11
+ HTMLAttributes: {},
12
+ };
13
+ },
14
+ content: 'paragraph block*',
15
+ defining: true,
16
+ parseHTML() {
17
+ return [
18
+ {
19
+ tag: 'li',
20
+ },
21
+ ];
22
+ },
23
+ renderHTML({ HTMLAttributes }) {
24
+ return ['li', core.mergeAttributes(this.options.HTMLAttributes, HTMLAttributes), 0];
25
+ },
26
+ addKeyboardShortcuts() {
27
+ return {
28
+ Enter: () => this.editor.commands.splitListItem(this.name),
29
+ Tab: () => this.editor.commands.sinkListItem(this.name),
30
+ 'Shift-Tab': () => this.editor.commands.liftListItem(this.name),
31
+ };
32
+ },
33
+ });
34
+
35
+ const TextStyle = core.Mark.create({
36
+ name: 'textStyle',
37
+ addOptions() {
38
+ return {
39
+ HTMLAttributes: {},
40
+ };
41
+ },
42
+ parseHTML() {
43
+ return [
44
+ {
45
+ tag: 'span',
46
+ getAttrs: element => {
47
+ const hasStyles = element.hasAttribute('style');
48
+ if (!hasStyles) {
49
+ return false;
50
+ }
51
+ return {};
52
+ },
53
+ },
54
+ ];
55
+ },
56
+ renderHTML({ HTMLAttributes }) {
57
+ return ['span', core.mergeAttributes(this.options.HTMLAttributes, HTMLAttributes), 0];
58
+ },
59
+ addCommands() {
60
+ return {
61
+ removeEmptyTextStyle: () => ({ state, commands }) => {
62
+ const attributes = core.getMarkAttributes(state, this.type);
63
+ const hasStyles = Object.entries(attributes).some(([, value]) => !!value);
64
+ if (hasStyles) {
65
+ return true;
66
+ }
67
+ return commands.unsetMark(this.name);
68
+ },
69
+ };
70
+ },
71
+ });
72
+
73
+ const inputRegex = /^\s*([-+*])\s$/;
74
+ const BulletList = core.Node.create({
75
+ name: 'bulletList',
76
+ addOptions() {
77
+ return {
78
+ itemTypeName: 'listItem',
79
+ HTMLAttributes: {},
80
+ keepMarks: false,
81
+ keepAttributes: false,
82
+ };
83
+ },
84
+ group: 'block list',
85
+ content() {
86
+ return `${this.options.itemTypeName}+`;
87
+ },
88
+ parseHTML() {
89
+ return [
90
+ { tag: 'ul' },
91
+ ];
92
+ },
93
+ renderHTML({ HTMLAttributes }) {
94
+ return ['ul', core.mergeAttributes(this.options.HTMLAttributes, HTMLAttributes), 0];
95
+ },
96
+ addCommands() {
97
+ return {
98
+ toggleBulletList: () => ({ commands, chain }) => {
99
+ if (this.options.keepAttributes) {
100
+ return chain().toggleList(this.name, this.options.itemTypeName, this.options.keepMarks).updateAttributes(ListItem.name, this.editor.getAttributes(TextStyle.name)).run();
101
+ }
102
+ return commands.toggleList(this.name, this.options.itemTypeName, this.options.keepMarks);
103
+ },
104
+ };
105
+ },
106
+ addKeyboardShortcuts() {
107
+ return {
108
+ 'Mod-Shift-8': () => this.editor.commands.toggleBulletList(),
109
+ };
110
+ },
111
+ addInputRules() {
112
+ let inputRule = core.wrappingInputRule({
113
+ find: inputRegex,
114
+ type: this.type,
115
+ });
116
+ if (this.options.keepMarks || this.options.keepAttributes) {
117
+ inputRule = core.wrappingInputRule({
118
+ find: inputRegex,
119
+ type: this.type,
120
+ keepMarks: this.options.keepMarks,
121
+ keepAttributes: this.options.keepAttributes,
122
+ getAttributes: () => { return this.editor.getAttributes(TextStyle.name); },
123
+ editor: this.editor,
124
+ });
125
+ }
126
+ return [
127
+ inputRule,
128
+ ];
129
+ },
130
+ });
131
+
132
+ exports.BulletList = BulletList;
133
+ exports["default"] = BulletList;
134
+ exports.inputRegex = inputRegex;
135
+
136
+ Object.defineProperty(exports, '__esModule', { value: true });
137
+
138
+ }));
139
+ //# sourceMappingURL=index.umd.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.umd.js","sources":["../../extension-list-item/src/list-item.ts","../../extension-text-style/src/text-style.ts","../src/bullet-list.ts"],"sourcesContent":["import { mergeAttributes, Node } from '@tiptap/core'\n\nexport interface ListItemOptions {\n HTMLAttributes: Record<string, any>,\n}\n\nexport const ListItem = Node.create<ListItemOptions>({\n name: 'listItem',\n\n addOptions() {\n return {\n HTMLAttributes: {},\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 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 */\n removeEmptyTextStyle: () => ReturnType,\n }\n }\n}\n\nexport const TextStyle = Mark.create<TextStyleOptions>({\n name: 'textStyle',\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'\nimport TextStyle from '../../extension-text-style/src'\n\nexport interface BulletListOptions {\n itemTypeName: string,\n HTMLAttributes: Record<string, any>,\n keepMarks: boolean,\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\nexport const inputRegex = /^\\s*([-+*])\\s$/\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(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-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(TextStyle.name) },\n editor: this.editor,\n })\n }\n return [\n inputRule,\n ]\n },\n})\n"],"names":["Node","mergeAttributes","Mark","getMarkAttributes","wrappingInputRule"],"mappings":";;;;;;EAMO,MAAM,QAAQ,GAAGA,SAAI,CAAC,MAAM,CAAkB;EACnD,IAAA,IAAI,EAAE,UAAU;MAEhB,UAAU,GAAA;UACR,OAAO;EACL,YAAA,cAAc,EAAE,EAAE;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BAAA,aAAa,EAAE,MAAQ,EAAA,OAAO,IAAI,CAAC,MAAM,CAAC,aAAa,CAAC,SAAS,CAAC,IAAI,CAAC,CAAA,EAAE;kBACzE,MAAM,EAAE,IAAI,CAAC,MAAM;EACpB,aAAA,CAAC,CAAA;EACH,SAAA;UACD,OAAO;cACL,SAAS;WACV,CAAA;OACF;EACF,CAAA;;;;;;;;;;;;"}
@@ -1,16 +1,19 @@
1
- import { Command, Node } from '@tiptap/core';
1
+ import { Node } from '@tiptap/core';
2
2
  export interface BulletListOptions {
3
+ itemTypeName: string;
3
4
  HTMLAttributes: Record<string, any>;
5
+ keepMarks: boolean;
6
+ keepAttributes: boolean;
4
7
  }
5
8
  declare module '@tiptap/core' {
6
- interface Commands {
9
+ interface Commands<ReturnType> {
7
10
  bulletList: {
8
11
  /**
9
12
  * Toggle a bullet list
10
13
  */
11
- toggleBulletList: () => Command;
14
+ toggleBulletList: () => ReturnType;
12
15
  };
13
16
  }
14
17
  }
15
18
  export declare const inputRegex: RegExp;
16
- export declare const BulletList: Node<BulletListOptions>;
19
+ export declare const BulletList: Node<BulletListOptions, any>;
@@ -0,0 +1,3 @@
1
+ import { ListItem } from './list-item';
2
+ export * from './list-item';
3
+ export default ListItem;
@@ -0,0 +1,5 @@
1
+ import { Node } from '@tiptap/core';
2
+ export interface ListItemOptions {
3
+ HTMLAttributes: Record<string, any>;
4
+ }
5
+ export declare const ListItem: Node<ListItemOptions, any>;
@@ -0,0 +1,3 @@
1
+ import { TextStyle } from './text-style';
2
+ export * from './text-style';
3
+ export default TextStyle;
@@ -0,0 +1,15 @@
1
+ import { Mark } from '@tiptap/core';
2
+ export interface TextStyleOptions {
3
+ HTMLAttributes: Record<string, any>;
4
+ }
5
+ declare module '@tiptap/core' {
6
+ interface Commands<ReturnType> {
7
+ textStyle: {
8
+ /**
9
+ * Remove spans without inline style attributes.
10
+ */
11
+ removeEmptyTextStyle: () => ReturnType;
12
+ };
13
+ }
14
+ }
15
+ export declare const TextStyle: Mark<TextStyleOptions, any>;
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": "2.0.0-beta.8",
4
+ "version": "2.0.0-rc.1",
5
5
  "homepage": "https://tiptap.dev",
6
6
  "keywords": [
7
7
  "tiptap",
@@ -12,19 +12,35 @@
12
12
  "type": "github",
13
13
  "url": "https://github.com/sponsors/ueberdosis"
14
14
  },
15
- "main": "dist/tiptap-extension-bullet-list.cjs.js",
16
- "umd": "dist/tiptap-extension-bullet-list.umd.js",
17
- "module": "dist/tiptap-extension-bullet-list.esm.js",
15
+ "type": "module",
16
+ "exports": {
17
+ ".": {
18
+ "types": "./dist/packages/extension-bullet-list/src/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
+ "umd": "dist/index.umd.js",
18
26
  "types": "dist/packages/extension-bullet-list/src/index.d.ts",
19
27
  "files": [
20
28
  "src",
21
29
  "dist"
22
30
  ],
23
31
  "peerDependencies": {
24
- "@tiptap/core": "^2.0.0-beta.1"
32
+ "@tiptap/core": "2.0.0-rc.1"
33
+ },
34
+ "devDependencies": {
35
+ "@tiptap/core": "2.0.0-rc.1"
25
36
  },
26
- "dependencies": {
27
- "prosemirror-inputrules": "^1.1.3"
37
+ "repository": {
38
+ "type": "git",
39
+ "url": "https://github.com/ueberdosis/tiptap",
40
+ "directory": "packages/extension-bullet-list"
28
41
  },
29
- "gitHead": "9718002875433e78917976ad7daf0915ecb43c6f"
30
- }
42
+ "scripts": {
43
+ "clean": "rm -rf dist",
44
+ "build": "npm run clean && rollup -c"
45
+ }
46
+ }
@@ -1,17 +1,22 @@
1
- import { Command, Node, mergeAttributes } from '@tiptap/core'
2
- import { wrappingInputRule } from 'prosemirror-inputrules'
1
+ import { mergeAttributes, Node, wrappingInputRule } from '@tiptap/core'
2
+
3
+ import ListItem from '../../extension-list-item/src'
4
+ import TextStyle from '../../extension-text-style/src'
3
5
 
4
6
  export interface BulletListOptions {
7
+ itemTypeName: string,
5
8
  HTMLAttributes: Record<string, any>,
9
+ keepMarks: boolean,
10
+ keepAttributes: boolean,
6
11
  }
7
12
 
8
13
  declare module '@tiptap/core' {
9
- interface Commands {
14
+ interface Commands<ReturnType> {
10
15
  bulletList: {
11
16
  /**
12
17
  * Toggle a bullet list
13
18
  */
14
- toggleBulletList: () => Command,
19
+ toggleBulletList: () => ReturnType,
15
20
  }
16
21
  }
17
22
  }
@@ -21,13 +26,20 @@ export const inputRegex = /^\s*([-+*])\s$/
21
26
  export const BulletList = Node.create<BulletListOptions>({
22
27
  name: 'bulletList',
23
28
 
24
- defaultOptions: {
25
- HTMLAttributes: {},
29
+ addOptions() {
30
+ return {
31
+ itemTypeName: 'listItem',
32
+ HTMLAttributes: {},
33
+ keepMarks: false,
34
+ keepAttributes: false,
35
+ }
26
36
  },
27
37
 
28
38
  group: 'block list',
29
39
 
30
- content: 'listItem+',
40
+ content() {
41
+ return `${this.options.itemTypeName}+`
42
+ },
31
43
 
32
44
  parseHTML() {
33
45
  return [
@@ -41,8 +53,11 @@ export const BulletList = Node.create<BulletListOptions>({
41
53
 
42
54
  addCommands() {
43
55
  return {
44
- toggleBulletList: () => ({ commands }) => {
45
- return commands.toggleList('bulletList', 'listItem')
56
+ toggleBulletList: () => ({ commands, chain }) => {
57
+ if (this.options.keepAttributes) {
58
+ return chain().toggleList(this.name, this.options.itemTypeName, this.options.keepMarks).updateAttributes(ListItem.name, this.editor.getAttributes(TextStyle.name)).run()
59
+ }
60
+ return commands.toggleList(this.name, this.options.itemTypeName, this.options.keepMarks)
46
61
  },
47
62
  }
48
63
  },
@@ -54,8 +69,23 @@ export const BulletList = Node.create<BulletListOptions>({
54
69
  },
55
70
 
56
71
  addInputRules() {
72
+ let inputRule = wrappingInputRule({
73
+ find: inputRegex,
74
+ type: this.type,
75
+ })
76
+
77
+ if (this.options.keepMarks || this.options.keepAttributes) {
78
+ inputRule = wrappingInputRule({
79
+ find: inputRegex,
80
+ type: this.type,
81
+ keepMarks: this.options.keepMarks,
82
+ keepAttributes: this.options.keepAttributes,
83
+ getAttributes: () => { return this.editor.getAttributes(TextStyle.name) },
84
+ editor: this.editor,
85
+ })
86
+ }
57
87
  return [
58
- wrappingInputRule(inputRegex, this.type),
88
+ inputRule,
59
89
  ]
60
90
  },
61
91
  })
package/CHANGELOG.md DELETED
@@ -1,171 +0,0 @@
1
- # Change Log
2
-
3
- All notable changes to this project will be documented in this file.
4
- See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
5
-
6
- # [2.0.0-beta.8](https://github.com/ueberdosis/tiptap/compare/@tiptap/extension-bullet-list@2.0.0-beta.7...@tiptap/extension-bullet-list@2.0.0-beta.8) (2021-05-06)
7
-
8
- **Note:** Version bump only for package @tiptap/extension-bullet-list
9
-
10
-
11
-
12
-
13
-
14
- # [2.0.0-beta.7](https://github.com/ueberdosis/tiptap/compare/@tiptap/extension-bullet-list@2.0.0-beta.6...@tiptap/extension-bullet-list@2.0.0-beta.7) (2021-05-05)
15
-
16
- **Note:** Version bump only for package @tiptap/extension-bullet-list
17
-
18
-
19
-
20
-
21
-
22
- # [2.0.0-beta.6](https://github.com/ueberdosis/tiptap/compare/@tiptap/extension-bullet-list@2.0.0-beta.5...@tiptap/extension-bullet-list@2.0.0-beta.6) (2021-04-23)
23
-
24
- **Note:** Version bump only for package @tiptap/extension-bullet-list
25
-
26
-
27
-
28
-
29
-
30
- # [2.0.0-beta.5](https://github.com/ueberdosis/tiptap/compare/@tiptap/extension-bullet-list@2.0.0-beta.4...@tiptap/extension-bullet-list@2.0.0-beta.5) (2021-04-22)
31
-
32
- **Note:** Version bump only for package @tiptap/extension-bullet-list
33
-
34
-
35
-
36
-
37
-
38
- # [2.0.0-beta.4](https://github.com/ueberdosis/tiptap/compare/@tiptap/extension-bullet-list@2.0.0-beta.3...@tiptap/extension-bullet-list@2.0.0-beta.4) (2021-04-21)
39
-
40
- **Note:** Version bump only for package @tiptap/extension-bullet-list
41
-
42
-
43
-
44
-
45
-
46
- # [2.0.0-beta.3](https://github.com/ueberdosis/tiptap/compare/@tiptap/extension-bullet-list@2.0.0-beta.2...@tiptap/extension-bullet-list@2.0.0-beta.3) (2021-04-16)
47
-
48
- **Note:** Version bump only for package @tiptap/extension-bullet-list
49
-
50
-
51
-
52
-
53
-
54
- # [2.0.0-beta.2](https://github.com/ueberdosis/tiptap/compare/@tiptap/extension-bullet-list@2.0.0-beta.1...@tiptap/extension-bullet-list@2.0.0-beta.2) (2021-04-15)
55
-
56
- **Note:** Version bump only for package @tiptap/extension-bullet-list
57
-
58
-
59
-
60
-
61
-
62
- # [2.0.0-beta.1](https://github.com/ueberdosis/tiptap/compare/@tiptap/extension-bullet-list@2.0.0-alpha.11...@tiptap/extension-bullet-list@2.0.0-beta.1) (2021-03-05)
63
-
64
- **Note:** Version bump only for package @tiptap/extension-bullet-list
65
-
66
-
67
-
68
-
69
-
70
- # [2.0.0-alpha.11](https://github.com/ueberdosis/tiptap/compare/@tiptap/extension-bullet-list@2.0.0-alpha.10...@tiptap/extension-bullet-list@2.0.0-alpha.11) (2021-02-16)
71
-
72
- **Note:** Version bump only for package @tiptap/extension-bullet-list
73
-
74
-
75
-
76
-
77
-
78
- # [2.0.0-alpha.10](https://github.com/ueberdosis/tiptap/compare/@tiptap/extension-bullet-list@2.0.0-alpha.9...@tiptap/extension-bullet-list@2.0.0-alpha.10) (2021-02-07)
79
-
80
- **Note:** Version bump only for package @tiptap/extension-bullet-list
81
-
82
-
83
-
84
-
85
-
86
- # [2.0.0-alpha.9](https://github.com/ueberdosis/tiptap/compare/@tiptap/extension-bullet-list@2.0.0-alpha.8...@tiptap/extension-bullet-list@2.0.0-alpha.9) (2021-02-05)
87
-
88
- **Note:** Version bump only for package @tiptap/extension-bullet-list
89
-
90
-
91
-
92
-
93
-
94
- # [2.0.0-alpha.8](https://github.com/ueberdosis/tiptap/compare/@tiptap/extension-bullet-list@2.0.0-alpha.7...@tiptap/extension-bullet-list@2.0.0-alpha.8) (2021-01-29)
95
-
96
- **Note:** Version bump only for package @tiptap/extension-bullet-list
97
-
98
-
99
-
100
-
101
-
102
- # [2.0.0-alpha.7](https://github.com/ueberdosis/tiptap/compare/@tiptap/extension-bullet-list@2.0.0-alpha.6...@tiptap/extension-bullet-list@2.0.0-alpha.7) (2021-01-29)
103
-
104
- **Note:** Version bump only for package @tiptap/extension-bullet-list
105
-
106
-
107
-
108
-
109
-
110
- # [2.0.0-alpha.6](https://github.com/ueberdosis/tiptap/compare/@tiptap/extension-bullet-list@2.0.0-alpha.5...@tiptap/extension-bullet-list@2.0.0-alpha.6) (2021-01-28)
111
-
112
- **Note:** Version bump only for package @tiptap/extension-bullet-list
113
-
114
-
115
-
116
-
117
-
118
- # [2.0.0-alpha.5](https://github.com/ueberdosis/tiptap/compare/@tiptap/extension-bullet-list@2.0.0-alpha.4...@tiptap/extension-bullet-list@2.0.0-alpha.5) (2020-12-18)
119
-
120
- **Note:** Version bump only for package @tiptap/extension-bullet-list
121
-
122
-
123
-
124
-
125
-
126
- # [2.0.0-alpha.4](https://github.com/ueberdosis/tiptap/compare/@tiptap/extension-bullet-list@2.0.0-alpha.3...@tiptap/extension-bullet-list@2.0.0-alpha.4) (2020-12-02)
127
-
128
- **Note:** Version bump only for package @tiptap/extension-bullet-list
129
-
130
-
131
-
132
-
133
-
134
- # [2.0.0-alpha.3](https://github.com/ueberdosis/tiptap/compare/@tiptap/extension-bullet-list@2.0.0-alpha.2...@tiptap/extension-bullet-list@2.0.0-alpha.3) (2020-11-19)
135
-
136
- **Note:** Version bump only for package @tiptap/extension-bullet-list
137
-
138
-
139
-
140
-
141
-
142
- # [2.0.0-alpha.2](https://github.com/ueberdosis/tiptap/compare/@tiptap/extension-bullet-list@2.0.0-alpha.1...@tiptap/extension-bullet-list@2.0.0-alpha.2) (2020-11-19)
143
-
144
- **Note:** Version bump only for package @tiptap/extension-bullet-list
145
-
146
-
147
-
148
-
149
-
150
- # [2.0.0-alpha.1](https://github.com/ueberdosis/tiptap/compare/@tiptap/extension-bullet-list@1.0.0-alpha.2...@tiptap/extension-bullet-list@2.0.0-alpha.1) (2020-11-18)
151
-
152
- **Note:** Version bump only for package @tiptap/extension-bullet-list
153
-
154
-
155
-
156
-
157
-
158
- # [1.0.0-alpha.2](https://github.com/ueberdosis/tiptap/compare/@tiptap/extension-bullet-list@1.0.0-alpha.1...@tiptap/extension-bullet-list@1.0.0-alpha.2) (2020-11-16)
159
-
160
- **Note:** Version bump only for package @tiptap/extension-bullet-list
161
-
162
-
163
-
164
-
165
-
166
- # 1.0.0-alpha.1 (2020-11-16)
167
-
168
-
169
- ### Reverts
170
-
171
- * Revert "use global namespace" ([0c9ce26](https://github.com/ueberdosis/tiptap/commit/0c9ce26c02c07d88a757c01b0a9d7f9e2b0b7502))
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,46 +0,0 @@
1
- 'use strict';
2
-
3
- Object.defineProperty(exports, '__esModule', { value: true });
4
-
5
- var core = require('@tiptap/core');
6
- var prosemirrorInputrules = require('prosemirror-inputrules');
7
-
8
- const inputRegex = /^\s*([-+*])\s$/;
9
- const BulletList = core.Node.create({
10
- name: 'bulletList',
11
- defaultOptions: {
12
- HTMLAttributes: {},
13
- },
14
- group: 'block list',
15
- content: 'listItem+',
16
- parseHTML() {
17
- return [
18
- { tag: 'ul' },
19
- ];
20
- },
21
- renderHTML({ HTMLAttributes }) {
22
- return ['ul', core.mergeAttributes(this.options.HTMLAttributes, HTMLAttributes), 0];
23
- },
24
- addCommands() {
25
- return {
26
- toggleBulletList: () => ({ commands }) => {
27
- return commands.toggleList('bulletList', 'listItem');
28
- },
29
- };
30
- },
31
- addKeyboardShortcuts() {
32
- return {
33
- 'Mod-Shift-8': () => this.editor.commands.toggleBulletList(),
34
- };
35
- },
36
- addInputRules() {
37
- return [
38
- prosemirrorInputrules.wrappingInputRule(inputRegex, this.type),
39
- ];
40
- },
41
- });
42
-
43
- exports.BulletList = BulletList;
44
- exports.default = BulletList;
45
- exports.inputRegex = inputRegex;
46
- //# sourceMappingURL=tiptap-extension-bullet-list.cjs.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"tiptap-extension-bullet-list.cjs.js","sources":["../src/bullet-list.ts"],"sourcesContent":["import { Command, Node, mergeAttributes } from '@tiptap/core'\nimport { wrappingInputRule } from 'prosemirror-inputrules'\n\nexport interface BulletListOptions {\n HTMLAttributes: Record<string, any>,\n}\n\ndeclare module '@tiptap/core' {\n interface Commands {\n bulletList: {\n /**\n * Toggle a bullet list\n */\n toggleBulletList: () => Command,\n }\n }\n}\n\nexport const inputRegex = /^\\s*([-+*])\\s$/\n\nexport const BulletList = Node.create<BulletListOptions>({\n name: 'bulletList',\n\n defaultOptions: {\n HTMLAttributes: {},\n },\n\n group: 'block list',\n\n content: 'listItem+',\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 }) => {\n return commands.toggleList('bulletList', 'listItem')\n },\n }\n },\n\n addKeyboardShortcuts() {\n return {\n 'Mod-Shift-8': () => this.editor.commands.toggleBulletList(),\n }\n },\n\n addInputRules() {\n return [\n wrappingInputRule(inputRegex, this.type),\n ]\n },\n})\n"],"names":["Node","mergeAttributes","wrappingInputRule"],"mappings":";;;;;;;MAkBa,UAAU,GAAG,iBAAgB;MAE7B,UAAU,GAAGA,SAAI,CAAC,MAAM,CAAoB;IACvD,IAAI,EAAE,YAAY;IAElB,cAAc,EAAE;QACd,cAAc,EAAE,EAAE;KACnB;IAED,KAAK,EAAE,YAAY;IAEnB,OAAO,EAAE,WAAW;IAEpB,SAAS;QACP,OAAO;YACL,EAAE,GAAG,EAAE,IAAI,EAAE;SACd,CAAA;KACF;IAED,UAAU,CAAC,EAAE,cAAc,EAAE;QAC3B,OAAO,CAAC,IAAI,EAAEC,oBAAe,CAAC,IAAI,CAAC,OAAO,CAAC,cAAc,EAAE,cAAc,CAAC,EAAE,CAAC,CAAC,CAAA;KAC/E;IAED,WAAW;QACT,OAAO;YACL,gBAAgB,EAAE,MAAM,CAAC,EAAE,QAAQ,EAAE;gBACnC,OAAO,QAAQ,CAAC,UAAU,CAAC,YAAY,EAAE,UAAU,CAAC,CAAA;aACrD;SACF,CAAA;KACF;IAED,oBAAoB;QAClB,OAAO;YACL,aAAa,EAAE,MAAM,IAAI,CAAC,MAAM,CAAC,QAAQ,CAAC,gBAAgB,EAAE;SAC7D,CAAA;KACF;IAED,aAAa;QACX,OAAO;YACLC,uCAAiB,CAAC,UAAU,EAAE,IAAI,CAAC,IAAI,CAAC;SACzC,CAAA;KACF;CACF;;;;;;"}
@@ -1,41 +0,0 @@
1
- import { Node, mergeAttributes } from '@tiptap/core';
2
- import { wrappingInputRule } from 'prosemirror-inputrules';
3
-
4
- const inputRegex = /^\s*([-+*])\s$/;
5
- const BulletList = Node.create({
6
- name: 'bulletList',
7
- defaultOptions: {
8
- HTMLAttributes: {},
9
- },
10
- group: 'block list',
11
- content: 'listItem+',
12
- parseHTML() {
13
- return [
14
- { tag: 'ul' },
15
- ];
16
- },
17
- renderHTML({ HTMLAttributes }) {
18
- return ['ul', mergeAttributes(this.options.HTMLAttributes, HTMLAttributes), 0];
19
- },
20
- addCommands() {
21
- return {
22
- toggleBulletList: () => ({ commands }) => {
23
- return commands.toggleList('bulletList', 'listItem');
24
- },
25
- };
26
- },
27
- addKeyboardShortcuts() {
28
- return {
29
- 'Mod-Shift-8': () => this.editor.commands.toggleBulletList(),
30
- };
31
- },
32
- addInputRules() {
33
- return [
34
- wrappingInputRule(inputRegex, this.type),
35
- ];
36
- },
37
- });
38
-
39
- export default BulletList;
40
- export { BulletList, inputRegex };
41
- //# sourceMappingURL=tiptap-extension-bullet-list.esm.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"tiptap-extension-bullet-list.esm.js","sources":["../src/bullet-list.ts"],"sourcesContent":["import { Command, Node, mergeAttributes } from '@tiptap/core'\nimport { wrappingInputRule } from 'prosemirror-inputrules'\n\nexport interface BulletListOptions {\n HTMLAttributes: Record<string, any>,\n}\n\ndeclare module '@tiptap/core' {\n interface Commands {\n bulletList: {\n /**\n * Toggle a bullet list\n */\n toggleBulletList: () => Command,\n }\n }\n}\n\nexport const inputRegex = /^\\s*([-+*])\\s$/\n\nexport const BulletList = Node.create<BulletListOptions>({\n name: 'bulletList',\n\n defaultOptions: {\n HTMLAttributes: {},\n },\n\n group: 'block list',\n\n content: 'listItem+',\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 }) => {\n return commands.toggleList('bulletList', 'listItem')\n },\n }\n },\n\n addKeyboardShortcuts() {\n return {\n 'Mod-Shift-8': () => this.editor.commands.toggleBulletList(),\n }\n },\n\n addInputRules() {\n return [\n wrappingInputRule(inputRegex, this.type),\n ]\n },\n})\n"],"names":[],"mappings":";;;MAkBa,UAAU,GAAG,iBAAgB;MAE7B,UAAU,GAAG,IAAI,CAAC,MAAM,CAAoB;IACvD,IAAI,EAAE,YAAY;IAElB,cAAc,EAAE;QACd,cAAc,EAAE,EAAE;KACnB;IAED,KAAK,EAAE,YAAY;IAEnB,OAAO,EAAE,WAAW;IAEpB,SAAS;QACP,OAAO;YACL,EAAE,GAAG,EAAE,IAAI,EAAE;SACd,CAAA;KACF;IAED,UAAU,CAAC,EAAE,cAAc,EAAE;QAC3B,OAAO,CAAC,IAAI,EAAE,eAAe,CAAC,IAAI,CAAC,OAAO,CAAC,cAAc,EAAE,cAAc,CAAC,EAAE,CAAC,CAAC,CAAA;KAC/E;IAED,WAAW;QACT,OAAO;YACL,gBAAgB,EAAE,MAAM,CAAC,EAAE,QAAQ,EAAE;gBACnC,OAAO,QAAQ,CAAC,UAAU,CAAC,YAAY,EAAE,UAAU,CAAC,CAAA;aACrD;SACF,CAAA;KACF;IAED,oBAAoB;QAClB,OAAO;YACL,aAAa,EAAE,MAAM,IAAI,CAAC,MAAM,CAAC,QAAQ,CAAC,gBAAgB,EAAE;SAC7D,CAAA;KACF;IAED,aAAa;QACX,OAAO;YACL,iBAAiB,CAAC,UAAU,EAAE,IAAI,CAAC,IAAI,CAAC;SACzC,CAAA;KACF;CACF;;;;;"}
@@ -1,49 +0,0 @@
1
- (function (global, factory) {
2
- typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports, require('@tiptap/core'), require('prosemirror-inputrules')) :
3
- typeof define === 'function' && define.amd ? define(['exports', '@tiptap/core', 'prosemirror-inputrules'], factory) :
4
- (global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory(global['@tiptap/extension-bullet-list'] = {}, global.core, global.prosemirrorInputrules));
5
- }(this, (function (exports, core, prosemirrorInputrules) { 'use strict';
6
-
7
- const inputRegex = /^\s*([-+*])\s$/;
8
- const BulletList = core.Node.create({
9
- name: 'bulletList',
10
- defaultOptions: {
11
- HTMLAttributes: {},
12
- },
13
- group: 'block list',
14
- content: 'listItem+',
15
- parseHTML() {
16
- return [
17
- { tag: 'ul' },
18
- ];
19
- },
20
- renderHTML({ HTMLAttributes }) {
21
- return ['ul', core.mergeAttributes(this.options.HTMLAttributes, HTMLAttributes), 0];
22
- },
23
- addCommands() {
24
- return {
25
- toggleBulletList: () => ({ commands }) => {
26
- return commands.toggleList('bulletList', 'listItem');
27
- },
28
- };
29
- },
30
- addKeyboardShortcuts() {
31
- return {
32
- 'Mod-Shift-8': () => this.editor.commands.toggleBulletList(),
33
- };
34
- },
35
- addInputRules() {
36
- return [
37
- prosemirrorInputrules.wrappingInputRule(inputRegex, this.type),
38
- ];
39
- },
40
- });
41
-
42
- exports.BulletList = BulletList;
43
- exports.default = BulletList;
44
- exports.inputRegex = inputRegex;
45
-
46
- Object.defineProperty(exports, '__esModule', { value: true });
47
-
48
- })));
49
- //# sourceMappingURL=tiptap-extension-bullet-list.umd.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"tiptap-extension-bullet-list.umd.js","sources":["../src/bullet-list.ts"],"sourcesContent":["import { Command, Node, mergeAttributes } from '@tiptap/core'\nimport { wrappingInputRule } from 'prosemirror-inputrules'\n\nexport interface BulletListOptions {\n HTMLAttributes: Record<string, any>,\n}\n\ndeclare module '@tiptap/core' {\n interface Commands {\n bulletList: {\n /**\n * Toggle a bullet list\n */\n toggleBulletList: () => Command,\n }\n }\n}\n\nexport const inputRegex = /^\\s*([-+*])\\s$/\n\nexport const BulletList = Node.create<BulletListOptions>({\n name: 'bulletList',\n\n defaultOptions: {\n HTMLAttributes: {},\n },\n\n group: 'block list',\n\n content: 'listItem+',\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 }) => {\n return commands.toggleList('bulletList', 'listItem')\n },\n }\n },\n\n addKeyboardShortcuts() {\n return {\n 'Mod-Shift-8': () => this.editor.commands.toggleBulletList(),\n }\n },\n\n addInputRules() {\n return [\n wrappingInputRule(inputRegex, this.type),\n ]\n },\n})\n"],"names":["Node","mergeAttributes","wrappingInputRule"],"mappings":";;;;;;QAkBa,UAAU,GAAG,iBAAgB;QAE7B,UAAU,GAAGA,SAAI,CAAC,MAAM,CAAoB;MACvD,IAAI,EAAE,YAAY;MAElB,cAAc,EAAE;UACd,cAAc,EAAE,EAAE;OACnB;MAED,KAAK,EAAE,YAAY;MAEnB,OAAO,EAAE,WAAW;MAEpB,SAAS;UACP,OAAO;cACL,EAAE,GAAG,EAAE,IAAI,EAAE;WACd,CAAA;OACF;MAED,UAAU,CAAC,EAAE,cAAc,EAAE;UAC3B,OAAO,CAAC,IAAI,EAAEC,oBAAe,CAAC,IAAI,CAAC,OAAO,CAAC,cAAc,EAAE,cAAc,CAAC,EAAE,CAAC,CAAC,CAAA;OAC/E;MAED,WAAW;UACT,OAAO;cACL,gBAAgB,EAAE,MAAM,CAAC,EAAE,QAAQ,EAAE;kBACnC,OAAO,QAAQ,CAAC,UAAU,CAAC,YAAY,EAAE,UAAU,CAAC,CAAA;eACrD;WACF,CAAA;OACF;MAED,oBAAoB;UAClB,OAAO;cACL,aAAa,EAAE,MAAM,IAAI,CAAC,MAAM,CAAC,QAAQ,CAAC,gBAAgB,EAAE;WAC7D,CAAA;OACF;MAED,aAAa;UACX,OAAO;cACLC,uCAAiB,CAAC,UAAU,EAAE,IAAI,CAAC,IAAI,CAAC;WACzC,CAAA;OACF;GACF;;;;;;;;;;;;"}