mirror of
https://github.com/hcengineering/platform.git
synced 2024-12-19 08:51:37 +03:00
EQMS-1325 Add mermaid and drawing board to editor kit (#7487)
Signed-off-by: Alexander Onnikov <Alexander.Onnikov@xored.com>
This commit is contained in:
parent
4fa36837c1
commit
2ea25fa4ab
@ -15,6 +15,7 @@
|
|||||||
//
|
//
|
||||||
-->
|
-->
|
||||||
<script lang="ts">
|
<script lang="ts">
|
||||||
|
import { Analytics } from '@hcengineering/analytics'
|
||||||
import { MarkupNode } from '@hcengineering/text'
|
import { MarkupNode } from '@hcengineering/text'
|
||||||
import { onDestroy, onMount } from 'svelte'
|
import { onDestroy, onMount } from 'svelte'
|
||||||
import { Doc as Ydoc } from 'yjs'
|
import { Doc as Ydoc } from 'yjs'
|
||||||
@ -80,7 +81,11 @@
|
|||||||
editorProps: { attributes: mergeAttributes(defaultEditorAttributes, { class: 'flex-grow' }) },
|
editorProps: { attributes: mergeAttributes(defaultEditorAttributes, { class: 'flex-grow' }) },
|
||||||
element,
|
element,
|
||||||
editable: false,
|
editable: false,
|
||||||
extensions: [await getEditorKit(), DecorationExtension, Collaboration.configure({ document: ydoc, field })]
|
extensions: [await getEditorKit(), DecorationExtension, Collaboration.configure({ document: ydoc, field })],
|
||||||
|
onContentError: ({ error, disableCollaboration }) => {
|
||||||
|
disableCollaboration()
|
||||||
|
Analytics.handleError(error)
|
||||||
|
}
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
|
||||||
|
@ -75,7 +75,7 @@
|
|||||||
import TextEditorToolbar from './TextEditorToolbar.svelte'
|
import TextEditorToolbar from './TextEditorToolbar.svelte'
|
||||||
import { noSelectionRender, renderCursor } from './editor/collaboration'
|
import { noSelectionRender, renderCursor } from './editor/collaboration'
|
||||||
import { defaultEditorAttributes } from './editor/editorProps'
|
import { defaultEditorAttributes } from './editor/editorProps'
|
||||||
import { DrawingBoardExtension, SavedBoard } from './extension/drawingBoard'
|
import { SavedBoard } from './extension/drawingBoard'
|
||||||
import { EmojiExtension } from './extension/emoji'
|
import { EmojiExtension } from './extension/emoji'
|
||||||
import { FileUploadExtension } from './extension/fileUploadExt'
|
import { FileUploadExtension } from './extension/fileUploadExt'
|
||||||
import { ImageUploadExtension } from './extension/imageUploadExt'
|
import { ImageUploadExtension } from './extension/imageUploadExt'
|
||||||
@ -83,7 +83,7 @@
|
|||||||
import { LeftMenuExtension } from './extension/leftMenu'
|
import { LeftMenuExtension } from './extension/leftMenu'
|
||||||
import { type FileAttachFunction } from './extension/types'
|
import { type FileAttachFunction } from './extension/types'
|
||||||
import { completionConfig, inlineCommandsConfig } from './extensions'
|
import { completionConfig, inlineCommandsConfig } from './extensions'
|
||||||
import { MermaidExtension, mermaidOptions } from './extension/mermaid'
|
import { mermaidOptions } from './extension/mermaid'
|
||||||
import { InlineCommentExtension } from './extension/inlineComment'
|
import { InlineCommentExtension } from './extension/inlineComment'
|
||||||
|
|
||||||
export let object: Doc
|
export let object: Doc
|
||||||
@ -464,6 +464,14 @@
|
|||||||
isHidden: () => !showToolbar
|
isHidden: () => !showToolbar
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
mermaid: {
|
||||||
|
...mermaidOptions,
|
||||||
|
ydoc,
|
||||||
|
ydocContentField: field
|
||||||
|
},
|
||||||
|
drawingBoard: {
|
||||||
|
getSavedBoard
|
||||||
|
},
|
||||||
...kitOptions
|
...kitOptions
|
||||||
}),
|
}),
|
||||||
...optionalExtensions,
|
...optionalExtensions,
|
||||||
@ -485,8 +493,6 @@
|
|||||||
}
|
}
|
||||||
}),
|
}),
|
||||||
EmojiExtension,
|
EmojiExtension,
|
||||||
MermaidExtension.configure({ ...mermaidOptions, ydoc, ydocContentField: field }),
|
|
||||||
DrawingBoardExtension.configure({ getSavedBoard }),
|
|
||||||
...extensions
|
...extensions
|
||||||
],
|
],
|
||||||
parseOptions: {
|
parseOptions: {
|
||||||
|
@ -31,7 +31,6 @@
|
|||||||
import { InlineCommandsExtension } from './extension/inlineCommands'
|
import { InlineCommandsExtension } from './extension/inlineCommands'
|
||||||
import { type FileAttachFunction } from './extension/types'
|
import { type FileAttachFunction } from './extension/types'
|
||||||
import { completionConfig, InlineCommandId, inlineCommandsConfig } from './extensions'
|
import { completionConfig, InlineCommandId, inlineCommandsConfig } from './extensions'
|
||||||
import { MermaidExtension, mermaidOptions } from './extension/mermaid'
|
|
||||||
|
|
||||||
export let label: IntlString | undefined = undefined
|
export let label: IntlString | undefined = undefined
|
||||||
export let content: Markup
|
export let content: Markup
|
||||||
@ -193,7 +192,6 @@
|
|||||||
}
|
}
|
||||||
extensions.push(
|
extensions.push(
|
||||||
imageUploadPlugin,
|
imageUploadPlugin,
|
||||||
MermaidExtension.configure(mermaidOptions),
|
|
||||||
FocusExtension.configure({ onCanBlur: (value: boolean) => (canBlur = value), onFocus: handleFocus })
|
FocusExtension.configure({ onCanBlur: (value: boolean) => (canBlur = value), onFocus: handleFocus })
|
||||||
)
|
)
|
||||||
if (enableEmojiReplace) {
|
if (enableEmojiReplace) {
|
||||||
|
@ -174,6 +174,7 @@
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
: false,
|
: false,
|
||||||
|
drawingBoard: false,
|
||||||
submit: supportSubmit ? { submit } : false,
|
submit: supportSubmit ? { submit } : false,
|
||||||
toolbar: {
|
toolbar: {
|
||||||
element: textToolbarElement,
|
element: textToolbarElement,
|
||||||
|
@ -35,6 +35,8 @@ import { ParagraphExtension } from '../components/extension/paragraph'
|
|||||||
import { SubmitExtension, type SubmitOptions } from '../components/extension/submit'
|
import { SubmitExtension, type SubmitOptions } from '../components/extension/submit'
|
||||||
import { Table, TableCell, TableRow } from '../components/extension/table'
|
import { Table, TableCell, TableRow } from '../components/extension/table'
|
||||||
import { DefaultKit, type DefaultKitOptions } from './default-kit'
|
import { DefaultKit, type DefaultKitOptions } from './default-kit'
|
||||||
|
import { MermaidExtension, type MermaidOptions, mermaidOptions } from '../components/extension/mermaid'
|
||||||
|
import { DrawingBoardExtension, type DrawingBoardOptions } from '../components/extension/drawingBoard'
|
||||||
|
|
||||||
export interface EditorKitOptions extends DefaultKitOptions {
|
export interface EditorKitOptions extends DefaultKitOptions {
|
||||||
history?: false
|
history?: false
|
||||||
@ -49,6 +51,8 @@ export interface EditorKitOptions extends DefaultKitOptions {
|
|||||||
}
|
}
|
||||||
})
|
})
|
||||||
| false
|
| false
|
||||||
|
drawingBoard?: DrawingBoardOptions | false
|
||||||
|
mermaid?: MermaidOptions | false
|
||||||
mode?: 'full' | 'compact'
|
mode?: 'full' | 'compact'
|
||||||
note?: NoteOptions | false
|
note?: NoteOptions | false
|
||||||
submit?: SubmitOptions | false
|
submit?: SubmitOptions | false
|
||||||
@ -248,6 +252,14 @@ async function buildEditorKit (): Promise<Extension<EditorKitOptions, any>> {
|
|||||||
staticKitExtensions.push([800, ImageExtension.configure(imageOptions)])
|
staticKitExtensions.push([800, ImageExtension.configure(imageOptions)])
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (this.options.drawingBoard !== false) {
|
||||||
|
staticKitExtensions.push([840, DrawingBoardExtension.configure(this.options.drawingBoard)])
|
||||||
|
}
|
||||||
|
|
||||||
|
if (this.options.mermaid !== false) {
|
||||||
|
staticKitExtensions.push([850, MermaidExtension.configure(this.options.mermaid ?? mermaidOptions)])
|
||||||
|
}
|
||||||
|
|
||||||
if (this.options.toolbar !== false) {
|
if (this.options.toolbar !== false) {
|
||||||
staticKitExtensions.push([
|
staticKitExtensions.push([
|
||||||
900,
|
900,
|
||||||
|
Loading…
Reference in New Issue
Block a user