Commit graph

79 commits

Author SHA1 Message Date
Trevor Parscal 255ce870e2 Puttin' em white-spacers where they aught'a be
function() -> function ()
){ -> ) {

Change-Id: I20a85fcf79d7aec64f7f2559e84c0279550d4eea
2012-08-06 18:52:19 -07:00
Trevor Parscal f0549e0075 Merge "Kill all but one of the Parsoid compat hacks, we don't need them any more" 2012-08-06 21:02:03 +00:00
Catrope 444961af2f Kill all but one of the Parsoid compat hacks, we don't need them any more
Also remove traces of Parsoid workarounds in tests. Tests are now
passing, yay :)

Change-Id: I8a59fc92c567c3595849e3e9377ce6eb6acde280
2012-08-06 13:56:40 -07:00
Catrope 68c5430872 Fix weird bug that was suddenly happening on the live site
When closing annotation nodes, we weren't popping them off
annotationStack. Not sure where this came from, but the code was
definitely bad and this fixes it.

Change-Id: I6d805e9aca3778666212135f76ff34c6baacbbc8
2012-08-06 13:51:51 -07:00
Trevor Parscal 13ccb68ae1 Cleanup - all jshint conditions are now met
Also:
* Removed a lot of dead code in Surface that was used in the now dead and gone sandbox.
* Changed from throwing an exception when calling getBalancedData on a range that produces no results from selectNodes to just returning []

Change-Id: Icf27094724eae5b90eec21308f9e26afe877e3ee
2012-08-03 18:56:04 -07: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
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
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
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
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
Catrope 23e3726a04 Merge "Added the missing "Node" to alien dm class names" 2012-07-25 21:45:39 +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
Trevor Parscal f43eeac80e Added the missing "Node" to alien dm class names
Change-Id: Ia18d3ede612e2ab8054feb6d94d3587a605e47c2
2012-07-25 11:54:54 -07:00
Catrope d8a8e0328a Fix childNodeTypes for table
Change-Id: I0981fab7687f98859550b2ab4413a490f96d3fe3
2012-07-23 18:00:23 -07:00
Catrope 015b85443f Merge "Converted some instances of "var\t" to "var "" 2012-07-20 00:43:02 +00: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
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 a564f81aa7 JSHint: Added dotfiles and fixed tons of linting warnings.
* "onevar" warning sometimes solved by just merging var statements
  other times solved by making it a function declaration instead
  of a function expression.
* Also fixed several '_this' variable names in ve.es.Surface to
  more descriptive names, and enabled warnings for dangling _
  in identifiers.

Change-Id: I7d411881e3e06cf9a7fe56d689c29375881a81de
2012-07-19 10:01:00 -07:00
Catrope 970873595b Merge "Made extendClass accept a variadic list of base classes to extend with" 2012-07-07 04:31:48 +00:00
Trevor Parscal 6828e2c8b6 Removed unused variables
Change-Id: I7fa9e60c6feba5eb5b705d64c8f3aa192aae89ee
2012-06-28 04:24:08 -07:00
Trevor Parscal 02b0c7a6f4 Made extendClass accept a variadic list of base classes to extend with
Change-Id: I6d2307ce39da47ad2673dd439789a2f74632c59f
2012-06-22 10:50:41 -07:00
Catrope 62b78c9109 Adjust oldRange in the rebuildNodes call as well
This fixes a bug Trevor reported where selecting from a list item across
a heading and into a paragraph, pressing backspace, then clicking undo
caused an exception.

Change-Id: Id2851271529e10548f6979a030a198054aa1c48f
2012-06-21 17:26:17 -07:00
Catrope f58b5b6fc8 Reconcile the order and completeness of textStyles in 2 different places
ve.ce.TextNode listed textStyle annotations that didn't actually exist,
and failed to recognize some that did exist (such as span; bug 37808).

Added all annotations to both places. <span> tags are now tolerated by
the editor in that it doesn't crash anymore, but they're displayed (and
saved!) without any attributes, so <span style="color:yellow;">y</span>
doesn't show a yellow 'y' in the editor and is saved back as
<span>y</span> .

Change-Id: Iaae11ad5044150fa904010983ff83579cb37733d
2012-06-21 14:46:43 -07:00
Trevor Parscal 5aa3bbedc7 Fixed output of translateOffset when collapsing a range
Change-Id: Ifb40dd1f9de557d4237660f5fb7119d6aa940c65
2012-06-21 10:45:58 -07:00
Trevor Parscal c548b3cdba Merge changes I44515c86,Ife902ace,Ia6510de1
* changes:
  Got rid of iteration to get the surface
  Removed attach and detach methods from ve.ce.Node
  Track adjustments in DocumentSynchronizer and apply them to oldRange
2012-06-21 06:41:57 +00:00
Catrope dc646ff32c Track adjustments in DocumentSynchronizer and apply them to oldRange
This is needed because oldRange is relative to the state of the model before any changes were made, but when we call selectNodes() it's gonna operate on a partially updated model tree.

This is a genuine bug in DocumentSynchronizer proper, which means I owe the entire team lunch

Change-Id: Ia6510de19df02e961c7f25fb8e7833abceb8d25b
2012-06-20 23:40:38 -07:00
Trevor Parscal cb3eba185d Merge "Fix adjustment of newRange in TransactionProcessor" 2012-06-21 06:38:42 +00:00
Catrope 0b9934b2cc Fix adjustment of newRange in TransactionProcessor
* Adjust both start and end for preceding operations
* Adjust end for the current operation as well

