Commit graph

436 commits

Author SHA1 Message Date
Catrope 2eb0d2a6b2 Great Annotation Refactor of 2013
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
2013-04-08 18:10:16 -07:00
Christian Williams de49bf2bf7 Quick fix for IE typing after generated content
The previous check was incorrect and was setting selection
too often.

Change-Id: I1ac393c149b6f814949b84e47faa04906c94f6af
2013-04-05 16:12:12 -07:00
Inez Korczyński fea3273cad Make ve.ce.Document.getSiblingWordBoundary compatible with new linmod
Change-Id: I746fb8ad761e68cb3c8a76550e2dd4cb540be4e6
2013-04-03 18:07:11 +00:00
Timo Tijhof 1ec8ba3e24 Remove superfluous spaces in function invocations.
Find-Exec: ack '\.[a-zA-Z]+\ \(' --js modules/ve modules/unicodejs
Change-Id: Ib7d0a6514f3321f1d09fbf7cf52c2a9c2cecde88
2013-04-03 17:48:34 +00:00
Ed Sanders fdf30b1ac8 Store data in LinearData class with an index-value store for objects
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
2013-03-30 10:06:34 +00:00
jenkins-bot 7b9618ebc2 Merge "Typing support after Aliens and Entities for IE" 2013-03-29 02:19:15 +00:00
Inez Korczyński 836fa82155 Make sure that rangy is initialized only once and that it is initialized before it is used.
Change-Id: Ia318908d34e82ae97ae1bf662ad9fc5dc28bf6ba
2013-03-28 14:50:43 -07:00
Christian Williams 48f6403504 Typing support after Aliens and Entities for IE
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
2013-03-28 14:49:09 -07:00
Timo Tijhof c53685b865 Doc: Replace "@property @type {Type}" with "@property {Type}".
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
2013-03-28 21:21:56 +01:00
Inez Korczyński 21e4fdc014 Added support for displaying inline images.
Change-Id: Ieecbca8ed864585e8eaa99598d4bfdb5ac9bfec7
2013-03-28 13:05:57 -07:00
Inez Korczyński 47691cf586 Initialize rangy once and globally instead of doing it in constructor of every surface.
Change-Id: I06e331021ff8af63e76ceccc005319fc9ce96619
2013-03-27 11:05:29 -07:00
jenkins-bot b20de29fe8 Merge "Small cleanup in CE" 2013-03-27 18:02:06 +00:00
Inez Korczyński fe0fdcd67c Small cleanup in CE
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
2013-03-27 10:50:02 -07:00
Christian Williams a8a5c74d8b Prevent adding content to aliens in IE
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
2013-03-26 16:01:13 -07:00
Inez Korczyński 2108030cfd Add support for slugs in ve.ce.Document.prototype.getRelativeOffset
Also removed ve.ce.Surface.prototype.adjustCursor because it is not being used anymore

Change-Id: Ib7dd8f4f6eaa688995d33247600875a45fc5a602
2013-03-25 16:43:57 -07:00
Inez Korczyński 0339a92284 Cleanup in ve.ce.Surface.
Mostly by extracting parts of onDocumentKeyDown method into separated methods: handleLeftOrRightArrowKey and handleUpOrDownArrowKey

Change-Id: If19abf2218bc667c729f7bf388074061cec3031c
2013-03-25 16:23:39 -07:00
Inez Korczyński 92ea103153 Small cleanup/refactoring to getSiblingWordBoundary
CPU time + memory optimization + make inexpensive comparison first

Change-Id: I7f504f741b4d90201e40bbc40ae2e88fe0db2e33
2013-03-25 20:38:24 +00:00
Inez Korczyński 3b8cdfe2a0 Programmatic handling for selection (arrow up and arrow down only).
This is only for IE and only for backwards selection.

Change-Id: Ifdcd2d404d1018057b5ba16753fc964b07738879
2013-03-22 17:06:41 -07:00
Inez Korczyński 8b2d3caebb Programmatic handling for selection (arrow left and arrow right only).
Change-Id: I6ccbecdeafbe189dbe052e4e9ce8f926dad14aea
2013-03-22 12:24:31 -07:00
Inez Korczyński 5b9964878d Introduce helper functions.
* ve.ce.isLeftOrRightArrowKey
* ve.ce.isUpOrDownArrowKey
* ve.ce.isArrowKey

Change-Id: Id9fd7975e98085d01e545d1d0fc6086a06648031
2013-03-22 11:43:18 -07:00
Inez Korczyński c8819742eb Introduce method ve.ce.Document.getRelativeOffset.
Change-Id: If2b8675b4604fc5ec1430497f2d55b2f3584a453
2013-03-22 11:41:26 -07:00
Inez Korczyński c636ae138d Cleanup to ve.dm.SurfaceFragment.wordBoundaryPattern
Change-Id: I475fc0c97d5af646f51fe779c4b3136ddd3f83d0
2013-03-21 15:24:23 -07:00
Inez Korczyński 8199f2a1c1 Removed ve.dm.Document.getIEStyleWordBoundary method.
Added ve.ce.Document.getSiblingWordBoundary method.

Change-Id: I44b53273429aede5be10f39c2ee2f70d96cdc6fb
2013-03-21 14:46:13 -07:00
Trevor Parscal c2e1350fe0 Remove more periods
Tags don't need periods at the end, these are not complete sentences.

