FROALA non editable content
Asked Answered
A

5

9

I am building an email template with FROALA. I don't want to give the user the power to edit a part of it. Is there a way to stop the user from editing a part of the content?

Thank you.

Adlib answered 30/1, 2015 at 15:43 Comment(0)
U
18

The best way for that would be to use the contenteditable=false flag and there is an example on the Froala Github repo as well: https://github.com/froala/wysiwyg-editor/blob/master/html/popular/disable_edit.html#L40.

<p>This <span contenteditable="false">zone</span> can't be edited.</p>

If you would like to allow deleting that when using backspace/delete, then you should also add the class fr-deletable to it:

<p>This <span contenteditable="false" class="fr-deletable">zone</span> can be deleted.</p>
Undercurrent answered 10/7, 2017 at 6:59 Comment(0)
A
6

For that, You can use

<div contenteditable="false"></div>.
Adlib answered 30/1, 2015 at 17:27 Comment(0)
M
0

Froala allows you to make froala non-editable,

Lets make this instance non editable:

<div id="froala-editor"></div>

Initiate Froala Instance:

$('#froala-editor').froalaEditor({});

Make in non-editable

$('#froala-editor').froalaEditor('edit.off');

Demo: https://jsfiddle.net/q87duk2c/17/

enter image description here

If you want to activate it again you can do:

$('#froala-editor').froalaEditor('edit.on');
Musaceous answered 12/1, 2019 at 8:55 Comment(0)
U
0

Requirement can be of 2 types :

  1. As soon as we initiate froala editor we want editor to be disabled in that particular scenario below code will work.

HTML:

<div id="froala-editor">

</div>

JavaScript:

$('#froala-editor').froalaEditor({});
$('#froala-editor').froalaEditor('edit.off');
  1. If we want some part of html to be in read only mode will other must work as editable.For that
<div id="froala-editor">
<div id="new" contenteditable="false">
  <p>
  hi lets make this content non editable
  </p>
  </div>
</div>

contenteditable=false just give this attribute on top of it.

div with id new is in read only mode.

Unicef answered 19/6, 2020 at 4:26 Comment(0)
D
0

For some reason, I need to disable/enable the toolbar too (only in this case the cursor is correct when moving the mouse above any button in the toolbar):

var editor = new FroalaEditor(...);
...
if (booReadOnly) {
    editor.edit.off();
    editor.toolbar.disable();
} else {
    editor.edit.on();
    editor.toolbar.enable();

}

Dispersoid answered 1/2, 2022 at 19:51 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.