跳至內容 跳至搜尋

Action Text

Action Text 為 Rails 帶來了豐富的文字內容和編輯功能。它包含 Trix 編輯器,可以處理從格式到連結、引用、列表、嵌入式圖片和圖庫的所有內容。Trix 編輯器產生的豐富文字內容會儲存在它自己的 RichText 模型中,該模型與應用程式中任何現有的 Active Record 模型相關聯。任何嵌入的圖片(或其他附件)都會使用 Active Storage 自動儲存,並與包含的 RichText 模型相關聯。

您可以在 Action Text 概覽 指南中閱讀更多關於 Action Text 的資訊。

開發

Action Text 的 JavaScript 以 npm 模組(在 @rails/actiontext 下)和透過資源管道作為 actiontext.js(並且我們將 Trix 鏡像為 trix.js)兩種方式發佈。為了確保後者保持同步,您必須在 JavaScript 來源或 Trix 相依性更新時執行 yarn build 並提交構件。CSS 變更必須手動帶到 app/assets/stylesheets/trix.css

授權

Action Text 根據 MIT 授權 發佈。

命名空間
方法
G
H
V

類別公開方法

gem_version()

Gem::Version 的形式返回目前載入的 Action Text 版本。

# File actiontext/lib/action_text/gem_version.rb, line 7
def self.gem_version
  Gem::Version.new VERSION::STRING
end

html_document_class()

# File actiontext/lib/action_text.rb, line 47
def html_document_class
  return @html_document_class if defined?(@html_document_class)
  @html_document_class =
    defined?(Nokogiri::HTML5) ? Nokogiri::HTML5::Document : Nokogiri::HTML4::Document
end

html_document_fragment_class()

# File actiontext/lib/action_text.rb, line 53
def html_document_fragment_class
  return @html_document_fragment_class if defined?(@html_document_fragment_class)
  @html_document_fragment_class =
    defined?(Nokogiri::HTML5) ? Nokogiri::HTML5::DocumentFragment : Nokogiri::HTML4::DocumentFragment
end

version()

Gem::Version 的形式返回目前載入的 Action Text 版本。

# File actiontext/lib/action_text/version.rb, line 9
def self.version
  gem_version
end