diff --git a/word/Editor/Document.js b/word/Editor/Document.js index ca0beaf2c7..e6343139f6 100644 --- a/word/Editor/Document.js +++ b/word/Editor/Document.js @@ -1408,7 +1408,7 @@ function CDocument(DrawingDocument, isMainLogicDocument) this.CompileStyleOnLoad = false; // Компилировать ли принудительно стили во время загрузки this.SmartParagraphSelection = true; // Выделять ли автоматически знак параграфа, когда все содержимое параграфа выделено this.PreventPreDelete = false; // Заглушка на случай, когда удаляемые объекты, не удаляются, а переносятся - this.ClearNotesOnPreDelete = true; // Очищать ли сноски при удалении (выключаем, при сплите параграфа) + this.ClearNotesOnPreDelete = true; // Очищать ли сноски при удалении (выключаем, при сплите параграфа) // TODO: Объединить с PreventPreDelete this.DrawTableMode = { Start : false, diff --git a/word/Editor/Paragraph/RunContent/FootnoteReference.js b/word/Editor/Paragraph/RunContent/FootnoteReference.js index 675c7cbc79..cf95698492 100644 --- a/word/Editor/Paragraph/RunContent/FootnoteReference.js +++ b/word/Editor/Paragraph/RunContent/FootnoteReference.js @@ -293,7 +293,8 @@ let logicDocument = paragraph ? paragraph.GetTopDocumentContent() : null; if (!logicDocument - || !(logicDocument instanceof AscWord.CDocument) + || !logicDocument.IsDocumentEditor() + || logicDocument.isPreventedPreDelete() || false === logicDocument.ClearNotesOnPreDelete) return; diff --git a/word/Editor/Run.js b/word/Editor/Run.js index cd42869946..8fd2e1d3ef 100644 --- a/word/Editor/Run.js +++ b/word/Editor/Run.js @@ -12143,6 +12143,15 @@ ParaRun.prototype.CopyTextFormContent = function(oRun) */ ParaRun.prototype.ConvertFootnoteType = function(isToFootnote, oStyles, oFootnote, oRef) { + let _t = this; + function replaceRef(pos, newRef) + { + AscCommon.executeNoPreDelete(function(){ + _t.RemoveFromContent(pos, 1); + _t.AddToContent(pos, newRef); + }, _t.GetLogicDocument()); + } + var sRStyle = this.GetRStyle(); if (isToFootnote) { @@ -12151,21 +12160,15 @@ ParaRun.prototype.ConvertFootnoteType = function(isToFootnote, oStyles, oFootnot else if (sRStyle === oStyles.GetDefaultEndnoteReference()) this.SetRStyle(oStyles.GetDefaultFootnoteReference()); - for (var nCurPos = 0, nCount = this.Content.length; nCurPos < nCount; ++nCurPos) + for (let nCurPos = 0, nCount = this.Content.length; nCurPos < nCount; ++nCurPos) { - var oElement = this.Content[nCurPos]; + let oElement = this.Content[nCurPos]; if (!oRef || oRef === oElement) { if (para_EndnoteReference === oElement.Type) - { - this.RemoveFromContent(nCurPos, 1); - this.AddToContent(nCurPos, new AscWord.CRunFootnoteReference(oFootnote, oElement.CustomMark)); - } + replaceRef(nCurPos, new AscWord.CRunFootnoteReference(oFootnote, oElement.CustomMark)); else if (para_EndnoteRef === oElement.Type) - { - this.RemoveFromContent(nCurPos, 1); - this.AddToContent(nCurPos, new AscWord.CRunFootnoteRef(oFootnote)); - } + replaceRef(nCurPos, new AscWord.CRunFootnoteRef(oFootnote)); } } } @@ -12176,21 +12179,15 @@ ParaRun.prototype.ConvertFootnoteType = function(isToFootnote, oStyles, oFootnot else if (sRStyle === oStyles.GetDefaultFootnoteReference()) this.SetRStyle(oStyles.GetDefaultEndnoteReference()); - for (var nCurPos = 0, nCount = this.Content.length; nCurPos < nCount; ++nCurPos) + for (let nCurPos = 0, nCount = this.Content.length; nCurPos < nCount; ++nCurPos) { - var oElement = this.Content[nCurPos]; + let oElement = this.Content[nCurPos]; if (!oRef || oRef === oElement) { if (para_FootnoteReference === oElement.Type) - { - this.RemoveFromContent(nCurPos, 1); - this.AddToContent(nCurPos, new AscWord.CRunEndnoteReference(oFootnote, oElement.CustomMark)); - } + replaceRef(nCurPos, new AscWord.CRunEndnoteReference(oFootnote, oElement.CustomMark)); else if (para_FootnoteRef === oElement.Type) - { - this.RemoveFromContent(nCurPos, 1); - this.AddToContent(nCurPos, new AscWord.CRunEndnoteRef(oFootnote)); - } + replaceRef(nCurPos, new AscWord.CRunEndnoteRef(oFootnote)); } } }