Commit graph

192 commits

Author SHA1 Message Date
Trevor Parscal a5aeca3ff5 Major UI refactoring and improvements
Objective:

Refactor UI widgets, improve usability and accessibility of menus, general cleanup and style improvements.

Extras:
Fixed documentation in a few other files to make descriptions of jQuery event arguments more consistent, classes inherit correctly, and made use of the @cfg functionality in jsduck.

Changes:

.docs/config.json
* Added window, HTMLDocument, HTMLElement, DocumentFragment and XMLHttpRequest to externals, so jsduck doesn't throw warnings when they are used

demos/ve/index.php, modules/ve/test/index.php, VisualEditor.php
* Moved widgets above tools (since tools use widgets)

demos/ve/index.php
* Refactored widget initialization to use options
* Renamed variables to match widget names

ve.init.mw.ViewPageTarget.css
* Adjusted text sizes to make widgets work normally
* Added margins for buttons in toolbar (since button widgets
don't have any)
* Removed styles for init buttons (button widgets now)

ve.init.mw.ViewPageTarget.js
* Switched to using button widgets (involved moving things around
a bit)

ve.ui.LinkInspector.js, ve.ui.MWLinkInspector.js
* Renamed static property "inputWidget" to
"linkTargetInputWidget" to better reflect the required base class
for the properties value

icons.ai, check.png, check.svg
* Added "check" icon, used in menu right now to show which item
is selected

ve.ui.Icons-raster.css, ve.ui.Icons-vector.css
* Added check icon
* Removed :before pseudo selectors from most of the icon classes (not need by button tool anymore, makes them more reusable now)

ve.ui.Tool.css
* Adjusted drop down tool styles so menu appears below, instead
of on top, of the label
* Adjusted paragraph font size to better match actual content
* Updated class names to still work with menu widget changes
(items are their own widgets now)
* Updated selectors as per changes in the structure of button tools

ve.ui.Widget.css
* Added styles for buttons and menu items
* Adjusted menu styles

ve.ui.*ButtonTool.js
* Added config options argument passthrough

ve.ui.ButtonTool.js
* Moved var statement to the top inside constructor
* Switched to using "a" tag to get cross-browser :active support
* Added icon to inside of button to make icon styles more reusable
* Removed disabled support (now provided by widget parent class)

ve.ui.FormatDropDownTool.js
* Updated options initialization to construct menu item objects
* Modified handling of items to account for changes in menu and
item classes
* Optimized onUpdateState method a bit, adding early exit to
inner loop

ve.ui.ButtonTool.js, ve.ui.DropdownTool.js, ve.ui.Context.js,
ve.ui.Frame, ve.ui.Tool.js, ve.ui.Widget.js
* Added chain ability to non-getter methods

ve.ui.DropdownTool.js
* Removed items argument to constructor
* Updated code as per changes in menu class
* Fixed inconsistent naming of event handler methods
* Removed item event handling (now handled by items directly)
* Made use of this.$$ to ensure tool works in other frames

ve.ui.Tool.js
* Made tools inherit from widget
* Moved trigger registry event handler to a method

ve.ui.Context.js
* Switched from using menu to contain toolbar to a simple wrapper

ve.ui.js
* Added get$$ method, a convenience function for binding jQuery
to a specific document context

ve.ui.*Widget.js
* Switched to using a config options object instead of individual arguments
* Added options
* Factored out flags and labels into their own classes
* Refactored value setting methods for inputs

ve.ui.MenuWidget.js, ve.ui.MenuItemWidget.js
* Broke items out into their own classes
* Redesigned API
* Updated code that uses these classes
* Added support for keyboard interaction
* Made items flash when selected (delaying the hiding of the menu for 200ms)

ve.ui.LinkTargetInputWidget.js, ve.ui.MWLinkTargetInputWidget
* Refactored annotation setting methods

Change-Id: I7769bd5a5b79f1ab36f258ef9f2be583ca503ce6
2013-02-26 12:29:08 -08:00
Trevor Parscal 59c67e1e94 Modify styles, add disabled and read-only for widgets
demos/ve/demo.css, demos/ve/index.php
* Style changes for utilities and dump output
* Initially disable the log range button, activate when there's a range to log
* Make range inputs read-only
* Rename some widget variables
* Add extra structure and classes to dump output

ve.ui.Widget.css
* Remove left/right margin for buttons
* Simplify opaque white color
* Modify selector for disabled buttons - see changes in ve.ui.Widget.js
* Added styles for text input widget's readonly and disabled states

ve.ui.Widget.js
* Added disabled state

ve.ui.ButtonWidget.js
* Moved click event handler to method

ve.ui.InputLabelWidget.js
* Moved click event handler to method

ve.ui.InputWidget.js
* Moved input change event handler to method
* Added readOnly state

ve.ui.LinkTargetInputWidget.js
* Corrected documentation

ve.ui.MenuWidget.js
* Blocked interaction while widget is disabled

ve.ui.MWLinkTargetInputWidget.js
* Corrected documentation
* Blocked interaction while widget is disabled

ve.ui.TextInputMenuWidget.js
* Blocked interaction while widget is disabled

Change-Id: I7ea89873b50a98d058d1dd1e309e3e8b7c8e7b2e
2013-02-25 12:10:26 -08:00
Inez Korczyński a5e56718cd Introduction of ve.ce.RangyRange class.
Change-Id: I44bcb79a5967c362774603ea27181b9c64d2ea96
2013-02-22 17:02:42 -08:00
Catrope 04c72f6871 Add MWMetaNode to clean up <meta>/<link> hack in the converter
Change-Id: I4c69bff4981eef78415b43d31c3fd2ee271450ef
2013-02-22 15:21:40 -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
Trevor Parscal d0ff691f9e Add user interface widgets
* New! Button and InputLabel widgets
* Using new buttons in the demo
* Moved styles around to generalize input styles

Change-Id: Ic42e133f8fe0fffcb61374c09dd5668db82a4799
TODO: Use these buttons other places! (like ve.init)
2013-02-13 18:04:04 -08:00
Catrope e083afb029 Hybrid-ify MetaBlock/MetaInline
Change-Id: I7b7a2d50637e2009742b290cb1bd0f4fc0395934
2013-01-31 15:00:00 -08:00
Catrope c0690634ee Hybrid-ify AlienBlock/AlienInline
Change-Id: Ieda8383c0c04df208f4c5f2aa7380427467049b7
2013-01-31 14:59:59 -08:00
Trevor Parscal 294db5e3ef Trigger refactor
Objective: Simplify the registration and use of triggers

Changes:

* Renamed ve.Command to ve.Trigger
* Renamed command demo to trigger demo
* Removed language prefixing of triggers
* Generating trigger tooltips rather than hard-coding them in i18n
* Added documentation to clarify that only 'mac' and 'pc' are supported platforms, and how the default is chosen
* Simplified trigger registry's register command
* Updated trigger registrations

Change-Id: Ibab6ad5b5c86f24707f064967dc2119a81125392
2013-01-28 17:06:13 -08:00
Catrope 819b3ded33 Move matching code from AnnotationFactory to ModelRegistry
ModelRegistry registers both annotations and nodes, and performs
matching on both at the same time. It also registers annotations with
the AnnotationFactory, and nodes with the NodeFactory.

Change-Id: I5e68e506a0e573cc0afe6304ccea058ffc20d1c8
2013-01-22 15:51:37 -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 a30e4c325b Cleaned up paste target and surface styles
Resolves a TODO related to the paste target div.

VisualEditor.php
* Added link to ve.Surface.css

ve.Surface.js
* Cleaned up initialization of .ve-surface element
* Removed float clearing div (see ve.Surface.css)
* Removed paste div (moved to ve.ce.Surface)

ve.Surface.css
* Added rule which adds an ":after" element to handle clearing floats

ve.ce.Surface.js
* Cleaned up initialization of DOM elements
* Added paste target div
* Replaced paste element selectors with direct references to this.$pasteTarget

ve.ce.Surface.css
* Changed paste div styles to use a namespaced class instead of a generic ID

demos/ve/index.php
* Added link to ve.Surface.css

Change-Id: Ib93d45ac82ae643fc8e659f5a063c02a8ddacdde
2013-01-17 15:02:47 -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
Trevor Parscal 7d09e0671e Removed code for and links to unused libraries
Removes:
* ve.Position
* jquery.multiSuggest
* jquery.json

Change-Id: Ic21c9d3f5fe8a71d37a1a3633baa6325ca5d51b3
2013-01-10 13:25:33 -08:00
Catrope 080dfd7d07 (bug 42398) Kill ve.ce.Meta{Block,Inline}Node, not needed.
CE doesn't actually render meta nodes anymore now that we split them out
into the meta-linmod.

I took a stab at consolidating metaBlock and metaInline (into simply
'meta'), but we can't do that with the current node API unless we put a
lot of meta-specific hacks in the converter. So I'm leaving this for the
node API rewrite.

Change-Id: Ie83413df718eabcaeb504316a2db0d24a1be2226
2013-01-08 12:45:25 -08:00
Christian Williams d86312cde2 Fixing label tag in demo
Change-Id: I5715ec4a4f710bcadbe226b79a930d71dfd9e2d1
2012-12-19 17:49:29 -08:00
Trevor Parscal 3002bbb591 (bug 42806) Copy/paste errors on unbalanced data
ve.ce.Surface
* Switched to using getSlice instead of getData in copy and paste handlers
* Added try/catch which attempts to build a transaction with the unbalanced data first, but falls back on the balanced data otherwise

ve.dm.*Node
* Added default style attributes (now used by ve.dm.NodeFactory)

ve.dm.Document
* Fixed bugs in fixupInsertions where parentType was being set with an object rather than a string
* Made use of getDataElement
* Added adoption capability so that inserting a</h1><p>b into <p>c[cursor]d</p> results in <p>ca</p><p>bd</p> rather than throwing an exception
* Renamed getBalancedData to getSlice, now retuning a ve.dm.DocumentSlice object

ve.dm.DocumentSlice
* Introduced new container for balanced data and a range of the original context - useful for copy/paste

ve.dm.NodeFactory
* Added getDataElement method, which uses default attributes to create a boilerplate version of a data element

ve.dm.Document.test
* Updated getBalancedData test to be a getSlice test

demos/ve/index, VisualEditor, test/index
* Added references to ve.dm.DocumentSlice

Change-Id: Id9269a29e51ca213508de8f155d3feec5e5b0774
2012-12-07 13:34:28 -08:00
Timo Tijhof 6e5304a5fd Demos: Fix for I53b041f8 fixing Idbff4c51 fixing I840f7242
Change-Id: I860b0441c055cb1f4c04dff7ffdb4f9fafd42cc1
2012-12-05 08:18:09 +01:00
Christian Williams dc3d5be0f3 Fixing toolbar icons
This fixes the display of the toolbar icons in demos/ve/index.php

Change-Id: I53b041f8be3602f2a59d0c124dbebba83b1dfb72
2012-12-04 13:53:33 -08:00
Timo Tijhof 278e5f7640 Clean up, fix errors on demos.
* Fix 404 error for ve.ui.Icons-{raster,vector}.css
  Follows-up 9563f08 / I840f72426f9a.

makeStaticLoader.php:
* Clean up old code.
* Error out early for missing module.
* Put i18n stuff in the right place
  (some modules access ve.msg from the global scope to
  assign status variables, for standalone on demos this was
  failing due to wrong load order)

Change-Id: Idbff4c5136d567da747d9ae373cd2f6c3ee7fb1c
2012-12-04 08:58:20 +01:00
Timo Tijhof 381472ac99 init.Platform: Refactor parsed messages.
Rewrite VisualEditorMessagesModule:
* Replace copy-paste dump of user-css module with stuff for
  VisualEditor (class commend and module::$origin).
* Remove duplication between getMessages and getScript.
* Actually implement getModifiedTime so that the comment in
  getMessages() about cache invalidation is actually true
  Fixes bug 42670: ext.visualEditor.specialMessages cache broken

ve.init:
* Implement addParsedMessages and getParsedMessage so that we
  don't mix up plain messages with raw html messages (minoredit
  was previously overloaded in mw.msg storage with a parsed html
  message and retrieved though ve.msg, which is documented as
  retuning plain text, not raw html). This is now separated into
  a different method.
