@hufe921/canvas-editor 1.0.5 → 1.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (102) hide show
  1. package/CHANGELOG.md +61 -0
  2. package/README.md +9 -8
  3. package/dist/assets/catalog-ezAM0r6o.js.map +1 -0
  4. package/dist/assets/group-BZtj1M7o.js.map +1 -1
  5. package/dist/assets/value-DKLIEqC1.js.map +1 -0
  6. package/dist/assets/wordCount-xSvDqE7d.js.map +1 -0
  7. package/dist/canvas-editor.js +4786 -2873
  8. package/dist/canvas-editor.js.map +1 -1
  9. package/dist/canvas-editor.umd.cjs +42 -42
  10. package/dist/canvas-editor.umd.cjs.map +1 -1
  11. package/dist/src/editor/core/command/Command.d.ts +9 -0
  12. package/dist/src/editor/core/command/CommandAdapt.d.ts +11 -2
  13. package/dist/src/editor/core/contextmenu/ContextMenu.d.ts +7 -0
  14. package/dist/src/editor/core/draw/Draw.d.ts +21 -10
  15. package/dist/src/editor/core/draw/column/ColumnManager.d.ts +2 -1
  16. package/dist/src/editor/core/draw/control/Control.d.ts +3 -2
  17. package/dist/src/editor/core/draw/control/interactive/ControlSearch.d.ts +2 -1
  18. package/dist/src/editor/core/draw/control/richtext/Border.d.ts +2 -1
  19. package/dist/src/editor/core/draw/frame/Background.d.ts +2 -1
  20. package/dist/src/editor/core/draw/frame/Badge.d.ts +3 -1
  21. package/dist/src/editor/core/draw/frame/Footer.d.ts +2 -1
  22. package/dist/src/editor/core/draw/frame/Header.d.ts +2 -1
  23. package/dist/src/editor/core/draw/frame/LineNumber.d.ts +2 -1
  24. package/dist/src/editor/core/draw/frame/Margin.d.ts +2 -1
  25. package/dist/src/editor/core/draw/frame/PageBorder.d.ts +2 -1
  26. package/dist/src/editor/core/draw/frame/PageNumber.d.ts +2 -1
  27. package/dist/src/editor/core/draw/frame/Placeholder.d.ts +2 -1
  28. package/dist/src/editor/core/draw/frame/Watermark.d.ts +4 -3
  29. package/dist/src/editor/core/draw/graffiti/Graffiti.d.ts +2 -1
  30. package/dist/src/editor/core/draw/interactive/Area.d.ts +14 -1
  31. package/dist/src/editor/core/draw/interactive/AreaTool.d.ts +18 -0
  32. package/dist/src/editor/core/draw/interactive/Group.d.ts +2 -1
  33. package/dist/src/editor/core/draw/interactive/Search.d.ts +2 -1
  34. package/dist/src/editor/core/draw/interactive/Spellcheck.d.ts +2 -1
  35. package/dist/src/editor/core/draw/particle/CheckboxParticle.d.ts +2 -1
  36. package/dist/src/editor/core/draw/particle/HyperlinkParticle.d.ts +2 -1
  37. package/dist/src/editor/core/draw/particle/ImageParticle.d.ts +3 -1
  38. package/dist/src/editor/core/draw/particle/LabelParticle.d.ts +2 -1
  39. package/dist/src/editor/core/draw/particle/LineBreakParticle.d.ts +2 -1
  40. package/dist/src/editor/core/draw/particle/ListParticle.d.ts +2 -1
  41. package/dist/src/editor/core/draw/particle/PageBreakParticle.d.ts +2 -1
  42. package/dist/src/editor/core/draw/particle/RadioParticle.d.ts +2 -1
  43. package/dist/src/editor/core/draw/particle/SeparatorParticle.d.ts +2 -1
  44. package/dist/src/editor/core/draw/particle/SubscriptParticle.d.ts +2 -1
  45. package/dist/src/editor/core/draw/particle/SuperscriptParticle.d.ts +2 -1
  46. package/dist/src/editor/core/draw/particle/TextParticle.d.ts +8 -2
  47. package/dist/src/editor/core/draw/particle/TraceParticle.d.ts +3 -2
  48. package/dist/src/editor/core/draw/particle/WhiteSpaceParticle.d.ts +2 -1
  49. package/dist/src/editor/core/draw/particle/block/BlockParticle.d.ts +3 -1
  50. package/dist/src/editor/core/draw/particle/block/modules/BaseBlock.d.ts +2 -1
  51. package/dist/src/editor/core/draw/particle/block/modules/VideoBlock.d.ts +2 -1
  52. package/dist/src/editor/core/draw/particle/date/DatePicker.d.ts +1 -0
  53. package/dist/src/editor/core/draw/particle/latex/LaTexParticle.d.ts +6 -1
  54. package/dist/src/editor/core/draw/particle/table/TableOperate.d.ts +2 -0
  55. package/dist/src/editor/core/draw/particle/table/TableParticle.d.ts +3 -2
  56. package/dist/src/editor/core/draw/richtext/AbstractRichText.d.ts +3 -2
  57. package/dist/src/editor/core/draw/richtext/Highlight.d.ts +2 -1
  58. package/dist/src/editor/core/draw/richtext/Strikeout.d.ts +2 -1
  59. package/dist/src/editor/core/draw/richtext/Underline.d.ts +2 -1
  60. package/dist/src/editor/core/draw/ruler/Ruler.d.ts +31 -2
  61. package/dist/src/editor/core/event/GlobalEvent.d.ts +1 -0
  62. package/dist/src/editor/core/event/pagePointer.d.ts +8 -0
  63. package/dist/src/editor/core/layout/LayoutEngine.d.ts +31 -0
  64. package/dist/src/editor/core/layout/TextMeasurer.d.ts +10 -0
  65. package/dist/src/editor/core/range/RangeManager.d.ts +2 -1
  66. package/dist/src/editor/core/render/BackendFactory.d.ts +3 -0
  67. package/dist/src/editor/core/render/RenderBackend.d.ts +24 -0
  68. package/dist/src/editor/core/render/canvas/CanvasBackend.d.ts +19 -0
  69. package/dist/src/editor/core/render/canvas/CanvasRenderer.d.ts +5 -0
  70. package/dist/src/editor/core/render/canvas/CanvasSurface.d.ts +17 -0
  71. package/dist/src/editor/core/render/model/DisplayList.d.ts +62 -0
  72. package/dist/src/editor/core/render/model/RenderContext.d.ts +48 -0
  73. package/dist/src/editor/core/render/svg/SvgBackend.d.ts +22 -0
  74. package/dist/src/editor/core/render/svg/SvgRenderer.d.ts +9 -0
  75. package/dist/src/editor/core/render/svg/SvgSurface.d.ts +13 -0
  76. package/dist/src/editor/core/render/svg/scene/PathCompiler.d.ts +16 -0
  77. package/dist/src/editor/core/render/svg/scene/ResourceKey.d.ts +7 -0
  78. package/dist/src/editor/core/render/svg/scene/SceneCompiler.d.ts +9 -0
  79. package/dist/src/editor/core/render/svg/scene/SceneKey.d.ts +28 -0
  80. package/dist/src/editor/core/render/svg/scene/SceneNode.d.ts +20 -0
  81. package/dist/src/editor/core/render/svg/scene/SceneReconciler.d.ts +12 -0
  82. package/dist/src/editor/core/render/svg/scene/SvgNodeFactory.d.ts +14 -0
  83. package/dist/src/editor/dataset/constant/Common.d.ts +1 -0
  84. package/dist/src/editor/dataset/enum/Common.d.ts +4 -0
  85. package/dist/src/editor/dataset/enum/Editor.d.ts +4 -0
  86. package/dist/src/editor/dataset/enum/TabStop.d.ts +11 -0
  87. package/dist/src/editor/index.d.ts +6 -5
  88. package/dist/src/editor/interface/Area.d.ts +8 -0
  89. package/dist/src/editor/interface/Checkbox.d.ts +3 -0
  90. package/dist/src/editor/interface/Control.d.ts +2 -1
  91. package/dist/src/editor/interface/Draw.d.ts +4 -0
  92. package/dist/src/editor/interface/Editor.d.ts +6 -0
  93. package/dist/src/editor/interface/Element.d.ts +12 -0
  94. package/dist/src/editor/interface/Listener.d.ts +7 -1
  95. package/dist/src/editor/interface/Row.d.ts +12 -0
  96. package/dist/src/editor/interface/table/Td.d.ts +2 -0
  97. package/dist/src/editor/utils/element.d.ts +1 -0
  98. package/dist/src/editor/utils/print.d.ts +1 -0
  99. package/package.json +14 -13
  100. package/dist/assets/catalog-B-cbxN0s.js.map +0 -1
  101. package/dist/assets/value-CLcLo2uw.js.map +0 -1
  102. package/dist/assets/wordCount-BWZRHbSB.js.map +0 -1
