refactoring
This commit is contained in:
@@ -1,6 +1,8 @@
|
|||||||
import { Command, createNode } from '@tiptap/core'
|
import { Command, createNode } from '@tiptap/core'
|
||||||
import { wrappingInputRule } from 'prosemirror-inputrules'
|
import { wrappingInputRule } from 'prosemirror-inputrules'
|
||||||
|
|
||||||
|
export const inputRegex = /^\s*([-+*])\s$/
|
||||||
|
|
||||||
const BulletList = createNode({
|
const BulletList = createNode({
|
||||||
name: 'bullet_list',
|
name: 'bullet_list',
|
||||||
|
|
||||||
@@ -36,7 +38,7 @@ const BulletList = createNode({
|
|||||||
|
|
||||||
addInputRules() {
|
addInputRules() {
|
||||||
return [
|
return [
|
||||||
wrappingInputRule(/^\s*([-+*])\s$/, this.type),
|
wrappingInputRule(inputRegex, this.type),
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
})
|
})
|
||||||
|
|||||||
@@ -1,6 +1,8 @@
|
|||||||
import { Command, createNode } from '@tiptap/core'
|
import { Command, createNode } from '@tiptap/core'
|
||||||
import { wrappingInputRule } from 'prosemirror-inputrules'
|
import { wrappingInputRule } from 'prosemirror-inputrules'
|
||||||
|
|
||||||
|
export const inputRegex = /^(\d+)\.\s$/
|
||||||
|
|
||||||
const OrderedList = createNode({
|
const OrderedList = createNode({
|
||||||
name: 'ordered_list',
|
name: 'ordered_list',
|
||||||
|
|
||||||
@@ -56,7 +58,7 @@ const OrderedList = createNode({
|
|||||||
addInputRules() {
|
addInputRules() {
|
||||||
return [
|
return [
|
||||||
wrappingInputRule(
|
wrappingInputRule(
|
||||||
/^(\d+)\.\s$/,
|
inputRegex,
|
||||||
this.type,
|
this.type,
|
||||||
match => ({ order: +match[1] }),
|
match => ({ order: +match[1] }),
|
||||||
(match, node) => node.childCount + node.attrs.order === +match[1],
|
(match, node) => node.childCount + node.attrs.order === +match[1],
|
||||||
|
|||||||
@@ -1,6 +1,9 @@
|
|||||||
import { Command, createNode, mergeAttributes } from '@tiptap/core'
|
import { Command, createNode, mergeAttributes } from '@tiptap/core'
|
||||||
import { wrappingInputRule } from 'prosemirror-inputrules'
|
import { wrappingInputRule } from 'prosemirror-inputrules'
|
||||||
|
|
||||||
|
// TODO: add suport for [ ] and [x]
|
||||||
|
export const inputRegex = /^\s*(\[ \])\s$/
|
||||||
|
|
||||||
const TaskList = createNode({
|
const TaskList = createNode({
|
||||||
name: 'task_list',
|
name: 'task_list',
|
||||||
|
|
||||||
@@ -33,7 +36,7 @@ const TaskList = createNode({
|
|||||||
|
|
||||||
addInputRules() {
|
addInputRules() {
|
||||||
return [
|
return [
|
||||||
wrappingInputRule(/^\s*(\[ \])\s$/, this.type),
|
wrappingInputRule(inputRegex, this.type),
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
})
|
})
|
||||||
|
|||||||
Reference in New Issue
Block a user