roosterjs 9.4.0 → 9.4.1

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 9.4.0)
1
+ // Type definitions for roosterjs (Version 9.4.1)
2
2
  // Generated by dts tool from roosterjs
3
3
  // Project: https://github.com/Microsoft/roosterjs
4
4
 
@@ -8572,7 +8572,7 @@ var roosterjs_content_model_dom_1 = __webpack_require__(/*! roosterjs-content-mo
8572
8572
  */
8573
8573
  var formatContentModel = function (core, formatter, options, domToModelOptions) {
8574
8574
  var _a;
8575
- var _b = options || {}, apiName = _b.apiName, onNodeCreated = _b.onNodeCreated, getChangeData = _b.getChangeData, changeSource = _b.changeSource, rawEvent = _b.rawEvent, selectionOverride = _b.selectionOverride, scrollCaretIntoView = _b.scrollCaretIntoView;
8575
+ var _b = options || {}, onNodeCreated = _b.onNodeCreated, getChangeData = _b.getChangeData, rawEvent = _b.rawEvent, selectionOverride = _b.selectionOverride, scrollCaretIntoView = _b.scrollCaretIntoView;
8576
8576
  var model = core.api.createContentModel(core, domToModelOptions, selectionOverride);
8577
8577
  var context = {
8578
8578
  newEntities: [],
@@ -8606,9 +8606,9 @@ var formatContentModel = function (core, formatter, options, domToModelOptions)
8606
8606
  eventType: 'contentChanged',
8607
8607
  contentModel: clearModelCache ? undefined : model,
8608
8608
  selection: clearModelCache ? undefined : selection,
8609
- source: changeSource || roosterjs_content_model_dom_1.ChangeSource.Format,
8609
+ source: (options === null || options === void 0 ? void 0 : options.changeSource) || roosterjs_content_model_dom_1.ChangeSource.Format,
8610
8610
  data: getChangeData === null || getChangeData === void 0 ? void 0 : getChangeData(),
8611
- formatApiName: apiName,
8611
+ formatApiName: options === null || options === void 0 ? void 0 : options.apiName,
8612
8612
  changedEntities: getChangedEntities(context, rawEvent),
8613
8613
  };
8614
8614
  core.api.triggerEvent(core, eventData, true /*broadcast*/);
@@ -22189,6 +22189,21 @@ var mutate_1 = __webpack_require__(/*! ../common/mutate */ "./packages/roosterjs
22189
22189
  var normalizeContentModel_1 = __webpack_require__(/*! ../common/normalizeContentModel */ "./packages/roosterjs-content-model-dom/lib/modelApi/common/normalizeContentModel.ts");
22190
22190
  var normalizeTable_1 = __webpack_require__(/*! ./normalizeTable */ "./packages/roosterjs-content-model-dom/lib/modelApi/editing/normalizeTable.ts");
22191
22191
  var HeadingTags = ['h1', 'h2', 'h3', 'h4', 'h5', 'h6'];
22192
+ // An object to provide keys of required properties of segment format, do NOT use any of its values
22193
+ var RequiredEmptySegmentFormat = {
22194
+ backgroundColor: null,
22195
+ fontFamily: null,
22196
+ fontSize: null,
22197
+ fontWeight: null,
22198
+ italic: null,
22199
+ letterSpacing: null,
22200
+ lineHeight: null,
22201
+ strikethrough: null,
22202
+ superOrSubScriptSequence: null,
22203
+ textColor: null,
22204
+ underline: null,
22205
+ };
22206
+ var KeysOfSegmentFormat = (0, getObjectKeys_1.getObjectKeys)(RequiredEmptySegmentFormat);
22192
22207
  /**
22193
22208
  * Merge source model into target mode
22194
22209
  * @param target Target Content Model that will merge content into
@@ -22420,6 +22435,9 @@ function applyDefaultFormat(group, format, applyDefaultFormatOption) {
22420
22435
  applyDefaultFormat(segment, format, applyDefaultFormatOption);
22421
22436
  }
22422
22437
  segment.format = mergeSegmentFormat(applyDefaultFormatOption, format, (0, tslib_1.__assign)((0, tslib_1.__assign)({}, paragraphFormat_1), segment.format));
22438
+ if (segment.link) {
22439
+ segment.link.format = mergeSegmentFormat(applyDefaultFormatOption, getSegmentFormatInLinkFormat(format), segment.link.format);
22440
+ }
22423
22441
  });
22424
22442
  if (applyDefaultFormatOption === 'keepSourceEmphasisFormat') {
22425
22443
  delete paragraph.decorator;
@@ -22433,9 +22451,26 @@ function mergeBlockFormat(applyDefaultFormatOption, block) {
22433
22451
  delete (0, mutate_1.mutateBlock)(block).format.backgroundColor;
22434
22452
  }
22435
22453
  }
22454
+ /**
22455
+ * Hyperlink format type definition only contains textColor, backgroundColor and underline.
22456
+ * So create a minimum object with the styles supported in Hyperlink to be used in merge.
22457
+ */
22458
+ function getSegmentFormatInLinkFormat(targetFormat) {
22459
+ var result = {};
22460
+ if (targetFormat.textColor) {
22461
+ result.textColor = targetFormat.textColor;
22462
+ }
22463
+ if (targetFormat.backgroundColor) {
22464
+ result.backgroundColor = targetFormat.backgroundColor;
22465
+ }
22466
+ if (targetFormat.underline) {
22467
+ result.underline = targetFormat.underline;
22468
+ }
22469
+ return result;
22470
+ }
22436
22471
  function mergeSegmentFormat(applyDefaultFormatOption, targetFormat, sourceFormat) {
22437
22472
  return applyDefaultFormatOption == 'mergeAll'
22438
- ? (0, tslib_1.__assign)((0, tslib_1.__assign)({}, targetFormat), sourceFormat) : (0, tslib_1.__assign)((0, tslib_1.__assign)({}, targetFormat), getSemanticFormat(sourceFormat));
22473
+ ? (0, tslib_1.__assign)((0, tslib_1.__assign)({}, targetFormat), sourceFormat) : (0, tslib_1.__assign)((0, tslib_1.__assign)((0, tslib_1.__assign)({}, getFormatWithoutSegmentFormat(sourceFormat)), targetFormat), getSemanticFormat(sourceFormat));
22439
22474
  }
22440
22475
  function getSemanticFormat(segmentFormat) {
22441
22476
  var result = {};
@@ -22451,6 +22486,15 @@ function getSemanticFormat(segmentFormat) {
22451
22486
  }
22452
22487
  return result;
22453
22488
  }
22489
+ /**
22490
+ * Segment format can also contain other type of metadata, for example in Images/Hyperlink,
22491
+ * we want to preserve these properties when merging format
22492
+ */
22493
+ function getFormatWithoutSegmentFormat(sourceFormat) {
22494
+ var resultFormat = (0, tslib_1.__assign)({}, sourceFormat);
22495
+ KeysOfSegmentFormat.forEach(function (key) { return delete resultFormat[key]; });
22496
+ return resultFormat;
22497
+ }
22454
22498
 
22455
22499
 
22456
22500
  /***/ }),