mirror of
https://github.com/hcengineering/platform.git
synced 2025-04-22 16:27:22 +00:00
Added optional backlinks support to StyledTextArea (#3970)
Signed-off-by: Oleg Solodkov <oleg.solodkov@xored.com>
This commit is contained in:
parent
25f0e4d579
commit
8973254b41
@ -1,9 +1,12 @@
|
|||||||
<script lang="ts">
|
<script lang="ts">
|
||||||
|
import { AnyExtension } from '@tiptap/core'
|
||||||
import { IntlString } from '@hcengineering/platform'
|
import { IntlString } from '@hcengineering/platform'
|
||||||
import { ButtonSize, Label } from '@hcengineering/ui'
|
import { ButtonSize, Label } from '@hcengineering/ui'
|
||||||
import { createEventDispatcher } from 'svelte'
|
import { createEventDispatcher } from 'svelte'
|
||||||
import textEditorPlugin from '../plugin'
|
import textEditorPlugin from '../plugin'
|
||||||
import StyledTextEditor from './StyledTextEditor.svelte'
|
import StyledTextEditor from './StyledTextEditor.svelte'
|
||||||
|
import { Completion } from '../Completion'
|
||||||
|
import { completionConfig } from './extensions'
|
||||||
|
|
||||||
export let label: IntlString | undefined = undefined
|
export let label: IntlString | undefined = undefined
|
||||||
export let content: string | undefined
|
export let content: string | undefined
|
||||||
@ -16,6 +19,7 @@
|
|||||||
export let isScrollable: boolean = false
|
export let isScrollable: boolean = false
|
||||||
export let maxHeight: 'max' | 'card' | 'limited' | string | undefined = undefined
|
export let maxHeight: 'max' | 'card' | 'limited' | string | undefined = undefined
|
||||||
export let required = false
|
export let required = false
|
||||||
|
export let enableBackReferences = false
|
||||||
|
|
||||||
let rawValue: string
|
let rawValue: string
|
||||||
let oldContent = ''
|
let oldContent = ''
|
||||||
@ -45,6 +49,24 @@
|
|||||||
textEditor.focus()
|
textEditor.focus()
|
||||||
needFocus = false
|
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>
|
</script>
|
||||||
|
|
||||||
<!-- svelte-ignore a11y-click-events-have-key-events -->
|
<!-- svelte-ignore a11y-click-events-have-key-events -->
|
||||||
@ -68,6 +90,7 @@
|
|||||||
{buttonSize}
|
{buttonSize}
|
||||||
{maxHeight}
|
{maxHeight}
|
||||||
{isScrollable}
|
{isScrollable}
|
||||||
|
{extensions}
|
||||||
bind:content={rawValue}
|
bind:content={rawValue}
|
||||||
bind:this={textEditor}
|
bind:this={textEditor}
|
||||||
on:focus={() => {
|
on:focus={() => {
|
||||||
|
Loading…
Reference in New Issue
Block a user