mirror of
https://github.com/hcengineering/platform.git
synced 2024-11-22 03:14:40 +03:00
feat: improve links behavior in the editor (#6612)
Signed-off-by: Alexander Onnikov <Alexander.Onnikov@xored.com>
This commit is contained in:
parent
fc48297b70
commit
78e601ff43
@ -27,13 +27,15 @@
|
||||
function save (): void {
|
||||
dispatch('update', link)
|
||||
}
|
||||
|
||||
$: canSave = link === '' || URL.canParse(link)
|
||||
</script>
|
||||
|
||||
<Card
|
||||
label={textEditor.string.Link}
|
||||
okLabel={textEditor.string.Save}
|
||||
okAction={save}
|
||||
canSave
|
||||
{canSave}
|
||||
on:close={() => {
|
||||
dispatch('close')
|
||||
}}
|
||||
|
@ -73,11 +73,14 @@ export const DefaultKit = Extension.create<DefaultKitOptions>({
|
||||
export async function formatLink (editor: Editor): Promise<void> {
|
||||
const link = editor.getAttributes('link').href
|
||||
|
||||
showPopup(LinkPopup, { link }, undefined, undefined, (newLink) => {
|
||||
if (newLink === '') {
|
||||
editor.chain().focus().extendMarkRange('link').unsetLink().run()
|
||||
} else {
|
||||
editor.chain().focus().extendMarkRange('link').setLink({ href: newLink }).run()
|
||||
}
|
||||
// give editor some time to handle blur event
|
||||
setTimeout(() => {
|
||||
showPopup(LinkPopup, { link }, undefined, undefined, (newLink) => {
|
||||
if (newLink === '') {
|
||||
editor.chain().focus().extendMarkRange('link').unsetLink().run()
|
||||
} else {
|
||||
editor.chain().focus().extendMarkRange('link').setLink({ href: newLink }).run()
|
||||
}
|
||||
})
|
||||
})
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user