Skip to content

Commit

Permalink
EZQMS-470: Add server side tiptap extension for node uuid (#4358)
Browse files Browse the repository at this point in the history
Signed-off-by: Anna No <anna.no@xored.com>
  • Loading branch information
annano authored Jan 16, 2024
1 parent 31b0d98 commit 9def3b2
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 2 deletions.
6 changes: 4 additions & 2 deletions packages/text/src/kits/server-kit.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,19 +14,20 @@
//

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'
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]

Expand Down Expand Up @@ -72,7 +73,8 @@ export const ServerKit = Extension.create<ServerKitOptions>({
ImageNode.configure(this.options.image),
TodoItemNode,
TodoListNode,
ReferenceNode
ReferenceNode,
NodeUuid
]
}
})
23 changes: 23 additions & 0 deletions packages/text/src/marks/nodeUuid.ts
Original file line number Diff line number Diff line change
@@ -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]
}
})

0 comments on commit 9def3b2

Please sign in to comment.