devexpress-richedit 24.1.1-alpha-24085-0102 → 24.1.2-beta

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 (200) hide show
  1. package/bin/gulpfile.js +1 -1
  2. package/bin/index-custom.js +1 -1
  3. package/bin/localization-builder.js +1 -1
  4. package/bin/nspell-index.js +1 -1
  5. package/bin/nspell.webpack.config.js +1 -1
  6. package/bin/webpack-externals.js +3 -1
  7. package/bin/webpack.config.js +1 -1
  8. package/dist/dx.richedit.css +1 -0
  9. package/dist/dx.richedit.d.ts +17 -10
  10. package/dist/dx.richedit.js +52855 -51531
  11. package/dist/dx.richedit.min.js +2 -2
  12. package/index.d.ts +1 -1
  13. package/index.js +1 -1
  14. package/lib/client/bars/ribbon.js +2 -1
  15. package/lib/client/bars/rich-edit-ribbon/ribbon-items-data.js +2 -1
  16. package/lib/client/client-rich-edit.js +2 -1
  17. package/lib/client/commands/client-command-manager.js +2 -1
  18. package/lib/client/commands/commands.js +3 -0
  19. package/lib/client/commands/download-document-command.d.ts +3 -0
  20. package/lib/client/commands/download-document-command.js +13 -2
  21. package/lib/client/commands/export-document-command.js +4 -4
  22. package/lib/client/commands/mail-merge-command.js +7 -4
  23. package/lib/client/commands/open-document-command.d.ts +2 -1
  24. package/lib/client/commands/open-document-command.js +17 -12
  25. package/lib/client/default-localization.js +2 -1
  26. package/lib/client/dialogs/finish-and-merge-dialog.js +1 -0
  27. package/lib/client/document-processor/processor.d.ts +9 -2
  28. package/lib/client/document-processor/processor.js +18 -6
  29. package/lib/client/formats/docx/export/data.d.ts +4 -0
  30. package/lib/client/formats/docx/export/data.js +12 -0
  31. package/lib/client/formats/docx/export/exporter.d.ts +2 -0
  32. package/lib/client/formats/docx/export/exporter.js +15 -0
  33. package/lib/client/formats/docx/export/exporters/base/sections.js +5 -0
  34. package/lib/client/formats/docx/export/exporters/note-properties.d.ts +18 -0
  35. package/lib/client/formats/docx/export/exporters/note-properties.js +83 -0
  36. package/lib/client/formats/docx/export/exporters/settings.d.ts +2 -0
  37. package/lib/client/formats/docx/export/exporters/settings.js +11 -0
  38. package/lib/client/formats/docx/export/exporters/sub-document/base-sub-document.d.ts +15 -1
  39. package/lib/client/formats/docx/export/exporters/sub-document/base-sub-document.js +85 -3
  40. package/lib/client/formats/docx/export/exporters/sub-document/header-footer-sub-document-exporter.d.ts +2 -2
  41. package/lib/client/formats/docx/export/exporters/sub-document/header-footer-sub-document-exporter.js +2 -2
  42. package/lib/client/formats/docx/export/exporters/sub-document/main-sub-document.d.ts +2 -2
  43. package/lib/client/formats/docx/export/exporters/sub-document/main-sub-document.js +2 -2
  44. package/lib/client/formats/docx/export/exporters/sub-document/note-sub-document-exporter.d.ts +37 -0
  45. package/lib/client/formats/docx/export/exporters/sub-document/note-sub-document-exporter.js +71 -0
  46. package/lib/client/formats/docx/export/exporters/sub-document/text-box-content-exporter.d.ts +2 -2
  47. package/lib/client/formats/docx/export/exporters/sub-document/text-box-content-exporter.js +2 -2
  48. package/lib/client/formats/docx/import/destination/notes/endnotes/endnote-properties-destination.d.ts +16 -0
  49. package/lib/client/formats/docx/import/destination/notes/endnotes/endnote-properties-destination.js +48 -0
  50. package/lib/client/formats/docx/import/destination/notes/endnotes/endnote-reference-destination.d.ts +5 -0
  51. package/lib/client/formats/docx/import/destination/notes/endnotes/endnote-reference-destination.js +9 -0
  52. package/lib/client/formats/docx/import/destination/notes/endnotes/endnotes-destination.d.ts +5 -0
  53. package/lib/client/formats/docx/import/destination/notes/endnotes/endnotes-destination.js +39 -0
  54. package/lib/client/formats/docx/import/destination/notes/footnotes/footnote-properties-destination.d.ts +18 -0
  55. package/lib/client/formats/docx/import/destination/notes/footnotes/footnote-properties-destination.js +49 -0
  56. package/lib/client/formats/docx/import/destination/notes/footnotes/footnote-reference-destination.d.ts +5 -0
  57. package/lib/client/formats/docx/import/destination/notes/footnotes/footnote-reference-destination.js +9 -0
  58. package/lib/client/formats/docx/import/destination/notes/footnotes/footnotes-destination.d.ts +5 -0
  59. package/lib/client/formats/docx/import/destination/notes/footnotes/footnotes-destination.js +39 -0
  60. package/lib/client/formats/docx/import/destination/notes/note-destination.d.ts +18 -0
  61. package/lib/client/formats/docx/import/destination/notes/note-destination.js +45 -0
  62. package/lib/client/formats/docx/import/destination/notes/note-properties-destination.d.ts +32 -0
  63. package/lib/client/formats/docx/import/destination/notes/note-properties-destination.js +81 -0
  64. package/lib/client/formats/docx/import/destination/notes/note-reference-destination.d.ts +8 -0
  65. package/lib/client/formats/docx/import/destination/notes/note-reference-destination.js +21 -0
  66. package/lib/client/formats/docx/import/destination/notes/note-self-reference-destination.d.ts +5 -0
  67. package/lib/client/formats/docx/import/destination/notes/note-self-reference-destination.js +12 -0
  68. package/lib/client/formats/docx/import/destination/notes/note-separator-destination.d.ts +8 -0
  69. package/lib/client/formats/docx/import/destination/notes/note-separator-destination.js +20 -0
  70. package/lib/client/formats/docx/import/destination/paragraph-properties/paragraph-numbering-reference-destination.js +1 -1
  71. package/lib/client/formats/docx/import/destination/runs/run-destination.js +11 -5
  72. package/lib/client/formats/docx/import/destination/section/section-destination.js +5 -2
  73. package/lib/client/formats/docx/import/destination/settings/settings.js +4 -0
  74. package/lib/client/formats/docx/import/importer.d.ts +2 -0
  75. package/lib/client/formats/docx/import/importer.js +26 -0
  76. package/lib/client/formats/docx/import/importers/character-importer.d.ts +3 -0
  77. package/lib/client/formats/docx/import/importers/character-importer.js +12 -1
  78. package/lib/client/formats/docx/import/importers/end-notes-importer.d.ts +3 -4
  79. package/lib/client/formats/docx/import/importers/end-notes-importer.js +8 -3
  80. package/lib/client/formats/docx/import/importers/foot-notes-importer.d.ts +3 -5
  81. package/lib/client/formats/docx/import/importers/foot-notes-importer.js +8 -5
  82. package/lib/client/formats/docx/import/importers/notes-importer.d.ts +8 -0
  83. package/lib/client/formats/docx/import/importers/notes-importer.js +7 -0
  84. package/lib/client/formats/docx/translation-table/translation-tables.d.ts +7 -0
  85. package/lib/client/formats/docx/translation-table/translation-tables.js +27 -0
  86. package/lib/client/formats/docx/utils/constants.d.ts +2 -0
  87. package/lib/client/formats/docx/utils/constants.js +2 -0
  88. package/lib/client/model-api/formats/enum.d.ts +1 -0
  89. package/lib/client/model-api/formats/enum.js +1 -0
  90. package/lib/client/model-api/formats/exporter.d.ts +3 -4
  91. package/lib/client/model-api/formats/exporter.js +9 -6
  92. package/lib/client/model-api/formats/importer.js +2 -0
  93. package/lib/client/model-api/sub-document.d.ts +6 -2
  94. package/lib/client/model-api/sub-document.js +37 -35
  95. package/lib/client/model-api/table/table-borders.d.ts +1 -1
  96. package/lib/client/public/commands/enum.d.ts +1 -0
  97. package/lib/client/public/commands/enum.js +1 -0
  98. package/lib/client/public/document-processor.d.ts +3 -1
  99. package/lib/client/public/document-processor.js +2 -2
  100. package/lib/client/public/ribbon/item-ids.d.ts +1 -0
  101. package/lib/client/public/ribbon/item-ids.js +1 -0
  102. package/lib/client/public/rich-edit.d.ts +2 -1
  103. package/lib/client/public/rich-edit.js +16 -9
  104. package/lib/common/canvas/canvas-manager.js +2 -1
  105. package/lib/common/canvas/picture-renderer.d.ts +1 -1
  106. package/lib/common/canvas/renderes/common/document-renderer.d.ts +1 -1
  107. package/lib/common/canvas/renderes/common/document-renderer.js +6 -2
  108. package/lib/common/canvas/renderes/view-manager.js +3 -1
  109. package/lib/common/clipboard-content-inserter.js +2 -1
  110. package/lib/common/commands/client-command.d.ts +3 -1
  111. package/lib/common/commands/client-command.js +2 -0
  112. package/lib/common/commands/document/print-document-on-client-command.js +1 -1
  113. package/lib/common/commands/text/clipboard-commands.js +7 -5
  114. package/lib/common/document-format.d.ts +2 -0
  115. package/lib/common/document-format.js +2 -0
  116. package/lib/common/formats/document-importer-errors.d.ts +3 -1
  117. package/lib/common/formats/document-importer-errors.js +2 -0
  118. package/lib/common/formats/file-name-helper.d.ts +1 -0
  119. package/lib/common/formats/file-name-helper.js +7 -1
  120. package/lib/common/formats/html/export/get-html.d.ts +4 -0
  121. package/lib/common/formats/html/export/get-html.js +12 -0
  122. package/lib/common/formats/html/export/html-builder.d.ts +16 -0
  123. package/lib/common/formats/html/export/html-builder.js +98 -0
  124. package/lib/common/formats/html/export/html-document-exporter.d.ts +13 -0
  125. package/lib/common/formats/html/export/html-document-exporter.js +29 -0
  126. package/lib/common/formats/html/export/html-export.d.ts +25 -0
  127. package/lib/common/{html-export.js → formats/html/export/html-export.js} +115 -192
  128. package/lib/common/formats/html/import/html-document-importer.d.ts +15 -0
  129. package/lib/common/formats/html/import/html-document-importer.js +84 -0
  130. package/lib/common/formats/html/import/html-importer.d.ts +1 -0
  131. package/lib/common/formats/html/import/html-importer.js +13 -1
  132. package/lib/common/formats/html/import/insert-html.d.ts +4 -0
  133. package/lib/common/formats/html/import/insert-html.js +5 -0
  134. package/lib/common/formats/html/import/utils/paragraph-properties-utils.d.ts +1 -0
  135. package/lib/common/formats/html/import/utils/paragraph-properties-utils.js +17 -4
  136. package/lib/common/formats/i-document-exporter.d.ts +14 -0
  137. package/lib/common/formats/rtf/export/exporter.d.ts +1 -1
  138. package/lib/common/formats/rtf/export/exporter.js +1 -1
  139. package/lib/common/formats/rtf/importer-in-subdocument.d.ts +1 -1
  140. package/lib/common/formats/rtf/importer-in-subdocument.js +1 -1
  141. package/lib/common/formats/txt/txt-exporter.js +2 -1
  142. package/lib/common/input-controller.d.ts +2 -1
  143. package/lib/common/input-controller.js +5 -2
  144. package/lib/common/interfaces/i-rich-edit-core.d.ts +2 -0
  145. package/lib/common/layout/main-structures/layout-boxes/layout-anchored-picture-box.d.ts +2 -1
  146. package/lib/common/layout/main-structures/layout-boxes/layout-anchored-picture-box.js +4 -3
  147. package/lib/common/layout/main-structures/layout-boxes/layout-picture-box.d.ts +2 -1
  148. package/lib/common/layout/main-structures/layout-boxes/layout-picture-box.js +5 -4
  149. package/lib/common/layout/main-structures/layout-page.d.ts +1 -0
  150. package/lib/common/layout/main-structures/layout-page.js +5 -2
  151. package/lib/common/layout-formatter/box/generator/box-infos-generator.d.ts +1 -0
  152. package/lib/common/layout-formatter/box/generator/box-infos-generator.js +12 -2
  153. package/lib/common/layout-formatter/floating/page-anchored-object-holder.d.ts +5 -3
  154. package/lib/common/layout-formatter/floating/page-anchored-object-holder.js +7 -4
  155. package/lib/common/layout-formatter/formatter/base-formatter.js +0 -1
  156. package/lib/common/layout-formatter/formatter/main-formatter.js +1 -0
  157. package/lib/common/layout-formatter/managers/formatter-manager.d.ts +6 -2
  158. package/lib/common/layout-formatter/managers/formatter-manager.js +3 -1
  159. package/lib/common/layout-formatter/row/size-engine/row-sizes-manager.js +20 -4
  160. package/lib/common/measurer/measurer.js +2 -1
  161. package/lib/common/model/chunk.d.ts +1 -0
  162. package/lib/common/model/chunk.js +27 -2
  163. package/lib/common/model/document-model.d.ts +4 -0
  164. package/lib/common/model/document-model.js +4 -1
  165. package/lib/common/model/enums.d.ts +3 -1
  166. package/lib/common/model/enums.js +2 -0
  167. package/lib/common/model/footnotes/footnote.d.ts +46 -0
  168. package/lib/common/model/footnotes/footnote.js +100 -0
  169. package/lib/common/model/json/importers/sub-document/json-sub-document-importer.js +3 -3
  170. package/lib/common/model/json/importers/sub-document/run-importers.d.ts +6 -0
  171. package/lib/common/model/json/importers/sub-document/run-importers.js +9 -0
  172. package/lib/common/model/model-checks/position.d.ts +2 -1
  173. package/lib/common/model/model-checks/position.js +11 -2
  174. package/lib/common/model/numbering-lists/numbering-helper.d.ts +2 -1
  175. package/lib/common/model/numbering-lists/numbering-helper.js +3 -0
  176. package/lib/common/model/paragraph/paragraph-style.d.ts +1 -0
  177. package/lib/common/model/paragraph/paragraph-style.js +6 -2
  178. package/lib/common/model/properties-merger/paragraph-properties-merger.js +1 -1
  179. package/lib/common/model/runs/run-base.d.ts +1 -0
  180. package/lib/common/model/runs/simple-runs.d.ts +8 -2
  181. package/lib/common/model/runs/simple-runs.js +12 -6
  182. package/lib/common/model/section/section-properties.d.ts +3 -0
  183. package/lib/common/model/special-characters.d.ts +3 -0
  184. package/lib/common/model/special-characters.js +3 -0
  185. package/lib/common/model/sub-document-infos.d.ts +18 -0
  186. package/lib/common/model/sub-document-infos.js +39 -0
  187. package/lib/common/model/sub-document.d.ts +2 -0
  188. package/lib/common/model/sub-document.js +18 -16
  189. package/lib/common/mouse-handler/touch-handler/touch-handler-state-base.d.ts +1 -0
  190. package/lib/common/mouse-handler/touch-handler/touch-handler-state-base.js +21 -13
  191. package/lib/common/processor.d.ts +2 -0
  192. package/lib/common/rich-edit-core.d.ts +6 -2
  193. package/lib/common/rich-edit-core.js +20 -1
  194. package/lib/common/selection/selection-intervals-info.js +1 -1
  195. package/lib/common/utils/_license.d.ts +1 -0
  196. package/lib/common/utils/_license.js +2 -0
  197. package/lib/common/utils/size-utils.d.ts +3 -0
  198. package/lib/common/utils/size-utils.js +17 -4
  199. package/package.json +3 -3
  200. package/lib/common/html-export.d.ts +0 -32
