Commit graph

166 commits

Author SHA1 Message Date
Trevor Parscal 5e477cbe98 (bug 42401) Cursor movement fixes
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
2012-11-30 09:50:47 -08:00
Trevor Parscal a57288575f (bug 42350) Delete and backspace broken around inline aliens in Firefox
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
2012-11-28 16:44:34 -08:00
Trevor Parscal ee80af5f96 (bug 42404) Errors passing "incorrect" offsets to ve.ce.Surface.getNodeAndOffset
* 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
2012-11-26 15:01:35 -08: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
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
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
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
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
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
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
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
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
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
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 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
Christian Williams 40cc89eb50 Get annotations from first character of a range
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
2012-10-15 17:39:28 -07:00
Rob Moen 7db62daac7 Fix bold and italic key commands in surfaceView.
Change-Id: Iefc436a27285fd811b9d1ac2c684160fe7818a30
2012-10-15 14:47:40 -07:00
Inez Korczyński dac224e110 Added support for Ime in IE. In IE when starting IME sequence 'compositionStart' is called to late, but fortunatelty we can do all necessary job in handler for 'keyDown'.
Change-Id: Id6f15015c45afd81cf8e74d3e03f7fa21611862d
2012-10-14 12:28:06 -07:00
Rob Moen ab7c39cf79 Fix context icon in surfaceView
Change-Id: I742b6df25679827fd0e3096a58bb5291c5f4f77d
2012-10-12 17:18:32 -07:00
Inez Korczyński 3c69871f4a Refactored method ve.ce.Surface.handleInsertion. Now handling slug and insertion annotations is combined.
Change-Id: I70494c185addcf4d07d385dc1e9745aca2f9d05b
2012-10-11 16:32:32 -07:00
Trevor Parscal 55a31122b5 Merge "Support for pre-unannotating test" 2012-10-11 23:28:18 +00:00
Trevor Parscal e02a253e0e Merge "Native cursor movement" 2012-10-11 23:27:25 +00:00
Christian Williams 011069d17c Native cursor movement
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
2012-10-11 15:51:45 -07:00
Inez Korczyński a78719d7e4 Added missing call to surfaceObserver.clear();
Change-Id: I64eeeef8339d5765d5ce732e660eeba35482d7d3
2012-10-11 13:59:30 -07:00
Christian Williams 9719589e9a Support for pre-unannotating test
Removing check for insertAnnotations length because it's also important to know if we're pre-unannotating text.

Change-Id: I7fab39ca353d7656de3ce2985a821cb54384100e
2012-10-11 13:38:54 -07:00
Inez Korczyński 4c08740794 Introduce new method in ve.ce.Surface called handleInsertion that is responsible for the magic around inserting content with new annotation, or in a slug, or with IME.
Change-Id: Ia558376d3e509d15a0746297a9dd29d09beec652
2012-10-11 12:06:17 -07:00
Christian Williams 4e585eb092 Removing onKeyPress return statement
Also switched to using surfaceObserver and cleaned up some trailing whitespace.

Change-Id: If9a2b390e86f54b4c5ddfd499eefb31f0ab2c96f
2012-10-09 10:54:27 -07:00
Inez Korczyński 1ed7b3f96e Update ve.ce.Surface to call SurfaceObserver.stop/start/clear instead of stopPolling/startPolling/clearPollData.
Change-Id: I164599dd34304a3eaef285859a66428cf839accb
2012-10-05 14:57:42 -07:00
Inez Korczyński 2d752fe60c Small clean-up in ve.ce.Surface constructor.
Change-Id: I679511cd0b22192213873ceca5d8410b56d5def9
2012-10-04 17:08:26 -07:00
Inez Korczyński b2295a2de3 Fix minor bug with incorrect usage of hasSlugAtOffset.
Change-Id: I413fc5850cd7bcae9b1d955eb951394e1ed9df36
2012-10-04 14:31:25 -07:00
Inez Korczyński 72eb2825e5 Start using ve.ce.SurfaceObserver inside ve.ce.Surface. Moved methods getOffsetOfSlug, getOffsetFromElementNode, getOffsetFromTextNode and getOffset to ve.ce.js and made them static.
Change-Id: If6ce0ae10c494392cc384341cc87b61658d4934a
2012-10-04 14:28:54 -07:00
Inez Korczyński c4299fd838 Retire ve.ce.Surface.render variable and instead of it use variable "locked" via methods lock(), unlock() and isLocked().
Change-Id: Ic476a51e9e7766bd2793c2a7d773734cf9bcd0b6
2012-10-04 14:26:06 -07:00
Inez Korczyński 714e29d30f Created method getSlugAtOffset in ve.ce.Document and ve.ce.BranchNode, refactored the way how slugs are added.
Change-Id: I8006c7e6e1dd3c640939bf08f39192615b2e5343
2012-10-03 15:40:44 -07:00
Trevor Parscal 903acdfdf2 Added surface model lock and unlock events
This allowed me to move ve.ce.Surface particulars (such as the starting, stopping and clearing of polling) out of the UI code.

Also cleaned up some switch statements.

Change-Id: I7b85e42a4e01f8d76237d995e25275f2424541ea
2012-10-01 14:23:11 -07:00
Christian Williams ffefe63063 Insert Annotations
Change-Id: Ibc927730a668cdcea9c90fe4fc2cb3db4d20480e
2012-09-28 13:28:47 -07:00
Timo Tijhof ab7d6bf082 Documentation & clean up
* Commands for Sublime:

  Find*: "(\* @[a-z]+) ([^{].*) \{(.*)\}"
  Replace: "$1 {$3} $2"

  Save all && Close all

  Find: " function("
  Replace: " function ("

  Save all && Close all

  Find: "Intialization"
  Replace: "Initialization"

  Save all && Close all

* Consistent use of types (documented in CODING.rm):
  - Merged {Integer} into {Number}.
  - Merged {DOM Node} into {DOMElement}.

* Remove work-around /*jshint newcap: false */ from ve.js
  Calling Object() as a function to to use the internal
  toObject no longer throws a newcap warning in JSHint.
  It only does that normal functions now .

  (e.g. var a = Cap(); or var a = new uncap();)

* Add missing annotations (@static, @method, ..).

* Remove unused variables

* Remove null-assignments to variables that should just be
  undefined. There's a few variables explicitly set to null
  whereas they are set a few lines under and not used otherwise
  (e.g. 'tx' in ve.ce.Surface.prototype.onPaste)

Change-Id: I0721a08f8ecd93c25595aedaa1aadb0e08b83799
2012-09-17 16:02:52 +02:00