FROALA不可编辑的内容

时间:2015-01-30 15:44:00

标签: froala

我正在使用FROALA构建电子邮件模板。 我不想让用户有权编辑它的一部分。 有没有办法阻止用户编辑部分内容?

谢谢。

4 个答案:

答案 0 :(得分:6)

最好的方法是使用contenteditable=false标志,并在Froala Github repo上有一个例子: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>

如果您希望在使用退格/删除时允许删除它,那么您还应该将类fr-deletable添加到其中:

<p>This <span contenteditable="false" class="fr-deletable">zone</span> can be deleted.</p>

答案 1 :(得分:3)

为此,您可以使用

<div contenteditable="false"></div>.

答案 2 :(得分:0)

Froala允许您将Froala设为不可编辑,

让此实例不可编辑:

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

启动Froala实例:

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

设为不可编辑

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

演示:https://jsfiddle.net/q87duk2c/17/

enter image description here

如果要再次激活它,可以执行以下操作:

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

答案 3 :(得分:0)

需求可以是2种类型:

  1. 一旦启动froala编辑器,我们希望在以下特定情况下禁用编辑器,以下代码将起作用。

HTML:

<div id="froala-editor">

</div>

JavaScript:

$('#froala-editor').froalaEditor({});
$('#froala-editor').froalaEditor('edit.off');
  1. 如果我们希望html的某些部分处于只读模式,则其他部分必须可编辑。为此
<div id="froala-editor">
<div id="new" contenteditable="false">
  <p>
  hi lets make this content non editable
  </p>
  </div>
</div>

contenteditable = false只需在此属性上赋予该属性即可。

标识为new的

div处于只读模式。

相关问题