Support for embedding links and references in text editor (#9003)

Signed-off-by: Victor Ilyushchenko <alt13ri@gmail.com>
This commit is contained in:
Victor Ilyushchenko
2025-05-21 11:45:08 +07:00
committed by GitHub
parent e201abcc91
commit 007b11c9df
39 changed files with 1554 additions and 77 deletions
@@ -13,22 +13,37 @@
// limitations under the License.
-->
<script lang="ts">
import { createEventDispatcher } from 'svelte'
import { createEventDispatcher, onDestroy } from 'svelte'
import { type Editor } from '@tiptap/core'
import { type TextEditorAction, type ActionContext } from '@hcengineering/text-editor'
import { getResource } from '@hcengineering/platform'
import { Icon, IconSize, tooltip } from '@hcengineering/ui'
import tr from 'date-fns/locale/tr'
import { Transaction } from '@tiptap/pm/state'
export let action: TextEditorAction
export let size: IconSize
export let editor: Editor
export let actionCtx: ActionContext
export let blockMouseEvents = true
export let listenCursorUpdate = false
const dispatch = createEventDispatcher()
let selected: boolean = false
$: void updateSelected(editor, action)
if (listenCursorUpdate) {
const listener = ({ transaction }: { transaction: Transaction }) => {
if (transaction.getMeta('contextCursorUpdate') === true) {
void updateSelected(editor, action)
}
}
editor.on('transaction', listener)
onDestroy(() => {
editor.off('transaction', listener)
})
}
async function updateSelected (e: Editor, { isActive }: TextEditorAction): Promise<void> {
if (isActive === undefined) {
selected = false