Skip to content

Commit

Permalink
First commit 🔥
Browse files Browse the repository at this point in the history
  • Loading branch information
Christopher Blum committed Jun 20, 2011
0 parents commit 5a484fa
Show file tree
Hide file tree
Showing 88 changed files with 19,961 additions and 0 deletions.
16 changes: 16 additions & 0 deletions .tm_sync.config
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
#
# Change the configuration below to match your setup
# You have to setup ssh public key authentication in order for this to work,
# as we need to be able to copy stuff without entering a password everytime.
#
REMOTE_HOST="your.server.tld"
REMOTE_PORT="22"
REMOTE_USER="username"
REMOTE_PATH="/remote/directory"

# Here you can parse options on to rsync if you e.g. want to exclude files
RSYNC_OPTIONS="--exclude blib --exclude _build --exclude Makefile --exclude Build"

# Use the rsync option below with caution, as it replaces the remote directory
# with the contents of your project.
#RSYNC_OPTIONS="--delete"
7 changes: 7 additions & 0 deletions LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
Copyright (C) 2009 XING AG

This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 3 of the License, or any later version.

This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.

You should have received a copy of the GNU General Public License along with this program; if not, see <http://www.gnu.org/licenses/>.
65 changes: 65 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
VERSION = $(shell cat version.txt)

JS_OUTPUT = "dist/wysihtml5-${VERSION}.js"

JS_FILES = lib/rangy/rangy-core.js \
lib/rangy/rangy-cssclassapplier-wysihtml5.js \
src/wysihtml5.js \
src/browser_support.js \
src/utils/auto_focus.js \
src/utils/auto_link.js \
src/utils/caret.js \
src/utils/contains.js \
src/utils/convert_into_list.js \
src/utils/copy_styles.js \
src/utils/copy_attributes.js \
src/utils/get_in_dom_element.js \
src/utils/get_parent_element.js \
src/utils/get_style.js \
src/utils/has_element_with_tag_name.js \
src/utils/has_element_with_class_name.js \
src/utils/insert_rules.js \
src/utils/observe.js \
src/utils/resolve_list.js \
src/utils/rename_element.js \
src/utils/remove_empty_text_nodes.js \
src/utils/sandbox.js \
src/utils/sanitize_html.js \
src/utils/simulate_placeholder.js \
src/utils/synchronizer.js \
src/utils/text_content.js \
src/utils/unwrap.js \
src/quirks/clean_pasted_html.js \
src/quirks/ensure_proper_clearing.js \
src/quirks/insert_line_break_on_return.js \
src/quirks/redraw.js \
src/views/view.js \
src/views/composer.js \
src/views/composer.style.js \
src/views/composer.observe.js \
src/views/textarea.js \
src/toolbar/dialog.js \
src/toolbar/speech.js \
src/toolbar/toolbar.js \
src/commands.js \
src/commands/bold.js \
src/commands/createLink.js \
src/commands/fontSize.js \
src/commands/foreColor.js \
src/commands/formatBlock.js \
src/commands/formatInline.js \
src/commands/insertHTML.js \
src/commands/insertImage.js \
src/commands/insertLineBreak.js \
src/commands/insertOrderedList.js \
src/commands/insertUnorderedList.js \
src/commands/italic.js \
src/commands/justifyCenter.js \
src/commands/justifyLeft.js \
src/commands/justifyRight.js \
src/commands/underline.js \
src/editor.js

all:
@@rm ${JS_OUTPUT}
@@cat ${JS_FILES} >> ${JS_OUTPUT}
124 changes: 124 additions & 0 deletions README.textile
Original file line number Diff line number Diff line change
@@ -0,0 +1,124 @@
h1. wysihtml5 0.1.0

wysihtml5 is an open source rich text editor based on HTML5 technology and the progressive-enhancement approach.
It uses a sophisticated security concept and aims to generate fully valid HTML5 markup by preventing unmaintainable tag-soups and inline-styles.
The editor is already in production use on "XING.com":https://www.xing.com - a social network with more than 10 million members.

h2. Features:

* Auto linking of urls as-you-type
* Generates valid and semantic HTML5 markup (no _<font>_)
* Uses class-names instead of inline styles
* Unifies line-break handling across browsers (hitting enter will create _<br>_ instead of _<p>_ or _<div>_)
* Auto-parses content inserted via copy & paste (from Word, Powerpoint, PDF, other web pages, ...)
* Converts invalid or unknown html tags into valid/similar tags
* Source code view for users with HTML skills
* Uses sandboxed iframes in order to prevent identity theft through XSS
* Editor inherits styles and attributes (placeholder, autofocus, ...) from original textarea (you only have to style one element)

h2. Browser Support