* Improved documentation of the other msg methods to emphasise
  their differences
* Removed redundant code in attachSaveDialog() that was
  (partially) already done in setupSaveDialog() and moved the
  remaining bits into it as well. Checked all callers of these and
  they are both only called from ViewPageTarget.prototype.onLoad
* Also implement them in the standalone platform implementation,
  with the html escaper based on mw.html.escape
* Update init.platform.getMessage to use undefined instead of
  discouraged 'if-in' statement.
* Add test suite.

demos/test:
* Re-run makeStaticLoader.php on test to add ve.init.Platform.test
* Re-run makeStaticLoader.php on demos and update i18n caller
  to use ve.init.platform.addParsedMessages (also moved out of the
  auto-generated block for easier updating)

Change-Id: I7f26b47e9467e850c08b9c217c4f1098590de109
2012-12-04 07:56:41 +01:00
Catrope e148234c29 Render inline annotations in CE
Moved annotation rendering from ce.Textnode into the new
ce.ContentBranchNode class. This allows us to render annotations that
span across multiple nodes.

* Add ce.ContentBranchNode, inheriting ce.BranchNode
* Make ce.{Paragraph,Heading,Preformatted}Node inherit ce.ContentBranchNode
* Made ce.ContentBranchNode render its child nodes with anntations,
  using .getAnnotatedHtml() on the child nodes
