Skip to content

Commit

Permalink
EZQMS-393: Add CollaboratorEditor prop to hide popups (#4051)
Browse files Browse the repository at this point in the history
Signed-off-by: Anna No <anna.no@xored.com>
  • Loading branch information
annano authored Nov 27, 2023
1 parent d83b1a9 commit 6f37f27
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 24 deletions.
52 changes: 29 additions & 23 deletions packages/text-editor/src/components/CollaboratorEditor.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,7 @@
export let boundary: HTMLElement | undefined = undefined
export let attachFile: FileAttachFunction | undefined = undefined
export let canShowPopups = true
let element: HTMLElement
Expand Down Expand Up @@ -262,6 +263,7 @@
$: updateEditor(editor, field, comparedVersion)
$: if (editor) dispatch('editor', editor)
$: isStyleToolbarSupported = (!readonly || textNodeActions.length > 0) && canShowPopups
$: tippyOptions = {
zIndex: 100000,
Expand Down Expand Up @@ -304,7 +306,7 @@
InlineStyleToolbarExtension.configure({
tippyOptions,
element: textToolbarElement,
isSupported: () => !readonly,
isSupported: () => isStyleToolbarSupported,
isSelectionOnly: () => false
}),
InlinePopupExtension.configure({
Expand All @@ -315,7 +317,7 @@
appendTo: () => boundary ?? element
},
shouldShow: () => {
if (!visible && !readonly) {
if (!visible || !readonly || !canShowPopups) {
return false
}
return editor?.isActive('image')
Expand Down Expand Up @@ -448,27 +450,31 @@
bind:this={textToolbarElement}
style="visibility: hidden;"
>
<TextEditorStyleToolbar
textEditor={editor}
textFormatCategories={[
TextFormatCategory.Heading,
TextFormatCategory.TextDecoration,
TextFormatCategory.Link,
TextFormatCategory.List,
TextFormatCategory.Quote,
TextFormatCategory.Code,
TextFormatCategory.Table
]}
formatButtonSize={buttonSize}
{textNodeActions}
on:focus={() => {
needFocus = true
}}
on:action={(event) => {
dispatch('action', event.detail)
needFocus = true
}}
/>
{#if isStyleToolbarSupported}
<TextEditorStyleToolbar
textEditor={editor}
textFormatCategories={readonly
? []
: [
TextFormatCategory.Heading,
TextFormatCategory.TextDecoration,
TextFormatCategory.Link,
TextFormatCategory.List,
TextFormatCategory.Quote,
TextFormatCategory.Code,
TextFormatCategory.Table
]}
formatButtonSize={buttonSize}
{textNodeActions}
on:focus={() => {
needFocus = true
}}
on:action={(event) => {
dispatch('action', event.detail)
needFocus = true
}}
/>
{/if}
</div>

<div
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ export const InlineStyleToolbarExtension = Extension.create<InlineStyleToolbarOp
return false
}

if (editor.isDestroyed || !editor.isEditable) {
if (editor.isDestroyed) {
return false
}

Expand Down

0 comments on commit 6f37f27

Please sign in to comment.