Commit graph

651 commits

Author SHA1 Message Date
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
Roan Kattouw cde3304864 Recompute auto-numbered reference listKeys when merging internalLists
This fixes some of the problems with pasting references.

It's a bit overzealous in that references get renumbered even when
replacing, which is unnecessary but doesn't actually have any
noticeable effect.

Unfortunately, the internal list state depends so much on the converter
having run that we now need to add yet another hack, to set the counter
to the appropriate value.

Change-Id: I3c6514ce600af4f4c037f419554d34b5a5c86a63
2013-11-20 16:50:48 +05:30
jenkins-bot 137ca9d2d6 Merge "Store inner whitespace of the body and compare it on conversion" 2013-11-20 10:45:04 +00:00
Timo Tijhof de979ff293 Replace raw oojs-ui files with v0.1.0-pre (0267100ab3)
Change-Id: I792bc0335269976ff29433227b6fa562a1026aeb
2013-11-20 10:27:48 +05:30
Trevor Parscal 3dcba7679a Add OO.ui.ToggleWidget
Compact toggle widget with short labels for on/off states.

Change-Id: I582e81126d5f1564302409c1b262e28e4a9505ac
2013-11-12 16:54:35 -08:00
Trevor Parscal 65a2f41268 Cleanup after window refactor
Related to: I82c4fed8bcb3fb5630938c8bc4dd9b2d5f1a8c1d

Change-Id: I4cc280725315fee0c5dd042479d4373cc0cdd0b4
2013-11-12 12:02:28 -08:00
Trevor Parscal 4192cbc4d5 Window refactor
Changes:

* Cleanup the window API to use more consistent and intuitive methods - we
  now use initialize/setup/teardown instead of
  initialize/onSetup/onOpen/onClose as methods which are overridden, and
  use open/close methods to control the window
* Change events around to have opening/open and closing/close events which
  act as before/after points during the opening/closing process
* Make WindowSet and Context respond to windows being opened, rather than
  opening them directly
* Fix a LinkInspector creation mode bug where the initial text doesn't get
  reset
* Move inspector, a VisualEditor concept, back to VE
* Cleanup naming of SurfaceDialog, SurfaceToolbar, etc. to use shorter
  names, they were given Surface* names when the generic ones were also in
  VE, but now the generic ones are in OO, so they can return to their
  original names

Change-Id: I82c4fed8bcb3fb5630938c8bc4dd9b2d5f1a8c1d
2013-11-08 12:33:25 -08:00
Trevor Parscal db9f941fa6 Rename this.$ to this.$element, and this.$$ to this.$
Objectives:
* Rename this.$ to this.$element
* Rename this.$$ to this.$
* Get rid of the need to use this.frame.$$
* Rename OO.ui.Element.get$$ to OO.ui.Element.getJQuery

Changes: (using Sublime Text regex patterns)
* Replace "get$$" with "getJQuery"
* Replace "\.(\$)([^\$a-zA-Z])" with ".$element$2"
* Replace "\.(\$\$)" with ".$"
* Replace "'$$'" with "'$'"
* Set this.$ to null in constructor of OO.ui.Window
* Set this.$ to this.frame.$ in initialize method of OO.ui.Window
* Replace "\.(frame.\$)([^\$a-zA-Z])" with ".\$$2"

Bonus:
* Use this.$() in a bunch of places where $() was erroneously used

Change-Id: If3d870124ab8d10f8223532cda95c2b2b075db94
2013-11-03 23:03:49 -08:00
Ed Sanders 3838498e8b Store inner whitespace of the body and compare it on conversion
Calculate and store the two inner whitespace values of the body in the
dm.Document. When converting back, make sure the first/last nodes
pre/post outer whitespace matches the inner left/right whitespace
of the body.

Bug: 54964
Change-Id: I45f1ffd63669f25a6cae878400bfe21719ed58ee
2013-10-31 17:09:06 +01:00
Ed Sanders 91f6b1d86c Fix: getDataFromDom tests should check for body or head
This wasn't updated when Roan split html into body & head, so
0 tests were running!

Change-Id: I4396b94426b2009f20707d64bf3d0f1ae651dbc8
2013-10-31 09:02:19 +00:00
Ed Sanders 5aa7f6526c Fix: files missing from demo and test runner
Change-Id: I783384a28147c9c7cdfdcb6639fea1f197cffb54
2013-10-31 08:57:39 +00:00
Trevor Parscal a3295f0939 Allow direct opening of pages in the meta dialog
Objectives:

* Hamburger menu in actions area of toolbar
* Add tools that open specific pages in the meta dialog
* Fix support for using setPage in ve.ui.PagedOutlineLayout
* Allow passing setup config objects through window open calls
* Add dialog action, similar to inspector action
* Fix incorrect or missing documentation