* Put a default implementation for .getAnnotatedHtml() in ce.LeafNode
* Override this in ce.TextNode to do escaping and whitespace handling
* Removed rendering code from ce.TextNode (this.$ is now unused there)
* Removed ce.TextNode.onUpdate() and ce.BranchNode.clean(), now unneeded
* Have ce.BranchNode propagate update events from children, so
  ce.ContentBranchNode can rerender when its children change
* Update tests, add test case for escaping of &<>'"

Change-Id: I4600e984b287c6ff9267f4281d2f09bab9e1ad95
2012-11-28 11:21:59 -08:00
Catrope 4303e9f30c Show annotations on nodes in demo debugger
Change-Id: I41948e8549345c713f1bd0762b08807b8f7617da
2012-11-27 14:41:39 -08:00
Catrope 0e1a6912b0 Display the lengths of model nodes in the demo debugging thingy
Also use .text() instead of .html() where appropriate

Change-Id: I9dcfd9c11c5c01f1459c48c8993c155203c94b13
2012-11-21 12:58:52 -08:00
Catrope 1234a702c9 (bug 42218) Add MWEntityNode
<span typeof="mw:Entity"> tags are now correctly represented in the
model, and rendered in CE. There are still issues with cursor movement
etc. in CE.

Because the prioritization mechanism for annotations vs nodes is broken
in the current "node API", I had to hack two special cases for mw:Entity
into the converter. I also had to change the converter to ignore the
children of inline nodes (this was a legitimate bug, but had never come
up before).