Change-Id: I2f96d609bddf3788aa5700ad1f0b46208f3517d7
2012-06-20 23:37:55 -07:00
Christian Williams 0ab3b65c03 Pressing enter in the last listItem, if empty, will exit the list
Change-Id: I084fabac09654adf50db97b554e937d2772f9a37
2012-06-20 21:10:48 -07:00
Trevor Parscal 9ecb3053e4 Merge "Document how to remove attributes" 2012-06-21 02:36:29 +00:00
Trevor Parscal f49ef7dfc0 Cleaned up selection and focus code for inspectors
Change-Id: Iee1a3525015967f1de461c9e0ebea84834346172
2012-06-20 19:22:38 -07:00
Catrope ac835c2d69 Merge "Keyboard shortcuts for bold and italic" 2012-06-21 02:09:28 +00:00
Christian Williams 14054becb5 Keyboard shortcuts for bold and italic
Change-Id: I12b80134152bbbbd2dfa42b32fec072cde29baa5
2012-06-20 19:09:06 -07:00
Catrope f2c178f020 Document how to remove attributes
Change-Id: I9a30a6510d62fb2ee4e6341ef74f2f5558125e72
2012-06-20 18:40:24 -07:00
Trevor Parscal e175292c07 Typo fixes throughout the codebase
And a missing semicolon

Change-Id: I8487525ae2a7fa8f58e00c92c7dff600d9bd9520
2012-06-20 16:01:02 -07:00
Catrope 37600d020c Add ve.dm.Transaction.translateOffset() and translateRange()
Change-Id: I21bde38056862a1de167646f6cf3030e38d3497b
2012-06-20 14:52:44 -07:00
Catrope 6afed5e5cc Move ve2/ back to ve/
Change-Id: Ie51d8e48171fb1f84045d1560ee603cee62b91f6
2012-06-19 18:20:28 -07:00
Trevor Parscal f1505a0e62 Merge remote-tracking branch 'origin/master' into dmrewrite
Change-Id: I43a3cd999ec0a5d3d05ee1e5bb71c450d485bc01
2012-05-02 10:17:44 -07:00
Trevor Parscal 7ea475ebcf Initial commit of data model rewrite
Ground-up rewrite of the data model. Putting this in the ve2 directory for now so we still have the old code floating around.

Main changes so far in this rewrite:
* Renamed hasChildren() to canHaveChildren()
* Added canHaveGrandchildren()
* Added a new node type TwigNode that can have children but not grandchildren (so all of its children must be LeafNodes)
* Implemented push/pop/shift/unshift as wrappers around splice()
* Renamed getElementType() to getType(). Nodes now take a string as a type, and the element stuff is gone and won't be back
* Removed clearRoot(), replaced it with setRoot( this ) where needed

Change-Id: I23f3bb1b4a2473575e5446e87fdf17af107bacf6
2012-04-19 13:54:34 -07:00
Catrope 4b6e1401a3 Fix typo
Function was renamed but error message wasn't updated

Change-Id: I61a9effa8dedcbdbc75c5c6842fb05f909561327
2012-04-16 12:20:16 -07:00
Catrope 7465b670e1 Add and update an offset map in DocumentNode
This has some TODOs still but I want to land it now anyway, and fix the
TODOs later.

* Add this.offsetMap which maps each linear model offset to a model tree node
* Refactor createNodesFromData()
** Rename it to buildSubtreeFromData()
** Have it build an offset map as well as a node subtree
** Have it set the root on the fake root node so that when the subtree
   is attached to the main tree later, we don't get a rippling root
   update all the way down
** Normalize the way the loop processes content, that way adding offsets
   for content is easier
* Add rebuildNodes() which uses buildSubtreeFromData() to rebuild stuff
* Use rebuildNodes() in DocumentSynchronizer
* Use pushRebuild() in TransactionProcessor
* Optimize setRoot() for the case where the root is already set correctly

Change-Id: I8b827d0823c969e671615ddd06e5f1bd70e9d54c
2012-04-13 16:46:02 -07:00
Robmoen 8a06ea5adc Merge "Changed to using structured lists" 2012-04-06 18:28:04 +00:00
Inez Korczynski 50acc0c785 Make toolbar and context menu works
Change-Id: Ice981390b22a257158b3417dda3a1945d777cb14
2012-04-06 17:43:14 +02:00
Inez Korczynski a57ae2692e Merge changes from branch ce-poll
Change-Id: Ibb6da1ac5229ed5afeda1a3944fe7deff3bfb9a7
2012-04-06 17:10:30 +02:00
Trevor Parscal 85b807ed5d Changed to using structured lists
This makes it possible to get identical rendering in the editor, but may make other things more complex. The Wikitext serializer is no longer compatible for rendering lists so it's been stubbed out. Also the way the toolbar works with lists is broken, so that's been disabled. The HTML serializer has been fixed to work correctly and no-longer-used styles have been removed.

Change-Id: If156f55068b1f6d229b3fa789164f28b2e3dfc76
2012-04-05 14:32:08 -07:00
Trevor Parscal 519d225d2f Cleanup of white space, missing semi-colons, line breaks, etc.
Change-Id: Ifa96a9f70fa8d149a4c403521aaa88a3e0546ef0
2012-04-02 15:28:26 -07:00