Commit graph

179 commits

Author SHA1 Message Date
Catrope 4b086b94d7 Make the full document regex hack a bit more robust
Anchor the regex and make it look for doctype too

Change-Id: I43abb6f214a28801642bde46b50f4ac12614d1e4
2013-02-21 14:59:19 -08:00
James D. Forrester 82114467f1 Bump copyright notice year range to -2013 over -2012
199 files touched. Whee!

Change-Id: Id82ce4a32f833406db4a1cc585674f2bdb39ba0d
2013-02-19 15:37:34 -08:00
Catrope 3035c311ec Make the converter work with full HTML documents rather than fragments
The Parsoid output will also be expected to be a full HTML document. For
backwards compatibility, we allow for the Parsoid output to be a
document fragment as well. We don't send a full document back yet, also
for b/c -- we'll change this later once Parsoid has been updated in
production.

ve.dm.Converter.js:
* Make getDataFromDom() accept a document rather than a node
** Split off the recursion (which does use nodes) into its own function
** For now we just convert the <body>. In the future, we'll want to do
   things with the <head> as well
* Pass the document around so we can use it when creating elements
* Make getDomFromData() return a document rather than a <div>

ve.init.mw.Target.js:
* Store a document (this.doc) rather than a DOM node (this.dom)
* Pass around documents rather than DOM nodes
* Detect whether the Parsoid output is an HTML document or a fragment
  using a hacky regex
* When submitting to Parsoid, submit the innerHTML of the <body>

ve.init.mw.ViewPageTarget.js:
* s/dom/doc/
* Store body.innerHTML in this.originalHtml

ve.Surface.js:
* s/dom/doc/

demos/ve/index.php:
* Don't wrap HTML in <div>
* Pass HTML document rather than DOM node to ve.Surface

ve.dm.Converter.test.js:
* Construct a document from the test HTML, rather than a <div>

ve.dm.example.js:
* Wrap the HTML in the converter test cases in <body> tags to prevent
  misinterpretation (HTML fragments starting with comments, <meta>,
  <link> and whitespace are problematic)

Change-Id: I82fdad0a099febc5e658486cbf8becfcdbc85a2d
2013-02-19 10:38:39 -08:00
jenkins-bot a7030a5148 Merge "Abort activation when changing to view mode." 2013-02-16 01:04:52 +00:00
Rob Moen 3070d0c56e Abort activation when changing to view mode.
Resolves (Bug 44838)

Changes:
* onLoad: Setup only if activating.  Prevents ve from loading after aborted
while activating.

* onViewTabClick: add clause for activating mode.  Calls deactivate with an
override, and exits activating mode.

Change-Id: Ia61cd1d576b63098419474ad58bc01362c08541e
2013-02-11 11:38:50 -08:00
Catrope 36d99ad901 Add Iceweasel to supported browsers list
Depends on https://gerrit.wikimedia.org/r/46666

Change-Id: I1192ce6687ba69504d0c4be484e479ddebedbc87
2013-01-29 17:53:09 -08:00
Trevor Parscal bf5ba1ea2b Fixed documentation errors
Many of these problems were introduced in I859b5871a9d2f17d970c002067c8ff24f3513e9f

Change-Id: Ifc2dc4934f782c4ce5107e3a356e357aef754083
2013-01-22 23:38:01 +00:00
Rob Moen 464471b538 Enable VisualEditor in MediaWiki integration for IE 9 and up.
Change-Id: I987223589c2a6b61dde5e2db8234cca40e237eec
2013-01-22 12:59:03 -08:00
Rob Moen 8ba81f4d67 Add interplatform, i18n shortcuts to ui buttons.
Objective:
* Put command shortcuts in button title attributes. (Bug 42919)
* Provide a registry for platform specific command triggers and their
corresponding i18n messages. (Bug 44012)
* Enable loading of triggers after ve.Surface is created. (lazy load)

Changes:

VisualEditor.i18n.php
* Add default trigger i18n messags for mac and pc system platforms

VisusalEditor.php, demos/ve/index.php
* Add links to files

ve.init.mw.Platform.js
* Define getUserLanguage and getSystemPlatform methods.

ve.init.sa.Platform.js
* Define getUserLanguage and getSystemPlatform methods.