Change-Id: I8efa931862149e892d08b370e70aff8d86a6db7d
2013-03-20 22:55:50 +00:00
Timo Tijhof 4e64187beb Document and clean up events in all the things
* 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
2013-03-20 09:58:27 -07:00
Ed Sanders d22c7f7773 Correct name of can(Node)HaveGrandchildren functions
Bug: 43893
Change-Id: I9fd2a1fd6e3ee0a7bdfc357b5d4e4e0fd3efa0a5
2013-03-13 23:25:33 +00:00
Ed Sanders 0ce20b6e16 Create MediaWiki specific nodes to contain MW specific rules.
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
2013-03-12 16:28:29 -07:00
Inez Korczyński b99192e110 Do not display phantoms while dragging mouse over alien nodes.
It really does screw up selection in IE and does not look good in other supported browsers.

Change-Id: Ie190e86b25c3b253d4cf809594e74094275d0d57
2013-03-08 15:18:38 -08:00
jenkins-bot 80067f8633 Merge "Use static.name once for ce and dm nodes" 2013-03-08 01:20:35 +00:00
Ed Sanders edcaaf9edc Use static.name once for ce and dm nodes
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
2013-03-07 17:19:39 -08:00
Inez Korczyński c021445649 Fix for incorrect usage of ve.Range
Properties "from" and "to" of ve.Range should be used when
direction of the range is important.

Change-Id: I73f27abf5c90f9aad8fdd0622f71b09188af9486
2013-03-07 15:49:00 -08:00
Inez Korczyński e9b8021bf3 Fix for IE bug where clearTimeout doesn't clear the timeout
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
2013-03-07 03:49:39 +00:00
Inez Korczyński b98ee5140a DomRange makes more sense as a name for this class (cause it is not rangy specific).
Change-Id: I670523a0ed2216ebe34dc4b759a4aa429b9da53c
2013-03-05 12:18:59 -08:00
jenkins-bot b3c624f857 Merge "Shift-Enter should add newline in preformatted" 2013-02-28 20:28:57 +00:00
Christian Williams 0af149824f Shift-Enter should add newline in preformatted
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
2013-02-26 14:01:23 -08:00
Trevor Parscal a5aeca3ff5 Major UI refactoring and improvements
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
2013-02-26 12:29:08 -08:00
jenkins-bot 86d1f2a35b Merge "Fixing canBeSplit for ListItemNode" 2013-02-26 01:20:15 +00:00
Timo Tijhof 0031725751 Cleanup: Omit second argument to setTimeout for "nextTick"
Not 0 or 1.

Change-Id: Ia6eb985e649c5bd196f87aac98c3919e60be9a86
2013-02-26 00:34:58 +00:00
Christian Williams 3cd0448b33 Fixing canBeSplit for ListItemNode
List items weren't being properly split because of a typo in this file.

Change-Id: Ib275d62156b775bad57624dfdf4b54eb9a925eaa
2013-02-25 16:29:32 -08:00
jenkins-bot fbdc0e62ed Merge "Resigning from localStorage" 2013-02-25 23:47:35 +00:00
Trevor Parscal 622180b6fa Fix JSDuck warnings
Follows-up I44bcb79a59 and various other changes.

Please remember to generate documentation and resolve
all warnings before pushing into gerrit.

Change-Id: I8a372443e841308463376d8673ce027a97bbcd30
2013-02-26 00:44:21 +01:00
Christian Williams 6614acc4a0 Resigning from localStorage
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
2013-02-25 15:33:50 -08:00
jenkins-bot d00486a450 Merge "Cleanup selection displaying related methods in ve.ce.Surface." 2013-02-23 01:18:15 +00:00
Inez Korczyński c3d10e965a Cleanup selection displaying related methods in ve.ce.Surface.
* Deleted blocks of code that are never executed.
* Deleted method (showCursor) that is never used.

Change-Id: I031585b40f384d3e0e5d4cb03f626c9229d97fcf
2013-02-22 17:05:54 -08:00
Inez Korczyński a5e56718cd Introduction of ve.ce.RangyRange class.
Change-Id: I44bcb79a5967c362774603ea27181b9c64d2ea96
2013-02-22 17:02:42 -08:00
Christian Williams 7e74f0aa70 (bug 43461) Hide Phantoms
This fixes a problem that phantoms would remain visible if moving the mouse quickly. Now binding to mousemove and also mouseout.

Change-Id: I4f5e3319038828f83b108e9f5a45f54ebfeb7027
2013-02-21 23:02:05 +00:00
Inez Korczyński 0c73aa012e Introduce ve.Keys based on DOM Level 3 KeyEvent
Change-Id: I6abee2c0c49e355aef39089c7c94e51aaee01929
2013-02-20 16:15:59 -08:00
jenkins-bot 1d0a383968 Merge "Very small cleanup of onCut method in ve.ce.Surface." 2013-02-20 17:36:48 +00:00
Inez Korczyński 2d9c5d5628 Very small cleanup of onCut method in ve.ce.Surface.
Use ve.bind in order to change context within which
callback is called - reduces a need of introducing
new local variable.

Change-Id: I75ece695548c87073dd22e5e7ec80057d7132d22
2013-02-20 17:35:30 +00:00
James D. Forrester 82114467f1 Bump copyright notice year range to -2013 over -2012
199 files touched. Whee!

Change-Id: Id82ce4a32f833406db4a1cc585674f2bdb39ba0d
2013-02-19 15:37:34 -08:00