Change-Id: I2d2c9b87554fb2a0c90ed6944a58b38a37efa712
2013-10-29 05:58:06 +00:00
Trevor Parscal 0ee35c99d0 Add OO.ui.PopupTool
Tool that launches a popup when clicked.

Change-Id: Ie35b51f8160ad3fb844491e2799656413d4029c0
2013-10-29 05:57:40 +00:00
Trevor Parscal d2dfb9ac4f Split oojs-ui from ve.ui
* Move and rename generic parts of ve.ui to OO.ui
* We now have a UI test suite because ve.Element (outside ve.ui)
  is now part of oojs-ui, so it needs a test suite.
* Added to the MW test run (just like we do for unicodejs).
* Updated csslint config (also added ve-mw and syntaxhighlight
  which were missing).

oojs-ui still depends on the TriggerRegistry in VE, this is addressed
in a follow-up commit.

Change-Id: Iec147155c1ddf20b73a4d15d87b8742207032312
2013-10-28 22:40:08 -07:00
jenkins-bot cc8010e556 Merge changes Ia6ca85bc,I919135eb,Ia18bd8fc,I49dfc81f,Ia234f174,I06425e2c,Ia192331b,I5624ae07
* changes:
  Get rid of dmRendering hack in ve.ce.MWInternalLinkAnnotation
  Render resolved URLs for href and src attributes in CE
  Give ce.Annotations a reference to their ce.ContentBranchNode
  Track the original HTMLDocument in ve.dm.Document
  Create CE nodes and annotations with the correct $$
  Add ve.resolveUrl for URL resolution
  Don't render href as src in MWBlockImageNode
  Rename 'html' to 'body' in converter tests
2013-10-28 18:55:11 +00:00
jenkins-bot 6bfa803fda Merge "Resolve rendered URLs according to the provided <base>" 2013-10-28 18:32:55 +00:00
Roan Kattouw a05703114a Track the original HTMLDocument in ve.dm.Document
Add it as an optional parameter to the constructor, and create a new
one if omitted.

This is going to be used to resolve URLs according to the right <base>,
but really that's a hack and we should come up with a better way to
track metadata from the <head>.

Change-Id: I49dfc81ff793d73e08a20e502d681a15613d23f7
2013-10-28 15:48:55 +00:00
Roan Kattouw 904abe74c8 Create CE nodes and annotations with the correct $$
Most of CE wasn't passing through $$ at all. Also fix CE tests that
weren't passing the required surface parameter to the ce.Document
constructor.

Change-Id: Ia234f174050f4b2666ec20e8acc24c6aa4305202
2013-10-28 15:48:51 +00:00
Roan Kattouw 17192da3a2 Add ve.resolveUrl for URL resolution
Use it to replace fullUrl in the tests

Change-Id: I06425e2c90a08a6f622e083f9297444f6f4672e8
2013-10-28 15:48:45 +00:00
Roan Kattouw 608b8d378d Rename 'html' to 'body' in converter tests
Because that's what it is now since 'head' was added. Also removed
the wrapping <body> tag (now added by the test runner) and renamed
normalizedHtml to normalizedBody.

Change-Id: I5624ae076c5e661d2789e499cd28e8282c885409
2013-10-28 15:46:55 +00:00
Roan Kattouw 74b8807df5 Resolve rendered URLs according to the provided <base>
This is done by using the computed property value rather than the
literal attribute value when rendering href and src attributes.
Helpfully, this provides perfect URL resolution natively in the browser,
which means the document's <base> is respected and all that good stuff.

For GeneratedContentNodes, we also need to find all DOM elements inside
the rendered DOM that have href or src attributes and resolve those.
This is done in the new getRenderedDomElements() function, which the
existing cleanup steps (remove <link>/<meta>/<style>, clone for
correct document) were moved into.

In order to make sure that the computed values are always computed
correctly, we need to make sure that in cases where HTML strings
in data-mw are parsed, they're parsed in the context of the correct
document so the correct <base> is applied.

We still need to solve this problem for models that actually store and
edit an href or src as an attribute. I'll post more about that on
bug 48915.

Bug: 48915
Change-Id: Iaccb9e3fc05cd151a0f5e632c8d3bd3568735309
2013-10-28 15:16:05 +00:00
Ed Sanders 59fa4c1097 Remove ve.ce.Surface.static.textPattern
It hasn't been used for a while.

