diff --git a/packages/text-editor/src/components/CollaboratorEditor.svelte b/packages/text-editor/src/components/CollaboratorEditor.svelte
index 4b75f4997e2..b748a8b5eec 100644
--- a/packages/text-editor/src/components/CollaboratorEditor.svelte
+++ b/packages/text-editor/src/components/CollaboratorEditor.svelte
@@ -35,7 +35,7 @@
import { calculateDecorations } from './diff/decorations'
import { defaultEditorAttributes } from './editor/editorProps'
import { completionConfig, defaultExtensions } from './extensions'
- import { InlineStyleToolbar } from './extension/inlineStyleToolbar'
+ import { InlineStyleToolbarExtension } from './extension/inlineStyleToolbar'
import { NodeUuidExtension } from './extension/nodeUuid'
import StyleButton from './StyleButton.svelte'
import TextEditorStyleToolbar from './TextEditorStyleToolbar.svelte'
@@ -47,7 +47,6 @@
export let token: string
export let collaboratorURL: string
- export let isFormatting = true
export let buttonSize: IconSize = 'small'
export let focusable: boolean = false
export let placeholder: IntlString = textEditorPlugin.string.EditorPlaceholder
@@ -90,7 +89,6 @@
let editor: Editor
let inlineToolbar: HTMLElement
- let showInlineToolbar = false
let placeHolderStr: string = ''
@@ -136,7 +134,6 @@
}
const [$start, $end] = [doc.resolve(range.from), doc.resolve(range.to)]
-
editor.view.dispatch(tr.setSelection(new TextSelection($start, $end)))
needFocus = true
})
@@ -146,6 +143,22 @@
provider.copyContent(documentId, snapshotId)
}
+ export function unregisterPlugin (nameOrPluginKey: string | PluginKey) {
+ if (!editor) {
+ return
+ }
+
+ editor.unregisterPlugin(nameOrPluginKey)
+ }
+
+ export function registerPlugin (plugin: Plugin) {
+ if (!editor) {
+ return
+ }
+
+ editor.registerPlugin(plugin)
+ }
+
let needFocus = false
let focused = false
@@ -201,6 +214,7 @@
})
$: updateEditor(editor, field, comparedVersion)
+ $: if (editor) dispatch('editor', editor)
onMount(() => {
ph.then(() => {
@@ -211,10 +225,10 @@
extensions: [
...defaultExtensions,
Placeholder.configure({ placeholder: placeHolderStr }),
- InlineStyleToolbar.configure({
+ InlineStyleToolbarExtension.configure({
element: inlineToolbar,
- getEditorElement: () => element,
- isShown: () => !readonly && showInlineToolbar
+ isSupported: () => !readonly,
+ isSelectionOnly: () => false
}),
Collaboration.configure({
document: ydoc,
@@ -247,22 +261,14 @@
onFocus: () => {
focused = true
},
- onUpdate: ({ editor, transaction }) => {
- showInlineToolbar = false
-
+ onUpdate: ({ transaction }) => {
// ignore non-document changes
if (!transaction.docChanged) return
- // TODO this is heavy and should be replaced with more lightweight event
- dispatch('content', editor.getHTML())
-
// ignore non-local changes
if (isChangeOrigin(transaction)) return
dispatch('update')
- },
- onSelectionUpdate: () => {
- showInlineToolbar = false
}
})
@@ -283,16 +289,11 @@
}
})
- function onEditorClick () {
- if (!editor.isEmpty) {
- showInlineToolbar = true
- }
- }
-
let showDiff = true
-