Commit graph

2917 commits

Author SHA1 Message Date
Ed Sanders 3c66a297c9 Merge getDataFromDom and getModelFromDom
Now getDataFromDom is no longer called externally, we can merge these two
methods to provide one API endpoint. Also now we have deleted getDataFromDom
we can remove the 'Recursion' disambiguator from the internal function.

Also now that the whitespace info doesn't need to be passed around, implement
it as a simple return value get function.

Change-Id: I9c667e9b90443d12660b731347d7535ccb1a17cd
2013-12-05 21:54:08 +00:00
Ed Sanders 25a6e93ef2 Separate data/metadata split and node tree loops
It's not much of an optimisation to combine these loops but
separating them gives us greater flexibility.

Move the building of the node tree to happen lazily when
getDocumentNode is called.

In the rich paste path we can now create the DM without building
the node tree and remove the metadata.

Change-Id: I10b4bc486ff8ff8037158aa6dfd45aac87557d42
2013-12-05 21:30:04 +00:00
Ed Sanders e01e2e045b Always use #getDocumentNode.
Because if you only sometimes use a getter you're just wasting your time!

Change-Id: Idd38976f77b58e322d527cecca9f9c36e3ad9318
2013-12-04 22:55:26 +00:00
Ed Sanders 6d34e344ee getDataFromDom -> getModelFromDom
Following on from getDomFromModel, this returns a document model
instead of element linear data. The only instance that hasn't been
replaced is in rich paste, where we need to sanitize the converted
data before constructing the document model.

This should be cleaned up in a later commit.

Change-Id: I37a2b641632af2cb515e3409deed5cd1fa358af5
2013-12-04 14:46:34 -08:00
jenkins-bot 4fe0bc5b80 Merge "Change signature of getDomFromData and rename" 2013-12-04 22:03:43 +00:00
Timo Tijhof 68cf65844e jscs: "var\t" -> "var "
Only 2 hits.

Change-Id: Ie8c5c39a49f620891bae8582dcc0d2f151e50e21
2013-12-04 21:06:19 +01:00
Roan Kattouw b3eb415e37 Remove ooui-inspector-* messages
Move existing uses over to the already existing visualeditor-inspector-*
messages.

Change-Id: I6da7f3d61256d1c2b4c1f9583da8bc59a2d7473d
2013-12-04 19:04:51 +00:00
Ed Sanders 86922f8ca8 Change signature of getDomFromData and rename
Currently it takes 4 arguments which are all properties
of the document model, so just pass the model instead and
access the properties later. Rename to getDomFromModel.

Change-Id: I0c378a04dc08b9b90bdc3984f8fa8c4acfe0b667
2013-12-04 16:30:40 +00:00
jenkins-bot 0b726589bd Merge "Fix spurious MetaList events" 2013-12-04 11:41:30 +00:00
Moriel Schottlender 87fd3b7756 Add direction classes to Toolbar based on context
Add rtl/ltr-related classes to the toolbar based on cursor context, so
certain icons can change based on inline and block directions.

Change-Id: I1b6e450226bf8da820fb622f28c1c3062c534bb0
2013-12-03 15:24:54 -08:00
Roan Kattouw 39eea83698 Fix spurious MetaList events
Moving items around in the MetaList only works if all deletions are
done before all insertions. This was almost but not completely true:
when moving an existing item we would delete it and immediately re-
insert it, meaning that if there were multiple items being moved
there would be a removal after an insertion.

Instead, let the insertion loop re-insert the moved items while
making sure not to emit insert events for them. This is how I
originally intended the code to be structured, but I thought that
duplicating the insertion would be equivalent to protecting the
emission of the insertion event. Clearly I was wrong.

This fixes weird bugs where categories sometimes appeared twice
in the category dialog depending on where the category was in
the list and what the exact length of the list was (i.e., whether
the binary search in the MetaList found the first or second item
with identical offset and index).

Change-Id: I4cd131052dda396add7a0e2dbe2383bb5c1b5721
2013-12-03 22:48:50 +00:00
jenkins-bot bbba628f3c Merge "Close inspectors when surface is focused but selection doesn't change" 2013-12-03 21:39:23 +00:00
jenkins-bot b5f04fe9e0 Merge "Use a global resizing flag on the surface to hide phantoms" 2013-12-03 03:22:56 +00:00
jenkins-bot 334bb899be Merge "Pressing enter in a list with no nearby content creates a paragraph" 2013-12-03 03:07:19 +00:00
jenkins-bot 76e3d9ec89 Merge "ve.ce.Surface.handleEnter tests" 2013-12-03 03:03:35 +00:00
jenkins-bot ad2fac3f92 Merge "Genericise runSurfaceHandleDeleteTest to work with other 'handle' methods" 2013-12-03 02:59:09 +00:00
Roan Kattouw da4995888b Close inspectors when surface is focused but selection doesn't change
It's possible for the user to put the cursor back from the inspector
in the surface without triggering a selection change, if the selection
was collapsed and they clicked in exactly the right spot.
In practice, this can happen if the link inspector is open in creation
mode and the user clicks to drop the cursor at the same position where
it was when the inspector was opened.

