mirror of
https://github.com/ONLYOFFICE/sdkjs.git
synced 2026-04-07 14:09:12 +08:00
Fix bug #40357
Improve the check of adding a quoted comment. From now on, if the inline content control has been partially selected and has one of the flags "Can't be edited" or "Can't be delete", then we won't add a quoted comment
This commit is contained in:
@ -11419,7 +11419,18 @@ Paragraph.prototype.AddCommentToObject = function(Comment, ObjectId)
|
||||
Paragraph.prototype.CanAddComment = function()
|
||||
{
|
||||
if (true === this.Selection.Use && true != this.IsSelectionEmpty())
|
||||
{
|
||||
var nStartPos = this.Selection.StartPos <= this.Selection.EndPos ? this.Selection.StartPos : this.Selection.EndPos;
|
||||
var nEndPos = this.Selection.StartPos <= this.Selection.EndPos ? this.Selection.EndPos : this.Selection.StartPos;
|
||||
|
||||
for (var nPos = nStartPos; nPos <= nEndPos; ++nPos)
|
||||
{
|
||||
if (this.Content[nPos].CanAddComment && !this.Content[nPos].CanAddComment())
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
};
|
||||
|
||||
@ -606,6 +606,14 @@ CParagraphContentBase.prototype.GetAllFields = function(isUseSelection, arrField
|
||||
{
|
||||
return arrFields ? arrFields : [];
|
||||
};
|
||||
/**
|
||||
* Проверяем можно ли добавлять комментарий по заданому селекту
|
||||
* @returns {boolean}
|
||||
*/
|
||||
CParagraphContentBase.prototype.CanAddComment = function()
|
||||
{
|
||||
return true;
|
||||
};
|
||||
|
||||
/**
|
||||
* Это базовый класс для элементов содержимого(контент) параграфа, у которых есть свое содержимое.
|
||||
@ -3687,6 +3695,22 @@ CParagraphContentWithParagraphLikeContent.prototype.GetAllFields = function(isUs
|
||||
|
||||
return arrFields;
|
||||
};
|
||||
CParagraphContentWithParagraphLikeContent.prototype.CanAddComment = function()
|
||||
{
|
||||
if (!this.Selection.Use)
|
||||
return true;
|
||||
|
||||
var nStartPos = this.Selection.StartPos <= this.Selection.EndPos ? this.Selection.StartPos : this.Selection.EndPos;
|
||||
var nEndPos = this.Selection.StartPos <= this.Selection.EndPos ? this.Selection.EndPos : this.Selection.StartPos;
|
||||
|
||||
for (var nPos = nStartPos; nPos <= nEndPos; ++nPos)
|
||||
{
|
||||
if (this.Content[nPos].CanAddComment && !this.Content[nPos].CanAddComment())
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
};
|
||||
//----------------------------------------------------------------------------------------------------------------------
|
||||
// Функции, которые должны быть реализованы в классах наследниках
|
||||
//----------------------------------------------------------------------------------------------------------------------
|
||||
|
||||
@ -728,6 +728,13 @@ CInlineLevelSdt.prototype.ClearContentControl = function()
|
||||
this.Add_ToContent(0, new ParaRun(this.GetParagraph(), false));
|
||||
this.Remove_FromContent(1, this.Content.length - 1);
|
||||
};
|
||||
CInlineLevelSdt.prototype.CanAddComment = function()
|
||||
{
|
||||
if (!this.CanBeDeleted() || (!this.CanBeEdited() && !this.IsSelectedAll()))
|
||||
return false;
|
||||
|
||||
return CParagraphContentWithParagraphLikeContent.prototype.CanAddComment.apply(this, arguments);
|
||||
};
|
||||
//--------------------------------------------------------export--------------------------------------------------------
|
||||
window['AscCommonWord'] = window['AscCommonWord'] || {};
|
||||
window['AscCommonWord'].CInlineLevelSdt = CInlineLevelSdt;
|
||||
|
||||
Reference in New Issue
Block a user