package/CHANGELOG.md CHANGED
@@ -1,3 +1,64 @@
1
+ # [1.1.0](https://github.com/Hufe921/canvas-editor/compare/v1.0.6...v1.1.0) (2026-11-06)
2
+
3
+
4
+ ### Bug Fixes
5
+
6
+ * exclude trace-deleted titles from catalog #1510 ([84389f2](https://github.com/Hufe921/canvas-editor/commit/84389f2a1dc23360da17d5428727d3e72adc619f)), closes [#1510](https://github.com/Hufe921/canvas-editor/issues/1510)
7
+ * hide table tool in form mode #1511 ([8b94772](https://github.com/Hufe921/canvas-editor/commit/8b9477218871353553d07ca2d4ee4a1f40f8f465)), closes [#1511](https://github.com/Hufe921/canvas-editor/issues/1511)
8
+ * place contextmenu by available viewport space #1514 ([73ad2fa](https://github.com/Hufe921/canvas-editor/commit/73ad2fa86e3d64a888ae467ada29d80265174d72)), closes [#1514](https://github.com/Hufe921/canvas-editor/issues/1514)
9
+
10
+
11
+ ### Documentation
12
+
13
+ * add pdf export notes ([09bdb1f](https://github.com/Hufe921/canvas-editor/commit/09bdb1f3e80a1bee28ff6a6717c17b052860e54b))
14
+ * update README SVG render layer entry to built-in backend ([7cfb52e](https://github.com/Hufe921/canvas-editor/commit/7cfb52ed5ea87faa4a6e7a336e0c46caff142fa3))
15
+
16
+
17
+ ### Features
18
+
19
+ * add line-end punctuation hanging option #692 ([68f1a41](https://github.com/Hufe921/canvas-editor/commit/68f1a41753a6ce093e59f1d6f0ad11733960154d)), closes [#692](https://github.com/Hufe921/canvas-editor/issues/692)
20
+ * add paragraph indent and ruler indent markers #725 #1190 #1459 ([4be9e29](https://github.com/Hufe921/canvas-editor/commit/4be9e29228d980c41e57811c629d4965e54d1e62)), closes [#725](https://github.com/Hufe921/canvas-editor/issues/725) [#1190](https://github.com/Hufe921/canvas-editor/issues/1190) [#1459](https://github.com/Hufe921/canvas-editor/issues/1459)
21
+ * add paragraph indent and tab hanging indent #725 #1190 ([948e6ac](https://github.com/Hufe921/canvas-editor/commit/948e6ac583f63efc48403e2a63a32456ee9c274c)), closes [#725](https://github.com/Hufe921/canvas-editor/issues/725) [#1190](https://github.com/Hufe921/canvas-editor/issues/1190)
22
+ * add paragraph tab stops with leader and ruler marks #256 ([1865c9b](https://github.com/Hufe921/canvas-editor/commit/1865c9b063def06a36ba27151a781d4893fca076)), closes [#256](https://github.com/Hufe921/canvas-editor/issues/256)
23
+ * add SVG rendering backend #374 ([cf51314](https://github.com/Hufe921/canvas-editor/commit/cf51314a5179a709b9ef9d13cea8041257d02cfb)), closes [#374](https://github.com/Hufe921/canvas-editor/issues/374)
24
+ * promote incremental layout to stable and enable by default ([516f1a4](https://github.com/Hufe921/canvas-editor/commit/516f1a437f7fa6fcbb7a0f41d8f552ac0087a3a4))
25
+
26
+
27
+ ### Tests
28
+
29
+ * stabilize canvas rendering regression tests ([9a1c3d8](https://github.com/Hufe921/canvas-editor/commit/9a1c3d807cdf4817329b8682d3b3d546b9956147))
30
+
31
+
32
+
33
+ ## [1.0.6](https://github.com/Hufe921/canvas-editor/compare/v1.0.5...v1.0.6) (2026-10-23)
34
+
35
+
36
+ ### Bug Fixes
37
+
38
+ * exclude paragraph spacingAfter from row decorations #1498 ([1d7cd1a](https://github.com/Hufe921/canvas-editor/commit/1d7cd1a7742f3e8af1f67536a5157d03b2945de7)), closes [#1498](https://github.com/Hufe921/canvas-editor/issues/1498)
39
+ * honor extraPickAttrs for table row and cell identities #1492 ([71aa099](https://github.com/Hufe921/canvas-editor/commit/71aa0996c2d4c827ec5d86d9acee80eb0a3f98a4)), closes [#1492](https://github.com/Hufe921/canvas-editor/issues/1492)
40
+ * use 24-hour format for date control and parse value by dateFormat #1503 ([b598ce9](https://github.com/Hufe921/canvas-editor/commit/b598ce927572ed453b420e742a2f9f5bd38aa45b)), closes [#1503](https://github.com/Hufe921/canvas-editor/issues/1503)
41
+
42
+
43
+ ### Chores
44
+
45
+ * add prepublishOnly script for release preparation ([ced4746](https://github.com/Hufe921/canvas-editor/commit/ced4746ba13c7f2d3bbad0644fdff5e842eba049))
46
+
47
+
48
+ ### Features
49
+
50
+ * add area minimum height with resize handle #1051 ([75b4c14](https://github.com/Hufe921/canvas-editor/commit/75b4c14e7da589b46912abf4b14597e3d99026bb)), closes [#1051](https://github.com/Hufe921/canvas-editor/issues/1051)
51
+ * add checkbox cross mark style #1501 ([a3b2a93](https://github.com/Hufe921/canvas-editor/commit/a3b2a93d321802e202cfba4ccbdd955a98d91761)), closes [#1501](https://github.com/Hufe921/canvas-editor/issues/1501)
52
+ * add paragraph spacing #499 ([124bbcc](https://github.com/Hufe921/canvas-editor/commit/124bbcc5176ee91935cfef5ec2374aff5284cb3a)), closes [#499](https://github.com/Hufe921/canvas-editor/issues/499)
53
+ * add table cell border color/width setting #1053 ([4a2bf92](https://github.com/Hufe921/canvas-editor/commit/4a2bf92cf676de9decc7713b63b0c6f20fb8aaac)), closes [#1053](https://github.com/Hufe921/canvas-editor/issues/1053)
54
+
55
+
56
+ ### Tests
57
+
58
+ * trim multi-page diff test load for CI timeout ([e8d0be8](https://github.com/Hufe921/canvas-editor/commit/e8d0be8f4c7d23ef1056a35b0891a3bc1083db82))
59
+
60
+
61
+
1
62
  ## [1.0.5](https://github.com/Hufe921/canvas-editor/compare/v1.0.4...v1.0.5) (2026-10-11)
2
63
 
3
64
 
package/README.md CHANGED
@@ -44,7 +44,7 @@
44
44
 
45
45
  ## Overview
46
46
 
47
- **Canvas Editor** is a feature-rich, WYSIWYG document editor built on top of the HTML `<canvas>` API. It is designed for use cases that demand pixel-perfect rendering, advanced typography, complex layouts, and Word-like document experiences in the browser — including EMR (Electronic Medical Records), legal contracts, reports, and other document-centric applications.
47
+ **Canvas Editor** is a feature-rich, WYSIWYG document editor rendered with HTML `<canvas>` (with an optional SVG backend). It is designed for use cases that demand pixel-perfect rendering, advanced typography, complex layouts, and Word-like document experiences in the browser — including EMR (Electronic Medical Records), legal contracts, reports, and other document-centric applications.
48
48
 
49
49
  Unlike traditional `contenteditable`-based editors, Canvas Editor takes full control of the rendering pipeline, providing consistent typography across browsers, precise pagination, and a uniform export experience.
50
50
 
@@ -108,13 +108,13 @@ For complete API documentation, see the [official docs](https://hufe.club/canvas
108
108
 
109
109
  ## Ecosystem
110
110
 
111
- | Project | Description |
112
- | -------------------------------------------------------------------------- | ----------------------------------------------------------------------------------- |
113
- | [canvas-editor-plugin](https://github.com/Hufe921/canvas-editor-plugin) | Official plugins: Word/Excel import-export, formula, comment, spellcheck & 20+ more |
114
- | [feature/svg](https://github.com/Hufe921/canvas-editor/tree/feature/svg) | SVG render layer (in development) |
115
- | [feature/pdf](https://github.com/Hufe921/canvas-editor/tree/feature/pdf) | PDF export feature |
116
- | [feature/ai](https://github.com/Hufe921/canvas-editor/tree/feature/ai) | AI-powered text processing demo |
117
- | [feature/CRDT](https://github.com/Hufe921/canvas-editor/tree/feature/CRDT) | CRDT-based collaboration (experimental) |
111
+ | Project | Description |
112
+ | ------------------------------------------------------------------------------------------ | ----------------------------------------------------------------------------------------------------- |
113
+ | [canvas-editor-plugin](https://github.com/Hufe921/canvas-editor-plugin) | Official plugins: Word/Excel import-export, formula, comment, spellcheck & 20+ more |
114
+ | [SVG render layer](https://github.com/Hufe921/canvas-editor/tree/main/src/editor/core/render/svg) | Built-in SVG rendering backend — enable via the `backend: 'svg'` editor option (supersedes the old `feature/svg` branch) |
115
+ | [feature/pdf](https://github.com/Hufe921/canvas-editor/tree/feature/pdf) | PDF export — [live demo](https://hufe.club/canvas-editor-pdf) |
116
+ | [feature/ai](https://github.com/Hufe921/canvas-editor/tree/feature/ai) | AI-powered text processing demo |
117
+ | [feature/CRDT](https://github.com/Hufe921/canvas-editor/tree/feature/CRDT) | CRDT-based collaboration (experimental) |
118
118
 
119
119
  ## Development
120
120
 
@@ -173,6 +173,7 @@ npm run docs:build # Build the documentation site
173
173
  src/editor/
174
174
  ├── core/
175
175
  │ ├── draw/ # Rendering engine (canvas drawing)
176
+ │ ├── render/ # Pluggable render backends (canvas / SVG)
176
177
  │ │ ├── particle/ # Element renderers (text, image, table, latex, ...)
177
178
  │ │ ├── control/ # Form control rendering
178
179
  │ │ ├── frame/ # Frame elements (margin, background, borders)
@@ -0,0 +1 @@
1
+ {"version":3,"file":"catalog-ezAM0r6o.js","names":["TraceType","\"INSERTED\"","\"DELETED\"","titleOrderNumberMapping","\"first\"","\"second\"","\"third\"","\"fourth\"","\"fifth\"","\"sixth\"","TEXTLIKE_ELEMENT_TYPE","isTextLikeElement","element","isTraceDeleted","records","getCatalog","payload","titleElementList","t","elementList","getElementInfo","titleId","titleElement","positionList","valueList","aliveIndex","position","titleE","el","trList","r","tr","d","value","index","recursiveInsert","subCatalogItem","catalogItem","catalogItemLevel","titleLevel","title","catalog","evt"],"sources":["../../src/editor/dataset/enum/Trace.ts","../../src/editor/core/worker/works/catalog.ts"],"sourcesContent":["export enum TraceType {\n INSERTED = 'inserted',\n DELETED = 'deleted'\n}\n","import { TraceType } from '../../../dataset/enum/Trace'\nimport { ICatalog, ICatalogItem } from '../../../interface/Catalog'\nimport { IElement, IElementPosition } from '../../../interface/Element'\n\ninterface IGetCatalogPayload {\n elementList: IElement[]\n positionList: IElementPosition[]\n}\n\ntype ICatalogElement = IElement & {\n pageNo: number\n}\n\nenum ElementType {\n TEXT = 'text',\n IMAGE = 'image',\n TABLE = 'table',\n HYPERLINK = 'hyperlink',\n SUPERSCRIPT = 'superscript',\n SUBSCRIPT = 'subscript',\n SEPARATOR = 'separator',\n PAGE_BREAK = 'pageBreak',\n CONTROL = 'control',\n CHECKBOX = 'checkbox',\n RADIO = 'radio',\n LATEX = 'latex',\n TAB = 'tab',\n DATE = 'date',\n BLOCK = 'block',\n TITLE = 'title',\n AREA = 'area',\n LIST = 'list',\n LABEL = 'label'\n}\n\nenum TitleLevel {\n FIRST = 'first',\n SECOND = 'second',\n THIRD = 'third',\n FOURTH = 'fourth',\n FIFTH = 'fifth',\n SIXTH = 'sixth'\n}\n\nconst titleOrderNumberMapping: Record<TitleLevel, number> = {\n [TitleLevel.FIRST]: 1,\n [TitleLevel.SECOND]: 2,\n [TitleLevel.THIRD]: 3,\n [TitleLevel.FOURTH]: 4,\n [TitleLevel.FIFTH]: 5,\n [TitleLevel.SIXTH]: 6\n}\n\nconst TEXTLIKE_ELEMENT_TYPE: ElementType[] = [\n ElementType.TEXT,\n ElementType.HYPERLINK,\n ElementType.SUBSCRIPT,\n ElementType.SUPERSCRIPT,\n ElementType.CONTROL,\n ElementType.DATE,\n ElementType.LABEL\n]\n\nconst ZERO = '\\u200B'\n\nfunction isTextLikeElement(element: IElement): boolean {\n return !element.type || TEXTLIKE_ELEMENT_TYPE.includes(element.type)\n}\n\n// 被删除的留痕元素不进目录(与 utils/element.ts isElementTraceDeleted 同口径)\nfunction isTraceDeleted(element: IElement): boolean {\n const records = element.trace\n return records?.[records.length - 1]?.type === TraceType.DELETED\n}\n\nfunction getCatalog(payload: IGetCatalogPayload): ICatalog | null {\n const { elementList, positionList } = payload\n // 筛选标题\n const titleElementList: ICatalogElement[] = []\n let t = 0\n while (t < elementList.length) {\n const element = elementList[t]\n const getElementInfo = (\n element: IElement,\n elementList: IElement[],\n position: number\n ) => {\n const titleId = element.titleId\n const level = element.level\n const titleElement: ICatalogElement = {\n type: ElementType.TITLE,\n value: '',\n level,\n titleId,\n pageNo: positionList[t].pageNo\n }\n const valueList: IElement[] = []\n // 段内首个未删除元素下标:段边界仍按 titleId 划分,已删除元素照样收进段内\n let aliveIndex = -1\n while (position < elementList.length) {\n const titleE = elementList[position]\n if (titleId !== titleE.titleId) {\n position--\n break\n }\n if (aliveIndex < 0 && !isTraceDeleted(titleE)) {\n aliveIndex = position\n }\n valueList.push(titleE)\n position++\n }\n titleElement.value = valueList\n .filter(el => !isTraceDeleted(el) && isTextLikeElement(el))\n .map(el => el.value)\n .join('')\n .replace(new RegExp(ZERO, 'g'), '')\n return { position, titleElement, aliveIndex }\n }\n if (element.titleId) {\n const { position, titleElement, aliveIndex } = getElementInfo(\n element,\n elementList,\n t\n )\n t = position\n // 整段已删除的标题不进目录;页码取首个未删除元素所在页\n if (~aliveIndex) {\n titleElement.pageNo = positionList[aliveIndex].pageNo\n titleElementList.push(titleElement)\n }\n }\n if (element.type === ElementType.TABLE) {\n const trList = element.trList!\n for (let r = 0; r < trList.length; r++) {\n const tr = trList[r]\n for (let d = 0; d < tr.tdList.length; d++) {\n const td = tr.tdList[d]\n const value = td.value\n if (value.length > 1) {\n let index = 1\n while (index < value.length) {\n if (value[index]?.titleId) {\n const { titleElement, position, aliveIndex } = getElementInfo(\n value[index],\n value,\n index\n )\n if (~aliveIndex) {\n titleElementList.push(titleElement)\n }\n index = position\n }\n index++\n }\n }\n }\n }\n }\n t++\n }\n if (!titleElementList.length) return null\n // 查找到比最新元素大的标题时终止\n const recursiveInsert = (\n title: ICatalogElement,\n catalogItem: ICatalogItem\n ) => {\n const subCatalogItem =\n catalogItem.subCatalog[catalogItem.subCatalog.length - 1]\n const catalogItemLevel = titleOrderNumberMapping[subCatalogItem?.level]\n const titleLevel = titleOrderNumberMapping[title.level!]\n if (subCatalogItem && titleLevel > catalogItemLevel) {\n recursiveInsert(title, subCatalogItem)\n } else {\n catalogItem.subCatalog.push({\n id: title.titleId!,\n name: title.value,\n level: title.level!,\n pageNo: title.pageNo,\n subCatalog: []\n })\n }\n }\n // 循环标题组\n // 如果当前列表级别小于标题组最新标题级别:则递归查找最小级别并追加\n // 如果大于:则直接追加至当前标题组\n const catalog: ICatalog = []\n for (let e = 0; e < titleElementList.length; e++) {\n const title = titleElementList[e]\n const catalogItem = catalog[catalog.length - 1]\n const catalogItemLevel = titleOrderNumberMapping[catalogItem?.level]\n const titleLevel = titleOrderNumberMapping[title.level!]\n if (catalogItem && titleLevel > catalogItemLevel) {\n recursiveInsert(title, catalogItem)\n } else {\n catalog.push({\n id: title.titleId!,\n name: title.value,\n level: title.level!,\n pageNo: title.pageNo,\n subCatalog: []\n })\n }\n }\n return catalog\n}\n\nonmessage = evt => {\n const payload = <IGetCatalogPayload>evt.data\n const catalog = getCatalog(payload)\n postMessage(catalog)\n}\n"],"mappings":"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"}
@@ -1 +1 @@
1
- {"version":3,"file":"group-BZtj1M7o.js","names":[],"sources":["../../src/editor/core/worker/works/group.ts"],"sourcesContent":["import { IElement } from '../../../interface/Element'\n\nenum ElementType {\n TABLE = 'table'\n}\n\nfunction getGroupIds(elementList: IElement[]): string[] {\n const groupIds: string[] = []\n for (const element of elementList) {\n if (element.type === ElementType.TABLE) {\n const trList = element.trList!\n for (let r = 0; r < trList.length; r++) {\n const tr = trList[r]\n for (let d = 0; d < tr.tdList.length; d++) {\n const td = tr.tdList[d]\n groupIds.push(...getGroupIds(td.value))\n }\n }\n }\n if (!element.groupIds) continue\n for (const groupId of element.groupIds) {\n if (!groupIds.includes(groupId)) {\n groupIds.push(groupId)\n }\n }\n }\n return groupIds\n}\n\nonmessage = evt => {\n const elementList = <IElement[]>evt.data\n const groupIds = getGroupIds(elementList)\n postMessage(groupIds)\n}\n"],"mappings":"YAMA,SAAS,EAAY,EAAmC,CACtD,IAAM,EAAqB,CAAC,EAC5B,IAAK,IAAM,KAAW,EAAa,CACjC,GAAI,EAAQ,OAAA,QAA4B,CACtC,IAAM,EAAS,EAAQ,OACvB,IAAK,IAAI,EAAI,EAAG,EAAI,EAAO,OAAQ,IAAK,CACtC,IAAM,EAAK,EAAO,GAClB,IAAK,IAAI,EAAI,EAAG,EAAI,EAAG,OAAO,OAAQ,IAAK,CACzC,IAAM,EAAK,EAAG,OAAO,GACrB,EAAS,KAAK,GAAG,EAAY,EAAG,KAAK,CAAC,CACxC,CACF,CACF,CACK,KAAQ,SACb,IAAK,IAAM,KAAW,EAAQ,SACvB,EAAS,SAAS,CAAO,GAC5B,EAAS,KAAK,CAAO,CAG3B,CACA,OAAO,CACT,CAEA,UAAY,GAAO,CACjB,IAAM,EAA0B,EAAI,KAC9B,EAAW,EAAY,CAAW,EACxC,YAAY,CAAQ,CACtB"}
1
+ {"version":3,"file":"group-BZtj1M7o.js","names":["getGroupIds","groupIds","element","elementList","trList","tr","d","td","groupId","evt"],"sources":["../../src/editor/core/worker/works/group.ts"],"sourcesContent":["import { IElement } from '../../../interface/Element'\n\nenum ElementType {\n TABLE = 'table'\n}\n\nfunction getGroupIds(elementList: IElement[]): string[] {\n const groupIds: string[] = []\n for (const element of elementList) {\n if (element.type === ElementType.TABLE) {\n const trList = element.trList!\n for (let r = 0; r < trList.length; r++) {\n const tr = trList[r]\n for (let d = 0; d < tr.tdList.length; d++) {\n const td = tr.tdList[d]\n groupIds.push(...getGroupIds(td.value))\n }\n }\n }\n if (!element.groupIds) continue\n for (const groupId of element.groupIds) {\n if (!groupIds.includes(groupId)) {\n groupIds.push(groupId)\n }\n }\n }\n return groupIds\n}\n\nonmessage = evt => {\n const elementList = <IElement[]>evt.data\n const groupIds = getGroupIds(elementList)\n postMessage(groupIds)\n}\n"],"mappings":"YAMA,SAASA,EAAY,EAAmC,CACtD,IAAMC,EAAqB,CAAC,EAC5B,IAAK,IAAMC,KAAWC,EAAa,CACjC,GAAID,EAAQ,OAAA,QAA4B,CACtC,IAAME,EAASF,EAAQ,OACvB,IAAK,IAAI,EAAI,EAAG,EAAIE,EAAO,OAAQ,IAAK,CACtC,IAAMC,EAAKD,EAAO,GAClB,IAAK,IAAIE,EAAI,EAAGA,EAAID,EAAG,OAAO,OAAQ,IAAK,CACzC,IAAME,EAAKF,EAAG,OAAOC,GACrBL,EAAS,KAAK,GAAGD,EAAYO,EAAG,KAAK,CAAC,CACxC,CACF,CACF,CACA,GAAKL,EAAQ,SACb,IAAK,IAAMM,KAAWN,EAAQ,SACvBD,EAAS,SAASO,CAAO,GAC5BP,EAAS,KAAKO,CAAO,CAG3B,CACA,OAAOP,CACT,CAEA,UAAY,GAAO,CACjB,IAAME,EAA0BM,EAAI,KAC9BR,EAAWD,EAAYG,CAAW,EACxC,YAAYF,CAAQ,CACtB"}