[de] Fix cursor position during composite input

This commit is contained in:
KirillovIlya
2024-02-15 18:06:48 +03:00
committed by Ilya Kirillov
parent f4f623cdb8
commit 730f619b89
4 changed files with 101 additions and 4 deletions

View File

@ -94,6 +94,20 @@ $(function () {
AscTest.EnterTextCompositeInput("yz");
AscTest.CorrectEnterText("yz", "x");
assert.strictEqual(GetParagraphText(p), "xx", "Test special case, when added symbols collect to a single grapheme with previous symbols");
// Вводим на сингальском 1ෑඒ (1-e-e-t)
p = new AscWord.CParagraph(AscTest.DrawingDocument);
logicDocument.PushToContent(p);
AscTest.MoveCursorToParagraph(p);
AscTest.EnterText("1");
AscTest.BeginCompositeInput();
AscTest.ReplaceCompositeInput([]);
AscTest.ReplaceCompositeInput([3536]);
AscTest.ReplaceCompositeInput([3537]);
AscTest.ReplaceCompositeInput([3537, 3474]);
AscTest.EndCompositeInput();
assert.strictEqual(GetParagraphText(p), "1ෑඒ", "Add text '1ෑඒ'");
assert.strictEqual(p.IsCursorAtEnd(), true, "Check cursor position");
});
QUnit.test("EnterText/CorrectEnterText/CompositeInput in collaboration", function (assert)
{
@ -120,6 +134,42 @@ $(function () {
AscTest.EndCollaboration();
});
QUnit.test("EnterText/CorrectEnterText/CompositeInput with running TextSpeaker", function (assert)
{
AscTest.StartTextSpeaker();
AscTest.ClearDocument();
let p = new AscWord.CParagraph(AscTest.DrawingDocument);
logicDocument.AddToContent(0, p);
AscTest.EnterText("ABC");
assert.strictEqual(GetParagraphText(p), "ABC", "Add text 'ABC' in collaboration");
AscTest.MoveCursorLeft();
AscTest.EnterText("111");
AscTest.CorrectEnterText("11", "23");
assert.strictEqual(GetParagraphText(p), "AB123C", "Add text '111' and correct it with '123' in collaboration (sync between actions)");
AscTest.EnterText("QQQ");
AscTest.CorrectEnterText("QQ", "RS");
assert.strictEqual(GetParagraphText(p), "AB123QRSC", "Add text '111' and correct it with '123' in collaboration (no sync between actions)");
// Вводим на сингальском 1ෑඒ (1-e-e-t)
p = new AscWord.CParagraph(AscTest.DrawingDocument);
logicDocument.PushToContent(p);
AscTest.MoveCursorToParagraph(p);
AscTest.EnterText("1");
AscTest.BeginCompositeInput();
AscTest.ReplaceCompositeInput([]);
AscTest.ReplaceCompositeInput([3536]);
AscTest.ReplaceCompositeInput([3537]);
AscTest.ReplaceCompositeInput([3537, 3474]);
AscTest.EndCompositeInput();
assert.strictEqual(GetParagraphText(p), "1ෑඒ", "Add text '1ෑඒ'");
assert.strictEqual(p.IsCursorAtEnd(), true, "Check cursor position");
AscTest.StopTextSpeaker();
});
QUnit.test("Test 'complex script' property on input", function (assert)
{
function CheckParagraphSplit(p, text, runCS, runText)
@ -220,6 +270,5 @@ $(function () {
[true, true],
["3", "ෑඒ"]
);
});
});

View File

@ -433,10 +433,18 @@
{
AscCommon.CollaborativeEditing.End_CollaborationEditing();
}
function StartTextSpeaker()
{
AscCommon.EditorActionSpeaker.run();
}
function StopTextSpeaker()
{
AscCommon.EditorActionSpeaker.stop();
}
//--------------------------------------------------------export----------------------------------------------------
AscTest.CreateLogicDocument = CreateLogicDocument;
AscTest.GetLogicDocument = CreateLogicDocument;
AscTest.CreateParagraph = CreateParagraph;
AscTest.CreateRun = CreateRun;
AscTest.CreateTable = CreateTable;
@ -474,6 +482,8 @@
AscTest.SyncCollaboration = SyncCollaboration;
AscTest.EndCollaboration = EndCollaboration;
AscTest.SelectParagraphRange = SelectParagraphRange;
AscTest.StartTextSpeaker = StartTextSpeaker;
AscTest.StopTextSpeaker = StopTextSpeaker;
})(window);

View File

@ -73,6 +73,7 @@
window['asc_docs_api'] = AscCommon.baseEditorsApi;
let _callbacks = {};
const editor = new AscCommon.baseEditorsApi({});
editor.WordControl = drawingDocument;
editor.WordControl.m_oDrawingDocument = drawingDocument;
@ -105,7 +106,44 @@
editor.sync_ColumnsPropsCallback = function(){};
editor.sync_LineNumbersPropsCollback = function(){};
editor.sync_SectionPropsCallback = function(){};
editor.sendEvent = function()
{
var name = arguments[0];
if (_callbacks.hasOwnProperty(name))
{
for (var i = 0; i < _callbacks[name].length; ++i)
{
_callbacks[name][i].apply(this || window, Array.prototype.slice.call(arguments, 1));
}
return true;
}
return false;
};
editor.asc_registerCallback = function(name, callback)
{
if (!_callbacks.hasOwnProperty(name))
_callbacks[name] = [];
_callbacks[name].push(callback);
};
editor.asc_unregisterCallback = function(name, callback)
{
if (_callbacks.hasOwnProperty(name))
{
for (var i = _callbacks[name].length - 1; i >= 0; --i)
{
if (_callbacks[name][i] === callback)
_callbacks[name].splice(i, 1);
}
}
};
editor.getSelectionState = function()
{
return AscTest.GetLogicDocument().GetSelectionState();
};
editor.getSpeechDescription = function()
{
return AscTest.GetLogicDocument().getSpeechDescription(...arguments);
};
//--------------------------------------------------------export----------------------------------------------------
AscTest.DrawingDocument = drawingDocument;
AscTest.Editor = editor;

View File

@ -13751,7 +13751,7 @@ Paragraph.prototype.SetSelectionState = function(State, StateIndex)
this.CurPos.RealY = ParaState.CurPos.RealY;
this.CurPos.PagesPos = ParaState.CurPos.PagesPos;
this.Set_ParaContentPos(ParaState.CurPos.ContentPos, true, -1, -1);
this.Set_ParaContentPos(ParaState.CurPos.ContentPos, true, -1, -1, false);
this.RemoveSelection();