Commit graph

19 commits

Author SHA1 Message Date
Catrope 0516b1d7f0 Make entity nodes work in CE
Check for all node classes in getOffsetFromTextNode(), not just
branches and aliens (an entity is neither)

Render entities with contenteditable=false. Without this, selection was
still broken, because:

Foo|€Bar was really <p>Foo<span>|€</span>Bar</p> which maps correctly.
Foo€|Bar was really <p>Foo<span>€|</span>Bar</p> which maps to the same,
which is incorrect.

With cE=false, the cursor can't be inside the span, so we get:
Foo|€Bar is really <p>Foo|<span>€</span>Bar</p> which maps correctly.
Foo€|Bar is really <p>Foo<span>€</span>|Bar</p> which maps correctly.

Change-Id: Iaf603346590a9ad553c152565eb203136be7a399
2012-11-21 12:04:31 -08:00
Inez Korczyński 72c564b47f (bug 41072) Add support for adding outer length in ve.ce offset getters
ve.ce.getOffsetFromElementNode now supports adding outer length
of given node to status functions.

It is temporary solution that I will review in the future.

Change-Id: If779802156aa78dbced9d4c769e8e7877120b337
2012-11-13 11:17:59 -08:00
Timo Tijhof 37f3a288ec Standards: Fix global variables and pass JSHint.
Follows-up:
* IK 714e29d30f
* IK 3b8a5ae4d5
* IK 72eb2825e5
* RK 7fe7182f43
* ...

Change-Id: I671f08e4899bfb9508cef272190ec72721a0af9a
2012-10-23 00:53:48 +02:00
Inez Korczyński 72eb2825e5 Start using ve.ce.SurfaceObserver inside ve.ce.Surface. Moved methods getOffsetOfSlug, getOffsetFromElementNode, getOffsetFromTextNode and getOffset to ve.ce.js and made them static.
Change-Id: If6ce0ae10c494392cc384341cc87b61658d4934a
2012-10-04 14:28:54 -07:00
Catrope 40b60ebda8 Make getDomText() return an empty string for slugs
Slugs aren't represented in the model at all, but in the DOM they do
contain a single character (&nbsp; or &#xFEFF;), so we have to override
the return value of getDomText() to be empty.

Change-Id: Ic93cb694b0632bc81d8d0749149e4d739232ed48
2012-10-01 11:37:39 -07:00
Trevor Parscal 944228aec7 Whitespace and comments
* Added documentation for ve.AnnotationSet
* Replaced uses of "// Inheritance" with "// parent Constructor"
* Added "// Mixin constructor" where needed
* Added missing section comments like "/* Static Methods */"
* Cleaned up excessive newlines (matching /\n\n\n/g)
* Put unnecessarily multi-line statements on a single line

Change-Id: I2c9b47ba296f7dd3c9cc2985581fbcefd6d76325
2012-09-17 16:53:03 -07:00
Timo Tijhof 71020f7175 Remainder JSHint fixes on modules/ve/*
[jshint]
ce/ve.ce.Surface.js: line 670, col 9, Too many var statements.
ce/ve.ce.Surface.js: line 695, col 6, Missing semicolon.
ce/ve.ce.Surface.js: line 726, col 22, Expected '===' and instead saw '=='.
ce/ve.ce.Surface.js: line 726, col 41, Expected '===' and instead saw '=='.
ce/ve.ce.Surface.js: line 733, col 13, Too many var statements.
ce/ve.ce.Surface.js: line 734, col 24, Expected '===' and instead saw '=='.
ce/ve.ce.Surface.js: line 1013, col 13, Too many var statements.
ce/ve.ce.Surface.js: line 1019, col 17, Too many var statements.
ce/ve.ce.Surface.js: line 1023, col 18, Too many ar statements.
ce/ve.ce.Surface.js: line 1027, col 13, Too many var statements.
dm/annotations/ve.dm.LinkAnnotation.js: line 70, col 52, Insecure '.'.
dm/ve.dm.Converter.js: line 383, col 29, Empty block.
dm/ve.dm.Converter.js: line 423, col 33, Empty block.

Commands:
 * jshint .
 * ack '(if|else|function|switch|for|while)\('
 * Sublime Text 2:
   Find(*): (if|else|function|switch|for|while)\(
   Replace: $1 (
 * ack '  ' -Q # double spaces, except in certain comments

Change-Id: I8e34bf2924bc8688fdf8acef08bbc4f6707e93be
2012-09-05 13:45:09 -07:00
Inez Korczynski 9920fb0725 Fix ve.ce.getDomText to work with <br/> tags by making it skip not contenteditable=false but all leaf nodes.
Change-Id: I9e728e091a3021840dac07e9601fc764e7750c49
2012-08-22 11:08:11 -07:00
Catrope 2f31681922 Handle uneditable nodes in ve.ce.getDomText()
There is a TODO about this but these were never handled. This lack of
handling caused weird offset issues when editing paragraphs containing
inline aliens, because the text of the inline alien was returned.
Instead, return an appropriate number of characters so the offset logic
keeps working.

Removed the textContent||innerText code because it would bypass the
uneditable node logic: paragraphNode.textContent would return the text
of the entire paragraph (including any aliens), and we'd never descend
into the paragraph to reach the alien node.

Change-Id: Ia05755755dd5380cb9a0b5a0334c6721b4e0d3b7
2012-08-17 17:21:15 -07:00
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 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 e175292c07 Typo fixes throughout the codebase
And a missing semicolon

Change-Id: I8487525ae2a7fa8f58e00c92c7dff600d9bd9520
2012-06-20 16:01:02 -07:00
Catrope 6afed5e5cc Move ve2/ back to ve/
Change-Id: Ie51d8e48171fb1f84045d1560ee603cee62b91f6
2012-06-19 18:20:28 -07:00
Trevor Parscal ce824d6299 Cleanup 2012-03-09 22:45:22 +00:00
Inez Korczynski 2e9ab44719 Update class names, from ve.es to ve.cs, and update code that uses those classes 2012-03-06 22:39:43 +00:00
Inez Korczynski 594a0e6d6c Rename bunch of files from ve.es.* to ve.ce.* (and update references) 2012-03-06 22:35:42 +00:00
Inez Korczynski b3453dc71c Add new method: getDOMText 2012-02-10 22:19:12 +00:00
Trevor Parscal 6dcc39fe11 Migrated es.* to new ve.* namespace which is more structured, and will make it easier to keep data model, edit surface, user interface and content editable work separated cleanly 2012-02-06 23:50:56 +00:00