@univerjs/docs-ui 0.24.0 → 0.25.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 (121) hide show
  1. package/lib/cjs/facade.js +42 -11
  2. package/lib/cjs/index.js +4487 -1456
  3. package/lib/cjs/locale/ar-SA.js +124 -0
  4. package/lib/cjs/locale/ca-ES.js +11 -10
  5. package/lib/cjs/locale/de-DE.js +124 -0
  6. package/lib/cjs/locale/en-US.js +11 -10
  7. package/lib/cjs/locale/es-ES.js +11 -10
  8. package/lib/cjs/locale/fa-IR.js +11 -10
  9. package/lib/cjs/locale/fr-FR.js +11 -10
  10. package/lib/cjs/locale/id-ID.js +124 -0
  11. package/lib/cjs/locale/it-IT.js +124 -0
  12. package/lib/cjs/locale/ja-JP.js +11 -10
  13. package/lib/cjs/locale/ko-KR.js +11 -10
  14. package/lib/cjs/locale/pl-PL.js +124 -0
  15. package/lib/cjs/locale/pt-BR.js +124 -0
  16. package/lib/cjs/locale/ru-RU.js +13 -12
  17. package/lib/cjs/locale/sk-SK.js +11 -10
  18. package/lib/cjs/locale/vi-VN.js +22 -21
  19. package/lib/cjs/locale/zh-CN.js +11 -10
  20. package/lib/cjs/locale/zh-HK.js +124 -0
  21. package/lib/cjs/locale/zh-TW.js +22 -21
  22. package/lib/es/facade.js +42 -11
  23. package/lib/es/index.js +4476 -1462
  24. package/lib/es/locale/ar-SA.js +123 -0
  25. package/lib/es/locale/ca-ES.js +11 -10
  26. package/lib/es/locale/de-DE.js +123 -0
  27. package/lib/es/locale/en-US.js +11 -10
  28. package/lib/es/locale/es-ES.js +11 -10
  29. package/lib/es/locale/fa-IR.js +11 -10
  30. package/lib/es/locale/fr-FR.js +11 -10
  31. package/lib/es/locale/id-ID.js +123 -0
  32. package/lib/es/locale/it-IT.js +123 -0
  33. package/lib/es/locale/ja-JP.js +11 -10
  34. package/lib/es/locale/ko-KR.js +11 -10
  35. package/lib/es/locale/pl-PL.js +123 -0
  36. package/lib/es/locale/pt-BR.js +123 -0
  37. package/lib/es/locale/ru-RU.js +13 -12
  38. package/lib/es/locale/sk-SK.js +11 -10
  39. package/lib/es/locale/vi-VN.js +22 -21
  40. package/lib/es/locale/zh-CN.js +11 -10
  41. package/lib/es/locale/zh-HK.js +123 -0
  42. package/lib/es/locale/zh-TW.js +22 -21
  43. package/lib/facade.js +42 -11
  44. package/lib/index.css +240 -26
  45. package/lib/index.js +4476 -1462
  46. package/lib/locale/ar-SA.js +123 -0
  47. package/lib/locale/ca-ES.js +11 -10
  48. package/lib/locale/de-DE.js +123 -0
  49. package/lib/locale/en-US.js +11 -10
  50. package/lib/locale/es-ES.js +11 -10
  51. package/lib/locale/fa-IR.js +11 -10
  52. package/lib/locale/fr-FR.js +11 -10
  53. package/lib/locale/id-ID.js +123 -0
  54. package/lib/locale/it-IT.js +123 -0
  55. package/lib/locale/ja-JP.js +11 -10
  56. package/lib/locale/ko-KR.js +11 -10
  57. package/lib/locale/pl-PL.js +123 -0
  58. package/lib/locale/pt-BR.js +123 -0
  59. package/lib/locale/ru-RU.js +13 -12
  60. package/lib/locale/sk-SK.js +11 -10
  61. package/lib/locale/vi-VN.js +22 -21
  62. package/lib/locale/zh-CN.js +11 -10
  63. package/lib/locale/zh-HK.js +123 -0
  64. package/lib/locale/zh-TW.js +22 -21
  65. package/lib/types/commands/commands/doc-block-move.command.d.ts +40 -0
  66. package/lib/types/commands/commands/doc-delete.command.d.ts +2 -1
  67. package/lib/types/commands/commands/doc-page-setup.command.d.ts +2 -0
  68. package/lib/types/commands/commands/list.command.d.ts +1 -0
  69. package/lib/types/components/paragraph-menu/index.d.ts +23 -1
  70. package/lib/types/controllers/render-controllers/doc-contextmenu.render-controller.d.ts +8 -2
  71. package/lib/types/controllers/render-controllers/doc.render-controller.d.ts +8 -2
  72. package/lib/types/controllers/render-controllers/zoom.render-controller.d.ts +3 -3
  73. package/lib/types/facade/f-document.d.ts +18 -0
  74. package/lib/types/index.d.ts +6 -1
  75. package/lib/types/locale/ar-SA.d.ts +18 -0
  76. package/lib/types/locale/de-DE.d.ts +18 -0
  77. package/lib/types/locale/en-US.d.ts +117 -110
  78. package/lib/types/locale/id-ID.d.ts +18 -0
  79. package/lib/types/locale/it-IT.d.ts +18 -0
  80. package/lib/types/locale/pl-PL.d.ts +18 -0
  81. package/lib/types/locale/pt-BR.d.ts +18 -0
  82. package/lib/types/locale/zh-HK.d.ts +18 -0
  83. package/lib/types/menu/menu.d.ts +9 -1
  84. package/lib/types/menu/paragraph-menu.d.ts +21 -2
  85. package/lib/types/menu/schema.d.ts +1 -0
  86. package/lib/types/services/clipboard/clipboard.service.d.ts +5 -1
  87. package/lib/types/services/clipboard/html-to-udm/converter.d.ts +12 -0
  88. package/lib/types/services/clipboard/html-to-udm/paste-plugins/type.d.ts +1 -0
  89. package/lib/types/services/clipboard/internal-fragment.d.ts +30 -0
  90. package/lib/types/services/doc-content-insert.service.d.ts +28 -0
  91. package/lib/types/services/doc-event-manager.service.d.ts +19 -1
  92. package/lib/types/services/doc-paragraph-menu.service.d.ts +51 -3
  93. package/lib/types/services/doc-popup-manager.service.d.ts +2 -2
  94. package/lib/types/services/docs-render.service.d.ts +2 -1
  95. package/lib/types/services/editor/editor.d.ts +1 -0
  96. package/lib/types/services/selection/convert-text-range.d.ts +1 -0
  97. package/lib/types/services/selection/doc-selection-render.service.d.ts +4 -0
  98. package/lib/types/views/page-settings/index.d.ts +4 -2
  99. package/lib/types/views/rich-text-editor/hooks/use-editor.d.ts +2 -1
  100. package/lib/umd/facade.js +5 -1
  101. package/lib/umd/index.js +37 -10
  102. package/lib/umd/locale/ar-SA.js +1 -0
  103. package/lib/umd/locale/ca-ES.js +1 -1
  104. package/lib/umd/locale/de-DE.js +1 -0
  105. package/lib/umd/locale/en-US.js +1 -1
  106. package/lib/umd/locale/es-ES.js +1 -1
  107. package/lib/umd/locale/fa-IR.js +1 -1
  108. package/lib/umd/locale/fr-FR.js +1 -1
  109. package/lib/umd/locale/id-ID.js +1 -0
  110. package/lib/umd/locale/it-IT.js +1 -0
  111. package/lib/umd/locale/ja-JP.js +1 -1
  112. package/lib/umd/locale/ko-KR.js +1 -1
  113. package/lib/umd/locale/pl-PL.js +1 -0
  114. package/lib/umd/locale/pt-BR.js +1 -0
  115. package/lib/umd/locale/ru-RU.js +1 -1
  116. package/lib/umd/locale/sk-SK.js +1 -1
  117. package/lib/umd/locale/vi-VN.js +1 -1
  118. package/lib/umd/locale/zh-CN.js +1 -1
  119. package/lib/umd/locale/zh-HK.js +1 -0
  120. package/lib/umd/locale/zh-TW.js +1 -1
  121. package/package.json +11 -11