Change-Id: Ib9f70437c58b4ca06aa09f7272bf51d9c41b18f2
2012-11-20 16:19:55 -08:00
Trevor Parscal 9c22ee346a Added undo-before-apply for new link annotations
When the link inspector is used to create a new annotation, the text is annotated with the default link target derived from the selected text. Then if the inspector is used to change that value, yet another transaction is processed when the inspector is closed.

To avoid having to press undo 2x, this change makes the inspector undo it's first change before applying the changed annotation.

This change also introduces insert, remove and select content actions.

Change-Id: I3e29189158fb01336d6b053bc2a8bda2a91a0a46
2012-11-19 17:10:05 -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
Trevor Parscal 443c5438ab Refactored commands into a registry
* Now ve.Factory inherits from the more general ve.Registry
* New class ve.CommandRegistry
* Refactored setupToolbar and command setup code into setupComands

Change-Id: Ic548e5de95b77889727362d3e66d7be83c12a603
2012-11-07 15:52:30 -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 6082953562 Made jquery.multiSuggest it's own RL module
* Also updated resource paths in tests and demo pages

Change-Id: Ic21b678f91ed8d1fe1c7ac2a53d89270aacf7c26
2012-11-06 16:37:01 -08:00
Trevor Parscal 238feeb881 Tools changes
* Rewrite of all tools, dramatically simplifiying them and decreasing
  duplication
* Tools are now created using a tool factory instead of
  a make-shift facility built into the toolbar
* All UI object have a surface or a toolbar reference instead of a
  surface view

Change-Id: I589ecba36bf715b452d03c8fd5c0547dc3c1dc61
2012-10-26 14:48:27 -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
Trevor Parscal 735ed96f5f Add ve.Action, ve.ActionFactory, subclasses
Moved implementation of all the tools into a reusable action
system. To execute an action just call

surface.execute( actionName, method, param1, param2, ... );

This helps keep tools simple, and opens the door to key commands
reusing the same code.

