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

标签 jsf primefaces text-editor

我有 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/

相关文章:

java - 我如何分配 s :link to a ui:param value field?

jquery - PrimeFaces p :inputText and p:inputTextarea rendering too wide in a p:panelGrid form

java - 如何更改outputText的值?

plugins - Vim(Windows)-新的帮助文件不起作用

regex - 在 Notepad++ 中多行搜索和替换每行的开头和结尾

java - p :dataTable - refresh datatable after delete row

java - 文件上传后如何加载JSF页面?

jsf - PrimeFaces 对话框引用父级

jsf-2 - 移动站点前缀和jsf 2

文本字段上的 Flutter 滚动条