devexpress-richedit 24.1.3 → 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.
package/index.d.ts CHANGED
@@ -1,6 +1,6 @@
1
1
  /**
2
2
  * DevExpress WebRichEdit (index.d.ts)
3
- * Version: 24.1.3
3
+ * Version: 24.1.4
4
4
  * Copyright (c) 2012 - 2024 Developer Express Inc. ALL RIGHTS RESERVED
5
5
  * License: https://www.devexpress.com/Support/EULAs
6
6
  */
package/index.js CHANGED
@@ -1,6 +1,6 @@
1
1
  /**
2
2
  * DevExpress WebRichEdit (index.js)
3
- * Version: 24.1.3
3
+ * Version: 24.1.4
4
4
  * Copyright (c) 2012 - 2024 Developer Express Inc. ALL RIGHTS RESERVED
5
5
  * License: https://www.devexpress.com/Support/EULAs
6
6
  */
@@ -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)
@@ -7,6 +7,7 @@ export declare class AnchorObjectPositionCalculatorBase {
7
7
  protected obj: LayoutAnchoredObjectBox;
8
8
  protected lp: LayoutPosition;
9
9
  protected isRelativeCell: boolean;
10
+ protected isSimpleView: boolean;
10
11
  constructor(manager: FormatterManager);
11
12
  protected get anchorInfo(): AnchorInfo;
12
13
  protected init(obj: LayoutAnchoredObjectBox): void;
@@ -10,5 +10,6 @@ export class AnchorObjectPositionCalculatorBase {
10
10
  this.obj = obj;
11
11
  this.isRelativeCell = !!this.manager.activeFormatter.tableFormatter &&
12
12
  (obj.anchorInfo.layoutTableCell || this.manager.model.compatibilitySettings.layoutInTableCell);
13
+ this.isSimpleView = this.manager.innerClientProperties.viewsSettings.isSimpleView;
13
14
  }
14
15
  }
@@ -47,13 +47,15 @@ export class AnchorObjectVerticalPositionCalculator extends AnchorObjectPosition
47
47
  switch (this.anchorInfo.verticalPositionType) {
48
48
  case AnchorObjectVerticalPositionType.Page:
49
49
  return this.isRelativeCell ? this.relativeColumnPos() + this.lp.row.tableCellInfo.y + this.topCellMargin : 0;
50
- case AnchorObjectVerticalPositionType.Paragraph:
51
- return this.relativeColumnPos() + this.getRowWhatStartParagraphY();
52
50
  case AnchorObjectVerticalPositionType.Line:
53
51
  return this.relativeColumnPos() + this.lp.row.y;
54
52
  case AnchorObjectVerticalPositionType.Margin:
55
- return this.isRelativeCell ? this.relativeColumnPos() + this.lp.row.tableCellInfo.y + this.topCellMargin :
56
- this.manager.boundsCalculator.marginTop;
53
+ if (!this.isSimpleView) {
54
+ return this.isRelativeCell ? this.relativeColumnPos() + this.lp.row.tableCellInfo.y + this.topCellMargin :
55
+ this.manager.boundsCalculator.marginTop;
56
+ }
57
+ case AnchorObjectVerticalPositionType.Paragraph:
58
+ return this.relativeColumnPos() + this.getRowWhatStartParagraphY();
57
59
  case AnchorObjectVerticalPositionType.TopMargin:
58
60
  case AnchorObjectVerticalPositionType.InsideMargin:
59
61
  return this.isRelativeCell ? this.relativeColumnPos() + this.lp.row.tableCellInfo.y + this.topCellMargin : 0;
@@ -45,15 +45,20 @@ export class ControlFontsLoader {
45
45
  };
46
46
  const xhr = new XMLHttpRequest();
47
47
  xhr.onload = (_e) => {
48
- const fontSource = xhr.response;
49
- if (xhr.status >= 400 || !fontSource) {
50
- if (fontInfo.next())
51
- this.makeRequest(fontInfo, afterLoading);
48
+ const contentType = xhr.getResponseHeader("Content-Type");
49
+ if (contentType !== 'text/html') {
50
+ const fontSource = xhr.response;
51
+ if (xhr.status >= 400 || !fontSource) {
52
+ if (fontInfo.next())
53
+ this.makeRequest(fontInfo, afterLoading);
54
+ else
55
+ notLoaded();
56
+ }
52
57
  else
53
- notLoaded();
58
+ afterLoading(fontSource);
54
59
  }
55
60
  else
56
- afterLoading(fontSource);
61
+ notLoaded();
57
62
  };
58
63
  xhr.onerror = () => notLoaded();
59
64
  xhr.open("GET", fontInfo.currentPath, true);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "devexpress-richedit",
3
- "version": "24.1.3",
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.3",
18
- "devextreme-dist": "24.1.3"
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",