Commit graph

215 commits

Author SHA1 Message Date
Inez Korczynski 8b823a7dc6 Introduce new method in Surface model called "change" and get rid of "setSelection" and "transact". Start using new method in Surface view - which right away fixes two bugs - typing at the and of the document, and typing in newly created paragraph/heading. 2012-06-18 13:19:07 -07:00
Catrope b74f24851a Actually fix getRange() this time. Hopefully.
Change-Id: I583a9c2c1ae01370988b4a34ddbf7d3d231e0a74
2012-06-15 16:09:08 -07:00
Catrope 0be0ebf4a8 Forgot to add dl as a sublist type
Change-Id: Ie04904ffdaf20402dbb22ebe96bcaf2db9ea8b8a
2012-06-15 00:07:09 -07:00
Catrope dae599ac2f Fix the newline workarounds (for Parsoid newline handling) for headings
* Parsoid outputs bare newlines after a heading unless it's followed by
  a <p>, so strip leading and trailing newlines in all bare text
* Adding a leading newline in <p>s is only needed if preceded by a
  heading, don't add it otherwise
* Headings need a bare newline after them unless followed by a <p>
* Headings also need a bare newline before them if preceded by a <pre>

Change-Id: Ib02f800b26453541604e920fbb3845c51cdc6dea
2012-06-14 22:50:46 -07:00
Catrope 13c44dd336 Apply <p> tag workaround to <dd> and <dt> too
Change-Id: Ie639c8fd740adc8d9fa26d61ebae2716e41eb2ba
2012-06-14 22:50:46 -07:00
Catrope 37a1bf7cc8 Fix indentation of comment, remove commented-out debugger statements
Change-Id: I7db94e262100cb83be382de4ac4858a1535bc9f5
2012-06-14 22:50:46 -07:00
Catrope 6b2fb7b2e0 More dirty hacks to deal with Parsoid's behavior re newlines in <p>s
This strips certain newlines added by Parsoid so they don't end up in
the linear model, and puts them back in on the way out so Parsoid
doesn't freak out and produce invalid wikitext

Change-Id: I256aaded4229c915868dc868ec6eaa1a73e00be1
2012-06-14 19:35:39 -07:00
Catrope 884e107a24 Fix typo rawr
Change-Id: Ib80b5e62aa4053c070ebdd065f327b54a30dc90f
2012-06-14 16:57:09 -07:00
Catrope 6d6914c3bc Fix missing adjustment in TransactionProcessor
I forgot to adjust a range based on this.cursor for this.adjustment .
This indirectly caused Rob to get an exception when trying to wrap
the last node in the document, because the unadjusted range was past the
end of the document.

Change-Id: If9d5b76568fae25ba2c0f405f1c4fcdd8d879e4f
2012-06-14 16:36:16 -07:00
Catrope 2393ce4627 Fix broken getRange() function, wasn't skipping the opening element
Change-Id: Ib02cf9d22ba612e1cee02a4dd75f106907b74949
2012-06-14 16:23:20 -07:00
Catrope bd69fdd93f Don't blow away attributes coming from toDataElement()
This fixed a bug where an <h2> element with HTML attributes would be
converted to a 'heading' element with those HTML attributes but without
the 'level' attribute, which indirectly caused an exception somewhere in
ve.ce

Change-Id: I8bf32ff0d8e0f9d016b2abc6cb31824df05bdfc2
2012-06-14 16:06:35 -07:00
Catrope bb5c82745e Handle aliens correctly in the converter
Previously, data-mw-gc (generated content) elements were unconditionally
converted to alienInline nodes, and unrecognized elements were
unconditionally converted to alienBlock nodes. This is wrong and
produced weird results when I started experimenting with <code> tags.

Instead, I made both gc and unknown element trigger alienation, but the
decision of whether we generate an alienInline or an alienBlock node is
separate and is based only on whether we're inside a content node.

