Allow to add line break into a inline text forms
This commit is contained in:
Ilya Kirillov
2025-06-07 01:25:24 +03:00
parent cd507e3d19
commit e8b196a557
4 changed files with 29 additions and 14 deletions

View File

@ -318,9 +318,9 @@ CStylesPainter.prototype.get_MergedStyles = function ()
if (!logicDocument)
return;
let isShowParaMarks = _api.get_ShowParaMarks();
if (isShowParaMarks)
_api.put_ShowParaMarks(false);
let isShowParaMarks = _api.ShowParaMarks;
if (false !== isShowParaMarks)
_api.ShowParaMarks = false;
let oldTabStop = AscCommonWord.Default_Tab_Stop;
AscCommonWord.Default_Tab_Stop = 1;
@ -336,8 +336,8 @@ CStylesPainter.prototype.get_MergedStyles = function ()
AscCommonWord.Default_Tab_Stop = oldTabStop;
if (isShowParaMarks)
_api.put_ShowParaMarks(isShowParaMarks);
if (false !== isShowParaMarks)
_api.ShowParaMarks = isShowParaMarks;
};
StylePreviewGenerator.prototype._drawStyle = function(_api, graphics, style, styleName)
{

View File

@ -9115,7 +9115,7 @@ CDocument.prototype.OnKeyDown = function(e)
}
else if ((inlineSdt = oSelectedInfo.GetInlineLevelSdt()) && inlineSdt.IsForm())
{
if (inlineSdt.IsTextForm() && inlineSdt.IsMultiLineForm())
if (inlineSdt.IsTextForm() && (inlineSdt.IsMultiLineForm() || (!inlineSdt.IsFixedForm() && e.ShiftKey)))
this.executeShortcut(Asc.c_oAscDocumentShortcutType.InsertLineBreak);
else
this.Api.asc_MoveToFillingForm(true);
@ -9873,7 +9873,7 @@ CDocument.prototype.executeShortcut = function(type)
case Asc.c_oAscDocumentShortcutType.InsertLineBreak:
{
let inlineSdt = this.GetSelectedElementsInfo().GetInlineLevelSdt();
let allowInForm = (inlineSdt && inlineSdt.IsForm() && inlineSdt.IsTextForm() && inlineSdt.IsMultiLineForm());
let allowInForm = (inlineSdt && inlineSdt.IsForm() && inlineSdt.IsTextForm() && (inlineSdt.IsMultiLineForm() || !inlineSdt.IsFixedForm()));
if (!this.IsSelectionLocked(AscCommon.changestype_Paragraph_Content, null, false, allowInForm))
{
let selectedInfo = this.GetSelectedElementsInfo();

View File

@ -485,7 +485,7 @@
for (var nIndex = 0, nCount = this.Elements.length; nIndex < nCount; ++nIndex)
{
var oElement = this.Elements[nIndex].Element;
if (oElement.IsParagraph())
if (oElement.IsParagraph() || oElement.IsTable() || oElement.IsBlockLevelSdt())
sText += oElement.GetText(oPr);
}
return sText;
@ -938,16 +938,28 @@
if ((!oForm.IsTextForm() && !oForm.IsComboBox() && !oForm.IsDatePicker()))
return;
let newLineSep = oForm.IsMultiLineForm() ? "\n" : "";
let newLineSep = "";
if (oForm.IsMultiLineForm() || (oForm.IsTextForm() && !oForm.IsFixedForm()))
newLineSep = "\n";
let sInsertedText = this.GetText({
ParaSeparator : "",
TableCellSeparator : "",
TableRowSeparator : "",
ParaSeparator : newLineSep,
TableCellSeparator : newLineSep,
TableRowSeparator : newLineSep,
NewLineSeparator : newLineSep
});
if (sInsertedText
&& sInsertedText.length
&& newLineSep
&& sInsertedText[sInsertedText.length - 1] === newLineSep)
{
sInsertedText = sInsertedText.slice(0, -1);
}
if (!sInsertedText || !sInsertedText.length)
return;
var isPlaceHolder = oRun.GetParentForm().IsPlaceHolder();
if (isPlaceHolder && oRun.GetParent() instanceof CInlineLevelSdt)
{

View File

@ -98,7 +98,7 @@ CInlineLevelSdt.prototype.Add = function(Item)
{
if (para_Tab === Item.Type)
return CParagraphContentWithParagraphLikeContent.prototype.Add.call(this, new AscWord.CRunSpace());
else if (Item.Type !== para_Text && Item.Type !== para_Space && (!(Item instanceof AscWord.CRunBreak) || !Item.IsLineBreak() || !this.IsMultiLineForm()))
else if (Item.Type !== para_Text && Item.Type !== para_Space && (!(Item instanceof AscWord.CRunBreak) || !Item.IsLineBreak() || (!this.IsMultiLineForm() && this.IsFixedForm())))
return;
oTextFormRun = this.MakeSingleRunElement(false);
@ -3230,6 +3230,9 @@ CInlineLevelSdt.prototype.ConvertFormToFixed = function(nW, nH)
nH = Math.max(nH, 22 * g_dKoef_pt_to_mm);
}
// Удаляем переносы строк и все лишнее, т.к. изначально конвертим в однострочную форму
this.CorrectSingleLineFormContent();
// Для билдера, чтобы мы могли конвертить форму, даже если она нигде не лежит
if (!oParent)
return this.private_ConvertFormToFixed(nW, nH);