@fileverse-dev/ddoc 7.0.3 → 7.1.1-zoom.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 (47) hide show
  1. package/dist/{ddoc-persistence-DLdSviUr.mjs → ddoc-persistence-DwgX_Jov.mjs} +1 -1
  2. package/dist/headless-editor-utils.es.js +1 -1
  3. package/dist/{index-DzUWhgai.mjs → index-4pSmjy_x.mjs} +1 -1
  4. package/dist/index.es.js +8771 -8322
  5. package/dist/package/components/editor-bubble-menu/types.d.ts +0 -1
  6. package/dist/package/components/editor-toolbar/zoom-level.d.ts +1 -6
  7. package/dist/package/components/editor-toolbar.d.ts +1 -3
  8. package/dist/package/components/fullscreen-toolbar.d.ts +1 -3
  9. package/dist/package/components/inline-comment/comment-drawer-desktop.d.ts +1 -0
  10. package/dist/package/components/inline-comment/types.d.ts +1 -3
  11. package/dist/package/components/inline-comment/use-comment-drawer-filters.d.ts +6 -2
  12. package/dist/package/components/tabs/confirm-delete-modal.d.ts +1 -1
  13. package/dist/package/components/tabs/document-mobile-tab-panel.d.ts +3 -1
  14. package/dist/package/components/tabs/document-tabs-sidebar.d.ts +13 -4
  15. package/dist/package/components/tabs/tab-item.d.ts +9 -3
  16. package/dist/package/components/tabs/use-tab-tree-view.d.ts +36 -0
  17. package/dist/package/components/tabs/utils/__tests__/subtab-test-helpers.d.ts +11 -0
  18. package/dist/package/components/tabs/utils/__tests__/v7/v7-tab-ops.d.ts +15 -0
  19. package/dist/package/components/tabs/utils/__tests__/v7/v7-tab-utils.d.ts +45 -0
  20. package/dist/package/components/tabs/utils/tab-operations.d.ts +37 -0
  21. package/dist/package/components/tabs/utils/tab-utils.d.ts +25 -1
  22. package/dist/package/components/toc/document-outline.d.ts +1 -1
  23. package/dist/package/components/toc/types.d.ts +4 -0
  24. package/dist/package/constants/zoom.d.ts +3 -1
  25. package/dist/package/extensions/d-block/dblock-drag-handle.d.ts +1 -0
  26. package/dist/package/extensions/d-block/zoom-platform.d.ts +3 -0
  27. package/dist/package/extensions/resizable-media/corner-resize.d.ts +5 -0
  28. package/dist/package/extensions/resizable-media/media-paste-drop-plugin/media-paste-drop-plugin.d.ts +2 -1
  29. package/dist/package/hooks/use-canvas-metrics.d.ts +7 -2
  30. package/dist/package/hooks/use-has-floating-comments.d.ts +6 -0
  31. package/dist/package/hooks/use-tab-editor.d.ts +1 -2
  32. package/dist/package/hooks/use-tab-manager.d.ts +1 -0
  33. package/dist/package/hooks/use-zoom-shortcuts.d.ts +7 -0
  34. package/dist/package/hooks/use-zoom.d.ts +13 -0
  35. package/dist/package/hooks/use-zoomed-page.d.ts +11 -0
  36. package/dist/package/types.d.ts +5 -0
  37. package/dist/package/use-ddoc-editor.d.ts +2 -1
  38. package/dist/package/utils/upload-images.d.ts +3 -1
  39. package/dist/package/utils/zoom.d.ts +28 -0
  40. package/dist/persistence.es.js +1 -1
  41. package/dist/style.css +1 -1
  42. package/dist/tab-utils-Cvs3qmhi.mjs +340 -0
  43. package/dist/{use-headless-editor-CbMBM1S_.mjs → use-headless-editor-o0kJ5Qyo.mjs} +5884 -5685
  44. package/package.json +2 -2
  45. package/dist/package/constants/canvas-dimensions.d.ts +0 -81
  46. package/dist/package/zoom-service.d.ts +0 -10
  47. package/dist/tab-utils-BNFvrUAj.mjs +0 -284
package/package.json CHANGED
@@ -2,7 +2,7 @@
2
2
  "name": "@fileverse-dev/ddoc",
3
3
  "private": false,
4
4
  "description": "DDoc",
5
- "version": "7.0.3",
5
+ "version": "7.1.1-zoom.0",
6
6
  "repository": {
7
7
  "type": "git",
8
8
  "url": "git+https://github.com/fileverse/fileverse-ddocs.git"
@@ -205,4 +205,4 @@
205
205
  "vitest": "^2.1.0",
206
206
  "yjs": "13.6.30"
207
207
  }
