Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

EZQMS-393: Add CollaboratorEditor prop to hide popups #4051

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
annano marked this conversation as resolved.
Show resolved Hide resolved

$: 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