mxcad 1.0.297 → 1.0.298

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/mxcad.d.ts CHANGED
@@ -13977,6 +13977,7 @@ export interface LineInfo {
13977
13977
  };
13978
13978
  horizontalOffset?: number;
13979
13979
  bottomSpacing?: number;
13980
+ isEndLine?: boolean;
13980
13981
  }
13981
13982
  declare class MultilineTextConverter {
13982
13983
  /**
@@ -14164,6 +14165,8 @@ declare class MxCADMTextImp extends PubSub<{
14164
14165
  getTotalContentHeight(): number;
14165
14166
  /** 设置实体类型 */
14166
14167
  setEntityType(type: "custom" | "mtext"): void;
14168
+ /** 获取节点Color颜色 */
14169
+ getColor: (node: MarksStyleText) => McCmColor | undefined;
14167
14170
  }
14168
14171
  declare function convertCadPointToSlatePoint(this: MxCADMText, point: McGePoint3d): {
14169
14172
  path: number[];
package/dist/mxcad.es.js CHANGED
@@ -14368,7 +14368,7 @@ win.McDrawObjectEvent_asciiToUTF8 = function (hexstr) {
14368
14368
  return MxG2312Obj.decodeFromGb2312Imp(hexstr);
14369
14369
  };
14370
14370
 
14371
- const version$1 = "1.0.297";
14371
+ const version$1 = "1.0.298";
14372
14372
 
14373
14373
  var isSharedArrayBuffer = ("SharedArrayBuffer" in window);
14374
14374
  var isCdn = document.currentScript && /unpkg\.com\/mxcad/.test(document.currentScript.src);
@@ -23542,6 +23542,7 @@ function findTextSequences(textNodes) {
23542
23542
  textNodes.forEach(function (node, nodeIndex) {
23543
23543
  if (isText(node)) {
23544
23544
  if (node.type && MxCADMText.elementTextManager.hasText(node.type)) {
23545
+ currentSequence = null;
23545
23546
  sequences.push(createSequence(SequenceType.TextNode, createFragment(node, nodeIndex, 0, node.text.length)));
23546
23547
  return;
23547
23548
  }
@@ -23573,8 +23574,8 @@ function findTextSequences(textNodes) {
23573
23574
  currentPos = sequenceEnd;
23574
23575
  }
23575
23576
  }
23576
- }
23577
- if (isElement(node)) {
23577
+ } else if (isElement(node) && MxCADMText.elementTextManager.has(node.type)) {
23578
+ currentSequence = null;
23578
23579
  sequences.push(createSequence(SequenceType.Element, createFragment(node, nodeIndex, 0, 0)));
23579
23580
  }
23580
23581
  });
@@ -23791,8 +23792,8 @@ function calculateLineBreaks(ent, textNodes, paragraphIndex, options) {
23791
23792
  sequence.fragments.forEach(function (fragment) {
23792
23793
  updateSequence(sequence, fragment);
23793
23794
  });
23794
- updateLineBreakInfo(currentLine, true, sequence.type === SequenceType.Continuous ? BreakType.Word : sequence.isAutoBreak ? BreakType.Word : BreakType.Forced);
23795
23795
  applyCharLevelSpacing();
23796
+ updateLineBreakInfo(currentLine, true, sequence.type === SequenceType.Continuous ? BreakType.Word : sequence.isAutoBreak ? BreakType.Word : BreakType.Forced);
23796
23797
  lines.push(currentLine);
23797
23798
  currentLine = createNewLine(baseHeight, lineHeightRatio);
23798
23799
  currentWidth = 0;
@@ -23821,6 +23822,7 @@ function calculateLineBreaks(ent, textNodes, paragraphIndex, options) {
23821
23822
  if (currentLine.nodes.length > 0) {
23822
23823
  updateLineBreakInfo(currentLine, true, BreakType.Forced);
23823
23824
  applyCharLevelSpacing();
23825
+ currentLine.isEndLine = true;
23824
23826
  lines.push(currentLine);
23825
23827
  }
23826
23828
  return lines;
@@ -23896,8 +23898,8 @@ var combinationMTextContents = function combinationMTextContents(node, text) {
23896
23898
  font = node.font,
23897
23899
  tiltAngle = node.tiltAngle,
23898
23900
  tracking = node.tracking,
23899
- widthFactor = node.widthFactor,
23900
- textPosition = node.textPosition;
23901
+ widthFactor = node.widthFactor;
23902
+ node.textPosition;
23901
23903
  var contents = text;
23902
23904
  var str = "";
23903
23905
  if (font !== void 0 || bold === true || italic === true) {
@@ -23912,11 +23914,6 @@ var combinationMTextContents = function combinationMTextContents(node, text) {
23912
23914
  if (typeof widthFactor === "number") {
23913
23915
  str += "\\W".concat(widthFactor, ";");
23914
23916
  }
23915
- if (textPosition === "superscript") {
23916
- contents = "\\S".concat(contents, "^;");
23917
- } else if (textPosition === "subscript") {
23918
- contents = "\\S^".concat(contents, ";");
23919
- }
23920
23917
  return "{" + str + contents + "}";
23921
23918
  };
23922
23919
  var setFont = function setFont(node, mcText, style) {
@@ -23956,8 +23953,8 @@ var getTextHeight = function getTextHeight(node, baseHeight, ent) {
23956
23953
  var _ref = getTextCalculateData(ent, node) || {
23957
23954
  width: 0
23958
23955
  },
23959
- width = _ref.width;
23960
- return width;
23956
+ height = _ref.height;
23957
+ return height;
23961
23958
  }
23962
23959
  return baseHeight * ((node === null || node === void 0 ? void 0 : node.fontSize) || 1);
23963
23960
  };
@@ -24130,8 +24127,10 @@ function generateNodeFingerprint(node, baseHeight, style) {
24130
24127
  _node$tracking = node.tracking,
24131
24128
  tracking = _node$tracking === void 0 ? 0 : _node$tracking,
24132
24129
  _node$widthFactor = node.widthFactor,
24133
- widthFactor = _node$widthFactor === void 0 ? 0 : _node$widthFactor;
24134
- return "".concat(type, "_").concat(style, "_").concat(font, "_").concat(fontSize, "_").concat(Number(bold), "_").concat(Number(italic), "_").concat(Number(underline), "_").concat(Number(strike), "_").concat(Number(overline), "_").concat(tiltAngle, "_").concat(tracking, "_").concat(widthFactor, "_").concat(baseHeight);
24130
+ widthFactor = _node$widthFactor === void 0 ? 0 : _node$widthFactor,
24131
+ _node$textPosition = node.textPosition,
24132
+ textPosition = _node$textPosition === void 0 ? "" : _node$textPosition;
24133
+ return "".concat(type, "_").concat(textPosition, "_").concat(style, "_").concat(font, "_").concat(fontSize, "_").concat(Number(bold), "_").concat(Number(italic), "_").concat(Number(underline), "_").concat(Number(strike), "_").concat(Number(overline), "_").concat(tiltAngle, "_").concat(tracking, "_").concat(widthFactor, "_").concat(baseHeight);
24135
24134
  }
24136
24135
  function getCachedCharacterWidth(char, fingerprint, node, baseHeight, style, ent) {
24137
24136
  var cache = globalCharacterCache.get(fingerprint);
@@ -24161,7 +24160,11 @@ function getBasicTextWidth(text, node, baseHeight, style, ent, offset) {
24161
24160
  ent: ent
24162
24161
  }),
24163
24162
  width = _getTextNodeBoxInfo.width;
24164
- return width * ((node === null || node === void 0 ? void 0 : node.tracking) || 1) + (offset || 0);
24163
+ var tracking = (node === null || node === void 0 ? void 0 : node.tracking) || 1;
24164
+ if (node.textPosition === "superscript" || node.textPosition === "subscript") {
24165
+ tracking = 0.5;
24166
+ }
24167
+ return width * tracking + (offset || 0);
24165
24168
  }
24166
24169
  function calculateTextWidth(text, node, baseHeight, style, ent, offset) {
24167
24170
  if (text.length === 0) return 0;
@@ -24198,7 +24201,8 @@ function getTextWidth(text, node, baseHeight, style, ent) {
24198
24201
  width = _ref.width;
24199
24202
  return width;
24200
24203
  }
24201
- return calculateTextWidth(text, node, baseHeight, style, ent);
24204
+ var normalWidth = calculateTextWidth(text, node, baseHeight, style, ent);
24205
+ return normalWidth;
24202
24206
  }
24203
24207
 
24204
24208
  function ownKeys$3(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
@@ -24712,6 +24716,7 @@ var renderParagraph = function renderParagraph(ent, draw, props) {
24712
24716
  positionInfo.horizontalOffset += nodeInfo.extraCharSpacing || 0;
24713
24717
  }
24714
24718
  if (isText(nodeInfo.node)) {
24719
+ var isTextPosition = nodeInfo.node.textPosition === "superscript" || nodeInfo.node.textPosition === "subscript";
24715
24720
  if (nodeInfo.node.type && MxCADMText.elementTextManager.hasText(nodeInfo.node.type)) {
24716
24721
  var currentTextWidth = renderMText();
24717
24722
  lineOffset += currentTextWidth;
@@ -24744,89 +24749,200 @@ var renderParagraph = function renderParagraph(ent, draw, props) {
24744
24749
  });
24745
24750
  ents.push.apply(ents, _toConsumableArray(entitys));
24746
24751
  lineOffset += width2 + (nodeInfo.extraCharSpacing || 0);
24747
- } else if (nodeInfo.hasCharLevelSpacing || nodeInfo.node.tracking) {
24752
+ } else if (isTextPosition) {
24748
24753
  var _currentTextWidth = renderMText();
24749
24754
  lineOffset += _currentTextWidth;
24750
24755
  if (!isOneCharacter) positionInfo.horizontalOffset = lineOffset;
24751
24756
  var textContent = nodeInfo.node.text.substring(nodeInfo.startOffset, nodeInfo.endOffset);
24752
- var textHeight = getTextHeight(nodeInfo.node, height, ent);
24753
- positionInfo.verticalOffset -= textHeight;
24754
- for (var i = 0; i < textContent.length; i++) {
24755
- var char = textContent[i];
24756
- var charEntity = createTextEntity({
24757
+ var shouldApplyCharLevelSpacing = (ent.getMTextImp().entityType === "mtext" && !ent.getMTextImp().isEditState ? nodeInfo.hasCharLevelSpacing && line.isEndLine : nodeInfo.hasCharLevelSpacing) || nodeInfo.node.tracking;
24758
+ var newPositionInfo = {
24759
+ basePosition: positionInfo.basePosition.clone(),
24760
+ horizontalOffset: positionInfo.horizontalOffset,
24761
+ verticalOffset: positionInfo.verticalOffset - line.height
24762
+ };
24763
+ var textHeight = getTextHeight(nodeInfo.node, height / 2, ent);
24764
+ if (nodeInfo.node.textPosition === "superscript") {
24765
+ if (line.height > nodeInfo.height) {
24766
+ newPositionInfo.verticalOffset -= line.height - nodeInfo.height;
24767
+ }
24768
+ } else {
24769
+ newPositionInfo.verticalOffset += line.height - textHeight;
24770
+ }
24771
+ if (shouldApplyCharLevelSpacing) {
24772
+ for (var i = 0; i < textContent.length; i++) {
24773
+ var char = textContent[i];
24774
+ var charEntity = createTextEntity({
24775
+ node: nodeInfo.node,
24776
+ text: char,
24777
+ height: height / 2,
24778
+ position: newPositionInfo,
24779
+ style: ent.textStyle,
24780
+ ent: ent
24781
+ });
24782
+ if (!mTextImp.isEditState) {
24783
+ charEntity.transformBy(transformsMatrix);
24784
+ }
24785
+ var baseCharWidth = nodeInfo.width / textContent.length;
24786
+ var extraSpacing = 0;
24787
+ if (nodeInfo.hasCharLevelSpacing) {
24788
+ var isLastNode = line.nodes.indexOf(nodeInfo) === line.nodes.length - 1;
24789
+ var isLastChar = i === textContent.length - 1;
24790
+ if (!(isLastNode && isLastChar)) {
24791
+ extraSpacing = nodeInfo.extraCharSpacing || 0;
24792
+ }
24793
+ }
24794
+ if (nodeInfo.node.tracking) {
24795
+ extraSpacing += nodeInfo.node.tracking * (height / 2);
24796
+ }
24797
+ var charWidth = baseCharWidth + extraSpacing;
24798
+ var charMinPt = charEntity.location.clone();
24799
+ var charMaxPt = charMinPt.clone().addvec(McGeVector3d.kXAxis.clone().mult(charWidth)).addvec(McGeVector3d.kYAxis.clone().negate().mult(textHeight));
24800
+ if (nodeInfo.node.color) {
24801
+ var mcColor = getColor(nodeInfo.node);
24802
+ if (mcColor) {
24803
+ draw.trueColor = mcColor;
24804
+ }
24805
+ }
24806
+ if (nodeInfo.node.underline) {
24807
+ var underline = drawLine$1(draw, new McGePoint3d(charMinPt.x, charMaxPt.y, charMinPt.z), new McGePoint3d(charMaxPt.x, charMaxPt.y, charMinPt.z), !mTextImp.isEditState ? transformsMatrix : void 0);
24808
+ ents.push(underline);
24809
+ }
24810
+ if (nodeInfo.node.strike) {
24811
+ var strikeY = charMinPt.y - textHeight * 0.5;
24812
+ var strike = drawLine$1(draw, new McGePoint3d(charMinPt.x, strikeY, charMinPt.z), new McGePoint3d(charMaxPt.x, strikeY, charMinPt.z), !mTextImp.isEditState ? transformsMatrix : void 0);
24813
+ ents.push(strike);
24814
+ }
24815
+ if (nodeInfo.node.overline) {
24816
+ var overline = drawLine$1(draw, new McGePoint3d(charMinPt.x, charMinPt.y, charMinPt.z), new McGePoint3d(charMaxPt.x, charMinPt.y, charMinPt.z), !mTextImp.isEditState ? transformsMatrix : void 0);
24817
+ ents.push(overline);
24818
+ }
24819
+ draw.drawEntity(charEntity);
24820
+ ents.push(charEntity);
24821
+ draw.trueColor = ent.trueColor;
24822
+ newPositionInfo.horizontalOffset += charWidth;
24823
+ lineOffset += charWidth;
24824
+ }
24825
+ } else {
24826
+ var textEntity = createTextEntity({
24757
24827
  node: nodeInfo.node,
24758
- text: char,
24828
+ text: textContent,
24829
+ height: height / 2,
24830
+ position: newPositionInfo,
24831
+ style: ent.textStyle,
24832
+ ent: ent
24833
+ });
24834
+ if (!mTextImp.isEditState) {
24835
+ textEntity.transformBy(transformsMatrix);
24836
+ }
24837
+ if (nodeInfo.node.color) {
24838
+ var _mcColor = getColor(nodeInfo.node);
24839
+ if (_mcColor) {
24840
+ draw.trueColor = _mcColor;
24841
+ }
24842
+ }
24843
+ draw.drawEntity(textEntity);
24844
+ ents.push(textEntity);
24845
+ var textMinPt = textEntity.location.clone();
24846
+ var textMaxPt = textMinPt.clone().addvec(McGeVector3d.kXAxis.clone().mult(nodeInfo.width)).addvec(McGeVector3d.kYAxis.clone().negate().mult(textHeight));
24847
+ if (nodeInfo.node.underline) {
24848
+ var _underline = drawLine$1(draw, new McGePoint3d(textMinPt.x, textMaxPt.y, textMinPt.z), new McGePoint3d(textMaxPt.x, textMaxPt.y, textMinPt.z), !mTextImp.isEditState ? transformsMatrix : void 0);
24849
+ ents.push(_underline);
24850
+ }
24851
+ if (nodeInfo.node.strike) {
24852
+ var _strikeY = textMinPt.y - textHeight * 0.5;
24853
+ var _strike = drawLine$1(draw, new McGePoint3d(textMinPt.x, _strikeY, textMinPt.z), new McGePoint3d(textMaxPt.x, _strikeY, textMinPt.z), !mTextImp.isEditState ? transformsMatrix : void 0);
24854
+ ents.push(_strike);
24855
+ }
24856
+ if (nodeInfo.node.overline) {
24857
+ var _overline = drawLine$1(draw, new McGePoint3d(textMinPt.x, textMinPt.y, textMinPt.z), new McGePoint3d(textMaxPt.x, textMinPt.y, textMinPt.z), !mTextImp.isEditState ? transformsMatrix : void 0);
24858
+ ents.push(_overline);
24859
+ }
24860
+ draw.trueColor = ent.trueColor;
24861
+ lineOffset += nodeInfo.width + (nodeInfo.extraCharSpacing || 0);
24862
+ }
24863
+ } else if ((ent.getMTextImp().entityType === "mtext" && !ent.getMTextImp().isEditState ? nodeInfo.hasCharLevelSpacing && line.isEndLine : nodeInfo.hasCharLevelSpacing) || nodeInfo.node.tracking) {
24864
+ var _currentTextWidth2 = renderMText();
24865
+ lineOffset += _currentTextWidth2;
24866
+ if (!isOneCharacter) positionInfo.horizontalOffset = lineOffset;
24867
+ var _textContent = nodeInfo.node.text.substring(nodeInfo.startOffset, nodeInfo.endOffset);
24868
+ var _textHeight = getTextHeight(nodeInfo.node, height, ent);
24869
+ positionInfo.verticalOffset -= _textHeight;
24870
+ for (var _i = 0; _i < _textContent.length; _i++) {
24871
+ var _char = _textContent[_i];
24872
+ var _charEntity = createTextEntity({
24873
+ node: nodeInfo.node,
24874
+ text: _char,
24759
24875
  height: height,
24760
24876
  position: positionInfo,
24761
24877
  style: ent.textStyle,
24762
24878
  ent: ent
24763
24879
  });
24764
24880
  if (!mTextImp.isEditState) {
24765
- charEntity.transformBy(transformsMatrix);
24881
+ _charEntity.transformBy(transformsMatrix);
24766
24882
  }
24767
- var baseCharWidth = getTextWidth(char, nodeInfo.node, height, ent.textStyle, ent);
24768
- var extraSpacing = 0;
24883
+ var _baseCharWidth = getTextWidth(_char, nodeInfo.node, height, ent.textStyle, ent);
24884
+ var _extraSpacing = 0;
24769
24885
  if (nodeInfo.hasCharLevelSpacing) {
24770
24886
  if (totalChars === 1) {
24771
- extraSpacing = 0;
24887
+ _extraSpacing = 0;
24772
24888
  } else {
24773
- var isLastNode = line.nodes.indexOf(nodeInfo) === line.nodes.length - 1;
24774
- var isLastChar = i === textContent.length - 1;
24775
- if (!(isLastNode && isLastChar)) {
24776
- extraSpacing = nodeInfo.extraCharSpacing || 0;
24889
+ var _isLastNode = line.nodes.indexOf(nodeInfo) === line.nodes.length - 1;
24890
+ var _isLastChar = _i === _textContent.length - 1;
24891
+ if (!(_isLastNode && _isLastChar)) {
24892
+ _extraSpacing = nodeInfo.extraCharSpacing || 0;
24777
24893
  }
24778
24894
  }
24779
24895
  }
24780
- var charWidth = baseCharWidth + extraSpacing;
24781
- positionInfo.horizontalOffset += charWidth;
24782
- var charMinPt = charEntity.location.clone();
24783
- var charMaxPt = charMinPt.clone().addvec(McGeVector3d.kXAxis.clone().mult(charWidth)).addvec(McGeVector3d.kYAxis.clone().negate().mult(textHeight));
24896
+ var _charWidth = _baseCharWidth + _extraSpacing;
24897
+ positionInfo.horizontalOffset += _charWidth;
24898
+ var _charMinPt = _charEntity.location.clone();
24899
+ var _charMaxPt = _charMinPt.clone().addvec(McGeVector3d.kXAxis.clone().mult(_charWidth)).addvec(McGeVector3d.kYAxis.clone().negate().mult(_textHeight));
24784
24900
  if (nodeInfo.node.color) {
24785
- var mcColor = getColor(nodeInfo.node);
24786
- if (mcColor) {
24787
- draw.trueColor = mcColor;
24901
+ var _mcColor2 = getColor(nodeInfo.node);
24902
+ if (_mcColor2) {
24903
+ draw.trueColor = _mcColor2;
24788
24904
  }
24789
24905
  }
24790
24906
  if (nodeInfo.node.underline) {
24791
- var underline = drawLine$1(draw, new McGePoint3d(charMinPt.x, charMaxPt.y, charMinPt.z), new McGePoint3d(charMaxPt.x, charMaxPt.y, charMinPt.z), !mTextImp.isEditState ? transformsMatrix : void 0);
24792
- ents.push(underline);
24907
+ var _underline2 = drawLine$1(draw, new McGePoint3d(_charMinPt.x, _charMaxPt.y, _charMinPt.z), new McGePoint3d(_charMaxPt.x, _charMaxPt.y, _charMinPt.z), !mTextImp.isEditState ? transformsMatrix : void 0);
24908
+ ents.push(_underline2);
24793
24909
  }
24794
24910
  if (nodeInfo.node.strike) {
24795
- var strikeY = charMinPt.y - textHeight * 0.5;
24796
- var strike = drawLine$1(draw, new McGePoint3d(charMinPt.x, strikeY, charMinPt.z), new McGePoint3d(charMaxPt.x, strikeY, charMinPt.z), !mTextImp.isEditState ? transformsMatrix : void 0);
24797
- ents.push(strike);
24911
+ var _strikeY2 = _charMinPt.y - _textHeight * 0.5;
24912
+ var _strike2 = drawLine$1(draw, new McGePoint3d(_charMinPt.x, _strikeY2, _charMinPt.z), new McGePoint3d(_charMaxPt.x, _strikeY2, _charMinPt.z), !mTextImp.isEditState ? transformsMatrix : void 0);
24913
+ ents.push(_strike2);
24798
24914
  }
24799
24915
  if (nodeInfo.node.overline) {
24800
- var overline = drawLine$1(draw, new McGePoint3d(charMinPt.x, charMinPt.y, charMinPt.z), new McGePoint3d(charMaxPt.x, charMinPt.y, charMinPt.z), !mTextImp.isEditState ? transformsMatrix : void 0);
24801
- ents.push(overline);
24916
+ var _overline2 = drawLine$1(draw, new McGePoint3d(_charMinPt.x, _charMinPt.y, _charMinPt.z), new McGePoint3d(_charMaxPt.x, _charMinPt.y, _charMinPt.z), !mTextImp.isEditState ? transformsMatrix : void 0);
24917
+ ents.push(_overline2);
24802
24918
  }
24803
- draw.drawEntity(charEntity);
24804
- ents.push(charEntity);
24919
+ draw.drawEntity(_charEntity);
24920
+ ents.push(_charEntity);
24805
24921
  draw.trueColor = ent.trueColor;
24806
- lineOffset += charWidth;
24922
+ lineOffset += _charWidth;
24807
24923
  }
24808
24924
  } else {
24809
24925
  nodeSet.add(nodeInfo.node);
24810
- var _textContent = nodeInfo.node.text.substring(nodeInfo.startOffset, nodeInfo.endOffset);
24926
+ var _textContent2 = nodeInfo.node.text.substring(nodeInfo.startOffset, nodeInfo.endOffset);
24811
24927
  if (!nodeMap.has(nodeInfo.node)) {
24812
24928
  positionInfo.verticalOffset -= line.height;
24813
24929
  nodeMap.set(nodeInfo.node, {
24814
24930
  positionInfo: positionInfo,
24815
- text: _textContent,
24931
+ text: _textContent2,
24816
24932
  width: nodeInfo.width,
24817
24933
  lineHeight: line.height
24818
24934
  });
24819
24935
  } else {
24820
24936
  var info = nodeMap.get(nodeInfo.node);
24821
24937
  if (info) {
24822
- info.text += _textContent;
24938
+ info.text += _textContent2;
24823
24939
  info.width += nodeInfo.width;
24824
24940
  }
24825
24941
  }
24826
24942
  }
24827
24943
  } else if (isElement(nodeInfo.node)) {
24828
- var _currentTextWidth2 = renderMText();
24829
- lineOffset += _currentTextWidth2;
24944
+ var _currentTextWidth3 = renderMText();
24945
+ lineOffset += _currentTextWidth3;
24830
24946
  if (!isOneCharacter) positionInfo.horizontalOffset = lineOffset;
24831
24947
  var element = MxCADMText.elementTextManager.get(nodeInfo.node.type);
24832
24948
  var _calculateData = getCalculateData(ent, nodeInfo.node);
@@ -25223,22 +25339,45 @@ var MxCADMTextImp = /*#__PURE__*/function (_PubSub) {
25223
25339
  _defineProperty(_assertThisInitialized$1(_this), "getActualRenderStartPosition", getActualRenderStartPosition);
25224
25340
  _defineProperty(_assertThisInitialized$1(_this), "getLinePosition", getLinePosition);
25225
25341
  _defineProperty(_assertThisInitialized$1(_this), "getTextHeight", getTextHeight);
25342
+ _defineProperty(_assertThisInitialized$1(_this), "getColor", getColor);
25226
25343
  return _this;
25227
25344
  }
25228
25345
  _createClass$1(MxCADMTextImp, [{
25229
25346
  key: "isCustomTextOrElement",
25230
25347
  get: function get() {
25348
+ var _this2 = this;
25231
25349
  if (!this.data || this.data.length === 0) {
25232
25350
  return false;
25233
25351
  }
25234
25352
  var isSome = function isSome(node) {
25235
- if (isText(node) && node.type && MxCADMText.elementTextManager.hasText(node.type)) {
25236
- return true;
25237
- }
25238
- if (isElement(node) && node.type !== "paragraph" && MxCADMText.elementTextManager.has(node.type)) {
25239
- return true;
25353
+ if (isText(node)) {
25354
+ if (node.type && MxCADMText.elementTextManager.hasText(node.type)) return true;
25355
+ if ("tracking" in node && node.tracking !== 1) {
25356
+ return true;
25357
+ }
25358
+ if ("textPosition" in node && (node.textPosition === "superscript" || node.textPosition === "subscript")) {
25359
+ return true;
25360
+ }
25361
+ if ("underline" in node && node.underline) {
25362
+ return true;
25363
+ }
25364
+ if ("strike" in node && node.strike) {
25365
+ return true;
25366
+ }
25367
+ if ("overline" in node && node.overline) {
25368
+ return true;
25369
+ }
25240
25370
  }
25241
25371
  if (isElement(node)) {
25372
+ var isParagraph = function isParagraph(node2) {
25373
+ return node2.type === "paragraph";
25374
+ };
25375
+ if (isParagraph(node)) {
25376
+ if (node.alignment === "distribute") return true;
25377
+ if (typeof node.lineHeightRatio === "number" && node.lineHeightRatio !== _this2.lineHeightRatio) return true;
25378
+ } else if (MxCADMText.elementTextManager.has(node.type)) {
25379
+ return true;
25380
+ }
25242
25381
  return node.children.some(isSome);
25243
25382
  }
25244
25383
  return false;
@@ -26265,16 +26404,16 @@ function convertCadPointToSlatePoint(point) {
26265
26404
  } else {
26266
26405
  _nodeChars = info.endOffset - info.startOffset;
26267
26406
  }
26268
- var _isLastNode2 = index === line.nodes.length - 1;
26269
- var _charsWithSpacing = _isLastNode2 ? Math.max(0, _nodeChars - 1) : _nodeChars;
26407
+ var isLastChar = index === line.nodes.length - 1 && info.endOffset === nodeInfo.endOffset;
26408
+ var _charsWithSpacing = isLastChar ? Math.max(0, _nodeChars - 1) : _nodeChars;
26270
26409
  extraSpacingOffset += info.extraCharSpacing * _charsWithSpacing;
26271
26410
  }
26272
26411
  }
26273
26412
  if (nodeInfo.extraCharSpacing) {
26274
26413
  var _charsBeforeMid = mid - nodeInfo.startOffset;
26275
- var _isLastNode3 = _i3 === line.nodes.length - 1;
26414
+ var _isLastNode2 = _i3 === line.nodes.length - 1;
26276
26415
  var isLastPosition = mid === nodeInfo.endOffset;
26277
- if (_isLastNode3 && isLastPosition) {
26416
+ if (_isLastNode2 && isLastPosition) {
26278
26417
  if (_charsBeforeMid > 0) {
26279
26418
  extraSpacingOffset += nodeInfo.extraCharSpacing * (_charsBeforeMid - 1);
26280
26419
  }
@@ -26290,11 +26429,15 @@ function convertCadPointToSlatePoint(point) {
26290
26429
  if (nextChar) {
26291
26430
  var nextCharWidth = getTextWidth(nextChar, nodeInfo.node, mTextImp.textBaseHeight, _this.textStyle, _this);
26292
26431
  var extraCharSpacing = 0;
26293
- if (isExtraSpacing && nodeInfo.extraCharSpacing && !(_i3 === line.nodes.length - 1 && mid === nodeInfo.endOffset - 1)) {
26294
- extraCharSpacing = nodeInfo.extraCharSpacing;
26432
+ if (isExtraSpacing && nodeInfo.extraCharSpacing) {
26433
+ var _isLastChar = _i3 === line.nodes.length - 1 && mid === nodeInfo.endOffset - 1;
26434
+ if (!_isLastChar) {
26435
+ extraCharSpacing = nodeInfo.extraCharSpacing;
26436
+ }
26295
26437
  }
26296
26438
  var completeCharWidth = nextCharWidth + extraCharSpacing;
26297
- var charCenter = adjustedMeasuredX + completeCharWidth / 2;
26439
+ var charStartX = adjustedMeasuredX;
26440
+ var charCenter = charStartX + completeCharWidth / 2;
26298
26441
  if (x >= charCenter) {
26299
26442
  var diff2 = Math.abs(charCenter - x);
26300
26443
  if (diff2 < minDiff) {
@@ -26303,6 +26446,14 @@ function convertCadPointToSlatePoint(point) {
26303
26446
  }
26304
26447
  left = mid + 1;
26305
26448
  continue;
26449
+ } else {
26450
+ var _diff = Math.abs(charCenter - x);
26451
+ if (_diff < minDiff) {
26452
+ minDiff = _diff;
26453
+ bestOffset = mid;
26454
+ }
26455
+ right = mid - 1;
26456
+ continue;
26306
26457
  }
26307
26458
  }
26308
26459
  }