Change-Id: Ie786fa3d38d1ea17d39b5dfb8eeeb5f2256267ce
2012-10-26 14:44:17 -07:00
Timo Tijhof 34cbc729db ve.ui.CommandFactory: Initial implementation
Based on https://github.com/ccampbell/mousetrap.

Cleaned up to fit our coding standards, pass JSHint, and assume
jQuery's fixes where possible (e.g. no need for an addEvent
utility, no need for filling e.target, e.which, etc. cross-browser
which jQuery.Event already does).

Initially all were local functions in the constructor, but to
allow some customisations in subclasses moved various methods
to the prototype instead and marked with @private.

Really, only .register() must be called from the outside. The rest
assumes normalisation etc. or might break things if called
incorrectly.

Change-Id: Ic69a3c70759052094aefbeab623d885f8b118e14
2012-10-24 17:48:16 +00:00
Inez Korczyński 4d351ff459 Make the debug tool (Dump all data) compatible with ve.AnnotationsSet (instead of array)
Change-Id: I0ff131d69933a0fe98232410eb7be72ea2492066
2012-10-19 15:20:40 -07:00
Christian Williams 156e56b47b Fixing location of ve.ce.CenterNode.js and adding comma between variable declarations
Change-Id: If54e314f47860ac30060bec6b3f5997ed3709e0b
2012-10-17 13:18:57 -07:00
Timo Tijhof edc5f38d4c Fix path issues with missing files, inconsistent subset in demo, test & mediawiki.
* CenterNode missing in ResourceLoader registry
* UI classes and rangy not in static test/index.html
* Transaction and TransactionProcessor listed twice

Added a maintenance script that generates the <script> and <link> tags for all
files in the same order everywhere.

Change-Id: I5d22d33769b4e356e8065d295505f6f9a8b0bea8
2012-10-16 10:03:26 -04:00
Trevor Parscal 56487ae1ef Merge "Add a missing reference to file ve.dm.SurfaceFragment.js inside index.php for standalone demo." 2012-10-13 00:35:46 +00:00
Rob Moen df211b91d8 Fix standalone demo.
Change-Id: Ieef15ad3edc039b205e5e4e870311927384be561
2012-10-12 17:07:21 -07:00
Inez Korczyński 54c51b6b18 Add a missing reference to file ve.dm.SurfaceFragment.js inside index.php for standalone demo.
Change-Id: I12c134a4a2e2bbec271ade5d211c48939cfc9a5f
2012-10-12 16:36:55 -07:00
Catrope 613dd14332 New annotation API: convert existing annotations
This changes ve.dm.LinkAnnotation to be a generic annotation for <a>
tags, and adds ve.dm.MWInternalLinkAnnotation and
ve.dm.MWExternalLinkAnnotation as MW-specific subclasses. This nicely
splits out the MW-specific parts in LinkAnnotation, and ideally we'd
also move these files somewhere else to reflect their MW-specificity,
but I haven't gotten to that yet.

Similarly, ve.dm.TextStyleAnnotation is now a generic base class for
simple tag-only-no-metadata annotations, and it has 11 subclasses, one
for each tag we support. This is quite a bit more verbose than the
previous code, but I think it's cleaner and more flexible. I considered
writing a function that would generate a TextStyleAnnotation subclass,
then calling that 11 times, but that's not possible if we want to keep
named functions for the constructors.

Change-Id: Ifba10153eef40280e44025dd72d4e9d9f33b0632
2012-10-12 15:07:25 -07:00
Inez Korczyński 580ed725a7 Created simple debug tool - that compares data between DOM and Model - very useful while working on SurfaceObserver and text insertion stuff.
Change-Id: Id30513fc64a947ab7ef0474882ace750f41624b8
2012-10-10 14:27:25 -07:00
Inez Korczyński 3b8a5ae4d5 Initial import of ve.ce.SufaceObserver
Change-Id: Ifc14a6cc30e46c8ae99c59dcb916795c603329ed
2012-10-04 14:24:12 -07:00
Trevor Parscal daa7e76807 Merge "Add a node type for meta nodes" 2012-09-18 18:15:46 +00:00
Catrope 7b96fbe3d2 Add a node type for meta nodes
This node type represents <meta> or <link> (transparently, based on the
style attribute). I had to make two node types for this and hack the
toData conversion code directly into ve.dm.Converter, because we don't
have native support for node types that can be both inline and block.
(We should add this in the node API rewrite.)

The CE implementation renders a placeholder (with the same styles as an
alien node) right now. I'm not sure how nice that is, but it's better
than rendering raw <meta>/<link> tags.