Change-Id: I7d004f38bc76ef8a794294a7c685ada73ab7855e
2013-10-28 14:44:23 +00:00
jenkins-bot 291e1f3449 Merge changes Iaba76ac1,Ib15c39f3,If5a3b4d4,I44425d26,I8f162894
* changes:
  .change( null, foo ) -> .setSelection( foo )
  Remove SurfaceObserver locking (unused)
  Implement ve.dm.Surface.prototype.undo() and redo() in terms of change()
  Enslave dm.Surface to dm.Document
  Remove dm.Surface's 'change' event
2013-10-25 21:05:32 +00:00
jenkins-bot e180b8c1ca Merge changes Ifeb1a1fc,I521eff00
* changes:
  Migrate away from using the 'change' event in dm.Surface
  Make dm.Surface's 'select' event more useful
2013-10-25 17:59:00 +00:00
Roan Kattouw 534f0bdde7 .change( null, foo ) -> .setSelection( foo )
Change-Id: Iaba76ac17888a7825f5a9cd1c383d4f429454278
2013-10-25 18:29:49 +01:00
Roan Kattouw 1bf58252ce Implement ve.dm.Surface.prototype.undo() and redo() in terms of change()
...or really changeInternal(), so we can avoid adding undo transactions
to the undo stack.

Also get rid of the pattern where undo() and redo() return a selection
which the caller then has to restore, and instead just restore the
selection.

Bug: 53224
Change-Id: If5a3b4d4162e9f0713ee9cd26e79a66efe52770f
2013-10-25 18:29:48 +01:00
Roan Kattouw b7ee30d4e4 Enslave dm.Surface to dm.Document
* Replace surface 'transact' event with 'documentUpdate' event
* Have surface listen for all document transactions and update selection
  as appropriate (as well as emitting 'documentUpdate')
* Implement change() in terms of setSelection()
** Queue 'contextChange' events so contextChange is only emitted once
** Use this.transacting flag to prevent setSelection() (which is called
   because the model emits transact events) from doing too much
** Behavioral change: lock/unlock now emitted separately for
   transaction and selection changes

Change-Id: I44425d260ec70758f99d13f99e41f5c993d260c2
2013-10-25 18:29:48 +01:00
David Chan 04cbbef4ee Remove dm.Surface's 'change' event
ve.dm.Surface.js:
* Stop emitting 'change' and remove its event documentation

ve.ce.Surface.js:
* Listen to 'select' instead of 'change'
* Perform a CE surface update after model-based keydown handling

ve.dm.Surface.test.js:
* Stop asserting that 'change' is emitted

Change-Id: I8f16289493e835d890709c6dfe093d04c18522b6
2013-10-25 18:29:13 +01:00
jenkins-bot 044e2e289c Merge "Split ext.visualEditor.experimental into specific modules" 2013-10-24 14:05:33 +00:00
Roan Kattouw 412eb34de8 Split ext.visualEditor.experimental into specific modules
Math, hiero, language and alienextension are now each in their own
module. Kept the experimental module for backwards compatibility,
it just has all of its constituent modules as dependencies.

MWExperimentalTool.js was split up, and ExperimentalTool.js was
renamed to LanguageInspectorTool.js.

Change-Id: I63b49dfbdb59dc9a494049553cc0c01e89e48826
2013-10-23 16:20:30 -07:00
Ed Sanders 58fba521e0 Use jsdifflib for QUnit diff
Because QUnit's inline diff is terrible for large diffs,
especially when there are block whitespaces changes.

Change-Id: I786fb981b02777ede38c4bee261f9e32f8f908ed
2013-10-23 20:31:17 +00:00
Roan Kattouw 53e4c370ea Migrate away from using the 'change' event in dm.Surface
Instead, listen to 'select', or to 'transact' on the dm.Document.

This commit only fixes uses outside of the dm/ce.Surface ecosystem.
ce.Surface still listens to 'change'.

ve.init.mw.ViewPageTarget.js:
* Rename onSurfaceModelTransact to clearSaveDialogDiff and bind it to
  the document's transact event instead
* Rename onSurfaceModelChange to checkForWikitextWarning and bind it
  to the surface's transact event. This is needed because the function
  inspects the surface's selection, which isn't yet in a consistent
  state when the document's transact event fires

ve.ui.MWReferenceDialog.js:
* Rename onSurfaceChange to onDocumentTransact and rebind accordingly

ve.ce.ProtectedNode.js:
* Get rid of onSurfaceModelChange
* Instead, bind positionPhantoms to the document's transact event
  directly, and only bind it while phantoms are visible

ve.ui.Context.js:
* Rename onChange to onModelSelect and rebind accordingly
* Rename afterChange to afterModelSelect
* Drop check for undefined selection, no longer needed now that we're
  listening to a finer-grained event

ve.ce.Surface.test.js:
* Listen to 'select' instead of 'change'

