diff --git a/libs/shared/lib/components/textEditor/TextEditor.tsx b/libs/shared/lib/components/textEditor/TextEditor.tsx index f3ba1ce03e202727610f48dbbe921f2cbb8735e8..2b931b872d68b8bd21c9a356c31561d7eabd2883 100644 --- a/libs/shared/lib/components/textEditor/TextEditor.tsx +++ b/libs/shared/lib/components/textEditor/TextEditor.tsx @@ -40,7 +40,7 @@ export function TextEditor({ editorState, setEditorState, showToolbar, placehold return ( <LexicalComposer initialConfig={initialConfig}> - <div className="flex items-center bg-secondary-50 rounded mt-4 space-x-2"> + <div className="editor-toolbar flex items-center bg-secondary-50 rounded mt-4 space-x-2"> <PreviewPlugin contentEditable={contentEditableRef} /> {showToolbar && <ToolbarPlugin />} </div> diff --git a/libs/shared/lib/components/textEditor/plugins/InsertVariablesPlugin.tsx b/libs/shared/lib/components/textEditor/plugins/InsertVariablesPlugin.tsx index ba2fdcfabd6750044b3a882c43ddb98ff4fd2162..c6932a3b6bf2587d78cd30592fe542485db15cdb 100644 --- a/libs/shared/lib/components/textEditor/plugins/InsertVariablesPlugin.tsx +++ b/libs/shared/lib/components/textEditor/plugins/InsertVariablesPlugin.tsx @@ -44,6 +44,7 @@ export const InsertVariablesPlugin = () => { type="dropdown" label={`${nodeType} variable`} value="" + className="insert-variable" options={optionsForType(nodeType)} onChange={(v) => onChange(`${nodeType} ${v}`, VariableType.statistic)} /> @@ -53,6 +54,7 @@ export const InsertVariablesPlugin = () => { type="dropdown" label={`Visualization`} value="" + className="insert-variable" options={visualizationOptions} onChange={(v) => onChange(v, VariableType.visualization)} /> diff --git a/libs/shared/lib/components/textEditor/plugins/PreviewPlugin.tsx b/libs/shared/lib/components/textEditor/plugins/PreviewPlugin.tsx index 4f9c450d2cae3d84153e09a30fb91204542d9611..d6a2bd2f97e9a41a9470c5ab8a74fc6a84f73247 100644 --- a/libs/shared/lib/components/textEditor/plugins/PreviewPlugin.tsx +++ b/libs/shared/lib/components/textEditor/plugins/PreviewPlugin.tsx @@ -109,6 +109,8 @@ export function PreviewPlugin({ contentEditable }: { contentEditable: RefObject< if (editor == null) return; editor.classList.add('hidden'); + document.querySelectorAll('.editor-toolbar > div:not(.toolbar-preview)').forEach((el) => el.classList.add('hidden')); + document.querySelectorAll('.insert-variable').forEach((el) => el.classList.add('hidden')); let preview = editor.parentElement?.querySelector('.editor + .preview'); preview?.classList.remove('hidden'); @@ -125,6 +127,9 @@ export function PreviewPlugin({ contentEditable }: { contentEditable: RefObject< if (editor == null) return; editor.classList.remove('hidden'); + document.querySelectorAll('.editor-toolbar > div:not(.toolbar-preview)').forEach((el) => el.classList.remove('hidden')); + document.querySelectorAll('.insert-variable').forEach((el) => el.classList.remove('hidden')); + editor?.querySelector('div')?.focus(); let preview = editor.parentElement?.querySelector('.editor + .preview');