This whole thing is a total pile of hacks to make VE deal with
<meta>/<link> tags until we have a proper node types API.

Change-Id: Id6783fcfc35a896db088ff424ff9faaabcaff716
2012-09-10 15:35:30 -07:00
Trevor Parscal 818fdd8b52 Added links to annotation set classes for demo
Change-Id: I1584eb22a177871d1f18761cf4ec35d8961b2b91
2012-09-07 15:26:24 -07:00
Trevor Parscal b370bbd0bc Improved icons
* Moved icons into Illustrator (used to be in Photoshop)
* Added SVG icons too
* Added support for devices with pixel ratio > 1 (they use SVG)
* Cleaned up icons (little rendering errors here and there)
* Organized icons into their own folder
* Increased the horizontal margin of the down arrows in the formatting (in the toolbar) and location (in the link inspector) drop down menus

Change-Id: I29b7084c9b1145051b2a76f514cfca9826d53ddb
2012-08-31 13:23:04 -07:00
Inez Korczynski 29aef1dec8 Very simple (and a little bit messy) debug tool that dumps not HTML table linear model, view tree and model tree.
Change-Id: I625047fbb99c0d63e1ac6865b7e9cddf4ab72a2e
2012-08-23 15:07:32 -07:00
Inez Korczynski 844df5c8e6 Support for <center> tag
Change-Id: I0d64561dd82b8377ee7491103e81569eaca22fee
2012-08-22 12:51:33 -07:00
Rob Moen dda2c932bd Added MW page suggestion functionality.
Created jQuery plugin MultiSuggest which builds a categorized dropdown
under specified input box.

Revised inspector to no longer be an iframe but to contain an Iframe.
This reduces xbrowser issues with positioning and toggling inspector
container.

Added Inspector overlay element for positioning arbitrary elements
over the iFrame.  This prevents growing the iframe to arbitrary lenghts.

Change-Id: I8efbbd091b0b24a19a4b73aa122d21a329cf97e4
2012-08-17 14:12:26 -07:00
Trevor Parscal d147504f49 Added support for apex skin
* Made vector specific styles only active in the vector skin
* Added apex specific styles
* Removed override of text size for document node
* Added stylesheet for stand-alone to specify text size for document node

Change-Id: I8a57918912499f9453a5692ff45a04a16ed34cde
2012-08-15 16:35:52 -07:00
Trevor Parscal 5752b3fb72 Merge "Add ve.dm.BreakNode to represent <br>" 2012-08-09 21:50:41 +00:00
Catrope 625161e35c Add ve.dm.BreakNode to represent <br>
Change-Id: I3825199c3c8cbe3b50c01e03f39f20cef7c55a28
2012-08-09 14:50:25 -07:00
Trevor Parscal d8ee3c2c29 After much research on error objects, native = good, custom = bad
Stack traces, line numbers, etc. All the approaches I've seen are bad hacks. This is the best way to go.

Change-Id: Ib12e9d2ecfe610bcc89d046005e35cc13efa3d99
2012-08-08 10:48:53 -07:00
Trevor Parscal b4de3ead08 Throw ve.Error instead of string literals
Throwing strings is bad because it doesn't include a lot of important
information that an error object does, such as a stack trace or where
the error was actually thrown from.

ve.Error inherits directly from Error. In the future we may create
more specific subclasses and/or do custom stuff.

Some interesting reading on the subject:
* http://www.devthought.com/2011/12/22/a-string-is-not-an-error/

Change-Id: Ib7c568a1dcb98abac44c6c146e84dde5315b2826
2012-08-08 06:19:00 +02:00
Trevor Parscal 53e9258280 Added ve.init.platform with MediaWiki and stand-alone implementations
This should make it much simpler to keep MediaWiki specifics out of VisualEditor, which will in turn make it easier to integrate VisualEditor into another platform.

Change-Id: I073e9737b37c28af889f2457d10b082cefd0d63b
2012-07-27 13:39:19 -07:00
Inez Korczynski 876fd6be36 Added very simple "debug" tool to demo page.
Change-Id: I3df694187089ac4caa2287b55e3a51755cdec2c7
2012-07-24 16:44:06 -07:00
Trevor Parscal 6b34f09df2 Removed some whitespace
And added a license to some files that didn't have it yet