Change-Id: Ifeb1a1fc5427696f2aae5441d4b54dde366793e0
2013-10-23 11:54:35 -07:00
Roan Kattouw 36fc3b5911 Rename oo.js to oojs.js per library name
Change-Id: I9f02a4438a18243022506b5a2fcc445af03aa945
2013-10-22 19:18:32 +00:00
Trevor Parscal 26a1d8986b Remove ve.Factory and ve.Registry and use oojs instead
Change-Id: I2717300e6cc6102296a2b8d063d344fa5897c825
2013-10-22 19:15:18 +00:00
Trevor Parscal b635541de2 Remove ve.getHash and use getHash from oojs instead
Change-Id: Ib688a3ba0ab07e0d0dc328a3878440756d1103fe
2013-10-22 19:14:23 +00:00
Trevor Parscal 6018e77d70 Use OO.EventEmitter instead of ve.EventEmitter
Change-Id: Ie35e5f51a8d3c0d7f4fa46230b7b37112df610b9
2013-10-22 16:57:33 +00:00
Trevor Parscal efafed3231 Remove ve.{inheritClass,mixinClass} and use OO instead
Change-Id: I8df9226a358a76b661eab6e967ff0d63d361f691
2013-10-18 18:58:08 +02:00
Trevor Parscal 81bbba4932 Split out popup functionality from ve.ui.PopupButtonWidget to ve.ui.PopuppableElement
Change-Id: I522d852d81d9674723a3262da3f030417f4fc3be
2013-10-17 10:21:03 -07:00
Timo Tijhof 4ba01f08c3 Regenerate static loaders to include newly added ui.layouts
Follows-up 4efc6ca.

Change-Id: I51f3c861c88f93bf76f6c0f16ab0c3928b30b839
2013-10-16 12:17:50 +00:00
Trevor Parscal 395d5f563c Remove ve.isMixedIn(), it's unused and it's evil
Change-Id: I5a5fc4c8eb56530dbac3bc32122faf20b8c92aa5
2013-10-11 21:51:01 +00:00
Ed Sanders bffa0df53f Prevent deletion of FocusableNodes from a collapsed selection
Instead select the node and require the user to press delete
again if they really meant to delete the node.

Also test cases!

Bug: 55336
Change-Id: I66520e18740e78ce6313f9b31bb575d06b91bea8
2013-10-09 17:41:31 +02:00
jenkins-bot 846414f215 Merge "Destroy test surfaces" 2013-10-08 09:19:03 +00:00
Ed Sanders c752215896 Destroy test surfaces
Also make sure surface observers are detached so they don't try to
poll the CE when it has been destroyed. This was causing exceptions
to be thrown in test runners.

Change-Id: Ic8864a73f3ee04da6018f552b1aa68748d7ffba7
2013-10-08 11:16:10 +02:00
jenkins-bot 1e0c24da49 Merge "Make dialogs, inspectors windows and window sets generic" 2013-10-07 18:55:07 +00:00
Trevor Parscal 4aa86d0f87 Make dialogs, inspectors windows and window sets generic
Objective:
* Remove surface dependencies in dialogs, inspectors, windows and window sets
* Introduce surface-specific versions of dialogs, inspectors and window sets

Change-Id: I2db59127d2085b02e173a3605e174317e419e213
2013-10-07 10:37:47 -07:00
jenkins-bot ac0f2ba092 Merge "Refactor out data processing from ve.dm.Document constructor" 2013-10-07 16:36:02 +00:00
Ed Sanders a8d84db0e8 Refactor out data processing from ve.dm.Document constructor
Also make collection of metadata and construction of nodes optional.

Change-Id: I02ba6d2199caccaf9fe9dcfba58eefa7b52c52b1
2013-10-07 17:26:21 +01:00
jenkins-bot 00b6de429b Merge "Use FlatLinearData for storing converter results" 2013-10-07 14:47:21 +00:00
Ed Sanders e9a8c62692 Remove PagedDialog from test files
Fix for patch I5efa2f893f4b which only removed one reference to the file.

Change-Id: I89b9f30ee8309e1cba0ed98a74238ba671b76a59
2013-10-07 10:57:42 +01:00
Ed Sanders 44b1fdebe4 Use FlatLinearData for storing converter results
Previously we returned ElementLinearData from the converter, then
stripped out the MetaLinearData. This meant that before processing
the ElementLinearData from the converter actually contained metadata
which is confusing.

The new document constructor stores the converter results in a
FlatLinearData object and simultaneously populates element and meta
data stores.

Also in this commit I have moved various methods from ElementLinearData
to FlatLinearData, from which ElementLinearData inherits.

Change-Id: I64561bde2c31d8f703c13ac7b0a0c5f7ade9f3d4
2013-10-06 20:27:32 +01:00