From d325def307af4fb795317e64746612cfa69aee06 Mon Sep 17 00:00:00 2001 From: Nick Bernal Date: Mon, 5 Aug 2024 18:57:26 -0700 Subject: [PATCH] Refactor toolbar in superdoc to work with new SE toolbar, fix issue where we don't always have an active editor, update toolbar buttons on new editor focus --- .../src/components/toolbar/Toolbar.vue | 24 ++++--------------- .../src/components/toolbar/ToolbarItem.js | 8 ++----- packages/superdoc/package.json | 2 +- packages/superdoc/src/Superdoc.vue | 16 +++++++++---- .../components/SuperToolbar/SuperToolbar.vue | 9 +++---- packages/superdoc/src/dev/SuperdocDev.vue | 13 ---------- packages/superdoc/src/index.js | 11 +++++---- 7 files changed, 28 insertions(+), 55 deletions(-) diff --git a/packages/super-editor/src/components/toolbar/Toolbar.vue b/packages/super-editor/src/components/toolbar/Toolbar.vue index c09917a281..798c2c4584 100644 --- a/packages/super-editor/src/components/toolbar/Toolbar.vue +++ b/packages/super-editor/src/components/toolbar/Toolbar.vue @@ -13,7 +13,7 @@ import { undoDepth, redoDepth } from 'prosemirror-history'; const props = defineProps({ editorInstance: { type: Object, - required: true, + required: false, }, updateTransaction: { type: Object, @@ -332,7 +332,8 @@ const alignment = makeToolbarItem({ markName: 'textAlign', labelAttr: 'textAlign', getIcon(self) { - const attrs = self.editor.getAttributes('paragraph').textAlign; + let attrs = self.editor?.getAttributes('paragraph').textAlign; + if (!attrs) attrs = 'left'; return `fa-align-${attrs}`; }, onTextMarkSelection(self, mark) { @@ -570,8 +571,8 @@ const toolbarItems = ref([ alignment, bulletedList, numberedList, - indentRight, indentLeft, + indentRight, separator, search, overflow, @@ -762,23 +763,6 @@ defineExpose({