Tiny bootstrap-compatible WISWYG rich text editor

Overview

bootstrap-wysiwyg

Important information for Github requests/issues

Please do not submit issues/comments to this repo. Instead, submit it to

https://github.com/steveathon/bootstrap-wysiwyg

Although this is the original repository, we need the project to be tiny and focused on the needs of the MindMup tool, which means that we do not want to complicate it with all the various bits and pieces needed for other usages and older browsers.

Meanwhile, Steve was kind enough to create a fork, backport it to older browsers, extend and integrate all kinds of changes. Steve's fork does not need to stay small, slim and focused, so please use his repo for all your needs if this plugin does provide out of the box

About the editor

Tiny bootstrap-compatible WISWYG rich text editor, based on browser execCommand, built originally for MindMup. Here are the key features:

  • Automatically binds standard hotkeys for common operations on Mac and Windows
  • Drag and drop files to insert images, support image upload (also taking photos on mobile devices)
  • Allows a custom built toolbar, no magic markup generators, enabling the web site to use all the goodness of Bootstrap, Font Awesome and so on...
  • Does not force any styling - it's all up to you
  • Uses standard browser features, no magic non-standard code, toolbar and keyboard configurable to execute any supported browser command
  • Does not create a separate frame, backup text areas etc - instead keeps it simple and runs everything inline in a DIV
  • (Optionally) cleans up trailing whitespace and empty divs and spans
  • Requires a modern browser (tested in Chrome 26, Firefox 19, Safari 6)
  • Supports mobile devices (tested on IOS 6 Ipad/Iphone and Android 4.1.1 Chrome)

Basic Usage

See http://mindmup.github.com/bootstrap-wysiwyg/

Customising

You can assign commands to hotkeys and toolbar links. For a toolbar link, just put the execCommand command name into a data-edit attribute. For more info on execCommand, see http://www.quirksmode.org/dom/execCommand.html and https://developer.mozilla.org/en/docs/Rich-Text_Editing_in_Mozilla

<div class="btn-toolbar" data-role="editor-toolbar" data-target="#editor">
  <a class="btn btn-large" data-edit="bold"><i class="icon-bold"></i></a>
</div>

To pass arguments to a command, separate a command with a space.

  <a data-edit="fontName Arial">...</a>

You can also use input type='text' with a data-edit attribute. When the value is changed, the command from the data-edit attribute will be applied using the input value as the command argument

<input type="text" data-edit="createLink">

If the input type is file, when a file is selected the contents will be read in using the FileReader API and the data URL will be used as the argument

<input type="file" data-edit="insertImage">

To change hotkeys, specify the map of hotkeys to commands in the hotKeys option. For example:

$('#editor').wysiwyg({
  hotKeys: {
    'ctrl+b meta+b': 'bold',
    'ctrl+i meta+i': 'italic',
    'ctrl+u meta+u': 'underline',
    'ctrl+z meta+z': 'undo',
    'ctrl+y meta+y meta+shift+z': 'redo'
  }
});

Styling for mobile devices

This editor should work pretty well with mobile devices, but you'll need to consider the following things when styling it:

  • keyboards on mobile devices take a huge part of the screen
  • having to scroll the screen to touch the toolbar can cause the editing component to lose focus, and the mobile device keyboard might go away
  • mobile devices tend to move the screen viewport around to ensure that the focused element is shown, so it's best that the edit box is glued to the top

For the content attachment editor on MindMup, we apply the following rules to mobile device styling:

  • edit box is glued to the top, so the focus doesn't jump around
  • toolbar is below the edit box
  • on portrait screens, edit box size is 50% of the screen
  • on landscape screens, edit box size is 30% of the screen
  • as the screen gets smaller, non-critical toolbar buttons get hidden into a "other" menu

Dependencies

