Skip to content
Merged
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
15 changes: 7 additions & 8 deletions packages/super-editor/src/components/toolbar/super-toolbar.js
Original file line number Diff line number Diff line change
Expand Up @@ -186,12 +186,7 @@ export class SuperToolbar extends EventEmitter {
this.config.selector = this.config.element;
}

this.toolbarContainer = this.getElementBySelector(this.config.selector);

if (!this.toolbarContainer) {
return;
}

this.toolbarContainer = this.findElementBySelector(this.config.selector);
this.#initToolbarGroups();
this.#makeToolbarItems({
superToolbar: this,
Expand All @@ -202,6 +197,10 @@ export class SuperToolbar extends EventEmitter {
isDev: config.isDev,
});

if (this.config.selector && !this.toolbarContainer) {
return;
}

this.app = createApp(Toolbar);
this.app.directive('click-outside', vClickOutside);
this.app.config.globalProperties.$toolbar = this;
Expand All @@ -212,7 +211,7 @@ export class SuperToolbar extends EventEmitter {
this.updateToolbarState();
}

getElementBySelector(selector) {
findElementBySelector(selector) {
let el = null;

if (selector) {
Expand Down Expand Up @@ -607,7 +606,7 @@ export class SuperToolbar extends EventEmitter {
isDev = false,
} = {}) {
const documentWidth = document.documentElement.clientWidth; // take into account the scrollbar
const containerWidth = this.toolbarContainer.offsetWidth;
const containerWidth = this.toolbarContainer?.offsetWidth ?? 0;
const availableWidth = this.config.responsiveToContainer ? containerWidth : documentWidth;

const { defaultItems, overflowItems } = makeDefaultItems({
Expand Down
Loading