roosterjs 9.18.0 → 9.19.0

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/rooster.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- // Type definitions for roosterjs (Version 9.18.0)
1
+ // Type definitions for roosterjs (Version 9.19.0)
2
2
  // Generated by dts tool from roosterjs
3
3
  // Project: https://github.com/Microsoft/roosterjs
4
4
 
@@ -81,7 +81,7 @@ type ContentModelBlockFormat = BackgroundColorFormat & DirectionFormat & TextAli
81
81
  /**
82
82
  * Format of table cell
83
83
  */
84
- type ContentModelTableCellFormat = ContentModelBlockFormat & BorderBoxFormat & VerticalAlignFormat & WordBreakFormat & TextColorFormat & SizeFormat;
84
+ type ContentModelTableCellFormat = ContentModelBlockFormat & BorderBoxFormat & VerticalAlignFormat & WordBreakFormat & TextColorFormat & SizeFormat & BoldFormat;
85
85
 
86
86
  /**
87
87
  * The format object for a list item in Content Model
@@ -3553,6 +3553,7 @@ type ExperimentalFeature = /**
3553
3553
  */
3554
3554
  'PersistCache'
3555
3555
  /**
3556
+ * @deprecated
3556
3557
  * Workaround for the Legacy Image Edit
3557
3558
  */
3558
3559
  | 'LegacyImageSelection'
@@ -4596,8 +4597,13 @@ interface FormatContentModelContext {
4596
4597
  * @optional
4597
4598
  * When pass true, skip adding undo snapshot when write Content Model back to DOM.
4598
4599
  * Need to be set by the formatter function
4600
+ * Default value is false, which means add undo snapshot
4601
+ * When set to true, it will skip adding undo snapshot but mark "hasNewContent" so that next undo snapshot will be added, this is same with "MarkNewContent"
4602
+ * When set to 'DoNotSkip', it will add undo snapshot (default behavior)
4603
+ * When set to 'MarkNewContent', it will skip adding undo snapshot but mark "hasNewContent" so that next undo snapshot will be added
4604
+ * When set to 'SkipAll', it will skip adding undo snapshot and not mark "hasNewContent", as if no change is made
4599
4605
  */
4600
- skipUndoSnapshot?: boolean;
4606
+ skipUndoSnapshot?: boolean | 'DoNotSkip' | 'MarkNewContent' | 'SkipAll';
4601
4607
  /**
4602
4608
  * @optional
4603
4609
  * When set to true, formatWithContentModel API will not keep cached Content Model. Next time when we need a Content Model, a new one will be created
@@ -8704,6 +8710,7 @@ class AutoFormatPlugin implements EditorPlugin {
8704
8710
  * @param options An optional parameter that takes in an object of type AutoFormatOptions, which includes the following properties:
8705
8711
  * - autoBullet: A boolean that enables or disables automatic bullet list formatting. Defaults to false.
8706
8712
  * - autoNumbering: A boolean that enables or disables automatic numbering formatting. Defaults to false.
8713
+ * - removeListMargins: A boolean to remove list margins when it is automatically triggered. Defaults to false.
8707
8714
  * - autoHyphen: A boolean that enables or disables automatic hyphen transformation. Defaults to false.
8708
8715
  * - autoFraction: A boolean that enables or disables automatic fraction transformation. Defaults to false.
8709
8716
  * - autoOrdinals: A boolean that enables or disables automatic ordinal number transformation. Defaults to false.
@@ -8766,6 +8773,10 @@ interface AutoFormatOptions extends AutoLinkOptions {
8766
8773
  * Transform ordinal numbers into superscript
8767
8774
  */
8768
8775
  autoOrdinals?: boolean;
8776
+ /**
8777
+ * Remove the margins of auto triggered list
8778
+ */
8779
+ removeListMargins?: boolean;
8769
8780
  }
8770
8781
 
8771
8782
  /**
@@ -9504,6 +9515,9 @@ class ImageEditPlugin implements ImageEditor, EditorPlugin {
9504
9515
  private mouseDownHandler;
9505
9516
  private onDropHandler;
9506
9517
  private keyDownHandler;
9518
+ private setContentHandler;
9519
+ private formatEventHandler;
9520
+ private contentChangedHandler;
9507
9521
  /**
9508
9522
  * EXPOSED FOR TESTING PURPOSE ONLY
9509
9523
  */
