roosterjs-content-model-dom 0.13.0 → 0.14.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.
Files changed (118) hide show
  1. package/lib/domToModel/context/createDomToModelContext.js +1 -1
  2. package/lib/domToModel/context/createDomToModelContext.js.map +1 -1
  3. package/lib/domToModel/context/defaultProcessors.js +1 -0
  4. package/lib/domToModel/context/defaultProcessors.js.map +1 -1
  5. package/lib/domToModel/processors/entityProcessor.js +1 -8
  6. package/lib/domToModel/processors/entityProcessor.js.map +1 -1
  7. package/lib/domToModel/processors/headingProcessor.js +2 -2
  8. package/lib/domToModel/processors/headingProcessor.js.map +1 -1
  9. package/lib/domToModel/processors/tableProcessor.js +11 -1
  10. package/lib/domToModel/processors/tableProcessor.js.map +1 -1
  11. package/lib/formatHandlers/common/floatFormatHandler.d.ts +6 -0
  12. package/lib/formatHandlers/common/floatFormatHandler.js +20 -0
  13. package/lib/formatHandlers/common/floatFormatHandler.js.map +1 -0
  14. package/lib/formatHandlers/common/verticalAlignFormatHandler.js +3 -0
  15. package/lib/formatHandlers/common/verticalAlignFormatHandler.js.map +1 -1
  16. package/lib/formatHandlers/defaultFormatHandlers.js +14 -1
  17. package/lib/formatHandlers/defaultFormatHandlers.js.map +1 -1
  18. package/lib/formatHandlers/segment/fontSizeFormatHandler.js +51 -1
  19. package/lib/formatHandlers/segment/fontSizeFormatHandler.js.map +1 -1
  20. package/lib/formatHandlers/utils/defaultStyles.js +1 -1
  21. package/lib/formatHandlers/utils/defaultStyles.js.map +1 -1
  22. package/lib/formatHandlers/utils/parseValueWithUnit.d.ts +2 -2
  23. package/lib/formatHandlers/utils/parseValueWithUnit.js +18 -10
  24. package/lib/formatHandlers/utils/parseValueWithUnit.js.map +1 -1
  25. package/lib/modelApi/creators/createEntity.d.ts +3 -3
  26. package/lib/modelApi/creators/createEntity.js +4 -4
  27. package/lib/modelApi/creators/createEntity.js.map +1 -1
  28. package/lib/modelToDom/contentModelToDom.d.ts +1 -1
  29. package/lib/modelToDom/contentModelToDom.js.map +1 -1
  30. package/lib/modelToDom/handlers/handleDivider.js +4 -2
  31. package/lib/modelToDom/handlers/handleDivider.js.map +1 -1
  32. package/lib/modelToDom/handlers/handleEntity.js +7 -1
  33. package/lib/modelToDom/handlers/handleEntity.js.map +1 -1
  34. package/lib/modelToDom/handlers/handleFormatContainer.js +4 -2
  35. package/lib/modelToDom/handlers/handleFormatContainer.js.map +1 -1
  36. package/lib/modelToDom/handlers/handleParagraph.js +4 -2
  37. package/lib/modelToDom/handlers/handleParagraph.js.map +1 -1
  38. package/lib/modelToDom/handlers/handleTable.js +13 -6
  39. package/lib/modelToDom/handlers/handleTable.js.map +1 -1
  40. package/lib-amd/domToModel/context/createDomToModelContext.js +1 -1
  41. package/lib-amd/domToModel/context/createDomToModelContext.js.map +1 -1
  42. package/lib-amd/domToModel/context/defaultProcessors.js +1 -0
  43. package/lib-amd/domToModel/context/defaultProcessors.js.map +1 -1
  44. package/lib-amd/domToModel/processors/entityProcessor.js +1 -8
  45. package/lib-amd/domToModel/processors/entityProcessor.js.map +1 -1
  46. package/lib-amd/domToModel/processors/headingProcessor.js +2 -2
  47. package/lib-amd/domToModel/processors/headingProcessor.js.map +1 -1
  48. package/lib-amd/domToModel/processors/tableProcessor.js +11 -2
  49. package/lib-amd/domToModel/processors/tableProcessor.js.map +1 -1
  50. package/lib-amd/formatHandlers/common/floatFormatHandler.d.ts +6 -0
  51. package/lib-amd/formatHandlers/common/floatFormatHandler.js +22 -0
  52. package/lib-amd/formatHandlers/common/floatFormatHandler.js.map +1 -0
  53. package/lib-amd/formatHandlers/common/verticalAlignFormatHandler.js +3 -0
  54. package/lib-amd/formatHandlers/common/verticalAlignFormatHandler.js.map +1 -1
  55. package/lib-amd/formatHandlers/defaultFormatHandlers.js +14 -2
  56. package/lib-amd/formatHandlers/defaultFormatHandlers.js.map +1 -1
  57. package/lib-amd/formatHandlers/segment/fontSizeFormatHandler.js +51 -2
  58. package/lib-amd/formatHandlers/segment/fontSizeFormatHandler.js.map +1 -1
  59. package/lib-amd/formatHandlers/utils/defaultStyles.js +1 -1
  60. package/lib-amd/formatHandlers/utils/defaultStyles.js.map +1 -1
  61. package/lib-amd/formatHandlers/utils/parseValueWithUnit.d.ts +2 -2
  62. package/lib-amd/formatHandlers/utils/parseValueWithUnit.js +18 -10
  63. package/lib-amd/formatHandlers/utils/parseValueWithUnit.js.map +1 -1
  64. package/lib-amd/modelApi/creators/createEntity.d.ts +3 -3
  65. package/lib-amd/modelApi/creators/createEntity.js +4 -4
  66. package/lib-amd/modelApi/creators/createEntity.js.map +1 -1
  67. package/lib-amd/modelToDom/contentModelToDom.d.ts +1 -1
  68. package/lib-amd/modelToDom/contentModelToDom.js.map +1 -1
  69. package/lib-amd/modelToDom/handlers/handleDivider.js +4 -2
  70. package/lib-amd/modelToDom/handlers/handleDivider.js.map +1 -1
  71. package/lib-amd/modelToDom/handlers/handleEntity.js +7 -1
  72. package/lib-amd/modelToDom/handlers/handleEntity.js.map +1 -1
  73. package/lib-amd/modelToDom/handlers/handleFormatContainer.js +4 -2
  74. package/lib-amd/modelToDom/handlers/handleFormatContainer.js.map +1 -1
  75. package/lib-amd/modelToDom/handlers/handleParagraph.js +4 -2
  76. package/lib-amd/modelToDom/handlers/handleParagraph.js.map +1 -1
  77. package/lib-amd/modelToDom/handlers/handleTable.js +13 -6
  78. package/lib-amd/modelToDom/handlers/handleTable.js.map +1 -1
  79. package/lib-mjs/domToModel/context/createDomToModelContext.js +1 -1
  80. package/lib-mjs/domToModel/context/createDomToModelContext.js.map +1 -1
  81. package/lib-mjs/domToModel/context/defaultProcessors.js +1 -0
  82. package/lib-mjs/domToModel/context/defaultProcessors.js.map +1 -1
  83. package/lib-mjs/domToModel/processors/entityProcessor.js +1 -8
  84. package/lib-mjs/domToModel/processors/entityProcessor.js.map +1 -1
  85. package/lib-mjs/domToModel/processors/headingProcessor.js +2 -2
  86. package/lib-mjs/domToModel/processors/headingProcessor.js.map +1 -1
  87. package/lib-mjs/domToModel/processors/tableProcessor.js +11 -1
  88. package/lib-mjs/domToModel/processors/tableProcessor.js.map +1 -1
  89. package/lib-mjs/formatHandlers/common/floatFormatHandler.d.ts +6 -0
  90. package/lib-mjs/formatHandlers/common/floatFormatHandler.js +17 -0
  91. package/lib-mjs/formatHandlers/common/floatFormatHandler.js.map +1 -0
  92. package/lib-mjs/formatHandlers/common/verticalAlignFormatHandler.js +3 -0
  93. package/lib-mjs/formatHandlers/common/verticalAlignFormatHandler.js.map +1 -1
  94. package/lib-mjs/formatHandlers/defaultFormatHandlers.js +14 -1
  95. package/lib-mjs/formatHandlers/defaultFormatHandlers.js.map +1 -1
  96. package/lib-mjs/formatHandlers/segment/fontSizeFormatHandler.js +51 -1
  97. package/lib-mjs/formatHandlers/segment/fontSizeFormatHandler.js.map +1 -1
  98. package/lib-mjs/formatHandlers/utils/defaultStyles.js +1 -1
  99. package/lib-mjs/formatHandlers/utils/defaultStyles.js.map +1 -1
  100. package/lib-mjs/formatHandlers/utils/parseValueWithUnit.d.ts +2 -2
  101. package/lib-mjs/formatHandlers/utils/parseValueWithUnit.js +18 -10
  102. package/lib-mjs/formatHandlers/utils/parseValueWithUnit.js.map +1 -1
  103. package/lib-mjs/modelApi/creators/createEntity.d.ts +3 -3
  104. package/lib-mjs/modelApi/creators/createEntity.js +4 -4
  105. package/lib-mjs/modelApi/creators/createEntity.js.map +1 -1
  106. package/lib-mjs/modelToDom/contentModelToDom.d.ts +1 -1
  107. package/lib-mjs/modelToDom/contentModelToDom.js.map +1 -1
  108. package/lib-mjs/modelToDom/handlers/handleDivider.js +4 -2
  109. package/lib-mjs/modelToDom/handlers/handleDivider.js.map +1 -1
  110. package/lib-mjs/modelToDom/handlers/handleEntity.js +7 -1
  111. package/lib-mjs/modelToDom/handlers/handleEntity.js.map +1 -1
  112. package/lib-mjs/modelToDom/handlers/handleFormatContainer.js +4 -2
  113. package/lib-mjs/modelToDom/handlers/handleFormatContainer.js.map +1 -1
  114. package/lib-mjs/modelToDom/handlers/handleParagraph.js +4 -2
  115. package/lib-mjs/modelToDom/handlers/handleParagraph.js.map +1 -1
  116. package/lib-mjs/modelToDom/handlers/handleTable.js +13 -6
  117. package/lib-mjs/modelToDom/handlers/handleTable.js.map +1 -1
  118. package/package.json +4 -4
@@ -23,7 +23,7 @@ function createDomToModelContext(editorContext, options, selection) {
23
23
  }, blockDecorator: {
24
24
  format: {},
25
25
  tagName: '',
26
- }, elementProcessors: (0, tslib_1.__assign)((0, tslib_1.__assign)({}, defaultProcessors_1.defaultProcessorMap), ((options === null || options === void 0 ? void 0 : options.processorOverride) || {})), defaultStyles: (0, tslib_1.__assign)((0, tslib_1.__assign)({}, defaultStyles_1.defaultStyleMap), ((options === null || options === void 0 ? void 0 : options.defaultStyleOverride) || {})), formatParsers: (0, defaultFormatHandlers_1.getFormatParsers)(options === null || options === void 0 ? void 0 : options.formatParserOverride, options === null || options === void 0 ? void 0 : options.additionalFormatParsers), defaultElementProcessors: defaultProcessors_1.defaultProcessorMap, defaultFormatParsers: defaultFormatHandlers_1.defaultFormatParsers, allowCacheElement: !(options === null || options === void 0 ? void 0 : options.disableCacheElement) });
26
+ }, elementProcessors: (0, tslib_1.__assign)((0, tslib_1.__assign)({}, defaultProcessors_1.defaultProcessorMap), ((options === null || options === void 0 ? void 0 : options.processorOverride) || {})), defaultStyles: (0, tslib_1.__assign)((0, tslib_1.__assign)({}, defaultStyles_1.defaultStyleMap), ((options === null || options === void 0 ? void 0 : options.defaultStyleOverride) || {})), formatParsers: (0, defaultFormatHandlers_1.getFormatParsers)(options === null || options === void 0 ? void 0 : options.formatParserOverride, options === null || options === void 0 ? void 0 : options.additionalFormatParsers), defaultElementProcessors: defaultProcessors_1.defaultProcessorMap, defaultFormatParsers: defaultFormatHandlers_1.defaultFormatParsers });
27
27
  if (editorContext === null || editorContext === void 0 ? void 0 : editorContext.isRootRtl) {
28
28
  context.blockFormat.direction = 'rtl';
29
29
  }
