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 ...@@ -2946,6 +2946,10 @@ CParagraphContentWithParagraphLikeContent.prototype.AddContentControl = function
return oContentControl; return oContentControl;
} }
}; };
CParagraphContentWithParagraphLikeContent.prototype.GetElementsCount = function()
{
return this.Content.length;
};
//---------------------------------------------------------------------------------------------------------------------- //----------------------------------------------------------------------------------------------------------------------
// Функции, которые должны быть реализованы в классах наследниках // Функции, которые должны быть реализованы в классах наследниках
//---------------------------------------------------------------------------------------------------------------------- //----------------------------------------------------------------------------------------------------------------------
......
...@@ -339,6 +339,11 @@ CInlineLevelSdt.prototype.FindNextFillingForm = function(isNext, isCurrent, isSt ...@@ -339,6 +339,11 @@ CInlineLevelSdt.prototype.FindNextFillingForm = function(isNext, isCurrent, isSt
return null; return null;
}; };
CInlineLevelSdt.prototype.GetAllContentControls = function(arrContentControls)
{
arrContentControls.push(this);
CParagraphContentWithParagraphLikeContent.prototype.GetAllContentControls.apply(this, arguments);
};
//---------------------------------------------------------------------------------------------------------------------- //----------------------------------------------------------------------------------------------------------------------
// Выставление настроек // Выставление настроек
//---------------------------------------------------------------------------------------------------------------------- //----------------------------------------------------------------------------------------------------------------------
......
...@@ -520,6 +520,8 @@ ...@@ -520,6 +520,8 @@
var _script = "(function(){ var Api = window.g_asc_plugins.api;\n" + _current["Script"] + "\n})();"; var _script = "(function(){ var Api = window.g_asc_plugins.api;\n" + _current["Script"] + "\n})();";
eval(_script); eval(_script);
if (AscCommonWord.sdttype_BlockLevel === _blockStd.GetContentControlType())
{
if (_isReplaced) if (_isReplaced)
{ {
if (_blockStd.Content.Get_ElementsCount() > 1) if (_blockStd.Content.Get_ElementsCount() > 1)
...@@ -536,6 +538,28 @@ ...@@ -536,6 +538,28 @@
} }
LogicDocument.MoveCursorRight(false, false, true); LogicDocument.MoveCursorRight(false, false, true);
} }
}
else
{
if (_isReplaced)
{
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);
}
}
var _worker = _api.__content_control_worker; var _worker = _api.__content_control_worker;
if (_worker.documents[_worker.current]["Props"]) if (_worker.documents[_worker.current]["Props"])
......
...@@ -1340,9 +1340,10 @@ ...@@ -1340,9 +1340,10 @@
/** /**
* Insert an array of elements in the current position of the document. * Insert an array of elements in the current position of the document.
* @param {DocumentElement[]} arrContent - An array of elements to insert. * @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? * @returns {boolean} Success?
*/ */
ApiDocument.prototype.InsertContent = function(arrContent) ApiDocument.prototype.InsertContent = function(arrContent, isInline)
{ {
var oSelectedContent = new CSelectedContent(); var oSelectedContent = new CSelectedContent();
for (var nIndex = 0, nCount = arrContent.length; nIndex < nCount; ++nIndex) for (var nIndex = 0, nCount = arrContent.length; nIndex < nCount; ++nIndex)
...@@ -1350,6 +1351,9 @@ ...@@ -1350,6 +1351,9 @@
var oElement = arrContent[nIndex]; var oElement = arrContent[nIndex];
if (oElement instanceof ApiParagraph || oElement instanceof ApiTable) if (oElement instanceof ApiParagraph || oElement instanceof ApiTable)
{ {
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.Add(new CSelectedElement(oElement.private_GetImpl(), 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