208
- }
208
+ }
@@ -1,81 +0,0 @@
1
- /**
2
- * Canvas dimension constants
3
- * Design Philosophy: Canvas mimics real paper (A4) - fixed dimensions regardless of screen size
4
- * Paper doesn't change size in the real world, so our canvas shouldn't either
5
- */
6
- /**
7
- * Constraints for zoom 1.4 (fit mode)
8
- * These percentages account for the 1.4x transform scaling applied to the canvas
9
- */
10
- export declare const ORIENTATION_CONSTRAINTS: {
11
- readonly portrait: {
12
- readonly zoomFitWidth: "55%";
13
- readonly zoomFitMaxWidth: 1100;
14
- };
15
- readonly landscape: {
16
- readonly zoomFitWidth: "60%";
17
- readonly zoomFitMaxWidth: 1200;
18
- };
19
- };
20
- /**
21
- * Canvas dimension constants for different orientations and zoom levels
22
- * Portrait: Standard document width (850px at 100% zoom)
23
- * Landscape: Wider canvas for horizontal layouts (1190px at 100% zoom, ~1.4x portrait)
24
- *
25
- * Note: Zoom level 1.4 uses percentage widths that are scaled by transform: scaleX(1.4)
26
- * The effective width is baseWidth * 1.4, so percentages are reduced accordingly
27
- */
28
- export declare const CANVAS_DIMENSIONS: {
29
- readonly portrait: {
30
- readonly '0.5': {
31
- readonly width: 700;
32
- readonly minHeight: "150%";
33
- };
34
- readonly '0.75': {
35
- readonly width: 800;
36
- readonly minHeight: "200%";
37
- };
38
- readonly '1': {
39
- readonly width: 850;
40
- readonly minHeight: "100%";
41
- };
42
- readonly '1.4': {
43
- readonly width: 1190;
44
- readonly minHeight: "140%";
45
- };
46
- readonly '1.5': {
47
- readonly width: 1275;
48
- readonly minHeight: "150%";
49
- };
50
- readonly '2': {
51
- readonly width: 1700;
52
- readonly minHeight: "200%";
53
- };
54
- };
55
- readonly landscape: {
56
- readonly '0.5': {
57
- readonly width: 980;
58
- readonly minHeight: "150%";
59
- };
60
- readonly '0.75': {
61
- readonly width: 1135;
62
- readonly minHeight: "200%";
63
- };
64
- readonly '1': {
65
- readonly width: 1190;
66
- readonly minHeight: "100%";
67
- };
68
- readonly '1.4': {
69
- readonly width: 1666;
70
- readonly minHeight: "140%";
71
- };
72
- readonly '1.5': {
73
- readonly width: 1785;
74
- readonly minHeight: "150%";
75
- };
76
- readonly '2': {
77
- readonly width: 2380;
78
- readonly minHeight: "200%";
79
- };
80
- };
81
- };
@@ -1,10 +0,0 @@
1
- declare class ZoomService {
2
- private static instance;
3
- private _currentZoom;
4
- static getInstance(): ZoomService;
5
- get currentZoom(): string;
6
- setZoom(zoom: string): void;
7
- private updateElementPosition;
8
- }
9
- export declare const zoomService: ZoomService;
10
- export {};
@@ -1,284 +0,0 @@
1
- import { fromUint8Array as R, toUint8Array as p } from "js-base64";
2
- import * as d from "yjs";
3
- const M = "default", E = "Tab 1", Y = "ddocTabs", F = "tabs_order", S = "tabs_name_registry", N = "tabs_emoji_registry", U = "tabs_state", L = "tabs_delete_registry", A = "activeTabId";
4
- function m(e) {
5
- return {
6
- order: e.getArray(F),
7
- nameById: e.getMap(S),
8
- emojiById: e.getMap(N),
9
- tabState: e.getMap(U),
10
- // Soft-deleted tabs keep their fragment for undo and late peer updates.
11
- // This tombstone stops self-heal from resurrecting deleted tabs from stale tab metadata.
12
- deletedById: e.getMap(L)
13
- };
14
- }
15
- function h(e, t) {
16
- if (e)
17
- try {
18
- if (Array.isArray(e)) {
19
- const n = e.map((r) => p(r));
20
- d.applyUpdate(t, d.mergeUpdates(n), "self");
21
- return;
22
- }
23
- d.applyUpdate(t, p(e), "self");
24
- } catch (n) {
25
- console.log(n);
26
- }
27
- }
28
- function g(e) {
29
- return e ? e.toArray().filter((t) => typeof t == "string") : [];
30
- }
31
- function C(e) {
32
- const t = e.getMap(Y), n = t.get("order"), r = t.get("tabs"), s = t.get("activeTabId"), l = g(
33
- n instanceof d.Array ? n : null
34
- ), o = /* @__PURE__ */ new Map(), f = /* @__PURE__ */ new Map();
35
- return r instanceof d.Map && r.forEach((u, a) => {
36
- if (!(u instanceof d.Map) || typeof a != "string") return;
37
- const i = u.get("name"), c = u.get("emoji");
38
- typeof i == "string" && o.set(a, i), (typeof c == "string" || c === null) && f.set(a, c);
39
- }), {
40
- order: l,
41
- names: o,
42
- emojis: f,
43
- activeTabId: s instanceof d.Text && s.toString() || null,
44
- deletedIds: /* @__PURE__ */ new Set(),
45
- hasData: l.length > 0 || o.size > 0 || f.size > 0 || s instanceof d.Text && s.length > 0
46
- };
47
- }
48
- function I(e) {
49
- const t = m(e), n = /* @__PURE__ */ new Map(), r = /* @__PURE__ */ new Map(), s = /* @__PURE__ */ new Set();
50
- t.nameById.forEach((f, u) => {
51
- typeof f == "string" && n.set(u, f);
52
- }), t.emojiById.forEach((f, u) => {
53
- (typeof f == "string" || f === null) && r.set(u, f);
54
- }), t.deletedById.forEach((f, u) => {
55
- f === !0 && s.add(u);
56
- });
57
- const l = t.tabState.get(A), o = typeof l == "string" ? l : null;
58
- return {
59
- order: g(t.order),
60
- names: n,
61
- emojis: r,
62
- activeTabId: o,
63
- deletedIds: s,
64
- hasData: t.order.length > 0 || t.nameById.size > 0 || t.emojiById.size > 0 || t.deletedById.size > 0 || o !== null
65
- };
66
- }
67
- function _(e) {
68
- const t = /* @__PURE__ */ new Set(), n = [];
69
- return e.forEach((r) => {
70
- t.has(r) || (t.add(r), n.push(r));
71
- }), n;
72
- }
73
- function j(e) {
74
- return e === 0 ? E : `Tab ${e + 1}`;
75
- }
76
- function K(e, t) {
77
- return _([
78
- ...e.order,
79
- ...t.order,
80
- ...Array.from(e.names.keys()),
81
- ...Array.from(e.emojis.keys()),
82
- ...Array.from(t.names.keys()),
83
- ...Array.from(t.emojis.keys())
84
- ]);
85
- }
86
- function b(e, t) {
87
- const n = new Set(e.deletedIds);
88
- t.forEach((a) => {
89
- a.deletedIds.forEach((i) => n.add(i));
90
- });
91
- const r = /* @__PURE__ */ new Set(), s = [];
92
- e.order.forEach((a) => {
93
- !n.has(a) && !r.has(a) && (r.add(a), s.push(a));
94
- });
95
- const l = /* @__PURE__ */ new Map(), o = /* @__PURE__ */ new Map();
96
- e.names.forEach((a, i) => {
97
- n.has(i) || l.set(i, a);
98
- }), e.emojis.forEach((a, i) => {
99
- n.has(i) || o.set(i, a);
100
- }), t.forEach((a) => {
101
- a.order.forEach((i) => {
102
- n.has(i) || (r.has(i) || (r.add(i), s.push(i)), !l.has(i) && a.names.has(i) && l.set(i, a.names.get(i) ?? E), o.has(i) || o.set(
103
- i,
104
- a.emojis.has(i) ? a.emojis.get(i) ?? null : null
105
- ));
106
- });
107
- }), s.forEach((a, i) => {
108
- l.has(a) || l.set(a, j(i)), (!o.has(a) || o.get(a) === void 0) && o.set(a, null);
109
- });
110
- const u = [
111
- e.activeTabId,
112
- ...t.map((a) => a.activeTabId)
113
- ].find(
114
- (a) => !!a && r.has(a) && !n.has(a)
115
- ) ?? s[0] ?? null;
116
- return {
117
- order: s,
118
- names: l,
119
- emojis: o,
120
- activeTabId: u,
121
- deletedIds: n
122
- };
123
- }
124
- function z(e, t, n) {
125
- const r = (n == null ? void 0 : n.createDefaultTabIfMissing) ?? !1, s = new Set(e.deletedIds), l = K(
126
- e,
127
- t
128
- ).filter((c) => !s.has(c)), o = _([
129
- ...e.order,
130
- ...t.order
131
- ]);
132
- l.forEach((c) => {
133
- o.includes(c) || o.push(c);
134
- }), o.length === 0 && r && o.push(M);
135
- const f = /* @__PURE__ */ new Map(), u = /* @__PURE__ */ new Map();
136
- o.forEach((c, D) => {
137
- const B = e.names.get(c) ?? t.names.get(c) ?? j(D), O = e.emojis.has(c) ? e.emojis.get(c) ?? null : t.emojis.has(c) ? t.emojis.get(c) ?? null : null;
138
- f.set(c, B), u.set(c, O);
139
- });
140
- const i = [
141
- e.activeTabId,
142
- t.activeTabId
143
- ].find(
144
- (c) => !!c && o.includes(c)
145
- ) ?? o[0] ?? null;
146
- return {
147
- order: o,
148
- names: f,
149
- emojis: u,
150
- activeTabId: i,
151
- deletedIds: s
152
- };
153
- }
154
- function k(e, t) {
155
- return e.length !== t.length ? !1 : e.every((n, r) => n === t[r]);
156
- }
157
- function V(e, t) {
158
- const n = g(e);
159
- return k(n, t) ? !1 : (e.length > 0 && e.delete(0, e.length), t.length > 0 && e.insert(0, t), !0);
160
- }
161
- function W(e, t, n) {
162
- const r = e.get(t);
163
- return n === null ? r === void 0 ? !1 : (e.delete(t), !0) : r === n ? !1 : (e.set(t, n), !0);
164
- }
165
- function T(e, t) {
166
- let n = !1;
167
- return Array.from(e.keys()).forEach((r) => {
168
- t.has(r) || (e.delete(r), n = !0);
169
- }), t.forEach((r, s) => {
170
- e.get(s) !== r && (e.set(s, r), n = !0);
171
- }), n;
172
- }
173
- function v(e, t, n = "self") {
174
- const r = m(e);
175
- let s = !1;
176
- const l = new Map(
177
- Array.from(t.deletedIds, (o) => [o, !0])
178
- );
179
- return e.transact(() => {
180
- t.order.forEach((o) => {
181
- e.getXmlFragment(o);
182
- }), s = V(r.order, t.order) || s, s = T(r.nameById, t.names) || s, s = T(r.emojiById, t.emojis) || s, s = W(
183
- r.tabState,
184
- A,
185
- t.activeTabId
186
- ) || s, s = T(r.deletedById, l) || s;
187
- }, n), s;
188
- }
189
- function y(e, t) {
190
- const n = I(e), r = C(e), s = z(
191
- n,
192
- r,
193
- t
194
- );
195
- return {
196
- tabSnapshotV2: n,
197
- legacySnapshot: r,
198
- resolvedTabState: s
199
- };
200
- }
201
- function w(e, t, n = "self") {
202
- const { resolvedTabState: r } = y(e, t);
203
- return v(e, r, n);
204
- }
205
- function P(e, t, n) {
206
- h(e, t);
207
- const r = w(t, {
208
- ...n,
209
- createDefaultTabIfMissing: (n == null ? void 0 : n.createDefaultTabIfMissing) ?? !0
210
- }), s = m(t);
211
- return {
212
- tabList: q(s),
213
- activeTabId: X(s) || M,
214
- didWrite: r
215
- };
216
- }
217
- function $(e) {
218
- return m(e);
219
- }
220
- function H(e, t, n = "self") {
221
- const r = w(e, t, n);
222
- return {
223
- ...m(e),
224
- didWrite: r
225
- };
226
- }
227
- function Q(e, t) {
228
- const n = e.map((o) => {
229
- const f = new d.Doc();
230
- return h(o, f), y(f, t).resolvedTabState;
231
- }), r = new d.Doc();
232
- h(e, r);
233
- const { resolvedTabState: s } = y(
234
- r,
235
- t
236
- ), l = b(
237
- s,
238
- n
239
- );
240
- return v(r, l), R(d.encodeStateAsUpdate(r));
241
- }
242
- function X(e) {
243
- const t = e.tabState.get(A);
244
- return typeof t == "string" ? t : null;
245
- }
246
- function G(e, t) {
247
- return e.nameById.has(t) ? {
248
- name: e.nameById.get(t) ?? E,
249
- emoji: e.emojiById.has(t) ? e.emojiById.get(t) ?? null : null
250
- } : null;
251
- }
252
- function q(e) {
253
- const t = /* @__PURE__ */ new Set();
254
- return g(e.order).filter((n) => t.has(n) ? !1 : (t.add(n), !0)).map((n) => {
255
- const r = G(
256
- e,
257
- n
258
- );
259
- return r ? {
260
- id: n,
261
- name: r.name,
262
- emoji: r.emoji
263
- } : null;
264
- }).filter((n) => n !== null);
265
- }
266
- function Z(e) {
267
- return e.toArray().map((t) => t instanceof d.XmlElement || t instanceof d.XmlText ? t.clone() : null).filter((t) => t !== null);
268
- }
269
- export {
270
- A,
271
- M as D,
272
- Y as L,
273
- F as O,
274
- U as S,
275
- G as a,
276
- X as b,
277
- Z as c,
278
- P as d,
279
- q as e,
280
- E as f,
281
- $ as g,
282
- Q as m,
283
- H as s
284
- };