Commit graph

1928 commits

Author SHA1 Message Date
Gabriel Wicke b18193907f Some more attribute accessor/shadow methods
Change-Id: I2ea56054cfd534c7cca7567742438b86eef326ab
2012-07-30 10:27:57 -07:00
Subramanya Sastry de1d734f23 Refactored duplicated code in Util
Change-Id: I05d02b73cd35b4b61843fdc17e97a4a8c5d0e8b6
2012-07-30 10:24:43 -05:00
Timo Tijhof 077e21867e Kranitor #3: jQuerlyfornication ft. The Cascaders
* Classicifation (JS)
 Use addClass instead of attr( 'class' ) whenever possible.
 addClass will manipulate the properties directly instead of
 (re-)setting an attribute which (most) browsers then sync
 with the properties.

 Difference between:
 elem.className
 and
 elem.setAttribute( 'class', .. );

 Just like .checked, .value, .disabled and other interactive
 properties, the HTML attributes should only be used for initial
 values from the html document. When in javascript, only set
 properties. Attributes are either ignored or slow.

* Styling (JS)
 Use .css() instead of attr( 'style' ).

 Again, setting properties instead of attributes is much faster,
 easier and safer. And this way it takes care of cross-browser
 issues where applicable, and less prone to error due to dealing
 with key-value pairs instead of css strings.

 Difference between:
 elem.style.foo = 'bar';
 and
 elem.setAttribute( 'style', 'foo: bar;' );

* Finding (JS)
 Use .find( 'foo bar' ) instead of .find( 'foo' ).find( 'bar' ).
 It is CSS!