@@ -1,120 +1,49 @@
1
- import { RichEditUnit } from './utils/unit-converter';
2
- import { LayoutPictureBox } from './layout/main-structures/layout-boxes/layout-picture-box';
3
- import { BorderLineStyle } from './model/borders/enums';
4
- import { CharacterProperties } from './model/character/character-properties';
5
- import { CharacterFormattingScript, UnderlineType } from './model/character/enums';
6
- import { ColorHelper } from './model/color/color';
7
- import { Field } from './model/fields/field';
8
- import { NumberingFormat } from './model/numbering-lists/list-level-properties';
9
- import { NumberingType } from './model/numbering-lists/numbering-list';
10
- import { ParagraphAlignment, ParagraphFirstLineIndent, ParagraphLineSpacingType } from './model/paragraph/paragraph-properties';
11
- import { RichUtils } from './model/rich-utils';
12
- import { RunType } from './model/runs/run-type';
13
- import { Table } from './model/tables/main-structures/table';
14
- import { TableCellPropertiesMergerShadingInfo, TableCellVerticalAlignmentMerger } from './model/tables/properties-mergers/table-cell-properties-merger';
15
- import { TablePropertiesMergerBorderHorizontal, TablePropertiesMergerBorderVertical, TablePropertiesMergerCellSpacing, TablePropertiesMergerIndent } from './model/tables/properties-mergers/table-properties-merger';
16
- import { ConditionalTableStyleFormatting, TableCellMergingState, TableCellVerticalAlignment } from './model/tables/secondary-structures/table-base-structures';
17
- import { TableWidthUnitType } from './model/tables/secondary-structures/table-units';
18
- import { HtmlConverter } from './rich-utils/html-converter';
19
1
  import { UnitConverter } from '@devexpress/utils/lib/class/unit-converter';
