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

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.
@@ -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;
@@ -49,7 +50,8 @@ export declare class HtmlImporter {
49
50
  measurer: IMeasurer;
50
51
  tagImporters: Record<string, TypeOfTagImporterConstructor>;
51
52
  private static importers;
52
- constructor(modelManager: IModelManager, measurer: IMeasurer, subDocPosition: SubDocumentPosition, initElements: HTMLElement[], charPropsBundle: MaskedCharacterPropertiesBundle);
53
+ private formatImagesImporter?;
54
+ constructor(modelManager: IModelManager, measurer: IMeasurer, subDocPosition: SubDocumentPosition, initElements: HTMLElement[], charPropsBundle: MaskedCharacterPropertiesBundle, formatImagesImporter?: FormatImagesImporter);
53
55
  import(): FixedInterval;
54
56
  private convertChildElements;
55
57
  private getSortedTables;
@@ -61,6 +63,8 @@ export declare class HtmlImporter {
61
63
  removeAllTrailingLineBreaks(): void;
62
64
  getLastImportedRun(): RunInfo;
63
65
  columnSize(): Size;
66
+ private registerImageRuns;
67
+ private findIndexImportedInlinePictureRunInfo;
64
68
  static convertHtml(html: string): string;
65
69
  private static extractBodyContent;
66
70
  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;
@@ -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,6 +109,7 @@ 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 =
@@ -138,6 +143,8 @@ export class HtmlImporter {
138
143
  insertedInterval = new FixedInterval(this.subDocPosition.position, 0);
139
144
  for (let info of this.loadFontInfos)
140
145
  this.modelManager.modelManipulator.font.loadFontInfo(info.fontInfo, info.subDocument, [info.applyNewFontOnIntervalsAfterLoad], this.measurer);
146
+ if (this.formatImagesImporter)
147
+ this.registerImageRuns();
141
148
  });
142
149
  return insertedInterval;
143
150
  }
@@ -244,6 +251,28 @@ export class HtmlImporter {
244
251
  return ColumnCalculator.findMinimalColumnSize(section.sectionProperties)
245
252
  .applyConverter(UnitConverter.pixelsToTwips);
246
253
  }
254
+ registerImageRuns() {
255
+ let importedRunsInfoIndex = -1;
256
+ this.subDocument.chunks.forEach((chunk) => {
257
+ chunk.textRuns.forEach((run) => {
258
+ if (run instanceof InlinePictureRun) {
259
+ importedRunsInfoIndex = this.findIndexImportedInlinePictureRunInfo(run.info.publicAPIID, ++importedRunsInfoIndex);
260
+ const subDocPos = new SubDocumentPosition(this.subDocument, run.startOffset);
261
+ const importedRunsInfo = this.importedRunsInfo[importedRunsInfoIndex];
262
+ const options = ImageLoadingOptions.initByActualSize(importedRunsInfo.actualSize);
263
+ const importerData = new FormatImagesImporterData(subDocPos, options, run);
264
+ this.formatImagesImporter.registerImageRun(importerData);
265
+ }
266
+ });
267
+ });
268
+ }
269
+ findIndexImportedInlinePictureRunInfo(publicAPIID, startIndex = 0) {
270
+ for (let i = startIndex, runInfo; runInfo = this.importedRunsInfo[i]; i++) {
271
+ if (runInfo instanceof ImportedInlinePictureRunInfo && runInfo.picInfo.publicAPIID === publicAPIID)
272
+ return i;
273
+ }
274
+ return -1;
275
+ }
247
276
  static convertHtml(html) {
248
277
  Log.print(LogSource.HtmlImporter, "convertHtml", () => html);
249
278
  html = html.replace(/<(\w[^>]*) lang=([^ |>]*)([^>]*)/gi, "<$1$3");
@@ -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)
@@ -46,7 +46,7 @@ export class ControlFontsLoader {
46
46
  const xhr = new XMLHttpRequest();
47
47
  xhr.onload = (_e) => {
48
48
  const contentType = xhr.getResponseHeader("Content-Type");
49
- if (contentType != null && contentType.startsWith('font')) {
49
+ if (contentType !== 'text/html') {
50
50
  const fontSource = xhr.response;
51
51
  if (xhr.status >= 400 || !fontSource) {
52
52
  if (fontInfo.next())
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "devexpress-richedit",
3
- "version": "24.1.4-build-24183-0102",
3
+ "version": "24.1.4-build-24186-1015",
4
4
  "homepage": "https://www.devexpress.com/",
5
5
  "bugs": "https://www.devexpress.com/support/",
6
6
  "author": "Developer Express Inc.",
@@ -14,8 +14,8 @@
14
14
  "build-nspell": "webpack --mode production --config=bin/nspell.webpack.config.js"
15
15
  },
16
16
  "peerDependencies": {
17
- "devextreme": "24.1.4-build-24181-1937",
18
- "devextreme-dist": "24.1.4-build-24181-1937"
17
+ "devextreme": "24.1.4-build-24185-1936",
18
+ "devextreme-dist": "24.1.4-build-24185-1936"
19
19
  },
20
20
  "dependencies": {
21
21
  "jszip": "~3.10.1",