@@ -1 +1 @@
1
- {"version":3,"file":"createDomToModelContext.js","sourceRoot":"","sources":["../../../../../packages-content-model/roosterjs-content-model-dom/lib/domToModel/context/createDomToModelContext.ts"],"names":[],"mappings":";;;;AAAA,oFAAoG;AACpG,yDAA0D;AAC1D,0EAA2E;AAI3E;;;;;GAKG;AACH,SAAgB,uBAAuB,CACnC,aAA6B,EAC7B,OAA0B,EAC1B,SAA4B;IAE5B,IAAM,OAAO,mDACN,aAAa,KAEhB,WAAW,EAAE,EAAE,EACf,aAAa,EAAE,EAAE,EACjB,aAAa,EAAE,KAAK,EAEpB,UAAU,EAAE;YACR,MAAM,EAAE,EAAE;YACV,gBAAgB,EAAE,EAAE;SACvB,EACD,IAAI,EAAE;YACF,MAAM,EAAE,EAAE;YACV,OAAO,EAAE,EAAE;SACd,EACD,IAAI,EAAE;YACF,MAAM,EAAE,EAAE;SACb,EACD,cAAc,EAAE;YACZ,MAAM,EAAE,EAAE;YACV,OAAO,EAAE,EAAE;SACd,EAED,iBAAiB,kDACV,uCAAmB,GACnB,CAAC,CAAA,OAAO,aAAP,OAAO,uBAAP,OAAO,CAAE,iBAAiB,KAAI,EAAE,CAAC,GAGzC,aAAa,kDACN,+BAAe,GACf,CAAC,CAAA,OAAO,aAAP,OAAO,uBAAP,OAAO,CAAE,oBAAoB,KAAI,EAAE,CAAC,GAG5C,aAAa,EAAE,IAAA,wCAAgB,EAC3B,OAAO,aAAP,OAAO,uBAAP,OAAO,CAAE,oBAAoB,EAC7B,OAAO,aAAP,OAAO,uBAAP,OAAO,CAAE,uBAAuB,CACnC,EAED,wBAAwB,EAAE,uCAAmB,EAC7C,oBAAoB,EAAE,4CAAoB,EAC1C,iBAAiB,EAAE,CAAC,CAAA,OAAO,aAAP,OAAO,uBAAP,OAAO,CAAE,mBAAmB,CAAA,GACnD,CAAC;IAEF,IAAI,aAAa,aAAb,aAAa,uBAAb,aAAa,CAAE,SAAS,EAAE;QAC1B,OAAO,CAAC,WAAW,CAAC,SAAS,GAAG,KAAK,CAAC;KACzC;IAED,IAAI,SAAS,EAAE;QACX,OAAO,CAAC,OAAO,GAAG,SAAS,CAAC;KAC/B;IAED,OAAO,OAAO,CAAC;AACnB,CAAC;AAzDD,0DAyDC","sourcesContent":["import { defaultFormatParsers, getFormatParsers } from '../../formatHandlers/defaultFormatHandlers';\nimport { defaultProcessorMap } from './defaultProcessors';\nimport { defaultStyleMap } from '../../formatHandlers/utils/defaultStyles';\nimport { DomToModelContext, DomToModelOption, EditorContext } from 'roosterjs-content-model-types';\nimport { SelectionRangeEx } from 'roosterjs-editor-types';\n\n/**\n * Create context object form DOM to Content Model conversion\n * @param editorContext Context of editor\n * @param options Options for this context\n * @param selection Selection that already exists in content\n */\nexport function createDomToModelContext(\n editorContext?: EditorContext,\n options?: DomToModelOption,\n selection?: SelectionRangeEx\n): DomToModelContext {\n const context: DomToModelContext = {\n ...editorContext,\n\n blockFormat: {},\n segmentFormat: {},\n isInSelection: false,\n\n listFormat: {\n levels: [],\n threadItemCounts: [],\n },\n link: {\n format: {},\n dataset: {},\n },\n code: {\n format: {},\n },\n blockDecorator: {\n format: {},\n tagName: '',\n },\n\n elementProcessors: {\n ...defaultProcessorMap,\n ...(options?.processorOverride || {}),\n },\n\n defaultStyles: {\n ...defaultStyleMap,\n ...(options?.defaultStyleOverride || {}),\n },\n\n formatParsers: getFormatParsers(\n options?.formatParserOverride,\n options?.additionalFormatParsers\n ),\n\n defaultElementProcessors: defaultProcessorMap,\n defaultFormatParsers: defaultFormatParsers,\n allowCacheElement: !options?.disableCacheElement,\n };\n\n if (editorContext?.isRootRtl) {\n context.blockFormat.direction = 'rtl';\n }\n\n if (selection) {\n context.rangeEx = selection;\n }\n\n return context;\n}\n"]}
1
+ {"version":3,"file":"createDomToModelContext.js","sourceRoot":"","sources":["../../../../../packages-content-model/roosterjs-content-model-dom/lib/domToModel/context/createDomToModelContext.ts"],"names":[],"mappings":";;;;AAAA,oFAAoG;AACpG,yDAA0D;AAC1D,0EAA2E;AAI3E;;;;;GAKG;AACH,SAAgB,uBAAuB,CACnC,aAA6B,EAC7B,OAA0B,EAC1B,SAA4B;IAE5B,IAAM,OAAO,mDACN,aAAa,KAEhB,WAAW,EAAE,EAAE,EACf,aAAa,EAAE,EAAE,EACjB,aAAa,EAAE,KAAK,EAEpB,UAAU,EAAE;YACR,MAAM,EAAE,EAAE;YACV,gBAAgB,EAAE,EAAE;SACvB,EACD,IAAI,EAAE;YACF,MAAM,EAAE,EAAE;YACV,OAAO,EAAE,EAAE;SACd,EACD,IAAI,EAAE;YACF,MAAM,EAAE,EAAE;SACb,EACD,cAAc,EAAE;YACZ,MAAM,EAAE,EAAE;YACV,OAAO,EAAE,EAAE;SACd,EAED,iBAAiB,kDACV,uCAAmB,GACnB,CAAC,CAAA,OAAO,aAAP,OAAO,uBAAP,OAAO,CAAE,iBAAiB,KAAI,EAAE,CAAC,GAGzC,aAAa,kDACN,+BAAe,GACf,CAAC,CAAA,OAAO,aAAP,OAAO,uBAAP,OAAO,CAAE,oBAAoB,KAAI,EAAE,CAAC,GAG5C,aAAa,EAAE,IAAA,wCAAgB,EAC3B,OAAO,aAAP,OAAO,uBAAP,OAAO,CAAE,oBAAoB,EAC7B,OAAO,aAAP,OAAO,uBAAP,OAAO,CAAE,uBAAuB,CACnC,EAED,wBAAwB,EAAE,uCAAmB,EAC7C,oBAAoB,EAAE,4CAAoB,GAC7C,CAAC;IAEF,IAAI,aAAa,aAAb,aAAa,uBAAb,aAAa,CAAE,SAAS,EAAE;QAC1B,OAAO,CAAC,WAAW,CAAC,SAAS,GAAG,KAAK,CAAC;KACzC;IAED,IAAI,SAAS,EAAE;QACX,OAAO,CAAC,OAAO,GAAG,SAAS,CAAC;KAC/B;IAED,OAAO,OAAO,CAAC;AACnB,CAAC;AAxDD,0DAwDC","sourcesContent":["import { defaultFormatParsers, getFormatParsers } from '../../formatHandlers/defaultFormatHandlers';\nimport { defaultProcessorMap } from './defaultProcessors';\nimport { defaultStyleMap } from '../../formatHandlers/utils/defaultStyles';\nimport { DomToModelContext, DomToModelOption, EditorContext } from 'roosterjs-content-model-types';\nimport { SelectionRangeEx } from 'roosterjs-editor-types';\n\n/**\n * Create context object form DOM to Content Model conversion\n * @param editorContext Context of editor\n * @param options Options for this context\n * @param selection Selection that already exists in content\n */\nexport function createDomToModelContext(\n editorContext?: EditorContext,\n options?: DomToModelOption,\n selection?: SelectionRangeEx\n): DomToModelContext {\n const context: DomToModelContext = {\n ...editorContext,\n\n blockFormat: {},\n segmentFormat: {},\n isInSelection: false,\n\n listFormat: {\n levels: [],\n threadItemCounts: [],\n },\n link: {\n format: {},\n dataset: {},\n },\n code: {\n format: {},\n },\n blockDecorator: {\n format: {},\n tagName: '',\n },\n\n elementProcessors: {\n ...defaultProcessorMap,\n ...(options?.processorOverride || {}),\n },\n\n defaultStyles: {\n ...defaultStyleMap,\n ...(options?.defaultStyleOverride || {}),\n },\n\n formatParsers: getFormatParsers(\n options?.formatParserOverride,\n options?.additionalFormatParsers\n ),\n\n defaultElementProcessors: defaultProcessorMap,\n defaultFormatParsers: defaultFormatParsers,\n };\n\n if (editorContext?.isRootRtl) {\n context.blockFormat.direction = 'rtl';\n }\n\n if (selection) {\n context.rangeEx = selection;\n }\n\n return context;\n}\n"]}
@@ -46,6 +46,7 @@ exports.defaultProcessorMap = {
46
46
  p: pProcessor_1.pProcessor,
47
47
  pre: formatContainerProcessor_1.formatContainerProcessor,
48
48
  s: knownElementProcessor_1.knownElementProcessor,
49
+ section: knownElementProcessor_1.knownElementProcessor,
49
50
  span: knownElementProcessor_1.knownElementProcessor,
50
51
  strike: knownElementProcessor_1.knownElementProcessor,
51
52
  strong: knownElementProcessor_1.knownElementProcessor,
@@ -1 +1 @@
1
- {"version":3,"file":"defaultProcessors.js","sourceRoot":"","sources":["../../../../../packages-content-model/roosterjs-content-model-dom/lib/domToModel/context/defaultProcessors.ts"],"names":[],"mappings":";;;AAAA,yDAAwD;AACxD,+DAA8D;AAC9D,6DAA4D;AAC5D,uE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ent":["import { brProcessor } from '../processors/brProcessor';\nimport { childProcessor } from '../processors/childProcessor';\nimport { codeProcessor } from '../processors/codeProcessor';\nimport { delimiterProcessor } from '../processors/delimiterProcessor';\nimport { elementProcessor } from '../processors/elementProcessor';\nimport { ElementProcessorMap } from 'roosterjs-content-model-types';\nimport { entityProcessor } from '../processors/entityProcessor';\nimport { fontProcessor } from '../processors/fontProcessor';\nimport { formatContainerProcessor } from '../processors/formatContainerProcessor';\nimport { generalProcessor } from '../processors/generalProcessor';\nimport { headingProcessor } from '../processors/headingProcessor';\nimport { hrProcessor } from '../processors/hrProcessor';\nimport { imageProcessor } from '../processors/imageProcessor';\nimport { knownElementProcessor } from '../processors/knownElementProcessor';\nimport { linkProcessor } from '../processors/linkProcessor';\nimport { listItemProcessor } from '../processors/listItemProcessor';\nimport { listProcessor } from '../processors/listProcessor';\nimport { pProcessor } from '../processors/pProcessor';\nimport { tableProcessor } from '../processors/tableProcessor';\nimport { textProcessor } from '../processors/textProcessor';\n\n/**\n * @internal\n */\nexport const defaultProcessorMap: ElementProcessorMap = {\n a: linkProcessor,\n b: knownElementProcessor,\n blockquote: knownElementProcessor,\n br: brProcessor,\n code: codeProcessor,\n div: knownElementProcessor,\n em: knownElementProcessor,\n font: fontProcessor,\n i: knownElementProcessor,\n img: imageProcessor,\n h1: headingProcessor,\n h2: headingProcessor,\n h3: headingProcessor,\n h4: headingProcessor,\n h5: headingProcessor,\n h6: headingProcessor,\n hr: hrProcessor,\n li: listItemProcessor,\n ol: listProcessor,\n p: pProcessor,\n pre: formatContainerProcessor,\n s: knownElementProcessor,\n span: knownElementProcessor,\n strike: knownElementProcessor,\n strong: knownElementProcessor,\n sub: knownElementProcessor,\n sup: knownElementProcessor,\n table: tableProcessor,\n u: knownElementProcessor,\n ul: listProcessor,\n\n '*': generalProcessor,\n '#text': textProcessor,\n element: elementProcessor,\n entity: entityProcessor,\n child: childProcessor,\n delimiter: delimiterProcessor,\n};\n"]}
1
+ {"version":3,"file":"defaultProcessors.js","sourceRoot":"","sources":["../../../../../packages-content-model/roosterjs-content-model-dom/lib/domToModel/context/defaultProcessors.ts"],"names":[],"mappings":";;;AAAA,yDAAwD;AACxD,+DAA8D;AAC9D,6DAA4D;AAC5D,uEAAsE;AACtE,mEAAkE;AAElE,iEAAgE;AAChE,6DAA4D;AAC5D,mFAAkF;AAClF,mEAAkE;AAClE,mEAAkE;AAClE,yDAAwD;AACxD,+DAA8D;AAC9D,6EAA4E;AAC5E,6DAA4D;AAC5D,qEAAoE;AACpE,6DAA4D;AAC5D,uDAAsD;AACtD,+DAA8D;AAC9D,6DAA4D;AAE5D;;GAEG;AACU,QAAA,mBAAmB,GAAwB;IACpD,CAAC,EAAE,6BAAa;IAChB,CAAC,EAAE,6CAAqB;IACxB,UAAU,EAAE,6CAAqB;IACjC,EAAE,EAAE,yBAAW;IACf,IAAI,EAAE,6BAAa;IACnB,GAAG,EAAE,6CAAqB;IAC1B,EAAE,EAAE,6CAAqB;IACzB,IAAI,EAAE,6BAAa;IACnB,CAAC,EAAE,6CAAqB;IACxB,GAAG,EAAE,+BAAc;IACnB,EAAE,EAAE,mCAAgB;IACpB,EAAE,EAAE,mCAAgB;IACpB,EAAE,EAAE,mCAAgB;IACpB,EAAE,EAAE,mCAAgB;IACpB,EAAE,EAAE,mCAAgB;IACpB,EAAE,EAAE,mCAAgB;IACpB,EAAE,EAAE,yBAAW;IACf,EAAE,EAAE,qCAAiB;IACrB,EAAE,EAAE,6BAAa;IACjB,CAAC,EAAE,uBAAU;IACb,GAAG,EAAE,mDAAwB;IAC7B,CAAC,EAAE,6CAAqB;IACxB,OAAO,EAAE,6CAAqB;IAC9B,IAAI,EAAE,6CAAqB;IAC3B,MAAM,EAAE,6CAAqB;IAC7B,MAAM,EAAE,6CAAqB;IAC7B,GAAG,EAAE,6CAAqB;IAC1B,GAAG,EAAE,6CAAqB;IAC1B,KAAK,EAAE,+BAAc;IACrB,CAAC,EAAE,6CAAqB;IACxB,EAAE,EAAE,6BAAa;IAEjB,GAAG,EAAE,mCAAgB;IACrB,OAAO,EAAE,6BAAa;IACtB,OAAO,EAAE,mCAAgB;IACzB,MAAM,EAAE,iCAAe;IACvB,KAAK,EAAE,+BAAc;IACrB,SAAS,EAAE,uCAAkB;CAChC,CAAC","sourcesContent":["import { brProcessor } from '../processors/brProcessor';\nimport { childProcessor } from '../processors/childProcessor';\nimport { codeProcessor } from '../processors/codeProcessor';\nimport { delimiterProcessor } from '../processors/delimiterProcessor';\nimport { elementProcessor } from '../processors/elementProcessor';\nimport { ElementProcessorMap } from 'roosterjs-content-model-types';\nimport { entityProcessor } from '../processors/entityProcessor';\nimport { fontProcessor } from '../processors/fontProcessor';\nimport { formatContainerProcessor } from '../processors/formatContainerProcessor';\nimport { generalProcessor } from '../processors/generalProcessor';\nimport { headingProcessor } from '../processors/headingProcessor';\nimport { hrProcessor } from '../processors/hrProcessor';\nimport { imageProcessor } from '../processors/imageProcessor';\nimport { knownElementProcessor } from '../processors/knownElementProcessor';\nimport { linkProcessor } from '../processors/linkProcessor';\nimport { listItemProcessor } from '../processors/listItemProcessor';\nimport { listProcessor } from '../processors/listProcessor';\nimport { pProcessor } from '../processors/pProcessor';\nimport { tableProcessor } from '../processors/tableProcessor';\nimport { textProcessor } from '../processors/textProcessor';\n\n/**\n * @internal\n */\nexport const defaultProcessorMap: ElementProcessorMap = {\n a: linkProcessor,\n b: knownElementProcessor,\n blockquote: knownElementProcessor,\n br: brProcessor,\n code: codeProcessor,\n div: knownElementProcessor,\n em: knownElementProcessor,\n font: fontProcessor,\n i: knownElementProcessor,\n img: imageProcessor,\n h1: headingProcessor,\n h2: headingProcessor,\n h3: headingProcessor,\n h4: headingProcessor,\n h5: headingProcessor,\n h6: headingProcessor,\n hr: hrProcessor,\n li: listItemProcessor,\n ol: listProcessor,\n p: pProcessor,\n pre: formatContainerProcessor,\n s: knownElementProcessor,\n section: knownElementProcessor,\n span: knownElementProcessor,\n strike: knownElementProcessor,\n strong: knownElementProcessor,\n sub: knownElementProcessor,\n sup: knownElementProcessor,\n table: tableProcessor,\n u: knownElementProcessor,\n ul: listProcessor,\n\n '*': generalProcessor,\n '#text': textProcessor,\n element: elementProcessor,\n entity: entityProcessor,\n child: childProcessor,\n delimiter: delimiterProcessor,\n};\n"]}
@@ -19,14 +19,7 @@ var entityProcessor = function (group, element, context) {
19
19
  var _a = entity || { isReadonly: true }, id = _a.id, type = _a.type, isReadonly = _a.isReadonly;
20
20
  var isBlockEntity = (0, isBlockElement_1.isBlockElement)(element, context);
21
21
  (0, stackFormat_1.stackFormat)(context, { segment: isBlockEntity ? 'empty' : undefined, paragraph: 'empty' }, function () {
22
- var wrapperToUse = context.allowCacheElement
23
- ? element
24
- : element.cloneNode(true /* deep */);
25
- if (!context.allowCacheElement) {
26
- wrapperToUse.style.backgroundColor = element.style.backgroundColor || 'inherit';
27
- wrapperToUse.style.color = element.style.color || 'inherit';
28
- }
29
- var entityModel = (0, createEntity_1.createEntity)(wrapperToUse, isReadonly, context.segmentFormat, id, type);
22
+ var entityModel = (0, createEntity_1.createEntity)(element, isReadonly, type, context.segmentFormat, id);
30
23
  // TODO: Need to handle selection for editable entity
31
24
  if (context.isInSelection) {
32
25
  entityModel.isSelected = true;
@@ -1 +1 @@
1
- {"version":3,"file":"entityProcessor.js","sourceRoot":"","sources":["../../../../../packages-content-model/roosterjs-content-model-dom/lib/domToModel/processors/entityProcessor.ts"],"names":[],"mappings":";;;AAAA,2DAA0D;AAC1D,+DAA8D;AAC9D,qEAAoE;AAEpE,6DAA4D;AAC5D,0DAAyD;AACzD,oDAAmD;AAEnD;;;;;GAKG;AACI,IAAM,eAAe,GAAkC,UAAC,KAAK,EAAE,OAAO,EAAE,OAAO;IAClF,IAAM,MAAM,GAAG,IAAA,2CAAoB,EAAC,OAAO,CAAC,CAAC;IAE7C,wFAAwF;IAClF,IAAA,KAA2B,MAAM,IAAI,EAAE,UAAU,EAAE,IAAI,EAAE,EAAvD,EAAE,QAAA,EAAE,IAAI,UAAA,EAAE,UAAU,gBAAmC,CAAC;IAChE,IAAM,aAAa,GAAG,IAAA,+BAAc,EAAC,OAAO,EAAE,OAAO,CAAC,CAAC;IAEvD,IAAA,yBAAW,EACP,OAAO,EACP,EAAE,OAAO,EAAE,aAAa,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,SAAS,EAAE,SAAS,EAAE,OAAO,EAAE,EACpE;QACI,IAAM,YAAY,GAAG,OAAO,CAAC,iBAAiB;YAC1C,CAAC,CAAC,OAAO;YACT,CAAC,CAAE,OAAO,CAAC,SAAS,CAAC,IAAI,CAAC,UAAU,CAAiB,CAAC;QAE1D,IAAI,CAAC,OAAO,CAAC,iBAAiB,EAAE;YAC5B,YAAY,CAAC,KAAK,CAAC,eAAe,GAAG,OAAO,CAAC,KAAK,CAAC,eAAe,IAAI,SAAS,CAAC;YAChF,YAAY,CAAC,KAAK,CAAC,KAAK,GAAG,OAAO,CAAC,KAAK,CAAC,KAAK,IAAI,SAAS,CAAC;SAC/D;QAED,IAAM,WAAW,GAAG,IAAA,2BAAY,EAC5B,YAAY,EACZ,UAAU,EACV,OAAO,CAAC,aAAa,EACrB,EAAE,EACF,IAAI,CACP,CAAC;QAEF,qDAAqD;QACrD,IAAI,OAAO,CAAC,aAAa,EAAE;YACvB,WAAW,CAAC,UAAU,GAAG,IAAI,CAAC;SACjC;QAED,IAAI,aAAa,EAAE;YACf,IAAA,mBAAQ,EAAC,KAAK,EAAE,WAAW,CAAC,CAAC;SAChC;aAAM;YACH,IAAA,uBAAU,EAAC,KAAK,EAAE,WAAW,CAAC,CAAC;SAClC;IACL,CAAC,CACJ,CAAC;AACN,CAAC,CAAC;AAxCW,QAAA,eAAe,mBAwC1B","sourcesContent":["import { addBlock } from '../../modelApi/common/addBlock';\nimport { addSegment } from '../../modelApi/common/addSegment';\nimport { createEntity } from '../../modelApi/creators/createEntity';\nimport { ElementProcessor } from 'roosterjs-content-model-types';\nimport { getEntityFromElement } from 'roosterjs-editor-dom';\nimport { isBlockElement } from '../utils/isBlockElement';\nimport { stackFormat } from '../utils/stackFormat';\n\n/**\n * Content Model Element Processor for entity\n * @param group The parent block group\n * @param parent Parent DOM node to process\n * @param context DOM to Content Model context\n */\nexport const entityProcessor: ElementProcessor<HTMLElement> = (group, element, context) => {\n const entity = getEntityFromElement(element);\n\n // In Content Model we also treat read only element as an entity since we cannot edit it\n const { id, type, isReadonly } = entity || { isReadonly: true };\n const isBlockEntity = isBlockElement(element, context);\n\n stackFormat(\n context,\n { segment: isBlockEntity ? 'empty' : undefined, paragraph: 'empty' },\n () => {\n const wrapperToUse = context.allowCacheElement\n ? element\n : (element.cloneNode(true /* deep */) as HTMLElement);\n\n if (!context.allowCacheElement) {\n wrapperToUse.style.backgroundColor = element.style.backgroundColor || 'inherit';\n wrapperToUse.style.color = element.style.color || 'inherit';\n }\n\n const entityModel = createEntity(\n wrapperToUse,\n isReadonly,\n context.segmentFormat,\n id,\n type\n );\n\n // TODO: Need to handle selection for editable entity\n if (context.isInSelection) {\n entityModel.isSelected = true;\n }\n\n if (isBlockEntity) {\n addBlock(group, entityModel);\n } else {\n addSegment(group, entityModel);\n }\n }\n );\n};\n"]}
1
+ {"version":3,"file":"entityProcessor.js","sourceRoot":"","sources":["../../../../../packages-content-model/roosterjs-content-model-dom/lib/domToModel/processors/entityProcessor.ts"],"names":[],"mappings":";;;AAAA,2DAA0D;AAC1D,+DAA8D;AAC9D,qEAAoE;AAEpE,6DAA4D;AAC5D,0DAAyD;AACzD,oDAAmD;AAEnD;;;;;GAKG;AACI,IAAM,eAAe,GAAkC,UAAC,KAAK,EAAE,OAAO,EAAE,OAAO;IAClF,IAAM,MAAM,GAAG,IAAA,2CAAoB,EAAC,OAAO,CAAC,CAAC;IAE7C,wFAAwF;IAClF,IAAA,KAA2B,MAAM,IAAI,EAAE,UAAU,EAAE,IAAI,EAAE,EAAvD,EAAE,QAAA,EAAE,IAAI,UAAA,EAAE,UAAU,gBAAmC,CAAC;IAChE,IAAM,aAAa,GAAG,IAAA,+BAAc,EAAC,OAAO,EAAE,OAAO,CAAC,CAAC;IAEvD,IAAA,yBAAW,EACP,OAAO,EACP,EAAE,OAAO,EAAE,aAAa,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,SAAS,EAAE,SAAS,EAAE,OAAO,EAAE,EACpE;QACI,IAAM,WAAW,GAAG,IAAA,2BAAY,EAAC,OAAO,EAAE,UAAU,EAAE,IAAI,EAAE,OAAO,CAAC,aAAa,EAAE,EAAE,CAAC,CAAC;QAEvF,qDAAqD;QACrD,IAAI,OAAO,CAAC,aAAa,EAAE;YACvB,WAAW,CAAC,UAAU,GAAG,IAAI,CAAC;SACjC;QAED,IAAI,aAAa,EAAE;YACf,IAAA,mBAAQ,EAAC,KAAK,EAAE,WAAW,CAAC,CAAC;SAChC;aAAM;YACH,IAAA,uBAAU,EAAC,KAAK,EAAE,WAAW,CAAC,CAAC;SAClC;IACL,CAAC,CACJ,CAAC;AACN,CAAC,CAAC;AAzBW,QAAA,eAAe,mBAyB1B","sourcesContent":["import { addBlock } from '../../modelApi/common/addBlock';\nimport { addSegment } from '../../modelApi/common/addSegment';\nimport { createEntity } from '../../modelApi/creators/createEntity';\nimport { ElementProcessor } from 'roosterjs-content-model-types';\nimport { getEntityFromElement } from 'roosterjs-editor-dom';\nimport { isBlockElement } from '../utils/isBlockElement';\nimport { stackFormat } from '../utils/stackFormat';\n\n/**\n * Content Model Element Processor for entity\n * @param group The parent block group\n * @param parent Parent DOM node to process\n * @param context DOM to Content Model context\n */\nexport const entityProcessor: ElementProcessor<HTMLElement> = (group, element, context) => {\n const entity = getEntityFromElement(element);\n\n // In Content Model we also treat read only element as an entity since we cannot edit it\n const { id, type, isReadonly } = entity || { isReadonly: true };\n const isBlockEntity = isBlockElement(element, context);\n\n stackFormat(\n context,\n { segment: isBlockEntity ? 'empty' : undefined, paragraph: 'empty' },\n () => {\n const entityModel = createEntity(element, isReadonly, type, context.segmentFormat, id);\n\n // TODO: Need to handle selection for editable entity\n if (context.isInSelection) {\n entityModel.isSelected = true;\n }\n\n if (isBlockEntity) {\n addBlock(group, entityModel);\n } else {\n addSegment(group, entityModel);\n }\n }\n );\n};\n"]}
@@ -16,8 +16,8 @@ var headingProcessor = function (group, element, context) {
16
16
  var segmentFormat = {};
17
17
  (0, parseFormat_1.parseFormat)(element, context.formatParsers.segmentOnBlock, segmentFormat, context);
18
18
  // These formats are already declared on heading element, no need to keep them in context.
19
- // And we should not duplicate them in context, either. Because when we want to turn off header,
20
- // inner text should not keep those text format from header.
19
+ // And we should not duplicate them in context, either. Because when we want to turn off heading,
20
+ // inner text should not keep those text format from heading.
21
21
  (0, roosterjs_editor_dom_1.getObjectKeys)(segmentFormat).forEach(function (key) {
22
22
  delete context.segmentFormat[key];
23
23
  });
@@ -1 +1 @@
1
- {"version":3,"file":"headingProcessor.js","sourceRoot":"","sources":["../../../../../packages-content-model/roosterjs-content-model-dom/lib/domToModel/processors/headingProcessor.ts"],"names":[],"mappings":";;;AAAA,2DAA0D;AAC1D,mDAAkD;AAElD,2EAA0E;AAC1E,6FAA4F;AAC5F,6DAAqD;AACrD,oDAAmD;AACnD,oDAAmD;AAEnD;;GAEG;AACI,IAAM,gBAAgB,GAAyC,UAAC,KAAK,EAAE,OAAO,EAAE,OAAO;IAC1F,IAAA,yBAAW,EACP,OAAO,EACP,EAAE,OAAO,EAAE,sBAAsB,EAAE,SAAS,EAAE,cAAc,EAAE,cAAc,EAAE,OAAO,EAAE,EACvF;QACI,IAAM,aAAa,GAA8B,EAAE,CAAC;QAEpD,IAAA,yBAAW,EAAC,OAAO,EAAE,OAAO,CAAC,aAAa,CAAC,cAAc,EAAE,aAAa,EAAE,OAAO,CAAC,CAAC;QAEnF,0FAA0F;QAC1F,gGAAgG;QAChG,4DAA4D;QAC5D,IAAA,oCAAa,EAAC,aAAa,CAAC,CAAC,OAAO,CAAC,UAAA,GAAG;YACpC,OAAO,OAAO,CAAC,aAAa,CAAC,GAAG,CAAC,CAAC;QACtC,CAAC,CAAC,CAAC;QAEH,OAAO,CAAC,cAAc,GAAG,IAAA,mDAAwB,EAAC,OAAO,CAAC,OAAO,EAAE,aAAa,CAAC,CAAC;QAElF,IAAA,+BAAc,EAAC,KAAK,EAAE,OAAO,EAAE,OAAO,CAAC,CAAC;IAC5C,CAAC,CACJ,CAAC;IAEF,IAAA,mBAAQ,EAAC,KAAK,EAAE,IAAA,iCAAe,EAAC,IAAI,CAAC,cAAc,EAAE,OAAO,CAAC,WAAW,CAAC,CAAC,CAAC;AAC/E,CAAC,CAAC;AAvBW,QAAA,gBAAgB,oBAuB3B","sourcesContent":["import { addBlock } from '../../modelApi/common/addBlock';\nimport { blockProcessor } from './blockProcessor';\nimport { ContentModelSegmentFormat, ElementProcessor } from 'roosterjs-content-model-types';\nimport { createParagraph } from '../../modelApi/creators/createParagraph';\nimport { createParagraphDecorator } from '../../modelApi/creators/createParagraphDecorator';\nimport { getObjectKeys } from 'roosterjs-editor-dom';\nimport { parseFormat } from '../utils/parseFormat';\nimport { stackFormat } from '../utils/stackFormat';\n\n/**\n * @internal\n */\nexport const headingProcessor: ElementProcessor<HTMLHeadingElement> = (group, element, context) => {\n stackFormat(\n context,\n { segment: 'shallowCloneForBlock', paragraph: 'shallowClone', blockDecorator: 'empty' },\n () => {\n const segmentFormat: ContentModelSegmentFormat = {};\n\n parseFormat(element, context.formatParsers.segmentOnBlock, segmentFormat, context);\n\n // These formats are already declared on heading element, no need to keep them in context.\n // And we should not duplicate them in context, either. Because when we want to turn off header,\n // inner text should not keep those text format from header.\n getObjectKeys(segmentFormat).forEach(key => {\n delete context.segmentFormat[key];\n });\n\n context.blockDecorator = createParagraphDecorator(element.tagName, segmentFormat);\n\n blockProcessor(group, element, context);\n }\n );\n\n addBlock(group, createParagraph(true /*isImplicit*/, context.blockFormat));\n};\n"]}
1
+ {"version":3,"file":"headingProcessor.js","sourceRoot":"","sources":["../../../../../packages-content-model/roosterjs-content-model-dom/lib/domToModel/processors/headingProcessor.ts"],"names":[],"mappings":";;;AAAA,2DAA0D;AAC1D,mDAAkD;AAElD,2EAA0E;AAC1E,6FAA4F;AAC5F,6DAAqD;AACrD,oDAAmD;AACnD,oDAAmD;AAEnD;;GAEG;AACI,IAAM,gBAAgB,GAAyC,UAAC,KAAK,EAAE,OAAO,EAAE,OAAO;IAC1F,IAAA,yBAAW,EACP,OAAO,EACP,EAAE,OAAO,EAAE,sBAAsB,EAAE,SAAS,EAAE,cAAc,EAAE,cAAc,EAAE,OAAO,EAAE,EACvF;QACI,IAAM,aAAa,GAA8B,EAAE,CAAC;QAEpD,IAAA,yBAAW,EAAC,OAAO,EAAE,OAAO,CAAC,aAAa,CAAC,cAAc,EAAE,aAAa,EAAE,OAAO,CAAC,CAAC;QAEnF,0FAA0F;QAC1F,iGAAiG;QACjG,6DAA6D;QAC7D,IAAA,oCAAa,EAAC,aAAa,CAAC,CAAC,OAAO,CAAC,UAAA,GAAG;YACpC,OAAO,OAAO,CAAC,aAAa,CAAC,GAAG,CAAC,CAAC;QACtC,CAAC,CAAC,CAAC;QAEH,OAAO,CAAC,cAAc,GAAG,IAAA,mDAAwB,EAAC,OAAO,CAAC,OAAO,EAAE,aAAa,CAAC,CAAC;QAElF,IAAA,+BAAc,EAAC,KAAK,EAAE,OAAO,EAAE,OAAO,CAAC,CAAC;IAC5C,CAAC,CACJ,CAAC;IAEF,IAAA,mBAAQ,EAAC,KAAK,EAAE,IAAA,iCAAe,EAAC,IAAI,CAAC,cAAc,EAAE,OAAO,CAAC,WAAW,CAAC,CAAC,CAAC;AAC/E,CAAC,CAAC;AAvBW,QAAA,gBAAgB,oBAuB3B","sourcesContent":["import { addBlock } from '../../modelApi/common/addBlock';\nimport { blockProcessor } from './blockProcessor';\nimport { ContentModelSegmentFormat, ElementProcessor } from 'roosterjs-content-model-types';\nimport { createParagraph } from '../../modelApi/creators/createParagraph';\nimport { createParagraphDecorator } from '../../modelApi/creators/createParagraphDecorator';\nimport { getObjectKeys } from 'roosterjs-editor-dom';\nimport { parseFormat } from '../utils/parseFormat';\nimport { stackFormat } from '../utils/stackFormat';\n\n/**\n * @internal\n */\nexport const headingProcessor: ElementProcessor<HTMLHeadingElement> = (group, element, context) => {\n stackFormat(\n context,\n { segment: 'shallowCloneForBlock', paragraph: 'shallowClone', blockDecorator: 'empty' },\n () => {\n const segmentFormat: ContentModelSegmentFormat = {};\n\n parseFormat(element, context.formatParsers.segmentOnBlock, segmentFormat, context);\n\n // These formats are already declared on heading element, no need to keep them in context.\n // And we should not duplicate them in context, either. Because when we want to turn off heading,\n // inner text should not keep those text format from heading.\n getObjectKeys(segmentFormat).forEach(key => {\n delete context.segmentFormat[key];\n });\n\n context.blockDecorator = createParagraphDecorator(element.tagName, segmentFormat);\n\n blockProcessor(group, element, context);\n }\n );\n\n addBlock(group, createParagraph(true /*isImplicit*/, context.blockFormat));\n};\n"]}
@@ -7,6 +7,7 @@ var createTable_1 = require("../../modelApi/creators/createTable");
7
7
  var createTableCell_1 = require("../../modelApi/creators/createTableCell");
8
8
  var getBoundingClientRect_1 = require("../utils/getBoundingClientRect");
9
9
  var parseFormat_1 = require("../utils/parseFormat");
10
+ var roosterjs_editor_dom_1 = require("roosterjs-editor-dom");
10
11
  var stackFormat_1 = require("../utils/stackFormat");
11
12
  /**
12
13
  * Content Model Element Processor for table
@@ -52,7 +53,11 @@ var tableProcessor = function (group, tableElement, context) {
52
53
  var _loop_1 = function (row) {
53
54
  var tr = tableElement.rows[row];
54
55
  var tableRow = table.rows[row];
55
- if (context.allowCacheElement) {
56
+ var tbody = tr.parentNode;
57
+ if ((0, roosterjs_editor_dom_1.safeInstanceOf)(tbody, 'HTMLTableSectionElement')) {
58
+ (0, parseFormat_1.parseFormat)(tbody, context.formatParsers.tableRow, tableRow.format, context);
59
+ }
60
+ else if (context.allowCacheElement) {
56
61
  tableRow.cachedElement = tr;
57
62
  }
58
63
  (0, parseFormat_1.parseFormat)(tr, context.formatParsers.tableRow, tableRow.format, context);
@@ -140,6 +145,11 @@ var tableProcessor = function (group, tableElement, context) {
140
145
  targetCol = out_targetCol_1;
141
146
  }
142
147
  });
148
+ for (var col = 0; col < tableRow.cells.length; col++) {
149
+ if (!tableRow.cells[col]) {
150
+ tableRow.cells[col] = (0, createTableCell_1.createTableCell)(false, false, false, context.blockFormat);
151
+ }
152
+ }
143
153
  };
144
154
  for (var row = 0; row < tableElement.rows.length; row++) {
145
155
  _loop_1(row);
@@ -1 +1 @@
1
- {"version":3,"file":"tableProcessor.js","sourceRoot":"","sources":["../../../../../packages-content-model/roosterjs-content-model-dom/lib/domToModel/processors/tableProcessor.ts"],"names":[],"mappings":";;;;AAAA,2DAA0D;AAC1D,mEAAkE;AAClE,2EAA0E;AAC1E,wEAAuE;AACvE,oDAAmD;AAEnD,oDAAmD;AAOnD;;;;;;;;;;;;;;;;GAgBG;AACI,IAAM,cAAc,GAAuC,UAC9D,KAAK,EACL,YAAY,EACZ,OAAO;IAEP,IAAA,yBAAW,EACP,OAAO,EACP,EAAE,OAAO,EAAE,sBAAsB,EAAE,SAAS,EAAE,sBAAsB,EAAE,EACtE;;QACI,IAAA,yBAAW,EAAC,YAAY,EAAE,OAAO,CAAC,aAAa,CAAC,KAAK,EAAE,OAAO,CAAC,WAAW,EAAE,OAAO,CAAC,CAAC;QAErF,IAAM,KAAK,GAAG,IAAA,yBAAW,EAAC,YAAY,CAAC,IAAI,CAAC,MAAM,EAAE,OAAO,CAAC,WAAW,CAAC,CAAC;QACzE,IAAM,cAAc,GAChB,CAAA,MAAA,OAAO,CAAC,OAAO,0CAAE,IAAI,2BAAsC;YACvD,CAAC,CAAC,OAAO,CAAC,OAAO;YACjB,CAAC,CAAC,IAAI,CAAC;QACf,IAAM,aAAa,GAAG,cAAc,aAAd,cAAc,uBAAd,cAAc,CAAE,KAAK,CAAC;QAC5C,IAAM,WAAW,GAAG,cAAc,aAAd,cAAc,uBAAd,cAAc,CAAE,WAAW,CAAC;QAChD,IAAM,iBAAiB,GACnB,aAAa,IAAI,YAAY;YAC7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,SAAmB;IAClC,IAAI,MAAM,GAAa,EAAE,CAAC;IAC1B,IAAI,OAAO,GAAG,SAAS,CAAC,SAAS,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC;IAE9C,KAAK,IAAI,CAAC,GAAG,SAAS,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC,IAAI,CAAC,EAAE,CAAC,EAAE,EAAE;QAC5C,IAAI,SAAS,CAAC,CAAC,CAAC,KAAK,SAAS,EAAE;YAC5B,MAAM,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC;SACjB;aAAM;YACH,MAAM,CAAC,CAAC,CAAC,GAAG,OAAO,GAAG,SAAS,CAAC,CAAC,CAAC,CAAC;YACnC,OAAO,GAAG,SAAS,CAAC,CAAC,CAAC,CAAC;SAC1B;KACJ;IAED,OAAO,MAAM,CAAC;AAClB,CAAC","sourcesContent":["import { addBlock } from '../../modelApi/common/addBlock';\nimport { createTable } from '../../modelApi/creators/createTable';\nimport { createTableCell } from '../../modelApi/creators/createTableCell';\nimport { getBoundingClientRect } from '../utils/getBoundingClientRect';\nimport { parseFormat } from '../utils/parseFormat';\nimport { SelectionRangeTypes } from 'roosterjs-editor-types';\nimport { stackFormat } from '../utils/stackFormat';\nimport {\n ContentModelTableCellFormat,\n DatasetFormat,\n ElementProcessor,\n} from 'roosterjs-content-model-types';\n\n/**\n * Content Model Element Processor for table\n *\n * For Table with merged/splitted cells, HTML uses colSpan and rowSpan attributes to specify how it should be rendered.\n * To make it easier to edit a table, we will use a different way to describe table.\n *\n * 1. For a m * n table (m rows, n columns), we always create a m * n array for the cells.\n * 2. For a regular table cell, it is mapped to one item of this array\n * 3. For a merged/splitted table cell, it will has colSpan/rowSpan value. We also created TableCell model for those spanned\n * cells, and use \"spanLeft\" and \"spanAbove\" to mark its state\n * 4. When edit table, we always edit on this mapped m * n array because it always has an item for each cell\n * 5. When write back to DOM, we create TD/TH elements for those non-spanned cells, and mark its colSpan/rowSpan value according\n * its neighbour cell's spanLeft/spanAbove attribute\n * @param group The parent block group\n * @param parent Parent DOM node to process\n * @param context DOM to Content Model context\n */\nexport const tableProcessor: ElementProcessor<HTMLTableElement> = (\n group,\n tableElement,\n context\n) => {\n stackFormat(\n context,\n { segment: 'shallowCloneForBlock', paragraph: 'shallowCloneForGroup' },\n () => {\n parseFormat(tableElement, context.formatParsers.block, context.blockFormat, context);\n\n const table = createTable(tableElement.rows.length, context.blockFormat);\n const tableSelection =\n context.rangeEx?.type == SelectionRangeTypes.TableSelection\n ? context.rangeEx\n : null;\n const selectedTable = tableSelection?.table;\n const coordinates = tableSelection?.coordinates;\n const hasTableSelection =\n selectedTable == tableElement &&\n !!coordinates?.firstCell &&\n !!coordinates?.lastCell;\n\n if (context.allowCacheElement) {\n table.cachedElement = tableElement;\n }\n\n parseFormat(tableElement, context.formatParsers.table, table.format, context);\n parseFormat(tableElement, context.formatParsers.tableBorder, table.format, context);\n parseFormat(\n tableElement,\n context.formatParsers.segmentOnBlock,\n context.segmentFormat,\n context\n );\n parseFormat(tableElement, context.formatParsers.dataset, table.dataset, context);\n addBlock(group, table);\n\n const columnPositions: number[] = [0];\n const rowPositions: number[] = [0];\n const zoomScale = context.zoomScale || 1;\n\n for (let row = 0; row < tableElement.rows.length; row++) {\n const tr = tableElement.rows[row];\n const tableRow = table.rows[row];\n\n if (context.allowCacheElement) {\n tableRow.cachedElement = tr;\n }\n\n parseFormat(tr, context.formatParsers.tableRow, tableRow.format, context);\n\n stackFormat(context, { paragraph: 'shallowClone', segment: 'shallowClone' }, () => {\n const parent = tr.parentElement;\n const parentTag = parent?.tagName;\n\n if (\n parent &&\n (parentTag == 'TBODY' || parentTag == 'THEAD' || parentTag == 'TFOOT')\n ) {\n // If there is TBODY around TR, retrieve format from TBODY first, in case some format are declared there\n parseFormat(\n parent,\n context.formatParsers.block,\n context.blockFormat,\n context\n );\n parseFormat(\n parent,\n context.formatParsers.segmentOnBlock,\n context.segmentFormat,\n context\n );\n }\n\n parseFormat(tr, context.formatParsers.block, context.blockFormat, context);\n parseFormat(\n tr,\n context.formatParsers.segmentOnBlock,\n context.segmentFormat,\n context\n );\n\n for (\n let sourceCol = 0, targetCol = 0;\n sourceCol < tr.cells.length;\n sourceCol++\n ) {\n for (; tableRow.cells[targetCol]; targetCol++) {}\n\n const td = tr.cells[sourceCol];\n const hasSelectionBeforeCell = context.isInSelection;\n const colEnd = targetCol + td.colSpan;\n const rowEnd = row + td.rowSpan;\n const needCalcWidth = columnPositions[colEnd] === undefined;\n const needCalcHeight = rowPositions[rowEnd] === undefined;\n\n if (needCalcWidth || needCalcHeight) {\n const rect = getBoundingClientRect(td);\n\n if (rect.width > 0 || rect.height > 0) {\n if (needCalcWidth) {\n columnPositions[colEnd] =\n columnPositions[targetCol] + rect.width / zoomScale;\n }\n\n if (needCalcHeight) {\n rowPositions[rowEnd] =\n rowPositions[row] + rect.height / zoomScale;\n }\n }\n }\n\n stackFormat(\n context,\n { paragraph: 'shallowClone', segment: 'shallowClone' },\n () => {\n parseFormat(\n td,\n context.formatParsers.block,\n context.blockFormat,\n context\n );\n parseFormat(\n td,\n context.formatParsers.segmentOnTableCell,\n context.segmentFormat,\n context\n );\n\n const cellFormat: ContentModelTableCellFormat = {\n ...context.blockFormat,\n };\n const dataset: DatasetFormat = {};\n\n parseFormat(\n td,\n context.formatParsers.tableCell,\n cellFormat,\n context\n );\n parseFormat(\n td,\n context.formatParsers.tableBorder,\n cellFormat,\n context\n );\n parseFormat(td, context.formatParsers.dataset, dataset, context);\n\n for (\n let colSpan = 1;\n colSpan <= td.colSpan;\n colSpan++, targetCol++\n ) {\n for (let rowSpan = 1; rowSpan <= td.rowSpan; rowSpan++) {\n const hasTd = colSpan == 1 && rowSpan == 1;\n const cell = createTableCell(\n colSpan > 1,\n rowSpan > 1,\n td.tagName == 'TH',\n cellFormat\n );\n\n cell.dataset = { ...dataset };\n\n const spannedRow = table.rows[row + rowSpan - 1];\n\n if (spannedRow) {\n spannedRow.cells[targetCol] = cell;\n }\n\n if (hasTd) {\n if (context.allowCacheElement) {\n cell.cachedElement = td;\n }\n\n const { listParent, levels } = context.listFormat;\n\n context.listFormat.listParent = undefined;\n context.listFormat.levels = [];\n\n try {\n context.elementProcessors.child(cell, td, context);\n } finally {\n context.listFormat.listParent = listParent;\n context.listFormat.levels = levels;\n }\n }\n\n const hasSelectionAfterCell = context.isInSelection;\n\n if (\n (hasSelectionBeforeCell && hasSelectionAfterCell) ||\n (hasTableSelection &&\n row >= coordinates.firstCell.y &&\n row <= coordinates.lastCell.y &&\n targetCol >= coordinates.firstCell.x &&\n targetCol <= coordinates.lastCell.x)\n ) {\n cell.isSelected = true;\n }\n }\n }\n }\n );\n }\n });\n }\n\n table.widths = calcSizes(columnPositions);\n\n const heights = calcSizes(rowPositions);\n\n table.rows.forEach((row, i) => {\n if (heights[i] > 0) {\n row.height = heights[i];\n }\n });\n }\n );\n};\n\nfunction calcSizes(positions: number[]): number[] {\n let result: number[] = [];\n let lastPos = positions[positions.length - 1];\n\n for (let i = positions.length - 2; i >= 0; i--) {\n if (positions[i] === undefined) {\n result[i] = 0;\n } else {\n result[i] = lastPos - positions[i];\n lastPos = positions[i];\n }\n }\n\n return result;\n}\n"]}
1
+ {"version":3,"file":"tableProcessor.js","sourceRoot":"","sources":["../../../../../packages-content-model/roosterjs-content-model-dom/lib/domToModel/processors/tableProcessor.ts"],"names":[],"mappings":";;;;AAAA,2DAA0D;AAC1D,mEAAkE;AAClE,2EAA0E;AAC1E,wEAAuE;AACvE,oDAAmD;AACnD,6DAAsD;AAEtD,oDAAmD;AAOnD;;;;;;;;;;;;;;;;GAgBG;AACI,IAAM,cAAc,GAAuC,UAC9D,KAAK,EACL,YAAY,EACZ,OAAO;IAEP,IAAA,yBAAW,EACP,OAAO,EACP,EAAE,OAAO,EAAE,sBAAsB,EAAE,SAAS,EAAE,sBAAsB,EAAE,EACtE;;QACI,IAAA,yBAAW,EAAC,YAAY,EAAE,OAAO,CAAC,aAAa,CAAC,KAAK,EAAE,OAAO,CAAC,W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AI,CAAC,EAAE,CAAC,EAAE,EAAE;QAC5C,IAAI,SAAS,CAAC,CAAC,CAAC,KAAK,SAAS,EAAE;YAC5B,MAAM,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC;SACjB;aAAM;YACH,MAAM,CAAC,CAAC,CAAC,GAAG,OAAO,GAAG,SAAS,CAAC,CAAC,CAAC,CAAC;YACnC,OAAO,GAAG,SAAS,CAAC,CAAC,CAAC,CAAC;SAC1B;KACJ;IAED,OAAO,MAAM,CAAC;AAClB,CAAC","sourcesContent":["import { addBlock } from '../../modelApi/common/addBlock';\nimport { createTable } from '../../modelApi/creators/createTable';\nimport { createTableCell } from '../../modelApi/creators/createTableCell';\nimport { getBoundingClientRect } from '../utils/getBoundingClientRect';\nimport { parseFormat } from '../utils/parseFormat';\nimport { safeInstanceOf } from 'roosterjs-editor-dom';\nimport { SelectionRangeTypes } from 'roosterjs-editor-types';\nimport { stackFormat } from '../utils/stackFormat';\nimport {\n ContentModelTableCellFormat,\n DatasetFormat,\n ElementProcessor,\n} from 'roosterjs-content-model-types';\n\n/**\n * Content Model Element Processor for table\n *\n * For Table with merged/splitted cells, HTML uses colSpan and rowSpan attributes to specify how it should be rendered.\n * To make it easier to edit a table, we will use a different way to describe table.\n *\n * 1. For a m * n table (m rows, n columns), we always create a m * n array for the cells.\n * 2. For a regular table cell, it is mapped to one item of this array\n * 3. For a merged/splitted table cell, it will has colSpan/rowSpan value. We also created TableCell model for those spanned\n * cells, and use \"spanLeft\" and \"spanAbove\" to mark its state\n * 4. When edit table, we always edit on this mapped m * n array because it always has an item for each cell\n * 5. When write back to DOM, we create TD/TH elements for those non-spanned cells, and mark its colSpan/rowSpan value according\n * its neighbour cell's spanLeft/spanAbove attribute\n * @param group The parent block group\n * @param parent Parent DOM node to process\n * @param context DOM to Content Model context\n */\nexport const tableProcessor: ElementProcessor<HTMLTableElement> = (\n group,\n tableElement,\n context\n) => {\n stackFormat(\n context,\n { segment: 'shallowCloneForBlock', paragraph: 'shallowCloneForGroup' },\n () => {\n parseFormat(tableElement, context.formatParsers.block, context.blockFormat, context);\n\n const table = createTable(tableElement.rows.length, context.blockFormat);\n const tableSelection =\n context.rangeEx?.type == SelectionRangeTypes.TableSelection\n ? context.rangeEx\n : null;\n const selectedTable = tableSelection?.table;\n const coordinates = tableSelection?.coordinates;\n const hasTableSelection =\n selectedTable == tableElement &&\n !!coordinates?.firstCell &&\n !!coordinates?.lastCell;\n\n if (context.allowCacheElement) {\n table.cachedElement = tableElement;\n }\n\n parseFormat(tableElement, context.formatParsers.table, table.format, context);\n parseFormat(tableElement, context.formatParsers.tableBorder, table.format, context);\n parseFormat(\n tableElement,\n context.formatParsers.segmentOnBlock,\n context.segmentFormat,\n context\n );\n parseFormat(tableElement, context.formatParsers.dataset, table.dataset, context);\n addBlock(group, table);\n\n const columnPositions: number[] = [0];\n const rowPositions: number[] = [0];\n const zoomScale = context.zoomScale || 1;\n\n for (let row = 0; row < tableElement.rows.length; row++) {\n const tr = tableElement.rows[row];\n const tableRow = table.rows[row];\n\n const tbody = tr.parentNode;\n\n if (safeInstanceOf(tbody, 'HTMLTableSectionElement')) {\n parseFormat(tbody, context.formatParsers.tableRow, tableRow.format, context);\n } else if (context.allowCacheElement) {\n tableRow.cachedElement = tr;\n }\n\n parseFormat(tr, context.formatParsers.tableRow, tableRow.format, context);\n\n stackFormat(context, { paragraph: 'shallowClone', segment: 'shallowClone' }, () => {\n const parent = tr.parentElement;\n const parentTag = parent?.tagName;\n\n if (\n parent &&\n (parentTag == 'TBODY' || parentTag == 'THEAD' || parentTag == 'TFOOT')\n ) {\n // If there is TBODY around TR, retrieve format from TBODY first, in case some format are declared there\n parseFormat(\n parent,\n context.formatParsers.block,\n context.blockFormat,\n context\n );\n parseFormat(\n parent,\n context.formatParsers.segmentOnBlock,\n context.segmentFormat,\n context\n );\n }\n\n parseFormat(tr, context.formatParsers.block, context.blockFormat, context);\n parseFormat(\n tr,\n context.formatParsers.segmentOnBlock,\n context.segmentFormat,\n context\n );\n\n for (\n let sourceCol = 0, targetCol = 0;\n sourceCol < tr.cells.length;\n sourceCol++\n ) {\n for (; tableRow.cells[targetCol]; targetCol++) {}\n\n const td = tr.cells[sourceCol];\n const hasSelectionBeforeCell = context.isInSelection;\n const colEnd = targetCol + td.colSpan;\n const rowEnd = row + td.rowSpan;\n const needCalcWidth = columnPositions[colEnd] === undefined;\n const needCalcHeight = rowPositions[rowEnd] === undefined;\n\n if (needCalcWidth || needCalcHeight) {\n const rect = getBoundingClientRect(td);\n\n if (rect.width > 0 || rect.height > 0) {\n if (needCalcWidth) {\n columnPositions[colEnd] =\n columnPositions[targetCol] + rect.width / zoomScale;\n }\n\n if (needCalcHeight) {\n rowPositions[rowEnd] =\n rowPositions[row] + rect.height / zoomScale;\n }\n }\n }\n\n stackFormat(\n context,\n { paragraph: 'shallowClone', segment: 'shallowClone' },\n () => {\n parseFormat(\n td,\n context.formatParsers.block,\n context.blockFormat,\n context\n );\n parseFormat(\n td,\n context.formatParsers.segmentOnTableCell,\n context.segmentFormat,\n context\n );\n\n const cellFormat: ContentModelTableCellFormat = {\n ...context.blockFormat,\n };\n const dataset: DatasetFormat = {};\n\n parseFormat(\n td,\n context.formatParsers.tableCell,\n cellFormat,\n context\n );\n parseFormat(\n td,\n context.formatParsers.tableBorder,\n cellFormat,\n context\n );\n parseFormat(td, context.formatParsers.dataset, dataset, context);\n\n for (\n let colSpan = 1;\n colSpan <= td.colSpan;\n colSpan++, targetCol++\n ) {\n for (let rowSpan = 1; rowSpan <= td.rowSpan; rowSpan++) {\n const hasTd = colSpan == 1 && rowSpan == 1;\n const cell = createTableCell(\n colSpan > 1,\n rowSpan > 1,\n td.tagName == 'TH',\n cellFormat\n );\n\n cell.dataset = { ...dataset };\n\n const spannedRow = table.rows[row + rowSpan - 1];\n\n if (spannedRow) {\n spannedRow.cells[targetCol] = cell;\n }\n\n if (hasTd) {\n if (context.allowCacheElement) {\n cell.cachedElement = td;\n }\n\n const { listParent, levels } = context.listFormat;\n\n context.listFormat.listParent = undefined;\n context.listFormat.levels = [];\n\n try {\n context.elementProcessors.child(cell, td, context);\n } finally {\n context.listFormat.listParent = listParent;\n context.listFormat.levels = levels;\n }\n }\n\n const hasSelectionAfterCell = context.isInSelection;\n\n if (\n (hasSelectionBeforeCell && hasSelectionAfterCell) ||\n (hasTableSelection &&\n row >= coordinates.firstCell.y &&\n row <= coordinates.lastCell.y &&\n targetCol >= coordinates.firstCell.x &&\n targetCol <= coordinates.lastCell.x)\n ) {\n cell.isSelected = true;\n }\n }\n }\n }\n );\n }\n });\n\n for (let col = 0; col < tableRow.cells.length; col++) {\n if (!tableRow.cells[col]) {\n tableRow.cells[col] = createTableCell(\n false,\n false,\n false,\n context.blockFormat\n );\n }\n }\n }\n\n table.widths = calcSizes(columnPositions);\n\n const heights = calcSizes(rowPositions);\n\n table.rows.forEach((row, i) => {\n if (heights[i] > 0) {\n row.height = heights[i];\n }\n });\n }\n );\n};\n\nfunction calcSizes(positions: number[]): number[] {\n let result: number[] = [];\n let lastPos = positions[positions.length - 1];\n\n for (let i = positions.length - 2; i >= 0; i--) {\n if (positions[i] === undefined) {\n result[i] = 0;\n } else {\n result[i] = lastPos - positions[i];\n lastPos = positions[i];\n }\n }\n\n return result;\n}\n"]}
@@ -0,0 +1,6 @@
1
+ import { FloatFormat } from 'roosterjs-content-model-types';
2
+ import { FormatHandler } from '../FormatHandler';
3
+ /**
4
+ * @internal
5
+ */
6
+ export declare const floatFormatHandler: FormatHandler<FloatFormat>;
@@ -0,0 +1,20 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.floatFormatHandler = void 0;
4
+ /**
5
+ * @internal
6
+ */
7
+ exports.floatFormatHandler = {
8
+ parse: function (format, element) {
9
+ var float = element.style.float || element.getAttribute('align');
10
+ if (float) {
11
+ format.float = float;
12
+ }
13
+ },
14
+ apply: function (format, element) {
15
+ if (format.float) {
16
+ element.style.float = format.float;
17
+ }
18
+ },
19
+ };
20
+ //# sourceMappingURL=floatFormatHandler.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"floatFormatHandler.js","sourceRoot":"","sources":["../../../../../packages-content-model/roosterjs-content-model-dom/lib/formatHandlers/common/floatFormatHandler.ts"],"names":[],"mappings":";;;AAGA;;GAEG;AACU,QAAA,kBAAkB,GAA+B;IAC1D,KAAK,EAAE,UAAC,MAAM,EAAE,OAAO;QACnB,IAAM,KAAK,GAAG,OAAO,CAAC,KAAK,CAAC,KAAK,IAAI,OAAO,CAAC,YAAY,CAAC,OAAO,CAAC,CAAC;QAEnE,IAAI,KAAK,EAAE;YACP,MAAM,CAAC,KAAK,GAAG,KAAK,CAAC;SACxB;IACL,CAAC;IACD,KAAK,EAAE,UAAC,MAAM,EAAE,OAAO;QACnB,IAAI,MAAM,CAAC,KAAK,EAAE;YACd,OAAO,CAAC,KAAK,CAAC,KAAK,GAAG,MAAM,CAAC,KAAK,CAAC;SACtC;IACL,CAAC;CACJ,CAAC","sourcesContent":["import { FloatFormat } from 'roosterjs-content-model-types';\nimport { FormatHandler } from '../FormatHandler';\n\n/**\n * @internal\n */\nexport const floatFormatHandler: FormatHandler<FloatFormat> = {\n parse: (format, element) => {\n const float = element.style.float || element.getAttribute('align');\n\n if (float) {\n format.float = float;\n }\n },\n apply: (format, element) => {\n if (format.float) {\n element.style.float = format.float;\n }\n },\n};\n"]}
@@ -20,6 +20,9 @@ exports.verticalAlignFormatHandler = {
20
20
  case 'bottom':
21
21
  format.verticalAlign = 'bottom';
22
22
  break;
23
+ case 'middle':
24
+ format.verticalAlign = 'middle';
25
+ break;
23
26
  }
24
27
  },
25
28
  apply: function (format, element) {
@@ -1 +1 @@
1
- {"version":3,"file":"verticalAlignFormatHandler.js","sourceRoot":"","sources":["../../../../../packages-content-model/roosterjs-content-model-dom/lib/formatHandlers/common/verticalAlignFormatHandler.ts"],"names":[],"mappings":";;;AAGA;;GAEG;AACU,QAAA,0BAA0B,GAAuC;IAC1E,KAAK,EAAE,UAAC,MAAM,EAAE,OAAO;QACnB,IAAM,KAAK,GAAG,OAAO,CAAC,KAAK,CAAC,aAAa,IAAI,OAAO,CAAC,YAAY,CAAC,QAAQ,CAAC,CAAC;QAE5E,QAAQ,KAAK,EAAE;YACX,KAAK,UAAU,CAAC;YAChB,KAAK,SAAS,CAAC;YACf,KAAK,OAAO,CAAC;YACb,KAAK,KAAK,CAAC;YACX,KAAK,UAAU,CAAC;YAChB,KAAK,aAAa,CAAC;YACnB,KAAK,KAAK;gBACN,MAAM,CAAC,aAAa,GAAG,KAAK,CAAC;gBAC7B,MAAM;YAEV,KAAK,QAAQ;gBACT,MAAM,CAAC,aAAa,GAAG,QAAQ,CAAC;gBAChC,MAAM;SACb;IACL,CAAC;IACD,KAAK,EAAE,UAAC,MAAM,EAAE,OAAO;QACnB,IAAI,MAAM,CAAC,aAAa,EAAE;YACtB,OAAO,CAAC,KAAK,CAAC,aAAa,GAAG,MAAM,CAAC,aAAa,CAAC;SACtD;IACL,CAAC;CACJ,CAAC","sourcesContent":["import { FormatHandler } from '../FormatHandler';\nimport { VerticalAlignFormat } from 'roosterjs-content-model-types';\n\n/**\n * @internal\n */\nexport const verticalAlignFormatHandler: FormatHandler<VerticalAlignFormat> = {\n parse: (format, element) => {\n const align = element.style.verticalAlign || element.getAttribute('valign');\n\n switch (align) {\n case 'baseline':\n case 'initial':\n case 'super':\n case 'sub':\n case 'text-top':\n case 'text-bottom':\n case 'top':\n format.verticalAlign = 'top';\n break;\n\n case 'bottom':\n format.verticalAlign = 'bottom';\n break;\n }\n },\n apply: (format, element) => {\n if (format.verticalAlign) {\n element.style.verticalAlign = format.verticalAlign;\n }\n },\n};\n"]}
1
+ {"version":3,"file":"verticalAlignFormatHandler.js","sourceRoot":"","sources":["../../../../../packages-content-model/roosterjs-content-model-dom/lib/formatHandlers/common/verticalAlignFormatHandler.ts"],"names":[],"mappings":";;;AAGA;;GAEG;AACU,QAAA,0BAA0B,GAAuC;IAC1E,KAAK,EAAE,UAAC,MAAM,EAAE,OAAO;QACnB,IAAM,KAAK,GAAG,OAAO,CAAC,KAAK,CAAC,aAAa,IAAI,OAAO,CAAC,YAAY,CAAC,QAAQ,CAAC,CAAC;QAE5E,QAAQ,KAAK,EAAE;YACX,KAAK,UAAU,CAAC;YAChB,KAAK,SAAS,CAAC;YACf,KAAK,OAAO,CAAC;YACb,KAAK,KAAK,CAAC;YACX,KAAK,UAAU,CAAC;YAChB,KAAK,aAAa,CAAC;YACnB,KAAK,KAAK;gBACN,MAAM,CAAC,aAAa,GAAG,KAAK,CAAC;gBAC7B,MAAM;YAEV,KAAK,QAAQ;gBACT,MAAM,CAAC,aAAa,GAAG,QAAQ,CAAC;gBAChC,MAAM;YAEV,KAAK,QAAQ;gBACT,MAAM,CAAC,aAAa,GAAG,QAAQ,CAAC;gBAChC,MAAM;SACb;IACL,CAAC;IACD,KAAK,EAAE,UAAC,MAAM,EAAE,OAAO;QACnB,IAAI,MAAM,CAAC,aAAa,EAAE;YACtB,OAAO,CAAC,KAAK,CAAC,aAAa,GAAG,MAAM,CAAC,aAAa,CAAC;SACtD;IACL,CAAC;CACJ,CAAC","sourcesContent":["import { FormatHandler } from '../FormatHandler';\nimport { VerticalAlignFormat } from 'roosterjs-content-model-types';\n\n/**\n * @internal\n */\nexport const verticalAlignFormatHandler: FormatHandler<VerticalAlignFormat> = {\n parse: (format, element) => {\n const align = element.style.verticalAlign || element.getAttribute('valign');\n\n switch (align) {\n case 'baseline':\n case 'initial':\n case 'super':\n case 'sub':\n case 'text-top':\n case 'text-bottom':\n case 'top':\n format.verticalAlign = 'top';\n break;\n\n case 'bottom':\n format.verticalAlign = 'bottom';\n break;\n\n case 'middle':\n format.verticalAlign = 'middle';\n break;\n }\n },\n apply: (format, element) => {\n if (format.verticalAlign) {\n element.style.verticalAlign = format.verticalAlign;\n }\n },\n};\n"]}
@@ -10,6 +10,7 @@ var boxShadowFormatHandler_1 = require("./common/boxShadowFormatHandler");
10
10
  var datasetFormatHandler_1 = require("./common/datasetFormatHandler");
11
11
  var directionFormatHandler_1 = require("./block/directionFormatHandler");
12
12
  var displayFormatHandler_1 = require("./block/displayFormatHandler");
13
+ var floatFormatHandler_1 = require("./common/floatFormatHandler");
13
14
  var fontFamilyFormatHandler_1 = require("./segment/fontFamilyFormatHandler");
14
15
  var fontSizeFormatHandler_1 = require("./segment/fontSizeFormatHandler");
15
16
  var roosterjs_editor_dom_1 = require("roosterjs-editor-dom");
@@ -45,6 +46,7 @@ var defaultFormatHandlerMap = {
45
46
  dataset: datasetFormatHandler_1.datasetFormatHandler,
46
47
  direction: directionFormatHandler_1.directionFormatHandler,
47
48
  display: displayFormatHandler_1.displayFormatHandler,
49
+ float: floatFormatHandler_1.floatFormatHandler,
48
50
  fontFamily: fontFamilyFormatHandler_1.fontFamilyFormatHandler,
49
51
  fontSize: fontSizeFormatHandler_1.fontSizeFormatHandler,
50
52
  htmlAlign: htmlAlignFormatHandler_1.htmlAlignFormatHandler,
@@ -142,7 +144,18 @@ var defaultFormatKeysPerCategory = {
142
144
  ],
143
145
  tableBorder: ['borderBox', 'tableSpacing'],
144
146
  tableCellBorder: ['borderBox'],
145
- image: ['id', 'size', 'margin', 'padding', 'borderBox', 'border', 'boxShadow', 'display'],
147
+ image: [
148
+ 'id',
149
+ 'size',
150
+ 'margin',
151
+ 'padding',
152
+ 'borderBox',
153
+ 'border',
154
+ 'boxShadow',
155
+ 'display',
156
+ 'float',
157
+ 'verticalAlign',
158
+ ],
146
159
  link: [
147
160
  'link',
148
161
  'textColor',
@@ -1 +1 @@
1
- {"version":3,"file":"defaultFormatHandlers.js","sourceRoot":"","sources":["../../../../packages-content-model/roosterjs-content-model-dom/lib/formatHandlers/defaultFormatHandlers.ts"],"names":[],"mappings":";;;;AAAA,sFAAqF;AACrF,iEAAgE;AAChE,0EAAyE;AACzE,oEAAmE;AACnE,0EAAyE;AACzE,sEAAqE;AACrE,yEAAwE;AACxE,qEAAoE;AACpE,6EAA4E;AAC5E,yEAAwE;AAExE,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AAC;IAClB,CAAC,EAAE,EAA+B,CAAC,CAAC;AACxC,CAAC;AAlBD,8CAkBC","sourcesContent":["import { backgroundColorFormatHandler } from './common/backgroundColorFormatHandler';\nimport { boldFormatHandler } from './segment/boldFormatHandler';\nimport { borderBoxFormatHandler } from './common/borderBoxFormatHandler';\nimport { borderFormatHandler } from './common/borderFormatHandler';\nimport { boxShadowFormatHandler } from './common/boxShadowFormatHandler';\nimport { datasetFormatHandler } from './common/datasetFormatHandler';\nimport { directionFormatHandler } from './block/directionFormatHandler';\nimport { displayFormatHandler } from './block/displayFormatHandler';\nimport { fontFamilyFormatHandler } from './segment/fontFamilyFormatHandler';\nimport { fontSizeFormatHandler } from './segment/fontSizeFormatHandler';\nimport { FormatHandler } from './FormatHandler';\nimport { getObjectKeys } from 'roosterjs-editor-dom';\nimport { htmlAlignFormatHandler } from './block/htmlAlignFormatHandler';\nimport { idFormatHandler } from './common/idFormatHandler';\nimport { italicFormatHandler } from './segment/italicFormatHandler';\nimport { letterSpacingFormatHandler } from './segment/letterSpacingFormatHandler';\nimport { lineHeightFormatHandler } from './block/lineHeightFormatHandler';\nimport { linkFormatHandler } from './segment/linkFormatHandler';\nimport { listItemThreadFormatHandler } from './list/listItemThreadFormatHandler';\nimport { listLevelThreadFormatHandler } from './list/listLevelThreadFormatHandler';\nimport { listStylePositionFormatHandler } from './list/listStylePositionFormatHandler';\nimport { marginFormatHandler } from './block/marginFormatHandler';\nimport { paddingFormatHandler } from './block/paddingFormatHandler';\nimport { sizeFormatHandler } from './common/sizeFormatHandler';\nimport { strikeFormatHandler } from './segment/strikeFormatHandler';\nimport { superOrSubScriptFormatHandler } from './segment/superOrSubScriptFormatHandler';\nimport { tableLayoutFormatHandler } from './table/tableLayoutFormatHandler';\nimport { tableSpacingFormatHandler } from './table/tableSpacingFormatHandler';\nimport { textAlignFormatHandler } from './block/textAlignFormatHandler';\nimport { textColorFormatHandler } from './segment/textColorFormatHandler';\nimport { textColorOnTableCellFormatHandler } from './table/textColorOnTableCellFormatHandler';\nimport { underlineFormatHandler } from './segment/underlineFormatHandler';\nimport { verticalAlignFormatHandler } from './common/verticalAlignFormatHandler';\nimport { whiteSpaceFormatHandler } from './block/whiteSpaceFormatHandler';\nimport { wordBreakFormatHandler } from './common/wordBreakFormatHandler';\nimport {\n ContentModelFormatMap,\n FormatHandlerTypeMap,\n FormatKey,\n FormatApplier,\n FormatAppliers,\n FormatAppliersPerCategory,\n FormatParser,\n FormatParsers,\n FormatParsersPerCategory,\n} from 'roosterjs-content-model-types';\n\ntype FormatHandlers = {\n [Key in FormatKey]: FormatHandler<FormatHandlerTypeMap[Key]>;\n};\n\nconst defaultFormatHandlerMap: FormatHandlers = {\n backgroundColor: backgroundColorFormatHandler,\n bold: boldFormatHandler,\n border: borderFormatHandler,\n borderBox: borderBoxFormatHandler,\n boxShadow: boxShadowFormatHandler,\n dataset: datasetFormatHandler,\n direction: directionFormatHandler,\n display: displayFormatHandler,\n fontFamily: fontFamilyFormatHandler,\n fontSize: fontSizeFormatHandler,\n htmlAlign: htmlAlignFormatHandler,\n id: idFormatHandler,\n italic: italicFormatHandler,\n letterSpacing: letterSpacingFormatHandler,\n lineHeight: lineHeightFormatHandler,\n link: linkFormatHandler,\n listItemThread: listItemThreadFormatHandler,\n listLevelThread: listLevelThreadFormatHandler,\n listStylePosition: listStylePositionFormatHandler,\n margin: marginFormatHandler,\n padding: paddingFormatHandler,\n size: sizeFormatHandler,\n strike: strikeFormatHandler,\n superOrSubScript: superOrSubScriptFormatHandler,\n tableLayout: tableLayoutFormatHandler,\n tableSpacing: tableSpacingFormatHandler,\n textAlign: textAlignFormatHandler,\n textColor: textColorFormatHandler,\n textColorOnTableCell: textColorOnTableCellFormatHandler,\n underline: underlineFormatHandler,\n verticalAlign: verticalAlignFormatHandler,\n whiteSpace: whiteSpaceFormatHandler,\n wordBreak: wordBreakFormatHandler,\n};\n\nconst styleBasedSegmentFormats: (keyof FormatHandlerTypeMap)[] = [\n 'letterSpacing',\n 'fontFamily',\n 'fontSize',\n];\n\nconst elementBasedSegmentFormats: (keyof FormatHandlerTypeMap)[] = [\n 'strike',\n 'underline',\n 'superOrSubScript',\n 'italic',\n 'bold',\n];\nconst sharedBlockFormats: (keyof FormatHandlerTypeMap)[] = [\n 'direction',\n 'textAlign',\n 'lineHeight',\n 'whiteSpace',\n];\nconst sharedContainerFormats: (keyof FormatHandlerTypeMap)[] = [\n 'backgroundColor',\n 'margin',\n 'padding',\n 'border',\n];\n\nconst defaultFormatKeysPerCategory: {\n [key in keyof ContentModelFormatMap]: (keyof FormatHandlerTypeMap)[];\n} = {\n block: sharedBlockFormats,\n listItem: ['listItemThread'],\n listItemElement: [...sharedBlockFormats, 'direction', 'textAlign', 'lineHeight', 'margin'],\n listLevel: [\n 'listLevelThread',\n 'direction',\n 'textAlign',\n 'margin',\n 'padding',\n 'listStylePosition',\n 'backgroundColor',\n ],\n styleBasedSegment: [...styleBasedSegmentFormats, 'textColor', 'backgroundColor', 'lineHeight'],\n elementBasedSegment: elementBasedSegmentFormats,\n segment: [\n ...styleBasedSegmentFormats,\n ...elementBasedSegmentFormats,\n 'textColor',\n 'backgroundColor',\n 'lineHeight',\n ],\n segmentOnBlock: [...styleBasedSegmentFormats, ...elementBasedSegmentFormats, 'textColor'],\n segmentOnTableCell: [\n ...styleBasedSegmentFormats,\n ...elementBasedSegmentFormats,\n 'textColorOnTableCell',\n ],\n tableCell: [\n 'border',\n 'backgroundColor',\n 'padding',\n 'verticalAlign',\n 'wordBreak',\n 'textColor',\n 'htmlAlign',\n 'size',\n ],\n tableRow: ['backgroundColor'],\n table: [\n 'id',\n 'border',\n 'backgroundColor',\n 'display',\n 'htmlAlign',\n 'margin',\n 'size',\n 'tableLayout',\n ],\n tableBorder: ['borderBox', 'tableSpacing'],\n tableCellBorder: ['borderBox'],\n image: ['id', 'size', 'margin', 'padding', 'borderBox', 'border', 'boxShadow', 'display'],\n link: [\n 'link',\n 'textColor',\n 'underline',\n 'display',\n 'margin',\n 'padding',\n 'backgroundColor',\n 'border',\n 'size',\n 'textAlign',\n ],\n segmentUnderLink: ['textColor'],\n code: ['fontFamily', 'display'],\n dataset: ['dataset'],\n divider: [...sharedBlockFormats, ...sharedContainerFormats, 'display', 'size', 'htmlAlign'],\n container: [...sharedContainerFormats, 'htmlAlign', 'size', 'display'],\n};\n\n/**\n * @internal\n */\nexport const defaultFormatParsers: FormatParsers = getObjectKeys(defaultFormatHandlerMap).reduce(\n (result, key) => {\n result[key] = defaultFormatHandlerMap[key].parse as FormatParser<any>;\n return result;\n },\n <FormatParsers>{}\n);\n\n/**\n * @internal\n */\nexport const defaultFormatAppliers: FormatAppliers = getObjectKeys(defaultFormatHandlerMap).reduce(\n (result, key) => {\n result[key] = defaultFormatHandlerMap[key].apply as FormatApplier<any>;\n return result;\n },\n <FormatAppliers>{}\n);\n\n/**\n * @internal\n */\nexport function getFormatParsers(\n override: Partial<FormatParsers> = {},\n additionalParsers: Partial<FormatParsersPerCategory> = {}\n): FormatParsersPerCategory {\n return getObjectKeys(defaultFormatKeysPerCategory).reduce((result, key) => {\n const value = defaultFormatKeysPerCategory[key]\n .map(\n formatKey =>\n (override[formatKey] === undefined\n ? defaultFormatParsers[formatKey]\n : override[formatKey]) as FormatParser<any>\n )\n .concat((additionalParsers[key] as FormatParser<any>[]) || []);\n\n result[key] = value;\n\n return result;\n }, {} as FormatParsersPerCategory);\n}\n\n/**\n * @internal\n */\nexport function getFormatAppliers(\n override: Partial<FormatAppliers> = {},\n additionalAppliers: Partial<FormatAppliersPerCategory> = {}\n): FormatAppliersPerCategory {\n return getObjectKeys(defaultFormatKeysPerCategory).reduce((result, key) => {\n const value = defaultFormatKeysPerCategory[key]\n .map(\n formatKey =>\n (override[formatKey] === undefined\n ? defaultFormatAppliers[formatKey]\n : override[formatKey]) as FormatApplier<any>\n )\n .concat((additionalAppliers[key] as FormatApplier<any>[]) || []);\n\n result[key] = value;\n\n return result;\n }, {} as FormatAppliersPerCategory);\n}\n"]}
1
+ {"version":3,"file":"defaultFormatHandlers.js","sourceRoot":"","sources":["../../../../packages-content-model/roosterjs-content-model-dom/lib/formatHandlers/defaultFormatHandlers.ts"],"names":[],"mappings":";;;;AAAA,sFAAqF;AACrF,iEAAgE;AAChE,0EAAyE;AACzE,oEAAmE;AACnE,0EAAyE;AACzE,sEAAqE;AACrE,yEAAwE;AACxE,qEAAoE;AACpE,kEAAiE;AACjE,6EAA4E;AAC5E,yEAAwE;AAExE,6DAAqD;AACrD,yEAAwE;AACxE,4DAA2D;AAC3D,qEAAoE;AACpE,mFAAkF;AAClF,2EAA0E;AAC1E,iEAAgE;AAChE,kFAAiF;AACjF,oFAAmF;AACnF,wFAAuF;AACvF,mEAAkE;AAClE,qEAAoE;AACpE,gEAA+D;AAC/D,qEAAoE;AACpE,yFAAwF;AACxF,6EAA4E;AAC5E,+EAA8E;AAC9E,yEAAwE;AACxE,2EAA0E;AAC1E,+FAA8F;AAC9F,2EAA0E;AAC1E,kFAAiF;AACjF,2EAA0E;AAC1E,0EAAyE;AAiBzE,IAAM,uBAAuB,GAAmB;IAC5C,eAAe,EAAE,2DAA4B;IAC7C,IAAI,EAAE,qCAAiB;IACvB,MAAM,EAAE,yCAAmB;IAC3B,SAAS,EAAE,+CAAsB;IACjC,SAAS,EAAE,+CAAsB;IACjC,OAAO,EAAE,2CAAoB;IAC7B,SAAS,EAAE,+CAAsB;IACjC,OAAO,EAAE,2CAAoB;IAC7B,KAAK,EAAE,uCAAkB;IACzB,UAAU,EAAE,iDAAuB;IACnC,QAAQ,EAAE,6CAAqB;IAC/B,SAAS,EAAE,+CAAsB;IACjC,EAAE,EAAE,iCAAe;IACnB,MAAM,EAAE,yCAAmB;IAC3B,aAAa,EAAE,uDAA0B;IACzC,UAAU,EAAE,iDAAuB;IACnC,IAAI,EAAE,qCAAiB;IACvB,cAAc,EAAE,yDAA2B;IAC3C,eAAe,EAAE,2DAA4B;IAC7C,iBAAiB,EAAE,+DAA8B;IACjD,MAAM,EAAE,yCAA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,UAAA,SAAS;YACL,OAAA,CAAC,QAAQ,CAAC,SAAS,CAAC,KAAK,SAAS;gBAC9B,CAAC,CAAC,6BAAqB,CAAC,SAAS,CAAC;gBAClC,CAAC,CAAC,QAAQ,CAAC,SAAS,CAAC,CAAuB;QAFhD,CAEgD,CACvD;aACA,MAAM,CAAE,kBAAkB,CAAC,GAAG,CAA0B,IAAI,EAAE,CAAC,CAAC;QAErE,MAAM,CAAC,GAAG,CAAC,GAAG,KAAK,CAAC;QAEpB,OAAO,MAAM,CAAC;IAClB,CAAC,EAAE,EAA+B,CAAC,CAAC;AACxC,CAAC;AAlBD,8CAkBC","sourcesContent":["import { backgroundColorFormatHandler } from './common/backgroundColorFormatHandler';\nimport { boldFormatHandler } from './segment/boldFormatHandler';\nimport { borderBoxFormatHandler } from './common/borderBoxFormatHandler';\nimport { borderFormatHandler } from './common/borderFormatHandler';\nimport { boxShadowFormatHandler } from './common/boxShadowFormatHandler';\nimport { datasetFormatHandler } from './common/datasetFormatHandler';\nimport { directionFormatHandler } from './block/directionFormatHandler';\nimport { displayFormatHandler } from './block/displayFormatHandler';\nimport { floatFormatHandler } from './common/floatFormatHandler';\nimport { fontFamilyFormatHandler } from './segment/fontFamilyFormatHandler';\nimport { fontSizeFormatHandler } from './segment/fontSizeFormatHandler';\nimport { FormatHandler } from './FormatHandler';\nimport { getObjectKeys } from 'roosterjs-editor-dom';\nimport { htmlAlignFormatHandler } from './block/htmlAlignFormatHandler';\nimport { idFormatHandler } from './common/idFormatHandler';\nimport { italicFormatHandler } from './segment/italicFormatHandler';\nimport { letterSpacingFormatHandler } from './segment/letterSpacingFormatHandler';\nimport { lineHeightFormatHandler } from './block/lineHeightFormatHandler';\nimport { linkFormatHandler } from './segment/linkFormatHandler';\nimport { listItemThreadFormatHandler } from './list/listItemThreadFormatHandler';\nimport { listLevelThreadFormatHandler } from './list/listLevelThreadFormatHandler';\nimport { listStylePositionFormatHandler } from './list/listStylePositionFormatHandler';\nimport { marginFormatHandler } from './block/marginFormatHandler';\nimport { paddingFormatHandler } from './block/paddingFormatHandler';\nimport { sizeFormatHandler } from './common/sizeFormatHandler';\nimport { strikeFormatHandler } from './segment/strikeFormatHandler';\nimport { superOrSubScriptFormatHandler } from './segment/superOrSubScriptFormatHandler';\nimport { tableLayoutFormatHandler } from './table/tableLayoutFormatHandler';\nimport { tableSpacingFormatHandler } from './table/tableSpacingFormatHandler';\nimport { textAlignFormatHandler } from './block/textAlignFormatHandler';\nimport { textColorFormatHandler } from './segment/textColorFormatHandler';\nimport { textColorOnTableCellFormatHandler } from './table/textColorOnTableCellFormatHandler';\nimport { underlineFormatHandler } from './segment/underlineFormatHandler';\nimport { verticalAlignFormatHandler } from './common/verticalAlignFormatHandler';\nimport { whiteSpaceFormatHandler } from './block/whiteSpaceFormatHandler';\nimport { wordBreakFormatHandler } from './common/wordBreakFormatHandler';\nimport {\n ContentModelFormatMap,\n FormatHandlerTypeMap,\n FormatKey,\n FormatApplier,\n FormatAppliers,\n FormatAppliersPerCategory,\n FormatParser,\n FormatParsers,\n FormatParsersPerCategory,\n} from 'roosterjs-content-model-types';\n\ntype FormatHandlers = {\n [Key in FormatKey]: FormatHandler<FormatHandlerTypeMap[Key]>;\n};\n\nconst defaultFormatHandlerMap: FormatHandlers = {\n backgroundColor: backgroundColorFormatHandler,\n bold: boldFormatHandler,\n border: borderFormatHandler,\n borderBox: borderBoxFormatHandler,\n boxShadow: boxShadowFormatHandler,\n dataset: datasetFormatHandler,\n direction: directionFormatHandler,\n display: displayFormatHandler,\n float: floatFormatHandler,\n fontFamily: fontFamilyFormatHandler,\n fontSize: fontSizeFormatHandler,\n htmlAlign: htmlAlignFormatHandler,\n id: idFormatHandler,\n italic: italicFormatHandler,\n letterSpacing: letterSpacingFormatHandler,\n lineHeight: lineHeightFormatHandler,\n link: linkFormatHandler,\n listItemThread: listItemThreadFormatHandler,\n listLevelThread: listLevelThreadFormatHandler,\n listStylePosition: listStylePositionFormatHandler,\n margin: marginFormatHandler,\n padding: paddingFormatHandler,\n size: sizeFormatHandler,\n strike: strikeFormatHandler,\n superOrSubScript: superOrSubScriptFormatHandler,\n tableLayout: tableLayoutFormatHandler,\n tableSpacing: tableSpacingFormatHandler,\n textAlign: textAlignFormatHandler,\n textColor: textColorFormatHandler,\n textColorOnTableCell: textColorOnTableCellFormatHandler,\n underline: underlineFormatHandler,\n verticalAlign: verticalAlignFormatHandler,\n whiteSpace: whiteSpaceFormatHandler,\n wordBreak: wordBreakFormatHandler,\n};\n\nconst styleBasedSegmentFormats: (keyof FormatHandlerTypeMap)[] = [\n 'letterSpacing',\n 'fontFamily',\n 'fontSize',\n];\n\nconst elementBasedSegmentFormats: (keyof FormatHandlerTypeMap)[] = [\n 'strike',\n 'underline',\n 'superOrSubScript',\n 'italic',\n 'bold',\n];\nconst sharedBlockFormats: (keyof FormatHandlerTypeMap)[] = [\n 'direction',\n 'textAlign',\n 'lineHeight',\n 'whiteSpace',\n];\nconst sharedContainerFormats: (keyof FormatHandlerTypeMap)[] = [\n 'backgroundColor',\n 'margin',\n 'padding',\n 'border',\n];\n\nconst defaultFormatKeysPerCategory: {\n [key in keyof ContentModelFormatMap]: (keyof FormatHandlerTypeMap)[];\n} = {\n block: sharedBlockFormats,\n listItem: ['listItemThread'],\n listItemElement: [...sharedBlockFormats, 'direction', 'textAlign', 'lineHeight', 'margin'],\n listLevel: [\n 'listLevelThread',\n 'direction',\n 'textAlign',\n 'margin',\n 'padding',\n 'listStylePosition',\n 'backgroundColor',\n ],\n styleBasedSegment: [...styleBasedSegmentFormats, 'textColor', 'backgroundColor', 'lineHeight'],\n elementBasedSegment: elementBasedSegmentFormats,\n segment: [\n ...styleBasedSegmentFormats,\n ...elementBasedSegmentFormats,\n 'textColor',\n 'backgroundColor',\n 'lineHeight',\n ],\n segmentOnBlock: [...styleBasedSegmentFormats, ...elementBasedSegmentFormats, 'textColor'],\n segmentOnTableCell: [\n ...styleBasedSegmentFormats,\n ...elementBasedSegmentFormats,\n 'textColorOnTableCell',\n ],\n tableCell: [\n 'border',\n 'backgroundColor',\n 'padding',\n 'verticalAlign',\n 'wordBreak',\n 'textColor',\n 'htmlAlign',\n 'size',\n ],\n tableRow: ['backgroundColor'],\n table: [\n 'id',\n 'border',\n 'backgroundColor',\n 'display',\n 'htmlAlign',\n 'margin',\n 'size',\n 'tableLayout',\n ],\n tableBorder: ['borderBox', 'tableSpacing'],\n tableCellBorder: ['borderBox'],\n image: [\n 'id',\n 'size',\n 'margin',\n 'padding',\n 'borderBox',\n 'border',\n 'boxShadow',\n 'display',\n 'float',\n 'verticalAlign',\n ],\n link: [\n 'link',\n 'textColor',\n 'underline',\n 'display',\n 'margin',\n 'padding',\n 'backgroundColor',\n 'border',\n 'size',\n 'textAlign',\n ],\n segmentUnderLink: ['textColor'],\n code: ['fontFamily', 'display'],\n dataset: ['dataset'],\n divider: [...sharedBlockFormats, ...sharedContainerFormats, 'display', 'size', 'htmlAlign'],\n container: [...sharedContainerFormats, 'htmlAlign', 'size', 'display'],\n};\n\n/**\n * @internal\n */\nexport const defaultFormatParsers: FormatParsers = getObjectKeys(defaultFormatHandlerMap).reduce(\n (result, key) => {\n result[key] = defaultFormatHandlerMap[key].parse as FormatParser<any>;\n return result;\n },\n <FormatParsers>{}\n);\n\n/**\n * @internal\n */\nexport const defaultFormatAppliers: FormatAppliers = getObjectKeys(defaultFormatHandlerMap).reduce(\n (result, key) => {\n result[key] = defaultFormatHandlerMap[key].apply as FormatApplier<any>;\n return result;\n },\n <FormatAppliers>{}\n);\n\n/**\n * @internal\n */\nexport function getFormatParsers(\n override: Partial<FormatParsers> = {},\n additionalParsers: Partial<FormatParsersPerCategory> = {}\n): FormatParsersPerCategory {\n return getObjectKeys(defaultFormatKeysPerCategory).reduce((result, key) => {\n const value = defaultFormatKeysPerCategory[key]\n .map(\n formatKey =>\n (override[formatKey] === undefined\n ? defaultFormatParsers[formatKey]\n : override[formatKey]) as FormatParser<any>\n )\n .concat((additionalParsers[key] as FormatParser<any>[]) || []);\n\n result[key] = value;\n\n return result;\n }, {} as FormatParsersPerCategory);\n}\n\n/**\n * @internal\n */\nexport function getFormatAppliers(\n override: Partial<FormatAppliers> = {},\n additionalAppliers: Partial<FormatAppliersPerCategory> = {}\n): FormatAppliersPerCategory {\n return getObjectKeys(defaultFormatKeysPerCategory).reduce((result, key) => {\n const value = defaultFormatKeysPerCategory[key]\n .map(\n formatKey =>\n (override[formatKey] === undefined\n ? defaultFormatAppliers[formatKey]\n : override[formatKey]) as FormatApplier<any>\n )\n .concat((additionalAppliers[key] as FormatApplier<any>[]) || []);\n\n result[key] = value;\n\n return result;\n }, {} as FormatAppliersPerCategory);\n}\n"]}
@@ -2,6 +2,7 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.fontSizeFormatHandler = void 0;
4
4
  var superOrSubScriptFormatHandler_1 = require("./superOrSubScriptFormatHandler");
5
+ var parseValueWithUnit_1 = require("../utils/parseValueWithUnit");
5
6
  /**
6
7
  * @internal
7
8
  */
@@ -12,7 +13,12 @@ exports.fontSizeFormatHandler = {
12
13
  // when font size is 'smaller' and the style is for superscript/subscript,
13
14
  // the font size will be handled by superOrSubScript handler
14
15
  if (fontSize && !(0, superOrSubScriptFormatHandler_1.isSuperOrSubScript)(fontSize, verticalAlign) && fontSize != 'inherit') {
15
- format.fontSize = fontSize;
16
+ if (element.style.fontSize) {
17
+ format.fontSize = normalizeFontSize(fontSize, context.segmentFormat.fontSize);
18
+ }
19
+ else if (defaultStyle.fontSize) {
20
+ format.fontSize = fontSize;
21
+ }
16
22
  }
17
23
  },
18
24
  apply: function (format, element, context) {
@@ -21,4 +27,48 @@ exports.fontSizeFormatHandler = {
21
27
  }
22
28
  },
23
29
  };
30
+ // https://developer.mozilla.org/en-US/docs/Web/CSS/font-size
31
+ var KnownFontSizes = {
32
+ 'xx-small': '6.75pt',
33
+ 'x-small': '7.5pt',
34
+ small: '9.75pt',
35
+ medium: '12pt',
36
+ large: '13.5pt',
37
+ 'x-large': '18pt',
38
+ 'xx-large': '24pt',
39
+ 'xxx-large': '36pt',
40
+ };
41
+ function normalizeFontSize(fontSize, contextFont) {
42
+ var knownFontSize = KnownFontSizes[fontSize];
43
+ if (knownFontSize) {
44
+ return knownFontSize;
45
+ }
46
+ else if (fontSize == 'smaller' ||
47
+ fontSize == 'larger' ||
48
+ fontSize.endsWith('em') ||
49
+ fontSize.endsWith('%')) {
50
+ if (!contextFont) {
51
+ return undefined;
52
+ }
53
+ else {
54
+ var existingFontSize = (0, parseValueWithUnit_1.parseValueWithUnit)(contextFont, undefined /*element*/, 'px');
55
+ if (existingFontSize) {
56
+ switch (fontSize) {
57
+ case 'smaller':
58
+ return Math.round((existingFontSize * 500) / 6) / 100 + 'px';
59
+ case 'larger':
60
+ return Math.round((existingFontSize * 600) / 5) / 100 + 'px';
61
+ default:
62
+ return (0, parseValueWithUnit_1.parseValueWithUnit)(fontSize, existingFontSize, 'px') + 'px';
63
+ }
64
+ }
65
+ }
66
+ }
67
+ else if (fontSize == 'inherit' || fontSize == 'revert' || fontSize == 'unset') {
68
+ return undefined;
69
+ }
70
+ else {
71
+ return fontSize;
72
+ }
73
+ }
24
74
  //# sourceMappingURL=fontSizeFormatHandler.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"fontSizeFormatHandler.js","sourceRoot":"","sources":["../../../../../packages-content-model/roosterjs-content-model-dom/lib/formatHandlers/segment/fontSizeFormatHandler.ts"],"names":[],"mappings":";;;AAEA,iFAAqE;AAErE;;GAEG;AACU,QAAA,qBAAqB,GAAkC;IAChE,KAAK,EAAE,UAAC,MAAM,EAAE,OAAO,EAAE,OAAO,EAAE,YAAY;QAC1C,IAAM,QAAQ,GAAG,OAAO,CAAC,KAAK,CAAC,QAAQ,IAAI,YAAY,CAAC,QAAQ,CAAC;QACjE,IAAM,aAAa,GAAG,OAAO,CAAC,KAAK,CAAC,aAAa,IAAI,YAAY,CAAC,aAAa,CAAC;QAEhF,0EAA0E;QAC1E,4DAA4D;QAC5D,IAAI,QAAQ,IAAI,CAAC,IAAA,kDAAkB,EAAC,QAAQ,EAAE,aAAa,CAAC,IAAI,QAAQ,IAAI,SAAS,EAAE;YACnF,MAAM,CAAC,QAAQ,GAAG,QAAQ,CAAC;SAC9B;IACL,CAAC;IACD,KAAK,EAAE,UAAC,MAAM,EAAE,OAAO,EAAE,OAAO;QAC5B,IAAI,MAAM,CAAC,QAAQ,IAAI,MAAM,CAAC,QAAQ,IAAI,OAAO,CAAC,cAAc,CAAC,QAAQ,EAAE;YACvE,OAAO,CAAC,KAAK,CAAC,QAAQ,GAAG,MAAM,CAAC,QAAQ,CAAC;SAC5C;IACL,CAAC;CACJ,CAAC","sourcesContent":["import { FontSizeFormat } from 'roosterjs-content-model-types';\nimport { FormatHandler } from '../FormatHandler';\nimport { isSuperOrSubScript } from './superOrSubScriptFormatHandler';\n\n/**\n * @internal\n */\nexport const fontSizeFormatHandler: FormatHandler<FontSizeFormat> = {\n parse: (format, element, context, defaultStyle) => {\n const fontSize = element.style.fontSize || defaultStyle.fontSize;\n const verticalAlign = element.style.verticalAlign || defaultStyle.verticalAlign;\n\n // when font size is 'smaller' and the style is for superscript/subscript,\n // the font size will be handled by superOrSubScript handler\n if (fontSize && !isSuperOrSubScript(fontSize, verticalAlign) && fontSize != 'inherit') {\n format.fontSize = fontSize;\n }\n },\n apply: (format, element, context) => {\n if (format.fontSize && format.fontSize != context.implicitFormat.fontSize) {\n element.style.fontSize = format.fontSize;\n }\n },\n};\n"]}
1
+ {"version":3,"file":"fontSizeFormatHandler.js","sourceRoot":"","sources":["../../../../../packages-content-model/roosterjs-content-model-dom/lib/formatHandlers/segment/fontSizeFormatHandler.ts"],"names":[],"mappings":";;;AAEA,iFAAqE;AACrE,kEAAiE;AAEjE;;GAEG;AACU,QAAA,qBAAqB,GAAkC;IAChE,KAAK,EAAE,UAAC,MAAM,EAAE,OAAO,EAAE,OAAO,EAAE,YAAY;QAC1C,IAAM,QAAQ,GAAG,OAAO,CAAC,KAAK,CAAC,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AAI,QAAQ;QACpB,QAAQ,CAAC,QAAQ,CAAC,IAAI,CAAC;QACvB,QAAQ,CAAC,QAAQ,CAAC,GAAG,CAAC,EACxB;QACE,IAAI,CAAC,WAAW,EAAE;YACd,OAAO,SAAS,CAAC;SACpB;aAAM;YACH,IAAM,gBAAgB,GAAG,IAAA,uCAAkB,EAAC,WAAW,EAAE,SAAS,CAAC,WAAW,EAAE,IAAI,CAAC,CAAC;YAEtF,IAAI,gBAAgB,EAAE;gBAClB,QAAQ,QAAQ,EAAE;oBACd,KAAK,SAAS;wBACV,OAAO,IAAI,CAAC,KAAK,CAAC,CAAC,gBAAgB,GAAG,GAAG,CAAC,GAAG,CAAC,CAAC,GAAG,GAAG,GAAG,IAAI,CAAC;oBACjE,KAAK,QAAQ;wBACT,OAAO,IAAI,CAAC,KAAK,CAAC,CAAC,gBAAgB,GAAG,GAAG,CAAC,GAAG,CAAC,CAAC,GAAG,GAAG,GAAG,IAAI,CAAC;oBACjE;wBACI,OAAO,IAAA,uCAAkB,EAAC,QAAQ,EAAE,gBAAgB,EAAE,IAAI,CAAC,GAAG,IAAI,CAAC;iBAC1E;aACJ;SACJ;KACJ;SAAM,IAAI,QAAQ,IAAI,SAAS,IAAI,QAAQ,IAAI,QAAQ,IAAI,QAAQ,IAAI,OAAO,EAAE;QAC7E,OAAO,SAAS,CAAC;KACpB;SAAM;QACH,OAAO,QAAQ,CAAC;KACnB;AACL,CAAC","sourcesContent":["import { FontSizeFormat } from 'roosterjs-content-model-types';\nimport { FormatHandler } from '../FormatHandler';\nimport { isSuperOrSubScript } from './superOrSubScriptFormatHandler';\nimport { parseValueWithUnit } from '../utils/parseValueWithUnit';\n\n/**\n * @internal\n */\nexport const fontSizeFormatHandler: FormatHandler<FontSizeFormat> = {\n parse: (format, element, context, defaultStyle) => {\n const fontSize = element.style.fontSize || defaultStyle.fontSize;\n const verticalAlign = element.style.verticalAlign || defaultStyle.verticalAlign;\n\n // when font size is 'smaller' and the style is for superscript/subscript,\n // the font size will be handled by superOrSubScript handler\n if (fontSize && !isSuperOrSubScript(fontSize, verticalAlign) && fontSize != 'inherit') {\n if (element.style.fontSize) {\n format.fontSize = normalizeFontSize(fontSize, context.segmentFormat.fontSize);\n } else if (defaultStyle.fontSize) {\n format.fontSize = fontSize;\n }\n }\n },\n apply: (format, element, context) => {\n if (format.fontSize && format.fontSize != context.implicitFormat.fontSize) {\n element.style.fontSize = format.fontSize;\n }\n },\n};\n\n// https://developer.mozilla.org/en-US/docs/Web/CSS/font-size\nconst KnownFontSizes: Record<string, string> = {\n 'xx-small': '6.75pt',\n 'x-small': '7.5pt',\n small: '9.75pt',\n medium: '12pt',\n large: '13.5pt',\n 'x-large': '18pt',\n 'xx-large': '24pt',\n 'xxx-large': '36pt',\n};\n\nfunction normalizeFontSize(fontSize: string, contextFont: string | undefined): string | undefined {\n const knownFontSize = KnownFontSizes[fontSize];\n\n if (knownFontSize) {\n return knownFontSize;\n } else if (\n fontSize == 'smaller' ||\n fontSize == 'larger' ||\n fontSize.endsWith('em') ||\n fontSize.endsWith('%')\n ) {\n if (!contextFont) {\n return undefined;\n } else {\n const existingFontSize = parseValueWithUnit(contextFont, undefined /*element*/, 'px');\n\n if (existingFontSize) {\n switch (fontSize) {\n case 'smaller':\n return Math.round((existingFontSize * 500) / 6) / 100 + 'px';\n case 'larger':\n return Math.round((existingFontSize * 600) / 5) / 100 + 'px';\n default:\n return parseValueWithUnit(fontSize, existingFontSize, 'px') + 'px';\n }\n }\n }\n } else if (fontSize == 'inherit' || fontSize == 'revert' || fontSize == 'unset') {\n return undefined;\n } else {\n return fontSize;\n }\n}\n"]}
@@ -161,7 +161,7 @@ exports.defaultImplicitFormatMap = (_a = {
161
161
  },
162
162
  h4: {
163
163
  fontWeight: 'bold',
164
- fontSize: '1em', // Set this default value here to overwrite existing font size when change header level
164
+ fontSize: '1em', // Set this default value here to overwrite existing font size when change heading level
165
165
  },
166
166
  h5: {
167
167
  fontWeight: 'bold',
@@ -1 +1 @@
1
- {"version":3,"file":"defaultStyles.js","sourceRoot":"","sources":["../../../../../packages-content-model/roosterjs-content-model-dom/lib/formatHandlers/utils/defaultStyles.ts"],"names":[],"mappings":";;;;AAEA,IAAM,YAAY,GAAiC;IAC/C,OAAO,EAAE,OAAO;CACnB,CAAC;AAEF;;GAEG;AACU,QAAA,eAAe,GAAoB;IAC5C,OAAO,EAAE,YAAY;IACrB,OAAO,EAAE,YAAY;IACrB,KAAK,EAAE,YAAY;IACnB,CAAC,EAAE;QACC,UAAU,EAAE,MAAM;KACrB;IACD,UAAU,EAAE;QACR,OAAO,EAAE,OAAO;QAChB,SAAS,EAAE,KAAK;QAChB,YAAY,EAAE,KAAK;QACnB,UAAU,EAAE,MAAM;QAClB,WAAW,EAAE,MAAM;KACtB;IACD,EAAE,EAAE,YAAY;IAChB,MAAM,EAAE;QACJ,OAAO,EAAE,OAAO;QAChB,SAAS,EAAE,QAAQ;KACtB;IACD,EAAE,EAAE,YAAY;IAChB,GAAG,EAAE,YAAY;IACjB,EAAE,EAAE,YAAY;IAChB,EAAE,EAAE,YAAY;IAChB,EAAE,EAAE;QACA,SAAS,EAAE,QAAQ;KACtB;IACD,QAAQ,EAAE,YAAY;IACtB,UAAU,EAAE,YAAY;IACxB,MAAM,EAAE,YAAY;IACpB,MAAM,EAAE,YAAY;IACpB,IAAI,EAAE,YAAY;IAClB,EAAE,EAAE;QACA,OAAO,EAAE,OAAO;QAChB,UAAU,EAAE,MAAM;QAClB,QAAQ,EAAE,KAAK;KAClB;IACD,EAAE,EAAE;QACA,OAAO,EAAE,OAAO;QAChB,UAAU,EAAE,MAAM;QAClB,QAAQ,EAAE,OAAO;KACpB;IACD,EAAE,EAAE;QACA,OAAO,EAAE,OAAO;QAChB,UAAU,EAAE,MAAM;QAClB,QAAQ,EAAE,QAAQ;KACrB;IACD,EAAE,EAAE;QACA,OAAO,EAAE,OAAO;QAChB,UAAU,EAAE,MAAM;KACrB;IACD,EAAE,EAAE;QACA,OAAO,EAAE,OA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B,CAAC,EAFiB,cAAc,GAAd,sBAAc,KAAd,sBAAc,QAE/B;AAED;;GAEG;AACU,QAAA,wBAAwB;QACjC,CAAC,EAAE;YACC,SAAS,EAAE,IAAI;SAClB;QACD,UAAU,EAAE;YACR,SAAS,EAAE,KAAK;YAChB,YAAY,EAAE,KAAK;YACnB,UAAU,EAAE,MAAM;YAClB,WAAW,EAAE,MAAM;SACtB;QACD,IAAI,EAAE;YACF,UAAU,EAAE,WAAW;SAC1B;QACD,EAAE,EAAE;YACA,UAAU,EAAE,MAAM;YAClB,QAAQ,EAAE,KAAK;SAClB;QACD,EAAE,EAAE;YACA,UAAU,EAAE,MAAM;YAClB,QAAQ,EAAE,OAAO;SACpB;QACD,EAAE,EAAE;YACA,UAAU,EAAE,MAAM;YAClB,QAAQ,EAAE,QAAQ;SACrB;QACD,EAAE,EAAE;YACA,UAAU,EAAE,MAAM;YAClB,QAAQ,EAAE,KAAK,EAAE,uFAAuF;SAC3G;QACD,EAAE,EAAE;YACA,UAAU,EAAE,MAAM;YAClB,QAAQ,EAAE,QAAQ;SACrB;QACD,EAAE,EAAE;YACA,UAAU,EAAE,MAAM;YAClB,QAAQ,EAAE,QAAQ;SACrB;QACD,CAAC,EAAE;YACC,SAAS,EAAE,KAAK;YAChB,YAAY,EAAE,KAAK;SACtB;QACD,GAAG,EAAE;YACD,UAAU,EAAE,WAAW;YACvB,UAAU,EAAE,KAAK;YACjB,SAAS,EAAE,KAAK;YAChB,YAAY,EAAE,KAAK;SACtB;;IAED,uEAAuE;IACvE,wFAAwF;IACxF,+BAA6B;QACzB,UAAU,EAAE,WAAW;QACvB,UAAU,EAAE,KAAK;KACpB;QACH","sourcesContent":["import { DefaultImplicitFormatMap, DefaultStyleMap } from 'roosterjs-content-model-types';\n\nconst blockElement: Partial<CSSStyleDeclaration> = {\n display: 'block',\n};\n\n/**\n * @internal\n */\nexport const defaultStyleMap: DefaultStyleMap = {\n address: blockElement,\n article: blockElement,\n aside: blockElement,\n b: {\n fontWeight: 'bold',\n },\n blockquote: {\n display: 'block',\n marginTop: '1em',\n marginBottom: '1em',\n marginLeft: '40px',\n marginRight: '40px',\n },\n br: blockElement,\n center: {\n display: 'block',\n textAlign: 'center',\n },\n dd: blockElement,\n div: blockElement,\n dl: blockElement,\n dt: blockElement,\n em: {\n fontStyle: 'italic',\n },\n fieldset: blockElement,\n figcaption: blockElement,\n figure: blockElement,\n footer: blockElement,\n form: blockElement,\n h1: {\n display: 'block',\n fontWeight: 'bold',\n fontSize: '2em',\n },\n h2: {\n display: 'block',\n fontWeight: 'bold',\n fontSize: '1.5em',\n },\n h3: {\n display: 'block',\n fontWeight: 'bold',\n fontSize: '1.17em',\n },\n h4: {\n display: 'block',\n fontWeight: 'bold',\n },\n h5: {\n display: 'block',\n fontWeight: 'bold',\n fontSize: '0.83em',\n },\n h6: {\n display: 'block',\n fontWeight: 'bold',\n fontSize: '0.67em',\n },\n header: blockElement,\n hr: blockElement,\n i: {\n fontStyle: 'italic',\n },\n li: {\n display: 'list-item',\n },\n main: blockElement,\n nav: blockElement,\n ol: blockElement,\n p: {\n display: 'block',\n marginTop: '1em',\n marginBottom: '1em',\n },\n pre: {\n display: 'block',\n fontFamily: 'monospace',\n whiteSpace: 'pre',\n marginTop: '1em',\n marginBottom: '1em',\n },\n s: {\n textDecoration: 'line-through',\n },\n section: blockElement,\n strike: {\n textDecoration: 'line-through',\n },\n strong: {\n fontWeight: 'bold',\n },\n sub: {\n verticalAlign: 'sub',\n fontSize: 'smaller',\n },\n sup: {\n verticalAlign: 'super',\n fontSize: 'smaller',\n },\n table: {\n display: 'table',\n boxSizing: 'border-box',\n },\n td: {\n display: 'table-cell',\n },\n th: {\n display: 'table-cell',\n },\n u: {\n textDecoration: 'underline',\n },\n ul: blockElement,\n};\n\n/**\n * @internal\n */\nexport const enum PseudoTagNames {\n childOfPre = 'pre *', // This value is not a CSS selector, it just to tell this will impact elements under PRE tag. Any unique value here can work actually\n}\n\n/**\n * A map from tag name to its default implicit formats\n */\nexport const defaultImplicitFormatMap: DefaultImplicitFormatMap = {\n a: {\n underline: true,\n },\n blockquote: {\n marginTop: '1em',\n marginBottom: '1em',\n marginLeft: '40px',\n marginRight: '40px',\n },\n code: {\n fontFamily: 'monospace',\n },\n h1: {\n fontWeight: 'bold',\n fontSize: '2em',\n },\n h2: {\n fontWeight: 'bold',\n fontSize: '1.5em',\n },\n h3: {\n fontWeight: 'bold',\n fontSize: '1.17em',\n },\n h4: {\n fontWeight: 'bold',\n fontSize: '1em', // Set this default value here to overwrite existing font size when change header level\n },\n h5: {\n fontWeight: 'bold',\n fontSize: '0.83em',\n },\n h6: {\n fontWeight: 'bold',\n fontSize: '0.67em',\n },\n p: {\n marginTop: '1em',\n marginBottom: '1em',\n },\n pre: {\n fontFamily: 'monospace',\n whiteSpace: 'pre',\n marginTop: '1em',\n marginBottom: '1em',\n },\n\n // For PRE tag, the following styles will be included from the PRE tag.\n // Adding this implicit style here so no need to generate these style for child elements\n [PseudoTagNames.childOfPre]: {\n fontFamily: 'monospace',\n whiteSpace: 'pre',\n },\n};\n"]}
1
+ {"version":3,"file":"defaultStyles.js","sourceRoot":"","sources":["../../../../../packages-content-model/roosterjs-content-model-dom/lib/formatHandlers/utils/defaultStyles.ts"],"names":[],"mappings":";;;;AAEA,IAAM,YAAY,GAAiC;IAC/C,OAAO,EAAE,OAAO;CACnB,CAAC;AAEF;;GAEG;AACU,QAAA,eAAe,GAAoB;IAC5C,OAAO,EAAE,YAAY;IACrB,OAAO,EAAE,YAAY;IACrB,KAAK,EAAE,YAAY;IACnB,CAAC,EAAE;QACC,UAAU,EAAE,MAAM;KACrB;IACD,UAAU,EAAE;QACR,OAAO,EAAE,OAAO;QAChB,SAAS,EAAE,KAAK;QAChB,YAAY,EAAE,KAAK;QACnB,UAAU,EAAE,MAAM;QAClB,WAAW,EAAE,MAAM;KACtB;IACD,EAAE,EAAE,YAAY;IAChB,MAAM,EAAE;QACJ,OAAO,EAAE,OAAO;QAChB,SAAS,EA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QAAQ,EAAE,KAAK,EAAE,wFAAwF;SAC5G;QACD,EAAE,EAAE;YACA,UAAU,EAAE,MAAM;YAClB,QAAQ,EAAE,QAAQ;SACrB;QACD,EAAE,EAAE;YACA,UAAU,EAAE,MAAM;YAClB,QAAQ,EAAE,QAAQ;SACrB;QACD,CAAC,EAAE;YACC,SAAS,EAAE,KAAK;YAChB,YAAY,EAAE,KAAK;SACtB;QACD,GAAG,EAAE;YACD,UAAU,EAAE,WAAW;YACvB,UAAU,EAAE,KAAK;YACjB,SAAS,EAAE,KAAK;YAChB,YAAY,EAAE,KAAK;SACtB;;IAED,uEAAuE;IACvE,wFAAwF;IACxF,+BAA6B;QACzB,UAAU,EAAE,WAAW;QACvB,UAAU,EAAE,KAAK;KACpB;QACH","sourcesContent":["import { DefaultImplicitFormatMap, DefaultStyleMap } from 'roosterjs-content-model-types';\n\nconst blockElement: Partial<CSSStyleDeclaration> = {\n display: 'block',\n};\n\n/**\n * @internal\n */\nexport const defaultStyleMap: DefaultStyleMap = {\n address: blockElement,\n article: blockElement,\n aside: blockElement,\n b: {\n fontWeight: 'bold',\n },\n blockquote: {\n display: 'block',\n marginTop: '1em',\n marginBottom: '1em',\n marginLeft: '40px',\n marginRight: '40px',\n },\n br: blockElement,\n center: {\n display: 'block',\n textAlign: 'center',\n },\n dd: blockElement,\n div: blockElement,\n dl: blockElement,\n dt: blockElement,\n em: {\n fontStyle: 'italic',\n },\n fieldset: blockElement,\n figcaption: blockElement,\n figure: blockElement,\n footer: blockElement,\n form: blockElement,\n h1: {\n display: 'block',\n fontWeight: 'bold',\n fontSize: '2em',\n },\n h2: {\n display: 'block',\n fontWeight: 'bold',\n fontSize: '1.5em',\n },\n h3: {\n display: 'block',\n fontWeight: 'bold',\n fontSize: '1.17em',\n },\n h4: {\n display: 'block',\n fontWeight: 'bold',\n },\n h5: {\n display: 'block',\n fontWeight: 'bold',\n fontSize: '0.83em',\n },\n h6: {\n display: 'block',\n fontWeight: 'bold',\n fontSize: '0.67em',\n },\n header: blockElement,\n hr: blockElement,\n i: {\n fontStyle: 'italic',\n },\n li: {\n display: 'list-item',\n },\n main: blockElement,\n nav: blockElement,\n ol: blockElement,\n p: {\n display: 'block',\n marginTop: '1em',\n marginBottom: '1em',\n },\n pre: {\n display: 'block',\n fontFamily: 'monospace',\n whiteSpace: 'pre',\n marginTop: '1em',\n marginBottom: '1em',\n },\n s: {\n textDecoration: 'line-through',\n },\n section: blockElement,\n strike: {\n textDecoration: 'line-through',\n },\n strong: {\n fontWeight: 'bold',\n },\n sub: {\n verticalAlign: 'sub',\n fontSize: 'smaller',\n },\n sup: {\n verticalAlign: 'super',\n fontSize: 'smaller',\n },\n table: {\n display: 'table',\n boxSizing: 'border-box',\n },\n td: {\n display: 'table-cell',\n },\n th: {\n display: 'table-cell',\n },\n u: {\n textDecoration: 'underline',\n },\n ul: blockElement,\n};\n\n/**\n * @internal\n */\nexport const enum PseudoTagNames {\n childOfPre = 'pre *', // This value is not a CSS selector, it just to tell this will impact elements under PRE tag. Any unique value here can work actually\n}\n\n/**\n * A map from tag name to its default implicit formats\n */\nexport const defaultImplicitFormatMap: DefaultImplicitFormatMap = {\n a: {\n underline: true,\n },\n blockquote: {\n marginTop: '1em',\n marginBottom: '1em',\n marginLeft: '40px',\n marginRight: '40px',\n },\n code: {\n fontFamily: 'monospace',\n },\n h1: {\n fontWeight: 'bold',\n fontSize: '2em',\n },\n h2: {\n fontWeight: 'bold',\n fontSize: '1.5em',\n },\n h3: {\n fontWeight: 'bold',\n fontSize: '1.17em',\n },\n h4: {\n fontWeight: 'bold',\n fontSize: '1em', // Set this default value here to overwrite existing font size when change heading level\n },\n h5: {\n fontWeight: 'bold',\n fontSize: '0.83em',\n },\n h6: {\n fontWeight: 'bold',\n fontSize: '0.67em',\n },\n p: {\n marginTop: '1em',\n marginBottom: '1em',\n },\n pre: {\n fontFamily: 'monospace',\n whiteSpace: 'pre',\n marginTop: '1em',\n marginBottom: '1em',\n },\n\n // For PRE tag, the following styles will be included from the PRE tag.\n // Adding this implicit style here so no need to generate these style for child elements\n [PseudoTagNames.childOfPre]: {\n fontFamily: 'monospace',\n whiteSpace: 'pre',\n },\n};\n"]}
@@ -1,7 +1,7 @@
1
1
  /**
2
2
  * Parse unit value with its unit
3
3
  * @param value The source value to parse
4
- * @param element The source element which has this unit value.
4
+ * @param currentSizePxOrElement The source element which has this unit value, or current font size (in px) from context.
5
5
  * @param resultUnit Unit for result, can be px or pt. @default px
6
6
  */
7
- export declare function parseValueWithUnit(value?: string, element?: HTMLElement, resultUnit?: 'px' | 'pt'): number;
7
+ export declare function parseValueWithUnit(value?: string, currentSizePxOrElement?: number | HTMLElement, resultUnit?: 'px' | 'pt'): number;