devexpress-richedit 24.1.4-build-24183-0102 → 24.1.4

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 (58) hide show
  1. package/dist/dx.richedit.js +139 -80
  2. package/dist/dx.richedit.min.js +1 -1
  3. package/lib/client/client-rich-edit.js +2 -2
  4. package/lib/common/formats/html/import/html-document-importer.js +1 -1
  5. package/lib/common/formats/html/import/html-importer.d.ts +14 -5
  6. package/lib/common/formats/html/import/html-importer.js +59 -18
  7. package/lib/common/formats/html/import/importers/a.d.ts +1 -1
  8. package/lib/common/formats/html/import/importers/a.js +1 -1
  9. package/lib/common/formats/html/import/importers/b.d.ts +1 -1
  10. package/lib/common/formats/html/import/importers/b.js +1 -1
  11. package/lib/common/formats/html/import/importers/base.d.ts +2 -1
  12. package/lib/common/formats/html/import/importers/base.js +1 -0
  13. package/lib/common/formats/html/import/importers/br.d.ts +1 -1
  14. package/lib/common/formats/html/import/importers/br.js +1 -1
  15. package/lib/common/formats/html/import/importers/center.d.ts +1 -1
  16. package/lib/common/formats/html/import/importers/center.js +1 -1
  17. package/lib/common/formats/html/import/importers/cite.d.ts +1 -1
  18. package/lib/common/formats/html/import/importers/cite.js +1 -1
  19. package/lib/common/formats/html/import/importers/div.d.ts +1 -1
  20. package/lib/common/formats/html/import/importers/div.js +3 -3
  21. package/lib/common/formats/html/import/importers/em.d.ts +1 -1
  22. package/lib/common/formats/html/import/importers/em.js +1 -1
  23. package/lib/common/formats/html/import/importers/font.d.ts +1 -1
  24. package/lib/common/formats/html/import/importers/font.js +1 -1
  25. package/lib/common/formats/html/import/importers/i.d.ts +1 -1
  26. package/lib/common/formats/html/import/importers/i.js +1 -1
  27. package/lib/common/formats/html/import/importers/img.d.ts +1 -1
  28. package/lib/common/formats/html/import/importers/img.js +3 -2
  29. package/lib/common/formats/html/import/importers/li.d.ts +2 -1
  30. package/lib/common/formats/html/import/importers/li.js +13 -10
  31. package/lib/common/formats/html/import/importers/list-base.d.ts +1 -1
  32. package/lib/common/formats/html/import/importers/list-base.js +2 -1
  33. package/lib/common/formats/html/import/importers/p.d.ts +3 -3
  34. package/lib/common/formats/html/import/importers/p.js +19 -16
  35. package/lib/common/formats/html/import/importers/pre.d.ts +1 -1
  36. package/lib/common/formats/html/import/importers/pre.js +1 -1
  37. package/lib/common/formats/html/import/importers/span.d.ts +1 -1
  38. package/lib/common/formats/html/import/importers/span.js +1 -1
  39. package/lib/common/formats/html/import/importers/table.d.ts +1 -1
  40. package/lib/common/formats/html/import/importers/table.js +2 -2
  41. package/lib/common/formats/html/import/importers/tbody.d.ts +1 -1
  42. package/lib/common/formats/html/import/importers/tbody.js +1 -1
  43. package/lib/common/formats/html/import/importers/td.d.ts +1 -1
  44. package/lib/common/formats/html/import/importers/td.js +2 -2
  45. package/lib/common/formats/html/import/importers/text-node.d.ts +1 -1
  46. package/lib/common/formats/html/import/importers/text-node.js +2 -2
  47. package/lib/common/formats/html/import/importers/tr.d.ts +1 -1
  48. package/lib/common/formats/html/import/importers/tr.js +1 -1
  49. package/lib/common/formats/html/import/importers/tt.d.ts +1 -1
  50. package/lib/common/formats/html/import/importers/tt.js +1 -1
  51. package/lib/common/formats/html/import/importers/undefined.d.ts +1 -1
  52. package/lib/common/formats/html/import/importers/undefined.js +2 -2
  53. package/lib/common/formats/html/import/utils/paragraph-list-properties-utils.js +13 -4
  54. package/lib/common/input-controller.d.ts +8 -8
  55. package/lib/common/input-controller.js +5 -5
  56. package/lib/common/model/fonts/loader.js +1 -1
  57. package/lib/common/rich-utils/html-utils.d.ts +1 -1
  58. package/package.json +3 -3
