mirror of
https://github.com/ONLYOFFICE/sdkjs.git
synced 2026-04-07 14:09:12 +08:00
[de][bu] Add Delete method for ApiFormBase
Don't return forms on GetAllContentControls method in JsApi
This commit is contained in:
110
tests/runAll.js
110
tests/runAll.js
@ -33,65 +33,65 @@
|
|||||||
const path = require("path");
|
const path = require("path");
|
||||||
|
|
||||||
const allTests = [
|
const allTests = [
|
||||||
// 'cell/spreadsheet-calculation/FormulaTests.html',
|
'cell/spreadsheet-calculation/FormulaTests.html',
|
||||||
// 'cell/spreadsheet-calculation/PivotTests.html',
|
'cell/spreadsheet-calculation/PivotTests.html',
|
||||||
// 'cell/spreadsheet-calculation/copy-paste-tests.html',
|
'cell/spreadsheet-calculation/copy-paste-tests.html',
|
||||||
// 'cell/spreadsheet-calculation/SheetStructureTests.html',
|
'cell/spreadsheet-calculation/SheetStructureTests.html',
|
||||||
// 'cell/spreadsheet-calculation/autoFilterTests.html',
|
'cell/spreadsheet-calculation/autoFilterTests.html',
|
||||||
// 'cell/spreadsheet-calculation/UserProtectedRangesTest.html',
|
'cell/spreadsheet-calculation/UserProtectedRangesTest.html',
|
||||||
// 'cell/spreadsheet-calculation/FormulaTrace.html',
|
'cell/spreadsheet-calculation/FormulaTrace.html',
|
||||||
// 'cell/spreadsheet-calculation/whatIfAnalysisTests.html',
|
'cell/spreadsheet-calculation/whatIfAnalysisTests.html',
|
||||||
// 'cell/spreadsheet-calculation/NumFormatParse.html',
|
'cell/spreadsheet-calculation/NumFormatParse.html',
|
||||||
// 'cell/spreadsheet-calculation/DataValidationTests.html',
|
'cell/spreadsheet-calculation/DataValidationTests.html',
|
||||||
// 'cell/spreadsheet-calculation/conditionalFormattingTests.html',
|
'cell/spreadsheet-calculation/conditionalFormattingTests.html',
|
||||||
// 'cell/spreadsheet-calculation/ExternalReference.html',
|
'cell/spreadsheet-calculation/ExternalReference.html',
|
||||||
// 'cell/spreadsheet-calculation/SheetMemoryTest.html',
|
'cell/spreadsheet-calculation/SheetMemoryTest.html',
|
||||||
//
|
|
||||||
// 'word/unit-tests/paragraphContentPos.html',
|
'word/unit-tests/paragraphContentPos.html',
|
||||||
// 'word/unit-tests/deleted-text-recovery.html',
|
'word/unit-tests/deleted-text-recovery.html',
|
||||||
// 'word/content-control/block-level/cursorAndSelection.html',
|
'word/content-control/block-level/cursorAndSelection.html',
|
||||||
// 'word/content-control/inline-level/checkbox.html',
|
'word/content-control/inline-level/checkbox.html',
|
||||||
// 'word/content-control/inline-level/cursorAndSelection.html',
|
'word/content-control/inline-level/cursorAndSelection.html',
|
||||||
// 'word/content-control/inline-level/date-time.html',
|
'word/content-control/inline-level/date-time.html',
|
||||||
// 'word/custom-xml/custom-xml.html',
|
'word/custom-xml/custom-xml.html',
|
||||||
// 'word/document-calculation/floating-position/drawing.html',
|
'word/document-calculation/floating-position/drawing.html',
|
||||||
// 'word/document-calculation/paragraph.html',
|
'word/document-calculation/paragraph.html',
|
||||||
// 'word/document-calculation/table/correctBadTable.html',
|
'word/document-calculation/table/correctBadTable.html',
|
||||||
// 'word/document-calculation/table/flowTablePosition.html',
|
'word/document-calculation/table/flowTablePosition.html',
|
||||||
// 'word/document-calculation/table/pageBreak.html',
|
'word/document-calculation/table/pageBreak.html',
|
||||||
// 'word/document-calculation/table/table-flow.html',
|
'word/document-calculation/table/table-flow.html',
|
||||||
// 'word/document-calculation/table/table-header.html',
|
'word/document-calculation/table/table-header.html',
|
||||||
// 'word/document-calculation/textShaper/textShaper.html',
|
'word/document-calculation/textShaper/textShaper.html',
|
||||||
// 'word/document-calculation/text-hyphenator/text-hyphenator.html',
|
'word/document-calculation/text-hyphenator/text-hyphenator.html',
|
||||||
// 'word/forms/forms.html',
|
'word/forms/forms.html',
|
||||||
// 'word/forms/complexForm.html',
|
'word/forms/complexForm.html',
|
||||||
// 'word/numbering/numberingApplicator.html',
|
'word/numbering/numberingApplicator.html',
|
||||||
// 'word/numbering/numberingCalculation.html',
|
'word/numbering/numberingCalculation.html',
|
||||||
// 'word/numbering/numberingAutocorrect.html',
|
'word/numbering/numberingAutocorrect.html',
|
||||||
// 'word/api/api.html',
|
'word/api/api.html',
|
||||||
// 'word/api/cross-ref.html',
|
'word/api/cross-ref.html',
|
||||||
// 'word/api/textInput.html',
|
'word/api/textInput.html',
|
||||||
// 'word/styles/displayStyle.html',
|
'word/styles/displayStyle.html',
|
||||||
// 'word/styles/paraPr.html',
|
'word/styles/paraPr.html',
|
||||||
// 'word/styles/styleApplicator.html',
|
'word/styles/styleApplicator.html',
|
||||||
// 'word/text-autocorrection/as-you-type.html',
|
'word/text-autocorrection/as-you-type.html',
|
||||||
// 'word/plugins/pluginsApi.html',
|
'word/plugins/pluginsApi.html',
|
||||||
// 'word/revisions/document-content.html',
|
'word/revisions/document-content.html',
|
||||||
// 'word/revisions/paragraph.html',
|
'word/revisions/paragraph.html',
|
||||||
// 'word/merge-documents/mergeDocuments.html',
|
'word/merge-documents/mergeDocuments.html',
|
||||||
// 'word/math-autocorrection/math-autocorrection.html',
|
'word/math-autocorrection/math-autocorrection.html',
|
||||||
// 'word/math-ml/math-ml.html',
|
'word/math-ml/math-ml.html',
|
||||||
'word/change-case/change-case.html',
|
'word/change-case/change-case.html',
|
||||||
'word/js-api/js-api.html',
|
'word/js-api/js-api.html',
|
||||||
'word/js-api/js-api-forms.html',
|
'word/js-api/js-api-forms.html',
|
||||||
|
|
||||||
// 'cell/shortcuts/shortcuts.html',
|
'cell/shortcuts/shortcuts.html',
|
||||||
// 'slide/shortcuts/shortcuts.html',
|
'slide/shortcuts/shortcuts.html',
|
||||||
// 'word/shortcuts/shortcuts.html',
|
'word/shortcuts/shortcuts.html',
|
||||||
//
|
|
||||||
// //related ooxml tests
|
//related ooxml tests
|
||||||
// 'oform/xml/oformXml.html',
|
'oform/xml/oformXml.html',
|
||||||
// 'word/custom-xml/custom-xml-ooxml.html',
|
'word/custom-xml/custom-xml-ooxml.html',
|
||||||
];
|
];
|
||||||
|
|
||||||
const maxTestsAtOnce = require('events').defaultMaxListeners;
|
const maxTestsAtOnce = require('events').defaultMaxListeners;
|
||||||
|
|||||||
@ -34,8 +34,11 @@ $(function ()
|
|||||||
{
|
{
|
||||||
QUnit.module("Test the ApiTextForm methods");
|
QUnit.module("Test the ApiTextForm methods");
|
||||||
|
|
||||||
|
let logicDocument = AscTest.CreateLogicDocument();
|
||||||
|
|
||||||
function createApiTextForm(pr)
|
function createApiTextForm(pr)
|
||||||
{
|
{
|
||||||
|
pr = pr ? pr : {"key": "Name", "placeholder": "Enter your name"};
|
||||||
return AscTest.Editor.CreateTextForm(pr);
|
return AscTest.Editor.CreateTextForm(pr);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -51,4 +54,34 @@ $(function ()
|
|||||||
textForm.SetPlaceholderText("TEST");
|
textForm.SetPlaceholderText("TEST");
|
||||||
assert.strictEqual(textForm.GetPlaceholderText(), "TEST" , "Check text form placeholder after reset placeholder text");
|
assert.strictEqual(textForm.GetPlaceholderText(), "TEST" , "Check text form placeholder after reset placeholder text");
|
||||||
});
|
});
|
||||||
|
|
||||||
|
QUnit.test("Delete", function (assert)
|
||||||
|
{
|
||||||
|
AscTest.ClearDocument();
|
||||||
|
let document = AscTest.Editor.GetDocument();
|
||||||
|
let p = AscTest.Editor.CreateParagraph();
|
||||||
|
document.Push(p);
|
||||||
|
|
||||||
|
let textForm = createApiTextForm();
|
||||||
|
|
||||||
|
p.AddText("Before");
|
||||||
|
p.Push(textForm);
|
||||||
|
p.AddText("After");
|
||||||
|
|
||||||
|
assert.strictEqual(textForm.Sdt.IsUseInDocument(), true, "Check if text form were added");
|
||||||
|
|
||||||
|
textForm.Delete(false);
|
||||||
|
assert.strictEqual(textForm.Sdt.IsUseInDocument(), false, "Check if text form were deleted");
|
||||||
|
assert.strictEqual(p.GetText(), "BeforeAfter\r\n", "Check paragraph text");
|
||||||
|
|
||||||
|
p.RemoveAllElements();
|
||||||
|
textForm.SetText("Inside");
|
||||||
|
p.AddText("Before");
|
||||||
|
p.Push(textForm);
|
||||||
|
p.AddText("After");
|
||||||
|
|
||||||
|
textForm.Delete(true);
|
||||||
|
assert.strictEqual(textForm.Sdt.IsUseInDocument(), false, "Check if text form were deleted");
|
||||||
|
assert.strictEqual(p.GetText(), "BeforeInsideAfter\r\n", "Check paragraph text");
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
|||||||
@ -23546,7 +23546,23 @@
|
|||||||
this.Sdt.SetFormRole(role);
|
this.Sdt.SetFormRole(role);
|
||||||
return true;
|
return true;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Removes a form and its content. If keepContent is true, the content is not deleted.
|
||||||
|
* @memberof ApiFormBase
|
||||||
|
* @typeofeditors ["CDE", "CFE"]
|
||||||
|
* @since 9.2.0
|
||||||
|
* @param {boolean} keepContent - Specifies if the content will be deleted or not.
|
||||||
|
* @returns {boolean} - returns false if form wasn't added to the document.
|
||||||
|
* @see office-js-api/Examples/{Editor}/ApiFormBase/Methods/Delete.js
|
||||||
|
*/
|
||||||
|
ApiFormBase.prototype.Delete = function(keepContent)
|
||||||
|
{
|
||||||
|
return executeNoFormLockCheck(function(){
|
||||||
|
return ApiInlineLvlSdt.prototype.Delete.call(this, keepContent);
|
||||||
|
}, this);
|
||||||
|
};
|
||||||
|
|
||||||
//------------------------------------------------------------------------------------------------------------------
|
//------------------------------------------------------------------------------------------------------------------
|
||||||
//
|
//
|
||||||
// ApiTextForm
|
// ApiTextForm
|
||||||
@ -28160,6 +28176,7 @@
|
|||||||
ApiFormBase.prototype["SetTag"] = ApiFormBase.prototype.SetTag;
|
ApiFormBase.prototype["SetTag"] = ApiFormBase.prototype.SetTag;
|
||||||
ApiFormBase.prototype["GetRole"] = ApiFormBase.prototype.GetRole;
|
ApiFormBase.prototype["GetRole"] = ApiFormBase.prototype.GetRole;
|
||||||
ApiFormBase.prototype["SetRole"] = ApiFormBase.prototype.SetRole;
|
ApiFormBase.prototype["SetRole"] = ApiFormBase.prototype.SetRole;
|
||||||
|
ApiFormBase.prototype["Delete"] = ApiFormBase.prototype.Delete;
|
||||||
|
|
||||||
ApiTextForm.prototype["GetClassType"] = ApiTextForm.prototype.GetClassType;
|
ApiTextForm.prototype["GetClassType"] = ApiTextForm.prototype.GetClassType;
|
||||||
ApiTextForm.prototype["IsAutoFit"] = ApiTextForm.prototype.IsAutoFit;
|
ApiTextForm.prototype["IsAutoFit"] = ApiTextForm.prototype.IsAutoFit;
|
||||||
@ -28531,10 +28548,10 @@
|
|||||||
{
|
{
|
||||||
if (!oControl)
|
if (!oControl)
|
||||||
return null;
|
return null;
|
||||||
|
|
||||||
if (oControl instanceof CBlockLevelSdt)
|
if (oControl instanceof CBlockLevelSdt)
|
||||||
return (new ApiBlockLvlSdt(oControl));
|
return (new ApiBlockLvlSdt(oControl));
|
||||||
else if (oControl instanceof CInlineLevelSdt)
|
else if (oControl instanceof CInlineLevelSdt && !oControl.IsForm())
|
||||||
return (new ApiInlineLvlSdt(oControl));
|
return (new ApiInlineLvlSdt(oControl));
|
||||||
|
|
||||||
return null;
|
return null;
|
||||||
@ -29662,6 +29679,8 @@
|
|||||||
};
|
};
|
||||||
ApiBlockLvlSdt.prototype._canBeEdited = ApiInlineLvlSdt.prototype._canBeEdited;
|
ApiBlockLvlSdt.prototype._canBeEdited = ApiInlineLvlSdt.prototype._canBeEdited;
|
||||||
ApiBlockLvlSdt.prototype._canBeDeleted = ApiInlineLvlSdt.prototype._canBeDeleted;
|
ApiBlockLvlSdt.prototype._canBeDeleted = ApiInlineLvlSdt.prototype._canBeDeleted;
|
||||||
|
ApiFormBase.prototype._canBeEdited = ApiInlineLvlSdt.prototype._canBeEdited;
|
||||||
|
ApiFormBase.prototype._canBeDeleted = ApiInlineLvlSdt.prototype._canBeDeleted;
|
||||||
ApiContentControlList.prototype.GetListPr = function()
|
ApiContentControlList.prototype.GetListPr = function()
|
||||||
{
|
{
|
||||||
if (this.Sdt.IsComboBox())
|
if (this.Sdt.IsComboBox())
|
||||||
|
|||||||
Reference in New Issue
Block a user