Change-Id: I12335337c3fa60c725ae7bcfbfb52a1dda153fb5
2012-06-14 12:24:14 -07:00
Inez Korczynski 94d29eaf49 Merge branch 'dmrewrite' of ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/VisualEditor into dmrewrite 2012-06-13 21:17:13 -07:00
Catrope e6751e3f03 Set data.title based on sHref so LinkInspector can use it
Change-Id: I7589740ec5661afd7c8dd0f54e955d170e3096e6
2012-06-13 19:32:49 -07:00
Catrope d0adb112c0 Needs copyArray instead of copyObject, d'oh
Change-Id: Ic185d328a87579262458fe24fd01539c495f09a2
2012-06-13 18:30:50 -07:00
Inez Korczynski 092e84d31f Merge branch 'dmrewrite' of ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/VisualEditor into dmrewrite 2012-06-13 17:19:11 -07:00
Trevor Parscal 31a2a0243a Removed duplicate update event on length change and cleaned up some methods that were being called by symbolic operation name
Change-Id: Ica623d1c5619b8268eb97f631e09f9e2f5b67bf0
2012-06-13 17:16:04 -07:00
Trevor Parscal e266905b94 Moved history tracking into a startable/stoppable service
And made it not start on it's own, but be started by ve.Surface - this makes it so it's not polling in the unit tests, for instance

Change-Id: I940df04d392fd134d18847949efe0e2232328323
2012-06-13 17:16:04 -07:00
Catrope efa93c24be Copy objects in newFromWrap() to prevent reference pollution
Change-Id: Ia1f71341342bea44f6ca08088a1276d54187b22a
2012-06-13 16:56:51 -07:00
Inez Korczynski 29a8ac77c3 Merge branch 'dmrewrite' of ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/VisualEditor into dmrewrite 2012-06-13 16:23:35 -07:00
Inez Korczynski 81473a8119 Make method ve.dm.Document.addAnnotationsToData accept collection of annotations as a param - instead of an array 2012-06-13 16:23:19 -07:00
Catrope 7dd65cda91 Add newFromWrap(), ported 98% verbatim from the old code
Change-Id: I81fc74b1d23bc6b60e476bfefbae4d7d9a9bf5f6
2012-06-13 16:17:23 -07:00
Catrope 0bc1693998 Fix partial undo of ab0c37 in 2ea103
Change-Id: I42225802c45b3867a2aafd40e6941754b1b415b4
2012-06-13 16:16:07 -07:00
Trevor Parscal 429225fb57 Whitespace fixes (jshint was tweaking out)
Change-Id: Id75a097ae4958029caf0a0315343c2fab9c99b89
2012-06-13 16:06:21 -07:00
Trevor Parscal 169b7e754d Cleaned up toolbar annotation updates
Change-Id: I8cefd6c871ed6d1ad71f64eb66236de1b8b719b5
2012-06-13 14:31:46 -07:00
Rob Moen bf08347922 Fix js error
Change-Id: I3424f205649345a97a7f4d28c4c040c3c3bb6aa7
2012-06-12 11:17:46 -07:00
Rob Moen 2ea1030ab4 Rewrite document annotation getters to return collection objects
vs arrays

Change-Id: Ib48a39fff501cdb769f5b9b9fc7717805b74236e
2012-06-12 11:10:29 -07:00
Catrope 92d715df92 Fix some comment typos
Change-Id: I58e21bb4cb75580369b89a10cf324c100ed15724
2012-06-11 18:19:12 -07:00
Catrope ab0c37def9 Rip out the offset map
The offset map was broken from the start because it wasn't updated when
adjusting the length of a text node, and if we fix that bug it's
doubtful whether the costs of updating the offset map outweigh the
benefits, especially considering that adjusting the length of a text
node is something we do for almost every keypress. If it turns out
having an offset map does make sense, we can always reintroduce it
later.

Change-Id: I59e8bc154f7d07aa1bab2f473c13ff466d0e463f
2012-06-11 18:10:08 -07:00
Catrope 407ea15373 Make the LinkAnnotation code a bit more robust
Change-Id: I42603788cf112541df67811858bd8854dd224b24
2012-06-11 18:10:06 -07:00
Catrope 48abc8e30a Terrible hacks to work around Parsoid bugs
This makes my test document round-trip cleanly though, yay!
2012-06-11 17:32:58 -07:00
Trevor Parscal c8c4ed8f99 Added ve.dm.Transaction.newFromContentBranchConversion
Change-Id: I0e272b24dddae028e44d4c693297b1875000ef57
2012-06-11 15:58:44 -07:00
Trevor Parscal 9891adf116 Added getRange and getOuterRange to ve.dm.Node
Change-Id: If1b226d7944335e9b78d59433e322faf5d48382e
2012-06-11 15:58:44 -07:00
Inez Korczynski a609afe52f Port static method addAnnotationsToData from ve to ve2 2012-06-11 15:31:55 -07:00
Trevor Parscal 21ff108c28 Bring link converter in line with Parsoid
Parsoid outputs rel="mw:wikiLink" or rel="mw:extLink", so we convert that to link/wikiLink and wiki/extLink respectively.

