Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: add mermaid plugin to server kit #7671

Merged
merged 1 commit into from
Jan 15, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -186,6 +186,8 @@
{/each}
{/if}
</th>
{:else if node.type === MarkupNodeType.mermaid}
<!-- TODO -->
haiodo marked this conversation as resolved.
Show resolved Hide resolved
{:else if node.type === MarkupNodeType.comment}
<!-- Ignore -->
{:else}
Expand Down
2 changes: 2 additions & 0 deletions packages/text/src/kits/server-kit.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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'
Expand Down Expand Up @@ -85,6 +86,7 @@ export const ServerKit = Extension.create<ServerKitOptions>({
}),
CodeBlockExtension.configure(codeBlockOptions),
CodeExtension.configure(codeOptions),
MermaidExtension.configure(mermaidOptions),
...tableExtensions,
...taskListExtensions,
...fileExtensions,
Expand Down
1 change: 1 addition & 0 deletions packages/text/src/markup/model.ts
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ export enum MarkupNodeType {
table_row = 'tableRow',
table_cell = 'tableCell',
table_header = 'tableHeader',
mermaid = 'mermaid',
comment = 'comment'
}

Expand Down
44 changes: 44 additions & 0 deletions packages/text/src/nodes/mermaid.ts
Original file line number Diff line number Diff line change
@@ -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'
}
}
}
})
Loading