fix: add mermaid plugin to server kit (#7671)

Signed-off-by: Alexander Onnikov <Alexander.Onnikov@xored.com>
This commit is contained in:
Alexander Onnikov
2025-01-15 12:39:52 +07:00
committed by GitHub
parent 0d7c2a6509
commit ff5b57dd47
4 changed files with 49 additions and 0 deletions
@@ -186,6 +186,8 @@
{/each}
{/if}
</th>
{:else if node.type === MarkupNodeType.mermaid}
<!-- TODO -->
{:else if node.type === MarkupNodeType.comment}
<!-- Ignore -->
{:else}
+2
View File
@@ -33,6 +33,7 @@ import { DefaultKit, DefaultKitOptions } from './default-kit'
import { CodeExtension, codeOptions } from '../marks/code'
import { NoteBaseExtension } from '../marks/noteBase'
import { CommentNode } from '../nodes/comment'
import { MermaidExtension, mermaidOptions } from '../nodes/mermaid'
import TextAlign from '@tiptap/extension-text-align'
import TextStyle from '@tiptap/extension-text-style'
import { BackgroundColor, TextColor } from '../marks/colors'
@@ -85,6 +86,7 @@ export const ServerKit = Extension.create<ServerKitOptions>({
}),
CodeBlockExtension.configure(codeBlockOptions),
CodeExtension.configure(codeOptions),
MermaidExtension.configure(mermaidOptions),
...tableExtensions,
...taskListExtensions,
...fileExtensions,
+1
View File
@@ -38,6 +38,7 @@ export enum MarkupNodeType {
table_row = 'tableRow',
table_cell = 'tableCell',
table_header = 'tableHeader',
mermaid = 'mermaid',
comment = 'comment'
}
+44
View File
@@ -0,0 +1,44 @@
//
// Copyright © 2024 Hardcore Engineering Inc.
//
// Licensed under the Eclipse Public License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License. You may
// obtain a copy of the License at https://www.eclipse.org/legal/epl-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
//
// See the License for the specific language governing permissions and
// limitations under the License.
//
import CodeBlock, { CodeBlockOptions } from '@tiptap/extension-code-block'
import { codeBlockOptions } from './codeblock'
export const mermaidOptions: CodeBlockOptions = {
...codeBlockOptions,
defaultLanguage: 'mermaid'
}
export const MermaidExtension = CodeBlock.extend({
name: 'mermaid',
group: 'block',
parseHTML () {
return [
{
tag: 'div.mermaid-diagram',
preserveWhitespace: 'full'
}
]
},
addAttributes () {
return {
language: {
default: 'mermaid'
}
}
}
})