When this happens, the inspector wouldn't close, because it only closed
in response to selection changes. If the user then typed something,
weird things would happen.

To prevent this state (cursor is in surface but inspector is open) from
occurring, close the inspector and hide the context when the document is
focused. This fixes the link inspector creation mode issue, and it also
causes the link inspector to no longer briefly remain visible after the
user has clicked out of it.

Bug: 56976
Change-Id: Ib70fc13031873009a175e4b049a07694a87ce25d
2013-12-02 23:52:54 +00:00
jenkins-bot 4c54865134 Merge "Re-order command registry to match toolbar order" 2013-12-02 22:51:52 +00:00
jenkins-bot 5ca96e805f Merge changes I177877bf,I49a02b5d
* changes:
  Use visibility: hidden; for the ui.Context and its popup
  Followup eb95d7b0b2: don't hide the inspectors WindowSet at all
2013-12-02 21:18:55 +00:00
jenkins-bot e223156d06 Merge "Fix JS errors when inserting references" 2013-12-02 21:15:32 +00:00
Roan Kattouw 1df63b8a63 Use visibility: hidden; for the ui.Context and its popup
They contain iframes and those need to not be display: none;
in order to make Firefox happy.

Bug: 57568
Change-Id: I177877bff3c3b18bfc87ee4e6afa7e60fea26ffc
2013-12-02 13:03:06 -08:00
Roan Kattouw 07671c6b53 Followup eb95d7b0b2: don't hide the inspectors WindowSet at all
There's no point in hiding the WindowSet if we've already closed the
open window in it. In fact, there's no point in hiding a WindowSet
pretty much ever.

Change-Id: I49a02b5d255b266eb9e0a537cb64082eb0ad5e4b
2013-12-02 12:29:33 -08:00
Roan Kattouw f8ff2023c3 Fix JS errors when inserting references
ve.ui.MWReferenceDialog.prototype.teardown:
* Pass ranges rather than nodes to transaction builders
* Don't do a removal in insertion mode, we know the removal range
  will be empty

ve.dm.Transaction.newFromDocumentInsertion:
* Correctly splice the edited internalItem into listData in the case
  that newDoc isn't a document slice of doc
* Rename range to spliceItemRange for clarity
* Introduce spliceListNodeRange and set it to either newDoc's
  listNodeRange or doc's depending on whether newDoc is a slice of doc

Bug: 57683
Change-Id: Iae7de7701ae86bed89b707038407243d82249e1a
2013-12-02 11:35:00 -08:00
jenkins-bot 8c1f58979e Merge "Use visibility: hidden; to hide inspectors" 2013-12-02 19:26:07 +00:00
Roan Kattouw eb95d7b0b2 Use visibility: hidden; to hide inspectors
Using display: none; on the inspectors WindowSet causes Firefox to
neglect to load CSS in the inspectors' iframes, which means the frame
never initializes and the inspector never opens.

Bug: 57568
Change-Id: Ia1a0ce78754fa1318a7d439abe1f0e2f86420e7a
2013-12-02 10:42:31 -08:00
jenkins-bot 649c1aeb9e Merge "Add focus and blur events to ce.Surface" 2013-12-02 18:35:39 +00:00
Ed Sanders 456c97d912 Pressing enter in a list with no nearby content creates a paragraph
Currently we assume getNearestContentOffset will give us something
sane however it can return -1 when there is no nearby content and so
an exception is thrown. In this case we have to create an empty
paragraph to place the cursor in.

Change-Id: Ic6c19da881e47ff6be45cdaa4b71bfcc1c654796
2013-12-02 15:57:43 +00:00
Ed Sanders 519e54d463 ve.ce.Surface.handleEnter tests
Change-Id: Ic30cd4e116029be85822f73dcb84938e641bc4b9
2013-12-02 15:57:41 +00:00
Ed Sanders 96e2313e6e Genericise runSurfaceHandleDeleteTest to work with other 'handle' methods
We will want to reuse this test runner for handleEnter and handleInsertion.

Change-Id: I7489bf2d20fa17b1c164ff20e0cfcd9b9d5102d2
2013-12-02 15:52:44 +00:00
Ed Sanders 76091d4474 Re-order command registry to match toolbar order
Bonus: fix grammar in DialogAction comment.

Change-Id: I0fdf5f028f7191b0d662456ec1506490d7439a1a
2013-12-02 14:18:03 +00:00
jenkins-bot 2cf336b958 Merge changes Icb404af8,Ib6efc2a5,I6d48f8ee
* changes:
  Make autonumbered external links inspectable
  Always remove the annotation when the remove button is clicked
  Add abstract getAnnotation() method to AnnotationInspector
