Before, hitting enter at the start of the link would result in the link text
being removed from an <a> on the new line, and an empty <a> tag on the previous
line. Now the link remains on the new line as expected, and no empty <a> tag is
produced.
in the preceding block.
Just return a boolean for the TreeWalker filter fn. This diverges from the spec,
but since the goal of this implementation is not to fully implement the spec
and we're never going to use a native implementation, this doesn't matter and
the code is easier to read when the function is just returning a boolean like
any normal filter function.
* Be more liberal in tld, as there are now a billion new ones, of every length.
* Fix bug where if the URL contains an @ it would add it as a mailto link
instead.
Set the defaultBlockProperties property on a squire instance to an object and
it will use these properties when it has to create a new default block element.
If a text node at the beinning of a block began with white-space, it would mean
some situations where we should be doing all the transformations for
enter/delete/backspace were being left to the browser.
* Hit tab to increase list depth, or call increaseListLevel method.
* Hit enter on a blank item to decrease list depth, or call decreaseListLevel method.
The clean functions used a `this` reference to call createElement, but are
called as functions not methods so `this` is undefined. Instead, we'll get the
ownerDocument off the nodes passed in, then call the createElement function
directly.
This is now an instance method, whereas before it was global. Annoyingly, we
need to access this from from within fixCursor which has no reference to the
RTE instance itself (and it would be a pain to pass one down). For now, just
referring to the global `editor` variable if it exists (i.e. if the script
loaded in an iframe). Need a better solution longer term though.
* If you load the squire.js script into a top-level page rather than an iframe,
it will add a Squire constructor to the global scope.
* The Squire constructor can be used to instantiate multiple instances on the
same page without having to load/parse/execute the full code every time.
* For each instance, create a new iframe, then call `new Squire( document )`,
with the document node for each iframe.
If you copy a portion of text from word, it includes an image version of the text as well as an HTML version. On paste, we now ignore the image
representation on the clipboard if an HTML representation is present, so that
the text pastes as expected, rather than as an image.
If you removed an event listener whilst it was being fired, this would alter the
list of handlers, which would cause the fireEvent function to read past the end
of the array (and to skip the next listener). Now, we clone the array of
listeners before firing, so adding/removing listeners has no effect on an
already firing event.
Firefox incorrectly goes back/forward in history instead of moving the cursor to
the beginning/end of the line when you press cmd-left/right on a mac. We now
override this to do the right thing.
When cleaning up pasted content, we remove any empty inline tags. However, we
should not be stripping <img> tags (which are of course both inline and empty).
Webkit needs a special placeholder text node as it can't focus empty text nodes.
This was being cleaned up too early, before the user had a chance to enter any
text.
The previous test was incorrect. A <br> actually introduces a line break if
there is any non-whitespace after it in the block or if there is another <br>
after it in the block. It is irrelevant what comes before it in the block.
When cleaning up <br>s, if it's inside a block we can't split, it's probably a
containing node (like a <blockquote>), so we should wrap the top level inlines
instead.
* Odd bug this. From the logs, it seems either it's returning a range with no
startContainer, or the startContainer is not something inheriting from the
Node prototype (which would be very wrong).
When cleaning up <br> elements, we need to accurately determine whether there's
text before and after it in the block to know whether it will introduce a
visible line break.
* But only if it's deleting whitespace or destroying a block or deleting a
selection. This makes it undo deletion word-by-word rather than
character-by-character.
Previously, we were just removing <br>s that didn't have siblings on both sides. A better test is whether the containing block has any non-whitespace text content. If it does, the <br> is a line break and we can just split the block. If it doesn't though, we need to leave the <br> as a placeholder, to ensure the block doesn't collapse to 0 height.
* When cleaning the tree we want to remove useless whitespace between block
nodes, but we were being a bit too aggressive and removing all whitespace
nodes. Now checks the context first.
Merging containers could remove the nodeAfterSplit from the tree, which then
caused an error to be thrown if it had no content, as the code would try to
remove it again.
* Do not move range boundaries inside images; these should always be treated as
leaf nodes.
* Workaround FF bug where it may return range as being inside of image node.
When restoring a range from a bookmark, always call range.moveBoundariesDownTree
to anchor it to the nearest text node. If you call setSelection with a range not
anchored inside a textnode, Opera may incorrectly set the selection.
A willPaste event is now fired just before pasted content is inserted into the
document, allowing custom, arbitrary modification of the pasted content, or
prevention of the paste event altogether.
If the node containing the zero-width space character was merged by a call to
Range#mergeInlines, the character was not being removed, making for odd cursor
movement.