Added optional backlinks support to StyledTextArea (#3970)

Signed-off-by: Oleg Solodkov <oleg.solodkov@xored.com>
This commit is contained in:
Oleg Solodkov 2023-11-10 19:56:45 +04:00 committed by GitHub
parent 25f0e4d579
commit 8973254b41
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -1,9 +1,12 @@
<script lang="ts">
import { AnyExtension } from '@tiptap/core'
import { IntlString } from '@hcengineering/platform'
import { ButtonSize, Label } from '@hcengineering/ui'
import { createEventDispatcher } from 'svelte'
import textEditorPlugin from '../plugin'
import StyledTextEditor from './StyledTextEditor.svelte'
import { Completion } from '../Completion'
import { completionConfig } from './extensions'
export let label: IntlString | undefined = undefined
export let content: string | undefined
@ -16,6 +19,7 @@
export let isScrollable: boolean = false
export let maxHeight: 'max' | 'card' | 'limited' | string | undefined = undefined
export let required = false
export let enableBackReferences = false
let rawValue: string
let oldContent = ''
@ -45,6 +49,24 @@
textEditor.focus()
needFocus = false
}
function configureExtensions () {
const completionPlugin = Completion.configure({
...completionConfig,
showDoc (event: MouseEvent, _id: string, _class: string) {
dispatch('open-document', { event, _id, _class })
}
})
const extensions: AnyExtension[] = []
if (enableBackReferences) {
extensions.push(completionPlugin)
}
return extensions
}
const extensions = configureExtensions()
</script>
<!-- svelte-ignore a11y-click-events-have-key-events -->
@ -68,6 +90,7 @@
{buttonSize}
{maxHeight}
{isScrollable}
{extensions}
bind:content={rawValue}
bind:this={textEditor}
on:focus={() => {