Commit c29c2e79 authored by Ilya Kirillov's avatar Ilya Kirillov

Added ability to insert inline content to the document.

parent ee5e8b67
......@@ -2946,6 +2946,10 @@ CParagraphContentWithParagraphLikeContent.prototype.AddContentControl = function
return oContentControl;
}
};
CParagraphContentWithParagraphLikeContent.prototype.GetElementsCount = function()
{
return this.Content.length;
};
//----------------------------------------------------------------------------------------------------------------------
// Функции, которые должны быть реализованы в классах наследниках
//----------------------------------------------------------------------------------------------------------------------
......
......@@ -339,6 +339,11 @@ CInlineLevelSdt.prototype.FindNextFillingForm = function(isNext, isCurrent, isSt
return null;
};
CInlineLevelSdt.prototype.GetAllContentControls = function(arrContentControls)
{
arrContentControls.push(this);
CParagraphContentWithParagraphLikeContent.prototype.GetAllContentControls.apply(this, arguments);
};
//----------------------------------------------------------------------------------------------------------------------
// Выставление настроек
//----------------------------------------------------------------------------------------------------------------------
......
......@@ -520,21 +520,45 @@
var _script = "(function(){ var Api = window.g_asc_plugins.api;\n" + _current["Script"] + "\n})();";
eval(_script);
if (_isReplaced)
if (AscCommonWord.sdttype_BlockLevel === _blockStd.GetContentControlType())
{
if (_blockStd.Content.Get_ElementsCount() > 1)
_blockStd.Content.Remove_FromContent(_blockStd.Content.Get_ElementsCount() - 1, 1);
if (_isReplaced)
{
if (_blockStd.Content.Get_ElementsCount() > 1)
_blockStd.Content.Remove_FromContent(_blockStd.Content.Get_ElementsCount() - 1, 1);
_blockStd.MoveCursorToStartPos(false);
_blockStd.MoveCursorToStartPos(false);
}
else
{
if (_blockStd.Content.Get_ElementsCount() > 1)
{
_blockStd.Content.Remove_FromContent(_blockStd.Content.Get_ElementsCount() - 1, 1);
_blockStd.MoveCursorToEndPos(false, false);
}
LogicDocument.MoveCursorRight(false, false, true);
}
}
else
{
if (_blockStd.Content.Get_ElementsCount() > 1)
if (_isReplaced)
{
_blockStd.Content.Remove_FromContent(_blockStd.Content.Get_ElementsCount() - 1, 1);
_blockStd.MoveCursorToEndPos(false, false);
if (_blockStd.GetElementsCount() > 1)
_blockStd.Remove_FromContent(_blockStd.GetElementsCount() - 1, 1);
_blockStd.MoveCursorToStartPos();
_blockStd.SetThisElementCurrent();
}
else
{
if (_blockStd.Content.GetElementsCount() > 1)
{
_blockStd.Remove_FromContent(_blockStd.GetElementsCount() - 1, 1);
_blockStd.MoveCursorToEndPos();
_blockStd.SetThisElementCurrent();
}
LogicDocument.MoveCursorRight(false, false, true);
}
LogicDocument.MoveCursorRight(false, false, true);
}
var _worker = _api.__content_control_worker;
......
......@@ -1340,9 +1340,10 @@
/**
* Insert an array of elements in the current position of the document.
* @param {DocumentElement[]} arrContent - An array of elements to insert.
* @param {boolean} [isInline=false] - Inline insert on not (works only when the length of arrContent = 1 and it's a paragraph)
* @returns {boolean} Success?
*/
ApiDocument.prototype.InsertContent = function(arrContent)
ApiDocument.prototype.InsertContent = function(arrContent, isInline)
{
var oSelectedContent = new CSelectedContent();
for (var nIndex = 0, nCount = arrContent.length; nIndex < nCount; ++nIndex)
......@@ -1350,7 +1351,10 @@
var oElement = arrContent[nIndex];
if (oElement instanceof ApiParagraph || oElement instanceof ApiTable)
{
oSelectedContent.Add(new CSelectedElement(oElement.private_GetImpl(), true));
if (true === isInline && 1 === nCount && oElement instanceof ApiParagraph)
oSelectedContent.Add(new CSelectedElement(oElement.private_GetImpl(), false));
else
oSelectedContent.Add(new CSelectedElement(oElement.private_GetImpl(), true));
}
}
oSelectedContent.On_EndCollectElements(this.Document, true);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment