EZQMS-470: Add server side tiptap extension for node uuid (#4358)

Signed-off-by: Anna No <anna.no@xored.com>
This commit is contained in:
Anna No 2024-01-16 20:04:52 +07:00 committed by GitHub
parent 31b0d98d90
commit 9def3b2213
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 27 additions and 2 deletions

View File

@ -14,6 +14,7 @@
//
import { Extension } from '@tiptap/core'
import { Level } from '@tiptap/extension-heading'
import Table from '@tiptap/extension-table'
import TableCell from '@tiptap/extension-table-cell'
import TableHeader from '@tiptap/extension-table-header'
@ -21,12 +22,12 @@ import TableRow from '@tiptap/extension-table-row'
import TaskItem from '@tiptap/extension-task-item'
import TaskList from '@tiptap/extension-task-list'
import { NodeUuid } from '../marks/nodeUuid'
import { ImageNode, ImageOptions } from '../nodes/image'
import { ReferenceNode } from '../nodes/reference'
import { TodoItemNode, TodoListNode } from '../nodes/todo'
import { DefaultKit, DefaultKitOptions } from './default-kit'
import { Level } from '@tiptap/extension-heading'
const headingLevels: Level[] = [1, 2, 3, 4, 5, 6]
@ -72,7 +73,8 @@ export const ServerKit = Extension.create<ServerKitOptions>({
ImageNode.configure(this.options.image),
TodoItemNode,
TodoListNode,
ReferenceNode
ReferenceNode,
NodeUuid
]
}
})

View File

@ -0,0 +1,23 @@
import { Mark } from '@tiptap/core'
const NAME = 'node-uuid'
/**
* @public
*/
export const NodeUuid = Mark.create({
name: NAME,
inline: true,
parseHTML () {
return [
{
tag: `span[${NAME}]`
}
]
},
renderHTML ({ HTMLAttributes }) {
return ['span', HTMLAttributes, 0]
}
})