Skip to content

Commit

Permalink
Fix: Improved form success detection
Browse files Browse the repository at this point in the history
  • Loading branch information
fsbraun committed Sep 27, 2024
1 parent 52bfc70 commit 0902deb
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 9 deletions.
4 changes: 2 additions & 2 deletions private/js/cms.editor.js
Original file line number Diff line number Diff line change
Expand Up @@ -366,7 +366,7 @@ class CMSEditor {
// Fallback solution is to reload the page as djagocms-text-ckeditor used to do.
const dom = document.createElement('html');
dom.innerHTML = body;
const success_element = dom.querySelectorAll('.messagelist > .success').length > 0;
const success_element = dom.querySelectorAll('div.messagelist > div.success').length > 0;
if (!success_element) {
el.dataset.changed = 'true';
// Collect messages
Expand Down Expand Up @@ -485,7 +485,7 @@ class CMSEditor {
}

//
let saveSuccess = !!form.querySelector('.messagelist :not(.error)');
let saveSuccess = !!form.querySelector('.messagelist :not(.error,.success)');
if (!saveSuccess) {
saveSuccess =
!!form.querySelector('.dashboard #content-main') &&
Expand Down
18 changes: 11 additions & 7 deletions private/js/tiptap_plugins/cms.balloon-toolbar.js
Original file line number Diff line number Diff line change
Expand Up @@ -116,14 +116,18 @@ export default class CmsBalloonToolbar {
}
depth -= 1;
}
depth = 1; // TODO: Decide which works better: First level, or highest level with block node
this._updateToolbarIcon(resolvedPos.node(depth));
const startPos = resolvedPos.start(depth);
this.toolbar.dataset.block = startPos;
const pos = this.editor.view.coordsAtPos(startPos);
const ref = this.editor.options.el.getBoundingClientRect();
if (depth > 0) {
this._updateToolbarIcon(resolvedPos.node(depth));
const startPos = resolvedPos.start(depth);
this.toolbar.dataset.block = startPos;
const pos = this.editor.view.coordsAtPos(startPos);
const ref = this.editor.options.el.getBoundingClientRect();

this.toolbar.style.insetBlockStart = `${pos.top - ref.top}px`;
this.toolbar.style.insetBlockStart = `${pos.top - ref.top}px`;
this.toolbar.style.display = 'block';
} else {
this.toolbar.style.display = 'none';
}
// TODO: Set the size of the balloon according to the fontsize
// this.toolbar.style.setProperty('--size', this.editor.view. ...)
}
Expand Down
1 change: 1 addition & 0 deletions private/js/tiptap_plugins/cms.plugin.js
Original file line number Diff line number Diff line change
Expand Up @@ -163,6 +163,7 @@ const cmsPluginNodes = {
// Node types need to match
return false;
}
attrs['data-node'] = this.name;
// return attributes and content
return {
HTMLAttributes: attrs,
Expand Down

0 comments on commit 0902deb

Please sign in to comment.