Commit graph

320 commits

Author SHA1 Message Date
Timo Tijhof 1ba75b7ea9 The last ever mw.ext.ve jshint fixup
Change-Id: I262673214dd59e5bcaf4e0855e68728365b041fe
2012-11-26 22:36:07 +01:00
Trevor Parscal 9c74c97808 Fix even more inspector issues, and some ce ones as well
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
2012-11-21 15:26:12 -08:00
Catrope 0516b1d7f0 Make entity nodes work in CE
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
2012-11-21 12:04:31 -08:00
Catrope 1234a702c9 (bug 42218) Add MWEntityNode
<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
2012-11-20 16:19:55 -08:00
Christian Williams 9787166bab Fixing Pre-Annotations
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
2012-11-19 17:09:08 -08:00
Trevor Parscal 96fcbbd695 Cleanup var statements
Put non-assignment vars first

Change-Id: Id868976bc4d7c21032aef5020fe5fd0eb5df7a14
2012-11-19 17:05:34 -08:00
Catrope 7fb9b1c09a Merge "(bug 42123) Add i18n for aliennated content tool tip." 2012-11-17 01:08:07 +00:00
James D. Forrester c7fd1819a3 (bug 42123) Add i18n for aliennated content tool tip.
Change-Id: Ibb98d256fb989cd69407b487df673ee22f8c9758
2012-11-16 16:52:22 -08:00
Christian Williams 1932e0907f Phantoms not vanishing on mouseout
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
2012-11-16 11:32:59 -08:00
Inez Korczyński ebbd297841 (bug 42134) Add shields after node is attached to the live DOM
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
2012-11-15 14:17:12 -08:00
Christian Williams fcfca947a9 Better Shield Logic
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
2012-11-14 18:38:42 -08:00
Christian Williams 9f4a4d9e92 Disable Table Editing
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
2012-11-14 17:14:45 -08:00
Trevor Parscal e808e67a64 Merge "Display overlay phantoms for inline blocks (no need to use shields)." 2012-11-15 00:11:21 +00:00
Trevor Parscal ba01a76363 Merge "Support for node HTML attributes" 2012-11-15 00:05:16 +00:00
Inez Korczyński 4c7f3d2182 Temporary quick fix for BugId 41223. It is just for release purpose and I will keep working on solid solution.
Change-Id: I3f428f88b0e8d6d837f1dfd9d269ca3c99147ed7
2012-11-14 15:02:40 -08:00
Inez Korczyński 2da5676fe1 Support for node HTML attributes
Walk through node model attributes and pick just the HTML ones, then apply them to the DOM element

Change-Id: I7e0ffd71023ad692fcad7386b853410747398793
2012-11-14 14:22:03 -08:00
Inez Korczyński 0d15980638 Display overlay phantoms for inline blocks (no need to use shields).
Change-Id: Ife362035c43daf863a3b6a5f892dc928d1f6ec80
2012-11-14 13:43:03 -08:00
Christian Williams 836f7dea9e Alien Phantoms
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
2012-11-14 13:11:29 -08:00
Inez Korczyński 72c564b47f (bug 41072) Add support for adding outer length in ve.ce offset getters
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
2012-11-13 11:17:59 -08:00
Trevor Parscal da1d7e4a70 Merge "Nicely highlightable alien nodes" 2012-11-13 18:25:27 +00:00
Christian Williams e03cef06a7 Nicely highlightable alien nodes
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
2012-11-13 10:25:05 -08:00
Inez Korczyński 27ddb456c8 Fix for ve.ce.BranchNode.setupSlugs - insert each slug only once
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
2012-11-12 15:32:22 -08:00
Catrope f10ca89888 Merge "Mapped tab key to indentation action" 2012-11-08 00:31:10 +00:00
Trevor Parscal 614dd307f7 Mapped tab key to indentation action
* Added cancelable action return value to surface execute method

Change-Id: I57a58962399a46a0e41b4e95e438dc528770d619
2012-11-07 16:26:13 -08:00
Catrope 3d76ce60fe Merge "Replaced command factory with new command class" 2012-11-07 23:51:19 +00:00
Trevor Parscal ab57bed7da Replaced command factory with new command class
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
2012-11-07 15:47:03 -08:00
Christian Williams 05c3e088d0 Fixing native selection rendering for floats
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
2012-11-07 15:07:43 -08:00
Catrope 1f01100eb9 Flag pre nodes as having significant whitespace
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 &nbsp;s for spaces).

