mirror of
https://github.com/webodf/WebODF.git
synced 2026-11-30 16:47:58 +01:00
* Use the new isInlineRoot method in OdfUtils, to
determine walkability around annotations via the TextPositionFilter. - In checkLeftRight, now that positions to the left and right of an annotation are walkable by default, block the position to the right of an annotation if there is a grouping element (span, annotation highlight, etc) to the right. - Thus, now you can step to both the left and right of a rangeless annotaiton. If the annotaiton has a highlighted range, the cursor won't be able to step between the <office:annotation> element and it's annotationHighlight, so there can be no strange text insertion there, and no rewrapping is required over the newly inserted text as it goes straight into the highlighted span like everywhere else. * Add tests to OdtDocumentTests for cursor positions around annotations. * Add tests to operationtests.xml (mostly bumping up the positions of SplitParagraph operations after adding annotations, now that 1 new position is exposed.
This commit is contained in:
@@ -64,6 +64,9 @@ ops.TextPositionFilter = function TextPositionFilter(getRootNode) {
|
||||
var r, firstPos, rightOfChar;
|
||||
// accept if there is a character immediately to the left
|
||||
if (leftNode) {
|
||||
if (odfUtils.isInlineRoot(leftNode) && odfUtils.isGroupingElement(rightNode)) {
|
||||
return FILTER_REJECT;
|
||||
}
|
||||
r = odfUtils.lookLeftForCharacter(leftNode);
|
||||
if (r === 1) {// non-whitespace character or a character element
|
||||
return FILTER_ACCEPT;
|
||||
|
||||
@@ -509,8 +509,12 @@ ops.OdtDocumentTests = function OdtDocumentTests(runner) {
|
||||
testCursorPositions("<text:p><text:span>|<draw:frame text:anchor-type=\"as-char\"><draw:image><office:binary-data>data</office:binary-data></draw:image></draw:frame>|</text:span></text:p>");
|
||||
}
|
||||
function testAvailablePositions_Annotations() {
|
||||
testCursorPositions('<text:p>|a|b|<office:annotation><text:list><text:list-item><text:p>|</text:p></text:list-item></text:list></office:annotation>c|d|<office:annotation-end></office:annotation-end>1|2|</text:p>');
|
||||
testCursorPositions('<text:p>|a|b|<office:annotation><text:list><text:list-item><text:p>|</text:p></text:list-item></text:list></office:annotation>|c|d|<office:annotation-end></office:annotation-end>1|2|</text:p>');
|
||||
}
|
||||
function testAvailablePositions_BetweenAnnotationAndSpan() {
|
||||
testCursorPositions('<text:p>|a|b|<office:annotation><text:list><text:list-item><text:p>|</text:p></text:list-item></text:list></office:annotation><text:span>c|d|e|</text:span><office:annotation-end></office:annotation-end>1|2|</text:p>');
|
||||
}
|
||||
|
||||
|
||||
function getTextNodeAtStep_BeginningOfTextNode() {
|
||||
var doc = createOdtDocument("<text:p>ABCD</text:p>");
|
||||
@@ -768,6 +772,7 @@ ops.OdtDocumentTests = function OdtDocumentTests(runner) {
|
||||
testAvailablePositions_SpaceElements,
|
||||
testAvailablePositions_DrawElements,
|
||||
testAvailablePositions_Annotations,
|
||||
testAvailablePositions_BetweenAnnotationAndSpan,
|
||||
|
||||
getTextNodeAtStep_BeginningOfTextNode,
|
||||
getTextNodeAtStep_EndOfTextNode,
|
||||
|
||||
@@ -1289,7 +1289,7 @@
|
||||
<op optype="AddAnnotation" memberid="Alice" position="2" length="1" name="alice_1" timestamp="1375706047061"/>
|
||||
<op optype="SplitParagraph" memberid="Bob" position="2"/>
|
||||
</ops>
|
||||
<after><office:text><text:p>ab</text:p><text:p><office:annotation office:name="alice_1"><dc:creator e:memberid="Alice">Alice</dc:creator><dc:date>2013-08-05T12:34:07.061Z</dc:date><text:list><text:list-item><text:p><c:cursor c:memberId="Alice"/></text:p></text:list-item></text:list></office:annotation><c:cursor c:memberId="Bob"/>c<office:annotation-end office:name="alice_1"/>d</text:p></office:text></after>
|
||||
<after><office:text><text:p>ab</text:p><text:p><c:cursor c:memberId="Bob"/><office:annotation office:name="alice_1"><dc:creator e:memberid="Alice">Alice</dc:creator><dc:date>2013-08-05T12:34:07.061Z</dc:date><text:list><text:list-item><text:p><c:cursor c:memberId="Alice"/></text:p></text:list-item></text:list></office:annotation>c<office:annotation-end office:name="alice_1"/>d</text:p></office:text></after>
|
||||
</test>
|
||||
<test name="SplitParagraphAddAnnotation_endPosSame">
|
||||
<!-- a paragraph split at the position of the end of an annotation should add the split to the annotated area -->
|
||||
@@ -1300,7 +1300,7 @@
|
||||
<op optype="AddCursor" memberid="Bob"/>
|
||||
<op optype="MoveCursor" memberid="Bob" position="3"/>
|
||||
<op optype="AddAnnotation" memberid="Alice" position="2" length="1" name="alice_1" timestamp="1375706047061"/>
|
||||
<op optype="SplitParagraph" memberid="Bob" position="4"/>
|
||||
<op optype="SplitParagraph" memberid="Bob" position="5"/>
|
||||
</ops>
|
||||
<after><office:text><text:p>ab<office:annotation office:name="alice_1"><dc:creator e:memberid="Alice">Alice</dc:creator><dc:date>2013-08-05T12:34:07.061Z</dc:date><text:list><text:list-item><text:p><c:cursor c:memberId="Alice"/></text:p></text:list-item></text:list></office:annotation>c</text:p><text:p><office:annotation-end office:name="alice_1"/><c:cursor c:memberId="Bob"/>d</text:p></office:text></after>
|
||||
</test>
|
||||
@@ -1326,8 +1326,8 @@
|
||||
<op optype="AddCursor" memberid="Bob"/>
|
||||
<op optype="MoveCursor" memberid="Bob" position="3"/>
|
||||
<op optype="AddAnnotation" memberid="Alice" position="2" length="1" name="alice_1" timestamp="1375706047061"/>
|
||||
<op optype="InsertText" memberid="Bob" position="4" text="1" moveCursor="true"/>
|
||||
<op optype="InsertText" memberid="Bob" position="5" text="2" moveCursor="true"/>
|
||||
<op optype="InsertText" memberid="Bob" position="5" text="1" moveCursor="true"/>
|
||||
<op optype="InsertText" memberid="Bob" position="6" text="2" moveCursor="true"/>
|
||||
</ops>
|
||||
<after><office:text><text:p>ab<office:annotation office:name="alice_1"><dc:creator e:memberid="Alice">Alice</dc:creator><dc:date>2013-08-05T12:34:07.061Z</dc:date><text:list><text:list-item><text:p><c:cursor c:memberId="Alice"/></text:p></text:list-item></text:list></office:annotation>c12<c:cursor c:memberId="Bob"/><office:annotation-end office:name="alice_1"/>d</text:p></office:text></after>
|
||||
</test>
|
||||
@@ -1340,8 +1340,8 @@
|
||||
<op optype="AddCursor" memberid="Bob"/>
|
||||
<op optype="MoveCursor" memberid="Bob" position="4"/>
|
||||
<op optype="AddAnnotation" memberid="Alice" position="2" length="2" name="alice_1" timestamp="1375706047061"/>
|
||||
<op optype="InsertText" memberid="Bob" position="5" text="1" moveCursor="true"/>
|
||||
<op optype="InsertText" memberid="Bob" position="6" text="2" moveCursor="true"/>
|
||||
<op optype="InsertText" memberid="Bob" position="6" text="1" moveCursor="true"/>
|
||||
<op optype="InsertText" memberid="Bob" position="7" text="2" moveCursor="true"/>
|
||||
</ops>
|
||||
<after><office:text><text:p>ab<office:annotation office:name="alice_1"><dc:creator e:memberid="Alice">Alice</dc:creator><dc:date>2013-08-05T12:34:07.061Z</dc:date><text:list><text:list-item><text:p><c:cursor c:memberId="Alice"/></text:p></text:list-item></text:list></office:annotation>cd12<c:cursor c:memberId="Bob"/><office:annotation-end office:name="alice_1"/></text:p></office:text></after>
|
||||
</test>
|
||||
|
||||
Reference in New Issue
Block a user