bootstrap-wysihtml5

Simple, beautiful wysiwyg editor

  • 所有者: jhollingworth/bootstrap-wysihtml5
  • 平台:
  • 許可證: MIT License
  • 分類:
  • 主題:
  • 喜歡:
    0
      比較:

Github星跟蹤圖

This repo is no longer maintained. "bootstrap3-wysiwyg":https://github.com/bootstrap-wysiwyg/bootstrap3-wysiwyg is much better

h1. Overview

Bootstrap-wysihtml5 is a javascript plugin that makes it easy to create simple, beautiful wysiwyg editors with the help of "wysihtml5":https://github.com/xing/wysihtml5 and "Twitter Bootstrap":http://twitter.github.com/bootstrap/.

h1. Examples

  • "http://jhollingworth.github.com/bootstrap-wysihtml5":http://jhollingworth.github.com/bootstrap-wysihtml5/

h1. Quick Start

If you are using rails use the "bootstrap-wysihtml5-rails gem":http://rubygems.org/gems/bootstrap-wysihtml5-rails.

Otherwise, download "the latest version of bootstrap-wysihtml5":https://github.com/jhollingworth/bootstrap-wysihtml5/downloads.

h2. Files to reference

h2. Usage

You can get the html generated by getting the value of the text area, e.g.

h1. Advanced

h2. Options

An options object can be passed in to .wysihtml5() to configure the editor:

h3. Buttons

To override which buttons to show, set the appropriate flags:

h3. Custom Templates for Toolbar Buttons

To define custom templates for buttons, you can submit a customTemplates hash with the new definitions. Each entry should be a function which expects 'locale' and optional 'options' to manage the translations.

For example, the default template used for the editHtml mode button looks like this (with size fetched from the optional 'options')

You can change it to not use the pencil icon (for example) by defining the custom template like this:

This will override only the toolbar template for html, and all others will use the default.

h3. Stylesheets

It is possible to supply a number of stylesheets for inclusion in the editor <iframe>:

h3. Events

Wysihtml5 exposes a "number of events":https://github.com/xing/wysihtml5/wiki/Events. You can hook into these events when initialising the editor:

h3. Shallow copy by default, deep on request

Options you pass in will be added to the defaults via a shallow copy. (see "jQuery.extend()":http://api.jquery.com/jQuery.extend/ for details). You can use a deep copy instead (which is probably what you want if you're adding tags or classes to parserRules) via 'deepExtend', as in the parserRules example below.

h3. Parser Rules

If you find the editor is stripping out tags or attributes you need, then you'll want to extend (or replace) parserRules. This example extends the defaults to allow the and tags, and the class "middle":

There's quite a bit that can be done with parserRules; see "wysihtml5's advanced parser ruleset":https://github.com/xing/wysihtml5/blob/master/parser_rules/advanced.js for details. bootstrap-wysihtml5's default parserRules can be found "in the source":https://github.com/jhollingworth/bootstrap-wysihtml5/blob/master/src/bootstrap-wysihtml5.js (just search for 'parserRules' in the file).

h3. Defaults

You can change bootstrap-wysihtml5's defaults by altering:

This object has the same structure as the options object you pass in to .wysihtml5(). You can revert to the original defaults by calling:

Operations on the defaults are not thread-safe; if you're going to change the defaults, you probably want to do it only once, after you load the bootstrap-wysihtml plugin and before you start instantiating your editors.

h2. The underlying wysihtml5 object

You can access the "wysihtml5 editor object":https://github.com/xing/wysihtml5 like this:

h2. I18n

You can use Bootstrap-wysihtml5 in other languages. There are some translations available in the src/locales directory. You can include your desired one after the plugin and pass its key to the editor. Example:

It is possible to use custom translations as well. Just add a new key to $.fn.wysihtml5.locale before calling the editor constructor.

主要指標

概覽
名稱與所有者jhollingworth/bootstrap-wysihtml5
主編程語言JavaScript
編程語言Ruby (語言數: 3)
平台
許可證MIT License
所有者活动
創建於2012-03-19 22:26:50
推送於2020-04-14 20:13:56
最后一次提交2014-11-21 14:30:32
發布數0
用户参与
星數4.1k
關注者數173
派生數1k
提交數260
已啟用問題?
問題數241
打開的問題數163
拉請求數81
打開的拉請求數31
關閉的拉請求數44
项目设置
已啟用Wiki?
已存檔?
是復刻?
已鎖定?
是鏡像?
是私有?