Change-Id: I738a750c91a4ca4836c485e282865bb7525bf30a
2012-11-07 12:10:58 -08:00
Trevor Parscal 1e3f42f764 Merge "Styling aliens with a yellow background; preventing absolute positioning" 2012-11-06 00:09:41 +00:00
Christian Williams 901eea203e Styling aliens with a yellow background; preventing absolute positioning
Change-Id: I86fbbda841d69beeabf4e683de3b032fb70b1ac6
2012-11-05 14:22:10 -08:00
Trevor Parscal 4e377480cf Improved the responsiveness of the context menu
* 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
2012-11-05 12:47:47 -08:00
Rob Moen 5d86bc4379 Base for inspectors & context menu to operate on 0 length selection.
* 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
2012-11-02 13:08:32 -07:00
Catrope a87ffeefa1 Merge "Whitespace and comment cleanup on ve.ce.SurfaceObserver" 2012-10-26 21:59:00 +00:00
Rob Moen 9563f0880d UI context reorganization, inspector rewrite, iframe refactor, icon generalization
* 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
2012-10-26 14:46:11 -07:00
Trevor Parscal 44a78129c4 Whitespace and comment cleanup on ve.ce.SurfaceObserver
Change-Id: Ice4058f1041f3d0118c7955122b8ea4d538790e0
2012-10-26 10:27:54 -07:00
Timo Tijhof 37f3a288ec Standards: Fix global variables and pass JSHint.
Follows-up:
* IK 714e29d30f
* IK 3b8a5ae4d5
* IK 72eb2825e5
* RK 7fe7182f43
* ...

Change-Id: I671f08e4899bfb9508cef272190ec72721a0af9a
2012-10-23 00:53:48 +02:00
Catrope 8d82da1fb5 Merge "Rename property "timeout" to "timeoutId" - more descriptive." 2012-10-22 17:08:39 +00:00
Inez Korczyński 88c22b3a46 Rename property "timeout" to "timeoutId" - more descriptive.
Change-Id: I198d07e3c59ba1283085135f45882ce606bb2389
2012-10-19 17:11:59 -07:00
Trevor Parscal d09bc496c3 Merge "Fix for native deletion - it was breaking document (model and view) when deleting really fast (holding the key for example). This solution completely fix the problem, however it is not optimal - stop and start is called more often than should be." 2012-10-19 23:33:24 +00:00
Christian Williams bab6ca6a60 (bug 41055) Fixing large content copy and paste from external source for Firefox/Windows
Change-Id: I7169566cca486eb5085922c5ac8d932c60a7dcbb
2012-10-18 15:59:55 -07:00
Inez Korczyński 6735a47dcb Fix for native deletion - it was breaking document (model and view) when deleting really fast (holding the key for example). This solution completely fix the problem, however it is not optimal - stop and start is called more often than should be.
Change-Id: Ied5b34f92056407311aa1e84fbff35943138987f
2012-10-18 13:22:20 -07:00
Inez Korczyński 4b1b63d357 "Is there data?" a.k.a. Insert data only if there is a data to be inserted.
Change-Id: If5957c38668f4dedcba72fc79f9a273614c6dce3
2012-10-17 16:08:02 -07:00
Inez Korczyński 829b070330 Fix bug in ve.ce.BrancNode.setupSlugs. It was removing slugs from the DOM, but not from the internal (this.slugs) collection, so getSlugAtOffset was returning incorrect information.
Change-Id: I0307d2dfe5c62f992287532ef8925fead2899c58
2012-10-17 13:54:14 -07:00
Inez Korczyński 5c83742313 (Bug 41120) Missing coma. Who knows how it happened...
Change-Id: I4c0a65cc751bf378368df9f8b793f672fb7cca15
2012-10-17 12:48:11 -07:00
Trevor Parscal 5cd4222d9c Whitespace and comment cleanup for dm annotation classes
* Added comments to classes and methods
* Quieted a jshint warning
* Broke some long lines
* Replaced instances of "var\t" with "var "

Change-Id: I1d617ed9e5180f1a3dff42078fb5debb5d718407
2012-10-17 12:35:28 -07:00
Inez Korczyński 874adec1ac (Bug 41120) When getOffset is called for a slug offset there is no need to traverse DOM - we can simply just call getSlugAtOffset and use that information.
Change-Id: I46b21ca0d3ca11d72c77feeb884f7d92a201de36
2012-10-17 12:32:27 -07:00
Trevor Parscal 020a04f3dc Merge "Get annotations from first character of a range" 2012-10-17 19:28:05 +00:00
Christian Williams 280b0a368e (bug 41092) Fixing cut
Surface was being accidentally locked when we actually want the surface to re-render.

Change-Id: I1d20faec8e55934e1fff7534c7d8cfe94d19031d
2012-10-16 23:33:28 -07:00
Christian Williams 7a2faf7daf Ignore backspace keypress
Firefox triggers a keypress event for backspace. We handle backspace in keydown, so this keypress event should be ignored.

Change-Id: I6a481dbd5df0cf4558a5f1975717ca809250ccda
2012-10-16 12:23:57 -07:00
Christian Williams 177557808b (bug 33064) Ignore non-content keypresses
Ignore keypress handling for any keypress with e.which of 0.

Change-Id: Ifa8a562eb882b337bad466183849ba9871605653
2012-10-15 23:05:47 -07:00