Skip to content
This repository has been archived by the owner on Mar 8, 2019. It is now read-only.

Commit

Permalink
wysihtml5 v0.2.0 - now library agnostic
Browse files Browse the repository at this point in the history
  • Loading branch information
Christopher Blum committed Jul 13, 2011
1 parent 64b67e3 commit 623afa8
Show file tree
Hide file tree
Showing 125 changed files with 10,554 additions and 8,329 deletions.
2 changes: 1 addition & 1 deletion LICENSE
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
Copyright (C) 2009 XING AG
Copyright (C) 2011 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.

Expand Down
82 changes: 53 additions & 29 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -2,41 +2,51 @@ 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 \
JS_FILES = src/wysihtml5.js \
lib/rangy/rangy-core.js \
lib/base/base.js \
src/browser.js \
src/lang/array.js \
src/lang/dispatcher.js \
src/lang/object.js \
src/lang/string.js \
src/dom/auto_link.js \
src/dom/class.js \
src/dom/contains.js \
src/dom/convert_to_list.js \
src/dom/copy_attributes.js \
src/dom/copy_styles.js \
src/dom/delegate.js \
src/dom/get_as_dom.js \
src/dom/get_parent_element.js \
src/dom/get_style.js \
src/dom/has_element_with_tag_name.js \
src/dom/has_element_with_class_name.js \
src/dom/insert.js \
src/dom/insert_css.js \
src/dom/observe.js \
src/dom/parse.js \
src/dom/remove_empty_text_nodes.js \
src/dom/rename_element.js \
src/dom/replace_with_child_nodes.js \
src/dom/resolve_list.js \
src/dom/sandbox.js \
src/dom/set_attributes.js \
src/dom/set_styles.js \
src/dom/simulate_placeholder.js \
src/dom/text_content.js \
src/quirks/clean_pasted_html.js \
src/quirks/ensure_proper_clearing.js \
src/quirks/get_correct_inner_html.js \
src/quirks/insert_line_break_on_return.js \
src/quirks/redraw.js \
src/selection/selection.js \
src/selection/html_applier.js \
src/views/view.js \
src/views/composer.js \
src/views/composer.style.js \
src/views/composer.observe.js \
src/views/synchronizer.js \
src/views/textarea.js \
src/toolbar/dialog.js \
src/toolbar/speech.js \
Expand All @@ -60,6 +70,20 @@ JS_FILES = lib/rangy/rangy-core.js \
src/commands/underline.js \
src/editor.js

all:
all: bundle minify

bundle:
@@echo "Bundling..."
@@touch ${JS_OUTPUT}
@@rm ${JS_OUTPUT}
@@cat ${JS_FILES} >> ${JS_OUTPUT}
@@cat ${JS_FILES} >> ${JS_OUTPUT}
@@cat ${JS_OUTPUT} | sed "s/@VERSION/${VERSION}/" > "${JS_OUTPUT}.tmp"
@@mv "${JS_OUTPUT}.tmp" ${JS_OUTPUT}

minify:
@@echo "Minifying... (this requires node.js)"
@@node build/minify.js ${JS_OUTPUT}
@@echo "Done."

unittest:
@@open test/index.html
24 changes: 20 additions & 4 deletions README.textile
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
h1. wysihtml5 0.1.0
h1. wysihtml5 0.2.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.
It uses a sophisticated security concept and aims to generate fully valid HTML5 markup by preventing unmaintainable tag soups and inline styles.
The code is completely library agnostic: No jQuery, Prototype or similar is required.
The editor is already in use on "XING.com":https://www.xing.com - a social network with more than 10 million members.

h2. Features:

Expand All @@ -15,6 +16,7 @@ h2. Features:
* 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)
* Speech-input for Chrome 11+

h2. Browser Support

Expand Down Expand Up @@ -44,7 +46,7 @@ Following is a list of all configuration options with their corresponding defaul
// 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,
parser: wysihtml5.dom.parse || 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
Expand Down Expand Up @@ -113,6 +115,20 @@ copied to the hidden <code><textarea></code>)
behavior on the iframe's <code><body></code>
# Checks whether a toolbar is given and sets event listeners on it's link

h2. How to build your own wysihtml5 files

Clone and build the js file:
<code>
git clone git://github.com/xing/wysihtml5.git
cd wysihtml5
make
</code>

Run the unit tests:
<code>
make unittest
</code>

h2. Research Material

Before starting this library we spent a lot of time investigating the different browsers and their behaviors.
Expand Down
82 changes: 82 additions & 0 deletions build/minify.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,82 @@
var script = process.argv[2],
http = require("http"),
queryString = require("querystring"),
fs = require("fs");

if (!script) {
throw "No script url given";
}

function post(code, callback) {
// Build the post string from an object
var postData = queryString.stringify({
compilation_level: "SIMPLE_OPTIMIZATIONS",
output_format: "text",
output_info: "compiled_code",
warning_level: "QUIET",
js_code: code
});

// An object of options to indicate where to post to
var postOptions = {
host: "closure-compiler.appspot.com",
port: "80",
path: "/compile",
method: "POST",
headers: {
"Content-Type": "application/x-www-form-urlencoded",
"Content-Length": postData.length
}
};

// Set up the request
var request = http.request(postOptions, function(response) {
var responseText = [];
response.setEncoding("utf8");
response.on("data", function(data) {
responseText.push(data);
});
response.on("end", function() {
callback(responseText.join(""));
});
});

// Post the data
request.write(postData);
request.end();
}

function readFile(filePath, callback) {
// This is an async file read
fs.readFile(filePath, "utf-8", function (err, data) {
if (err) {
// If this were just a small part of the application, you would
// want to handle this differently, maybe throwing an exception
// for the caller to handle. Since the file is absolutely essential
// to the program's functionality, we're going to exit with a fatal
// error instead.
console.log("FATAL An error occurred trying to read in the file: " + err);
process.exit(-2);
}
// Make sure there's data before we post it
if (data) {
callback(data);
} else {
console.log("No data to post");
process.exit(-1);
}
});
}

function writeFile(filePath, data, callback) {
fs.writeFile(filePath, data, "utf-8", callback);
}


// Ok GO!
readFile(script, function(code) {
post(code, function(code) {
var output = script.replace(/\.js/, ".min.js");
writeFile(output, code);
});
});
Loading

0 comments on commit 623afa8

Please sign in to comment.