Commit graph

51 commits

Author SHA1 Message Date
Inez Korczyński 1d7cf569e6 Support for thumb and frame images with captions.
* VisualEditor.hooks.php
** export URL to magnify clip as a configuration variable so thumbnail image can render correctly

* ve.ce.Surface.css
** add CSS styling to make image captions look the same way in edit mode as they look in the view mode

* ve.ce.ParagraphNode.js
** add CSS class ve-ce-generated-wrapper if it is a generated wrapper

* ve.ce.MWImageCaptionNode.js
** make image caption rendering match the view mode

Change-Id: I0cd1b25e8f8355e0500aabc90e7c4cdf591545f3
2013-05-23 00:44:43 -07:00
Timo Tijhof d28e10d830 ve.Element: Add unit tests
Follows-up c2defc9.

Change-Id: I2045e40567de01f6b44beffe760b6a6287754f75
2013-05-21 19:18:46 +02:00
Ed Sanders a78042accd Disable VE on redirect pages
Will need to be undone once redirect editing support is added.

Bug: 47329
Change-Id: I68836156c35c796aa2156c382992b0c105ae34cf
2013-05-17 12:23:11 +01:00
jenkins-bot 30fb94e94f Merge "Implement ve.dm.MWTemplateNode.getWikitext()" 2013-05-15 22:18:01 +00:00
Catrope 54cd04c391 Implement ve.dm.MWTemplateNode.getWikitext()
Escapes }} and | by wrapping them in <nowiki> tags, and steps around
<nowiki> tags so as to not double-wrap things.

Change-Id: Ia50906524c1fcf55c9f390a114856bc7f20b2d3a
2013-05-15 15:16:34 -07:00
Trevor Parscal a56e795f58 ve.Editor
Objectives:

* Split ve.Surface into ve.Editor and ve.ui.Surface
* Move actions, triggers and commands to ve.ui
* Move toolbar wrapping, floating, shadow and actions functionality to configurable options of ve.ui.Toolbar
* Make ve.ce.Surface and ve.ui.Surface inherit ve.Element and use this.$$ for iframe friendliness
* Make the toolbar separately initialized so it's possible to have a surface without one, as well as control where the toolbar is

Some change notes:

VisualEditor.php
* Added standalone module for mediawiki integrated unit testing

ve.ce.Surface.js
* Remove requirement to pass in an attached container to construct object
* Inherit ve.Element and use this.$$ instead of $
* Make getSelectionRect iframe friendly
* Move most of the initialize stuff to a new initialize method to be called after the surface is attached to the DOM