package/dist/rooster.js CHANGED
@@ -8944,8 +8944,8 @@ var scrollCaretIntoView_1 = __webpack_require__(/*! ./scrollCaretIntoView */ "./
8944
8944
  * @param options More options, see FormatContentModelOptions
8945
8945
  */
8946
8946
  var formatContentModel = function (core, formatter, options, domToModelOptions) {
8947
- var _a;
8948
- var _b = options || {}, onNodeCreated = _b.onNodeCreated, getChangeData = _b.getChangeData, rawEvent = _b.rawEvent, selectionOverride = _b.selectionOverride, scroll = _b.scrollCaretIntoView;
8947
+ var _a, _b;
8948
+ var _c = options || {}, onNodeCreated = _c.onNodeCreated, rawEvent = _c.rawEvent, selectionOverride = _c.selectionOverride, scroll = _c.scrollCaretIntoView;
8949
8949
  var model = core.api.createContentModel(core, domToModelOptions, selectionOverride);
8950
8950
  var context = {
8951
8951
  newEntities: [],
@@ -8958,7 +8958,8 @@ var formatContentModel = function (core, formatter, options, domToModelOptions)
8958
8958
  var skipUndoSnapshot = context.skipUndoSnapshot, clearModelCache = context.clearModelCache, entityStates = context.entityStates, canUndoByBackspace = context.canUndoByBackspace;
8959
8959
  if (changed) {
8960
8960
  var isNested = core.undo.isNested;
8961
- var shouldAddSnapshot = !skipUndoSnapshot && !isNested;
8961
+ var shouldAddSnapshot = (!skipUndoSnapshot || skipUndoSnapshot == 'DoNotSkip') && !isNested;
8962
+ var shouldMarkNewContent = (skipUndoSnapshot === true || skipUndoSnapshot == 'MarkNewContent') && !isNested;
8962
8963
  var selection = void 0;
8963
8964
  if (shouldAddSnapshot) {
8964
8965
  core.undo.isNested = true;
@@ -8978,7 +8979,7 @@ var formatContentModel = function (core, formatter, options, domToModelOptions)
8978
8979
  contentModel: clearModelCache ? undefined : model,
8979
8980
  selection: clearModelCache ? undefined : selection,
8980
8981
  source: (options === null || options === void 0 ? void 0 : options.changeSource) || roosterjs_content_model_dom_1.ChangeSource.Format,
8981
- data: getChangeData === null || getChangeData === void 0 ? void 0 : getChangeData(),
8982
+ data: (_b = options === null || options === void 0 ? void 0 : options.getChangeData) === null || _b === void 0 ? void 0 : _b.call(options),
8982
8983
  formatApiName: options === null || options === void 0 ? void 0 : options.apiName,
8983
8984
  changedEntities: getChangedEntities(context, rawEvent),
8984
8985
  };
@@ -8992,7 +8993,7 @@ var formatContentModel = function (core, formatter, options, domToModelOptions)
8992
8993
  if (shouldAddSnapshot) {
8993
8994
  core.api.addUndoSnapshot(core, false /*canUndoByBackspace*/, entityStates);
8994
8995
  }
8995
- else {
8996
+ if (shouldMarkNewContent) {
8996
8997
  core.undo.snapshotsManager.hasNewContent = true;
8997
8998
  }
8998
8999
  }
@@ -13026,7 +13027,6 @@ var isSingleImageInSelection_1 = __webpack_require__(/*! ./isSingleImageInSelect
13026
13027
  var normalizePos_1 = __webpack_require__(/*! ./normalizePos */ "./packages/roosterjs-content-model-core/lib/corePlugin/selection/normalizePos.ts");
13027
13028
  var roosterjs_content_model_dom_1 = __webpack_require__(/*! roosterjs-content-model-dom */ "./packages/roosterjs-content-model-dom/lib/index.ts");
13028
13029
  var MouseLeftButton = 0;
13029
- var MouseMiddleButton = 1;
13030
13030
  var MouseRightButton = 2;
13031
13031
  var Up = 'ArrowUp';
13032
13032
  var Down = 'ArrowDown';
@@ -13232,7 +13232,7 @@ var SelectionPlugin = /** @class */ (function () {
13232
13232
  this.onMouseDown(this.editor, event.rawEvent);
13233
13233
  break;
13234
13234
  case 'mouseUp':
13235
- this.onMouseUp(this.editor, event);
13235
+ this.onMouseUp();
13236
13236
  break;
13237
13237
  case 'keyDown':
13238
13238
  this.onKeyDown(this.editor, event.rawEvent);
@@ -13248,40 +13248,25 @@ var SelectionPlugin = /** @class */ (function () {
13248
13248
  }
13249
13249
  };
13250
13250
  SelectionPlugin.prototype.onMouseDown = function (editor, rawEvent) {
13251
- var _a, _b;
13251
+ var _a;
13252
13252
  var selection = editor.getDOMSelection();
13253
13253
  var image;
13254
13254
  // Image selection
13255
- if (editor.isExperimentalFeatureEnabled('LegacyImageSelection')) {
13256
- if (rawEvent.button === MouseRightButton &&
13257
- (image =
13258
- (_a = this.getClickingImage(rawEvent)) !== null && _a !== void 0 ? _a : this.getContainedTargetImage(rawEvent, selection)) &&
13259
- image.isContentEditable) {
13260
- this.selectImageWithRange(image, rawEvent);
13261
- return;
13262
- }
13263
- else if ((selection === null || selection === void 0 ? void 0 : selection.type) == 'image' && selection.image !== rawEvent.target) {
13264
- this.selectBeforeOrAfterElement(editor, selection.image);
13265
- return;
13266
- }
13255
+ if ((selection === null || selection === void 0 ? void 0 : selection.type) == 'image' &&
13256
+ (rawEvent.button == MouseLeftButton ||
13257
+ (rawEvent.button == MouseRightButton &&
13258
+ !this.getClickingImage(rawEvent) &&
13259
+ !this.getContainedTargetImage(rawEvent, selection)))) {
13260
+ this.setDOMSelection(null /*domSelection*/, null /*tableSelection*/);
13267
13261
  }
13268
- else {
13269
- if ((selection === null || selection === void 0 ? void 0 : selection.type) == 'image' &&
13270
- (rawEvent.button == MouseLeftButton ||
13271
- (rawEvent.button == MouseRightButton &&
13272
- !this.getClickingImage(rawEvent) &&
13273
- !this.getContainedTargetImage(rawEvent, selection)))) {
13274
- this.setDOMSelection(null /*domSelection*/, null /*tableSelection*/);
13275
- }
13276
- if ((image =
13277
- (_b = this.getClickingImage(rawEvent)) !== null && _b !== void 0 ? _b : this.getContainedTargetImage(rawEvent, selection)) &&
13278
- image.isContentEditable) {
13279
- this.setDOMSelection({
13280
- type: 'image',
13281
- image: image,
13282
- }, null);
13283
- return;
13284
- }
13262
+ if ((image =
13263
+ (_a = this.getClickingImage(rawEvent)) !== null && _a !== void 0 ? _a : this.getContainedTargetImage(rawEvent, selection)) &&
13264
+ image.isContentEditable) {
13265
+ this.setDOMSelection({
13266
+ type: 'image',
13267
+ image: image,
13268
+ }, null);
13269
+ return;
13285
13270
  }
13286
13271
  // Table selection
13287
13272
  if ((selection === null || selection === void 0 ? void 0 : selection.type) == 'table' && rawEvent.button == MouseLeftButton) {
@@ -13309,33 +13294,7 @@ var SelectionPlugin = /** @class */ (function () {
13309
13294
  });
13310
13295
  }
13311
13296
  };
13312
- SelectionPlugin.prototype.selectImageWithRange = function (image, event) {
13313
- var _a;
13314
- var range = image.ownerDocument.createRange();
13315
- range.selectNode(image);
13316
- var domSelection = (_a = this.editor) === null || _a === void 0 ? void 0 : _a.getDOMSelection();
13317
- if ((domSelection === null || domSelection === void 0 ? void 0 : domSelection.type) == 'image' && image == domSelection.image) {
13318
- event.preventDefault();
13319
- }
13320
- else {
13321
- this.setDOMSelection({
13322
- type: 'range',
13323
- isReverted: false,
13324
- range: range,
13325
- }, null);
13326
- }
13327
- };
13328
- SelectionPlugin.prototype.onMouseUp = function (editor, event) {
13329
- var image;
13330
- if (editor.isExperimentalFeatureEnabled('LegacyImageSelection') &&
13331
- (image = this.getClickingImage(event.rawEvent)) &&
13332
- image.isContentEditable &&
13333
- event.rawEvent.button != MouseMiddleButton &&
13334
- (event.rawEvent.button ==
13335
- MouseRightButton /* it's not possible to drag using right click */ ||
13336
- event.isClicking)) {
13337
- this.selectImageWithRange(image, event.rawEvent);
13338
- }
13297
+ SelectionPlugin.prototype.onMouseUp = function () {
13339
13298
  this.detachMouseEvent();
13340
13299
  };
13341
13300
  SelectionPlugin.prototype.onKeyDown = function (editor, rawEvent) {
@@ -15279,6 +15238,9 @@ exports.defaultContentModelFormatMap = {
15279
15238
  marginTop: '1em',
15280
15239
  marginBottom: '1em',
15281
15240
  },
15241
+ th: {
15242
+ fontWeight: 'bold',
15243
+ },
15282
15244
  };
15283
15245
 
15284
15246
 
@@ -15411,6 +15373,7 @@ exports.defaultHTMLStyleMap = {
15411
15373
  },
15412
15374
  th: {
15413
15375
  display: 'table-cell',
15376
+ fontWeight: 'bold',
15414
15377
  },
15415
15378
  u: {
15416
15379
  textDecoration: 'underline',
@@ -22708,6 +22671,9 @@ function setFirstColumnFormatBorders(rows, format) {
22708
22671
  switch (rowIndex) {
22709
22672
  case 0:
22710
22673
  cell.isHeader = !!format.hasHeaderRow;
22674
+ if (cell.isHeader) {
22675
+ cell.format.fontWeight = 'bold';
22676
+ }
22711
22677
  break;
22712
22678
  case rows.length - 1:
22713
22679
  setBorderColor(cell.format, 'borderTop');
@@ -22735,6 +22701,7 @@ function setHeaderRowFormat(rows, format, metaOverrides) {
22735
22701
  (_a = rows[rowIndex]) === null || _a === void 0 ? void 0 : _a.cells.forEach(function (readonlyCell, cellIndex) {
22736
22702
  var cell = (0, mutate_1.mutateBlock)(readonlyCell);
22737
22703
  cell.isHeader = true;
22704
+ cell.format.fontWeight = 'bold';
22738
22705
  if (format.headerRowColor) {
22739
22706
  if (!metaOverrides.bgColorOverrides[rowIndex][cellIndex]) {
22740
22707
  (0, setTableCellBackgroundColor_1.setTableCellBackgroundColor)(cell, format.headerRowColor, false /*isColorOverride*/, true /*applyToSegments*/);
@@ -26643,6 +26610,7 @@ var updateMetadata_1 = __webpack_require__(/*! ../../modelApi/metadata/updateMet
26643
26610
  var isEmpty_1 = __webpack_require__(/*! ../../modelApi/common/isEmpty */ "./packages/roosterjs-content-model-dom/lib/modelApi/common/isEmpty.ts");
26644
26611
  var moveChildNodes_1 = __webpack_require__(/*! ../../domUtils/moveChildNodes */ "./packages/roosterjs-content-model-dom/lib/domUtils/moveChildNodes.ts");
26645
26612
  var reuseCachedElement_1 = __webpack_require__(/*! ../../domUtils/reuseCachedElement */ "./packages/roosterjs-content-model-dom/lib/domUtils/reuseCachedElement.ts");
26613
+ var stackFormat_1 = __webpack_require__(/*! ../utils/stackFormat */ "./packages/roosterjs-content-model-dom/lib/modelToDom/utils/stackFormat.ts");
26646
26614
  /**
26647
26615
  * @internal
26648
26616
  */
@@ -26688,7 +26656,7 @@ var handleTable = function (doc, parent, table, context, refNode) {
26688
26656
  (0, applyFormat_1.applyFormat)(tr, context.formatAppliers.tableRow, tableRow.format, context);
26689
26657
  }
26690
26658
  (_b = context.onNodeCreated) === null || _b === void 0 ? void 0 : _b.call(context, tableRow, tr);
26691
- for (var col = 0; col < tableRow.cells.length; col++) {
26659
+ var _loop_1 = function (col) {
26692
26660
  var cell = tableRow.cells[col];
26693
26661
  if (cell.isSelected) {
26694
26662
  var tableSelection = context.tableSelection || {
@@ -26706,9 +26674,9 @@ var handleTable = function (doc, parent, table, context, refNode) {
26706
26674
  context.tableSelection = tableSelection;
26707
26675
  }
26708
26676
  if (!cell.spanAbove && !cell.spanLeft) {
26709
- var td = (context.allowCacheElement && cell.cachedElement) ||
26710
- doc.createElement(cell.isHeader ? 'th' : 'td');
26711
- tr.appendChild(td);
26677
+ var tag = cell.isHeader ? 'th' : 'td';
26678
+ var td_1 = (context.allowCacheElement && cell.cachedElement) || doc.createElement(tag);
26679
+ tr.appendChild(td_1);
26712
26680
  var rowSpan = 1;
26713
26681
  var colSpan = 1;
26714
26682
  var width = table.widths[col];
@@ -26720,31 +26688,36 @@ var handleTable = function (doc, parent, table, context, refNode) {
26720
26688
  width += table.widths[col + colSpan];
26721
26689
  }
26722
26690
  if (rowSpan > 1) {
26723
- td.rowSpan = rowSpan;
26691
+ td_1.rowSpan = rowSpan;
26724
26692
  }
26725
26693
  if (colSpan > 1) {
26726
- td.colSpan = colSpan;
26694
+ td_1.colSpan = colSpan;
26727
26695
  }
26728
26696
  if (!cell.cachedElement || (cell.format.useBorderBox && (0, updateMetadata_1.hasMetadata)(table))) {
26729
- if (width > 0 && !td.style.width) {
26730
- td.style.width = width + 'px';
26697
+ if (width > 0 && !td_1.style.width) {
26698
+ td_1.style.width = width + 'px';
26731
26699
  }
26732
- if (height > 0 && !td.style.height) {
26733
- td.style.height = height + 'px';
26700
+ if (height > 0 && !td_1.style.height) {
26701
+ td_1.style.height = height + 'px';
26734
26702
  }
26735
26703
  }
26736
- if (!cell.cachedElement) {
26737
- if (context.allowCacheElement) {
26738
- cell.cachedElement = td;
26704
+ (0, stackFormat_1.stackFormat)(context, tag, function () {
26705
+ if (!cell.cachedElement) {
26706
+ if (context.allowCacheElement) {
26707
+ cell.cachedElement = td_1;
26708
+ }
26709
+ (0, applyFormat_1.applyFormat)(td_1, context.formatAppliers.block, cell.format, context);
26710
+ (0, applyFormat_1.applyFormat)(td_1, context.formatAppliers.tableCell, cell.format, context);
26711
+ (0, applyFormat_1.applyFormat)(td_1, context.formatAppliers.tableCellBorder, cell.format, context);
26712
+ (0, applyFormat_1.applyFormat)(td_1, context.formatAppliers.dataset, cell.dataset, context);
26739
26713
  }
26740
- (0, applyFormat_1.applyFormat)(td, context.formatAppliers.block, cell.format, context);
26741
- (0, applyFormat_1.applyFormat)(td, context.formatAppliers.tableCell, cell.format, context);
26742
- (0, applyFormat_1.applyFormat)(td, context.formatAppliers.tableCellBorder, cell.format, context);
26743
- (0, applyFormat_1.applyFormat)(td, context.formatAppliers.dataset, cell.dataset, context);
26744
- }
26745
- context.modelHandlers.blockGroupChildren(doc, td, cell, context);
26746
- (_f = context.onNodeCreated) === null || _f === void 0 ? void 0 : _f.call(context, cell, td);
26714
+ context.modelHandlers.blockGroupChildren(doc, td_1, cell, context);
26715
+ });
26716
+ (_f = context.onNodeCreated) === null || _f === void 0 ? void 0 : _f.call(context, cell, td_1);
26747
26717
  }
26718
+ };
26719
+ for (var col = 0; col < tableRow.cells.length; col++) {
26720
+ _loop_1(col);
26748
26721
  }
26749
26722
  }
26750
26723
  (_g = context.domIndexer) === null || _g === void 0 ? void 0 : _g.onTable(tableNode, table);
@@ -27192,6 +27165,7 @@ var DefaultOptions = {
27192
27165
  autoHyphen: false,
27193
27166
  autoFraction: false,
27194
27167
  autoOrdinals: false,
27168
+ removeListMargins: false,
27195
27169
  };
27196
27170
  /**
27197
27171
  * Auto Format plugin handles auto formatting, such as transforming * characters into a bullet list.
@@ -27202,6 +27176,7 @@ var AutoFormatPlugin = /** @class */ (function () {
27202
27176
  * @param options An optional parameter that takes in an object of type AutoFormatOptions, which includes the following properties:
27203
27177
  * - autoBullet: A boolean that enables or disables automatic bullet list formatting. Defaults to false.
27204
27178
  * - autoNumbering: A boolean that enables or disables automatic numbering formatting. Defaults to false.
27179
+ * - removeListMargins: A boolean to remove list margins when it is automatically triggered. Defaults to false.
27205
27180
  * - autoHyphen: A boolean that enables or disables automatic hyphen transformation. Defaults to false.
27206
27181
  * - autoFraction: A boolean that enables or disables automatic fraction transformation. Defaults to false.
27207
27182
  * - autoOrdinals: A boolean that enables or disables automatic ordinal number transformation. Defaults to false.
@@ -27272,24 +27247,29 @@ var AutoFormatPlugin = /** @class */ (function () {
27272
27247
  var formatOptions_1 = {
27273
27248
  changeSource: '',
27274
27249
  apiName: '',
27250
+ getChangeData: undefined,
27275
27251
  };
27276
27252
  (0, roosterjs_content_model_api_1.formatTextSegmentBeforeSelectionMarker)(editor, function (model, previousSegment, paragraph, _markerFormat, context) {
27277
- var _a = _this.options, autoBullet = _a.autoBullet, autoNumbering = _a.autoNumbering, autoLink = _a.autoLink, autoHyphen = _a.autoHyphen, autoFraction = _a.autoFraction, autoOrdinals = _a.autoOrdinals, autoMailto = _a.autoMailto, autoTel = _a.autoTel;
27253
+ var _a;
27254
+ var _b = _this.options, autoBullet = _b.autoBullet, autoNumbering = _b.autoNumbering, autoLink = _b.autoLink, autoHyphen = _b.autoHyphen, autoFraction = _b.autoFraction, autoOrdinals = _b.autoOrdinals, autoMailto = _b.autoMailto, autoTel = _b.autoTel, removeListMargins = _b.removeListMargins;
27278
27255
  var shouldHyphen = false;
27279
27256
  var shouldLink = false;
27280
27257
  var shouldList = false;
27281
27258
  var shouldFraction = false;
27282
27259
  var shouldOrdinals = false;
27283
27260
  if (autoBullet || autoNumbering) {
27284
- shouldList = (0, keyboardListTrigger_1.keyboardListTrigger)(model, paragraph, context, autoBullet, autoNumbering);
27261
+ shouldList = (0, keyboardListTrigger_1.keyboardListTrigger)(model, paragraph, context, autoBullet, autoNumbering, removeListMargins);
27285
27262
  }
27286
27263
  if (autoLink || autoTel || autoMailto) {
27287
- shouldLink = !!(0, roosterjs_content_model_api_1.promoteLink)(previousSegment, paragraph, {
27264
+ var linkSegment = (0, roosterjs_content_model_api_1.promoteLink)(previousSegment, paragraph, {
27288
27265
  autoLink: autoLink,
27289
27266
  autoTel: autoTel,
27290
27267
  autoMailto: autoMailto,
27291
27268
  });
27292
- if (shouldLink) {
27269
+ if (linkSegment) {
27270
+ var anchor_1 = createAnchor(((_a = linkSegment.link) === null || _a === void 0 ? void 0 : _a.format.href) || '', linkSegment.text);
27271
+ formatOptions_1.getChangeData = function () { return anchor_1; };
27272
+ shouldLink = true;
27293
27273
  context.canUndoByBackspace = true;
27294
27274
  }
27295
27275
  }
@@ -27327,10 +27307,10 @@ var AutoFormatPlugin = /** @class */ (function () {
27327
27307
  case 'Tab':
27328
27308
  if (!rawEvent.shiftKey) {
27329
27309
  (0, roosterjs_content_model_api_1.formatTextSegmentBeforeSelectionMarker)(editor, function (model, _previousSegment, paragraph, _markerFormat, context) {
27330
- var _a = _this.options, autoBullet = _a.autoBullet, autoNumbering = _a.autoNumbering;
27310
+ var _a = _this.options, autoBullet = _a.autoBullet, autoNumbering = _a.autoNumbering, removeListMargins = _a.removeListMargins;
27331
27311
  var shouldList = false;
27332
27312
  if (autoBullet || autoNumbering) {
27333
- shouldList = (0, keyboardListTrigger_1.keyboardListTrigger)(model, paragraph, context, autoBullet, autoNumbering);
27313
+ shouldList = (0, keyboardListTrigger_1.keyboardListTrigger)(model, paragraph, context, autoBullet, autoNumbering, removeListMargins);
27334
27314
  context.canUndoByBackspace = shouldList;
27335
27315
  }
27336
27316
  if (shouldList) {
@@ -27368,6 +27348,12 @@ var getChangeSource = function (shouldList, shouldHyphen, shouldLink) {
27368
27348
  ? roosterjs_content_model_dom_1.ChangeSource.AutoLink
27369
27349
  : '';
27370
27350
  };
27351
+ var createAnchor = function (url, text) {
27352
+ var anchor = document.createElement('a');
27353
+ anchor.href = url;
27354
+ anchor.textContent = text;
27355
+ return anchor;
27356
+ };
27371
27357
 
27372
27358
 
27373
27359
  /***/ }),
@@ -27840,14 +27826,14 @@ var roosterjs_content_model_api_1 = __webpack_require__(/*! roosterjs-content-mo
27840
27826
  /**
27841
27827
  * @internal
27842
27828
  */
27843
- function keyboardListTrigger(model, paragraph, context, shouldSearchForBullet, shouldSearchForNumbering) {
27829
+ function keyboardListTrigger(model, paragraph, context, shouldSearchForBullet, shouldSearchForNumbering, removeListMargins) {
27844
27830
  if (shouldSearchForBullet === void 0) { shouldSearchForBullet = true; }
27845
27831
  if (shouldSearchForNumbering === void 0) { shouldSearchForNumbering = true; }
27846
27832
  var listStyleType = (0, getListTypeStyle_1.getListTypeStyle)(model, shouldSearchForBullet, shouldSearchForNumbering);
27847
27833
  if (listStyleType) {
27848
27834
  paragraph.segments.splice(0, 1);
27849
27835
  var listType = listStyleType.listType, styleType = listStyleType.styleType, index = listStyleType.index;
27850
- triggerList(model, listType, styleType, index);
27836
+ triggerList(model, listType, styleType, index, removeListMargins);
27851
27837
  context.canUndoByBackspace = true;
27852
27838
  setAnnounceData(model, context);
27853
27839
  return true;
@@ -27855,8 +27841,8 @@ function keyboardListTrigger(model, paragraph, context, shouldSearchForBullet, s
27855
27841
  return false;
27856
27842
  }
27857
27843
  exports.keyboardListTrigger = keyboardListTrigger;
27858
- var triggerList = function (model, listType, styleType, index) {
27859
- (0, roosterjs_content_model_api_1.setListType)(model, listType);
27844
+ var triggerList = function (model, listType, styleType, index, removeListMargins) {
27845
+ (0, roosterjs_content_model_api_1.setListType)(model, listType, removeListMargins);
27860
27846
  var isOrderedList = listType == 'OL';
27861
27847
  if (index && index > 0 && isOrderedList) {
27862
27848
  (0, roosterjs_content_model_api_1.setModelListStartNumber)(model, index);
@@ -29006,8 +28992,8 @@ var handleEnterOnList = function (context) {
29006
28992
  }
29007
28993
  });
29008
28994
  if (listItem.levels.length == 0) {
29009
- var index_1 = findIndex(listParent.blocks, nextBlock.levels.length, listIndex);
29010
- nextBlock.levels[nextBlock.levels.length - 1].format.startNumberOverride = index_1;
28995
+ var nextBlockIndex = findIndex(listParent.blocks, nextBlock.levels.length);
28996
+ nextBlock.levels[nextBlock.levels.length - 1].format.startNumberOverride = nextBlockIndex;
29011
28997
  }
29012
28998
  }
29013
28999
  }
@@ -29051,16 +29037,16 @@ var createNewListLevel = function (listItem) {
29051
29037
  return (0, roosterjs_content_model_dom_1.createListLevel)(level.listType, (0, tslib_1.__assign)((0, tslib_1.__assign)({}, level.format), { startNumberOverride: undefined, displayForDummyItem: undefined }), level.dataset);
29052
29038
  });
29053
29039
  };
29054
- var findIndex = function (blocks, levelLength, index) {
29040
+ var findIndex = function (blocks, levelLength) {
29055
29041
  var counter = 1;
29056
- for (var i = index; i > -1; i--) {
29042
+ for (var i = 0; i < blocks.length; i++) {
29057
29043
  var listItem = blocks[i];
29058
29044
  if ((0, roosterjs_content_model_dom_1.isBlockGroupOfType)(listItem, 'ListItem') &&
29059
29045
  listItem.levels.length === levelLength) {
29060
29046
  counter++;
29061
29047
  }
29062
- else if (!((0, roosterjs_content_model_dom_1.isBlockGroupOfType)(listItem, 'ListItem') &&
29063
- listItem.levels.length == 0)) {
29048
+ else if ((0, roosterjs_content_model_dom_1.isBlockGroupOfType)(listItem, 'ListItem') &&
29049
+ listItem.levels.length == 0) {
29064
29050
  return counter;
29065
29051
  }
29066
29052
  }
@@ -30134,6 +30120,7 @@ var MouseRightButton = 2;
30134
30120
  var DRAG_ID = '_dragging';
30135
30121
  var IMAGE_EDIT_CLASS = 'imageEdit';
30136
30122
  var IMAGE_EDIT_CLASS_CARET = 'imageEditCaretColor';
30123
+ var IMAGE_EDIT_FORMAT_EVENT = 'ImageEditEvent';
30137
30124
  /**
30138
30125
  * ImageEdit plugin handles the following image editing features:
30139
30126
  * - Resize image
@@ -30243,9 +30230,7 @@ var ImageEditPlugin = /** @class */ (function () {
30243
30230
  this.keyDownHandler(this.editor, event);
30244
30231
  break;
30245
30232
  case 'contentChanged':
30246
- if (event.source == roosterjs_content_model_dom_1.ChangeSource.Drop) {
30247
- this.onDropHandler(this.editor);
30248
- }
30233
+ this.contentChangedHandler(this.editor, event);
30249
30234
  break;
30250
30235
  case 'extractContentWithDom':
30251
30236
  this.removeImageEditing(event.clonedRoot);
@@ -30322,6 +30307,32 @@ var ImageEditPlugin = /** @class */ (function () {
30322
30307
  }
30323
30308
  }
30324
30309
  };
30310
+ ImageEditPlugin.prototype.setContentHandler = function (editor) {
30311
+ var selection = editor.getDOMSelection();
30312
+ if ((selection === null || selection === void 0 ? void 0 : selection.type) == 'image' && selection.image.dataset.isEditing && !this.isEditing) {
30313
+ delete selection.image.dataset.isEditing;
30314
+ }
30315
+ };
30316
+ ImageEditPlugin.prototype.formatEventHandler = function (event) {
30317
+ if (this.isEditing && event.formatApiName !== IMAGE_EDIT_FORMAT_EVENT) {
30318
+ this.cleanInfo();
30319
+ this.isEditing = false;
30320
+ this.isCropMode = false;
30321
+ }
30322
+ };
30323
+ ImageEditPlugin.prototype.contentChangedHandler = function (editor, event) {
30324
+ switch (event.source) {
30325
+ case roosterjs_content_model_dom_1.ChangeSource.SetContent:
30326
+ this.setContentHandler(editor);
30327
+ break;
30328
+ case roosterjs_content_model_dom_1.ChangeSource.Format:
30329
+ this.formatEventHandler(event);
30330
+ break;
30331
+ case roosterjs_content_model_dom_1.ChangeSource.Drop:
30332
+ this.onDropHandler(editor);
30333
+ break;
30334
+ }
30335
+ };
30325
30336
  /**
30326
30337
  * EXPOSED FOR TESTING PURPOSE ONLY
30327
30338
  */
@@ -30400,6 +30411,7 @@ var ImageEditPlugin = /** @class */ (function () {
30400
30411
  }
30401
30412
  }
30402
30413
  },
30414
+ apiName: IMAGE_EDIT_FORMAT_EVENT,
30403
30415
  }, {
30404
30416
  tryGetFromCache: true,
30405
30417
  });
@@ -35478,7 +35490,15 @@ function createCellResizer(editor, td, table, isRTL, isHorizontal, onStart, onEn
35478
35490
  var zoomScale = editor.getDOMHelper().calculateZoomScale();
35479
35491
  var div = (0, createElement_1.createElement)(createElementData, document);
35480
35492
  (anchorContainer || document.body).appendChild(div);
35481
- var context = { editor: editor, td: td, table: table, isRTL: isRTL, zoomScale: zoomScale, onStart: onStart };
35493
+ var context = {
35494
+ editor: editor,
35495
+ td: td,
35496
+ table: table,
35497
+ isRTL: isRTL,
35498
+ zoomScale: zoomScale,
35499
+ onStart: onStart,
35500
+ originalWidth: (0, roosterjs_content_model_dom_1.parseValueWithUnit)(table.style.width),
35501
+ };
35482
35502
  var setPosition = isHorizontal ? setHorizontalPosition : setVerticalPosition;
35483
35503
  setPosition(context, div);
35484
35504
  var handler = {
@@ -35599,6 +35619,11 @@ function onDraggingVertical(context, event, initValue, deltaX) {
35599
35619
  tableRow.cells[col].style.width = cmTable.widths[col] + 'px';
35600
35620
  }
35601
35621
  }
35622
+ if (context.originalWidth > 0) {
35623
+ var newWidth = context.originalWidth + change + 'px';
35624
+ mutableTable.format.width = newWidth;
35625
+ table.style.width = newWidth;
35626
+ }
35602
35627
  return true;
35603
35628
  }
35604
35629
  else {