add basic bullet list
This commit is contained in:
32
packages/extension-bullet-list/index.ts
Normal file
32
packages/extension-bullet-list/index.ts
Normal file
@@ -0,0 +1,32 @@
|
||||
import { Node } from '@tiptap/core'
|
||||
import { wrappingInputRule } from 'prosemirror-inputrules'
|
||||
|
||||
declare module '@tiptap/core/src/Editor' {
|
||||
interface Editor {
|
||||
bulletList(): Editor,
|
||||
}
|
||||
}
|
||||
|
||||
export default new Node()
|
||||
.name('bullet_list')
|
||||
.schema(() => ({
|
||||
content: 'list_item+',
|
||||
group: 'block',
|
||||
parseDOM: [
|
||||
{ tag: 'ul' },
|
||||
],
|
||||
toDOM: () => ['ul', 0],
|
||||
}))
|
||||
.commands(({ editor, type }) => ({
|
||||
[name]: next => attrs => {
|
||||
// editor.toggleList(type, editor.schema.nodes.list_item)
|
||||
next()
|
||||
},
|
||||
}))
|
||||
.keys(({ editor }) => ({
|
||||
'Shift-Ctrl-8': () => editor.bulletList(),
|
||||
}))
|
||||
.inputRules(({ type }) => [
|
||||
wrappingInputRule(/^\s*([-+*])\s$/, type),
|
||||
])
|
||||
.create()
|
||||
17
packages/extension-bullet-list/package.json
Normal file
17
packages/extension-bullet-list/package.json
Normal file
@@ -0,0 +1,17 @@
|
||||
{
|
||||
"name": "@tiptap/extension-bullet-list",
|
||||
"version": "1.0.0",
|
||||
"source": "index.ts",
|
||||
"main": "dist/tiptap-extension-bullet-list.js",
|
||||
"umd:main": "dist/tiptap-extension-bullet-list.umd.js",
|
||||
"module": "dist/tiptap-extension-bullet-list.mjs",
|
||||
"unpkg": "dist/tiptap-extension-bullet-list.js",
|
||||
"jsdelivr": "dist/tiptap-extension-bullet-list.js",
|
||||
"files": [
|
||||
"src",
|
||||
"dist"
|
||||
],
|
||||
"peerDependencies": {
|
||||
"@tiptap/core": "2.x"
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user