簡體   English   中英

如何在 JSF 上使用 Markdown 編輯器 - Primefaces

[英]How to use a markdown editor on JSF - Primefaces

有人知道如何在 JSF 上使用 Markdown 編輯器嗎? 我知道這是可能的。

我嘗試了這些東西,但我無法讓它們工作。

http://markitup.jaysalvat.com/home/

http://toopay.github.io/bootstrap-markdown/

http://epiceditor.com/#step-4-init-epiceditor

如果您能創建一個小示例,我將不勝感激。

謝謝!!

存在已經基於庫 ButterFaces 中提到的 Bootstrap Markdown 完成 Markdown 語法的 JSF 實現。 只需將下一個依賴項添加到 Maven 項目:

<dependency>
  <groupId>org.butterfaces</groupId>
  <artifactId>components</artifactId>
  <version>3.4.0</version>
</dependency>

然后你可以像這樣在 JSF 頁面中使用它:

<!DOCTYPE html> 
<html xmlns="http://www.w3.org/1999/xhtml" 
      xmlns:h="http://xmlns.jcp.org/jsf/html" 
      xmlns:f="http://xmlns.jcp.org/jsf/core" 
      xmlns:b="http://butterfaces.org/components"> 
<h:head /> 
<body>
    <h:form id="formId">
        <b:markdown id="input"
                    label="label"
                    hideLabel="false"
                    value="Hallo & < > "
                    tooltip="tooltip"
                    readonly="false"
                    required="false"
                    disabled="false"
                    placeholder="Enter text..."
                    language="en"
                    autoFocus="false"
                    rendered="true">
        </b:markdown>
    </h:form> 
</body> 
</html>

該組件的來源可以在GitHub找到

文檔

使用http://markitup.jaysalvat.com/home/

下載它並將 css 和 js 文件添加到您的 JSF Header 中!

現在假設你有一個像這樣形式的 textarea:

<h:form id="formID">
    <h:inputTextarea id="textAreaID" cols="10" rows="10" value="#{yourbean.textareaValue}"  >
    </h:inputTextarea>

然后通過 JQuery 以這種方式指向它:

$('#formID\\:textAreaID').markItUp(yourSettings);

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM