我正在使用FROALA构建电子邮件模板。 我不想让用户有权编辑它的一部分。 有没有办法阻止用户编辑部分内容?
谢谢。
答案 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/
如果要再次激活它,可以执行以下操作:
$('#froala-editor').froalaEditor('edit.on');
答案 3 :(得分:0)
需求可以是2种类型:
HTML:
<div id="froala-editor">
</div>
JavaScript:
$('#froala-editor').froalaEditor({});
$('#froala-editor').froalaEditor('edit.off');
<div id="froala-editor">
<div id="new" contenteditable="false">
<p>
hi lets make this content non editable
</p>
</div>
</div>
contenteditable = false只需在此属性上赋予该属性即可。
标识为new的div处于只读模式。