givanz / VvvebJs

Drag and drop page builder library written in vanilla javascript without dependencies or build tools.
https://www.vvveb.com/vvvebjs/editor.html
Apache License 2.0
6.91k stars 1.59k forks source link

Non-editable area #274

Open carllrac1 opened 1 year ago

carllrac1 commented 1 year ago

I would like to block some sections of my website from being edited, the thing is that I have used data-vvveb-disabled, and although it works, it is not 100% effective. If the content of the section has text and I double click on it, I can edit the text even if the section is disabled.

Any idea how to fix this?

givanz commented 1 year ago

Hi

The data-vvveb-disabled solutions uses the css pointer-events:none property to disable mouse events on the element but the element dblclick is still executed on the first parent element that is editable and the text editor is enabled on the parent element and indirectly the child element that has the data-vvveb-disabled can also be edited.

To avoid this you need to remove pointer-events:none from data-vvveb-disabled and handle the data-vvveb-disabled attribute from javascript code in the event handlers by checking the presence of the attribute on the current element also on mousemove events for the highlighting etc.

You can also use a quick hack like

$("[data-vvveb-disabled]", window.FrameDocument).on("dblclick", function (e) {
    e.preventDefault();
   return false;
});
$("[data-vvveb-disabled]", window.FrameDocument).parent().on("dblclick", function (e) {
    e.preventDefault();
   return false;
});

to disable dbclick event on the elements.