mirror of
https://github.com/ueberdosis/tiptap.git
synced 2025-01-18 06:03:22 +08:00
feat: add itemTypeName option
This commit is contained in:
parent
d64fb22e7c
commit
3d7c8e642f
@ -31,6 +31,17 @@ BulletList.configure({
|
||||
})
|
||||
```
|
||||
|
||||
### itemTypeName
|
||||
Specify the list item name.
|
||||
|
||||
Default: `'listItem'`
|
||||
|
||||
```js
|
||||
BulletList.configure({
|
||||
itemTypeName: 'listItem',
|
||||
})
|
||||
```
|
||||
|
||||
## Commands
|
||||
|
||||
### toggleBulletList()
|
||||
|
@ -31,6 +31,17 @@ OrderedList.configure({
|
||||
})
|
||||
```
|
||||
|
||||
### itemTypeName
|
||||
Specify the list item name.
|
||||
|
||||
Default: `'listItem'`
|
||||
|
||||
```js
|
||||
OrderedList.configure({
|
||||
itemTypeName: 'listItem',
|
||||
})
|
||||
```
|
||||
|
||||
## Commands
|
||||
|
||||
### toggleOrderedList()
|
||||
|
@ -31,6 +31,17 @@ TaskList.configure({
|
||||
})
|
||||
```
|
||||
|
||||
### itemTypeName
|
||||
Specify the list item name.
|
||||
|
||||
Default: `'taskItem'`
|
||||
|
||||
```js
|
||||
TaskList.configure({
|
||||
itemTypeName: 'taskItem',
|
||||
})
|
||||
```
|
||||
|
||||
## Commands
|
||||
|
||||
# toggleTaskList()
|
||||
|
@ -1,6 +1,7 @@
|
||||
import { Node, mergeAttributes, wrappingInputRule } from '@tiptap/core'
|
||||
|
||||
export interface BulletListOptions {
|
||||
itemTypeName: string,
|
||||
HTMLAttributes: Record<string, any>,
|
||||
}
|
||||
|
||||
@ -22,13 +23,16 @@ export const BulletList = Node.create<BulletListOptions>({
|
||||
|
||||
addOptions() {
|
||||
return {
|
||||
itemTypeName: 'listItem',
|
||||
HTMLAttributes: {},
|
||||
}
|
||||
},
|
||||
|
||||
group: 'block list',
|
||||
|
||||
content: 'listItem+',
|
||||
content() {
|
||||
return `${this.options.itemTypeName}+`
|
||||
},
|
||||
|
||||
parseHTML() {
|
||||
return [
|
||||
@ -43,7 +47,7 @@ export const BulletList = Node.create<BulletListOptions>({
|
||||
addCommands() {
|
||||
return {
|
||||
toggleBulletList: () => ({ commands }) => {
|
||||
return commands.toggleList(this.name, 'listItem')
|
||||
return commands.toggleList(this.name, this.options.itemTypeName)
|
||||
},
|
||||
}
|
||||
},
|
||||
|
@ -1,6 +1,7 @@
|
||||
import { Node, mergeAttributes, wrappingInputRule } from '@tiptap/core'
|
||||
|
||||
export interface OrderedListOptions {
|
||||
itemTypeName: string,
|
||||
HTMLAttributes: Record<string, any>,
|
||||
}
|
||||
|
||||
@ -22,13 +23,16 @@ export const OrderedList = Node.create<OrderedListOptions>({
|
||||
|
||||
addOptions() {
|
||||
return {
|
||||
itemTypeName: 'listItem',
|
||||
HTMLAttributes: {},
|
||||
}
|
||||
},
|
||||
|
||||
group: 'block list',
|
||||
|
||||
content: 'listItem+',
|
||||
content() {
|
||||
return `${this.options.itemTypeName}+`
|
||||
},
|
||||
|
||||
addAttributes() {
|
||||
return {
|
||||
@ -62,7 +66,7 @@ export const OrderedList = Node.create<OrderedListOptions>({
|
||||
addCommands() {
|
||||
return {
|
||||
toggleOrderedList: () => ({ commands }) => {
|
||||
return commands.toggleList(this.name, 'listItem')
|
||||
return commands.toggleList(this.name, this.options.itemTypeName)
|
||||
},
|
||||
}
|
||||
},
|
||||
|
@ -1,6 +1,7 @@
|
||||
import { Node, mergeAttributes } from '@tiptap/core'
|
||||
|
||||
export interface TaskListOptions {
|
||||
itemTypeName: string,
|
||||
HTMLAttributes: Record<string, any>,
|
||||
}
|
||||
|
||||
@ -20,13 +21,16 @@ export const TaskList = Node.create<TaskListOptions>({
|
||||
|
||||
addOptions() {
|
||||
return {
|
||||
itemTypeName: 'taskItem',
|
||||
HTMLAttributes: {},
|
||||
}
|
||||
},
|
||||
|
||||
group: 'block list',
|
||||
|
||||
content: 'taskItem+',
|
||||
content() {
|
||||
return `${this.options.itemTypeName}+`
|
||||
},
|
||||
|
||||
parseHTML() {
|
||||
return [
|
||||
@ -44,7 +48,7 @@ export const TaskList = Node.create<TaskListOptions>({
|
||||
addCommands() {
|
||||
return {
|
||||
toggleTaskList: () => ({ commands }) => {
|
||||
return commands.toggleList(this.name, 'taskItem')
|
||||
return commands.toggleList(this.name, this.options.itemTypeName)
|
||||
},
|
||||
}
|
||||
},
|
||||
|
Loading…
Reference in New Issue
Block a user