ve.init.Platform.js
* Define abstract methods: getUserLangauge, getSystemPlatform

ve.ui.BoldBUttonTool.js, ve.ui.IndentButtonTool.js, ve.ui.ItalicButtonTool.js,
ve.ui.LinkButtonTool.js, ve.ui.OutdentButtonTool.js, ve.ui.RedoButtonTool.js,
ve.ui.UndoButtonTool.js
* Add registration for command triggers.

ve.Surface.js
* Methodize loading of triggers.
* Bind register event to ve.triggerRegistry to allow lazy loading of triggers.

ve.ui.Tool.js
* Init pre-registered tooltip messages.
* Update tool titles when new triggers are loaded.

ve.CommandRegistry.js
* Remove command registration ( moved to buttons themselves )

ve.TriggerRegistry.js
* New class for registering triggers.

ve.init.mw.ViewPageTarget.js
* Changed instance of unindent command to outdent.

Change-Id: Id8580a3f81aac751db0b7482422a73912648dfed
2013-01-17 15:28:32 -08:00
Trevor Parscal 8d33a3de0d Major Documentation Cleanup
* Made method descriptions imperative: "Do this" rather than "Does this"
* Changed use of "this object" to "the object" in method documentation
* Added missing documentation
* Fixed incorrect documentation
* Fixed incorrect debug method names (as in those VeDmClassName tags we add to functions so they make sense when dumped into in the console)
* Normalized use of package names throughout
* Normalized class descriptions
* Removed incorrect @abstract tags
* Added missing @method tags
* Lots of other minor cleanup

Change-Id: I4ea66a2dd107613e2ea3a5f56ff54d675d72957e
2013-01-16 15:37:59 -08:00
Trevor Parscal f31dc45da8 (bug 43841) Major ve.ui rewrite, especially ve.ui.LinkInspector
Objectives:

