XForms/CKEditor
外觀
< XForms
您希望能夠將 HTML 標記新增到 textarea 中。
我們將使用 CKEditor JavaScript 庫。此演示使用的是版本 3.2。
步驟
- 從以下網站下載原始碼:CKEditor 網站。
- 在您的本地檔案系統上解壓縮 zip 檔案
- 將 HTML 檔案中所有出現的 "&" 更改為 & a m p ; 並刪除 & n b s p ; 和 & c o p y ;,以使檔案成為格式良好的 XHTML 檔案,以便 eXist 可以索引它們。3.2 版本中的以下檔案需要修改
- ckeditor/CHANGES.html
- ckeditor/_source/plugins/wsc/dialogs/ciframe.html
- ckeditor/_source/plugins/wsc/dialogs/tmpFrameset.html
- ckeditor/plugins/wsc/dialogs/ciframe.html
- ckeditor/plugins/wsc/dialogs/tmpFrameset.html
- 將主 ckeditor 資料夾拖入 eXist。它應該立即索引所有 html 檔案並將所有非 XML 檔案(javascript、css 等)儲存為二進位制檔案。
- 注意:這似乎不可能。更改配置檔案以不編碼 XML。
未遵循上述步驟 3 將導致以下錯誤訊息
XMLDB exception caught: Failed to invoke method parse in class org.exist.xmlrpc.RpcConnection: org.xml.sax.SAXParseException: The entity name must immediately follow the '&' in the entity reference.
可以透過編輯 config.js 檔案來嘗試(參見 配置檔案引數 )
- 在 config.js 中新增以下行
- config.HtmlEncodeOutput = 'false';
- 用以下 sample_postdata.xq 替換 sample_postdata.php
在 _samples 資料夾中,您會發現幾個關於如何使用 CKEditor 的示例。這些 HTML 檔案中的每一個都包含一個包含以下行的 HTML 表單
<form action="sample_posteddata.xq" method="post">
以下程式可用作 sample_postdata.php 檔案的替代品。
sample_postdata.xq
xquery version "1.0";
declare option exist:serialize "method=xml media-type=text/xml omit-xml-declaration=yes indent=yes";
(: Get the content of the editor1 parameter :)
let $editor1 := request:get-parameter('editor1', '')
(: wrap the content in a div to make sure we have well-formed XML :)
let $wrapped-content := concat('<div>', $editor1, '</div>')
(: parse the escaped text so that we now have true XML markup :)
let $data-to-save := util:parse($wrapped-content)
return
<results>
{$data-to-save}
</results>
CKEditor 有很多 配置選項。它們透過編輯主 CKEditor 目錄中的 config.js 檔案來設定。
對 CKEditor 配置檔案進行以下更改應該可以工作,但似乎沒有正確的行為。
config.js
CKEDITOR.editorConfig = function( config )
{
// Define changes to default configuration here. For example:
// config.language = 'fr';
// config.uiColor = '#AADC6E';
// This should turn off encoding of the XML files as they are sent to the server
config.HtmlEncodeOutput = false;
config.entities = false;
};