This will make sure the marker moves correctly (backwards/forward)
in RTL languages as well as LTR languages, judging from the wiki pageLanguage.
This can be a quickfix until the movement can be decided per the direction
of the specific element (span/paragraph/div) the marker is in.
Bug: 38546
Change-Id: Ic01e110a5e6094cd275327a2e8cea90c900f1bd1
Making sure resize handle events are bound and unbound on focus, and that elements are created in the right window.
Change-Id: Ie90bb82aa6c81c372d76278dab3665bd49bf573c
When you typed after a ProtectedNode that was previously at the end of
a paragraph, then moved the mouse, you'd get a JS error.
What happened was the typing caused a new TextNode to be created after
the ProtectedNode, which caused the ParagraphNode to be rebuilt,
detaching the original ProtectedNode and creating a new one. The
detached ProtectedNode was still bound to mousemove on the body, and
when that event fired it would try to remove its phantoms from the
surface and fail because detached nodes can't get to the surface.
Change-Id: I9f38776f0267645b14d7b26e2a25007cf3be8ec7
Getting & setting the cursor is done with byte offsets
instead of data model offset (characters) so we need to
be able to convert between the two as well as splitting
characters.
TODO: The regex only works on surrogate pairs, not
yet combining accents.
fixupInsertion will combine a combining mark with the
character to its left it it can.
Bug: 48630
Change-Id: I8d936fb15d82f73cd45fac142c540a7950850d55
Add teardown call to surface destruction in mw target, and
teardown listener to resizeable node.
Bug: 48530
Change-Id: I807a0f32d3d1eb490456d887f7bf867bdb896df4
Prologue:
Farewell ve.Editor my good chap… Oh, hey there HTML frames - I didn't
see you there! In a world where iframes are outlaws, and symbols like
document and window are global, there were more than a few assumptions
about which document or window was being used. But fear not - for this
commit (probably) tracks them all down, leaving a trail of
iframe-compatible awesomeness in its wake. With the great ve.ui.Surface
now able to be used inside of iframes, let the reference editing
commence. But there, lurking in the darkness is a DM issue so fierce it
may take Roan and/or Ed up to 3 whole hours to sort it out.
Note to Roan and/or Ed:
Editing references seems to work fine, but when saving the page there
are "no changes" which is a reasonable indication to the contrary.
Objectives:
* Make it possible to have multiple surfaces be instantiated, get along
nicely, and be embedded inside of iframes if needed.
* Make reference content editable within a dialog
Approach:
* Move what's left of ve.Editor to ve.ui.Surface and essentially
obliterate all use of it
* Make even more stuff inherit from ve.Element (long live this.$$)
* Use the correct document or window anywhere it was being assumed to be
the top level one
* Resolve stacking order issues by removing the excessive use of z-index
and introducing global and local overlay elements for each editor
* Add a surface to the reference dialog, load up the reference contents
and save them back on apply
* Actually destroy what we create in ce and ui surfaces
* Add recursive frame offset calculation method to ve.Element
* Moved ve.ce.Surface's getSelectionRect method to the prototype
Bonus:
* Move ve.ce.DocumentNode.css contents to ve.ce.Node.css (not sure why it
was separate in the first place, but I'm likely the one to blame)
* Fix blatant lies in documentation
* Whitespace cleanup here and there
* Get rid of ve.ui.Window overlays - not used or needed
Change-Id: Iede83e7d24f7cb249b6ba3dc45d770445b862e08
* VisualEditor.hooks.php
** export URL to magnify clip as a configuration variable so thumbnail image can render correctly
* ve.ce.Surface.css
** add CSS styling to make image captions look the same way in edit mode as they look in the view mode
* ve.ce.ParagraphNode.js
** add CSS class ve-ce-generated-wrapper if it is a generated wrapper
* ve.ce.MWImageCaptionNode.js
** make image caption rendering match the view mode
Change-Id: I0cd1b25e8f8355e0500aabc90e7c4cdf591545f3
Rather than using namespaced linmod attributes, store the preserved
HTML attributes in the .htmlAttributes property of the linear model
element, in a nested structure to allow for easier treatment of child
nodes. Also added attribute order preservation by storing attributes
as an object plus an array of keys.
ve.ce.Node.js:
* Remove html/* attribute synchronization. Doesn't make sense any more
because these things aren't in the attributes object any more. I don't
think it ever made sense because these attributes were never supposed
to be changed anyway.
ve.ce.View.js:
* Replace renderAttributes() with a simple wrapper around
renderHtmlAttributeList()
ve.dm.Converter.js:
* Add buildHtmlAttributeList() and renderHtmlAttributes() for building
and rendering HTML attribute lists
ve.dm.Model.js:
* Add getter for .htmlAttributes
ve.dm.Node.js:
* Drop .htmlAttributes on clone, and remove logic dropping html/*
ve.ui.MWCategoryWidget.js:
* Remove html/0/about hack, was already unnecessary and now doesn't
work any more
tests/:
* UPDATE ALL THE TESTS
Change-Id: I620573afd70d36ade6b80413075b6e1f4a435abe
Objectives:
* Make the context menu display in the top right corner of the currently
focused inspectable node (if there is one)
* Prevent clicking on anything to do with the toolbar or popup from doing
anything at all, ever
Bonus:
* While we are using the clever feature in jQuery's on method which allows
passing boolean false to cancel the event - may as well do that in
ve.ui.Dialog as well
Changes:
ve.ui.FocusableNode
* Add ability to specify the focusable element so that dimensions can be
derived from it
ve.ce.Surface
* Add quotes to object keys
ve.ui.MediaDialog
* Change association from being MW specific to handling images in general
ve.ui.Context
* Add embedded styles for context
* Add embedded mode, which is triggered when the context is a single
focusable node, and the node is large enough to fit the context
reasonably
ve.ui.Dialog
* Inline mousedown handler
ve.ui.Toolbar, ve.ui.PopupWidget
* Cancel stray mousedown events
Change-Id: I4b25d33f64b4bcb8a3ecfd7e9728f54a2d4886f3
Objective:
* Add button to launch template dialog
* Add template dialog
Changes;
*.php
* Add messages and links to files
ve.ce.Node.css
* Make inline templates display as inline-block to contain their
contents (allowing shields to work properly)
ve.ui.MWTemplateDialog.js
* New empty dialog for templates
ve.ui.MWTemplateButtonTool.js
* New template button, appears in context and launches dialog
Change-Id: I9174ed7c9012522246a6defc859276bf36763f5b
Surface can be deep inside a skin layout of which it is not
unlikely for one or more of the parents to have position
relative.
Change-Id: Ie202fa43b837650fd296fa6804d035622e2599e1
Objectives:
* Split ve.Surface into ve.Editor and ve.ui.Surface
* Move actions, triggers and commands to ve.ui
* Move toolbar wrapping, floating, shadow and actions functionality to configurable options of ve.ui.Toolbar
* Make ve.ce.Surface and ve.ui.Surface inherit ve.Element and use this.$$ for iframe friendliness
* Make the toolbar separately initialized so it's possible to have a surface without one, as well as control where the toolbar is
Some change notes:
VisualEditor.php
* Added standalone module for mediawiki integrated unit testing
ve.ce.Surface.js
* Remove requirement to pass in an attached container to construct object
* Inherit ve.Element and use this.$$ instead of $
* Make getSelectionRect iframe friendly
* Move most of the initialize stuff to a new initialize method to be called after the surface is attached to the DOM
ve.init.mw.ViewPageTarget.js
* Merge toolbar functions into setup/teardown methods
* Add toolbar manually (since it's not added by the surface anymore)
ve.init.sa.Target.js
* Update new init procedure for editor, surface and toolbar separately
* Move toolbar floating stuff to ve.Toolbar
Change-Id: If91a9d6e76a8be8d1b5a2566394765a37d29a8a7
Objectives:
* Move ve.ui.Element to ve.Element
* Make CE nodes inherit from ve.Element
Changes:
ve.ui.Element.js, ve.Element.js
* Move and rename
* Move ve.ui.get$$ to ve.Element.static.get$$
* Add static getDocument and getWindow methods
* Add instance getElementDocument and getElementWindow methods
* Add getTagName method, which by default reads the static tagName property, but when overridden can return a tag name based on other factors
*.php
* Updated file link
ve.ce.*Annotation.js, ve.ce.*Node.js, ve.ce.View.js, ve.ce.Document
* Added config options pass through
* Replaced passing elements through constructor with defining static tag names
* Added getTagName overrides where needed that derive tag name from model
* Refactore dom wrapper methods, now consistently using getTagName
ve.ce.Surface.js
* Removed static initialization (not needed)
ve.dm.Model.js, ve.ui.Window.js
* Added missing docs
ve.ui.GroupElement.js, ve.ui.Layout.js, ve.ui.Widget.js,
* Updated class name for elements
ve.ui.Frame.js, ve.ui.LookupInputWidget.js
* Updated location of get$$
ve.ui.js
* Move get$$ to ve.Element
ve.js
* Add auto-init of static properties to mixinClass
Change-Id: I39ae14966456903728e4d9e53f806ddce9ca2b70
Objective:
Move toolbar floating functionality to ve.init and clean it up
As a bonus:
demo.css
* Fix CSS path to set width of inputs properly
Changes:
demos/ve/index.php
* Allow ve.init.sa.Target to construct it's own surface object
ve.ce.Surface.js
* Move object resizing and table editing disabling commands from ve.Surface
* Add method for getting the currently focused node
ve.init.mw.ViewPageTarget.js
* Remove initializing surface property (now done in parent class)
* Normalize all uses of "setup" to "setUp"
* Replace uses of getDocumentModel with getModel().getDocument()
* Add calls to set up and tear down for toolbar floating
ve.init.mw.Target.js
* Replace uses of getDocumentModel with getModel().getDocument()
ve.init.sa.Target.js
* Move example from ve.Surface
* Change constructor to accept document model
* Create ve.Surface object in constructor
* Add set up for toolbar floating
ve.ui.init.Target.js
* Initialize surface property
* Move and cleanup toolbar floating functionality from ve.Surface
ve.ui.Surface.js
* Remove example now that init.sa creates it's own surface (moved)
* Document options
* Simplify toolbar options and remove the concept of multiple toolbars
* No longer cache the options object
* Move toolbar initialization to constructor
* Change setupCommands to addCommands, making it useful after construction
* Inline selection initialization
* Move and cleanup toolbar floating functionality to ve.ce.Surface
* Reorganize a few methods
* Move toolbar floating to ve.init.Target.js
Change-Id: I393a426e35567d57c048122bf64a83c1ef45e6e8
Fixes change made in I7a8d6c474ecca5af02b72b6453c900ed61acea58 by using
DOM_VK_ENTER instead of DOM_VK_RETURN (which is not defined anymore).
Bug: 48386
Change-Id: I8d7aeffc8166487806e3489b054f508c5e9418ff
When the user presses Enter in an empty list item, we remove it. But if
the list item was the only child of the list, that leaves an empty list
which then gets a block slug, leading to all sorts of weird things, and
even pawns in Firefox. So check whether the list item was the last child
and if so, remove the list.
Bug: 48287
Change-Id: If22d9b904b8861e24d56944d791545635b2e4254
There is no need to call renderContents in ContentBranchNode constructor
because it is going to be called anyways in onSplice
Change-Id: Id1ab983668299658ecd6e89a37667cc34c701689
The way it operated was evil. It did a depth-first search from the root,
finding the node using reference equality. For documents with deep
structures, this could take a long time. Inez did some profiling and
found it was called tens of millions of times on a complex document.
Kill getOffsetFromNode() and move its functionality to getOffset().
The logic has been completely rewritten: getOffset() now traverses
up from the node rather than down from the root, and pretty much does
the reverse of what getNodeFromOffset() does. This should be much more
efficient even without offset caching in the node objects (which we may
still implement later).
Change-Id: I125f9fa423c40db6472e2c4a7c94214218ba3bc7
Shields were being added twice. Switched the blank png to gif
because the red IE background couldn't be replicated. Changed
some styles from Alien to Protected.
Change-Id: I9c62665e4e0dc54b8511749b9d2a629db7990a16
Factored the parsing of html/* attributes out into a static function.
Factored attribute (re)rendering out into ce.View, attribute updates
are much simpler now.
Change-Id: I4caa6d5e1e2c21c28ddff61c3c864e47f66cc6b2
The constructor doesn't use any parameter named "$resizable".
And the one usage of it (ve.ce.ImageNode) doesn't pass any
arguments.
Follows-up 3fe3032.
Change-Id: I30530f4199a7c8383933be286b7b7a705c05c26c
Objective:
Generalize the shield and phantom magic, so we can use it for pretty much
any node we like. Usually this will be used with generated content nodes,
but also with aliens (of course) and possible other stuff in the future.
Bonus:
Also fixes a bug in DM that would crash VE when you selected to the end
and hit backspace.
Changes:
*.php
* Added links to files
aliens.html
* Added attributes to aliens to make them aliens again
ve.ce.AlienNode.js
* Moved shield and phantom functionality to ve.ce.ProtectedNode
ve.ce.AlienNode.js, ve.ce.MWReferenceListNode.js,
ve.ce.MWReferenceNode.js, ve.ce.MWTemplateNode.js
* Mixed in ve.ce.ProtectedNode
ve.ce.Node.css
* Reorganized styles and updated class names
* Added simple light blue hover with outline (using inset box shadow) for
protected nodes, same style as before for aliens
ve.ce.Surface.css
* Moved phantom styles to ve.ce.Node.css
ve.ce.BranchNode.js
* Moved call to setLive(false) to happen before detach() so that the
surface object is still available and events can be disconnected
ve.ce.BranchNode.js, ve.ce.Document.js, ve.ce.js, ve.ce.Surface.js, ve.ce.SurfaceObserver.js
* Adjusted CSS class names
ve.ce.Node.js
* Moved shield template to ve.ce.ProtectedNode
ve.ce.ProtectedNode.js
* New class, mix into another class to protect it from editing
ve.ce.RelocatableNode.js
* Renamed temporary surface property to relocatingSurface to avoid
confusion when debugging
ve.ce.Surface.js
* Moved phantom template to ve.ce.ProtectedNode
ve.dm.Transaction.js
* Fixed bug where most of the internal list was being deleted when the
end of the document was selected and the user pressed backspace
Change-Id: I2468b16e1ba6785ad298e38190e33493135719c3
A bug in I4bad882d1d6fb83bcdcfd0de3bfc9af52960c2ff caused the vertical
position to sometimes be NaN, and thus make the context in the wrong
place (but only vertically).
Change-Id: I5216af5c432caaa0fb400d8d006647b9f2488619
Now comparing annotations in surface to insertionAnnotations
by comparable object to trigger pawn trick. Adding annotations
correctly to placeholder.
dm.Surface change method now uses setInsertionAnnotations()
and passes the AnnotationSet from offset-1. The set is cloned.
Added ve.ce.Surface.areAnnotationsCorrect() to compare either
annotations to the left or right to the insertionAnnotations.
Also use compareTo() and getComparableAnnotations() rather than
comparing by name, and fix SurfaceFragment.annotateContent() to
actually be selective when clearing rather than clearing everything.
Change-Id: I6116afa2e176daa0a0f2103a551501426829e2a6
The EventEmitter API we inherited from Node.js and then bastardized was
getting awkward and cumbersome. The number of uses of ve.bind was getting
out of control, and removing events meant caching the bound method in a
property. Many of the "features" of EventEmitter wasn't even being used,
some causing overhead, others just causing bloat. This change cleans up
how EventEmitter is used throughout the codebase.
The new event emitter API includes:
* emit - identical to the previous API, no longer throws an error if you
emit error without a handler
* once - identical to the previous API, still introduces a wrapper* on -
compatible with the previous API but has some new features
* off - identical to removeListener in the previous API
* connect - very similar to addListenerMethods but doesn't wrap callbacks
in closures anymore
* disconnect - new, basically the opposite of addListenerMethods
Another change that is made in this commit is mixing in rather than
inheriting from EventEmitter.
Finally, there are changes throughout the codebase anywhere
connect/disconnect could be used.
Change-Id: Ic3085d39172a8a719ce7f036690f673e59848d3a
.getClientRects() somestimes returns an empty collection which causes an
exception to be thrown by rangy. This corresponds to
.getBoundingDocumentRect() returning a hash full of zeroes.
Detect this and handle such ranges separately, by inserting dummy DOM
elements at the selection's beginning and end, then using their
position to determine where the actual selection was.
This behavior is seen sometimes in Opera, and in Chrome by using the link tool on text at the beginning of the document.
Bug: 47772
Change-Id: I4bad882d1d6fb83bcdcfd0de3bfc9af52960c2ff
Aliens now listen for surface model change events in order to
adjust the position of the phantoms.
Change-Id: I1e8bfba331a10678e9ca7e64b7818197237eb0a2
Remove all manual changes to SF ranges as these are not
undoable. Instead change translate range to default to
outer expand and build functionality around that behaviour
never changing.
As translate range is always outer I don't think we need to
check for start and end crossing over?
Added more undo tests to assert these selections are maintained
properly, and added the test case to 'update' for when and undo
point is overwritten.
Insert content now results in a selection over the inserted
content. Most usages were expecting this anyway and were
followed up with an adjustRange(-length,0) which is no longer
necessary.
Noticed that the link inspector case was never being triggered
as word boundary was always expanding to at least one char (mainly
for Hanzi selection). This doesn't make much sense as single
spaces get auto selected so removed this functionality.
Split collapseRange out into collapseRangeToStart and
collapseRangeToEnd as this may be required to get the old
behaviour (range moves to end after insert).
Change-Id: I3dc0b4d00d37bad1ca3076a69b41c5f0b3fa0570
CSSJanus flips left for right for RTL languages. To ensure proper positioning of phantoms, the phantom container must actually be set to left:0, not right:0. Added the @noflip option before the phantoms selector to prevent CSSJanus from modifying it.
Change-Id: Id7662362d117d6c5719b9b98d7a0dbf62e9ba3ff
Because we have a node for <table>, we also need one for <caption>,
otherwise we'll try to alienate it and fail.
Added the test case as a separate example document so Ed can use it
for his tests.
Removed test case asserting <caption> is alienated.
Change-Id: I3a917db58e6c0eb97899b214b07d01fc8d86b56d
Firefox fires key press events for arrow keys - but we handle them
already in keydown - so the solution is to just ignore those
key presses in the handler.
Change-Id: I1aff295a0958b75697c4d362e0d6095283f37fe8
Previously, they were only being deduplicated based on the transaction,
which meant that an undo was seen as a duplicate (but then if you undid
again, that wasn't a duplicate).
Change-Id: If432ea28e6c206a2ad5562e529e2d3ed808c20e4
It is going to be used at least for figure tags for which Parsoid gives as a lot of CSS class names that are useless for rendering purpose
Change-Id: I4b1e8084a6b7ab5294e0c3cf153fc6cffb3e8dac
Instead of calling $.append for every single char - buffer and call $.append only when really needed.
Change-Id: I53acfa795ea5dc6a8ca39ce11017daa85c9151d2
* Only place them in a high z-index while resizing so they don't render
above dialogs and menus
* Add resize transition
ve.ce.ImageNode.js
* Switch from element attributes to CSS for setting dimensions
ve.ce.Node.css
* Add resizing class for resizable nodes for z-index
* Add transitioning class for resizable nodes for transitions
* Switch from border to inset box-shadow to not affect handle position
calculation
ve.ce.ResizableNode.js
* Add/remove resizing class while resizing
* Switch from using $image to $resiable to make the class useful for
non-image node
* Enable transition and set new dimensions before transaction processing
which will cause re-rendering)
* Delay transaction processing for resize until after transition is
complete
* Add hiding of context menu on resize start
ve.ce.Surface.js
* Add getSurface method so we can get to the context menu
Change-Id: I4667e394d0af4a80b651c2a0f6d11d30e196bf60
ve.ce.Node.css
* Added prefixes for use of box-sizing
ve.ui.MWLinkInspector.js
* Whitespace
ve.ui.Inspector.css
* Corrected input width, always 100% wide now by using box-sizing
ve.ui.DialogButtonTool.js, ve.ui.Context.js
* Updated use of getViewsForNode
ve.ui.ViewRegistry.js
* Added inheritance-based prioritization for matching views with annotations and nodes
Bug: 47413
Change-Id: I286a28002c1691e58bbd7de04ed08cceb8b3bb07
Using left and right arrow key to move to and over an image will
select the entire node.
Bug: 37870
Bug: 38129
Change-Id: I70deadd2c2707149ea33e3b8ee42fb0d8508aacc
By removing the transaction listeners from surface fragments we
no longer have to make sure they are always manually destroyed.
In order to retain the functionality of having fragments update
with transactions elsewhere we keep a pointer to a place in the
new complete history stack in the surface. The complete history
stack records all transactions, even undone ones.
Whenever getRange is called we replay all transactions in the
complete history (in the correct order) since the fragment was
last updated.
Also in this commit:
* Updated Format/IndentationAction to test undo(). This increases
coverage of surface fragment behaviour.
* .range is always accessed by .getRange now, although as an
optimisation we can use the noCopy mode when we a sure the
returned range will not be modified.
* Added undo test to .update (previously .onTransact)
Bug: 47343
Change-Id: I9e9818da1baa8319a3002f6d74fd1aad6732a8f5
Actually really resizing the image
Show bounding box on mouseover with 4 handles. Bounding box is resizable. Image resizes to match bounding box on mouse up.
Change-Id: I1f3dac64eb86dd1f258937e4915af101b3ac19d8
*.php
* Added links to new file
ve.ce.ImageNode.js
* Added relocatable node mixin
* Added $image reference to the actual img element, so if it's wrapped
in a sub class the functionality in the parent class doesn't break.
* Moved drag start event handling to relocatable node
* Removed drag end binding, not needed.
ve.ce.MWImageNode.js
* Moved addClass to initialization section of constructor.
* Copied 'view' data prop from image element to keep stuff working after
the wrapping.
ve.ce.Node.css
* Switched to default (arrow) cursor for images.
ve.ce.RelocatableNode.js
* New mixing for nodes that should be relocatable
* Added implementation for drag start, which tells the surface to allow
dragging this node.
ve.ce.Surface.js
* Added relocation support, which is used by relocatable nodes
* Split onDocumentDragDrop into onDocumentDragOver and onDocumentDrop
which now have implementations that support relocation of nodes
ve.ui.Context.js
* Added relocation tracking to prevent context being shown while
relocating
Change-Id: I8703adfb707af2c3224431afc3418356ac2c686c
*.php
* Added links to new file
ve.ce.ImageNode.js
* Added focusable node mixin
ve.ce.FocusableNode.js
* New class!
* Adds isFocused and setFocused methods
* When a node is focused or blurred, 'focus' and 'blur' events are emitted
* While a node is focused, it will have the 've-ce-node-focused' class added to it's this.$
ve.ce.Surface.js
* Add detection of node focusing and setting focus and blur on nodes on change
Change-Id: I3f1ad6309571f2bfe568550e2e8f1bd5a0302085
Before, it took an array of objects and translated those to indexes
using the store. Literally every caller outside of the test suite got
an array of indexes from the linear model, translated those to objects,
then passed them into the AnnotationSet constructor which translated
them right back to indexes.
The previous behavior was kind of ridiculous on its face, but the
reason we found it is because Inez was investigating the performance
degradation when bolding a line and found that half of it was due
to the hundreds of ve.getHash() calls caused by this behavior.
Change-Id: I38df8ae9f6392849dacf477ea2f804283c964417
* Create MWTemplateBlockNode & MWTemplateInlineNode (in ce and dm)
* Move Alien's 'isInline' code to ve.dm.Node.static.isHybridInline
* Move definition of ce.AlienBlock/InlineNode inside ce.Aline.js file
to match dm.AlienBlock/InlineNode and MWTemplate
* Duplicate AlienBlock/Inline styles for templates
* Create test case for inline templates
* Count test cases in ve.dm.Converter.test.js automatically
Change-Id: Id9bc7f049ea974dd5e7f8b7a66080939e0948bbd
Change 57076 implemented the functionality required to skip
words in UnicodeJS. This change simply removes all the existing
code we had and replaces it with this implementation.
Bug: 46794
Change-Id: I6b2700d65476c4d34ba4a01a88382d7af8e736fb
This node stores the rendered in the index-value store, hashed on
a custom hash of the dm (type + mw) which makes it unique it its
parameters.
Bug: 46571
Change-Id: I0ab4c9f7bca207121d5b42e83c821771b6139da8
ve.ce.ImageNode.js
* Moved in generic stuff from MWImageNode
* Added drag end handler (empty, will be used soon)
ve.ce.MWImageNode.js
* Changed to inherit ImageNode
* Moved generic stuff out
ve.dm.ImageNode.js
* Added attribute extraction/preservation for src, width and height
ve.dm.MWImageNode.js
* Changed to inherit ImageNode
* Re-using ImageNode's attribute handling to extract/preserve attributes on both the image and wrapper level
Change-Id: Ied4e1ece24e6804220eac35330790f7084df55de
ve.dm.Converter and ve.ce.ContentBranchNode were duplicating a fair bit
of logic for annotation rendering. Moved the annotation opening and
closing logic into ve.dm.Converter.openAndCloseAnnotations, and
implemented both annotation rendering code paths in terms of that
function with callbacks for caller-specific behavior.
Change-Id: I7cba7d2fda7002287b07949a1b8120ba80bfe854
We weren't really using it exclusively for nodes any more, and the only
functionality in there was for using .static.name
Change-Id: Ie26928cd01faee95a10912201663b45f1f20fb19
Just like ve.dm.Model is a common base class for dm.Node, dm.Annotation
and dm.MetaItem.
ce.View abstracts the this.model and this.$ behavior, including liveness,
whitelisted HTML attribute rendering and adding a back reference in
.data(). The back reference has been renamed from .data( 'node' ) to
the more generic .data( 'view' ).
At this point this means ce.Annotation is just a shell around ce.View
(except where it defaults to a span rather than a div), but that could
change in the future.
Change-Id: I0eef5b80718e0b0fcd3f8bba096b452f0bb680d0
This changes the annotation API to be the same as the node API, sans
a few boolean flags that don't apply. The APIs were different, but
there was really no good reason why, so this makes things simpler for
API users. It also means we'll be able to factor a bunch of things out
because they're now duplicated between nodes, meta items and annotations.
Linear model annotations are now objects with 'type' and 'attributes'
properties (rather than 'name' and 'data'), for consistency with elements.
They now also contain html/0/* attributes for HTML attribute preservation,
which obsoletes the htmlTagName and htmlAttributes properties.
dm.Annotation subclasses take a reference to such an object and implement
conversion using .static.toDataElement and .static.toDomElements just
like nodes do. The custom .getHash() functions are no longer necessary
because of the way HTML attribute preservation was reimplemented.
CE rendering has been moved out of dm.Annotation (it never made sense to
have CE rendering functions in DM classes, this was bothering me) and into
separate ce.Annotation subclasses. These are very similar to CE nodes in
that they have a this.$ generated based on something in the DM; the main
difference is that nodes listen to events and update themselves, whereas
annotations are static and are simply destroyed and rebuilt when they
change. This change also adds whitelisted HTML attribute rendering for
annotations, as well as class="ve-ce-FooAnnotation" attributes.
Now that annotation classes produce real DOM nodes rather than weird
objects describing HTML tags, we can't generate HTML as a string in
ce.ContentBranchNode anymore. getRenderedContents() has been rewritten
to be much more similar to the way the converter renders annotations;
in fact, significant parts of it were copied from the converter, so that
should be factored out in the future. This change actually fixes an
annotation rendering discrepancy between ce.ContentBranchNode and
dm.Converter; see the diff of ve.ce.ContentBranchNode.test.js.
ve.ce.MWEntityNode.js:
* Remove stray property
ve.dm.MWExternalLinkAnnotation.js:
* Store 'rel' attribute
ve.dm.TextStyleAnnotation.js:
* Put all the conversion logic in the abstract base class
ve.dm.Converter.js:
* Also feed annotations through getDomElementsFromDataElement() and
createDataElement()
ve.dm.Node.js:
* Fix undocumented property
ve.ce.ContentBranchNode.test.js:
* Add descriptive messages for each test case
* Compare DOM trees, not HTML strings
* Compare without all the class="ve-ce-WhateverAnnotation" clutter
ve.ui.LinkInspector.js:
* Replace direct .getHash() calls (evil!) with ve.getHash()
Bug: 46464
Bug: 44808
Change-Id: I31991488579b8cce6d98ed8b29b486ba5ec38cdc
This is a redux of logic already in master.
Moved from keydown to keypress because IE
fires keydown multiple times for held keys.
Changed the logic to determine that the current
offset is just after an element that should not be
directly edited.
Change-Id: I5206d8919abde740d92f636b0c8618c4ebb6f6ff
Created an IndexValueStore class which can store any object and return
an integer index to its hash map.
Linear data is now stored in ve.dm.LinearData instances. Two subclasses
for element and meta data contain methods specific to those data types
(ElementLinearData and MetaLinearData).
The static methods in ve.dm.Document that inspected data at a given
offset are now instance methods of ve.dm.ElementLinearData.
AnnotationSets (which are no longer OrderedHashSets) have been moved
to /dm and also have to be instantiated with a pointer the store.
Bug: 46320
Change-Id: I249a5d48726093d1cb3e36351893f4bff85f52e2
When the cursor is between ce="false" elements and an editable next
sibling, IE often sets the anchorNode to be the ce="false" element
(or text node within). This change returns aliens to ce="false"
(abandoning the former true within true IE trick), and ensures that
the cursor is in the right place on keydown by programmatically
setting the selection.
Change-Id: I952488510f32b096b27e8e55d4afc7df930e0072
Also removed a few redundant headings in class documentation
comments. There is already an @class and it looks a bit odd in
the generated pages:
<h2>TextString</h2>
<p>TextString</p>
<p>This class provides a ...</p>
Change-Id: Ie311c6993ed02e79272dbde71f6a1bc252ef3037
Better comments for:
* ve.ce.Document.getRelativeOffset,
* ve.ce.Document.getSiblingWordBoundary.
Convert ve.ce.Surface.getSelectionRect to a static method.
Moved getNodeAndOffset from ve.ce.Surface to ve.ce.Document.
Change-Id: Ic00221fa463205d04c9b52150c0dd15904493b1e
The phantoms prevent direct clicking into aliens,
and the recent selection changes prevent keyboard
navigation into aliens, but one issue remained.
Clicking to place the cursor just after an alien
would actually focus within the alien. Typing
modified the alien content. By nesting ce="true"
within ce="true", IE ceases this behavior.
Dragging state is now set to false when blurring
the document. The mouseup event sets dragging to
false, but the event is cancelled because blur
happens between mousedown and mouseup. Phantom
display logic uses on this property.
Change-Id: I162dea89838756fd28d63ff66cc4a5e5bda2873a
Mostly by extracting parts of onDocumentKeyDown method into separated methods: handleLeftOrRightArrowKey and handleUpOrDownArrowKey
Change-Id: If19abf2218bc667c729f7bf388074061cec3031c
* Document them consistently between secetions Inheritance and
Static Properties under their own (new) section Events.
* Removed any quotes or brackets around the event name in existing
@emit annotations
Search: @emit.*['"{}(){}]
* For every call to this.emit() anywhere, added @emits.
* Fixed all warnings for references to undefined events
(introduced as a result of the previous point).
Event handler parameter documented based on the emit() call
and actual handlers using the event. Usually the latter is
more elaborate.
* Extend coverage of jQuery as needed
(copied from mwcore/maintenance/jsduck/external.js
written by me, hereby implicitly and explicitly released under MIT).
Specifics
* ve.ce.Surface#onContentChange: Fixed type of range from Object to ve.Range.
* ve.ce.SurfaceObserver#poll: Fix syntax for code from {} to `backticks`.
* ve.ui.Toolbar#onContextChange: Doesn't actually emit "clearState" event.
Removed #onClearState in Tool, ButtonTool and DropdownTool.
Bug: 45872
Change-Id: Id879aa769b2c72d86a0322e75dddeb868211ce28
Heading and Preformatted nodes have rules that should only
exist under a document node in MediaWiki.
Two new node types have been created as has a new DropdownTool which
uses these. The MW init options have been changed to use the new
DropdownTool.
Bug: 45295
Change-Id: I3f47e1ae1f5c1415bde58a75385e4bf5f4b8fffc
Add a static.name property to ce nodes and make sure both ce
and dm nodes always use the static.name property in constructors
and registration calls.
The result of this is that any given node type should now only
appear once in the code as a string.
Bug: 45701
Change-Id: Ibf31de16ab28ad58209c1443cd74f93dda278998
Apparently in IE even after you call clearTimeout, the function passed
to setTimeout might still get invoked (not 100% of the time).
It depends on the time difference between calling clearTimeout and
when that function was supposed to be called.
Change-Id: I050c1ecc51c1d891a028fb777243573487357171
Modified handleEnter to check for the condition that shift-enter
is being pressed inside of a preformatted block. If so, a break
node is inserted.
Bug: 45355
Change-Id: Iae7b3c88b7cd976e519c09821a064078228acc79
Objective:
Refactor UI widgets, improve usability and accessibility of menus, general cleanup and style improvements.
Extras:
Fixed documentation in a few other files to make descriptions of jQuery event arguments more consistent, classes inherit correctly, and made use of the @cfg functionality in jsduck.
Changes:
.docs/config.json
* Added window, HTMLDocument, HTMLElement, DocumentFragment and XMLHttpRequest to externals, so jsduck doesn't throw warnings when they are used
demos/ve/index.php, modules/ve/test/index.php, VisualEditor.php
* Moved widgets above tools (since tools use widgets)
demos/ve/index.php
* Refactored widget initialization to use options
* Renamed variables to match widget names
ve.init.mw.ViewPageTarget.css
* Adjusted text sizes to make widgets work normally
* Added margins for buttons in toolbar (since button widgets
don't have any)
* Removed styles for init buttons (button widgets now)
ve.init.mw.ViewPageTarget.js
* Switched to using button widgets (involved moving things around
a bit)
ve.ui.LinkInspector.js, ve.ui.MWLinkInspector.js
* Renamed static property "inputWidget" to
"linkTargetInputWidget" to better reflect the required base class
for the properties value
icons.ai, check.png, check.svg
* Added "check" icon, used in menu right now to show which item
is selected
ve.ui.Icons-raster.css, ve.ui.Icons-vector.css
* Added check icon
* Removed :before pseudo selectors from most of the icon classes (not need by button tool anymore, makes them more reusable now)
ve.ui.Tool.css
* Adjusted drop down tool styles so menu appears below, instead
of on top, of the label
* Adjusted paragraph font size to better match actual content
* Updated class names to still work with menu widget changes
(items are their own widgets now)
* Updated selectors as per changes in the structure of button tools
ve.ui.Widget.css
* Added styles for buttons and menu items
* Adjusted menu styles
ve.ui.*ButtonTool.js
* Added config options argument passthrough
ve.ui.ButtonTool.js
* Moved var statement to the top inside constructor
* Switched to using "a" tag to get cross-browser :active support
* Added icon to inside of button to make icon styles more reusable
* Removed disabled support (now provided by widget parent class)
ve.ui.FormatDropDownTool.js
* Updated options initialization to construct menu item objects
* Modified handling of items to account for changes in menu and
item classes
* Optimized onUpdateState method a bit, adding early exit to
inner loop
ve.ui.ButtonTool.js, ve.ui.DropdownTool.js, ve.ui.Context.js,
ve.ui.Frame, ve.ui.Tool.js, ve.ui.Widget.js
* Added chain ability to non-getter methods
ve.ui.DropdownTool.js
* Removed items argument to constructor
* Updated code as per changes in menu class
* Fixed inconsistent naming of event handler methods
* Removed item event handling (now handled by items directly)
* Made use of this.$$ to ensure tool works in other frames
ve.ui.Tool.js
* Made tools inherit from widget
* Moved trigger registry event handler to a method
ve.ui.Context.js
* Switched from using menu to contain toolbar to a simple wrapper
ve.ui.js
* Added get$$ method, a convenience function for binding jQuery
to a specific document context
ve.ui.*Widget.js
* Switched to using a config options object instead of individual arguments
* Added options
* Factored out flags and labels into their own classes
* Refactored value setting methods for inputs
ve.ui.MenuWidget.js, ve.ui.MenuItemWidget.js
* Broke items out into their own classes
* Redesigned API
* Updated code that uses these classes
* Added support for keyboard interaction
* Made items flash when selected (delaying the hiding of the menu for 200ms)
ve.ui.LinkTargetInputWidget.js, ve.ui.MWLinkTargetInputWidget
* Refactored annotation setting methods
Change-Id: I7769bd5a5b79f1ab36f258ef9f2be583ca503ce6
Follows-up I44bcb79a59 and various other changes.
Please remember to generate documentation and resolve
all warnings before pushing into gerrit.
Change-Id: I8a372443e841308463376d8673ce027a97bbcd30
Using localStorage for copy and paste between ve instances previously worked, but broke with the introduction of AnnotationSet. After a discussion with James, rich copy and paste from many sources is the real goal, so copy and paste enhancement should work toward that end.
Change-Id: I58c0f4525e486fada997872b40c2317f57034b7a
* Deleted blocks of code that are never executed.
* Deleted method (showCursor) that is never used.
Change-Id: I031585b40f384d3e0e5d4cb03f626c9229d97fcf
This fixes a problem that phantoms would remain visible if moving the mouse quickly. Now binding to mousemove and also mouseout.
Change-Id: I4f5e3319038828f83b108e9f5a45f54ebfeb7027
Use ve.bind in order to change context within which
callback is called - reduces a need of introducing
new local variable.
Change-Id: I75ece695548c87073dd22e5e7ec80057d7132d22
This means that <p data-foo="bar"> will now be converted to a paragraph
with attributes {"html/0/data-foo":"bar"} rather than {"html/foo":"bar"}
This paves the way for multi-element node (about group) handling in the
node API: nodes representing multiple DOM elements will have html/i/attr
to represent an attribute of the i'th DOM element.
Change-Id: Iea52bdccd721942ca708c8f9f47e934524809845
ve.Node.js
* Removed unused emitUpdate property
* Made traverseUpstream a dynamic method rather than static
ve.ce.Node.js, ve.ce.Surface.js
* Updated calls to traverseUpstream
Change-Id: I28a2dac61aa32668d35854fbdb7712401c42336a
Objective: Simplify the registration and use of triggers
Changes:
* Renamed ve.Command to ve.Trigger
* Renamed command demo to trigger demo
* Removed language prefixing of triggers
* Generating trigger tooltips rather than hard-coding them in i18n
* Added documentation to clarify that only 'mac' and 'pc' are supported platforms, and how the default is chosen
* Simplified trigger registry's register command
* Updated trigger registrations
Change-Id: Ibab6ad5b5c86f24707f064967dc2119a81125392
Lots of fixes for "it's" being used incorrectly.
ve.ce.Document.js
* Filled in documentation for missing params
ve.FormatAction.js
* Fixed incorrect tag for returns documentation
Change-Id: Ic256cc6952c31f5e6ae8be92919a0799cfe6188b
* Removed mousedown handler (dragging is handled in ve.ce.surface)
* Added attribute change handler to ve.ce.Node to keep attribute changes on the model in sync with the DOM
Change-Id: I1d6a7f3dc3136439ce511a4f3eb5a54797c8f996
Logical grouping for Init, Browser Events, Custom Events, Utilities, Helpers, Getters, and Setters. This may be a precursor to a future, larger refactoring.
Change-Id: I059f88a604f0b5bc383eb3ae274bab0fe2dc476b
Resolves a TODO related to the paste target div.
VisualEditor.php
* Added link to ve.Surface.css
ve.Surface.js
* Cleaned up initialization of .ve-surface element
* Removed float clearing div (see ve.Surface.css)
* Removed paste div (moved to ve.ce.Surface)
ve.Surface.css
* Added rule which adds an ":after" element to handle clearing floats
ve.ce.Surface.js
* Cleaned up initialization of DOM elements
* Added paste target div
* Replaced paste element selectors with direct references to this.$pasteTarget
ve.ce.Surface.css
* Changed paste div styles to use a namespaced class instead of a generic ID
demos/ve/index.php
* Added link to ve.Surface.css
Change-Id: Ib93d45ac82ae643fc8e659f5a063c02a8ddacdde
The normalize method doesn't need to be explicitly called anymore because there's not any code that changes the properties of a range directly anymore.
A good way to prove it's not needed anymore is to move the normalization logic to the constructor and then add "console.log(this.from <= this.to );" to the normalize method - you will find that it's never actually doing anything at all because the range was normalized by the constructor.
ve.Range
* Moved normalization logic to constructor
* Removed calls to normalize method
* Removed normalize method
* Simplified documentation for flip method
* Whitespace fixes
ve.Document, ve.dm.Transaction, ve.dm.Surface, ve.dm.Document, ve.ce.Surface
* Removed calls to range.normalize
* Switched to using range.isCollapsed instead of comparing properties directly
Change-Id: I80bfd06f88579c34dce2083c2b70d63ab92f1275
* Made method descriptions imperative: "Do this" rather than "Does this"
* Changed use of "this object" to "the object" in method documentation
* Added missing documentation
* Fixed incorrect documentation
* Fixed incorrect debug method names (as in those VeDmClassName tags we add to functions so they make sense when dumped into in the console)
* Normalized use of package names throughout
* Normalized class descriptions
* Removed incorrect @abstract tags
* Added missing @method tags
* Lots of other minor cleanup
Change-Id: I4ea66a2dd107613e2ea3a5f56ff54d675d72957e
Warning: modules/ve/test/ve.qunit.js:5: Class QUnit not found
Warning: .docs/categories.json No class found matching a pattern 've.Position' in categories file
Warning: modules/ve/ce/ve.ce.Surface.js:1297: Unknown type MouseEvent
Warning: modules/ve/ce/ve.ce.Surface.js:1297: Unknown type int
Follows-up:
* Ic21c9d3f
* Ib521eaa6
Change-Id: I8e371a2d4d91a1f03bd4ef59d18b7df715f23238
Follow up for I6a7c9e8ee8f995731bc205d666167874eb2ebe23
The first pass that Timo took missed the following cases
* "{Array|String}": string is just one of the values
* "{String[]}": string is followed by [] to indicate an array of strings
Change-Id: I65e595e8d37fb624802d84af9536a2d3c5d73c7d
CE doesn't actually render meta nodes anymore now that we split them out
into the meta-linmod.
I took a stab at consolidating metaBlock and metaInline (into simply
'meta'), but we can't do that with the current node API unless we put a
lot of meta-specific hacks in the converter. So I'm leaving this for the
node API rewrite.
Change-Id: Ie83413df718eabcaeb504316a2db0d24a1be2226
IE does not properly support MouseEvent.detail for reporting the number of clicks in a user action. The new clickCounter() function takes a mousedown event and returns the detail property if non-IE or calculates the detail by comparing to a recent history (up to 3) of mousedowns.
Change-Id: Ib521eaa695d7e436d67ebb49106159daadc2ee38
See CODING.md for how to run it.
Mistakes fixed:
* Warning: Unknown type function
-> Function
* Warning: Unknown type DOMElement
-> HTMLElement
* Warning: Unknown type DOM Node
-> HTMLElement
* Warning: Unknown type Integer
-> Mixed
* Warning: Unknown type Command
-> ve.Command
* Warning: Unknown type any
-> number
* Warning: Unknown type ve.Transaction
-> ve.dm.Transaction
* Warning: Unknown type ve.dm.AnnotationSet
-> ve.AnnotationSet
* Warning: Unknown type false
-> boolean
* Warning: Unknown type ve.dm.AlienNode
ve.dm doesn't have a generic AlienNode like ve.ce
-> Unknown type ve.dm.AlienInlineNode|ve.dm.AlienBlockNode
* Warning: Unknown type ve.ve.Surface
-> ve.ce.Surface
* ve.example.lookupNode:
-> Last @param should be @return
* ve.dm.Transaction.prototype.pushReplace:
-> @param {Array] should be @param {Array}
* Warning: ve.BranchNode.js:27: {@link ve.Node#hasChildren} links to non-existing member
-> (removed)
* Warning: ve.LeafNode.js:21: {@link ve.Node#hasChildren} links to non-existing member
-> (removed)
Differences fixed:
* Variadic arguments are like @param {Type...} [name]
instead of @param {Type} [name...]
* Convert all file headers from /** to /*! because JSDuck tries
to parse all /** blocks and fails to parse with all sorts of
errors for "Global property", "Unnamed property", and
"Duplicate property".
Find: \/\*\*([^@]+)(@copyright)
Replace: /*!$1$2
* Indented blocks are considered code examples.
A few methods had documentation with numbered lists that were
indented, which have now been updated to not be intended.
* The free-form text descriptions are parsed with Markdown,
which requires lists to be separated from paragraphs by an
empty line.
And we should use `backticks` instead of {braces} for inline
code in text paragraphs.
* Doc blocks for classes and their constructor have to be
in the correct order (@constructor, @param, @return must be
before @class, @abstract, @extends etc.)
* `@extends Class` must not have Class {wrapped}
* @throws must start with a {Type}
* @example means something else. It is used for an inline demo
iframe, not code block. For that simply indent with spaces.
* @member means something else.
Non-function properties are marked with @property, not @member.
* To create a link to a class or member, in most cases the name
is enough to create a link. E.g. Foo, Foo.bar, Foo.bar#quux,
where a hash stands for "instance member", so Foo.bar#quux,
links to Foo.bar.prototype.quux (the is not supported, as
"prototype" is considered an implementation detail, it only
indexes class name and method name).
If the magic linker doesn't work for some case, the
verbose syntax is {@link #target label}.
* @property can't have sub-properties (nested @param and @return
values are supported, only @static @property can't be nested).
We only have one case of this, which can be worked around by
moving those in a new virtual class. The code is unaltered
(only moved down so that it isn't with the scope of the main
@class block). ve.dm.TransactionProcessor.processors.
New:
* @mixins: Classes mixed into the current class.
* @event: Events that can be emitted by a class. These are also
inherited by subclasses. (+ @param, @return and @preventable).
So ve.Node#event-attach is inherited to ve.dm.BreakNode,
just like @method is.
* @singleton: Plain objects such as ve, ve.dm, ve.ce were missing
documentation causing a tree error. Documented those as a
JSDuck singleton, which they but just weren't documented yet.
NB: Members of @singleton don't need @static (if present,
triggers a compiler warning).
* @chainable: Shorthand for "@return this". We were using
"@return {classname}" which is ambiguous (returns the same
instance or another instance?), @chainable is specifically
for "@return this". Creates proper labels in the generated
HTML pages.
Removed:
* @mixin: (not to be confused with @mixins). Not supported by
JSDuck. Every class is standalone anyway. Where needed marked
them @class + @abstract instead.
Change-Id: I6a7c9e8ee8f995731bc205d666167874eb2ebe23
The {{coords}} template is correctly rendered as an inlineAlien, which previously did not have shields. However, the template has a deeply nested span that is positioned and floated. The fix is to shift shielding logic up to AlienNode (from AlienBlockNode) and to show phantoms on all shields (both block and inline). I've also updated the aliens demo to exhibit this corner case.
Change-Id: Ifce60c7762c0ead5c6fe29d6eabf601c1565cbfa
We got lucky - the fact that our alien styling choice required phantom overlays had the nice side-effect of preventing the ability to focus the aliens. Therefore, as soon as we started ignoring IE to deliver nice alien handling for standards-compliant browsers, we inadvertently solved(?) the IE alien problem. I've touched up the styling to look nice in IE 9 (solid green phantoms) and IE 10 (stripes). Shield GIF switched to PNG because IE 10 renders the transparent GIF as solid red. Yeah, red.
Change-Id: I3bc69acba9ed883a823cdf722117b90966bc332b
This solves 2 issues:
1. Paste scrolls to the top of the editable box because we temporarily moved the focus to the paste container, and then moved it back. We solve this by saving/restoring the scroll position.
2. Scroll position adjusts vertically when pasting (using key repeat) because we handle pastes with a setTimeout and multiple paste jobs will pile up before they can be finished. We solve this by disallowing paste until we are done handling the previous one. In the case of key repeat this only is observable as slowing the repeat rate.
Thank you Christian for helping me solve this the old fashioned way - by sacrificing features you don't really need!
Change-Id: I75bcf9843b57cdff0db9b6dea62d66d4d76ac011
ve.dm.Document
* 2 of the 3 paths of getSlice still returned arrays instead of ve.dm.DocumentSlice objects
ve.ce.Surface
* Translate the range using the insertion transaction and truncate it, so the cursor ends up just after the pasted content
Change-Id: If7bae5e254ec84a847c1d3527f74d9c09c2d82b4
ve.ce.Surface
* Switched to using getSlice instead of getData in copy and paste handlers
* Added try/catch which attempts to build a transaction with the unbalanced data first, but falls back on the balanced data otherwise
ve.dm.*Node
* Added default style attributes (now used by ve.dm.NodeFactory)
ve.dm.Document
* Fixed bugs in fixupInsertions where parentType was being set with an object rather than a string
* Made use of getDataElement
* Added adoption capability so that inserting a</h1><p>b into <p>c[cursor]d</p> results in <p>ca</p><p>bd</p> rather than throwing an exception
* Renamed getBalancedData to getSlice, now retuning a ve.dm.DocumentSlice object
ve.dm.DocumentSlice
* Introduced new container for balanced data and a range of the original context - useful for copy/paste
ve.dm.NodeFactory
* Added getDataElement method, which uses default attributes to create a boilerplate version of a data element
ve.dm.Document.test
* Updated getBalancedData test to be a getSlice test
demos/ve/index, VisualEditor, test/index
* Added references to ve.dm.DocumentSlice
Change-Id: Id9269a29e51ca213508de8f155d3feec5e5b0774
Since model.change now starts the surfaceObserver, a problem manifested where the surfaceObserver was observing the $('#paste') element (used for capturing and sanitizing pasted content from external sources). Simply switching the order of the transaction and the documentNode focus fixed the problem.
Change-Id: I1b542b546d7f3d97e2e954ca4b51ca74232b2877
Get rid of ve.ce.Surface.locked (and isLocked, lock, unlock) and instead introduce ve.ce.Surface.renderingEnabled (and isRenderingEnabled, enableRendering, disableRendering) which names are way less confusing and more specific. Also add use of isRenderingEnabled to ve.ce.ContentBranchNode.
Change-Id: I72e9e8f8dfbf43784d7e616369acc3e9649c715a
Initializing range var in SurfaceObserver to use this.range instead of null to avoid passing wrong information to onContentChange.
Change-Id: I1d4e3fa2393166dad887077529351a479401bf4b
ContentBranchNode shouldn't rerender on update, only on childUpdate.
When deleting across an inline node, update was emitted after the splice
had occurred in the DM but before the spice event was emitted that
caused the splice to happen in CE, leading to detached nodes and
associated sadness. See the bug for more details.
Change-Id: I2d44231b6e27efdb3f12967556cff174d9364d25
ve.ce.Surface
* Used getModel() as per TODO
* Simplified code by pre-calculating 2 statements that were being used 4 times each
* Re-structured logic so that simple insertion and deletion are only possible if next and previous have a range, triggering complex change otherwise
* Added some documentation
ve.ce.SurfaceObserver
* Added checks for whether rangy found a branch node within the document or not before accessing it's node via .data() and made it so we are only performing DOM > document range conversion if we did
* Removed some commented out code
Change-Id: Iaaf30a5b201710ab4235e775f18808a8d512f1f9
This will prevent inline alien phantoms from appearing while dragging. This was a usability enhancement identified by Inez/Christian.
Change-Id: Idf046db72e25875e899f5926ab7d50d2f514586b
This prevents memory waste when switching between read and visual editor tabs, which happens entirely on the client.
Change-Id: I31b50accac38d72a9367b9035504552dc0150104
When the content rendering stuff was moved to ve.ce.ContentBranchNode the onUpdate methods being used to update the DOM wrapper in ve.ce.HeadingNode was overlooked, so heading were not rendered on update anymore.
Change-Id: I994b8c43123c3cd02b9a550d5d7eac7d5052418e
ve.ce.Surface
* Added ve.ce.Surface.adjustCursor, which replaces repetitive and buggy code that was handling left and right arrow key presses
* New method only affects the selection target, so it won't collapse the selection on you - this was what caused bug 42401
* Made hasSlugAtOffset() actually return a boolean
ve.dm.Document
* Fixed turn-around issue in ve.dm.Document.getRelativeOffset - if the offset is already valid and we can't move in the direction we want, we should just leave it be, not turn around
* Since this method was being used by ve.ce.Surface to correct the cursor position on arrow key presses, it was causing the strange cursor jumping when you pressed an arrow key while at the edge of a document
ve.dm.SurfaceFragment
* Fixed typo where getAnnotationRangeFromSelection was preserving selection direction, but checking the wrong properties
ve.dm.Document.test
* Added tests that verify turn-around issue is fixed
Change-Id: Iba55cfc3d531e7d1333b78c94912ff22179aace8
ve.ce.Surface.handleDelete did not support inline elements. This patch resolves this by detecting them and using programatic delete instead of native browser delete.
Change-Id: I73215df88519450965be35d9e04cf4e621d1e90d
Moved annotation rendering from ce.Textnode into the new
ce.ContentBranchNode class. This allows us to render annotations that
span across multiple nodes.
* Add ce.ContentBranchNode, inheriting ce.BranchNode
* Make ce.{Paragraph,Heading,Preformatted}Node inherit ce.ContentBranchNode
* Made ce.ContentBranchNode render its child nodes with anntations,
using .getAnnotatedHtml() on the child nodes
* Put a default implementation for .getAnnotatedHtml() in ce.LeafNode
* Override this in ce.TextNode to do escaping and whitespace handling
* Removed rendering code from ce.TextNode (this.$ is now unused there)
* Removed ce.TextNode.onUpdate() and ce.BranchNode.clean(), now unneeded
* Have ce.BranchNode propagate update events from children, so
ce.ContentBranchNode can rerender when its children change
* Update tests, add test case for escaping of &<>'"
Change-Id: I4600e984b287c6ff9267f4281d2f09bab9e1ad95
* Added whitelist argument to setDomAttributes which allows filtering of attributes being set
* Added prefix argument to ve.dm.Node.getAttributes to allow extracting a subset of attributes by name prefix
* Added a whitelist to ve.ce.Node which was extracted from MediaWiki's Sanitizer class
* Replaced attribute copying code with a call to setDomAttributes using the whitelist argument, passing in attributes from a call to ve.dm.Node.getAttributes using the prefix argument
Also…
* Removed comment in constructor of ve.ce.Node, documentation for properties is usually in the getters/setters, and already was in this case
* Renamed ve.setDOMAttributes to ve.setDomAttributes
* Renamed ve.getDOMAttributes to ve.getDomAttributes
* Renamed ve.getDOMText to ve.getDomText
* Renamed ve.getDOMHash to ve.getDomHash
* Updated all callers of renamed methods
Change-Id: Id556172d5d18ea431044b9d402400e1f0e67a293
* Adjust offsets to correct positions before showing selection with them
* Throw an error inside of getNodeAndOffset if we can't find a match rather than mysteriously not retuning anything
Change-Id: Ia7347527e6466262e819f456404b32926fd95e34
ve.dm.SurfaceFragment
* Removed flawed implementation of word mode for expandRange method and made use of new getNearestWordBoundary method in the document model
ve.dm.Surface
* Got rid of useInsertionAnnotations, which allowed disabling and enabling of insertion annotations - this isn't needed anymore because it was just a dirty hack around the improper starting and stopping of surface observer that's now solved more elegantly by emitting lock and unlock before committing or rolling back transactions
* Get annotations from the first character of the selection if the selection is not collapsed
* Only emit annotationChange events if it really changed
ve.dm.Document
* Added getNearestWordBoundary method which performs the work behind the surface fragment expandRange word method
ve.ce.SurfaceObserver
* Allow using an initial selection to avoid the observer thinking the selection has changed just because it started out with null
* Only emit selectionChange event if there was a meaningful change
ve.ce.Surface
* (bug 42279) Only annotate characters if insertion annotations are not empty
* Remove manual locking and unlocking, this is now done inside the change method of surface model
* Provide an initial selection to surface observer when we clear it
* Remove enabling and disabling of insertionAnnotations, this isn't needed anymore
* Stop/start observer on key presses that execute actions as well as those that have no special handling
ve.ce.Document
* Make getNodeFromOffsetand getSlugAtOffset return null when given -1 as an offset
Change-Id: Ibf6b26de299e54ae8688a2653bf5d5538927f8c3
Check for all node classes in getOffsetFromTextNode(), not just
branches and aliens (an entity is neither)
Render entities with contenteditable=false. Without this, selection was
still broken, because:
Foo|€Bar was really <p>Foo<span>|€</span>Bar</p> which maps correctly.
Foo€|Bar was really <p>Foo<span>€|</span>Bar</p> which maps to the same,
which is incorrect.
With cE=false, the cursor can't be inside the span, so we get:
Foo|€Bar is really <p>Foo|<span>€</span>Bar</p> which maps correctly.
Foo€|Bar is really <p>Foo<span>€</span>|Bar</p> which maps correctly.
Change-Id: Iaf603346590a9ad553c152565eb203136be7a399
<span typeof="mw:Entity"> tags are now correctly represented in the
model, and rendered in CE. There are still issues with cursor movement
etc. in CE.
Because the prioritization mechanism for annotations vs nodes is broken
in the current "node API", I had to hack two special cases for mw:Entity
into the converter. I also had to change the converter to ignore the
children of inline nodes (this was a legitimate bug, but had never come
up before).
Change-Id: Ib9f70437c58b4ca06aa09f7272bf51d9c41b18f2
AnnotationAction and SurfaceFragment now use insertAnnotations.
ve.dm.Surface.test
* Removed test for annotate method (not needed anymore)
ve.dm.SurfaceFragment
* Now using getInsertionAnnotations method
* Added support for modifying insertion annotations when annotating a zero-length selection
ve.dm.Surface
* Moved in insertion annotations state from document model
* Added insertion annotation interface (enable, disable, areEnabled, get, set, add, and remove)
* Simplified handling of annotations on change
* Removed annotate method (not used anymore)
ve.dm.Document
* Removed insertion annotations (moved it to surface model)
ve.ce.Surface
* Cleaned up handleInsertion and changed it to use the insertion annotations interface on the surface model
ve.AnnotationAction
* Moved insertion annotation handling out of here since it's now included in the surface fragment
Change-Id: I047d656acf7fa1c63f726ca2b0801e1476f84f96
If the mouse is moved too quickly, the phantoms have a tendency to stick. This change moves the event from phantom.mouseleave to surface.mousemove.
Change-Id: I2c7e7bdc838427d4355a6c0c13bafe3198636dbe
This changeset introduces new variable property of ve.ce.Node called "live", which stores information whether or not given node is attached to the live DOM. When the value of this property changes event "live" is called.
Change-Id: I6d0ce923c25ff2c4015914f367582c9a15e62c65
jQuery.css('float') returns different null values for Chrome and Firefox. This fix takes this into account and applies shields only to aliens and floated descendants.
Change-Id: I4c1db148043ee95991a17720dee8febad62c415a
Native contenteditable execCommands were being tried before the surface was attached to the DOM. This is necessary for disabling native contenteditable object editing and resizing.
Change-Id: Idff6a30432396726deb8a38356172380ea12fced
Walk through node model attributes and pick just the HTML ones, then apply them to the DOM element
Change-Id: I7e0ffd71023ad692fcad7386b853410747398793
This changeset adds a visual treatment to uneditable AlienBlockNodes to indicate to the editor that the elements are uneditable. To deal with odd shapes, the alien's shields are cloned and added to a phantom container. The phantom container and the phantoms themselves may be styled appropriately.
Change-Id: I7ad52707966bc18be627aa4269725004edba86cd
ve.ce.getOffsetFromElementNode now supports adding outer length
of given node to status functions.
It is temporary solution that I will review in the future.
Change-Id: If779802156aa78dbced9d4c769e8e7877120b337
Browsers handle highlighting of our alien nodes differently. This change normalizes by hiding the native selection on the aliens, inserting blank image "shields" with native highlighting enabled.
Change-Id: Ica3576ef0e3c42b4aeae1da374cd1dc92f203d7d
When using jQuery insertBefore and insertAfter make sure to pass as a parameter jQuery selection of only one element (first for insertBefore and last for insertAfter).
Change-Id: Id469ed775642ab5be8e274ab3cb7730899e9487a
The port of mousetrap wasn't really what we needed. This is much simpler, matches the rest of our code, and does exactly what we need.
Change-Id: I67f413e097fc2d4078336edb14dd9440e771f196
This fixes a problem with how Chrome renders native selection around floated elements. By adding pseudo elements before and after block aliens, the rendering is fixed.
Change-Id: I7fdbb8f4c42e29d0574b308b8c5740066bb58e94
This causes the converter not to strip inner whitespace in them, and
causes CE to suppress the whitespace mangling logic that is normally
applied (↵ for newlines, ➞ for tabs, alternating s for spaces).
Change-Id: I738a750c91a4ca4836c485e282865bb7525bf30a
* Added selectionStart and selectionEnd events to ve.ce.Surface
* Switched from debouncing model change events to just ignoring
model change events while the user is in selection mode
(dragging mouse or pressing shift+arrow keys)
* Fixed bug with callout appearing on resize.
Change-Id: I3bb9952867a983a4f7612964ff719a1179dd0fc6
* Allow inspector to open with 0 length selection.
* Allow context menu to open with 0 length selection.
* Fixed bug in doc.getAnnotationsFromRange on zero length selection:
Method now returns annotations from start vs empty annotation set.
Change-Id: I3937c5c2824c7396d0c3ee11c13ffecdbed6052a
* Only show the inspector if the selected text has an inspectable annotation
* Replace the inline menu with a toolbar containing inspectable annotations
* Change the appearance of the inspector to match new mockups
* Add the trash can icon for removing annotations
* Move iframe handling code into a class that manages all that nonsense
Change-Id: I840f72426f9a9e50054a28de950393f0e9913153
* Added comments to classes and methods
* Quieted a jshint warning
* Broke some long lines
* Replaced instances of "var\t" with "var "
Change-Id: I1d617ed9e5180f1a3dff42078fb5debb5d718407
Firefox triggers a keypress event for backspace. We handle backspace in keydown, so this keypress event should be ignored.
Change-Id: I6a481dbd5df0cf4558a5f1975717ca809250ccda
If you select some text and start typing, we will now remove the content in the range and new content will be annotated with the annotations from the first character in the deleted range. This is similar to other editors.
Change-Id: I46ced52665ab10f9b724dbb225df5687c18a4c3a
The cursor will move natively when it can, allowing for word jumping with alt/ctrl keys. Special conditions exist for slugs and node boundaries that result in programatic movement.
Change-Id: Ife156bf94d8192ddd322c016ca8359855b17d7fc
Removing check for insertAnnotations length because it's also important to know if we're pre-unannotating text.
Change-Id: I7fab39ca353d7656de3ce2985a821cb54384100e