mirror of
https://github.com/ONLYOFFICE/sdkjs.git
synced 2026-02-10 18:15:19 +08:00
Fix bug #79871
Fix addingFieldData for field in header/footer/footnotes etc.
This commit is contained in:
@ -368,6 +368,7 @@
|
||||
return;
|
||||
|
||||
logicDocument.RemoveFromContent(0, logicDocument.GetElementsCount(), false);
|
||||
logicDocument.GetFinalSectPr().RemoveAllHdrFtr();
|
||||
}
|
||||
function ClearParagraph(p)
|
||||
{
|
||||
|
||||
@ -74,6 +74,8 @@
|
||||
Set_RulerState_Table : function() {},
|
||||
scrollToTarget : function() {},
|
||||
GetVisibleRegion : function() {return [{Page : 0, Y : 0}, {Page : 0, Y : 0}]},
|
||||
IsFreezePage : function() {return false;},
|
||||
Set_RulerState_HdrFtr : function() {},
|
||||
};
|
||||
|
||||
drawingDocument.CanvasHit = document.createElement('canvas');
|
||||
@ -173,6 +175,7 @@
|
||||
editor.asc_haveSpaceAfterParagraph = AscCommon.DocumentEditorApi.prototype.asc_haveSpaceAfterParagraph.bind(editor);
|
||||
editor.initCollaborativeEditing = AscCommon.DocumentEditorApi.prototype.initCollaborativeEditing.bind(editor);
|
||||
editor.asc_PasteData = AscCommon.DocumentEditorApi.prototype.asc_PasteData.bind(editor);
|
||||
editor.GoToHeader = AscCommon.DocumentEditorApi.prototype.GoToHeader.bind(editor);
|
||||
|
||||
editor.externalChartCollector = {
|
||||
onUpdateExternalList: function () {},
|
||||
|
||||
@ -113,7 +113,30 @@ $(function () {
|
||||
"Remove the first add-in field");
|
||||
|
||||
});
|
||||
|
||||
|
||||
QUnit.test("Test addin fields in header/footer", function (assert)
|
||||
{
|
||||
AscTest.ClearDocument();
|
||||
MoveToNewParagraph();
|
||||
|
||||
let sectPr = logicDocument.GetFinalSectPr();
|
||||
let header = AscTest.CreateDefaultHeader(sectPr);
|
||||
header.Set_CurrentElement(false, 0);
|
||||
|
||||
logicDocument.Set_DocumentDefaultTab(35.45);
|
||||
|
||||
let addinFieldData = {"FieldId": "1", "Value": "Addin №1", "Content": "This is the first addin field"};
|
||||
PluginsApi.pluginMethod_AddAddinField(addinFieldData);
|
||||
|
||||
logicDocument.RemoveSelection();
|
||||
logicDocument.Document_UpdateInterfaceState();
|
||||
|
||||
let fields = PluginsApi.pluginMethod_GetAllAddinFields();
|
||||
assert.strictEqual(fields.length, 1, "Check one addin field in header");
|
||||
assert.strictEqual(fields[0].Value, "Addin №1", "Check Value");
|
||||
assert.strictEqual(fields[0].Content, "This is the first addin field", "Check Content from header field");
|
||||
});
|
||||
|
||||
QUnit.test("Test RemoveFieldWrapper", function(assert)
|
||||
{
|
||||
AscTest.ClearDocument();
|
||||
|
||||
@ -14462,7 +14462,7 @@ CDocument.prototype.AddSectionBreak = function(sectionBreakType)
|
||||
sectPr.Copy(curSectPr);
|
||||
curSectPr.Set_Type(sectionBreakType);
|
||||
curSectPr.SetPageNumStart(-1);
|
||||
curSectPr.Clear_AllHdrFtr();
|
||||
curSectPr.RemoveAllHdrFtr();
|
||||
|
||||
this.History.MinorChanges = false;
|
||||
|
||||
|
||||
@ -1761,7 +1761,7 @@ CComplexField.prototype.GetFieldValueText = function()
|
||||
var oEndPos = oDocument.GetContentPosition(false);
|
||||
|
||||
oDocument.SetSelectionByContentPositions(oStartPos, oEndPos);
|
||||
let result = oDocument.GetSelectedText();
|
||||
let result = logicDocument ? logicDocument.GetSelectedText() : "";
|
||||
|
||||
if (state)
|
||||
logicDocument.LoadDocumentState(state);
|
||||
|
||||
@ -188,7 +188,7 @@ var section_footnote_RestartEachPage = 0x02;
|
||||
if (Other.HaveLineNumbers())
|
||||
this.SetLineNumbers(Other.GetLineNumbersCountBy(), Other.GetLineNumbersDistance(), Other.GetLineNumbersStart(), Other.GetLineNumbersRestart());
|
||||
};
|
||||
SectPr.prototype.Clear_AllHdrFtr = function()
|
||||
SectPr.prototype.RemoveAllHdrFtr = function()
|
||||
{
|
||||
this.Set_Header_First(null);
|
||||
this.Set_Header_Even(null);
|
||||
|
||||
@ -7210,7 +7210,7 @@
|
||||
oSectPr.Copy(oCurSectPr);
|
||||
oCurSectPr.Set_Type(oSectPr.Type);
|
||||
oCurSectPr.SetPageNumStart(-1);
|
||||
oCurSectPr.Clear_AllHdrFtr();
|
||||
oCurSectPr.RemoveAllHdrFtr();
|
||||
|
||||
oParagraph.private_GetImpl().Set_SectionPr(oSectPr);
|
||||
return new ApiSection(oSectPr);
|
||||
@ -11947,7 +11947,7 @@
|
||||
|
||||
oCurSectPr.Set_Type(oSectPr.Type);
|
||||
oCurSectPr.SetPageNumStart(-1);
|
||||
oCurSectPr.Clear_AllHdrFtr();
|
||||
oCurSectPr.RemoveAllHdrFtr();
|
||||
|
||||
this.private_GetImpl().Set_SectionPr(oSectPr);
|
||||
return true;
|
||||
|
||||
Reference in New Issue
Block a user