ve.init.mw.ViewPageTarget.js
* Merge toolbar functions into setup/teardown methods
* Add toolbar manually (since it's not added by the surface anymore)

ve.init.sa.Target.js
* Update new init procedure for editor, surface and toolbar separately
* Move toolbar floating stuff to ve.Toolbar

Change-Id: If91a9d6e76a8be8d1b5a2566394765a37d29a8a7
2013-05-15 10:39:12 -07:00
Ed Sanders 89b0dce8ec ListAction tests
Unwrap and wrap cases.

Change-Id: If4df07eae1d70347dc55b57dc117f2ff5c7385df
2013-05-13 18:59:53 +01:00
Krenair 4f7859895b Don't use VE on non-wikitext pages
Bug: 47456
Change-Id: Iae6510f661feedec181fd8697d799353edb5eac8
2013-05-11 22:26:51 +01:00
Catrope a65ff4fdb9 Use pageLanguage rather than pageViewLanguage for the surface's lang&dir
Bug: 33175
Change-Id: Ica006404227dcd286c387de4f637036341b17eae
2013-05-10 11:04:31 -07:00
jenkins-bot 638bf98e98 Merge "Fix ContentBranchNode test broken by ve.ce.ProtectedNode" 2013-05-07 21:54:18 +00:00
Catrope f6d28e6117 Fix ContentBranchNode test broken by ve.ce.ProtectedNode
Also make sure Jenkins actually runs that test suite

Change-Id: I72b10db3875370da95cb20e127ac8f1efee425bf
2013-05-07 14:48:23 -07:00
Catrope 317a404ece Make .static.storeHtmlAttributes more versatile
It now allows you to specify which attributes to preserve in various
ways rather than just setting true or false.

Removed unused factory methods that exposed the old value.

Change-Id: I914164adcf1f0e48fa3fa85277e68c72dbad393e
2013-05-07 14:45:26 -07:00
James D. Forrester 96683370b4 Do not have ignoreHidden set to true
We're no longer doing dark-launch deployments for the VisualEditor
so this is unnecessary and a bit messy.

Bug: 42936
Change-Id: I0e55faca4eabe910d9b4d8ca8c6b4b0bd42e8539
2013-04-25 15:12:47 -07:00
Catrope f3b03a64f6 Move config vars that are global in nature to the startup module
If they're in the per-page config, we'll have to deal with caching
nightmares when changing them.

Change-Id: Ic8866500b1f20aee36c436dcc3d132c8fde0a8fc
2013-04-18 20:00:55 -07:00
Ed Sanders fd23c9522f Separate experimental features out into a new module
Currently some issues, probably with loading nodes
after factories.

Toggled by global $wgVisualEditorEnableExperimentalCode.

Change-Id: Idab3dd68572c037289c6742d03fd327285110f67
2013-04-18 17:20:11 -07:00
Catrope a20ec306a5 Fix missing global in 116321afe5
Change-Id: Ia76ce0cdd3fed3de1829ae397f1ab3cf3686d8dc
2013-04-17 15:29:58 -07:00
Catrope 116321afe5 Make the "Report problem" POST URL configurable
Defaults to "$wgVisualEditorParsoidURL/_bugs/"

Change-Id: I4847d54b0effe433d5d179d91fdf361c249515ad
2013-04-17 17:05:58 +00:00
Timo Tijhof f669d14569 Test: Fix 404 error.
Follows-up I89f7c2afd815f3050.

Change-Id: Icdc9919b0b9b6f285795ea0d2753cd367cb6ae99
2013-04-02 23:29:20 +02:00
Ed Sanders fdf30b1ac8 Store data in LinearData class with an index-value store for objects
Created an IndexValueStore class which can store any object and return
an integer index to its hash map.

Linear data is now stored in ve.dm.LinearData instances. Two subclasses
for element and meta data contain methods specific to those data types
(ElementLinearData and MetaLinearData).

The static methods in ve.dm.Document that inspected data at a given
offset are now instance methods of ve.dm.ElementLinearData.

AnnotationSets (which are no longer OrderedHashSets) have been moved
to /dm and also have to be instantiated with a pointer the store.

Bug: 46320
Change-Id: I249a5d48726093d1cb3e36351893f4bff85f52e2
2013-03-30 10:06:34 +00:00
Ed Sanders 62318f9c61 Create basic tests for AnnotationSet.
Also covers methods inherited from OrderedHashSet.

Bug: 46320
Change-Id: I632e4cf1b87312179a9ce52df0d590ff42f56325
2013-03-19 15:31:50 +00:00
Catrope 00a109b4a1 Add MetaList
A MetaList is a collection of MetaItems representing all of the
metadata in a ve.dm.Document, and it updates itself live as the
underlying document changes.

Currently this interface is read-only, I'll add mutators next.

Change-Id: If7bfc9563af37e22dcdca9a682d6decc2f6f1872
2013-03-15 15:03:10 -07:00
Ed Sanders 9a7b8aacf8 Only unwrap { generated: wrapper } based on context.
Wrapper paragraphs should only be unwrapped if they are the first
element in their parent - or if there is a block level element separating
them from the previous unwrapped paragraph.

Empty paragraphs should only be unwrapped if they are empty and the
last element in their parent.

Also in this commit is a simple test for IndentationAction.decrease().

Bug: 45590
Change-Id: I1f47d12db6d57d984fd4607f667a3b62c53f3dd6
2013-03-13 00:42:16 +00:00
Ed Sanders c05b5d13cd Create tests for ve.FormatAction.convert
These 3 tests convert different selections of list items to headings.

Bug: 45216
Change-Id: I6cf042d9d5aa4afb68c0992f444b600ed69f0c04
2013-02-22 11:52:12 -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 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
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
James D. Forrester a7157d0c62 Create first VE Technical Debt bug entry for tracking, resolution
Change-Id: I47690b97c19ecc25b0f235036142fef9a2514e96
2012-12-10 17:49:11 -08:00
Timo Tijhof a600310e4d (bug 42136) Use user prefs to set initial state of "Watch this".
* Don't show at all if user isn't logged in
* Use "watch pages I create" and "watch pages I create" prefs
* If the user is already watching it, use that

Also updated relevant onMakeGlobalVariablesScript hook,
it was using old globals still, the hook has context as
of MediaWiki 1.19.

Change-Id: Ic3daf32505a745b3cccd0663a03bbf7f3885be84
2012-12-06 15:04:13 -08: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 43684f88fc (bug 42172) Tag edits made by VE
Uses MW's built-in change tagging. Made this configurable so it can be
turned off if it looks like we're blowing up the tags system with the
volume of VE edits.

Change-Id: I63052d90772906e34021035de496a65fea7945f7
2012-11-26 21:39:11 +00:00
Catrope 4085c2f554 Ignore hidden-ness of visualeditor-enable preference
Needed to make the dark launch work

Change-Id: I1c6f22cb85fdd852bfcc9985d826032f128c6b82
2012-11-14 15:44:15 -08:00
Catrope 4d7952d55c Integration revamp for December release
* Remove VisualEditor namespace, and restrictions on it
** For MW.org these will be moved to mediawiki-config
* Add $wgVisualEditorNamespaces
* Add visualeditor-enable preference and respect it
* Use $skin->getTitle() rather than $wgTitle
* Remove "Sandbox" from i18n message
* Remove duplicate enforcement of VE namespace from JS

Change-Id: I956f68c2dde55e4063530fcc7c90eda048e0d78b
2012-11-05 12:46:14 -08:00
Catrope 7fe7182f43 New annotation API: Annotation and AnnotationFactory classes
Fleshes out ve.dm.Annotation to a class. Annotations in the linear model
will be instances of a subclass of ve.dm.Annotation. Annotations are
defined by subclassing ve.dm.Annotation and registering this subclass
with ve.dm.AnnotationFactory.

ve.dm.AnnotationFactory keeps track of which annotation classes are known,
and has code to match an HTML element to an annotation class, for use in
the converter.

Change-Id: I68802bdb8736ced1f9e04ee49c623944b448141c
2012-10-12 15:07:02 -07:00
Trevor Parscal eabe5e6f61 ve.dm.SurfaceFragment: Implement wrapNodes and wrapAllNodes
Change-Id: I378f0aad0286a6c90adeb4602a57d6617154e8b6
2012-09-24 21:11:16 +02:00
Timo Tijhof c8ed44fb07 Refactor ve.getHash: Stabilize cross-browser differences; + unit tests
* Replaces c8b4a28936

* Use Object() casting to detect objects instead of .constructor
  (or instanceof). Both .constructor and instanceof compare by reference
  the type "Object" which means if the object comes from another window
  (where there is a different "Object" and "Object.prototype") it will
  drop out of the system and go freewack.

  Theory: If a variable casted to an object returns true when strictly compared
  to the original, the input must be an object.

  Which is true. It doesn't change the inheritance, it doesn't make it inherit
  from this window's Object if the object is from another window's object. All it
  does is cast to an object if not an object already.
  So e.g. "Object(5) !== 5" because 5 is a primitive value as opposed to an instance
  of Number.
  And contrary to "typeof", it doesn't return true for "null".

* .constructor also has the problem that it only works this way if the
  input is a plain object. e.g. a simple construtor function that creates
  an object also get in the wrong side of the if/else case since it is
  an instance of Object, but not directly (rather indirectly via another
  constructor).

* Added unit tests for basic getHash usage, as well as regression tests
  against the above two mentioned problems (these tests fail before this commit).

* While at it, also improved other utilities a bit.
 - Use hasOwnProperty instead of casting to boolean
   when checking for presence of native support.
   Thanks to Douglas Crockford for that tip.
 - Fix documentation for ve.getHash: Parameter is not named "obj".
 - Add Object-check to ve.getObjectKeys per ES5 Object.keys spec (to match native behavior)
 - Add Object-check to ve.getObjectValues to match ve.getObjectKeys
 - Improved performance of ve.getObjectKeys shim. Tried several potential optimizations
   and compared with jsperf. Using a "static" reference to hasOwn improves performance
   (by not having to look it up 4 scopes up and 3 property levels deep).
   Also using [.length] instead of .push() shared off a few ms.
 - Added unit tests for ve.getObjectValues

Change-Id: If24d09405321f201c67f7df75d332bb1171c8a36
2012-08-27 00:14:02 +02:00
Trevor Parscal 9c782b29b3 Added monobook support
* Added style for monobook
* Added monobook to whitelisted skins
* Made ve.init.mw.ViewPageTarget resilliant to vector and monobook-like skins

Change-Id: Ia39e034229204ae5f1f70dce5d74c6c4db42277b
2012-08-23 11:01:20 -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
Timo Tijhof b5a12d0167 Register QUnit tests suites in MediaWiki to run from Special:JavaScriptTest
* Also update test/index.html with latest minimalistic format
* Update test suite hardcoded paths to match the definition in
  VisualEditor.php for ResourceLoader
* Issues:
 - 'jquery/jquery.json.js' should not be loaded directly,
   using a dependency instead.
 - Load scripts from the <head> in test/index.html so that
   code that depends on document being ready is catches instead of
   silently being ignored.

Change-Id: I5ad7390137f4d17c153a1bf69f19c4869c08e323
2012-07-27 17:14:23 -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
Trevor Parscal c40174b60c Changed to use MIT license per agreement with the VisualEditor team
This license change is aimed at maximizing the reusability of this code
in other projects. VisualEditor is more than just an awesome editor for
MediaWiki, it's the new editor for the entire internet.

Added license and author files, plus mentions of the license to all
VisualEditor PHP, JavaScript and CSS files. Parser files have not been
modified but are effectively re-licensed since there's no overriding
license information. 3rd party libraries are not changed, but are all
already MIT licensed.

Change-Id: I895b256325db7c8689756edab34523de4418b0f2
2012-07-19 13:25:45 -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
Catrope f9f9328275 Remove userCan hook that had no effect
This hook tried to enforce $wgNamespaceProtection , but that's a core
config variable that's already enforced by MediaWiki itself

Change-Id: I15a40d92e0296eb60054d9845d5c42b880a8f278
2012-06-18 17:42:11 -07:00
Trevor Parscal 76bca4f520 Added veaction param which auto-initializes the editor
Made edit tabs rendered on non view pages work correctly by routing them to the view page with an extra param that auto-initializes the editor

Change-Id: I4fd9106c8b45c6fc79af9ccb44e18944e9b9d8b9
2012-06-18 14:13:26 -07:00
Trevor Parscal ce8efd6b15 Refactored veCore class into ve.init and ve.init.EditPageTarget
Change-Id: I52ef09aee38471ca49f3f4a845daf02e6dcc024c
2012-06-10 23:54:41 -07:00
Rob Moen c338304d33 Rewrite annotate as more low level method in Surface model.
TODO: follow up with annotate tests

Change-Id: If0e68bd3a09840b1e5f3e8d85fd22a8c10134b58
2012-06-04 14:29:27 -07:00
Rob Moen 3f3b525d56 Add MakeGlobalVariablesScript hook to add new global, vePageWatched.
This allows us to check the watchlist checkbox on save dialog.
Added watchlist toggling to ve save api.
Added some i18n messages to core integration.

Change-Id: Ibed8edb2c59ad49e1738c937c3bea518238d0845
2012-06-01 16:30:17 -07:00
Rob Moen 7d96b8426f Created save dialog in core integration
Stash content element styles and remove transitions
Working towards a cleaner saving experience

Change-Id: Ic67022456f46b2bef56a9b0ccfcf93c3283573c4
2012-05-31 16:56:40 -07:00
Catrope 3112448bde Make canUserEditPage() static
This shuts up a strict standards notice

Change-Id: I59ce775169965531dd10051418c927b769613abb
2012-05-31 02:41:21 -07:00
Rob Moen b59d49a80d Restrict edit access to VisualEditor namespace to sysops
To allow non sysops to save via VE, refactored ve save api
to use doEdit which bypasses namespace protection.
Add edit link in view nav for non sysop so that they may edit
Add View source link in dropdown for non sysops
Add Edit source link in dropdown for sysops
Cleaned up some of the integration core code
UI tweaks

Change-Id: Ib4249bc5fb7ffa6410e4f2d278aafbb871800981
2012-05-30 17:12:25 -07:00
Rob Moen 7d9e2d62a3 Restrict ext.visualEditor.core to the VisualEditor namespace in the hook
Change-Id: I169052bd9a1a38ab0352cca4bf8006a66db381f0
2012-05-25 16:34:25 -07:00