Comments
  • Multiple instances

    Multiple instances

    If you have a bunch of divs on the page with the same class ( .rte for instance), and apply the .wysiwyg method to them, they work perfectly with the hotkeys but the buttons don't work.

    If however, you apply a div to each one ( #rte1 #rte2 etc) it does work. This is OK, and for me I can easily do that programmatically in the flow of my application. But it's not standard and caused a little bit of confusion for me, and perhaps a lot of hair pulling for others.

    opened by chrisharrison 12
  • cleanHtml() adds html to the editor pane when dialog is open

    cleanHtml() adds html to the editor pane when dialog is open

    hi, my scenario: i'm using the editor part, and upon pressing command+p, i pop open a dialog. additionally, on every keyup i launch a callback to "save" my text using a call to editor.cleanHtml().

    when pressing command+p, the dialog window opens, and then cleanHtml get called due to keyup - and for some reason, the call to $(this).html() actually pastes the html into the editor itself ?!

    any ideas why and what can be a workaround?

    thx!

    opened by shie-erlich 5
  • Editor inside a modal window

    Editor inside a modal window

    When I open a modal window with an editor in it, I can't type in the editor - at the first keystroke, the Bold button lights up (first button in my toolbar) and that's it. No text can be typed into the editor.

    If I dismiss the modal and re-open it, everything works perfectly.

    Any idea what could be going on? I can provide more info at request - just don't know what would be helpful here...

    opened by joshorvis 4
  • Hotkeys dependency

    Hotkeys dependency

    It is mentioned in the docs that jQuery HotKeys is a dependency. But I interpreted this as "a dependency - if you intend to use the hotkey feature" ... and without it, the core functionality would still work. This is a standard terminology that other libraries use.

    It took me a while to realise that the jQuery HotKeys REALLY is a dependency. i.e. the whole thing relies on it. I think this should be made very, very clear in the instructions/documentation.

    opened by chrisharrison 4
  • Multiply editor instance and toolbars

    Multiply editor instance and toolbars

    <div class="btn-toolbar" data-role="editor-toolbar" data-target="#descriptionEn">
    ...
    </div>
    <div id="descriptionEn" name="descriptionEn"></div>
    
    <div class="btn-toolbar" data-role="editor-toolbar" data-target="#descriptionRu">
    ...
    </div>
    <div id="descriptionRu" name="descriptionRu"></div>
    

    Both toolbars are working in one mode

    opened by indapublic 3
  • Typo in Font-Awesome

    Typo in Font-Awesome

    Hi !

    I have made some critical bugfixes for your project : There was a typo in Font-Awesome name in your About & Readme.

    Yes, I know...

    See you, Thomas.

    opened by tzi 3
  • When hovering a button, the buttons at the right move

    When hovering a button, the buttons at the right move

    When I move over a button I clearly see all the buttons on his right move. I'm using firefox 20 on Fedora 18.

    Usually a .btn-group .btn has a computed left margin of -1px When hovering a .btn, the .btn next to him pass from having a margin-left of -1px to a margin-left of 0px, resulting in the visible effect of all the next buttons to move on the right.

    opened by riquito 3
  • Multiple Editors on one page

    Multiple Editors on one page

    Each editor has a data-target specific to the editor div (by id), but whenever I edit one, like add a bullet point, it adds the bullet point to all of them.

    So, for instance

    <div class="btn-toolbar" data-role="editor-toolbar" data-target="#editor1">
        <div class="btn-group">
            <a class="btn btn-default" data-edit="bold" data-original-title="Bold (Ctrl/Cmd+B)" title="Bold"><i class="fa fa-bold"></i></a>
            <a class="btn btn-default" data-edit="italic" data-original-title="Italic (Ctrl/Cmd+I)" title="Italic"><i class="fa fa-italic"></i></i></a>
            <a class="btn btn-default" data-edit="underline" data-original-title="Underline (Ctrl/Cmd+U)" title="Underline"><i class="fa fa-underline"></i></i></a>
        </div>
    </div>
    <div id="editor1"></div>
    <textarea class="form-control body-description hidden" id="hidden-editor" name="description"></textarea> <!-- editor html goes into here via jQuery, works great -->
    
        $('#editor1').wysiwyg();
    

    Then I have a second instance, all the same stuff, except the id is editor2 instead of editor1, then editor3, editor4, etc... but all of them seem to target eachother regardless of whatever I set the data target to?

    Help?

    opened by ayyobro 2
  • Merging latest push

    Merging latest push

    Here's the latest push from 12 developers fixing some problems.

    There are three open issues.

    This will close #171 #172 #157 (We added requirements, but we'll fix silent failure later) and clarifies use of #159 #149 #147 #143 #141 #140 #138 #52 #138 #136 #134 #135 (Updated) #133 #116 (The reason I got onto this project) #112 #113 #113 (Updated) #109 #101 #91 #86 #83 ( in 5f46909132a10fae95667d586f361b477b7cd09d ) #65 #61 (Appears to be working) #48 #40 #23 and #19

    Should close #167 #164 (by adding multiple input support)

    opened by steveathon 2
  • Multiple instance, single toolbar

    Multiple instance, single toolbar

    Good morning everyone,

    I'm using this plugin in a page that contains multiple instances of the editor (dynamically created, one fixed), but I need to have a single toolbar dynamically binded into the correct editor (I'm using Knockout 3.2).

    I've already read issue #52 (https://github.com/mindmup/bootstrap-wysiwyg/issues/52) (expecially Makusu answer) and I've binded the code as below:

    $('.editor').wysiwyg({ toolbarSelector: '[data-role=editor-toolbar]'} );

    and for the toolbar

    < div data-role="editor-toolbar" data-bind="attr: {'data-target' : $root.toolbarBind}" >

    where $root.toolbarBind is the ID of the editor selected.

    However, when I click some button on the toolbar, it modifies only the first of the editors, the fixed one. If I use the keyboard shortcut, they work flawlessy.

    What could possibly went wrong?

    opened by CoachGodzup 2
  • Listing on a cdn?

    Listing on a cdn?

    Hi

    Love the script, light weight, works great! Glad I switched to bootstrap :+1:

    Can you get your script on one of the cdn's? Would be great since I am trying to develop with hosting as little js/css files as I can.

    https://github.com/cdnjs/cdnjs

    Added you to my project, will link soon: https://github.com/gcphost/l4-bootstrap-admin

    opened by gcphost 2
  • Buttons update unexpectedly (mouseout)

    Buttons update unexpectedly (mouseout)

    With the WYSIWYG editor, if you select outside of the text area and then mouse over the WYSIWYG area, the buttons update to show the state of whatever the current selection is. This is because of editor.attr('contenteditable', true).on('mouseup keyup mouseout', function () { Removing the mouseout from that line fix's the issue, but im not sure if it breaks some functionality.

    opened by CynderR 0
  • How to populate the editor div with formatted text?

    How to populate the editor div with formatted text?

    I am struggling to get html formatted texct inside the editor (i.e. from database), then edit the text and save it back to the db. Any working example?

    opened by paulgodard 1
  • how to change div to p tag

    how to change div to p tag

    I am using the editor with Bootstrap and FontAwesome 4. Just a few changes from the example and it works great. When typing 2 lines of text separated by CR inside the editor the html output is: line one<div>line two</div> Is it possible to force the editor for a paragraph tag instead of a div tag and also tagging the first line so the output would be: <p>line one</p><p>line two</p> Of course, it is possible with JS but is there another way?

    opened by paulgodard 0
Owner
MindMup
MindMup
Simple rich text editor (contentEditable) for jQuery UI

Hallo - contentEditable for jQuery UI Hallo is a very simple in-place rich text editor for web pages. It uses jQuery UI and the HTML5 contentEditable

Henri Bergius 2.4k Dec 17, 2022
A modern, simple and elegant WYSIWYG rich text editor.

jQuery-Notebook A simple, clean and elegant WYSIWYG rich text editor for web aplications Note: Check out the fully functional demo and examples here.

Raphael Cruzeiro 1.7k Dec 12, 2022
Medium.com WYSIWYG editor clone. Uses contenteditable API to implement a rich text solution.

If you would be interested in helping to maintain one of the most successful WYSIWYG text editors on github, let us know! (See issue #1503) MediumEdit

yabwe 15.7k Jan 4, 2023
HTML5 rich text editor. Try the demo integration at

Squire Squire is an HTML5 rich text editor, which provides powerful cross-browser normalisation in a flexible lightweight package (only 16.5KB of JS a

Neil Jenkins 4.4k Dec 28, 2022
A rich text editor for everyday writing

Trix A Rich Text Editor for Everyday Writing Compose beautifully formatted text in your web application. Trix is a WYSIWYG editor for writing messages

Basecamp 17.3k Jan 3, 2023
Open source rich text editor based on HTML5 and the progressive-enhancement approach. Uses a sophisticated security concept and aims to generate fully valid HTML5 markup by preventing unmaintainable tag soups and inline styles.

This project isn’t maintained anymore Please check out this fork. wysihtml5 0.3.0 wysihtml5 is an open source rich text editor based on HTML5 technolo

Christopher Blum 6.5k Jan 7, 2023
Popline is an HTML5 Rich-Text-Editor Toolbar

popline Popline is a non-intrusive WYSIWYG editor that shows up only after selecting a piece of text on the page, inspired by popclip. Usage Load jQue

kenshin 1k Nov 4, 2022
Open source rich text editor based on HTML5 and the progressive-enhancement approach. Uses a sophisticated security concept and aims to generate fully valid HTML5 markup by preventing unmaintainable tag soups and inline styles.

This project isn’t maintained anymore Please check out this fork. wysihtml5 0.3.0 wysihtml5 is an open source rich text editor based on HTML5 technolo

Christopher Blum 6.5k Dec 30, 2022
A powerful WYSIWYG rich text web editor by pure javascript

KothingEditor A powerful WYSIWYG rich text web editor by pure javascript Demo : kothing.github.io/editor The KothingEditor is a lightweight, flexible,

Kothing 34 Dec 25, 2022
The world's #1 JavaScript library for rich text editing. Available for React, Vue and Angular

TinyMCE TinyMCE is the world's most advanced open source core rich text editor. Trusted by millions of developers, and used by some of the world's lar

Tiny 12.4k Jan 4, 2023
A completely customizable framework for building rich text editors. (Currently in beta.)

A completely customizable framework for building rich text editors. Why? · Principles · Demo · Examples · Documentation · Contributing! Slate lets you

Ian Storm Taylor 26.2k Dec 30, 2022
Collection of tools for building rich text editors.

psst we have great documentation at https://bangle.dev What is bangle.dev ? bangle.dev is a collection of components for building powerful editing exp

null 553 Dec 29, 2022
A markdown editor. http://lab.lepture.com/editor/

Editor A markdown editor you really want. Sponsors Editor is sponsored by Typlog. Overview Editor is not a WYSIWYG editor, it is a plain text markdown

Hsiaoming Yang 2.8k Dec 19, 2022
A chrome extension which helps change ace editor to monaco editor in web pages, supporting all features including autocompletes.

Monaco-It Monaco-It is a chrome extension turning Ace Editor into Monaco Editor, supporting all features including autocompletes. 一些中文说明 Supported Lan

null 3 May 17, 2022
Typewriter is a simple, FOSS, Web-based text editor that aims to provide a simple and intuitive environment for you to write in.

Typewriter Typewriter is a simple, FOSS, Web-based text editor that aims to provide a simple and intuitive environment for you to write in. Features S

Isla 2 May 24, 2022
Verbum is a fully flexible text editor based on lexical framework.

Verbum Verbum - Flexible Text Editor for React Verbum is a fully flexible rich text editor based on lexical-playground and lexical framework. ⚠️ As th

Ozan Yurtsever 560 Dec 29, 2022
The next generation Javascript WYSIWYG HTML Editor.

Froala Editor V3 Froala WYSIWYG HTML Editor is one of the most powerful JavaScript rich text editors ever. Slim - only add the plugins that you need (

Froala 5k Jan 1, 2023
Ace (Ajax.org Cloud9 Editor)

Ace (Ajax.org Cloud9 Editor) Note: The new site at http://ace.c9.io contains all the info below along with an embedding guide and all the other resour

Ajax.org B.V. 25.2k Jan 4, 2023
In-browser code editor

CodeMirror CodeMirror is a versatile text editor implemented in JavaScript for the browser. It is specialized for editing code, and comes with over 10

CodeMirror 25.6k Dec 30, 2022