Ensure we start with the same HTML (i.e. if an edit has
been made since the crash-recovery):
* Whenever an article target is activated, stash the initial
document html, other parsoid response data, and the request
parameters (pageName, mode, section) in session storage.
* Whenever an article is fetched through the target loader,
recover from session storage if the request parameters match.
Store transactions:
* On document transaction (debounced) append the latest
changes to session storage.
* If a document state is recovered from session storage,
attempt to re-apply the stored transactions.
Clear transactions:
* Whenever the target is torn down (i.e. save, deliberately
closing the editor to go back to read mode)
Other:
* If writing to session storage fails once, disable future
attempts for that session (assume storage quota exceeded)
* Disable tempWikitextEditor when recovering. We don't have
the transaction code loaded yet to perform the recovery.
Bug: T57370
Depends-On: I3832243fc347a99641fcb7e39a887a153c9a3b22
Depends-On: I448fb566fe9f7f5b5a76e88b70ca000e3d35b415
Change-Id: Id9d877f903cf4796a52f90991c030417a9f8786f
mw.storage catches errors, so we won't crash horribly when the user has
localStorage disabled / full.
Bug: T181822
Change-Id: I212994eb535b9a8fb5f6c09deaa10b16c3d7f10e
Accesskeys in this situation are unreliable cross-browser. Firefox won't
trigger the accesskey inside the dialog. We can manually simulate it, via the
existing trigger.
Bug: T121183
Change-Id: Ib919d8b9fcd9324a517037bcc6ef93a26d1488b9
We need this hack when visually editing articles, but not in e.g. the
Flow integration. Move it down so that mw.Target has a clean
parseDocument method that can be used by Flow without undesirable
newlines being introduced.
Change-Id: I52bba88b3d33c3d6d16c4cf832f23f970a243abf
Idea being: preload use case is often "load content, maybe with parameters,
immediately save it", so we can treat it as being already-modified for saving
purposes.
Bug: T179063
Change-Id: I35ff04bc9cb5172edf8174832624145973aa1fdb
* Rename 'deactivate' to 'tryDeactivate' as it may prompts
the user to deactivate.
* Merge 'cancel' and 'teardownSurface' in to 'teardown',
extending the parent method.
* Rename elementsThatHadOurAccessKey to $saveAccessKeyElements
and move teardown to parent class where it is setup.
* Move toolbarSaveButton teardown to parent class where it is setup.
* Cleanup changeDocumentTitle
Depends-On: I9d97614695272dca6936ef6f3461178fcf0368a8
Change-Id: Ie998a04c21f6615b4415edf471310db5edca3b5a
The default value of target#pageName is wgRelevantPageName
but other targets my override this, or change it dynamically
(e.g. ContentTranslation).
Also remove duplicate setter of pageName in mw.ArticleTarget,
already set in mw.Target.
Change-Id: Iebd1def1d4142978a673afec584a0b663644d176
Other page state is read directly, rather than passed in.
If we come up with a use case for passing this in at a later
date we can reconsider the best way to do this.
Change-Id: Iee7e608c969776b89dbb38b3b56a5177e48344af
Instead, use getCheckboxesDefinition(), and build our save form
checkboxes from that rather than extracting them from the HTML.
The ability to have non-checkbox fields there is removed, as that was
never intentional and is now impossible.
To avoid transient problems during deployment (old JS code cached in
the user's browser receiving the new format of API responses), the old
property is kept in the API response. We should remove it next week.
Bug: T174613
Bug: T174686
Change-Id: I5bfca5e116fe790302c3b6ac1357e80237fb1ed2
ve.init.mw.Target.static.parseDocument requires that its parameter be
a complete HTML document with a single root tag, otherwise some of its
workarounds break horribly in IE 11 (and possibly Firefox).
Bug: T171600
Change-Id: Iaacf24f7bef40a24230fcfa08e15bab31b1587c0
This stops the welcome dialog from being displayed repeatedly if the user
edits the article multiple times in the same pageload.
Bug: T170983
Change-Id: I8cc5990e9acb1ac09a2d6dd95eef8042c70088c7
Any MW target may want to get a wikitext fragment, not just
ArticleTargets. Requires us to move refreshEditToken up as well.
Change-Id: I27d30e20fefd5ba266d3d8e5f99383e9b4d4993a
* Fix focus and resize/scroll into view after the
captcha has loaded (so after the image has loaded
for FancyCaptch).
* Add margin between input and captcha
* Enable enter-to-submit on captch input field.
* Unify code for simple/math/questy and correctly
render math as HTML (by looking at the mime type)
Change-Id: I10433cefbfea8569674c120dde5b489570e20966
Sites like to customize 'readonlywarning' with things that we can't parse.
Instead, use 'apierror-readonly'. The old message is still shown in edit
notices.
Bug: T163455
Change-Id: I592accde17b256ecee27820df12d9d312499f8f7
If we retry and get another 'badtoken' error, something is very wrong,
and trying again and again is probably pointless. This behavior also
matches how mw.Api#postWithToken handles bad tokens.
Bug: T163493
Change-Id: I488fd7e74e37922044491695d6c9025a45531281
* Pass a wikitext promise, instead of wikitext
* Handle writing of content to the dialog from within
the dialog.
* Handle diff errors within the dialog.
* Never disable the 'Return to save form' (approve) button
* Remove redundant messages
Change-Id: Ibd76e8951998f751abfb4f407682202c2f73ac7e
This will be required later when we have to fetch the original
document from the server before running a visual diff.
Change-Id: I351688f4d1fec892bc297f40c209939cbb2ccf95
Provide a utility funcition in ve.init.mw.LinkCache to do this.
Also use this in ve.ce.MWTransclusionNode/ve.ui.MWPreviewElement, and
introduce to ve.ce.MWExtenionNode
Bug: T73900
Bug: T153535
Change-Id: Ieb9a0274b8c5ae1932c431546f09d18000fa6dd9