The rich text editing interface is supported in IE8+, FF 3.5+, Safari 4+, Opera 11+ and Chrome.
*Graceful Degradation:* Users with other browsers will see the textarea and are still able write plain HTML by themselves.
As of now iOS and Android don’t support rich text editing properly. For now they are treated like IE 6+7.

h2. Configuration

Following is a list of all configuration options with their corresponding default values:

bc. new wysihtml5.Editor("textarea-id", {
// Give the editor a name, the name will also be set as class name on the iframe and on the iframe's body
name: null,
// Whether the editor should look like the textarea (by adopting styles)
style: true,
// Id of the toolbar element, pass falsey value if you don't want any toolbar logic
toolbar: null,
// Whether urls, entered by the user should automatically become clickable-links
autoLink: true,
// Object which includes parser rules (set this to examples/rules/spec.json or your own spec, otherwise only span tags are allowed!)
parserRules: null,
// Parser method to use when the user inserts content via copy & paste
parser: wysihtml5.utils.sanitizeHTML || Prototype.K,
// Class name which should be set on the contentEditable element in the created sandbox iframe, can be styled via the 'stylesheets' option
composerClassName: "wysihtml5-editor",
// Class name to add to the body when the wysihtml5 editor is supported
bodyClassName: "wysihtml5-supported",
// Array (or single string) of stylesheet urls to be loaded in the editor's iframe
stylesheets: [],
// Placeholder text to use, defaults to the placeholder attribute on the textarea element
placeholderText: null,
// Whether the composer should allow the user to manually resize images, tables etc.
allowObjectResizing: true
});

h2. Events

The editor comes with a simple event handling:

bc. var editor = new wyishtml5.Editor("textarea-id", { ... });
editor.observe("change", function() {
alert("The content of the editor has changed")
});

editor.observe("load", function() {
alert("wysihtml5 is ready for take off!");
});

List of supported events:
* _load_ - when the editor is fully loaded
* _beforeload_ - for internal use only
* _focus_ - when the editor (regardless if rich text or source view) receives focus
* _focus:composer_ - when the rich text view receives focus
* _focus:textarea_ - when the source view receives focus
* _blur_ - when the editor (regardless if rich text or source view) gets blurred
* _blur:composer_ - when the rich text view gets blurred
* _blur:textarea_ - when the source view gets blurred
* _change_ - when the value changed (regardless if rich text or source view)
* _change:composer_ - when the value of the rich text view got changed
* _change:textarea_ - when the value of the source view got changed
* _paste_ - when the user pastes or drops content (regardless if rich text or source view)
* _paste:composer_ - when the user pastes or drops content into the rich text view
* _paste:textarea_ - when the user pastes or drops content into the source view
* _newword:composer_ - when the user wrote a new word in the rich text view
* _destroy:composer_ - when the rich text view gets removed
* _change_view_ - when switched between source and rich text view

h2. Progressive-Enhancement/Initialization Step By Step

# Takes a _<textarea>_
# Checks whether the browser supports rich text editing properly (stops here if not)
# Sets a class "wysihtml5-supported" on the _<body>_ of the page (can be used to toggle text hints on the page via CSS)
# Creates an inline _<iframe>_ with _<body contenteditable="true">_
# Copies textarea box styles (float, border, position, box-shadow, ...) to the
_<iframe>_
# Copies textarea text styles (color, font-size, font-family, text-indent, ...) to
the iframe's _<body>_
# Copies several attributes (spellcheck, autofocus, placeholder, className, title, ...)
from the _<textarea>_ to the iframe's _<body>_
# Checks whether HTMl5 autofocus and placeholder attributes are set and
simulates their logic on the iframe's _<body>_
# Hides the _<textarea>_
# Initializes sync logic (text you typed into the iframe's _<body>_ is automatically
copied to the hidden _<textarea>_)
# Observes the form's "onsubmit" and "onreset" events and simulates their
behavior on the iframe's _<body>_
# Checks whether a toolbar is given and sets event listeners on it's link

h2. Research Material

Before starting this library we spent a lot of time investigating the different browsers and their behaviors.

Check this repository:
"https://github.com/tiff/wysihtml5-tests":https://github.com/tiff/wysihtml5-tests

A compatibility table for rich text query commands can be found here:
"http://tifftiff.de/contenteditable/compliance_test.html":http://tifftiff.de/contenteditable/compliance_test.html

A pure native rich text editor with HTML validator and live source preview is here:
"http://tifftiff.de/contenteditable/editor.html":http://tifftiff.de/contenteditable/editor.html

h2. Contributors

* "@tiff":https://github.com/tiff
* "@ingochao":https://github.com/ingochao
* "@uwe":https://github.com/uwe
Loading

0 comments on commit 5a484fa

Please sign in to comment.