2013-11-30 08:58:09 +00:00
Roan Kattouw 93b645a453 Make autonumbered external links inspectable
When the target of an autonumbered link is changed to a URL, it's kept
as an autonumbered link and its target is updated. When the target is
changed to a MediaWiki page, the autonumbered link is removed and
replaced with an internal link with the text set to the target.
So for instance, if you inspect [http://www.example.com] and change
its target to "Foo", the result will be [[Foo]].

The core of this commit adds support for inspecting nodes to
ve.ui.LinkInspector. This support should probably move into a
class in between AnnotationInspector and LinkInspector, perhaps
called HybridInspector or something, but I'm deferring that for now.

LinkInspector allows changes to inspected nodes to be reflected either
as attribute changes on the node, or by replacing the node with something
else. MWLinkInspector uses this feature to replace the autonumbered
external link node with an internal link annotation when the target is
set to an external link.

Bug: 53505
Change-Id: Icb404af84c24574438e4de3ef05bbd1993b593f7
2013-11-30 00:14:41 -08:00
Roan Kattouw 8739772531 Add focus and blur events to ce.Surface
Didn't bother to deduplicate blur-focus event pairs that occur when the
focus moves from the documentNode to the pasteTarget or vice versa
(this happens when switching between normal selection and FocusableNode
selection).

Change-Id: If1ccd2fbf11de956b6c2364ae81b9dc20a1bf409
2013-11-27 21:56:34 +00:00
Roan Kattouw e41cb61814 Always remove the annotation when the remove button is clicked
Remove weird check that prevented a removal from happening if the
subclass's getAnnotation() method returned null.

This caused a bug where if you inspected a link, typed an invalid
link target (e.g. '|'), then clicked the remove button (trash can icon),
the inspector would close but the link wouldn't be removed.
However, if you typed something that was a valid link target (or didn't
touch the input at all), the remove button would work as expected.

Change-Id: Ib6efc2a5827b109c6b38185e6d89b7bb29b13a75
2013-11-27 14:55:33 +00:00
Roan Kattouw 0fe4a7778e Add abstract getAnnotation() method to AnnotationInspector
It was relied on, and all subclasses had one, but for some reason
it wasn't defined as an abstract method.

Change-Id: I6d48f8ee666bd339be87744840c6edb4abb56dbf
2013-11-27 14:52:18 +00:00
Timo Tijhof c852bf6000 ve.js: Coding style fixup for 6f2090aac6
Change-Id: I5ef9d590b5cc573df64f1c9099c79207c471cfb6
2013-11-26 23:00:24 +00:00
jenkins-bot 91f00b0eaf Merge "Revert model to use simple UTF-16 code units" 2013-11-26 22:53:06 +00:00
jenkins-bot c18534bcad Merge changes If814e178,Id133431e,I38d63e31,I16d575b6
* changes:
  Plain text paste with paste special
  Use rare unicode characters for paste placeholders
  Rich paste
  Add fixUpInsertion to newFromDocumentReplace
2013-11-26 21:07:46 +00:00
jenkins-bot 29d33c4528 Merge "Fix moving over an image with the arrow keys in Firefox" 2013-11-26 19:51:27 +00:00
David Chan 6f2090aac6 Revert model to use simple UTF-16 code units
This is a prerequisite to browser-based grapheme cluster handling, which
is needed so left/right cursoring and backspace behave as users expect.

modules/ve/ve.js
modules/ve/ce/ve.ce.Document.js
modules/ve/ce/ve.ce.js
* Revert cluster-aware splitting to trivial javascript code unit splitting
* Rewrite ve.splitClusters as a trivial compatibility method (remove soon)
* getClusterOffset/getByteOffset use unicodeJS.graphemebreak.splitClusters

modules/unicodejs/tools/unicodejs-properties.py
modules/unicodejs/unicodejs.graphemebreakproperties.js
modules/unicodejs/unicodejs.js
* Allow grapheme break tests to work with surrogate pairs

demos/ve/pages/minimal.html
demos/ve/pages/multibyte.html
demos/ve/pages/unicode.html
* replace file with more precise tests

modules/ve/test/ve.test.js
* Remove reference to grapheme-based splitting (which is no longer used)
* Correct typo

Bug: 53757
Bug: 51472
Bug: 51596
Bug: 51846
Change-Id: Ife34c87ebe40bc1689298b592eec5c0cdc2f7589
2013-11-26 19:38:14 +00:00
Ed Sanders b1e6dfcda6 Plain text paste with paste special
Register ctrl/cmd+shift+v as a trigger which sets a flag for the
next paste event.

When the paste special flag is set, modify the sanitizeData method
to strip all annotations, and any elements other than paragraphs.

Bug: 53781
Change-Id: If814e1786ffa805b52ab32f4a06f52da743fd9af
2013-11-26 18:23:58 +00:00
Thalia 65aab78d3b Use rare unicode characters for paste placeholders
Helps with bug reporting, like the snowman and pawn.

Change-Id: Id133431eea987442c8b50a05821ebd54649b26b9
2013-11-26 18:23:58 +00:00
Ed Sanders 7cec9ae04a Rich paste
Allow pasting of rich (HTML) content.

ve.ce.Surface
* Use a sliced document clone for converting to DM HTML (copy)
* Add full context to pasteTarget before copying
* Add ve-pasteProtect class to spans to prevent them being dropped
* Implement external paste by converting HTML to data and inserting
  with newFromDocumentInsertion
* Remove clipboard key placeholder after read so they aren't picked
  up by rich paste. Hash no longer includes the placeholder.
* Detect the corruption of important spans and fallback to clipboard
  data HTML if available.

ve.dm.LinearData
* Add clone method for copy

ve.dm.ElementLinearData
* Add compareUnannotated for use by context diffing.
* Add sanitize method for cleaning data according to a set of rules.

ve.dm.Transaction
* Add range parameter for inserting a range of a document only,
  e.g. stripping the paste context.

ve.dm.Document
* Implement sliced document clone creation so that DM HTML
  is generated correctly in onCopy

ve.dm.DocumentSlice
* Replaces LinearDataSlice. Now has two ranges for balanced data
  and data with a full context.

ve.init.Target.js
* Define default, loose, paste rules (just remove aliens).

ve.init.mw.ViewPageTarget
* Define strict MW paste rules:
  + no links, spans, underlines
  + no images, divs, aliens
  + strip extra HTML attribues

ve.init.sa.Target, ve.init.mw.ViewPageTarget, ve.ui.Surface
* Pass through and store paste rules.

Bug: 41193
Bug: 48170
Bug: 50128
Bug: 53828
Change-Id: I38d63e31ee3e3ee11707e3fffed5174e1d633b42
2013-11-26 18:23:12 +00:00
Roan Kattouw 21c72a553a Fix moving over an image with the arrow keys in Firefox
There was a bug when you moved over an image with the arrow keys:
if your selection was on an image and you pressed an arrow key, the
selection would move but focus would remain with the paste target
rather than going back to the document node, which caused strange
symptoms (immobilizing the arrow keys and scrolling horizontally)
in Firefox.

Bug: 57600
Change-Id: Iaf6a49787dd2fd2f3f88abd0d1f5ae512fd3fd68
2013-11-26 17:09:30 +00:00
Rob Moen 07464e20a5 Remove the toolbar tracker
We were using it for the pop-out save dialog, but now that the save
dialog is real dialog, we don't need it any more.

Change-Id: I72697b5502d5f3fd19f2369a754a62d614af715b
2013-11-26 13:37:50 +00:00
David Chan b4f4eeb4b6 Event Logger: collect IME functionality info
ve/ce/SurfaceObserver.js
* Do not setTimeout if frequency === null

demos/ve/eventLogger.html
* Standalone event logging script

ve/test/ce/imetests/*.js
* JSON event logs for various tests/browsers/IMEs

ve/test/ce/ve.ce.test.js
* Add an IME test

VisualEditor.hooks.php
* Add test files

Change-Id: I50e89d5a289f3fcb4fe2a6835a2ec96fb497242c
2013-11-25 16:56:09 +00:00
David Chan addd1d7b23 Test Surface with IME-like event sequences
* modules/ve/test/ce/ve.ce.TestRunner.js
Class to interact with the CE Surface and document in tests

* modules/ve/ve.EventSequencer.js
Wrap setTimeout/clearTimeout calls (for easy replacement in tests)

Change-Id: I2e2407e2b169ae77237c87bf8857b3026cc7efce
2013-11-25 16:49:49 +00:00
jenkins-bot 4f573a3ea2 Merge "Recompute auto-numbered reference listKeys when merging internalLists" 2013-11-20 11:33:15 +00:00
jenkins-bot 9093eff614 Merge "Fix reference to insertItem() in MetaList, was renamed to insertMeta()" 2013-11-20 11:31:37 +00:00
Ed Sanders 24a95b102d Add fixUpInsertion to newFromDocumentReplace
In order to do this we have to separate out the removal
operation from NDFR, so it becomes newFromDocumentInsertion
(again, although actually, for the first time). As NFDI is
an insertion we can just run fixUpInsertion on the data
part of it.

In order for the removal operation to be a proper removal
we have to allow metadata removal (the default is to merge it).

Change-Id: I16d575b61b9796e7e889f2c27cfe02b4a40b7639
2013-11-20 11:24:06 +00:00