Change-Id: I3a7e60374d1198d369a0475b8f65f7415012a337
2012-07-19 14:25:16 -07:00
Catrope 8ff9df6023 Merge "Renamed ve.ce.Document.css to ve.ce.DocumentNode.css to match it's contents" 2012-07-19 01:29:03 +00:00
Trevor Parscal 3afb270567 Renamed ve.ce.Document.css to ve.ce.DocumentNode.css to match it's contents
Change-Id: I3d7504dfda27309f631a5856ffa4aacd13b6edc7
2012-07-18 18:23:11 -07:00
Trevor Parscal 9a0380c67d Removed Special:VisualEditorSandbox and refactored demo
Also renamed ext.visualEditor.editPageInit to
ext.visualEditor.viewPageTarget

Change-Id: I8bdd04b3442067e87bccbc60dd4947aae1c7dfd2
2012-07-18 17:57:50 -07:00
Inez Korczynski 93b834a688 Update JS and CSS references in demo to point to new location - ve instead of ve2
Change-Id: I7d5c7888ec4c0923a42c25cf86799b0d07427acf
2012-06-19 20:53:55 -07:00
Trevor Parscal 44d50c980f Added i18n messages to mw.msg fallback
Change-Id: Ic4b44eb6ab31392fa727f14ec38800fe6b185d44
2012-06-19 13:58:54 -07:00
Trevor Parscal 11a3d883f2 Using resource loader debug scripts to unstub ve.log
Also added ve.dir and converted use of console.log to ve.log

Change-Id: Ibbfd78b6ece163f54f40e997c79a01de6609c2b4
2012-06-18 13:30:39 -07:00
Trevor Parscal 17fff0d163 Fixed dependency on mw, now demo works again
Change-Id: I26599e065a521cf08a16f5a65e36960a692421e9
2012-06-11 12:11:07 -07:00
Trevor Parscal 2e1b304a48 Cleaned up styles for editor in both demo and sandbox/integration
Change-Id: I9b4a3727fd04b3c3ff3f297c6656db2592856173
2012-06-08 16:20:37 -07:00
Trevor Parscal 5969f55550 Delete HTMLConverter and update demo&sandbox
Also update the demo and sandbox for ve.{dm,ce}.TableSectionNode

Change-Id: I5a73a8250d283e8666b93561ce9e9374739936a5
2012-06-08 12:40:43 -07:00
Trevor Parscal e7f03c6d70 More cleanup, removed ObjectAnnotation (they are inline elements now)
Change-Id: I2c53c145eed1a801392c954001de7641f928216c
2012-05-31 17:18:28 -07:00
Trevor Parscal 042ffb4e3b Added foundation for new converter
* Added converters to all relevant node implementations
* Added new annotation objects with their own factory

Change-Id: I9870d6d5eac45083929d74d2e58917d0939ca917
2012-05-31 16:50:16 -07:00
Trevor Parscal ea9191b5b4 Copied CSS styles from ve to ve2
Change-Id: Iabd5ee3edde5747952c4b78ef6e9cd5949016050
2012-05-24 15:15:29 -07:00
Inez Korczynski e7cd9e5ef7 Add missing JS files references to demo
Change-Id: I6f85942622b151932d10ab322e5d1ba8b4fbcee3
2012-05-24 11:38:07 -07:00
Christian Williams 32b9ccd0bf Moving alien node styling to CSS file
Change-Id: I21e4593b81669b48cec831236398866f89616f9a
2012-05-23 12:03:28 -07:00
Trevor Parscal 9af03a29b1 Updated demo and fixed HTML converter
Removed hard-coding of alien nodes, now aliens are automatically used for anything unknown, and block or inline aliens are selected based on whether the parent element can contain content or not.

Change-Id: I5d2a521ead4f4c96cb44d084a5c160cc20d8048e
2012-05-23 10:15:44 -07:00
Rob Moen 8286508491 Include jquery.json.js in both demos to fix error
Change-Id: Ic5810536317e6de8a23232b602aced877412b1ea
2012-05-21 12:49:14 -07:00
Rob Moen 7bf15b4377 Copy ui modules to ve2
Switch sandbox demo to use new ui modules
Update VisualEditor.php to use ve2 modules
SpecialPageSandbox working

Change-Id: I8261d6bf6ceb6ae7b7bfa5f61aec6a0121906765
2012-05-21 12:39:36 -07:00
Trevor Parscal 08765feab3 Merged ve.dm.DocumentFragment and ve.dm.Document
* Also fixed lots of whitespace issues and some global variable introductions

