gpt4 book ai didi

jsf - 在 p :textEditor 中添加或附加文本

转载 作者:行者123 更新时间:2023-12-03 21:52:13 24 4
gpt4 key购买 nike

我有 p:textEditor像下面这样

<p:textEditor 
id="editor"
widgetVar="editor"
value="#{xxxController.editorText}"
height="300"
placeholder="Enter your content"
toolbarVisible="false"/>
使用以下命令按钮将值添加/附加到 p:textEditor
<p:commandButton onclick="insertTag('[myValue]')" value="myValue" type="button" />

JavaScript
<script>

function insertTag( t )
{
PF( 'editor' ).insertText( t ) ;
}
</script>
但我得到 SCRIPT5007: Unable to get property 'insertText' of undefined or null reference当我尝试单击 <p:commandButton 时.
那么我们如何使用 widgetVar 或 JavaScript 将文本插入/附加到 p:textEditor ?
版本详情
JSF 2.2,
PrimeFaces 6.2

最佳答案

你需要这样做......一旦你有了小部件,“编辑器”变量就是 QuillJS 对象。

PF('editor').editor.insertText(0, 'Hello', 'bold', true);
见: https://quilljs.com/docs/api/#inserttext
见: https://quilljs.com/docs/api/#getlength

关于jsf - 在 p :textEditor 中添加或附加文本,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/62593793/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com