Also preserve the data-mw attribute; we probably need to do this more generally but this'll do for now.

Change-Id: I32e570bffa5a73a733a120d52cfd8b75d3191e02
2012-06-11 00:36:20 -07:00
Rob Moen 38e64418b5 Move inspectors into iframe loaded in contextView.
TODO- needs cleanup

Change-Id: I62d86260b48ef570ce18833dee3390ec9fff47e1
2012-06-08 17:17:11 -07:00
Christian Williams 80194260f3 Undo and Redo
Change-Id: I2d7c1bfd164a42e5d52001054e52e47ca245ad18
2012-06-08 16:21:47 -07:00
Trevor Parscal d61045085a Fixed link conversions to match parser
Change-Id: I67838a8c05729e4d32e6e2dfca53c7d457143ce3
2012-06-08 15:17:18 -07:00
Trevor Parscal 20d1c290d4 Fixed multi-auto-wrapping issue and added tests to track regressions
Roan mostly wrote this

Change-Id: Id292c84a4da97d6608aa7c17ab6a4cf5a2e3f409
2012-06-08 15:16:55 -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 2e0d4ef094 Make tableCell represent both <td> and <th>
Adding a 'style' attribute which is set to either 'data' or 'header'

This breaks even more tests because of missing style attributes

Change-Id: I0a75d8c1578b4414eeae8c484f6c4d6f8a59472a
2012-06-08 12:27:22 -07:00
Trevor Parscal c614d3391b Add ve.dm.TableSectionNode and ve.ce.TableSectionNode
Yes, this breaks a bunch of tests, because tableRows are now required to be inside tableSections

Change-Id: Idb52d988df69173647c85f7602344650456e078e
2012-06-08 12:26:45 -07:00
Trevor Parscal 5e6713eae5 Throw an exception when attempting to annotate a closing element
Change-Id: Ifd4e49ee05e74db8bec754a6c1f79c969c1f2eac
2012-06-08 12:23:59 -07:00
Trevor Parscal 5aa6f4b342 Fix bug in fixupInsertion()
When a text node was closed (either by encountering a non-text node or by reaching the end of the document), the fixupStack would not be processed. This led to attributes being dropped when nodes were split because of text being inserted into them

Change-Id: I41f6d20e0c1bfc8d8689b7e6325e724dd8156ab1
2012-06-08 12:23:58 -07:00
Trevor Parscal acdd5679ec Finish implementing ve.dm.Converter and document it
* Add code to handle elements and annotations
* Drop support for aliens from getDomElementFromDataElement() and move it into getDomFromData()
* Implement getDomElementFromDataAnnotation()
* Document a few functions

Change-Id: Ic6a418cbf9d7d1ad96299d7d3633970a876c6103
2012-06-07 21:58:56 -07:00
Trevor Parscal cc0c490502 Fix typo in LinkAnnotation
Change-Id: Idfb969a73c59aef1acf54edd61d555cdc295534c
2012-06-07 21:16:55 -07:00
Trevor Parscal f2b3df8027 Cleaned up some useless/unused functions
Change-Id: I6aa5d0ed3d21993ed653ee64b4928ef98874db2d
2012-06-07 15:02:40 -07:00
Rob Moen e1b8f9422d Fix bug in getAnnotationsFromRange where if the range length was 0
it would return no annotations.

Change-Id: Iec33366b2a1249122a21617d6681ae039557c2fe
2012-06-07 14:53:30 -07:00
Trevor Parscal 453bec4555 Fixed alienInline and alienBlock conversion (was missing closings)
Change-Id: Ie8e51eb8d9a452c656aebf341071da5627dd80b5
2012-06-07 14:30:06 -07:00
Trevor Parscal fa9fe8b08a Added support for alienInline nodes
Change-Id: I15b9cbcdb66b966dca28edcb26bf5d54a4f17be6
2012-06-07 14:16:19 -07:00