Change-Id: Ia6c82ef0c3b5c4938cf72afa86da6d79e4cb385a
2012-05-17 11:23:56 -07:00
Inez Korczynski 156e15c66b Added missing reference to ve.Document.js
Change-Id: I893442dcb1518c4c05e29fe29aece82ac04fe5c8
2012-05-09 22:51:46 -07:00
Christian Williams 28eb0c82e5 Adding HTML DOM -> Linear Model converter
Change-Id: Iae109d75e64321a7fe4ee8492d79ef5481716246
2012-05-04 15:47:41 -07:00
Rob Moen d42e738636 - Optimize surface model and write unit tests
Change-Id: I8de24c840c5aa2d4232e6e2cc5f72cbd30be96b4
2012-05-04 15:29:47 -07:00
Trevor Parscal 9887dbd96f Split Broke DefinitionListNode out of ListNode and DefinitionListItemNode out of ListItemNode
* Makes it simpler in the linear model because we don't have to use style: "item" for regular list items and style: "definition" for definition lists
* Enforces correct nesting through existing node rules systems
* Updates tests accordingly

Change-Id: I64d80af938e325f1961226505bdc386bb35ccdda
2012-05-04 11:56:32 -07:00
Rob Moen 014084fc65 - fix demo styling for docs list
Change-Id: I5e5d16fe9a002e3cafd01138ad9b92ff987178d6
2012-05-03 16:27:28 -07:00
Trevor Parscal 23e32af302 Added some styles to the demo to add spacing around stuff in the header
Change-Id: Id2e205e9a02dd9b040a40fa4f5ca14891e21d838
2012-05-03 15:21:03 -07:00
Trevor Parscal 4e8a9d75ea Added charset meta tag to demo
Change-Id: I544bdc446262f03bd15790a9cf6d7f9c2f9dcd55
2012-05-03 15:11:10 -07:00
Rob Moen 56dff6dacb Added new node types
Change-Id: I6b5f2e5a7dbdb7c59b4799d44f7924c5594c0e34
2012-05-03 14:22:09 -07:00
Inez Korczynski 6224c60075 Rendering works in very basic version
Change-Id: I8789860fe82f2e7db1e503889e20ce51de57bfa2
2012-05-03 14:02:35 -07:00
Christian Williams 07ca8787bb Including ve.NodeFactory.js
Change-Id: Iac47ea5486c5c631084d2f0d184ab8c84dfd6696
2012-05-03 13:40:16 -07:00
Christian Williams 4f487bf243 Updates to script includes in demo index.
Change-Id: I7c8859461c06ebce0d79633d52108d5a2714118a
2012-05-03 13:35:16 -07:00
Rob Moen 94479bd79d Build out ve.Surface constructor to support multiple editor instances
Now setting up multiple toolbars per config
Tools & Modes are now configurable per toolbar per instance
Base elements are created on demand and no longer id specific
Note: There are some bugs with multiple instances.

Change-Id: Id0bbbca2d1b76fd2db3f3b0f9abd90194930b610
2012-04-26 11:56:47 -07:00
Trevor Parscal 50f43c89d5 Add links in sandbox and demo to ve.dm.DocumentSychronizer.js
This was caused by added this dependency in the code without adding the links to the sandbox and demo

Change-Id: I7b2f0129a28dfd8655dfbce8688cfb3920c690fd
2012-04-02 13:28:09 -07:00
Trevor Parscal 19f3d5c107 Added ve.Surface, a wrapper around an editor instance
* This high level surface object is responsible for creating & managing editor instances
* Revised Sandbox demo to invoke in this way.

Change-Id: I4043779af9a2ab964deaf26079a992e82ebeef27
2012-03-29 15:55:33 -07:00
Trevor Parscal c44ef066b9 Replaced es with ce for Sandbox and main demo
* Configured VisualEditorSandbox to use es
* Reconfigured the ce demo to share the sandbox module
* Removed es demo
* Renamed ce demo to ve (es is broken anyways)

Patchset 2: squashed in https://gerrit.wikimedia.org/r/3953

Change-Id: If8d13bf7011616d222be78899b23186859d5ed70
2012-03-29 15:43:59 -07:00
Renamed from demos/ce/index.php (Browse further)