From 5cd2946ec1125990e955c4b5257583f5b787a8a8 Mon Sep 17 00:00:00 2001 From: Oliver Pulges Date: Tue, 20 Oct 2015 15:53:41 +0300 Subject: [PATCH] Update version --- CHANGELOG.textile | 1 + README.markdown | 7 +- dist/wysihtml-toolbar.js | 2473 ++++++++++++++++++++++++++++++--- dist/wysihtml-toolbar.min.js | 17 +- dist/wysihtml-toolbar.min.map | 2 +- dist/wysihtml.js | 2452 +++++++++++++++++++++++++++++--- dist/wysihtml.min.js | 16 +- dist/wysihtml.min.map | 2 +- package.json | 10 +- 9 files changed, 4577 insertions(+), 403 deletions(-) diff --git a/CHANGELOG.textile b/CHANGELOG.textile index fa17c34..f7ac1c8 100644 --- a/CHANGELOG.textile +++ b/CHANGELOG.textile @@ -1,5 +1,6 @@ * wysihtml5x 0.5.0-beta14* (October 20, 2015) * Adds editor.destroy() method +* Adds alignJustifyStyle command * Adds IE Edge support * Fixes issue of inserting ā in windows * Fixes issue where wysihtml.js script has to be inside body (error if in head) diff --git a/README.markdown b/README.markdown index 7e1da54..8d9ed73 100644 --- a/README.markdown +++ b/README.markdown @@ -46,11 +46,12 @@ The rich text editing interface is supported in IE8+, FF 29+, Safari 4+, Safari ## Development -wysihtml can be built using Grunt. Installation instructions for [Grunt can be found here](http://gruntjs.com/getting-started). Once you have it installed, wysihtml can be built by simply running +wysihtml can be initialized and built using node package manager: - grunt + npm install + npm run build -This builds both minified and development versions, including one with toolbar support. +This adds dependencies (first line) and builds both minified and development versions (second line), including one with toolbar support. ## Contributors diff --git a/dist/wysihtml-toolbar.js b/dist/wysihtml-toolbar.js index ef0551b..0a291f5 100644 --- a/dist/wysihtml-toolbar.js +++ b/dist/wysihtml-toolbar.js @@ -1,5 +1,5 @@ /** - * @license wysihtml v0.5.0-beta13 + * @license wysihtml v0.5.0-beta14 * https://github.com/Voog/wysihtml * * Author: Christopher Blum (https://github.com/tiff) @@ -10,7 +10,7 @@ * */ var wysihtml5 = { - version: "0.5.0-beta13", + version: "0.5.0-beta14", // namespaces commands: {}, @@ -422,6 +422,18 @@ var wysihtml5 = { prevTxt = texts.shift(), curText = prevTxt ? texts.shift() : null; + if (felement && felement.nodeType === 3) { + fnode = felement; + foffset = felement.nodeValue.length; + felement = undefined; + } + + if (aelement && aelement.nodeType === 3) { + anode = aelement; + aoffset = 0; + aelement = undefined; + } + if ((anode === fnode && foffset < aoffset) || (anode !== fnode && (anode.compareDocumentPosition(fnode) & Node.DOCUMENT_POSITION_PRECEDING) && !(anode.compareDocumentPosition(fnode) & Node.DOCUMENT_POSITION_CONTAINS))) { fnode = [anode, anode = fnode][0]; foffset = [aoffset, aoffset = foffset][0]; @@ -463,9 +475,18 @@ var wysihtml5 = { }; Node.prototype.normalize = nf; }; - - if ("Node" in window && "normalize" in Node.prototype && normalizeHasCaretError()) { - normalizeFix(); + + var F = function() { + window.removeEventListener("load", F); + if ("Node" in window && "normalize" in Node.prototype && normalizeHasCaretError()) { + normalizeFix(); + } + }; + + if (doc.readyState !== "complete") { + window.addEventListener("load", F); + } else { + F(); } }; @@ -4139,181 +4160,2110 @@ wysihtml5.polyfills(window, document); range = api.createRange(this.win.document); range.setStartAndEnd(node, offset); } - this.setSingleRange(range, this.isBackward()); - }; - } + this.setSingleRange(range, this.isBackward()); + }; + } + + selProto.setStart = createStartOrEndSetter(true); + selProto.setEnd = createStartOrEndSetter(false); + + // Add select() method to Range prototype. Any existing selection will be removed. + api.rangePrototype.select = function(direction) { + getSelection( this.getDocument() ).setSingleRange(this, direction); + }; + + selProto.changeEachRange = function(func) { + var ranges = []; + var backward = this.isBackward(); + + this.eachRange(function(range) { + func(range); + ranges.push(range); + }); + + this.removeAllRanges(); + if (backward && ranges.length == 1) { + this.addRange(ranges[0], "backward"); + } else { + this.setRanges(ranges); + } + }; + + selProto.containsNode = function(node, allowPartial) { + return this.eachRange( function(range) { + return range.containsNode(node, allowPartial); + }, true ) || false; + }; + + selProto.getBookmark = function(containerNode) { + return { + backward: this.isBackward(), + rangeBookmarks: this.callMethodOnEachRange("getBookmark", [containerNode]) + }; + }; + + selProto.moveToBookmark = function(bookmark) { + var selRanges = []; + for (var i = 0, rangeBookmark, range; rangeBookmark = bookmark.rangeBookmarks[i++]; ) { + range = api.createRange(this.win); + range.moveToBookmark(rangeBookmark); + selRanges.push(range); + } + if (bookmark.backward) { + this.setSingleRange(selRanges[0], "backward"); + } else { + this.setRanges(selRanges); + } + }; + + selProto.saveRanges = function() { + return { + backward: this.isBackward(), + ranges: this.callMethodOnEachRange("cloneRange") + }; + }; + + selProto.restoreRanges = function(selRanges) { + this.removeAllRanges(); + for (var i = 0, range; range = selRanges.ranges[i]; ++i) { + this.addRange(range, (selRanges.backward && i == 0)); + } + }; + + selProto.toHtml = function() { + var rangeHtmls = []; + this.eachRange(function(range) { + rangeHtmls.push( DomRange.toHtml(range) ); + }); + return rangeHtmls.join(""); + }; + + if (features.implementsTextRange) { + selProto.getNativeTextRange = function() { + var sel, textRange; + if ( (sel = this.docSelection) ) { + var range = sel.createRange(); + if (isTextRange(range)) { + return range; + } else { + throw module.createError("getNativeTextRange: selection is a control selection"); + } + } else if (this.rangeCount > 0) { + return api.WrappedTextRange.rangeToTextRange( this.getRangeAt(0) ); + } else { + throw module.createError("getNativeTextRange: selection contains no range"); + } + }; + } + + function inspect(sel) { + var rangeInspects = []; + var anchor = new DomPosition(sel.anchorNode, sel.anchorOffset); + var focus = new DomPosition(sel.focusNode, sel.focusOffset); + var name = (typeof sel.getName == "function") ? sel.getName() : "Selection"; + + if (typeof sel.rangeCount != "undefined") { + for (var i = 0, len = sel.rangeCount; i < len; ++i) { + rangeInspects[i] = DomRange.inspect(sel.getRangeAt(i)); + } + } + return "[" + name + "(Ranges: " + rangeInspects.join(", ") + + ")(anchor: " + anchor.inspect() + ", focus: " + focus.inspect() + "]"; + } + + selProto.getName = function() { + return "WrappedSelection"; + }; + + selProto.inspect = function() { + return inspect(this); + }; + + selProto.detach = function() { + actOnCachedSelection(this.win, "delete"); + deleteProperties(this); + }; + + WrappedSelection.detachAll = function() { + actOnCachedSelection(null, "deleteAll"); + }; + + WrappedSelection.inspect = inspect; + WrappedSelection.isDirectionBackward = isDirectionBackward; + + api.Selection = WrappedSelection; + + api.selectionPrototype = selProto; + + api.addShimListener(function(win) { + if (typeof win.getSelection == "undefined") { + win.getSelection = function() { + return getSelection(win); + }; + } + win = null; + }); + }); + + + /*----------------------------------------------------------------------------------------------------------------*/ + + // Wait for document to load before initializing + var docReady = false; + + var loadHandler = function(e) { + if (!docReady) { + docReady = true; + if (!api.initialized && api.config.autoInitialize) { + init(); + } + } + }; + + if (isBrowser) { + // Test whether the document has already been loaded and initialize immediately if so + if (document.readyState == "complete") { + loadHandler(); + } else { + if (isHostMethod(document, "addEventListener")) { + document.addEventListener("DOMContentLoaded", loadHandler, false); + } + + // Add a fallback in case the DOMContentLoaded event isn't supported + addListener(window, "load", loadHandler); + } + } + + return api; +}, this);;/** + * Text range module for Rangy. + * Text-based manipulation and searching of ranges and selections. + * + * Features + * + * - Ability to move range boundaries by character or word offsets + * - Customizable word tokenizer + * - Ignores text nodes inside