mirror of
https://github.com/ONLYOFFICE/sdkjs.git
synced 2026-02-10 18:15:19 +08:00
[de] Fix the problem with registering forms in the document editor
This commit is contained in:
@ -419,6 +419,7 @@
|
||||
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
CFormsManager.prototype.CheckFormsList = function()
|
||||
{
|
||||
_flushFormToCheck();
|
||||
if (!this.UpdateList)
|
||||
return;
|
||||
|
||||
@ -613,8 +614,54 @@
|
||||
{
|
||||
return (form && form.IsUseInDocument());
|
||||
};
|
||||
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
// Здесь мы копим список форм, которые еще никуда не добавлены и надо будет их обработать при первом обращении
|
||||
let formToCheck = [];
|
||||
function _registerForm(form)
|
||||
{
|
||||
let formId = form.GetId();
|
||||
if (formToCheck[formId])
|
||||
delete formToCheck[formId];
|
||||
|
||||
let para = form.GetParagraph();
|
||||
if (!para)
|
||||
return;
|
||||
|
||||
let logicDocument = para.GetLogicDocument();
|
||||
if (!logicDocument || !logicDocument.IsDocumentEditor())
|
||||
return;
|
||||
|
||||
logicDocument.GetFormsManager().Register(form);
|
||||
}
|
||||
function _flushFormToCheck()
|
||||
{
|
||||
formToCheck.forEach(_registerForm);
|
||||
formToCheck.length = 0;
|
||||
}
|
||||
function registerForm(form)
|
||||
{
|
||||
let para = form.GetParagraph();
|
||||
if (!para || !para.GetLogicDocument())
|
||||
{
|
||||
formToCheck.push(form);
|
||||
return;
|
||||
}
|
||||
|
||||
_registerForm(form);
|
||||
}
|
||||
function unregisterForm(form)
|
||||
{
|
||||
let para = form.GetParagraph();
|
||||
let logicDocument = para.GetLogicDocument();
|
||||
if (!logicDocument || !logicDocument.IsDocumentEditor())
|
||||
return;
|
||||
|
||||
logicDocument.GetFormsManager().Unregister(form);
|
||||
}
|
||||
//--------------------------------------------------------export----------------------------------------------------
|
||||
window['AscWord'] = window['AscWord'] || {};
|
||||
window['AscWord'].CFormsManager = CFormsManager;
|
||||
window['AscWord'].CFormsManager = CFormsManager;
|
||||
window['AscWord'].registerForm = registerForm;
|
||||
window['AscWord'].unregisterForm = unregisterForm;
|
||||
|
||||
})(window);
|
||||
|
||||
@ -1354,10 +1354,7 @@ CInlineLevelSdt.prototype.Document_UpdateInterfaceState = function()
|
||||
};
|
||||
CInlineLevelSdt.prototype.SetParagraph = function(oParagraph)
|
||||
{
|
||||
let oLogicDocument;
|
||||
if (this.GetTextFormPr() && (oLogicDocument = this.GetLogicDocument()))
|
||||
oLogicDocument.GetFormsManager().Register(this);
|
||||
|
||||
AscWord.registerForm(this);
|
||||
CParagraphContentWithParagraphLikeContent.prototype.SetParagraph.apply(this, arguments);
|
||||
};
|
||||
CInlineLevelSdt.prototype.Apply_TextPr = function(TextPr, IncFontSize, ApplyToAll)
|
||||
|
||||
@ -695,15 +695,10 @@ CChangesSdtPrFormPr.prototype.private_SetValue = function(Value)
|
||||
form.Pr.FormPr.Field = fieldMaster;
|
||||
}
|
||||
|
||||
let logicDocument = form.GetLogicDocument();
|
||||
let formManager = logicDocument ? logicDocument.GetFormsManager() : null;
|
||||
if (formManager)
|
||||
{
|
||||
if (Value)
|
||||
formManager.Register(form);
|
||||
else
|
||||
formManager.Unregister(form);
|
||||
}
|
||||
if (Value)
|
||||
AscWord.registerForm(form);
|
||||
else
|
||||
AscWord.unregisterForm(form);
|
||||
};
|
||||
CChangesSdtPrFormPr.prototype.private_CreateObject = function()
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user