Sha256: 5e9847677b13c53ddba1753f0794ae69559c9d725aba21cb00ba0ecf24a5a83f

Contents?: true

Size: 1.01 KB

Versions: 12

Compression:

Stored size: 1.01 KB

Contents

# shared helper methods for link editor and nest editor

format :html do
  def tinymce_id
    params[:tinymce_id]
  end

  private

  def tm_param key
    params[:"tm_snippet_#{key}"]
  end

  def modal_tm_snippet_editor?
    @tm_snippet_editor_mode != :overlay
  end

  def apply_tm_snippet_data snippet
    { "data-tinymce-id": tinymce_id }.tap do |data|
      apply_tm_snippet_vars data, snippet
      apply_tm_data_dismiss data
      apply_tm_data_index data
    end
  end

  def apply_tm_data_dismiss data
    data["data-bs-dismiss"] = "modal" if modal_tm_snippet_editor?
  end

  def apply_tm_data_index data
    data["data-index"] = params["index"] if params["index"].present?
  end

  def apply_tm_snippet_vars data, snippet
    apply_tm_snippet_var(data, :start) { tm_param :start }
    apply_tm_snippet_var(data, :size, :raw) { snippet.raw.size }
  end

  def apply_tm_snippet_var data, varname, paramname=nil
    return unless tm_param(paramname || varname).present?

    data[:"data-tm-snippet-#{varname}"] = yield
  end
end

Version data entries

12 entries across 12 versions & 1 rubygems

Version Path
card-mod-tinymce_editor-0.18.1 set/all/reference_editor.rb
card-mod-tinymce_editor-0.18.0 set/all/reference_editor.rb
card-mod-tinymce_editor-0.17.0 set/all/reference_editor.rb
card-mod-tinymce_editor-0.16.0 set/all/reference_editor.rb
card-mod-tinymce_editor-0.15.6 set/all/reference_editor.rb
card-mod-tinymce_editor-0.15.5 set/all/reference_editor.rb
card-mod-tinymce_editor-0.15.4 set/all/reference_editor.rb
card-mod-tinymce_editor-0.15.3 set/all/reference_editor.rb
card-mod-tinymce_editor-0.15.2.pre1 set/all/reference_editor.rb
card-mod-tinymce_editor-0.15.1.1 set/all/reference_editor.rb
card-mod-tinymce_editor-0.15.1 set/all/reference_editor.rb
card-mod-tinymce_editor-0.15.0 set/all/reference_editor.rb