* Make the link inspector easier to use
* Try to resolve a few bugs (bug 43841, bug 43063, bug 42986)
* Stop using jquery.multiSuggest (which didn't really understand annotations)
* Better divide MediaWiki specifics from generic implementations

Changes:

VisualEditor.php, modules/ve/test/index.php, demos/ve/index.php
* Updated links to files

ve.Registry
* Fixed mistake where registry was initialized as an array - this didn't cause any errors because you can add arbitrary properties to an array and use it like any other object

ve.Factory
* Removed duplicate initialization of registry property
* Added entries property, which is an array that's appended to for tracking the order of registrations

ve.CommandRegistry
* Added mwLink command which opens the mwLink inspector

ve.ui.TextInputWidget
* Added basic widget class for text inputs

ve.ui.TextInputMenuWidget
* Added widget that provides a menu of options for a text input widget

ve.ui.MWLinkTargetInputWidget
* Added MediaWiki specific link target widget

ve.ui.MenuWidget
* Converted ve.ui.Menu into a widget
* Moved the body of onSelect to onMouseUp

ve.ui.LinkTargetInputWidget
* Added link target widget which adds link annotation functionality to a normal text input

ve.ui.InputWidget
* Added generic input widget which emits reliable and instant change events and synchronizes a value property with the DOM value

ve.ui.Widget
* Added base widget class
* Widgets can be used in any frame

ve.ui.Tool
* Fixed line length issues

ve.ui.InspectorFactory
* Made use of new entries property for factories to select the most recently added inspector if more than one match a given annotation

ve.ui.Inspector
* Added auto-focus on the first visible input element on open
* Moved afterClose event to after re-focus on document on close
* Added documentation

ve.ui.Frame
* Adjusted documentation
* Added binding of $$ to the frame context so it can be passed around
* Added documentation

ve.ui.Context
* Added ve.ui.Widget.css to iframes
* Updated code as per moving of ve.ui.Menu to ve.ui.MenuWidget
* Removed unused positionBelowOverlay method
* Added CSS settings to set overlay left and width properties according to context size
* Added documentation

ve.ui.DropdownTool
* Updated code as per moving of ve.ui.Menu to ve.ui.MenuWidget

ve.ui.FormatDropdownTool
* Added documentation

ve.ui.MWLinkButtonTool
* Added MediaWiki specific version of ve.ui.LinkButtonTool, which opens the mwLink inspector

ve.ui.Widget.css
* Added styles for all widgets

ve.ui.Tool.css, ve.init.sa.css, ve.init.mw.ViewPageTarget.css, ve.init.mw.ViewPageTarget-apex.css
* Updated code as per moving of ve.ui.Menu to ve.ui.MenuWidget

ve.ui.Menu.css
* Deleted (merged into ve.ui.Widget.css)

ve.ui.Menu.css
* Deleted suggest styles (no longer used)

pending.gif, pending.psd
* Added diagonal stripe animation to indicate a pending request to the API

ve.ui.MWLinkInspector
* Added MediaWiki specific inspector which uses MediaWiki specific annotations and widgets

ve.ui.LinkInspector
* Removed mw global hint (not needed anymore)
* Switched from comparing targets to annotations (since the target text is ambiguous in some situations)
* Switched to using input widget, which is configured using a static property
* Removed use of jquery.multiSuggest
* Moved MediaWiki specifics to their own class (ve.ui.MWLinkInspector)

ve.init.mw.ViewPageTarget
* Added MediaWiki specific toolbar and command options

Change-Id: I859b5871a9d2f17d970c002067c8ff24f3513e9f
2013-01-15 15:05:11 -08:00
jenkins-bot b248cc3db9 Merge "More {String} -> {string} conversions in documentation" 2013-01-08 21:04:52 +00:00
Trevor Parscal a379e0f91e More {String} -> {string} conversions in documentation
Follow up for I6a7c9e8ee8f995731bc205d666167874eb2ebe23

The first pass that Timo took missed the following cases

* "{Array|String}": string is just one of the values
* "{String[]}": string is followed by [] to indicate an array of strings

Change-Id: I65e595e8d37fb624802d84af9536a2d3c5d73c7d
2013-01-08 13:02:12 -08:00
Trevor Parscal ec5333030b Initialization error when canceling load
Added check for the existence of the surface before the save dialog is hidden. This oversight caused errors when there was a load error and the user clicked cancel.

Change-Id: I3b6d8d4d9f4c81ffcbd7996d6b17ac04f33bf6d7
2013-01-08 12:29:54 -08:00
Timo Tijhof b11bbed7a6 JSDuck: Generated code documentation!
See CODING.md for how to run it.

Mistakes fixed:
* Warning: Unknown type function
  -> Function
* Warning: Unknown type DOMElement
  -> HTMLElement
* Warning: Unknown type DOM Node
  -> HTMLElement
* Warning: Unknown type Integer
  -> Mixed
* Warning: Unknown type Command
  -> ve.Command
* Warning: Unknown type any
  -> number
* Warning: Unknown type ve.Transaction
  -> ve.dm.Transaction
* Warning: Unknown type ve.dm.AnnotationSet
  -> ve.AnnotationSet
* Warning: Unknown type false
  -> boolean
* Warning: Unknown type ve.dm.AlienNode
  ve.dm doesn't have a generic AlienNode like ve.ce
  -> Unknown type ve.dm.AlienInlineNode|ve.dm.AlienBlockNode
* Warning: Unknown type ve.ve.Surface
  -> ve.ce.Surface
* ve.example.lookupNode:
  -> Last @param should be @return
* ve.dm.Transaction.prototype.pushReplace:
  -> @param {Array] should be @param {Array}
* Warning: ve.BranchNode.js:27: {@link ve.Node#hasChildren} links to non-existing member
  -> (removed)
* Warning: ve.LeafNode.js:21: {@link ve.Node#hasChildren} links to non-existing member
  -> (removed)

Differences fixed:
* Variadic arguments are like @param {Type...} [name]
  instead of @param {Type} [name...]
* Convert all file headers from /** to /*! because JSDuck tries
  to parse all /** blocks and fails to parse with all sorts of
   errors for "Global property", "Unnamed property", and
  "Duplicate property".
  Find: \/\*\*([^@]+)(@copyright)
  Replace: /*!$1$2
* Indented blocks are considered code examples.
  A few methods had documentation with numbered lists that were
  indented, which have now been updated to not be intended.
* The free-form text descriptions are parsed with Markdown,
  which requires lists to be separated from paragraphs by an
  empty line.
  And we should use `backticks` instead of {braces} for inline
  code in text paragraphs.
* Doc blocks for classes and their constructor have to be
  in the correct order (@constructor, @param, @return must be
  before @class, @abstract, @extends etc.)
* `@extends Class` must not have Class {wrapped}
* @throws must start with a {Type}
* @example means something else. It is used for an  inline demo
  iframe, not code block. For that simply indent with spaces.
* @member means something else.
  Non-function properties are marked with @property, not @member.
* To create a link to a class or member, in most cases the name
  is enough to create a link. E.g. Foo, Foo.bar, Foo.bar#quux,
  where a hash stands for "instance member", so Foo.bar#quux,
  links to Foo.bar.prototype.quux (the is not supported, as
  "prototype" is considered an implementation detail, it only
  indexes class name and method name).
  If the magic linker doesn't work for some case, the
  verbose syntax is {@link #target label}.
* @property can't have sub-properties (nested @param and @return
  values are supported, only @static @property can't be nested).
  We only have one case of this, which can be worked around by
  moving those in a new virtual class. The code is unaltered
  (only moved down so that it isn't with the scope of the main
  @class block). ve.dm.TransactionProcessor.processors.

New:
* @mixins: Classes mixed into the current class.
* @event: Events that can be emitted by a class. These are also
  inherited by subclasses. (+ @param, @return and @preventable).
  So ve.Node#event-attach is inherited to ve.dm.BreakNode,
  just like @method is.
* @singleton: Plain objects such as ve, ve.dm, ve.ce were missing
  documentation causing a tree error. Documented those as a
  JSDuck singleton, which they but just weren't documented yet.
  NB: Members of @singleton don't need @static (if present,
  triggers a compiler warning).
* @chainable: Shorthand for "@return this". We were using
  "@return {classname}" which is ambiguous (returns the same
  instance or another instance?), @chainable is specifically
  for "@return this". Creates proper labels in the generated
  HTML pages.

Removed:
* @mixin: (not to be confused with @mixins). Not supported by
  JSDuck. Every class is standalone anyway. Where needed marked
  them @class + @abstract instead.

Change-Id: I6a7c9e8ee8f995731bc205d666167874eb2ebe23
2013-01-05 01:16:32 +01:00
jenkins-bot cf5f2ae0f5 Merge "(bug 43040) All edits were being marked as minor" 2012-12-13 04:46:25 +00:00
Catrope 892990ef17 (bug 43040) All edits were being marked as minor
&minor=false doesn't work, but &minor=0 does

Change-Id: I73e18e7b58a151d78d56aa199cdfadb6d7150f1d
2012-12-12 17:51:47 -08:00
jenkins-bot df359ce829 Merge "Typo from I65447da8." 2012-12-13 01:12:13 +00:00
Timo Tijhof de4e12367f Typo from I65447da8.
Change-Id: I27cce9784149cf1e98c4ed144ead4718978a74ae
2012-12-13 02:11:25 +01:00
Catrope 803001d652 Handle a null response in onLoad()
Change-Id: I6ce6c3b313c4785db1bad47c8822cca5114d17a3
2012-12-12 16:58:06 -08:00
jenkins-bot 8b50543b6d Merge "Save dialog: Fix too-wide diff box." 2012-12-13 00:51:25 +00:00
jenkins-bot 74b874c1fa Merge "(bug 43013) Exclude edit notices with no visible text." 2012-12-13 00:39:10 +00:00
jenkins-bot 9ad0328b56 Merge "Phase out $.toJSON, use JSON.stringify directly." 2012-12-13 00:36:54 +00:00
Timo Tijhof 4fa57b469a Phase out $.toJSON, use JSON.stringify directly.
Although $.toJSON optimises heavily for modern browsers (it
becomes a direct reference to JSON.stringify), we still load the
extra plugin.

JSON is specified as part of ECMAScript 5, but most browsers
supported this one before they supported the rest of ES5.

http://caniuse.com/#search=JSON

Cut off for native JSON is IE7, Firefox 3.0 (3.6 supports it) and
Safari 3. Not any of our concern as VE will most likely never
support those (certainly not at this point in time, and less
likely as time goes on).

Change-Id: I4e8f26ac94763fa38d29e41264de0247f53a21e5
2012-12-13 01:33:46 +01:00
Timo Tijhof 18ab361a43 (bug 43013) Exclude edit notices with no visible text.
en.wikipedia.org has a template gala for edit notices with a whole
bunch of html framework outputted by default from
MediaWiki:Editnotice-0 (even if their underlying system has no
matches for the current page).

In the core editor from EditPage.php this isn't a problem as the
element is just idling hidden above the editor.

In the case of VisualEditor (where we have a custom delivery for
the edit notices) we don't want to say "1 notice available" on
every page, so we need to be smart and quickly walk the dom of the
notice, filter out invisible nodes, and if the resulting nodes
have no contents, ignore the notice all together.

Change-Id: I65447da8b88a9bae9c24ff155544ff66b3fe9100
2012-12-13 01:26:11 +01:00
Trevor Parscal 718e72d534 Disabled VisualEditor section edit link overrides by default
Server config: $wgVisualEditorEnableSectionEditLinks
Client config: mw.config.get( 'wgVisualEditor' ).enableSectionEditLinks

Change-Id: I859546475a32a686e318aa7108396606b5a0a78d
2012-12-12 15:35:33 -08:00
Timo Tijhof 0cec349074 Save dialog: Fix too-wide diff box.
The rules have changed, these constraints are no longer needed
and actually causing the table.diff to ignore the restrictions
and bump out of the container beyond the width of the window.

This restores the condition under which table.diff is displayed
by core EditPage.php.

Follows-up I5f59482f4db.

Change-Id: I456644bf14efab7dac351818d5c3bb69b9b3c993
2012-12-12 04:32:55 +01:00
jenkins-bot 20dd91423a Merge "Save dialog: Implement new "Review and Save" model." 2012-12-12 01:57:36 +00:00
Timo Tijhof cdee18dae8 Save dialog: Implement new "Review and Save" model.
Basically saveDialog-body now has three slides:
* review
* report
* save

There is a viewPage.swapSaveDialog method that is called like this
 viewPage.swapSaveDialog( 'review' );
initially called from showSaveDialog.

Misc:
 * Replaced more reused core message with a ve ones:
   savearticle => visualeditor-savedialog-label-save
   showdiff => (removed)

 * Removed min-height from saveDialog. When slide-review is
   load, it is very short and there shouldn't be 10em's of
   whitespace below the loader + buttons.

To avoid problems with diff cache being cleared while looking
at the save dialog, we lock and unlock the surface.
We could later remove this as and optimise it as feature, but for
now this fixes a bug.

Change-Id: I5f59482f4db16264014720b199d7652843c36108
2012-12-11 17:52:48 -08:00
Catrope 541aa0d3d6 Store HTML before the converter messes with it
Change-Id: I51f0a97a266522e46f415fd7618c3ef26a8924cd
2012-12-11 17:20:18 -08:00
Timo Tijhof 95742d65f6 Save dialog: Various clean up.
Drop "-down" class in favour of :active CSS pseudo-class.
* http://kimblim.dk/css-tests/selectors/
* http://www.quirksmode.org/css/contents.html
* http://caniuse.com/#search=css%202.1

Rename methods consistently to enableFoo and disableFoo.

Use mw.notify instead of mw.util.jsMessage (the latter takes a
string of html and parses it, instead of taking text).
Also, jsMessage is obsolete (legacy wrapper around mw.notify).

Rename slide-main to slide-save in preparation of other slides
and introduction of multi-step save dialog.

Re-introduce "disabled" state (not css, but actual state) so that
pressing "Show changes" multiple times will not spawn multiple
async operations. The save function guards against this by keeping
a static property in the internal helper method, but there are
still some operations happening between the button and that method
this should be guarded in the UI instead. Follows-up I67819168.

Change-Id: Idf0331377e6be814ccae853228d6159b4ad5a159
2012-12-11 23:13:54 +01:00
jenkins-bot ffc8ec5e50 Merge "Re-apply fixes made in a patch set that were accidentally reverted on rebase" 2012-12-11 21:35:31 +00:00
Catrope 3f903adb09 Add .reportProblem() to submit reports
Change-Id: I55ffd8bfc7664ead3827ef6be178a0b6f3b991a1
2012-12-11 13:19:51 -08:00
Trevor Parscal baa5754b2f Re-apply fixes made in a patch set that were accidentally reverted on rebase
In the change: I6781916822b4173ba906b9bc4c341219fbf10d82

71b97ec45b was reversed when I submitted 1789545284

Change-Id: I6cc59a27817bfbe55c7cbf45bba746a4bd6c375f
2012-12-11 13:06:40 -08:00
Timo Tijhof 3a2453b1b2 mw.ViewPageTarget: Move diff button logic, min-height for dialog.
Follows-up Ic77c5ce4 and I9d05ef6e.

Change-Id: I077172d590e53737691020c1265203134eea3c9c
2012-12-11 18:33:16 +01:00
jenkins-bot 64abfff53c Merge "Enable change makers by default" 2012-12-11 07:05:48 +00:00
Catrope 0d5db4eb4e Enable change makers by default
Change-Id: I7b5af42abe81cc5f41dd80692ac5d5ff007f99ed
2012-12-10 22:55:00 -08:00
Catrope 1a195b33e1 And also use a 100s timeout for show changes
Change-Id: I437d125cd1944299991d80f22fdaedd490bcb45f
2012-12-10 21:16:21 -08:00
Catrope 2e6425a16b Set the save timeout to 100s as well
Change-Id: Ic01ffaae2a0c4bbe91bee7705c60f26b7b34d0f9
2012-12-10 20:33:34 -08:00
jenkins-bot a90f79178a Merge "Hide the show changes button when we are creating a page" 2012-12-11 03:25:50 +00:00
Trevor Parscal 1edd9ad504 Hide the show changes button when we are creating a page
Change-Id: Ic77c5ce4757fd0cf6d7cdd9a991206b649fc2e5a
2012-12-10 19:24:26 -08:00
jenkins-bot dff8570850 Merge "Check if there's a document before we try and set focus on it" 2012-12-11 03:24:05 +00:00
Trevor Parscal c59e6b1638 Check if there's a document before we try and set focus on it
Change-Id: Ia7776c70c2593e4524adab3a347230ee3cccad29
2012-12-10 19:14:43 -08:00
Trevor Parscal c91ef9306c Add left margin to save dialog, visible with show changes
Change-Id: Iaadbfd30f7270fa90dc4adefc9855a55d087ce0c
2012-12-10 19:04:01 -08:00
jenkins-bot 6bb6f6b790 Merge "Throw edit warning on cancel." 2012-12-11 02:55:32 +00:00
Trevor Parscal 99ccfab9f0 (bug 42920) Add the feedback tool
icons, comment.*, ve.ui.Icons-*
* Added comment icon

ve.init.mw.ViewPageTarget
* Refactored editNoticeButton into being just a tool
* Added feedback tool, which shares the editNoticeButton code
* Added feedback object construction in init constructor
* Added launching code to feedback tool

VisualEditor.i18n
* Renamed editnotices-button message to editnotices-tool to match changes in code
* Added feedback tool message

VisualEditor
* Added dependency on mediawiki.feedback
* Updated changed message key
* Added reference to new message

Change-Id: I813c89a505386a9b3206bfbcb176016e28a592cb
2012-12-10 18:47:53 -08:00
Trevor Parscal 1789545284 Adjustments and fixes for styles
* Made buttons use shared CSS code
* Stopped using <button> elements and got all browsers looking the same
* Fixed focus on text area issue - had to let the stack clear first

Change-Id: I6781916822b4173ba906b9bc4c341219fbf10d82
2012-12-10 18:34:58 -08:00
Rob Moen f4cbfa5d87 Throw edit warning on cancel.
-Added reset and hide calls to deactivate to prevent problems
with the save dialog if the user exits to the view.
-Remove unneeded teardown routines from cancel.
-Calling deactivate without override.

Change-Id: I888019146186fb7cbc1ee2b8efee9a0c45286c23
2012-12-11 00:50:05 +00:00
jenkins-bot b6d0cebe59 Merge "(bug 42654) Implement Show changes in Save dialog." 2012-12-10 21:49:38 +00:00
jenkins-bot 3618e9846b Merge "Focus on document when notices are clicked" 2012-12-10 19:12:28 +00:00