@@ -53,8 +53,8 @@ export class ClientRichEdit {
53
53
  this.rawDataSource = settings.rawDataSource;
54
54
  this.contextMenuSettings = settings.contextMenuSettings;
55
55
  this.fullScreenHelper = new FullScreenHelper(element);
56
- if ("eyJsaWNlbnNlS2V5IjoiZXdvZ0lDSm1iM0p0WVhRaU9pQXhMQW9nSUNKcGJuUmxjbTVoYkZWellXZGxTV1FpT2lBaWFUbHhVemQxYzBSQ01HVlpTbDlrVGkxb2FYaGtVU0lLZlE9PS5INTlJcG94ZC90cWdVcE1leVdhamhubjl2NnFtMkFrQmc2MW0yU05ZUHIreFBrdnRLUm04Wm4rU08rUVQ3NEt3MVpWQ0pGeEJYV1dJRlNyRG1EZlVqYmV6N2RzTnpJbTR6S1A5M2l4amVQR0Jnb2o4eG9VSmZvNldmZzNMblpTUlNLcHFpZz09In0=")
57
- config(JSON.parse(atob("eyJsaWNlbnNlS2V5IjoiZXdvZ0lDSm1iM0p0WVhRaU9pQXhMQW9nSUNKcGJuUmxjbTVoYkZWellXZGxTV1FpT2lBaWFUbHhVemQxYzBSQ01HVlpTbDlrVGkxb2FYaGtVU0lLZlE9PS5INTlJcG94ZC90cWdVcE1leVdhamhubjl2NnFtMkFrQmc2MW0yU05ZUHIreFBrdnRLUm04Wm4rU08rUVQ3NEt3MVpWQ0pGeEJYV1dJRlNyRG1EZlVqYmV6N2RzTnpJbTR6S1A5M2l4amVQR0Jnb2o4eG9VSmZvNldmZzNMblpTUlNLcHFpZz09In0=")));
56
+ if ("eyJsaWNlbnNlS2V5IjoiZXdvZ0lDSm1iM0p0WVhRaU9pQXhMQW9nSUNKcGJuUmxjbTVoYkZWellXZGxTV1FpT2lBaWFYWkdXQzFTVkdFeU1IbFVPRGh0YzAxNmRsQTJaeUlLZlE9PS5GYjZ4U0JwU3BSVHBWajZ0dWtlQTJZaU1WVW5tb0ZoSDJKV3Ryak5iN3p6VlNrNzhKa294RVFKOW9rVlErYnh0SzM1WWlFZkpEWGJnNktrYVA1ZEljcnp0ZHlsOFlGL2ltc3BIWkY5aWlaeGtVK0FXbFVrV1RUb2c0ZnZDbWlxMTl2MWhIdz09In0=")
57
+ config(JSON.parse(atob("eyJsaWNlbnNlS2V5IjoiZXdvZ0lDSm1iM0p0WVhRaU9pQXhMQW9nSUNKcGJuUmxjbTVoYkZWellXZGxTV1FpT2lBaWFYWkdXQzFTVkdFeU1IbFVPRGh0YzAxNmRsQTJaeUlLZlE9PS5GYjZ4U0JwU3BSVHBWajZ0dWtlQTJZaU1WVW5tb0ZoSDJKV3Ryak5iN3p6VlNrNzhKa294RVFKOW9rVlErYnh0SzM1WWlFZkpEWGJnNktrYVA1ZEljcnp0ZHlsOFlGL2ltc3BIWkY5aWlaeGtVK0FXbFVrV1RUb2c0ZnZDbWlxMTl2MWhIdz09In0=")));
58
58
  this.prepareElement(element, settings);
59
59
  this.initDefaultFontsAndStyles();
60
60
  this.initBars(settings.ribbon, settings.fonts);
@@ -51,7 +51,7 @@ export class HtmlDocumentImporter {
51
51
  const measurer = new Measurer('');
52
52
  const position = new SubDocumentPosition(this.documentModel.mainSubDocument, 0);
53
53
  const initElements = container.childNodes;
54
- new HtmlImporter(this.modelManager, measurer, position, initElements, charPropsBundle).import();
54
+ new HtmlImporter(this.modelManager, measurer, position, initElements, charPropsBundle, this.formatImagesImporter).import();
55
55
  this.removeLastParagraph();
56
56
  }
57
57
  finally {
@@ -11,6 +11,7 @@ import { HtmlTagImporterBase } from './importers/base';
11
11
  import { LoadFontInfo } from './load-font-info';
12
12
  import { HtmlImporterMaskedCharacterProperties } from './utils/character-properties-utils';
13
13
  import { ParagraphListPropertiesUtils } from './utils/paragraph-list-properties-utils';
14
+ import { FormatImagesImporter } from '../../utils/images-import';
14
15
  export declare type TypeOfTagImporterConstructor = new (importer: HtmlImporter) => HtmlTagImporterBase;
15
16
  export declare class LevelInfo {
16
17
  element: HTMLElement;
@@ -19,7 +20,7 @@ export declare class LevelInfo {
19
20
  allowInsertRuns: boolean;
20
21
  constructor(element: HTMLElement, childElements: HTMLElement[], allowInsertRuns: boolean);
21
22
  initTagImporter(importer: HtmlImporter): this;
22
- static getElementTag(elem: HTMLElement): string;
23
+ static getElementTag(elem: HTMLElement | ChildNode): string;
23
24
  }
24
25
  export declare class HtmlImportData {
25
26
  runsInfo: RunInfo[];
@@ -29,18 +30,22 @@ export declare class HtmlImportData {
29
30
  export declare class HtmlImporter {
30
31
  currPosition: number;
31
32
  htmlImporterMaskedCharacterProperties: HtmlImporterMaskedCharacterProperties;
32
- paragraphListpropertiesUtils: ParagraphListPropertiesUtils;
33
+ paragraphListPropertiesUtils: ParagraphListPropertiesUtils;
33
34
  private importedRunsInfo;
34
35
  importedTablesInfo: TableInfo[];
35
36
  loadFontInfos: LoadFontInfo[];
36
37
  tempFontInfoCache: FontInfoCache;
37
38
  get currElement(): HTMLElement;
38
- get currElementChilds(): HTMLElement[];
39
+ get currElementChildren(): HTMLElement[];
39
40
  levelInfo: LevelInfo[];
41
+ get prevLevelInfo(): LevelInfo;
42
+ get currLevelInfo(): LevelInfo;
43
+ get currListItemLevelInfo(): LevelInfo | null;
40
44
  fieldsId: number;
41
45
  prevRunIsParagraph: boolean;
42
46
  listIndex: number;
43
47
  listInfos: ImportedParagraphListInfo[];
48
+ get currListInfo(): ImportedParagraphListInfo;
44
49
  importStarted: boolean;
45
50
  modelManager: IModelManager;
46
51
  private subDocPosition;
@@ -49,7 +54,8 @@ export declare class HtmlImporter {
49
54
  measurer: IMeasurer;
50
55
  tagImporters: Record<string, TypeOfTagImporterConstructor>;
51
56
  private static importers;
52
- constructor(modelManager: IModelManager, measurer: IMeasurer, subDocPosition: SubDocumentPosition, initElements: HTMLElement[], charPropsBundle: MaskedCharacterPropertiesBundle);
57
+ private formatImagesImporter?;
58
+ constructor(modelManager: IModelManager, measurer: IMeasurer, subDocPosition: SubDocumentPosition, initElements: HTMLElement[], charPropsBundle: MaskedCharacterPropertiesBundle, formatImagesImporter?: FormatImagesImporter);
53
59
  import(): FixedInterval;
54
60
  private convertChildElements;
55
61
  private getSortedTables;
@@ -57,10 +63,13 @@ export declare class HtmlImporter {
57
63
  private putDownParentPropertiesToChild;
58
64
  private getStyles;
59
65
  addRun(run: RunInfo, forceAdd?: boolean): void;
60
- addParagraphRun(listInfo: ImportedParagraphListInfo, element: HTMLElement, isTableCellTag?: boolean): void;
66
+ addParagraphRun(element: HTMLElement, listInfo?: ImportedParagraphListInfo, isTableCellTag?: boolean): void;
67
+ addCurrLevelParagraphRunIfNeeded(): void;
61
68
  removeAllTrailingLineBreaks(): void;
62
69
  getLastImportedRun(): RunInfo;
63
70
  columnSize(): Size;
71
+ private registerImageRuns;
72
+ private findIndexImportedInlinePictureRunInfo;
64
73
  static convertHtml(html: string): string;
65
74
  private static extractBodyContent;
66
75
  private static MapMissTablePropertiesByTagNames;
@@ -2,13 +2,14 @@ import { MapCreator } from '../../../utils/map-creator';
2
2
  import { ColumnCalculator } from '../../../layout-formatter/formatter/utils/columns-calculator';
3
3
  import { FontInfoCache } from '../../../model/caches/hashed-caches/font-info-cache';
4
4
  import { RunType } from '../../../model/runs/run-type';
5
+ import { SubDocumentPosition } from '../../../model/sub-document';
5
6
  import { Log } from '../../../rich-utils/debug/logger/base-logger/log';
6
7
  import { LogSource } from '../../../rich-utils/debug/logger/base-logger/log-source';
7
8
  import { UnitConverter } from '@devexpress/utils/lib/class/unit-converter';
8
9
  import { FixedInterval } from '@devexpress/utils/lib/intervals/fixed';
9
10
  import { DomUtils } from '@devexpress/utils/lib/utils/dom';
10
11
  import { ListUtils } from '@devexpress/utils/lib/utils/list';
11
- import { ImportedTextRunInfo, ImportedParagraphRunInfo } from './containers/runs';
12
+ import { ImportedTextRunInfo, ImportedParagraphRunInfo, ImportedInlinePictureRunInfo, } from './containers/runs';
12
13
  import { HtmlModelInserter } from './html-model-inserter';
13
14
  import { HtmlATagImporter } from './importers/a';
14
15
  import { HtmlBTagImporter } from './importers/b';
@@ -21,7 +22,7 @@ import { HtmlITagImporter } from './importers/i';
21
22
  import { HtmlImgTagImporter } from './importers/img';
22
23
  import { HtmlLiTagImporter } from './importers/li';
23
24
  import { HtmlOlTagImporter } from './importers/ol';
24
- import { HtmlH1TagImporter, HtmlH2TagImporter, HtmlH3TagImporter, HtmlH4TagImporter, HtmlH5TagImporter, HtmlH6TagImporter, HtmlPTagImporter } from './importers/p';
25
+ import { HtmlH1TagImporter, HtmlH2TagImporter, HtmlH3TagImporter, HtmlH4TagImporter, HtmlH5TagImporter, HtmlH6TagImporter, HtmlPTagImporter, } from './importers/p';
25
26
  import { HtmlPreTagImporter } from './importers/pre';
26
27
  import { HtmlSpanTagImporter } from './importers/span';
27
28
  import { HtmlTableTagImporter } from './importers/table';
@@ -37,6 +38,9 @@ import { ParagraphListPropertiesUtils } from './utils/paragraph-list-properties-
37
38
  import { RichUtils } from '../../../model/rich-utils';
38
39
  import { HtmlImporterMaskedParagraphProperties } from './utils/paragraph-properties-utils';
39
40
  import { HtmlImporterTabStops } from './utils/tab-stops-utils';
41
+ import { FormatImagesImporterData } from '../../utils/images-import';
42
+ import { InlinePictureRun } from '../../../../common/model/runs/inline-picture-run';
43
+ import { ImageLoadingOptions } from '../../../../common/model/manipulators/picture-manipulator/loader/image-loading-options';
40
44
  export class LevelInfo {
41
45
  constructor(element, childElements, allowInsertRuns) {
42
46
  this.element = element;
@@ -53,8 +57,8 @@ export class LevelInfo {
53
57
  return this;
54
58
  }
55
59
  static getElementTag(elem) {
56
- const tag = elem.tagName;
57
- return tag ? tag.toUpperCase() : "";
60
+ const tag = DomUtils.isHTMLElementNode(elem) && elem.tagName;
61
+ return tag ? tag.toUpperCase() : '';
58
62
  }
59
63
  }
60
64
  export class HtmlImportData {
@@ -64,7 +68,7 @@ export class HtmlImportData {
64
68
  }
65
69
  }
66
70
  export class HtmlImporter {
67
- constructor(modelManager, measurer, subDocPosition, initElements, charPropsBundle) {
71
+ constructor(modelManager, measurer, subDocPosition, initElements, charPropsBundle, formatImagesImporter) {
68
72
  this.fieldsId = 0;
69
73
  this.listIndex = 0;
70
74
  this.listInfos = [];
@@ -105,19 +109,27 @@ export class HtmlImporter {
105
109
  this.measurer = measurer;
106
110
  this.currPosition = this.subDocPosition.position;
107
111
  this.levelInfo = [new LevelInfo(null, initElements, true)];
112
+ this.formatImagesImporter = formatImagesImporter;
108
113
  this.loadFontInfos = [];
109
114
  this.tempFontInfoCache = new FontInfoCache(this.modelManager.model.cache.fontInfoCache.fontMeasurer);
110
115
  this.htmlImporterMaskedCharacterProperties =
111
116
  new HtmlImporterMaskedCharacterProperties(this, this.loadFontInfos, this.tempFontInfoCache, !modelManager.richOptions.fonts.limitedFonts);
112
- this.paragraphListpropertiesUtils = new ParagraphListPropertiesUtils(this, this.htmlImporterMaskedCharacterProperties);
117
+ this.paragraphListPropertiesUtils = new ParagraphListPropertiesUtils(this, this.htmlImporterMaskedCharacterProperties);
113
118
  this.tagImporters = {};
114
119
  for (let importerConst of HtmlImporter.importers)
115
120
  this.tagImporters[new importerConst(this).elementTag()] = importerConst;
116
121
  }
117
122
  get currElement() { return ListUtils.last(this.levelInfo).element; }
118
123
  ;
119
- get currElementChilds() { return ListUtils.last(this.levelInfo).childElements; }
124
+ get currElementChildren() { return ListUtils.last(this.levelInfo).childElements; }
120
125
  ;
126
+ get prevLevelInfo() { return this.levelInfo[this.levelInfo.length - 2]; }
127
+ get currLevelInfo() { return ListUtils.last(this.levelInfo); }
128
+ get currListItemLevelInfo() { return ListUtils.reverseElementBy(this.levelInfo, (levelInfo) => { var _a; return ((_a = levelInfo.tagImporter) === null || _a === void 0 ? void 0 : _a.elementTag()) === 'LI'; }); }
129
+ get currListInfo() {
130
+ const currListItemLevelInfo = this.currListItemLevelInfo;
131
+ return currListItemLevelInfo && !currListItemLevelInfo.tagImporter.paragraphWasAddedBefore ? ListUtils.last(this.listInfos) : null;
132
+ }
121
133
  get subDocument() { return this.subDocPosition.subDocument; }
122
134
  import() {
123
135
  this.importStarted = false;
@@ -138,11 +150,13 @@ export class HtmlImporter {
138
150
  insertedInterval = new FixedInterval(this.subDocPosition.position, 0);
139
151
  for (let info of this.loadFontInfos)
140
152
  this.modelManager.modelManipulator.font.loadFontInfo(info.fontInfo, info.subDocument, [info.applyNewFontOnIntervalsAfterLoad], this.measurer);
153
+ if (this.formatImagesImporter)
154
+ this.registerImageRuns();
141
155
  });
142
156
  return insertedInterval;
143
157
  }
144
158
  convertChildElements(preserveLineBreaks = false) {
145
- for (let element of this.currElementChilds)
159
+ for (let element of this.currElementChildren)
146
160
  this.convertElement(element, preserveLineBreaks);
147
161
  }
148
162
  getSortedTables() {
@@ -164,18 +178,18 @@ export class HtmlImporter {
164
178
  importer.enablePreserveLineBreaks = preserveLineBreaks;
165
179
  if (importer.isAllowed())
166
180
  importer.importBefore();
167
- if (importer.isImportChilds())
181
+ if (importer.isImportChildren())
168
182
  this.convertChildElements(preserveLineBreaks || importer.shouldPreserveLineBreaksOnChilds());
169
183
  if (importer.isAllowed())
170
184
  importer.importAfter();
171
185
  this.levelInfo.pop();
172
186
  }
173
187
  putDownParentPropertiesToChild() {
174
- if (!this.currElementChilds)
188
+ if (!this.currElementChildren)
175
189
  return;
176
190
  const element = this.currElement;
177
191
  const missTag = HtmlImporter.MapMissTablePropertiesByTagNames[ListUtils.last(this.levelInfo).tagImporter.elementTag()];
178
- ListUtils.forEach(this.currElementChilds, (childElement) => {
192
+ ListUtils.forEach(this.currElementChildren, (childElement) => {
179
193
  const childElemStyle = this.getStyles(childElement);
180
194
  if (!Object.keys(childElemStyle).length)
181
195
  return;
@@ -211,19 +225,26 @@ export class HtmlImporter {
211
225
  }
212
226
  addRun(run, forceAdd = false) {
213
227
  if (forceAdd || ListUtils.last(this.levelInfo).allowInsertRuns) {
228
+ const isParagraph = run.runType == RunType.ParagraphRun || run.runType == RunType.SectionRun;
214
229
  this.importedRunsInfo.push(run);
215
230
  this.currPosition += run.runLength;
216
- this.prevRunIsParagraph = run.runType == RunType.ParagraphRun || run.runType == RunType.SectionRun;
231
+ this.prevRunIsParagraph = isParagraph;
217
232
  this.importStarted = true;
233
+ if (isParagraph && this.currListItemLevelInfo)
234
+ this.currListItemLevelInfo.tagImporter.paragraphWasAddedBefore = true;
218
235
  }
219
236
  }
220
- addParagraphRun(listInfo, element, isTableCellTag = false) {
237
+ addParagraphRun(element, listInfo = null, isTableCellTag = false) {
221
238
  const htmlProperties = new HtmlImporterMaskedParagraphProperties();
222
239
  const properties = htmlProperties.import(this.modelManager.model.colorProvider, element, isTableCellTag);
223
240
  const tabs = HtmlImporterTabStops.import(element);
224
241
  this.removeAllTrailingLineBreaks();
225
242
  this.addRun(new ImportedParagraphRunInfo(listInfo, this.charPropsBundle, properties, tabs));
226
243
  }
244
+ addCurrLevelParagraphRunIfNeeded() {
245
+ if (this.currLevelInfo.element.previousSibling && !this.prevRunIsParagraph)
246
+ this.addParagraphRun(this.currLevelInfo.element, this.currListInfo);
247
+ }
227
248
  removeAllTrailingLineBreaks() {
228
249
  const last = this.importedRunsInfo.length - 1;
229
250
  for (let i = last; i >= last - 1; i--) {
@@ -244,6 +265,28 @@ export class HtmlImporter {
244
265
  return ColumnCalculator.findMinimalColumnSize(section.sectionProperties)
245
266
  .applyConverter(UnitConverter.pixelsToTwips);
246
267
  }
268
+ registerImageRuns() {
269
+ let importedRunsInfoIndex = -1;
270
+ this.subDocument.chunks.forEach((chunk) => {
271
+ chunk.textRuns.forEach((run) => {
272
+ if (run instanceof InlinePictureRun) {
273
+ importedRunsInfoIndex = this.findIndexImportedInlinePictureRunInfo(run.info.publicAPIID, ++importedRunsInfoIndex);
274
+ const subDocPos = new SubDocumentPosition(this.subDocument, run.startOffset);
275
+ const importedRunsInfo = this.importedRunsInfo[importedRunsInfoIndex];
276
+ const options = ImageLoadingOptions.initByActualSize(importedRunsInfo.actualSize);
277
+ const importerData = new FormatImagesImporterData(subDocPos, options, run);
278
+ this.formatImagesImporter.registerImageRun(importerData);
279
+ }
280
+ });
281
+ });
282
+ }
283
+ findIndexImportedInlinePictureRunInfo(publicAPIID, startIndex = 0) {
284
+ for (let i = startIndex, runInfo; runInfo = this.importedRunsInfo[i]; i++) {
285
+ if (runInfo instanceof ImportedInlinePictureRunInfo && runInfo.picInfo.publicAPIID === publicAPIID)
286
+ return i;
287
+ }
288
+ return -1;
289
+ }
247
290
  static convertHtml(html) {
248
291
  Log.print(LogSource.HtmlImporter, "convertHtml", () => html);
249
292
  html = html.replace(/<(\w[^>]*) lang=([^ |>]*)([^>]*)/gi, "<$1$3");
@@ -276,10 +319,6 @@ export class HtmlImporter {
276
319
  html = html.replace(/<font[^>]*>([^<>]+)<\/font>/gi, '$1');
277
320
  html = html.replace(/<span\s*><span\s*>([^<>]+)<\/span><\/span>/ig, '$1');
278
321
  html = html.replace(/<span>([^<>]+)<\/span>/gi, '$1');
279
- html = html.replace(/\s*(<li[\S\s]*?>)\s*/gi, '$1');
280
- html = html.replace(/\s*(<\/li>)\s*/gi, '$1');
281
- html = html.replace(/<li([^>]*)>([^<>]+)<\/li>/gi, '<li$1><p>$2</p></li>');
282
- html = html.replace(/<li([^>]*)>(([^<>]*)<(?!p)[\s\S]*?)<\/li>/gi, '<li$1><p>$2</p></li>');
283
322
  html = html.replace(/<caption([^>]*)>[\s\S]*?<\/caption>/gi, '');
284
323
  var array = html.match(/<[^>]*style\s*=\s*[^>]*>/gi);
285
324
  if (array && array.length > 0) {
@@ -311,6 +350,8 @@ export class HtmlImporter {
311
350
  html = html.replace(/<u>([\s\S]*?)<\/u>/gi, '<span style="text-decoration: underline">$1</span>');
312
351
  html = html.replace(/<s>([\s\S]*?)<\/s>/gi, '<span style="text-decoration: line-through">$1</span>');
313
352
  html = html.replace(/<\/([^\s>]+)(\s[^>]*)?><br><\/([^\s>]+)(\s[^>]*)?>/gi, '');
353
+ html = html.replace(/\s*(<([ph]\d?|ol|ul|li))/gi, '$1');
354
+ html = html.replace(/(<\/([ph]\d?|ol|ul|li)>)\s*/gi, '$1');
314
355
  html = this.extractBodyContent(html);
315
356
  Log.print(LogSource.HtmlImporter, "convertHtml", () => html);
316
357
  return html;
@@ -334,7 +375,7 @@ HtmlImporter.MapMissTablePropertiesByTagNames = new MapCreator()
334
375
  .add("TH", true)
335
376
  .get();
336
377
  HtmlImporter.MapShorthandProperty = new MapCreator()
337
- .add("background", true)
378
+ .add("background", false)
338
379
  .add("border", true)
339
380
  .add("borderImage", true)
340
381
  .add("borderTop", true)
@@ -2,7 +2,7 @@ import { HtmlTagImporterBase } from './base';
2
2
  export declare class HtmlATagImporter extends HtmlTagImporterBase {
3
3
  elementTag(): string;
4
4
  importBefore(): void;
5
- isImportChilds(): boolean;
5
+ isImportChildren(): boolean;
6
6
  importAfter(): void;
7
7
  isAllowed(): boolean;
8
8
  }
@@ -24,7 +24,7 @@ export class HtmlATagImporter extends HtmlTagImporterBase {
24
24
  this.addRun(new ImportedTextRunInfo(this.importer.modelManager.model, this.importer.measurer, codeText, this.importer.htmlImporterMaskedCharacterProperties.getBundleFrom(this.element, new FixedInterval(this.importer.currPosition, codeText.length))));
25
25
  this.addRun(new ImportedFieldCodeEndRunInfo(this.importer.charPropsBundle, this.importer.fieldsId));
26
26
  }
27
- isImportChilds() {
27
+ isImportChildren() {
28
28
  return true;
29
29
  }
30
30
  importAfter() {
@@ -2,6 +2,6 @@ import { HtmlTagImporterBase } from './base';
2
2
  export declare class HtmlBTagImporter extends HtmlTagImporterBase {
3
3
  elementTag(): string;
4
4
  importBefore(): void;
5
- isImportChilds(): boolean;
5
+ isImportChildren(): boolean;
6
6
  importAfter(): void;
7
7
  }
@@ -5,7 +5,7 @@ export class HtmlBTagImporter extends HtmlTagImporterBase {
5
5
  }
6
6
  importBefore() {
7
7
  }
8
- isImportChilds() {
8
+ isImportChildren() {
9
9
  return true;
10
10
  }
11
11
  importAfter() {
@@ -3,12 +3,13 @@ import { RunInfo } from '../containers/runs';
3
3
  import { HtmlImporter } from '../html-importer';
4
4
  export declare abstract class HtmlTagImporterBase {
5
5
  enablePreserveLineBreaks: boolean;
6
+ paragraphWasAddedBefore: boolean;
6
7
  protected importer: HtmlImporter;
7
8
  get colorProvider(): ColorProvider;
8
9
  constructor(importer: HtmlImporter);
9
10
  protected getClosestImporterByTagName(tagName: string): HtmlTagImporterBase;
10
11
  abstract importBefore(): any;
11
- abstract isImportChilds(): boolean;
12
+ abstract isImportChildren(): boolean;
12
13
  abstract importAfter(): any;
13
14
  abstract elementTag(): string;
14
15
  shouldPreserveLineBreaksOnChilds(): boolean;
@@ -2,6 +2,7 @@ import { ListUtils } from '@devexpress/utils/lib/utils/list';
2
2
  export class HtmlTagImporterBase {
3
3
  constructor(importer) {
4
4
  this.enablePreserveLineBreaks = false;
5
+ this.paragraphWasAddedBefore = false;
5
6
  this.importer = importer;
6
7
  }
7
8
  get colorProvider() { return this.importer.modelManager.model.colorProvider; }
@@ -2,6 +2,6 @@ import { HtmlTagImporterBase } from './base';
2
2
  export declare class HtmlBrTagImporter extends HtmlTagImporterBase {
3
3
  elementTag(): string;
4
4
  importBefore(): void;
5
- isImportChilds(): boolean;
5
+ isImportChildren(): boolean;
6
6
  importAfter(): void;
7
7
  }
@@ -12,7 +12,7 @@ export class HtmlBrTagImporter extends HtmlTagImporterBase {
12
12
  RichUtils.specialCharacters.LineBreak;
13
13
  this.addRun(new ImportedTextRunInfo(this.importer.modelManager.model, this.importer.measurer, breakChar, this.importer.htmlImporterMaskedCharacterProperties.getBundleFrom(this.element, new FixedInterval(this.importer.currPosition, 1))));
14
14
  }
15
- isImportChilds() {
15
+ isImportChildren() {
16
16
  return false;
17
17
  }
18
18
  importAfter() {
@@ -2,6 +2,6 @@ import { HtmlTagImporterBase } from './base';
2
2
  export declare class HtmlCenterTagImporter extends HtmlTagImporterBase {
3
3
  elementTag(): string;
4
4
  importBefore(): void;
5
- isImportChilds(): boolean;
5
+ isImportChildren(): boolean;
6
6
  importAfter(): void;
7
7
  }
@@ -5,7 +5,7 @@ export class HtmlCenterTagImporter extends HtmlTagImporterBase {
5
5
  }
6
6
  importBefore() {
7
7
  }
8
- isImportChilds() {
8
+ isImportChildren() {
9
9
  return true;
10
10
  }
11
11
  importAfter() {
@@ -2,6 +2,6 @@ import { HtmlTagImporterBase } from './base';
2
2
  export declare class HtmlCiteTagImporter extends HtmlTagImporterBase {
3
3
  elementTag(): string;
4
4
  importBefore(): void;
5
- isImportChilds(): boolean;
5
+ isImportChildren(): boolean;
6
6
  importAfter(): void;
7
7
  }
@@ -5,7 +5,7 @@ export class HtmlCiteTagImporter extends HtmlTagImporterBase {
5
5
  }
6
6
  importBefore() {
7
7
  }
8
- isImportChilds() {
8
+ isImportChildren() {
9
9
  return true;
10
10
  }
11
11
  importAfter() {
@@ -2,6 +2,6 @@ import { HtmlTagImporterBase } from './base';
2
2
  export declare class HtmlDivTagImporter extends HtmlTagImporterBase {
3
3
  elementTag(): string;
4
4
  importBefore(): void;
5
- isImportChilds(): boolean;
5
+ isImportChildren(): boolean;
6
6
  importAfter(): void;
7
7
  }
@@ -5,13 +5,13 @@ export class HtmlDivTagImporter extends HtmlTagImporterBase {
5
5
  }
6
6
  importBefore() {
7
7
  if (!this.importer.prevRunIsParagraph && this.importer.importStarted)
8
- this.importer.addParagraphRun(null, this.element);
8
+ this.importer.addParagraphRun(this.element);
9
9
  }
10
- isImportChilds() {
10
+ isImportChildren() {
11
11
  return true;
12
12
  }
13
13
  importAfter() {
14
14
  if (!this.importer.prevRunIsParagraph)
15
- this.importer.addParagraphRun(null, this.element);
15
+ this.importer.addParagraphRun(this.element);
16
16
  }
17
17
  }
@@ -2,6 +2,6 @@ import { HtmlTagImporterBase } from './base';
2
2
  export declare class HtmlEmTagImporter extends HtmlTagImporterBase {
3
3
  elementTag(): string;
4
4
  importBefore(): void;
5
- isImportChilds(): boolean;
5
+ isImportChildren(): boolean;
6
6
  importAfter(): void;
7
7
  }
@@ -5,7 +5,7 @@ export class HtmlEmTagImporter extends HtmlTagImporterBase {
5
5
  }
6
6
  importBefore() {
7
7
  }
8
- isImportChilds() {
8
+ isImportChildren() {
9
9
  return true;
10
10
  }
11
11
  importAfter() {
@@ -2,6 +2,6 @@ import { HtmlTagImporterBase } from './base';
2
2
  export declare class HtmlFontTagImporter extends HtmlTagImporterBase {
3
3
  elementTag(): string;
4
4
  importBefore(): void;
5
- isImportChilds(): boolean;
5
+ isImportChildren(): boolean;
6
6
  importAfter(): void;
7
7
  }
@@ -5,7 +5,7 @@ export class HtmlFontTagImporter extends HtmlTagImporterBase {
5
5
  }
6
6
  importBefore() {
7
7
  }
8
- isImportChilds() {
8
+ isImportChildren() {
9
9
  return true;
10
10
  }
11
11
  importAfter() {
@@ -2,6 +2,6 @@ import { HtmlTagImporterBase } from './base';
2
2
  export declare class HtmlITagImporter extends HtmlTagImporterBase {
3
3
  elementTag(): string;
4
4
  importBefore(): void;
5
- isImportChilds(): boolean;
5
+ isImportChildren(): boolean;
6
6
  importAfter(): void;
7
7
  }
@@ -5,7 +5,7 @@ export class HtmlITagImporter extends HtmlTagImporterBase {
5
5
  }
6
6
  importBefore() {
7
7
  }
8
- isImportChilds() {
8
+ isImportChildren() {
9
9
  return true;
10
10
  }
11
11
  importAfter() {
@@ -2,6 +2,6 @@ import { HtmlTagImporterBase } from './base';
2
2
  export declare class HtmlImgTagImporter extends HtmlTagImporterBase {
3
3
  elementTag(): string;
4
4
  importBefore(): void;
5
- isImportChilds(): boolean;
5
+ isImportChildren(): boolean;
6
6
  importAfter(): void;
7
7
  }
@@ -10,7 +10,8 @@ export class HtmlImgTagImporter extends HtmlTagImporterBase {
10
10
  importBefore() {
11
11
  const imageElement = this.importer.currElement;
12
12
  const originalSize = new Size(imageElement.naturalWidth, imageElement.naturalHeight);
13
- const actualSize = new Size(imageElement.width, imageElement.height);
13
+ const styleSize = new Size(parseFloat(imageElement.style.width), parseFloat(imageElement.style.height));
14
+ const actualSize = new Size(imageElement.width || styleSize.width, imageElement.height || styleSize.height);
14
15
  if (originalSize.width !== undefined && originalSize.height !== undefined)
15
16
  originalSize.applyConverter(UnitConverter.pixelsToTwips);
16
17
  if (actualSize.width !== undefined && actualSize.height !== undefined)
@@ -18,7 +19,7 @@ export class HtmlImgTagImporter extends HtmlTagImporterBase {
18
19
  const cacheInfo = this.importer.modelManager.model.cache.imageCache.createUnloadedByBase64OrUrl(imageElement.src, originalSize);
19
20
  this.addRun(new ImportedInlinePictureRunInfo(this.importer.charPropsBundle, InlinePictureInfo.defaultInfo(cacheInfo), actualSize));
20
21
  }
21
- isImportChilds() {
22
+ isImportChildren() {
22
23
  return false;
23
24
  }
24
25
  importAfter() {
@@ -2,6 +2,7 @@ import { HtmlTagImporterBase } from './base';
2
2
  export declare class HtmlLiTagImporter extends HtmlTagImporterBase {
3
3
  elementTag(): string;
4
4
  importBefore(): void;
5
- isImportChilds(): boolean;
5
+ isImportChildren(): boolean;
6
6
  importAfter(): void;
7
+ private isListElement;
7
8
  }
@@ -1,23 +1,26 @@
1
1
  import { ListUtils } from '@devexpress/utils/lib/utils/list';
2
2
  import { HtmlTagImporterBase } from './base';
3
- import { Errors } from '@devexpress/utils/lib/errors';
4
- import { DomUtils } from '@devexpress/utils/lib/utils/dom';
5
3
  import { LevelInfo } from '../html-importer';
6
4
  export class HtmlLiTagImporter extends HtmlTagImporterBase {
7
5
  elementTag() {
8
6
  return 'LI';
9
7
  }
10
- importBefore() { }
11
- isImportChilds() {
8
+ importBefore() {
9
+ const firstChild = this.element.childNodes[0];
10
+ this.element.innerHTML = this.element.innerHTML.trim();
11
+ if (this.isListElement(firstChild))
12
+ this.importer.addParagraphRun(this.element, this.importer.currListInfo);
13
+ }
14
+ isImportChildren() {
12
15
  return true;
13
16
  }
14
17
  importAfter() {
15
18
  const lastChild = ListUtils.last([...this.element.childNodes]);
16
- if (!DomUtils.isHTMLElementNode(lastChild) || LevelInfo.getElementTag(lastChild) !== 'UL' && LevelInfo.getElementTag(lastChild) !== 'OL') {
17
- const listInfo = ListUtils.last(this.importer.listInfos);
18
- if (!listInfo)
19
- throw new Error(Errors.InternalException);
20
- this.importer.addParagraphRun(listInfo, this.element);
21
- }
19
+ if (!this.importer.prevRunIsParagraph && !this.isListElement(lastChild))
20
+ this.importer.addParagraphRun(this.element, this.importer.currListInfo);
21
+ }
22
+ isListElement(elem) {
23
+ const tagName = LevelInfo.getElementTag(elem);
24
+ return tagName === 'OL' || tagName === 'UL';
22
25
  }
23
26
  }
@@ -2,6 +2,6 @@ import { HtmlTagImporterBase } from './base';
2
2
  export declare abstract class HtmlListTagImporterBase extends HtmlTagImporterBase {
3
3
  private _ignored;
4
4
  importBefore(): void;
5
- isImportChilds(): boolean;
5
+ isImportChildren(): boolean;
6
6
  importAfter(): void;
7
7
  }
@@ -10,6 +10,7 @@ export class HtmlListTagImporterBase extends HtmlTagImporterBase {
10
10
  this._ignored = false;
11
11
  }
12
12
  importBefore() {
13
+ this.importer.addCurrLevelParagraphRunIfNeeded();
13
14
  const listIndex = this.importer.listIndex;
14
15
  const parentList = ListUtils.last(this.importer.listInfos);
15
16
  const listLevel = parentList
@@ -23,7 +24,7 @@ export class HtmlListTagImporterBase extends HtmlTagImporterBase {
23
24
  const displayFormat = ParagraphListPropertiesUtils.importDisplayFormatStringByParentListFormat(listFormat, parentList === null || parentList === void 0 ? void 0 : parentList.listFormat, listLevel);
24
25
  this.importer.listInfos.push(new ImportedParagraphListInfo(listIndex, listLevel, listFormat, listFormat == NumberingFormat.Bullet ? NumberingType.Bullet : NumberingType.MultiLevel, displayFormat, null));
25
26
  }
26
- isImportChilds() {
27
+ isImportChildren() {
27
28
  return true;
28
29
  }
29
30
  importAfter() {
@@ -1,12 +1,12 @@
1
1
  import { HtmlTagImporterBase } from './base';
2
2
  export declare class HtmlPTagImporter extends HtmlTagImporterBase {
3
3
  private listInfo;
4
- private importChilds;
5
- private generateParagraph;
4
+ private importChildren;
6
5
  elementTag(): string;
7
6
  importBefore(): void;
8
- isImportChilds(): boolean;
7
+ isImportChildren(): boolean;
9
8
  importAfter(): void;
9
+ private getListInfo;
10
10
  }
11
11
  export declare class HtmlH1TagImporter extends HtmlPTagImporter {
12
12
  elementTag(): string;