20
2
  import { FixedInterval } from '@devexpress/utils/lib/intervals/fixed';
21
3
  import { ColorUtils } from '@devexpress/utils/lib/utils/color';
22
4
  import { EncodeUtils } from '@devexpress/utils/lib/utils/encode';
23
5
  import { SearchUtils } from '@devexpress/utils/lib/utils/search';
24
6
  import { StringUtils } from '@devexpress/utils/lib/utils/string';
25
- export class HtmlBuilder {
26
- constructor() {
27
- this.childElements = [];
28
- this.callbacks = [];
29
- }
30
- _getHtmlString() {
31
- return this.childElements.map(x => {
32
- if (typeof x === 'string')
33
- return x;
34
- return x.outerHTML;
35
- }).join('');
36
- }
37
- isEmpty() {
38
- return this.callbacks.length === 0 && this.childElements.length === 0;
39
- }
40
- clear() {
41
- this._currentElement = null;
42
- this.callbacks = [];
43
- this.childElements = [];
44
- return this;
45
- }
46
- startChild(tagName, namespaceUri) {
47
- const element = (namespaceUri) ? document.createElementNS(namespaceUri, tagName) : document.createElement(tagName);
48
- if (this._currentElement)
49
- this._currentElement.appendChild(element);
50
- else {
51
- this.childElements.push(element);
52
- }
53
- this._currentElement = element;
54
- return this;
55
- }
56
- configure(config) {
57
- config(this._currentElement);
58
- return this;
59
- }
60
- addCallback(callback) {
61
- this.callbacks.push(callback);
62
- }
63
- assignFrom(builder) {
64
- if (!builder)
65
- return this;
66
- if (typeof builder === "string") {
67
- this.addElement(builder);
68
- return this;
69
- }
70
- builder.callbacks.forEach((callback) => {
71
- callback(this);
72
- });
73
- builder.childElements.forEach((el) => {
74
- this.addElement(el);
75
- });
76
- builder.clear();
77
- return this;
78
- }
79
- addElement(element) {
80
- if (!element)
81
- return this;
82
- if (!this._currentElement) {
83
- this.childElements.push(element);
84
- return this;
85
- }
86
- if (typeof element === 'string')
87
- this._currentElement.innerHTML += element;
88
- else if (this._currentElement)
89
- this._currentElement.appendChild(element);
90
- else
91
- this._currentElement = element;
92
- return this;
93
- }
94
- endChild(tagName) {
95
- let currentElement = this._currentElement;
96
- while (currentElement.tagName.toLowerCase() !== tagName.toLowerCase()) {
97
- currentElement = currentElement.parentElement;
98
- }
99
- this._currentElement = currentElement.parentElement;
100
- return this;
101
- }
102
- }
7
+ import { RichEditUnit } from '../../../utils/unit-converter';
8
+ import { LayoutPictureBox } from '../../../layout/main-structures/layout-boxes/layout-picture-box';
9
+ import { BorderLineStyle } from '../../../model/borders/enums';
10
+ import { CharacterProperties } from '../../../model/character/character-properties';
11
+ import { CharacterFormattingScript, UnderlineType } from '../../../model/character/enums';
12
+ import { ColorHelper } from '../../../model/color/color';
13
+ import { Field } from '../../../model/fields/field';
14
+ import { NumberingFormat } from '../../../model/numbering-lists/list-level-properties';
15
+ import { NumberingType } from '../../../model/numbering-lists/numbering-list';
16
+ import { ParagraphAlignment, ParagraphFirstLineIndent, ParagraphLineSpacingType, } from '../../../model/paragraph/paragraph-properties';
17
+ import { RichUtils } from '../../../model/rich-utils';
18
+ import { RunType } from '../../../model/runs/run-type';
19
+ import { Table } from '../../../model/tables/main-structures/table';
20
+ import { TableCellPropertiesMergerShadingInfo, TableCellVerticalAlignmentMerger, } from '../../../model/tables/properties-mergers/table-cell-properties-merger';
21
+ import { TablePropertiesMergerBorderHorizontal, TablePropertiesMergerBorderVertical, TablePropertiesMergerCellSpacing, TablePropertiesMergerIndent, } from '../../../model/tables/properties-mergers/table-properties-merger';
22
+ import { ConditionalTableStyleFormatting, TableCellMergingState, TableCellVerticalAlignment, } from '../../../model/tables/secondary-structures/table-base-structures';
23
+ import { TableWidthUnitType } from '../../../model/tables/secondary-structures/table-units';
24
+ import { HtmlConverter } from '../../../rich-utils/html-converter';
25
+ import { HtmlBuilder } from './html-builder';
26
+ import { isDefined } from '@devexpress/utils/lib/utils/common';
103
27
  export class HtmlExporter {
104
- constructor(control) {
28
+ constructor(exportModelOptions) {
105
29
  this.rangeCopy = null;
106
- this.control = control;
30
+ this.exportModelOptions = exportModelOptions;
107
31
  }
108
- get colorProvider() { return this.control.modelManager.model.colorProvider; }
32
+ get modelManager() { return this.exportModelOptions.modelManager; }
33
+ get colorProvider() { return this.modelManager.model.colorProvider; }
34
+ get unitConverter() { return this.exportModelOptions.uiUnitConverter; }
35
+ get documentRenderer() { return this.exportModelOptions.pictureRenderer; }
36
+ get lastMaxNumPages() { return this.exportModelOptions.lastMaxNumPages; }
37
+ ;
38
+ get pageIndex() { return this.exportModelOptions.pageIndex; }
39
+ ;
109
40
  getHtmlElementsByInterval(model, subDocument, interval, guidLabel) {
110
41
  if (interval.length === 0)
111
42
  return;
112
- const unitConverter = this.control.uiUnitConverter;
113
- const unitTypeToString = unitConverter.getUnits() == RichEditUnit.Centimeter ? "cm" : "in";
43
+ const unitTypeToString = this.unitConverter.getUnits() == RichEditUnit.Centimeter ? "cm" : "in";
114
44
  const iterator = subDocument.getConstRunIterator(interval);
115
45
  let remainLength = interval.length;
116
46
  let currentPosition = interval.start;
117
- const renderer = this.control.viewManager.renderer;
118
47
  let resultBuilder = new HtmlBuilder();
119
48
  const paragraphsInInterval = subDocument.getParagraphsByInterval(interval);
120
49
  const paragraphs = [];
@@ -221,60 +150,27 @@ export class HtmlExporter {
221
150
  const currentParagraph = paragraphs[paragraphToStartIndex];
222
151
  paragraphs.splice(paragraphToStartIndex, 1);
223
152
  if (tableCell) {
224
- let parentRow = tableCell.parentRow;
225
- let parentTable = parentRow.parentTable;
226
- let paragraphStartPosition = currentParagraph.startLogPosition.value;
227
- if (parentTable.getStartPosition() == paragraphStartPosition) {
228
- if (parentTable.parentCell) {
229
- let parentCell = parentTable.parentCell;
230
- while (parentCell) {
231
- let currentParentRow = parentCell.parentRow;
232
- let currentParentTable = currentParentRow.parentTable;
233
- if (currentParentTable.getStartPosition() == paragraphStartPosition)
234
- resultBuilder
235
- .startChild('table')
236
- .configure((e) => e.style.cssText = this.getTableStyle(model, currentParentTable))
237
- .startChild('tbody');
238
- if (currentParentRow.getStartPosition() == paragraphStartPosition) {
239
- resultBuilder.startChild('tr');
240
- if (currentParentRow.gridBefore > 0)
241
- resultBuilder
242
- .startChild('td')
243
- .configure((el) => {
244
- el.style.cssText = "mso-cell-special:placeholder";
245
- el.setAttribute('colspan', currentParentRow.gridBefore.toString());
246
- el.innerHTML = " ";
247
- })
248
- .endChild('td');
249
- }
250
- if (parentCell.startParagraphPosition.value == paragraphStartPosition) {
251
- resultBuilder
252
- .startChild('td')
253
- .configure((el) => {
254
- el.style.cssText = this.getCellStyle(model, parentCell);
255
- if (parentCell.columnSpan > 1) {
256
- el.setAttribute('colspan', parentCell.columnSpan.toString());
257
- }
258
- });
259
- }
260
- parentCell = currentParentTable.parentCell;
261
- }
262
- }
153
+ const row = tableCell.parentRow;
154
+ const table = row.parentTable;
155
+ const paragraphStartPosition = currentParagraph.startLogPosition.value;
156
+ if (table.getStartPosition() == paragraphStartPosition) {
157
+ if (table.parentCell)
158
+ this.addParentTableRecursively(model, resultBuilder, table.parentCell, paragraphStartPosition);
263
159
  resultBuilder
264
160
  .startChild('table')
265
161
  .configure((el) => {
266
- el.style.cssText = this.getTableStyle(model, parentTable);
162
+ el.style.cssText = this.getTableStyle(model, table);
267
163
  })
268
164
  .startChild('tbody');
269
165
  }
270
- if (parentRow.getStartPosition() == paragraphStartPosition) {
166
+ if (row.getStartPosition() == paragraphStartPosition) {
271
167
  resultBuilder.startChild('tr');
272
- if (parentRow.gridBefore > 0) {
168
+ if (row.gridBefore > 0) {
273
169
  resultBuilder
274
170
  .startChild('td')
275
171
  .configure((el) => {
276
172
  el.style.cssText = "mso-cell-special:placeholder";
277
- el.setAttribute('colspan', parentRow.gridBefore.toString());
173
+ el.setAttribute('colspan', row.gridBefore.toString());
278
174
  el.innerHTML = " ";
279
175
  })
280
176
  .endChild('td');
@@ -283,18 +179,18 @@ export class HtmlExporter {
283
179
  if (tableCell.startParagraphPosition.value == paragraphStartPosition && !isContinueMergingCell) {
284
180
  let rowSpan = 1;
285
181
  if (tableCell.verticalMerging === TableCellMergingState.Restart) {
286
- let rowIndex = parentTable.rows.indexOf(parentRow);
287
- let cellIndex = parentRow.cells.indexOf(tableCell);
288
- for (let i = rowIndex + 1, row; row = parentTable.rows[i]; i++) {
182
+ let rowIndex = table.rows.indexOf(row);
183
+ let cellIndex = row.cells.indexOf(tableCell);
184
+ for (let i = rowIndex + 1, row; row = table.rows[i]; i++) {
289
185
  let nextRowCellIndex = cellIndex;
290
- if (row.cells.length != parentRow.cells.length) {
186
+ if (row.cells.length != row.cells.length) {
291
187
  let extraCellsCount = 0;
292
- let isNextRowLonger = row.cells.length > parentRow.cells.length;
293
- let shorterRow = isNextRowLonger ? parentRow : row;
188
+ let isNextRowLonger = row.cells.length > row.cells.length;
189
+ let shorterRow = isNextRowLonger ? row : row;
294
190
  for (let j = 0; (j < cellIndex) && (j < shorterRow.cells.length); j++) {
295
191
  extraCellsCount += shorterRow.cells[j].columnSpan - 1;
296
192
  if (!isNextRowLonger)
297
- extraCellsCount -= parentRow.cells[j].columnSpan - 1;
193
+ extraCellsCount -= row.cells[j].columnSpan - 1;
298
194
  }
299
195
  nextRowCellIndex += (isNextRowLonger ? 1 : -1) * extraCellsCount;
300
196
  }
@@ -322,7 +218,7 @@ export class HtmlExporter {
322
218
  const firstLineIndentType = maskedParagraphProperties.firstLineIndentType;
323
219
  if (firstLineIndentType != ParagraphFirstLineIndent.None) {
324
220
  paragraphStyle += "text-indent: " + (firstLineIndentType == ParagraphFirstLineIndent.Hanging ? "-" : "") +
325
- unitConverter.twipsToUI(maskedParagraphProperties.firstLineIndent) + unitTypeToString + ";";
221
+ this.unitConverter.twipsToUI(maskedParagraphProperties.firstLineIndent) + unitTypeToString + ";";
326
222
  }
327
223
  if (maskedParagraphProperties.alignment !== undefined) {
328
224
  paragraphStyle += "text-align: ";
@@ -349,7 +245,7 @@ export class HtmlExporter {
349
245
  }
350
246
  }
351
247
  if (maskedParagraphProperties.lineSpacingType != ParagraphLineSpacingType.Single) {
352
- const lineSpacingInUI = unitConverter.twipsToUI(maskedParagraphProperties.lineSpacing) + unitTypeToString + ";";
248
+ const lineSpacingInUI = this.unitConverter.twipsToUI(maskedParagraphProperties.lineSpacing) + unitTypeToString + ";";
353
249
  paragraphStyle += "line-height: ";
354
250
  switch (maskedParagraphProperties.lineSpacingType) {
355
251
  case ParagraphLineSpacingType.AtLeast:
@@ -374,11 +270,11 @@ export class HtmlExporter {
374
270
  if (ColorUtils.getAlpha(maskedParagraphProperties.shadingInfo.getActualColor(this.colorProvider)) > 0)
375
271
  paragraphStyle += "background: " + ColorHelper.getCssStringInternal(maskedParagraphProperties.shadingInfo.getActualColor(this.colorProvider)) + ";";
376
272
  if (maskedParagraphProperties.leftIndent)
377
- paragraphStyle += "margin-left: " + unitConverter.twipsToUI(maskedParagraphProperties.leftIndent) + unitTypeToString + ";";
273
+ paragraphStyle += "margin-left: " + this.unitConverter.twipsToUI(maskedParagraphProperties.leftIndent) + unitTypeToString + ";";
378
274
  if (maskedParagraphProperties.rightIndent)
379
- paragraphStyle += "margin-right: " + unitConverter.twipsToUI(maskedParagraphProperties.rightIndent) + unitTypeToString + ";";
380
- paragraphStyle += "margin-top: " + unitConverter.twipsToUI(maskedParagraphProperties.spacingBefore) + unitTypeToString + ";";
381
- paragraphStyle += "margin-bottom: " + unitConverter.twipsToUI(maskedParagraphProperties.spacingAfter) + unitTypeToString + ";";
275
+ paragraphStyle += "margin-right: " + this.unitConverter.twipsToUI(maskedParagraphProperties.rightIndent) + unitTypeToString + ";";
276
+ paragraphStyle += "margin-top: " + this.unitConverter.twipsToUI(maskedParagraphProperties.spacingBefore) + unitTypeToString + ";";
277
+ paragraphStyle += "margin-bottom: " + this.unitConverter.twipsToUI(maskedParagraphProperties.spacingAfter) + unitTypeToString + ";";
382
278
  const topBorderStyle = this.getBorderCssString(maskedParagraphProperties.topBorder);
383
279
  if (topBorderStyle)
384
280
  paragraphStyle += "border-top:" + topBorderStyle + ";";
@@ -453,10 +349,11 @@ export class HtmlExporter {
453
349
  case RunType.AnchoredPictureRun: {
454
350
  const picRun = run;
455
351
  const charMergProps = run.getCharacterMergedProperties();
456
- const pictureBox = new LayoutPictureBox(charMergProps, charMergProps.getLayoutColorInfo(this.colorProvider), picRun.cacheInfo, picRun.getActualSize().applyConverter(UnitConverter.twipsToPixels));
352
+ const pictureBox = new LayoutPictureBox(charMergProps, charMergProps.getLayoutColorInfo(this.colorProvider), picRun.cacheInfo, picRun.getActualSize().applyConverter(UnitConverter.twipsToPixels), picRun.info.nonVisualDrawingProperties.description);
353
+ const { cacheInfo, hyperlinkTip, description } = pictureBox;
457
354
  innerHtml
458
355
  .clear()
459
- .addElement(renderer.renderPicture(pictureBox));
356
+ .addElement(this.documentRenderer.renderPictureBoxContent(pictureBox.createSize(), cacheInfo, hyperlinkTip, description));
460
357
  break;
461
358
  }
462
359
  case RunType.InlineTextBoxRun:
@@ -507,14 +404,14 @@ export class HtmlExporter {
507
404
  let currentField = subDocument.fields[Field.normedBinaryIndexOf(subDocument.fields, currentPosition)];
508
405
  if (currentField) {
509
406
  let codeText = StringUtils.trim(subDocument.getText(currentField.getCodeInterval()).split("\\")[0]).toUpperCase();
510
- if (codeText == "NUMPAGES")
407
+ if (codeText == "NUMPAGES" && isDefined(this.lastMaxNumPages))
511
408
  innerHtml
512
409
  .clear()
513
- .addElement(this.control.layout.lastMaxNumPages.toString());
514
- else if (codeText == "PAGE")
410
+ .addElement(this.lastMaxNumPages.toString());
411
+ else if (codeText == "PAGE" && isDefined(this.pageIndex))
515
412
  innerHtml
516
413
  .clear()
517
- .addElement((this.control.selection.pageIndex + 1).toString());
414
+ .addElement((this.pageIndex + 1).toString());
518
415
  }
519
416
  break;
520
417
  default:
@@ -540,7 +437,7 @@ export class HtmlExporter {
540
437
  }
541
438
  if (html.isEmpty() && !innerHtml.isEmpty()) {
542
439
  const characterProperties = run.getCharacterMergedProperties();
543
- const boxStyle = "white-space:pre;" + HtmlConverter.getCssRules(characterProperties, characterProperties.textColor.toRgb(this.colorProvider), run.getType() == RunType.TextRun, false, false).
440
+ const boxStyle = HtmlConverter.getCssRules(characterProperties, characterProperties.textColor.toRgb(this.colorProvider), run.getType() == RunType.TextRun, false, false).
544
441
  join(";");
545
442
  html
546
443
  .startChild('span')
@@ -601,15 +498,15 @@ export class HtmlExporter {
601
498
  currentPosition += length;
602
499
  remainLength -= length;
603
500
  }
604
- if (/^<td[^>]*>/gi.test(resultBuilder._getHtmlString())) {
501
+ if (/^<td[^>]*>/gi.test(resultBuilder.getHtmlString())) {
605
502
  const builder = new HtmlBuilder();
606
503
  builder.startChild('tr');
607
504
  builder.assignFrom(resultBuilder);
608
505
  resultBuilder = builder;
609
506
  }
610
- if (/<\/td>$/gi.test(resultBuilder._getHtmlString()))
507
+ if (/<\/td>$/gi.test(resultBuilder.getHtmlString()))
611
508
  resultBuilder.endChild("tr");
612
- if (/^<tr[^>]*>/gi.test(resultBuilder._getHtmlString())) {
509
+ if (/^<tr[^>]*>/gi.test(resultBuilder.getHtmlString())) {
613
510
  const builder = new HtmlBuilder();
614
511
  builder
615
512
  .startChild('table')
@@ -620,7 +517,7 @@ export class HtmlExporter {
620
517
  .assignFrom(resultBuilder);
621
518
  resultBuilder = builder;
622
519
  }
623
- if (/<\/tr>$/gi.test(resultBuilder._getHtmlString()))
520
+ if (/<\/tr>$/gi.test(resultBuilder.getHtmlString()))
624
521
  resultBuilder
625
522
  .endChild('tbody')
626
523
  .endChild('table');
@@ -634,32 +531,58 @@ export class HtmlExporter {
634
531
  .endChild('span');
635
532
  return resultBuilder;
636
533
  }
534
+ addParentTableRecursively(model, builder, parentCell, paragraphStartPosition) {
535
+ const parentRow = parentCell.parentRow;
536
+ const parentTable = parentRow.parentTable;
537
+ if (parentTable.parentCell)
538
+ this.addParentTableRecursively(model, builder, parentTable.parentCell, paragraphStartPosition);
539
+ if (parentTable.getStartPosition() === paragraphStartPosition) {
540
+ builder
541
+ .startChild('table')
542
+ .configure(e => e.style.cssText = this.getTableStyle(model, parentTable))
543
+ .startChild('tbody');
544
+ }
545
+ if (parentRow.getStartPosition() === paragraphStartPosition) {
546
+ builder.startChild('tr');
547
+ if (parentRow.gridBefore > 0) {
548
+ builder
549
+ .startChild('td')
550
+ .configure(el => {
551
+ el.style.cssText = "mso-cell-special:placeholder";
552
+ el.setAttribute('colspan', parentRow.gridBefore.toString());
553
+ el.innerHTML = "&nbsp;";
554
+ })
555
+ .endChild('td');
556
+ }
557
+ }
558
+ if (parentCell.startParagraphPosition.value === paragraphStartPosition) {
559
+ builder
560
+ .startChild('td')
561
+ .configure((el) => {
562
+ el.style.cssText = this.getCellStyle(model, parentCell);
563
+ if (parentCell.columnSpan > 1)
564
+ el.setAttribute('colspan', parentCell.columnSpan.toString());
565
+ });
566
+ }
567
+ }
637
568
  getHtmlText(text) {
638
- let result = new HtmlBuilder();
569
+ const result = new HtmlBuilder();
639
570
  for (let i = 0; i < text.length; i++) {
640
571
  const char = text.charAt(i);
641
- if (char == RichUtils.specialCharacters.PageBreak)
642
- result.addCallback((builder) => {
643
- builder
644
- .startChild('br')
645
- .configure((el) => {
646
- el.style.cssText = "page-break-before:always";
647
- })
648
- .endChild('br');
649
- });
650
- else if (char == RichUtils.specialCharacters.LineBreak)
651
- result.addCallback((builder) => {
652
- builder
653
- .startChild('br')
654
- .endChild('br');
655
- });
656
- else {
657
- result.addCallback((builder) => {
658
- builder.configure((el) => {
659
- el.innerHTML += EncodeUtils.encodeHtml(text.substr(i));
572
+ switch (char) {
573
+ case RichUtils.specialCharacters.PageBreak:
574
+ case RichUtils.specialCharacters.ColumnBreak:
575
+ case RichUtils.specialCharacters.SectionMark:
576
+ result.addCallback((builder) => builder.addBreak("break-before:always"));
577
+ break;
578
+ case RichUtils.specialCharacters.LineBreak:
579
+ result.addCallback((builder) => builder.addBreak());
580
+ break;
581
+ default:
582
+ result.addCallback((builder) => {
583
+ builder.configure((el) => el.innerHTML += EncodeUtils.encodeHtml(text.substring(i)));
660
584
  });
661
- });
662
- break;
585
+ return result;
663
586
  }
664
587
  }
665
588
  return result;
@@ -693,7 +616,7 @@ export class HtmlExporter {
693
616
  default:
694
617
  break;
695
618
  }
696
- const rgba = this.control.modelManager.model.colorProvider.getRgbaFromModelColor(borderInfo.color);
619
+ const rgba = this.colorProvider.getRgbaFromModelColor(borderInfo.color);
697
620
  if (ColorUtils.getAlpha(rgba) > 0)
698
621
  borderStyle += " " + ColorHelper.getCssStringInternal(rgba);
699
622
  }
@@ -0,0 +1,15 @@
1
+ import { RichOptions } from "../../../model/options/rich-options";
2
+ import { MaskedCharacterPropertiesBundle } from "../../../rich-utils/properties-bundle";
3
+ import { FormatImportCallback, FormatImportReject, IDocumentImporter } from "../../i-document-importer";
4
+ export declare class HtmlDocumentImporter implements IDocumentImporter {
5
+ private documentModel;
6
+ private modelManager;
7
+ private formatImagesImporter;
8
+ importFromFile(blob: Blob, modelOptions: RichOptions, callback: FormatImportCallback, reject: FormatImportReject): void;
9
+ importFromString(text: string, modelOptions: RichOptions, callback: FormatImportCallback, reject: FormatImportReject, charPropsBundle?: MaskedCharacterPropertiesBundle): void;
10
+ private init;
11
+ private fillModel;
12
+ private createMaskedCharacterPropertiesBundle;
13
+ private createContainer;
14
+ private removeLastParagraph;
15
+ }
@@ -0,0 +1,84 @@
1
+ import { EmptyBatchUpdatableObject } from "@devexpress/utils/lib/class/batch-updatable";
2
+ import { ModelChecker } from "../../../model/model-checks/check-all";
3
+ import { ModelCreatorOptions } from "../../../model/creator/options";
4
+ import { ModelCreator } from "../../../model/creator/creator";
5
+ import { MaskedCharacterProperties } from "../../../model/character/character-properties";
6
+ import { SubDocumentPosition } from "../../../model/sub-document";
7
+ import { ClientModelManager } from "../../../model-manager";
8
+ import { MaskedCharacterPropertiesBundle } from "../../../rich-utils/properties-bundle";
9
+ import { Measurer } from "../../../measurer/measurer";
10
+ import { DocumentImporterErrors } from "../../document-importer-errors";
11
+ import { FormatImagesImporter } from "../../utils/images-import";
12
+ import { HtmlImporter } from "./html-importer";
13
+ export class HtmlDocumentImporter {
14
+ importFromFile(blob, modelOptions, callback, reject) {
15
+ this.init(modelOptions);
16
+ const reader = new FileReader();
17
+ reader.onload = () => {
18
+ this.importFromString(reader.result, modelOptions, callback, reject);
19
+ };
20
+ reader.onerror = (_ev) => {
21
+ reject(DocumentImporterErrors.HtmlFileReaderError);
22
+ };
23
+ reader.readAsText(blob);
24
+ }
25
+ importFromString(text, modelOptions, callback, reject, charPropsBundle) {
26
+ this.init(modelOptions);
27
+ try {
28
+ this.fillModel(text, charPropsBundle);
29
+ if (!new ModelChecker(this.documentModel).checkAll())
30
+ throw new Error();
31
+ }
32
+ catch (err) {
33
+ reject(DocumentImporterErrors.HtmlImportError);
34
+ return;
35
+ }
36
+ callback(this.documentModel, this.formatImagesImporter);
37
+ }
38
+ init(modelOptions) {
39
+ const options = new ModelCreatorOptions();
40
+ options.addSection = true;
41
+ options.addParagraph = true;
42
+ this.formatImagesImporter = new FormatImagesImporter();
43
+ this.documentModel = new ModelCreator(options).createModel(modelOptions).fillModel();
44
+ this.modelManager = new ClientModelManager(this.documentModel, modelOptions, new EmptyBatchUpdatableObject());
45
+ }
46
+ fillModel(text, charPropsBundle) {
47
+ const container = document.body.appendChild(this.createContainer());
48
+ try {
49
+ container.innerHTML = HtmlImporter.convertHtml(text);
50
+ charPropsBundle = charPropsBundle || this.createMaskedCharacterPropertiesBundle();
51
+ const measurer = new Measurer('');
52
+ const position = new SubDocumentPosition(this.documentModel.mainSubDocument, 0);
53
+ const initElements = container.childNodes;
54
+ new HtmlImporter(this.modelManager, measurer, position, initElements, charPropsBundle).import();
55
+ this.removeLastParagraph();
56
+ }
57
+ finally {
58
+ document.body.removeChild(container);
59
+ }
60
+ }
61
+ createMaskedCharacterPropertiesBundle() {
62
+ const maskedCharacterProperties = MaskedCharacterProperties.createDefault(this.documentModel);
63
+ const style = this.modelManager.model.stylesManager.getDefaultCharacterStyle();
64
+ return new MaskedCharacterPropertiesBundle(maskedCharacterProperties, style);
65
+ }
66
+ createContainer() {
67
+ const container = document.createElement('DIV');
68
+ container.id = 'import-container';
69
+ container.style.width = '0';
70
+ container.style.height = '0';
71
+ container.style.overflow = 'hidden';
72
+ return container;
73
+ }
74
+ removeLastParagraph() {
75
+ const lastParagraph = this.documentModel.mainSubDocument.getLastParagraph();
76
+ if (lastParagraph.length > 1)
77
+ return;
78
+ const section = this.documentModel.getSectionByPosition(lastParagraph.startLogPosition.value);
79
+ const lastChunk = this.documentModel.mainSubDocument.getLastChunk();
80
+ this.documentModel.mainSubDocument.paragraphs.pop();
81
+ section.setLength(this.documentModel.mainSubDocument, section.getLength() - lastParagraph.length);
82
+ lastChunk.removeRun(lastChunk.textRuns.length - 1);
83
+ }
84
+ }
@@ -62,6 +62,7 @@ export declare class HtmlImporter {
62
62
  getLastImportedRun(): RunInfo;
63
63
  columnSize(): Size;
64
64
  static convertHtml(html: string): string;
65
+ private static extractBodyContent;
65
66
  private static MapMissTablePropertiesByTagNames;
66
67
  private static MapShorthandProperty;
67
68
  }
@@ -289,7 +289,7 @@ export class HtmlImporter {
289
289
  html = html.replace(val, val.replace(/\n/gi, "<p/>"));
290
290
  });
291
291
  }
292
- html = html.replace(/(\n+\s+)|(\s+\n+)/gi, ' ');
292
+ html = html.replace(/(\r*\n+\s+)|(\s+\r*\n+)/gi, ' ');
293
293
  html = html.replace(/\n+/gi, ' ');
294
294
  html = html.replace(/\n/gi, RichUtils.specialCharacters.LineBreak);
295
295
  html = html.replace(/(<\/(?!(p)+)(\s*[^>]*)?>)<\/td>/gi, '$1<p>&nbsp;</p></td>');
@@ -298,9 +298,21 @@ export class HtmlImporter {
298
298
  html = html.replace(/<u>([\s\S]*?)<\/u>/gi, '<span style="text-decoration: underline">$1</span>');
299
299
  html = html.replace(/<s>([\s\S]*?)<\/s>/gi, '<span style="text-decoration: line-through">$1</span>');
300
300
  html = html.replace(/<\/([^\s>]+)(\s[^>]*)?><br><\/([^\s>]+)(\s[^>]*)?>/gi, '');
301
+ html = this.extractBodyContent(html);
301
302
  Log.print(LogSource.HtmlImporter, "convertHtml", () => html);
302
303
  return html;
303
304
  }
305
+ static extractBodyContent(html) {
306
+ const startTagMatch = /<body[^>]*>\s*/i.exec(html);
307
+ let startIndex = 0;
308
+ if (startTagMatch)
309
+ startIndex = startTagMatch.index + startTagMatch[0].length;
310
+ const endTagMatch = /\s*<\/body[^>]*>\s*/i.exec(html);
311
+ let endIndex = html.length;
312
+ if (endTagMatch)
313
+ endIndex = endTagMatch.index;
314
+ return html.substring(startIndex, endIndex);
315
+ }
304
316
  }
305
317
  HtmlImporter.importers = null;
306
318
  HtmlImporter.MapMissTablePropertiesByTagNames = new MapCreator()
@@ -0,0 +1,4 @@
1
+ import { FixedInterval } from "@devexpress/utils/lib/intervals/fixed";
2
+ import { SubDocument } from "../../../model/sub-document";
3
+ import { IProcessor } from "../../../processor";
4
+ export declare function insertHtmlInSubDocument(processor: IProcessor, subDocument: SubDocument, position: number, htmlText: string, callback: (interval: FixedInterval) => void): void;
@@ -0,0 +1,5 @@
1
+ import { HtmlDocumentImporter } from "./html-document-importer";
2
+ import { getAfterInsertCallback, getAfterInsertReject } from "../../callback-helpers";
3
+ export function insertHtmlInSubDocument(processor, subDocument, position, htmlText, callback) {
4
+ new HtmlDocumentImporter().importFromString(htmlText, processor.modelManager.richOptions, getAfterInsertCallback(processor, subDocument, position, callback), getAfterInsertReject(callback));
5
+ }
@@ -11,6 +11,7 @@ export declare class HtmlImporterMaskedParagraphProperties {
11
11
  private importRightIndent;
12
12
  private importSpacingBefore;
13
13
  private importSpacingAfter;
14
+ private importBackColor;
14
15
  private importLineSpacing;
15
16
  private setSpacingAsMultiple;
16
17
  private importTopBorder;