Skip to content

Commit

Permalink
Fix tiptap focus
Browse files Browse the repository at this point in the history
  • Loading branch information
fsbraun committed Jan 16, 2025
1 parent 0f5f967 commit 2bf53fd
Showing 1 changed file with 6 additions and 12 deletions.
18 changes: 6 additions & 12 deletions private/js/tiptap_plugins/cms.toolbar.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

import {Extension} from "@tiptap/core";

import {NodeSelection, TextSelection} from "@tiptap/pm/state";
import {TextSelection} from "@tiptap/pm/state";
import {Decoration, DecorationSet} from "@tiptap/pm/view";
import {Plugin} from "@tiptap/pm/state";
import TiptapToolbar from "./cms.tiptap.toolbar";
Expand Down Expand Up @@ -129,17 +129,6 @@ function _createBlockToolbar(editor, blockToolbar) {
}



// Add the form dialog only if it is not already open
// this.form = new CmsForm(this.editor.options.el, () => {});
// const rect = this.toolbar.getBoundingClientRect();
// const options = {
// x: (rect.left + rect.right) / 2,
// y: rect.bottom,
// toolbar: true
// };


function updateBlockToolbar(editor, state) {
'use strict';
const {resolvedPos, depth} = _getResolvedPos(state || editor.state);
Expand Down Expand Up @@ -271,6 +260,11 @@ function _createToolbar(editor, toolbar, filter) {
// Limit its width to the available space
toolbarElement.style.maxWidth = (window.innerWidth - toolbarElement.getBoundingClientRect().left - 16) + 'px';
}
setTimeout(() => {
if (toolbarElement.contains(document.activeElement)) {
editor.commands.focus();
}
}, 10);
return toolbarElement;
}

Expand Down

0 comments on commit 2bf53fd

Please sign in to comment.