package/lib/cjs/facade.js CHANGED
@@ -4,7 +4,7 @@ let _univerjs_core_facade = require("@univerjs/core/facade");
4
4
  let _univerjs_docs_ui = require("@univerjs/docs-ui");
5
5
  let _univerjs_engine_render = require("@univerjs/engine-render");
6
6
 
7
- //#region \0@oxc-project+runtime@0.129.0/helpers/typeof.js
7
+ //#region \0@oxc-project+runtime@0.133.0/helpers/esm/typeof.js
8
8
  function _typeof(o) {
9
9
  "@babel/helpers - typeof";
10
10
  return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function(o) {
@@ -15,7 +15,7 @@ function _typeof(o) {
15
15
  }
16
16
 
17
17
  //#endregion
18
- //#region \0@oxc-project+runtime@0.129.0/helpers/toPrimitive.js
18
+ //#region \0@oxc-project+runtime@0.133.0/helpers/esm/toPrimitive.js
19
19
  function toPrimitive(t, r) {
20
20
  if ("object" != _typeof(t) || !t) return t;
21
21
  var e = t[Symbol.toPrimitive];
@@ -28,14 +28,14 @@ function toPrimitive(t, r) {
28
28
  }
29
29
 
30
30
  //#endregion
31
- //#region \0@oxc-project+runtime@0.129.0/helpers/toPropertyKey.js
31
+ //#region \0@oxc-project+runtime@0.133.0/helpers/esm/toPropertyKey.js
32
32
  function toPropertyKey(t) {
33
33
  var i = toPrimitive(t, "string");
34
34
  return "symbol" == _typeof(i) ? i : i + "";
35
35
  }
36
36
 
37
37
  //#endregion
38
- //#region \0@oxc-project+runtime@0.129.0/helpers/defineProperty.js
38
+ //#region \0@oxc-project+runtime@0.133.0/helpers/esm/defineProperty.js
39
39
  function _defineProperty(e, r, t) {
40
40
  return (r = toPropertyKey(r)) in e ? Object.defineProperty(e, r, {
41
41
  value: t,
@@ -46,7 +46,7 @@ function _defineProperty(e, r, t) {
46
46
  }
47
47
 
48
48
  //#endregion
49
- //#region \0@oxc-project+runtime@0.129.0/helpers/decorateParam.js
49
+ //#region \0@oxc-project+runtime@0.133.0/helpers/esm/decorateParam.js
50
50
  function __decorateParam(paramIndex, decorator) {
51
51
  return function(target, key) {
52
52
  decorator(target, key, paramIndex);
@@ -54,7 +54,7 @@ function __decorateParam(paramIndex, decorator) {
54
54
  }
55
55
 
56
56
  //#endregion
57
- //#region \0@oxc-project+runtime@0.129.0/helpers/decorate.js
57
+ //#region \0@oxc-project+runtime@0.133.0/helpers/esm/decorate.js
58
58
  function __decorate(decorators, target, key, desc) {
59
59
  var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
60
60
  if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
@@ -100,22 +100,53 @@ let FDocument = class FDocument {
100
100
  * @param text - The text to be added to the end of this text region.
101
101
  */
102
102
  appendText(text) {
103
- const unitId = this.id;
104
103
  const { body } = this.getSnapshot();
105
104
  if (!body) throw new Error("The document body is empty");
106
105
  const lastPosition = body.dataStream.length - 2;
107
- const activeRange = {
106
+ return this.insertText(text, {
108
107
  startOffset: lastPosition,
109
108
  endOffset: lastPosition,
110
- collapsed: true,
111
109
  segmentId: ""
110
+ });
111
+ }
112
+ /**
113
+ * Inserts text at the provided document range. Defaults to appending before the final section break.
114
+ * @param text - The text to insert.
115
+ * @param options - Optional target range, segment id, and cursor offset.
116
+ */
117
+ insertText(text, options = {}) {
118
+ var _options$startOffset, _options$endOffset, _options$segmentId;
119
+ const unitId = this.id;
120
+ const { body } = this.getSnapshot();
121
+ if (!body) throw new Error("The document body is empty");
122
+ const startOffset = (_options$startOffset = options.startOffset) !== null && _options$startOffset !== void 0 ? _options$startOffset : Math.max(0, body.dataStream.length - 2);
123
+ const endOffset = (_options$endOffset = options.endOffset) !== null && _options$endOffset !== void 0 ? _options$endOffset : startOffset;
124
+ const segmentId = (_options$segmentId = options.segmentId) !== null && _options$segmentId !== void 0 ? _options$segmentId : "";
125
+ const activeRange = {
126
+ startOffset,
127
+ endOffset,
128
+ collapsed: startOffset === endOffset,
129
+ segmentId
112
130
  };
113
- const { segmentId } = activeRange;
114
131
  return this._commandService.executeCommand(_univerjs_docs_ui.InsertCommand.id, {
115
132
  unitId,
116
133
  body: { dataStream: text },
117
134
  range: activeRange,
118
- segmentId
135
+ segmentId,
136
+ ...options.cursorOffset == null ? {} : { cursorOffset: options.cursorOffset }
137
+ });
138
+ }
139
+ /**
140
+ * Inserts one or more plain-text paragraphs at the provided document range.
141
+ * @param text - Paragraph text. Newlines are normalized to document paragraph separators.
142
+ * @param options - Optional target range, segment id, and cursor offset.
143
+ */
144
+ insertParagraph(text = "", options = {}) {
145
+ var _options$cursorOffset;
146
+ const dataStream = `${text.replace(/\r\n/g, "\n").replace(/\r/g, "\n").split("\n").join("\r\n")}\r\n`;
147
+ return this.insertText(dataStream, {
148
+ ...options,
149
+ cursorOffset: (_options$cursorOffset = options.cursorOffset) !== null && _options$cursorOffset !== void 0 ? _options$cursorOffset : dataStream.length
119
150
  });
120
151
  }
121
152
  /**