Skip to content

Commit 4c58f30

Browse files
committed
implement inlineToolbar
1 parent e095706 commit 4c58f30

File tree

1 file changed

+16
-6
lines changed

1 file changed

+16
-6
lines changed

src/application/services/useNoteEditor.ts

Lines changed: 16 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -68,13 +68,13 @@ export const useNoteEditor = function useNoteEditor(options: UseNoteEditorOption
6868
* Loaded tools classes by grouped by tool.name
6969
* Undefined when tools are not loaded yet
7070
*/
71-
let toolsClasses: Record<string, EditorjsConfigTool> | undefined = undefined;
71+
let toolsUserConfig: Record<string, { class: EditorjsConfigTool; inlineToolbar: boolean }> | undefined = undefined;
7272

7373
/**
74-
* We can't make toolsClasses reactive since it contains excecutable js-classes, Vue can't handle that.
74+
* We can't make toolsUserConfig reactive since it contains excecutable js-classes, Vue can't handle that.
7575
* So we store reactive flag to indicate that tools are loaded
7676
*/
77-
const toolsClassesLoaded = ref<boolean>(false);
77+
const toolsUserConfigLoaded = ref<boolean>(false);
7878

7979
/**
8080
* Combine note and user tools
@@ -114,8 +114,17 @@ export const useNoteEditor = function useNoteEditor(options: UseNoteEditorOption
114114
*/
115115
const loadedToolsWithoutParagraph = loadedTools.filter(tool => tool.tool.name !== 'paragraph');
116116

117-
toolsClasses = Object.fromEntries(loadedToolsWithoutParagraph.map(toolClassAndInfo => [toolClassAndInfo.tool.name, toolClassAndInfo.class]));
118-
toolsClassesLoaded.value = true;
117+
toolsUserConfig = Object.fromEntries(
118+
loadedToolsWithoutParagraph
119+
.map(toolClassAndInfo => [
120+
toolClassAndInfo.tool.name,
121+
{
122+
class: toolClassAndInfo.class,
123+
inlineToolbar: true,
124+
},
125+
])
126+
);
127+
toolsUserConfigLoaded.value = true;
119128

120129
/**
121130
* Now all tools are loaded, we're ready to use the editor
@@ -148,8 +157,9 @@ export const useNoteEditor = function useNoteEditor(options: UseNoteEditorOption
148157
holderId: 'editorjs',
149158
data: options.noteContentResolver(),
150159
readOnly: toValue(options.canEdit) === false,
151-
tools: toolsClassesLoaded.value ? toolsClasses : undefined,
160+
tools: toolsUserConfigLoaded.value ? toolsUserConfig : undefined,
152161
placeholder: t('note.editor.placeholder'),
162+
inlineToolbar: true,
153163
};
154164
});
155165

0 commit comments

Comments
 (0)