* Vendor prefixes (CSS)
 It is important to always list newer (standards-compliant) versions
 *after* the older/prefixed variants.

 See also http://css-tricks.com/ordering-css3-properties/

 So the following three:
 -webkit-gradient (Chrome, Safari 4)
 -webkit-linear-gradient (Chrome 10, Safari 5+)
 linear-gradient (CSS3 standard)

 ... must be in that order.

 Notes:
  - "-moz-opacity" is from before Mozilla 1.7 (Firefox < 0.8)
    Has not been renamed to "opacity" since Firefox 0.9.
  - Removed redundant "-moz-opacity"
  - Added "filter: alpha(opacity=**);" where missing
  - Fixed order of css3 properties (old to new)
  - Add standardized css3 versions where missing
    (some 'border-radius' groups didn't have the non-prefixed version)
  - Spacing
  - @embed
  - Shorten hex colors where possible (#dddddd -> #ddd)
    $ ack '#([0-9a-f])\1{5}' --css
    $ ack '#([0-9a-f])\1{2};' --css

Change-Id: I386fedb9058c2567fd0af5f55291e9859a53329d
2012-07-28 13:05:57 -07:00
Subramanya Sastry 7f90b79d19 Sanitize html tags not on a whitelist.
* Need auditing to see if the whitelist is complete.
* Added <gallery> and <tag> to the whitelist since they seem to
  come from some extensions and parser tests depend on them.
  May need to use parsoid config or parser hooks/extension info
  to extend sanitizer whitelist.  For now, probably okay.

Change-Id: Id9ecdd96843e8f6ca65e8666807dec1015443d49
2012-07-28 11:33:51 -05: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
Catrope aabdb8dfba Flag MW-specific code in LinkInspector
Change-Id: I1a85c4c9f5ca0522c2d5491993fad7f05d3a1203
2012-07-27 14:51:58 -07:00
Trevor Parscal 1639b78df7 Merge "Bug 36200 - VisualEditor: Sticky selection popup" 2012-07-27 21:49:39 +00:00
Rob Moen f95677e428 Fixed the following bugs with save dialog.
-Bug 38042
Save dialog description field doesn't respond to 'Enter' or 'Return' keys

-Bug 38621
Pressing 'Esc' in Save-dialog should exit saving, return to editor

Change-Id: I9c43c6c9f2f2b538becc4fbbce1eda6e918d4879
2012-07-27 14:41:27 -07:00
Timo Tijhof 88f6089952 Kranitor #1: On-boarding
'''Kranitor commits''' are commits by Krinkle with his janitor hat on.
Must never contain functional changes mixed with miscellaneous changes.

.gitignore:
 * Add .DS_Store to the ignore list so that browsing the directories
   on Mac OS X, will not add these files to the list of untracked
   files.
 * Fix missing newline at end of file

.jshintrc
 * raises -> throws
 * +module (QUnit.module)
 * remove 'Node' (as of node-jshint 1.7.2 this is now part of
   'browser:true', as it should be)

Authors:
 * Adding myself

MWExtension/VisualEditor.php
 * Fix default value of wgVisualEditorParsoidURL to not
   point to the experimental instance in WMF Labs.

Issues:
 * ve.ce.TextNode:
  - Fix TODO: Don't perform a useless clone of an already-jQuerified object.
  - Use .html() to set html content instead of encapsulating between
    two strings. This is slightly faster but more importantly safer,
    and prevents situations where the resulting jQuery collection
    actually contains 2 elements instead of 1, thus messing up
    what .contents() is iterating over.
 * ve.ce.Document.test.js
  - Fix: ReferenceError: assert is not defined
 * ve.dm.Document.test.js
  - Fix: ReferenceError: assert is not defined
 * ve.dm.Transaction.test.js
  - Fix: ReferenceError: assert is not defined
 * ve.dm.TransactionProcessor.test.js
  - Fix: ReferenceError: assert is not defined
 * ext.visualEditor.viewPageTarget
  - Missing dependency on 'mediawiki.Title'

Code conventions / Misc cleanup
 * Various JSHint warnings.
 * Whitespace
 * jQuery(): Use '<tag>' for element creation,
   use '<valid><xml/></valid>' for parsing
 * Use the default operator instead of ternary when the condition and
   first value are the same.
   x = foo ? foo : bar; -> x = foo || bar;
   Because contrary to some programming language (PHP...), in JS the
   default operator does not enforce a boolean result but returns the
   original value, hence it being called the 'default' operator, as
   opposed to the 'or' operator.
 * No need to call addClass() twice, it takes a space-separated list
   (jQuery splits by space and adds if needed)
 * Use .on( event[, selector], fn ) instead of the deprecated
   routers to it such as .bind(), .delegate() and .live().
   All these three are now built-in and fully compatible with .on()
 * Add 'XXX:' comments for suspicious code that I don't want to change
   as part of a clean up commit.
 * Remove unused variables (several var x = this; where x was not
   used anywhere, possibly from boilerplate copy/paste)
 * Follows-up Trevor's commit that converts test suites to the new
   QUnit format. Also removed the globals since we no longer use those
   any more.

Change-Id: I7e37c9bff812e371c7f65a6fd85d9e2af3e0a22f
2012-07-27 14:40:00 -07:00
Trevor Parscal ad3145ea8b Merge changes I4855fce2,Idabdbf25
* changes:
  Do underscore/space conversion in internal link targets
  Get link title from href by stripping article path
2012-07-27 21:23:44 +00:00
Trevor Parscal 2f6cde7c56 Merge "Make VE work again with the link RDFa changes in Parsoid" 2012-07-27 21:23:01 +00: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
Subramanya Sastry a4274685b2 Continued port of the PHP sanitizer.
* CSS sanitization code now ported.
* Could use non-port review another day to see if the ported code makes
  sense and has any gotchas.
* More sanitizer parser tests now green.
* Could use a lot more aggressive addition of parser tests.

Change-Id: I9df003540bd31f327f5307472c9f7dcbbe7b4342
2012-07-27 10:52:39 -05:00
Catrope 7f5dc887ea Do underscore/space conversion in internal link targets
Convert underscores in the href attribute to spaces in the linear model,
and back to underscores when going back to HTML. This ensures the link
targets displayed to and edited by the user look nice

Change-Id: I4855fce28ad8b724284c53881abc7b99b59b9079
2012-07-26 17:30:35 -07:00
Rob Moen c656f831d1 Bug 36200 - VisualEditor: Sticky selection popup
Clearing context icon when editor loses focus.
-Reproduce problem by selecting text, then click outside of
the editor.  Selection is lost, and context icon is stuck.

Change-Id: I4b321f16cea73ec0e51540c0e71f265ab47514e9
2012-07-26 16:34:51 -07:00
Catrope 2b548a002f Get link title from href by stripping article path
This means we don't have to rely on data-rt.sHref. It also means that
we'll now be showing the canonical link target in the link inspector
rather than the link target as entered by the user, but that's fine.

Also change test to have href differ from sHref to show that we use
href.

Change-Id: Idabdbf2579663ef1efb47d6a73f39743c9f64f3b
2012-07-26 16:25:35 -07:00
Catrope 67e11ebbc3 Make VE work again with the link RDFa changes in Parsoid
This is ugly but makes things work again. I intend to clean this up once
we have a better attribute API

* Recognize mw:WikiLink, mw:SimpleWikiLink, mw:ExtLink,
 mw:NumberedExtLink and mw:UrlLink
* Support is incomplete because we can't get to the annotation text with
  the current API
* Preserve all unhandled attributes rather than special-casing data-mw
* Update remaining code using data-mw (sHref and stx extraction) to
  account for the data-mw -> data-rt rename
* Update tests accordingly

Change-Id: Ia13d3008a6d4cdc8828f9acda5aa797566bc597f
2012-07-26 16:23:03 -07:00
Gabriel Wicke 065bb50369 Merge "Rename data-rt to data-parsoid" 2012-07-26 22:48:56 +00:00
GWicke 96c9d4cb67 Merge "Minor: trace output tweak + code refactoring" 2012-07-26 22:45:49 +00:00
Gabriel Wicke cd6f8ecbbe Fix parserTests include paths
The recent directory move broke parserTests, fix it for now. Will need
refixing once me migrate to our own repo.

Change-Id: I014001cd6904d1dea3f9417c9cde9c80ab079232
2012-07-26 15:42:22 -07:00
Gabriel Wicke 72c5efedb8 Rename data-rt to data-parsoid
* Quite unique according to google, and more obvious
* Also adjust parserTests to ignore mw:Nowiki and mw:Placeholder spans

Change-Id: I340e85092b60a65b4053a40bf8c238e26cb49c96
2012-07-26 15:27:32 -07:00
Catrope 0a8fc3838d Merge "Code and comment cleanup in the ve module" 2012-07-26 20:50:11 +00:00
Subramanya Sastry 1d46cdae08 Minor: trace output tweak + code refactoring
Change-Id: Ic8f51749e84edb7741f5bcea467d647682ef1958
2012-07-26 15:43:02 -05:00
Trevor Parscal cd185cef1f Merge "Bug 38657 - VisualEditor: User should be able to select text in the save dialog." 2012-07-26 20:42:00 +00:00
GWicke f798c6048a Merge "First pass porting PHP's sanitizer to Parsoid" 2012-07-26 20:24:02 +00:00
Trevor Parscal 12d3afa85c Merge "(bug 37905) Make unlisting unlist all list levels" 2012-07-26 18:53:00 +00:00
Rob Moen 2ae174f805 Bug 38657 - VisualEditor: User should be able to select text in the save dialog.
- Attaching save dialog to toolbar wrapper vs toolbar itself.
- Attaching surface specific toolbar wrapper vs all toolbar wrappers
in the case of multiple editors on the page.

Change-Id: Ic81f5a680f5593c71c27b7d47fe246487eebd4a3
2012-07-26 11:47:11 -07:00
Trevor Parscal d12beec67b Code and comment cleanup in the ve module
Change-Id: Ifec72c3992db2ad222a1a89c5172d4089afd865b
2012-07-26 11:42:33 -07:00
Subramanya Sastry 25419d028a First pass porting PHP's sanitizer to Parsoid
* Ported attribute sanitization code (and related functions) from
  core/includes/Sanitizer.php
* Added dummy flags and set to true (use of rdfa, microdata attrs,
  and html5 mode).
* Removed couple whitelisted sanitizer tests.
* A few sanitizer tests now pass.
* More work to be done.

Change-Id: I19c92bbfcb57f3e97a7af1b7c5f63772e427dae4
2012-07-26 11:35:55 -05:00
Trevor Parscal b9af72e7e3 Merge "Switching to localStorage for copy and paste, remove test" 2012-07-26 00:08:10 +00:00
Christian Williams 9723bf51e5 Switching to localStorage for copy and paste, remove test
Change-Id: I555b8756afb53680d60f2068b8615787c60e9d8f
2012-07-25 17:07:08 -07:00
Trevor Parscal 94c68e6c4b Merge "Bug 33088 - VisualEditor: Editing a part of text of a link doesn't work" 2012-07-25 23:51:51 +00:00
Rob Moen df0fa5159c Bug 33088 - VisualEditor: Editing a part of text of a link doesn't work
(or this shouldn't be allowed)

-Revised method for for returning all link annotations in a
selection.  Now properly clearning all selected links.

-Trimming whitespace from selection
-Modifying selection if it doesn't contain annotated range
-Disabled link creation only if target is blank.  This allows
Existing link text to be modified while having the same target.

Change-Id: I7255dcf1c88fa1cd6e7edbc3baa82cd4c72a95d1
2012-07-25 16:49:34 -07:00
Trevor Parscal c244efe1ac Merge "Fix position of context icons." 2012-07-25 23:41:12 +00:00
Catrope 1a573480f7 Moved text node test to the correct directory
Change-Id: I6c2146cd051e9e992e6a30a2d5f83d337d454387
2012-07-25 14:49:48 -07:00
Catrope 23e3726a04 Merge "Added the missing "Node" to alien dm class names" 2012-07-25 21:45:39 +00:00
Catrope e9cfdd0230 Merge "Move test files" 2012-07-25 21:43:08 +00:00
Rob Moen 277e0f8b86 Fix position of context icons.
-Added RL embed for images

Change-Id: Id92e3cfe31376e18a924acc983ab17a2bcca837a
2012-07-25 14:41:25 -07:00
Trevor Parscal c03c52e762 Merge "Fix bug in getCoveredSiblingGroups(): forgot to decrement i at the end" 2012-07-25 21:38:06 +00:00
Trevor Parscal 76bac7d152 Move test files
Change-Id: Id0a0bd5b4a91f702cad34e9f5e7f2121763abffd
2012-07-25 14:35:49 -07:00
Catrope 639c9c189c (bug 37905) Make unlisting unlist all list levels
This means that when unlisting (unwrapping) a list, all of its child
lists are unwrapped too.

Change-Id: I7456ddf289dc15a662a4e1fabdeae283d31cd311
2012-07-25 14:24:39 -07:00
Catrope ce84277287 Fix bug in getCoveredSiblingGroups(): forgot to decrement i at the end
Change-Id: Iaba268e01000ac5a7ccfc6dfe23db624408e5234
2012-07-25 14:22:22 -07:00
Trevor Parscal a5b7d6d7c7 Merge "Parsoid: move tests/parser to modules/parser/test" 2012-07-25 21:14:13 +00:00
Gabriel Wicke 63cdfdc2c7 Merge "Add generic attribute accessors" 2012-07-25 20:50:23 +00:00
Trevor Parscal a05381dce7 Merge "Inspector box shadow was a bit too dramatic, adjusted styles." 2012-07-25 19:50:29 +00:00
Trevor Parscal abe32945d1 Merge "Bug 38655 - VisualEditor: White box syndrome strikes back!" 2012-07-25 19:49:45 +00:00
Rob Moen 99ff0d5f6c Inspector box shadow was a bit too dramatic, adjusted styles.
Change-Id: Ie0f066f62b363df645c072ee174000991258574e
2012-07-25 12:47:04 -07:00
Rob Moen 5a41f77b99 Bug 38655 - VisualEditor: White box syndrome strikes back!
-Hide / show inspector with visibility vs display property
for iframe cross browser compatibility.

Change-Id: Ibdd0250872c42d74d6ff7d22abdf9d838962acc1
2012-07-25 12:40:56 -07:00
Trevor Parscal c88cc63b81 Merge "Restore arrow-down to original size because it is needed in context menu." 2012-07-25 19:33:16 +00:00
Trevor Parscal 565432d4aa Merge "Fix childNodeTypes for table" 2012-07-25 19:30:19 +00:00
Catrope 13ba9b7de8 (bug 37980) Cutting all text and repasting it breaks the editor
This was caused by a bug in fixupInsertion that caused it to believe
that inserting something like "a</p><p>b</p><p>c" into the middle of an
empty paragraph was invalid.

This commit fixes the fixupInsertion bug, which fixes the
select-all-cut-paste behavior in Chrome. It's still broken in Firefox
because of selection-related issues, but I'll split that out into a
different bug report.

Change-Id: I767f5d37ec7e511778ae9ca8283ec4b26c728298
2012-07-25 12:29:19 -07:00
Rob Moen 3c9a4e7027 Restore arrow-down to original size because it is needed in context menu.
Add element for arrow icon in dropdown tool and new css rules which
support RTL.

Change-Id: I4193f9cac7af7b84cf8400e9bdcbcb4967b57932
2012-07-25 12:18:51 -07:00
Gabriel Wicke e3af50ea68 Add generic attribute accessors
* addAttribute and getAttribute do the obvious and simple thing
* addNormalizedAttribute remembers an unnormalized version of an attribute and
  supports change detection for the normalized attribute
* getAttributeSource retrieves the original attribute if there was a
  normalized version which was not changed, or the current value (potentially
  based on the normalized version) otherwise. For use by the
  WikitextSerializer.

Change-Id: I72533cf6cfff1ddb88be2501653c7c47d270898c
2012-07-25 11:58:24 -07:00
Trevor Parscal f43eeac80e Added the missing "Node" to alien dm class names
Change-Id: Ia18d3ede612e2ab8054feb6d94d3587a605e47c2
2012-07-25 11:54:54 -07:00
Carl Fürstenberg dca609e3f9 Parsoid: move tests/parser to modules/parser/test
In preparation for the big extraction of Parsoid out of VisualEditor,
we'll start by moving the tests into the parsoid location.

Change-Id: I4a926ee4aad1490d4f769d44e91af80842b881f0
2012-07-25 02:29:25 +02:00
Gabriel Wicke c4e7544f60 Merge "Use various RDFa types for links" 2012-07-24 20:17:42 +00:00
GWicke dfe082a258 Merge "Added html2wt command-line option to parse.js" 2012-07-24 18:26:50 +00:00
Subramanya Sastry 01d6f17a3e Renamed ext.Util.js to mediawiki.Util.js
Change-Id: I909847686c8239a0b00cbaa9a0b1583826ee1487
2012-07-24 13:07:53 -05:00
Subramanya Sastry 85fb2ab9ed Addressed review comments from recently merged debug_output branch.
* Got rid of mergeProperties monkey-patch from core-upgrade.
* Reformatted class defns in mediawiki.parser.defines.js.
* Protected unconditional tokenization of list handler output with an
  env.trace check.
* Other minor formatting fixes to respect 80-100 column code width
  guideline.

Change-Id: Ida769e0e239b01a813b2d30a65aba60216262a43
2012-07-24 13:05:04 -05:00
Gabriel Wicke fe97271394 Use various RDFa types for links
* the used RDFa types for links are now identical to those listed in
  http://www.mediawiki.org/wiki/Parsoid/RDFa_vocabulary, and are supported for
  serialization
* Editors are responsible for adjusting the type when converting between link
  types. Adding a caption to an mw:UrlLink for example should convert it into
  an mw:ExtLink.

Update: rebased on top of trace patches

Change-Id: Ie1b882e2b3fbad08be94769e1167dccd8dfea65d
2012-07-24 10:59:31 -07:00
Gabriel Wicke 9aa22ca0e2 Implement plain image mw:Image and eliminate data-gen
* Source-based round-tripping now uses typeof="mw:Placeholder" instead of
  data-gen.
* mw:Image is supported for round-tripping, but not yet for modifications as
  it is still source-based

Change-Id: Ie5cf4e54de0163168c25c2b5c09380657a15970f
2012-07-24 10:55:12 -07:00
GWicke 8f2c82289a Merge changes Ife2f840b,I657b1f33,I9d6a03cc,Ib81f96b8,Ia7469b4f,I160ba0c4,I03ae705b,I8343e5c0,I3ab637b7,I50346029
* changes:
  Additional work on readable tokenizer debug output
  Added 'href' key to anonymous KV wikilink and isbn attribute.
  Removed utility functions from mediawiki.parser.environment
  Added utility methods to ext.Util.js
  Added missing var keyword
  In trace mode, wrap transform to output trace info
  Output chunk tokens to console only in trace mode
  Further refinement of readable pretty-printing of tokens.
  More fixes on the way to readable debug/trace output.
  Added mergeProperties function to Object.prototype
2012-07-24 17:01:17 +00:00
Subramanya Sastry ddc6899b1b Added html2wt command-line option to parse.js
* A quick way to see how a html fragment serializes
* Minor JSHint tweaks.

Change-Id: I901398ec15700905c53de6f39cde93400b2f964a
2012-07-24 10:30:44 -05:00
Catrope f3f7715553 Merge "(bug 38545) Fix RTL position of the drop-down arrow" 2012-07-24 02:32:43 +00:00
Amir E. Aharoni fd0af6541b (bug 38545) Fix RTL position of the drop-down arrow
In RTL interface the drop-down arrow overlaps with the text.

The arrow was positioned explicitly in relation to the left margin, and this
can't work in a flipped RTL environment. I changed the position to "right"
and modified the arrow image a bit.

Some visual tweaks to the arrow may still be needed. Another option can be
to convert the image to SVG or to use a character like ▼.

Change-Id: Ib09a2a20b150de6e8a9531fc0db7dfffe4e95525
2012-07-23 19:27:53 -07:00
Krinkle 0949c5b9df Merge "Remove trailing commas" 2012-07-24 02:16:14 +00:00
Catrope da2e945ead Remove trailing commas
Change-Id: Iffd10561fbf2a5bc92acb50b9827a19016c623d6
2012-07-23 19:15:23 -07:00
Catrope d8a8e0328a Fix childNodeTypes for table
Change-Id: I0981fab7687f98859550b2ab4413a490f96d3fe3
2012-07-23 18:00:23 -07:00
GWicke df55d1e426 Merge "First pass updating debug output" 2012-07-23 23:46:46 +00:00
Catrope 1e62e9f64c Prepend a colon to internal links to Category: and File: pages
Change-Id: I77570ea6ec9f29b5d5eb06b518cb08a1b2cea0b2
2012-07-20 16:50:14 -07:00
Catrope 4eca804542 Factored out building the annotation into a separate function.
Also cleaned up some var statements.

Change-Id: I819cd9b783da71f407fe7b6b862e98f5e0cfa3c2
2012-07-20 16:50:13 -07:00
Subramanya Sastry 3004f3d3db Additional work on readable tokenizer debug output
* Added custom toString functions for extlink and wikilink
* Other minor tweaks

Change-Id: Ife2f840bfa0e77a86acdfdbfb574a230c9bd29dd
2012-07-20 18:12:37 -05:00
Subramanya Sastry d994d1292e First pass updating debug output
Change-Id: I1e0953d7b26b962e3758dd1091e87a5361257abc
2012-07-20 18:12:37 -05:00
Subramanya Sastry f558f3a33c Added 'href' key to anonymous KV wikilink and isbn attribute.
* This makes wikilink attrs more similar to ext links.
* Added 'content' key to ISBN links, but couldn't add it to regular
  wikilinks yet because of complexity of how they are handled in
  the rest of the pipeline.  Changing this requires fixing up other
  parts down the pipeline -- something for later.
* Fixed up wikilink handler to use named lookup for 'href' and
  'tail' rather than positional lookup.  Content lookup is still
  positional as before.

Change-Id: I657b1f338d38df3cfdfa99f27ac46e7fe1c9fd65
2012-07-20 18:12:37 -05:00
Subramanya Sastry 6b8a4b386e Removed utility functions from mediawiki.parser.environment
* these functions have already been added to ext.Util.js
* removed a couple jshint warnings.
* minor code restructuring in tokensToString and comments
  to better indicate what is going on.

Change-Id: I9d6a03cc35075e1a64d8fac9e167a3ce4ccd9424
2012-07-20 18:12:37 -05:00
Subramanya Sastry f87ed719e6 Added utility methods to ext.Util.js
* Copied over utility methods from mediawiki.parser.environment.js
  to ext.Util.js.
* Moved over utility method from mediawiki.parser.defines.js to
  ext.Util.js.
* Converted Util to be a singleton object rather than an allocatable
  class.  There is no reason to allocate a new utility class everywhere
  since this utility object has no useful state.
* Fixed up use of utility methods to use Util rather than env.

Change-Id: Ib81f96b894f6528f2ccbe36e1fd4c3d50cd1f6b7
2012-07-20 18:12:37 -05:00
Subramanya Sastry 82d9c31532 Added missing var keyword
Change-Id: Ia7469b4f43bc0b34f045792561d4ee24f9228773
2012-07-20 18:12:37 -05:00
Subramanya Sastry d0cdd2e5f8 In trace mode, wrap transform to output trace info
- Added extra debug_name parameter to addTransform which is
  used in addTransform to output useful trace info.

Change-Id: I160ba0c45f681149375e32ab19f97baa439b09a8
2012-07-20 18:12:37 -05:00
Subramanya Sastry f0a465abcb Output chunk tokens to console only in trace mode
Change-Id: I03ae705bf2679233c4d4b07c25915edd8110a2e8
2012-07-20 18:12:37 -05:00
Subramanya Sastry c148470204 Further refinement of readable pretty-printing of tokens.
Change-Id: I8343e5c0e2a17116920b8585ce8e5d9bc8826286
2012-07-20 18:12:37 -05:00
Subramanya Sastry 6999246fec More fixes on the way to readable debug/trace output.
Change-Id: I3ab637b7790c359255b8bc0ad5716da12bb25884
2012-07-20 18:12:37 -05:00
Subramanya Sastry 2ee1514552 Added mergeProperties function to Object.prototype
Change-Id: I50346029a9bd8a7d2cf954b0cca011f73a6fae07
2012-07-20 18:12:37 -05:00
Gabriel Wicke e1b2555db0 Merge "Start to use the tokenCollector for links" 2012-07-20 23:07:24 +00:00
Catrope 6ca1b06641 Merge "Rename addInterwiki to setInterwiki and add removeInterwiki complement" 2012-07-20 22:41:05 +00:00
Rob Moen 0195b04f26 Bug 33163 - VisualEditor: Floating toolbar should not be displayed when the edit area is entirely off-screen
- Added limits to toolbar float, Toolbar will not go past the last node in editor.
- Added bottom mode to allow toolbar to stick above the last node until the scroll position
is above the last node.
- Actually checking toolbar config now and setting float when flag is set.
- Gave float method for top toolbar a better name.

Change-Id: Ic39c5402fa7a05e13c5e81722d8729d93776d7e9
2012-07-20 15:28:44 -07:00
Catrope c8ce42c8e3 Do not put slugs after nested lists
But still put slugs before them. Done by overriding canHaveSlugAfter()
in ve.ce.ListNode.

Eventually this should be configurable and MediaWiki-specific

Change-Id: I5ad15ca4085a2d730add4954acbea358819b3986
2012-07-20 14:07:53 -07:00
Catrope 5be1b7798c Split canHaveSlug() into canHaveSlugBefore() and canHaveSlugAfter()
These determine whether a node can have a slug before and after,
respectively. The default implementation in ve.ce.Node is to use the
same rules for both, but individual node types can override this.

I'll need this to suppress slugs after nested lists but not before them.

Change-Id: Id88c0fc98aca7c7f52ce990ed9b8c42181ef6d18
2012-07-20 14:07:53 -07:00
Catrope feab4e58a1 Make Enter in an empty list item unindent
For pressing Enter in an empty list item at the end of a top-level list,
this has the same result as the previous code, but if you're in a nested
list it has the effect of jumping down a level. A previous incarnation
of this change just made Enter insert more list items ad infinitum if
you were in a nested list, but I think this is better.

This fixes a bug where pressing at the end of a nested list inserted a
paragraph in an invalid location

Change-Id: I9c7dbaf29a98f84926ed3a05e71c6294926dfce2
2012-07-20 14:07:53 -07:00
Catrope 5b4554b47f Let Tab and Shift+Tab trigger indentation again
Fix the commented-out code: it caused unindent to be triggered by just
pressing Shift. ASCII 16 is "data link escape", no idea where that came
from, so I removed it and used e.shiftKey instead.

Also check whether indent/outdent is even possible before doing it.
Currently this is done in a very hacky way (by checking the state of the
indent button), ideally we'd refactor things such that toolbar tools can
listen for keydowns and intercept them, that would make the code much
cleaner and we wouldn't have this problem.

Change-Id: I99885ee4b8a79cd24c4958c188addfc2b0453b03
2012-07-20 14:07:53 -07:00
Catrope ce1f4dac55 Work around crazy list rendering bug in Firefox
After indenting or outdenting a list item in a numbered list, the
numbering wasn't updated. So if you had:
1. One
2. Two
3. Three

and you indented "Two", you'd get:
1. One
     1. Two
3. Three

Adding or removing items in the list using the keyboard, or even
inspecting the list in Firebug (!), would trigger a renumbering and fix
the list to display "2. Three". But then the same issue would occur in
in reverse when outdenting "Two" (either using undo or using the
outdent button):
1. One
2. Two
2. Three

The workaround is to force a reflow by requesting the height (thank you
Timo). Implemented this in an override of onSplice() in ve.ce.ListNode, so
the list is detached and reattached every time children are spliced into
or out of it.

I haven't managed to come up with a minimal test case for this, not even
by putting a list in a contentEditable div and doing the same DOM
operations that ve.ce does from a setTimeout callback.

Change-Id: I93b2a309034c411a7b4e4b6c6bd4ef9d473999eb
2012-07-20 14:07:53 -07:00
Catrope b23800a55b First stab at list indent/outdent
This works pretty well, the only problems I found are:
* when selecting multiple list items, only the first is in/outdented
* there's no special handling for child lists, so the behavior for
  in/outdenting list items that have a child list can look weird, but
  it's consistent

Also needs more documentation

Change-Id: I6f4f3725e57a590196d7d638a77b87ea85586dc8
2012-07-20 14:07:46 -07:00
Catrope 6703bfc265 Fix selectNodes bug where selecting </li><li> returned an empty result
* When ascending back up the stack, check for a start between two closings
* Also check for an end between two openings
* This introduces code duplication but selectNodes() is full of that
  already. I'll have to do a duplication cleanup soon
* Add test case for </li><li>
* Update existing test case that covered a </li>

Change-Id: Ifc80585ce0e0d6988bc54228602c69f0d519200a
2012-07-19 18:10:57 -07:00
Catrope c66724fbf1 After finding a zero-length selection between nodes, return immediately
Change-Id: I04568e053e82c6d6effc370de5edee5d749e3ae6
2012-07-19 18:09:12 -07:00
Catrope ce0371e8ae Fix bug with nested lists in getCoveredSiblingGroups()
For nested lists, this function would return multiple groups where one
was wholly contained in the other, use offsets to prevent that from
happening.

Change-Id: Ib03bb1c81712d805cc263c2975cc3942de63d2ed
2012-07-19 18:09:12 -07:00
Catrope d31b562dc7 Merge "Fixed issue where #sitesub was being shown even if it wasn't originally" 2012-07-20 00:44:18 +00:00
Catrope 015b85443f Merge "Converted some instances of "var\t" to "var "" 2012-07-20 00:43:02 +00:00
Rob Moen 5e27d6a7a2 Revised inspector iframe construction to allow multiple inspectors
to be added.  Create inspector elements in the propper document
scope.  Restore inspector css classnames to camel case for proof
that inspectors are being created in the correct document scope.
Previously, inspector elements created in the wrong document scope
would have css rules applied only if class names were lowercase.
Issue only surfaced in Webkit browsers.  Though, this implementation
is more future proof and will help prevent future inspector bugs.
Patch 3) Fixed global variable definition and mistake with
inspectorDoc

Change-Id: I36c0d078aea10d919689768878004a19f7f89b55
2012-07-19 17:29:15 -07:00
Trevor Parscal a0f537712e Converted some instances of "var\t" to "var "
Change-Id: I02154e0381d5ae65b482bbcfc21ac93d0bf30d86
2012-07-19 17:24:54 -07:00
Rob Moen 8d90fdd881 Bug 33088 - VisualEditor: Editing a part of text of a link doesn't work (or this shouldn't be allowed)
-Selection of part of a link now modifies selection to entire link
range on inspection.
-Retaining selection direction on new range
Only partial fix to bug as previous link annotation is not
yet properly cleared.

Bug 33053 - VisualEditor: Link creation should not include trailing
spaces, and should provide a suggestion based on selected text
-Created method to return a new range without outer spaces.
-Retaining selection direction on new range.
-Enhancement needed for link suggestion.

Bug 33108 - VisualEditor: Highlighted trailing whitespace should
not have styles applied
-Modified trim method to retain selection, added call to trim
range on annotate method.

Change-Id: I92f264e19350c62b7c2ac3cd9e78af0071afef5c
2012-07-19 16:15:07 -07:00
Gabriel Wicke b344e140aa Start to use the tokenCollector for links
Now that we have access to the contents we can more easily compare the content
with link targets. This is still to do- this commit only converts the link
handler to work on the collected tokens.

* Start to implement latest RDFa spec from
  http://www.mediawiki.org/wiki/Parsoid/RDFa_vocabulary
* Capitalize types, add mw:Entity type for html entities
* Detect changes to entities using tokenCollector and srcContent

Change-Id: I45429f4b930858a16e166ef8377c8f6f5114c414
2012-07-19 14:56:32 -07:00