roosterjs 8.36.0 → 8.37.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.
@@ -1,4 +1,4 @@
1
- // Type definitions for roosterjs (Version 8.36.0)
1
+ // Type definitions for roosterjs (Version 8.37.0)
2
2
  // Generated by dts tool from roosterjs
3
3
  // Project: https://github.com/Microsoft/roosterjs
4
4
 
@@ -1236,8 +1236,9 @@ export class VListChain {
1236
1236
  * If the child inline elements have different styles, it will not modify the styles of the list item
1237
1237
  * @param element the LI Element to set the styles
1238
1238
  * @param styles The styles that should be applied to the element.
1239
+ * @param isCssStyle True means the given styles are CSS style names, false means they are HTML attributes @default true
1239
1240
  */
1240
- export function setListItemStyle(element: HTMLLIElement, styles: string[]): void;
1241
+ export function setListItemStyle(element: HTMLLIElement, styles: string[], isCssStyle?: boolean): void;
1241
1242
 
1242
1243
  /**
1243
1244
  * Get the format info of a table
@@ -1656,6 +1657,35 @@ export function getEntityFromElement(element: HTMLElement): Entity | null;
1656
1657
  */
1657
1658
  export function getEntitySelector(type?: string, id?: string): string;
1658
1659
 
1660
+ /**
1661
+ * Create a placeholder comment node for entity
1662
+ * @param entity The entity to create placeholder from
1663
+ * @returns A placeholder comment node as
1664
+ */
1665
+ export function createEntityPlaceholder(entity: Entity): HTMLElement;
1666
+
1667
+ /**
1668
+ * Move content from a container into a new Document fragment, and try keep entities to be reusable by creating placeholder
1669
+ * for them in the document fragment.
1670
+ * If an entity is directly under root container, the whole entity can be reused and no need to move it at all.
1671
+ * If an entity is not directly under root container, it is still reusable, but it may need some movement.
1672
+ * In any case, entities will be replaced with a placeholder in the target document fragment.
1673
+ * We will use an entity map (the "entities" parameter) to save the map from entity id to its wrapper element.
1674
+ * @param root The root element
1675
+ * @param entities A map from entity id to entity wrapper element
1676
+ * @returns A new document fragment contains all the content and entity placeholders
1677
+ */
1678
+ export function moveContentWithEntityPlaceholders(root: HTMLDivElement, entities: Record<string, HTMLElement>): DocumentFragment;
1679
+
1680
+ /**
1681
+ * Restore HTML content from a document fragment that may contain entity placeholders.
1682
+ * @param source Source document fragment that contains HTML content and entity placeholders
1683
+ * @param target Target container, usually to be editor root container
1684
+ * @param entities A map from entity id to entity wrapper, used for reusing existing DOM structure for entity
1685
+ * @param insertClonedNode When pass true, merge with a cloned copy of the nodes from source fragment rather than the nodes themselves @default false
1686
+ */
1687
+ export function restoreContentWithEntityPlaceholder(source: DocumentFragment, target: HTMLElement, entities: Record<string, HTMLElement> | null, insertClonedNode?: boolean): void;
1688
+
1659
1689
  /**
1660
1690
  * Gets the cached event data by cache key from event object if there is already one.
1661
1691
  * Otherwise, call getter function to create one, and cache it.
@@ -2868,6 +2898,10 @@ export interface LifecyclePluginState {
2868
2898
  * Cached document fragment for original content
2869
2899
  */
2870
2900
  shadowEditFragment: DocumentFragment | null;
2901
+ /**
2902
+ * Cached entity pairs for original content
2903
+ */
2904
+ shadowEditEntities: Record<string, HTMLElement> | null;
2871
2905
  /**
2872
2906
  * Cached selection path for original content
2873
2907
  */
@@ -6228,7 +6228,7 @@ var roosterjs_editor_dom_1 = __webpack_require__(/*! roosterjs-editor-dom */ "./
6228
6228
  */
6229
6229
  var switchShadowEdit = function (core, isOn) {
6230
6230
  var lifecycle = core.lifecycle, contentDiv = core.contentDiv;
6231
- var shadowEditFragment = lifecycle.shadowEditFragment, shadowEditSelectionPath = lifecycle.shadowEditSelectionPath, shadowEditTableSelectionPath = lifecycle.shadowEditTableSelectionPath, shadowEditImageSelectionPath = lifecycle.shadowEditImageSelectionPath;
6231
+ var shadowEditEntities = lifecycle.shadowEditEntities, shadowEditFragment = lifecycle.shadowEditFragment, shadowEditSelectionPath = lifecycle.shadowEditSelectionPath, shadowEditTableSelectionPath = lifecycle.shadowEditTableSelectionPath, shadowEditImageSelectionPath = lifecycle.shadowEditImageSelectionPath;
6232
6232
  var wasInShadowEdit = !!shadowEditFragment;
6233
6233
  var getShadowEditSelectionPath = function (selectionType, shadowEditSelection) {
6234
6234
  return (((shadowEditSelection === null || shadowEditSelection === void 0 ? void 0 : shadowEditSelection.type) == selectionType &&
@@ -6243,10 +6243,9 @@ var switchShadowEdit = function (core, isOn) {
6243
6243
  var range = core.api.getSelectionRange(core, true /*tryGetFromCache*/);
6244
6244
  shadowEditSelectionPath = range && (0, roosterjs_editor_dom_1.getSelectionPath)(contentDiv, range);
6245
6245
  shadowEditTableSelectionPath = getShadowEditSelectionPath(1 /* TableSelection */, selection);
6246
- shadowEditFragment = core.contentDiv.ownerDocument.createDocumentFragment();
6247
6246
  shadowEditImageSelectionPath = getShadowEditSelectionPath(2 /* ImageSelection */, selection);
6248
- (0, roosterjs_editor_dom_1.moveChildNodes)(shadowEditFragment, contentDiv);
6249
- shadowEditFragment.normalize();
6247
+ shadowEditEntities = {};
6248
+ shadowEditFragment = (0, roosterjs_editor_dom_1.moveContentWithEntityPlaceholders)(contentDiv, shadowEditEntities);
6250
6249
  core.api.triggerEvent(core, {
6251
6250
  eventType: 17 /* EnteredShadowEdit */,
6252
6251
  fragment: shadowEditFragment,
@@ -6256,22 +6255,22 @@ var switchShadowEdit = function (core, isOn) {
6256
6255
  lifecycle.shadowEditSelectionPath = shadowEditSelectionPath;
6257
6256
  lifecycle.shadowEditTableSelectionPath = shadowEditTableSelectionPath;
6258
6257
  lifecycle.shadowEditImageSelectionPath = shadowEditImageSelectionPath;
6258
+ lifecycle.shadowEditEntities = shadowEditEntities;
6259
6259
  }
6260
- (0, roosterjs_editor_dom_1.moveChildNodes)(contentDiv);
6261
6260
  if (lifecycle.shadowEditFragment) {
6262
- contentDiv.appendChild(lifecycle.shadowEditFragment.cloneNode(true /*deep*/));
6261
+ (0, roosterjs_editor_dom_1.restoreContentWithEntityPlaceholder)(lifecycle.shadowEditFragment, contentDiv, lifecycle.shadowEditEntities, true /*insertClonedNode*/);
6263
6262
  }
6264
6263
  }
6265
6264
  else {
6266
6265
  lifecycle.shadowEditFragment = null;
6267
6266
  lifecycle.shadowEditSelectionPath = null;
6267
+ lifecycle.shadowEditEntities = null;
6268
6268
  if (wasInShadowEdit) {
6269
6269
  core.api.triggerEvent(core, {
6270
6270
  eventType: 18 /* LeavingShadowEdit */,
6271
6271
  }, false /*broadcast*/);
6272
- (0, roosterjs_editor_dom_1.moveChildNodes)(contentDiv);
6273
6272
  if (shadowEditFragment) {
6274
- contentDiv.appendChild(shadowEditFragment);
6273
+ (0, roosterjs_editor_dom_1.restoreContentWithEntityPlaceholder)(shadowEditFragment, contentDiv, shadowEditEntities);
6275
6274
  }
6276
6275
  core.api.focus(core);
6277
6276
  if (shadowEditSelectionPath) {
@@ -7633,6 +7632,7 @@ var LifecyclePlugin = /** @class */ (function () {
7633
7632
  onExternalContentTransform: (_c = options.onExternalContentTransform) !== null && _c !== void 0 ? _c : null,
7634
7633
  experimentalFeatures: options.experimentalFeatures || [],
7635
7634
  shadowEditFragment: null,
7635
+ shadowEditEntities: null,
7636
7636
  shadowEditSelectionPath: null,
7637
7637
  shadowEditTableSelectionPath: null,
7638
7638
  shadowEditImageSelectionPath: null,
@@ -11274,6 +11274,143 @@ function commitEntity(wrapper, type, isReadonly, id) {
11274
11274
  exports.default = commitEntity;
11275
11275
 
11276
11276
 
11277
+ /***/ }),
11278
+
11279
+ /***/ "./packages/roosterjs-editor-dom/lib/entity/entityPlaceholderUtils.ts":
11280
+ /*!****************************************************************************!*\
11281
+ !*** ./packages/roosterjs-editor-dom/lib/entity/entityPlaceholderUtils.ts ***!
11282
+ \****************************************************************************/
11283
+ /*! no static exports found */
11284
+ /***/ (function(module, exports, __webpack_require__) {
11285
+
11286
+ "use strict";
11287
+
11288
+ Object.defineProperty(exports, "__esModule", { value: true });
11289
+ exports.restoreContentWithEntityPlaceholder = exports.moveContentWithEntityPlaceholders = exports.createEntityPlaceholder = void 0;
11290
+ var getEntityFromElement_1 = __webpack_require__(/*! ./getEntityFromElement */ "./packages/roosterjs-editor-dom/lib/entity/getEntityFromElement.ts");
11291
+ var getEntitySelector_1 = __webpack_require__(/*! ./getEntitySelector */ "./packages/roosterjs-editor-dom/lib/entity/getEntitySelector.ts");
11292
+ var getTagOfNode_1 = __webpack_require__(/*! ../utils/getTagOfNode */ "./packages/roosterjs-editor-dom/lib/utils/getTagOfNode.ts");
11293
+ var safeInstanceOf_1 = __webpack_require__(/*! ../utils/safeInstanceOf */ "./packages/roosterjs-editor-dom/lib/utils/safeInstanceOf.ts");
11294
+ var EntityPlaceHolderTagName = 'ENTITY-PLACEHOLDER';
11295
+ /**
11296
+ * Create a placeholder comment node for entity
11297
+ * @param entity The entity to create placeholder from
11298
+ * @returns A placeholder comment node as
11299
+ */
11300
+ function createEntityPlaceholder(entity) {
11301
+ var placeholder = entity.wrapper.ownerDocument.createElement(EntityPlaceHolderTagName);
11302
+ placeholder.id = entity.id;
11303
+ return placeholder;
11304
+ }
11305
+ exports.createEntityPlaceholder = createEntityPlaceholder;
11306
+ /**
11307
+ * Move content from a container into a new Document fragment, and try keep entities to be reusable by creating placeholder
11308
+ * for them in the document fragment.
11309
+ * If an entity is directly under root container, the whole entity can be reused and no need to move it at all.
11310
+ * If an entity is not directly under root container, it is still reusable, but it may need some movement.
11311
+ * In any case, entities will be replaced with a placeholder in the target document fragment.
11312
+ * We will use an entity map (the "entities" parameter) to save the map from entity id to its wrapper element.
11313
+ * @param root The root element
11314
+ * @param entities A map from entity id to entity wrapper element
11315
+ * @returns A new document fragment contains all the content and entity placeholders
11316
+ */
11317
+ function moveContentWithEntityPlaceholders(root, entities) {
11318
+ var entitySelector = (0, getEntitySelector_1.default)();
11319
+ var fragment = root.ownerDocument.createDocumentFragment();
11320
+ var next = null;
11321
+ var _loop_1 = function (child) {
11322
+ var entity;
11323
+ var nodeToAppend = child;
11324
+ next = child.nextSibling;
11325
+ if ((0, safeInstanceOf_1.default)(child, 'HTMLElement')) {
11326
+ if ((entity = (0, getEntityFromElement_1.default)(child))) {
11327
+ nodeToAppend = getPlaceholder(entity, entities);
11328
+ }
11329
+ else {
11330
+ child.querySelectorAll(entitySelector).forEach(function (wrapper) {
11331
+ var _a;
11332
+ if ((entity = (0, getEntityFromElement_1.default)(wrapper))) {
11333
+ var placeholder = getPlaceholder(entity, entities);
11334
+ (_a = wrapper.parentNode) === null || _a === void 0 ? void 0 : _a.replaceChild(placeholder, wrapper);
11335
+ }
11336
+ });
11337
+ }
11338
+ }
11339
+ fragment.appendChild(nodeToAppend);
11340
+ };
11341
+ for (var child = root.firstChild; child; child = next) {
11342
+ _loop_1(child);
11343
+ }
11344
+ fragment.normalize();
11345
+ return fragment;
11346
+ }
11347
+ exports.moveContentWithEntityPlaceholders = moveContentWithEntityPlaceholders;
11348
+ /**
11349
+ * Restore HTML content from a document fragment that may contain entity placeholders.
11350
+ * @param source Source document fragment that contains HTML content and entity placeholders
11351
+ * @param target Target container, usually to be editor root container
11352
+ * @param entities A map from entity id to entity wrapper, used for reusing existing DOM structure for entity
11353
+ * @param insertClonedNode When pass true, merge with a cloned copy of the nodes from source fragment rather than the nodes themselves @default false
11354
+ */
11355
+ function restoreContentWithEntityPlaceholder(source, target, entities, insertClonedNode) {
11356
+ var anchor = target.firstChild;
11357
+ entities = entities || {};
11358
+ var _loop_2 = function (current) {
11359
+ var wrapper = null;
11360
+ var next = current.nextSibling;
11361
+ var id = tryGetIdFromEntityPlaceholder(current);
11362
+ if (id && (wrapper = entities[current.id])) {
11363
+ anchor = removeUntil(anchor, wrapper);
11364
+ if (anchor) {
11365
+ anchor = anchor.nextSibling;
11366
+ }
11367
+ else {
11368
+ target.appendChild(wrapper);
11369
+ }
11370
+ }
11371
+ else {
11372
+ var nodeToInsert = insertClonedNode ? current.cloneNode(true /*deep*/) : current;
11373
+ target.insertBefore(nodeToInsert, anchor);
11374
+ if ((0, safeInstanceOf_1.default)(nodeToInsert, 'HTMLElement')) {
11375
+ nodeToInsert.querySelectorAll(EntityPlaceHolderTagName).forEach(function (placeholder) {
11376
+ var _a;
11377
+ wrapper = entities[placeholder.id];
11378
+ if (wrapper) {
11379
+ (_a = placeholder.parentNode) === null || _a === void 0 ? void 0 : _a.replaceChild(wrapper, placeholder);
11380
+ }
11381
+ });
11382
+ }
11383
+ }
11384
+ current = next;
11385
+ out_current_1 = current;
11386
+ };
11387
+ var out_current_1;
11388
+ for (var current = source.firstChild; current;) {
11389
+ _loop_2(current);
11390
+ current = out_current_1;
11391
+ }
11392
+ removeUntil(anchor);
11393
+ }
11394
+ exports.restoreContentWithEntityPlaceholder = restoreContentWithEntityPlaceholder;
11395
+ function removeUntil(anchor, nodeToStop) {
11396
+ var _a;
11397
+ while (anchor && (!nodeToStop || anchor != nodeToStop)) {
11398
+ var nodeToRemove = anchor;
11399
+ anchor = anchor.nextSibling;
11400
+ (_a = nodeToRemove.parentNode) === null || _a === void 0 ? void 0 : _a.removeChild(nodeToRemove);
11401
+ }
11402
+ return anchor;
11403
+ }
11404
+ function tryGetIdFromEntityPlaceholder(node) {
11405
+ return (0, getTagOfNode_1.default)(node) == EntityPlaceHolderTagName ? node.id : null;
11406
+ }
11407
+ function getPlaceholder(entity, entities) {
11408
+ var placeholder = createEntityPlaceholder(entity);
11409
+ entities[entity.id] = entity.wrapper;
11410
+ return placeholder;
11411
+ }
11412
+
11413
+
11277
11414
  /***/ }),
11278
11415
 
11279
11416
  /***/ "./packages/roosterjs-editor-dom/lib/entity/getEntityFromElement.ts":
@@ -12325,8 +12462,8 @@ exports.isCssVariable = isCssVariable;
12325
12462
 
12326
12463
  Object.defineProperty(exports, "__esModule", { value: true });
12327
12464
  exports.getIntersectedRect = exports.moveChildNodes = exports.KnownCreateElementData = exports.createElement = exports.matchesSelector = exports.setColor = exports.getInnerHTML = exports.readFile = exports.safeInstanceOf = exports.normalizeRect = exports.splitTextNode = exports.getLastLeafNode = exports.getFirstLeafNode = exports.getPreviousLeafSibling = exports.getNextLeafSibling = exports.wrap = exports.unwrap = exports.splitBalancedNodeRange = exports.splitParentNode = exports.queryElements = exports.matchLink = exports.isVoidHtmlElement = exports.isNodeEmpty = exports.isBlockElement = exports.getTagOfNode = exports.PendableFormatCommandMap = exports.getPendableFormatState = exports.getComputedStyle = exports.getComputedStyles = exports.fromHtml = exports.findClosestElementAncestor = exports.contains = exports.collapseNodes = exports.changeElementTag = exports.applyFormat = exports.getBrowserInfo = exports.Browser = exports.extractClipboardItemsForIE = exports.extractClipboardItems = exports.extractClipboardEvent = exports.applyTextStyle = exports.PartialInlineElement = exports.NodeInlineElement = exports.LinkInlineElement = exports.ImageInlineElement = exports.getInlineElementAtNode = exports.PositionContentSearcher = exports.ContentTraverser = exports.getFirstLastBlockElement = exports.getBlockElementAtNode = void 0;
12328
- exports.setGlobalCssStyles = exports.removeImportantStyleRule = exports.setStyles = exports.getStyles = exports.isCtrlOrMetaPressed = exports.isCharacterValue = exports.isModifierKey = exports.clearEventDataCache = exports.cacheGetEventData = exports.getEntitySelector = exports.getEntityFromElement = exports.commitEntity = exports.chainSanitizerCallback = exports.createDefaultHtmlSanitizerOptions = exports.getInheritableStyles = exports.HtmlSanitizer = exports.canUndoAutoComplete = exports.createSnapshots = exports.moveCurrentSnapsnot = exports.moveCurrentSnapshot = exports.clearProceedingSnapshotsV2 = exports.clearProceedingSnapshots = exports.canMoveCurrentSnapshot = exports.addSnapshotV2 = exports.addSnapshot = exports.addRangeToSelection = exports.setHtmlWithMetadata = exports.setHtmlWithSelectionPath = exports.getHtmlWithSelectionPath = exports.getSelectionPath = exports.isPositionAtBeginningOf = exports.getPositionRect = exports.createRange = exports.Position = exports.mergeBlocksInRegion = exports.getSelectionRangeInRegion = exports.isNodeInRegion = exports.collapseNodesInRegion = exports.getSelectedBlockElementsInRegion = exports.getRegionsFromRange = exports.saveTableCellMetadata = exports.getTableFormatInfo = exports.setListItemStyle = exports.VListChain = exports.createVListFromRegion = exports.VListItem = exports.VList = exports.isWholeTableSelected = exports.VTable = exports.isNodeAfter = void 0;
12329
- exports.toArray = exports.getObjectKeys = exports.arrayPush = exports.removeMetadata = exports.setMetadata = exports.getMetadata = exports.createObjectDefinition = exports.createArrayDefinition = exports.createStringDefinition = exports.createBooleanDefinition = exports.createNumberDefinition = exports.validate = exports.getTextContent = exports.deleteSelectedContent = exports.adjustInsertPosition = exports.removeGlobalCssStyle = void 0;
12465
+ exports.getStyles = exports.isCtrlOrMetaPressed = exports.isCharacterValue = exports.isModifierKey = exports.clearEventDataCache = exports.cacheGetEventData = exports.restoreContentWithEntityPlaceholder = exports.moveContentWithEntityPlaceholders = exports.createEntityPlaceholder = exports.getEntitySelector = exports.getEntityFromElement = exports.commitEntity = exports.chainSanitizerCallback = exports.createDefaultHtmlSanitizerOptions = exports.getInheritableStyles = exports.HtmlSanitizer = exports.canUndoAutoComplete = exports.createSnapshots = exports.moveCurrentSnapsnot = exports.moveCurrentSnapshot = exports.clearProceedingSnapshotsV2 = exports.clearProceedingSnapshots = exports.canMoveCurrentSnapshot = exports.addSnapshotV2 = exports.addSnapshot = exports.addRangeToSelection = exports.setHtmlWithMetadata = exports.setHtmlWithSelectionPath = exports.getHtmlWithSelectionPath = exports.getSelectionPath = exports.isPositionAtBeginningOf = exports.getPositionRect = exports.createRange = exports.Position = exports.mergeBlocksInRegion = exports.getSelectionRangeInRegion = exports.isNodeInRegion = exports.collapseNodesInRegion = exports.getSelectedBlockElementsInRegion = exports.getRegionsFromRange = exports.saveTableCellMetadata = exports.getTableFormatInfo = exports.setListItemStyle = exports.VListChain = exports.createVListFromRegion = exports.VListItem = exports.VList = exports.isWholeTableSelected = exports.VTable = exports.isNodeAfter = void 0;
12466
+ exports.toArray = exports.getObjectKeys = exports.arrayPush = exports.removeMetadata = exports.setMetadata = exports.getMetadata = exports.createObjectDefinition = exports.createArrayDefinition = exports.createStringDefinition = exports.createBooleanDefinition = exports.createNumberDefinition = exports.validate = exports.getTextContent = exports.deleteSelectedContent = exports.adjustInsertPosition = exports.removeGlobalCssStyle = exports.setGlobalCssStyles = exports.removeImportantStyleRule = exports.setStyles = void 0;
12330
12467
  var getBlockElementAtNode_1 = __webpack_require__(/*! ./blockElements/getBlockElementAtNode */ "./packages/roosterjs-editor-dom/lib/blockElements/getBlockElementAtNode.ts");
12331
12468
  Object.defineProperty(exports, "getBlockElementAtNode", { enumerable: true, get: function () { return getBlockElementAtNode_1.default; } });
12332
12469
  var getFirstLastBlockElement_1 = __webpack_require__(/*! ./blockElements/getFirstLastBlockElement */ "./packages/roosterjs-editor-dom/lib/blockElements/getFirstLastBlockElement.ts");
@@ -12498,6 +12635,10 @@ var getEntityFromElement_1 = __webpack_require__(/*! ./entity/getEntityFromEleme
12498
12635
  Object.defineProperty(exports, "getEntityFromElement", { enumerable: true, get: function () { return getEntityFromElement_1.default; } });
12499
12636
  var getEntitySelector_1 = __webpack_require__(/*! ./entity/getEntitySelector */ "./packages/roosterjs-editor-dom/lib/entity/getEntitySelector.ts");
12500
12637
  Object.defineProperty(exports, "getEntitySelector", { enumerable: true, get: function () { return getEntitySelector_1.default; } });
12638
+ var entityPlaceholderUtils_1 = __webpack_require__(/*! ./entity/entityPlaceholderUtils */ "./packages/roosterjs-editor-dom/lib/entity/entityPlaceholderUtils.ts");
12639
+ Object.defineProperty(exports, "createEntityPlaceholder", { enumerable: true, get: function () { return entityPlaceholderUtils_1.createEntityPlaceholder; } });
12640
+ Object.defineProperty(exports, "moveContentWithEntityPlaceholders", { enumerable: true, get: function () { return entityPlaceholderUtils_1.moveContentWithEntityPlaceholders; } });
12641
+ Object.defineProperty(exports, "restoreContentWithEntityPlaceholder", { enumerable: true, get: function () { return entityPlaceholderUtils_1.restoreContentWithEntityPlaceholder; } });
12501
12642
  var cacheGetEventData_1 = __webpack_require__(/*! ./event/cacheGetEventData */ "./packages/roosterjs-editor-dom/lib/event/cacheGetEventData.ts");
12502
12643
  Object.defineProperty(exports, "cacheGetEventData", { enumerable: true, get: function () { return cacheGetEventData_1.default; } });
12503
12644
  var clearEventDataCache_1 = __webpack_require__(/*! ./event/clearEventDataCache */ "./packages/roosterjs-editor-dom/lib/event/clearEventDataCache.ts");
@@ -13920,6 +14061,8 @@ var orderListStyles = [null, 'lower-alpha', 'lower-roman'];
13920
14061
  var unorderedListStyles = ['disc', 'circle', 'square'];
13921
14062
  var MARGIN_BASE = '0in 0in 0in 0.5in';
13922
14063
  var NEGATIVE_MARGIN = '-.25in';
14064
+ var stylesToInherit = ['font-size', 'font-family', 'color'];
14065
+ var attrsToInherit = ['data-ogsc', 'data-ogsb', 'data-ogac', 'data-ogab'];
13923
14066
  /**
13924
14067
  * @internal
13925
14068
  * The definition for the number of BulletListType or NumberingListType
@@ -14118,6 +14261,7 @@ var VListItem = /** @class */ (function () {
14118
14261
  * sure the direct parent of this list matches the list types when writing back.
14119
14262
  */
14120
14263
  VListItem.prototype.writeBack = function (listStack, originalRoot, shouldReuseAllAncestorListElements) {
14264
+ var _this = this;
14121
14265
  var _a;
14122
14266
  if (shouldReuseAllAncestorListElements === void 0) { shouldReuseAllAncestorListElements = false; }
14123
14267
  var nextLevel = 1;
@@ -14176,8 +14320,8 @@ var VListItem = /** @class */ (function () {
14176
14320
  this.node.style.setProperty('display', this.dummy ? 'block' : null);
14177
14321
  // 4. Inherit styles of the child element to the li, so we are able to apply the styles to the ::marker
14178
14322
  if (this.listTypes.length > 1) {
14179
- var stylesToInherit = ['font-size', 'font-family', 'color'];
14180
- (0, setListItemStyle_1.default)(this.node, stylesToInherit);
14323
+ (0, setListItemStyle_1.default)(this.node, stylesToInherit, true /*isCssStyle*/);
14324
+ (0, setListItemStyle_1.default)(this.node, attrsToInherit, false /*isCssStyle*/);
14181
14325
  }
14182
14326
  // 5. If this is not a list item now, need to unwrap the LI node and do proper handling
14183
14327
  if (this.listTypes.length <= 1) {
@@ -14192,7 +14336,7 @@ var VListItem = /** @class */ (function () {
14192
14336
  : undefined;
14193
14337
  var childNodes = isLi ? getChildrenAndUnwrap(this.node) : [this.node];
14194
14338
  if (stylesToApply) {
14195
- for (var i = 0; i < childNodes.length; i++) {
14339
+ var _loop_1 = function (i) {
14196
14340
  if ((0, safeInstanceOf_1.default)(childNodes[i], 'Text')) {
14197
14341
  childNodes[i] = (0, wrap_1.default)(childNodes[i], 'span');
14198
14342
  }
@@ -14200,7 +14344,16 @@ var VListItem = /** @class */ (function () {
14200
14344
  if ((0, safeInstanceOf_1.default)(node, 'HTMLElement')) {
14201
14345
  var styles = __assign(__assign({}, stylesToApply), (0, getStyles_1.default)(node));
14202
14346
  (0, setStyles_1.default)(node, styles);
14347
+ attrsToInherit.forEach(function (attr) {
14348
+ var attrValue = _this.node.getAttribute(attr);
14349
+ if (attrValue) {
14350
+ node.setAttribute(attr, attrValue);
14351
+ }
14352
+ });
14203
14353
  }
14354
+ };
14355
+ for (var i = 0; i < childNodes.length; i++) {
14356
+ _loop_1(i);
14204
14357
  }
14205
14358
  }
14206
14359
  wrapIfNotBlockNode(childNodes, true /*checkFirst*/, true /*checkLast*/);
@@ -14650,18 +14803,17 @@ var bulletListStyle = (_a = {},
14650
14803
  Object.defineProperty(exports, "__esModule", { value: true });
14651
14804
  var ContentTraverser_1 = __webpack_require__(/*! ../contentTraverser/ContentTraverser */ "./packages/roosterjs-editor-dom/lib/contentTraverser/ContentTraverser.ts");
14652
14805
  var findClosestElementAncestor_1 = __webpack_require__(/*! ../utils/findClosestElementAncestor */ "./packages/roosterjs-editor-dom/lib/utils/findClosestElementAncestor.ts");
14653
- var getStyles_1 = __webpack_require__(/*! ../style/getStyles */ "./packages/roosterjs-editor-dom/lib/style/getStyles.ts");
14654
14806
  var safeInstanceOf_1 = __webpack_require__(/*! ../utils/safeInstanceOf */ "./packages/roosterjs-editor-dom/lib/utils/safeInstanceOf.ts");
14655
- var setStyles_1 = __webpack_require__(/*! ../style/setStyles */ "./packages/roosterjs-editor-dom/lib/style/setStyles.ts");
14656
14807
  /**
14657
14808
  * Set the Style of a List Item provided, with the styles that the inline child elements have
14658
14809
  * If the child inline elements have different styles, it will not modify the styles of the list item
14659
14810
  * @param element the LI Element to set the styles
14660
14811
  * @param styles The styles that should be applied to the element.
14812
+ * @param isCssStyle True means the given styles are CSS style names, false means they are HTML attributes @default true
14661
14813
  */
14662
- function setListItemStyle(element, styles) {
14663
- var elementsStyles = getInlineChildElementsStyle(element, styles);
14664
- var stylesToApply = (0, getStyles_1.default)(element);
14814
+ function setListItemStyle(element, styles, isCssStyle) {
14815
+ if (isCssStyle === void 0) { isCssStyle = true; }
14816
+ var elementsStyles = getInlineChildElementsStyle(element, styles, isCssStyle);
14665
14817
  styles.forEach(function (styleName) {
14666
14818
  var styleValues = elementsStyles.map(function (style) {
14667
14819
  return style[styleName] !== undefined ? style[styleName] : '';
@@ -14669,13 +14821,17 @@ function setListItemStyle(element, styles) {
14669
14821
  if (styleValues &&
14670
14822
  (styleValues.length == 1 || new Set(styleValues).size == 1) &&
14671
14823
  styleValues[0]) {
14672
- stylesToApply[styleName] = styleValues[0];
14824
+ if (isCssStyle) {
14825
+ element.style.setProperty(styleName, styleValues[0]);
14826
+ }
14827
+ else {
14828
+ element.setAttribute(styleName, styleValues[0]);
14829
+ }
14673
14830
  }
14674
14831
  });
14675
- (0, setStyles_1.default)(element, stylesToApply);
14676
14832
  }
14677
14833
  exports.default = setListItemStyle;
14678
- function getInlineChildElementsStyle(element, styles) {
14834
+ function getInlineChildElementsStyle(element, styles, isCssStyle) {
14679
14835
  var _a, _b;
14680
14836
  var result = [];
14681
14837
  var contentTraverser = ContentTraverser_1.default.createBodyTraverser(element);
@@ -14685,14 +14841,12 @@ function getInlineChildElementsStyle(element, styles) {
14685
14841
  var currentNode = (currentInlineElement === null || currentInlineElement === void 0 ? void 0 : currentInlineElement.getContainerNode()) || null;
14686
14842
  var currentStyle = null;
14687
14843
  currentNode = currentNode ? (0, findClosestElementAncestor_1.default)(currentNode) : null;
14688
- // we should consider of when it is the single child node of element, the parentNode's style should add
14689
- // such as the "i", "b", "span" node in <li><span><b><i>aa</i></b></span></li>
14690
- while (currentNode &&
14691
- currentNode !== element &&
14692
- (0, safeInstanceOf_1.default)(currentNode, 'HTMLElement') &&
14693
- (result.length == 0 || (((_a = currentNode.textContent) === null || _a === void 0 ? void 0 : _a.trim().length) || 0) > 0)) {
14844
+ var _loop_2 = function () {
14845
+ var element_1 = currentNode;
14694
14846
  styles.forEach(function (styleName) {
14695
- var styleValue = currentNode.style.getPropertyValue(styleName);
14847
+ var styleValue = isCssStyle
14848
+ ? element_1.style.getPropertyValue(styleName)
14849
+ : element_1.getAttribute(styleName);
14696
14850
  if (!currentStyle) {
14697
14851
  currentStyle = {};
14698
14852
  }
@@ -14706,6 +14860,14 @@ function getInlineChildElementsStyle(element, styles) {
14706
14860
  else {
14707
14861
  currentNode = null;
14708
14862
  }
14863
+ };
14864
+ // we should consider of when it is the single child node of element, the parentNode's style should add
14865
+ // such as the "i", "b", "span" node in <li><span><b><i>aa</i></b></span></li>
14866
+ while (currentNode &&
14867
+ currentNode !== element &&
14868
+ (0, safeInstanceOf_1.default)(currentNode, 'HTMLElement') &&
14869
+ (result.length == 0 || (((_a = currentNode.textContent) === null || _a === void 0 ? void 0 : _a.trim().length) || 0) > 0)) {
14870
+ _loop_2();
14709
14871
  }
14710
14872
  if (currentStyle) {
14711
14873
  result.push(currentStyle);
@@ -20736,10 +20898,10 @@ var AutoNumberingList = {
20736
20898
  },
20737
20899
  };
20738
20900
  var getPreviousListItem = function (editor, textRange) {
20739
- var _a;
20740
- var previousNode = (_a = editor
20901
+ var blockElement = editor
20741
20902
  .getBodyTraverser(textRange === null || textRange === void 0 ? void 0 : textRange.startContainer)
20742
- .getPreviousBlockElement()) === null || _a === void 0 ? void 0 : _a.collapseToSingleElement();
20903
+ .getPreviousBlockElement();
20904
+ var previousNode = blockElement === null || blockElement === void 0 ? void 0 : blockElement.getEndNode();
20743
20905
  return (0, roosterjs_editor_dom_1.getTagOfNode)(previousNode) === 'LI' ? previousNode : undefined;
20744
20906
  };
20745
20907
  var getPreviousListType = function (editor, textRange, listType) {
@@ -21859,10 +22021,24 @@ function getAutoNumberingListStyle(textBeforeCursor, previousListChain, previous
21859
22021
  }
21860
22022
  }
21861
22023
  var isDoubleParenthesis = trigger[0] === '(' && trigger[trigger.length - 1] === ')';
21862
- var numberingType = identifyNumberingListType(trigger, isDoubleParenthesis, previousListStyle);
22024
+ var numberingType = isValidNumbering(trigger, isDoubleParenthesis)
22025
+ ? identifyNumberingListType(trigger, isDoubleParenthesis, previousListStyle)
22026
+ : null;
21863
22027
  return numberingType;
21864
22028
  }
21865
22029
  exports.default = getAutoNumberingListStyle;
22030
+ /**
22031
+ * Check if index has only numbers or only letters to avoid sequence of character such 1:1. trigger a list.
22032
+ * @param textBeforeCursor
22033
+ * @param isDoubleParenthesis
22034
+ * @returns
22035
+ */
22036
+ function isValidNumbering(textBeforeCursor, isDoubleParenthesis) {
22037
+ var index = isDoubleParenthesis
22038
+ ? textBeforeCursor.slice(1, -1)
22039
+ : textBeforeCursor.slice(0, -1);
22040
+ return Number(index) || /^[A-Za-z\s]*$/.test(index);
22041
+ }
21866
22042
 
21867
22043
 
21868
22044
  /***/ }),