@sametalmdr/word-editor 0.2.0-alpha → 0.3.0-alpha
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/CHANGELOG.md +108 -70
- package/LICENSE +21 -21
- package/README.md +286 -247
- package/dist/canvas/box-clipboard.js +238 -238
- package/dist/canvas/box-selection.js +80 -80
- package/dist/canvas/canvas-editor.js +502 -502
- package/dist/canvas/controller.js +717 -717
- package/dist/canvas/geometry.js +131 -131
- package/dist/canvas/gesture.d.ts +0 -1
- package/dist/canvas/gesture.js +289 -289
- package/dist/canvas/handles.js +212 -212
- package/dist/canvas/menu.js +82 -82
- package/dist/canvas/mode-controller.js +81 -81
- package/dist/canvas/nudge.js +108 -108
- package/dist/canvas/overlay.js +149 -149
- package/dist/canvas/snap.js +132 -132
- package/dist/canvas/viewport.js +112 -112
- package/dist/canvas/z-order.js +171 -171
- package/dist/commands/alignment.js +150 -150
- package/dist/commands/box.js +272 -272
- package/dist/commands/clipboard.js +93 -93
- package/dist/commands/graphemes.js +112 -112
- package/dist/commands/marks.js +153 -153
- package/dist/commands/paragraph-props.js +176 -176
- package/dist/commands/size.js +368 -368
- package/dist/commands/text.js +291 -291
- package/dist/docx.d.ts +1 -0
- package/dist/docx.js +15 -13
- package/dist/editor/editing-host.js +434 -434
- package/dist/element.js +41 -41
- package/dist/fonts/OFL-Carlito.txt +94 -0
- package/dist/fonts/calibri-metrics.d.ts +27 -0
- package/dist/fonts/calibri-metrics.js +88 -0
- package/dist/history/history.js +433 -433
- package/dist/index.js +63 -63
- package/dist/input/beforeinput.js +224 -224
- package/dist/input/clipboard.js +107 -107
- package/dist/input/composition.js +341 -341
- package/dist/input/keymap.js +54 -54
- package/dist/io/ooxml/custgeom.js +72 -72
- package/dist/io/ooxml/drawingml.js +232 -232
- package/dist/io/ooxml/edits.js +67 -67
- package/dist/io/ooxml/export-splice.js +880 -880
- package/dist/io/ooxml/export.js +365 -365
- package/dist/io/ooxml/fill.d.ts +93 -8
- package/dist/io/ooxml/fill.js +618 -562
- package/dist/io/ooxml/fit.d.ts +252 -0
- package/dist/io/ooxml/fit.js +598 -0
- package/dist/io/ooxml/import-gate.js +200 -200
- package/dist/io/ooxml/import.js +691 -691
- package/dist/io/ooxml/inflate.js +126 -126
- package/dist/io/ooxml/media.js +87 -87
- package/dist/io/ooxml/ns.d.ts +2 -0
- package/dist/io/ooxml/ns.js +26 -21
- package/dist/io/ooxml/numbering.js +290 -290
- package/dist/io/ooxml/opc-write.js +171 -171
- package/dist/io/ooxml/provenance.js +93 -93
- package/dist/io/ooxml/recipe.js +708 -708
- package/dist/io/ooxml/relationships.js +59 -59
- package/dist/io/ooxml/run-fonts.d.ts +89 -0
- package/dist/io/ooxml/run-fonts.js +378 -0
- package/dist/io/ooxml/slots.d.ts +4 -0
- package/dist/io/ooxml/slots.js +582 -581
- package/dist/io/ooxml/styles-resolve.js +257 -257
- package/dist/io/ooxml/units.js +43 -43
- package/dist/io/ooxml/value.js +120 -120
- package/dist/io/ooxml/xml-scan.js +616 -616
- package/dist/io/ooxml/zip-container.js +228 -228
- package/dist/io/ooxml/zip-reject.js +106 -106
- package/dist/measure/placement.js +83 -83
- package/dist/measure/report.js +75 -75
- package/dist/model/ids.js +70 -70
- package/dist/model/normalize.js +146 -146
- package/dist/model/position.js +283 -283
- package/dist/model/transaction.js +209 -209
- package/dist/platform/capabilities.js +25 -25
- package/dist/react/index.js +21 -21
- package/dist/selection/controller.js +315 -315
- package/dist/selection/dom-map.js +334 -334
- package/dist/state/editor-state.js +109 -109
- package/dist/styles.css +66 -66
- package/package.json +94 -93
package/dist/canvas/geometry.js
CHANGED
|
@@ -1,131 +1,131 @@
|
|
|
1
|
-
// Pure pt-space rectangle math for the canvas interaction layer (ADR-0018
|
|
2
|
-
// §9/Karar 9). Every function here works on {x, y, cx, cy} — the same shape
|
|
3
|
-
// BoxLayout and Decoration already use (src/model/node.js) — so a caller
|
|
4
|
-
// never converts between coordinate conventions to use this file.
|
|
5
|
-
//
|
|
6
|
-
// `rectLines` is the single definition of "the six snap lines" a rect
|
|
7
|
-
// offers (ADR-0018 Karar 6, §9): snap.js (a later phase) reuses this rather
|
|
8
|
-
// than recomputing left/centerX/right/top/centerY/bottom itself, the same
|
|
9
|
-
// "one definition, several consumers" discipline pageOccupants() applies to
|
|
10
|
-
// "is this a box or a decoration" (page.js).
|
|
11
|
-
//
|
|
12
|
-
// No src/, DOM, or history import — this module is pure data in, data out.
|
|
13
|
-
|
|
14
|
-
/**
|
|
15
|
-
* @typedef {object} Rect
|
|
16
|
-
* @property {number} x
|
|
17
|
-
* @property {number} y
|
|
18
|
-
* @property {number} cx
|
|
19
|
-
* @property {number} cy
|
|
20
|
-
*/
|
|
21
|
-
|
|
22
|
-
/**
|
|
23
|
-
* @typedef {object} SnapLines
|
|
24
|
-
* @property {number} left
|
|
25
|
-
* @property {number} centerX
|
|
26
|
-
* @property {number} right
|
|
27
|
-
* @property {number} top
|
|
28
|
-
* @property {number} centerY
|
|
29
|
-
* @property {number} bottom
|
|
30
|
-
*/
|
|
31
|
-
|
|
32
|
-
/**
|
|
33
|
-
* Extracts the rect portion of anything shaped like a BoxLayout or a
|
|
34
|
-
* Decoration (both carry x/y/cx/cy alongside fields this module does not
|
|
35
|
-
* care about — z, rot, fillHex, paths). Always returns a NEW object: the
|
|
36
|
-
* caller never receives a live reference into the model (invariant #13's
|
|
37
|
-
* discipline applied here even though this is not an IO boundary — a
|
|
38
|
-
* pageOccupants() consumer mutating a returned rect must never reach the
|
|
39
|
-
* real BoxLayout/Decoration entry).
|
|
40
|
-
*
|
|
41
|
-
* @param {{x: number, y: number, cx: number, cy: number}} entry
|
|
42
|
-
* @returns {Rect}
|
|
43
|
-
*/
|
|
44
|
-
export function rectOfLayout(entry) {
|
|
45
|
-
return { x: entry.x, y: entry.y, cx: entry.cx, cy: entry.cy };
|
|
46
|
-
}
|
|
47
|
-
|
|
48
|
-
/**
|
|
49
|
-
* True when `inner` is entirely within `outer`, edges inclusive. A point is
|
|
50
|
-
* just a zero-size rect ({x, y, cx: 0, cy: 0}) — hit-test.js's
|
|
51
|
-
* point-in-rect check reuses this rather than defining its own, the same
|
|
52
|
-
* "one definition" discipline as `rectLines`.
|
|
53
|
-
*
|
|
54
|
-
* @param {Rect} outer
|
|
55
|
-
* @param {Rect} inner
|
|
56
|
-
* @returns {boolean}
|
|
57
|
-
*/
|
|
58
|
-
export function rectContains(outer, inner) {
|
|
59
|
-
return (
|
|
60
|
-
outer.x <= inner.x &&
|
|
61
|
-
inner.x + inner.cx <= outer.x + outer.cx &&
|
|
62
|
-
outer.y <= inner.y &&
|
|
63
|
-
inner.y + inner.cy <= outer.y + outer.cy
|
|
64
|
-
);
|
|
65
|
-
}
|
|
66
|
-
|
|
67
|
-
/**
|
|
68
|
-
* True when `a` and `b` overlap by a non-zero area. Edges touching (sharing
|
|
69
|
-
* a boundary with no overlap) do NOT count — strict inequalities, matching
|
|
70
|
-
* `contenteditable-scale-probe.html`'s `countOverlaps` (the corpus's own
|
|
71
|
-
* overlap-pair count was built the same way).
|
|
72
|
-
*
|
|
73
|
-
* @param {Rect} a
|
|
74
|
-
* @param {Rect} b
|
|
75
|
-
* @returns {boolean}
|
|
76
|
-
*/
|
|
77
|
-
export function rectsIntersect(a, b) {
|
|
78
|
-
return a.x < b.x + b.cx && b.x < a.x + a.cx && a.y < b.y + b.cy && b.y < a.y + a.cy;
|
|
79
|
-
}
|
|
80
|
-
|
|
81
|
-
/**
|
|
82
|
-
* A rect built from two dragged corners can have a negative `cx`/`cy`
|
|
83
|
-
* (dragging up-left of the start point). Returns an equivalent rect with
|
|
84
|
-
* non-negative `cx`/`cy`, flipping `x`/`y` to compensate — the marquee
|
|
85
|
-
* (ADR-0018 Karar 5, a later phase) needs this before it can call
|
|
86
|
-
* `rectContains`/`rectsIntersect`, which assume non-negative size.
|
|
87
|
-
*
|
|
88
|
-
* @param {Rect} rect
|
|
89
|
-
* @returns {Rect}
|
|
90
|
-
*/
|
|
91
|
-
export function normalizeRect(rect) {
|
|
92
|
-
const x = rect.cx < 0 ? rect.x + rect.cx : rect.x;
|
|
93
|
-
const y = rect.cy < 0 ? rect.y + rect.cy : rect.y;
|
|
94
|
-
return { x, y, cx: Math.abs(rect.cx), cy: Math.abs(rect.cy) };
|
|
95
|
-
}
|
|
96
|
-
|
|
97
|
-
/**
|
|
98
|
-
* The smallest rect containing both `a` and `b` — the multi-select bounding
|
|
99
|
-
* box a later phase draws its single move handle around.
|
|
100
|
-
*
|
|
101
|
-
* @param {Rect} a
|
|
102
|
-
* @param {Rect} b
|
|
103
|
-
* @returns {Rect}
|
|
104
|
-
*/
|
|
105
|
-
export function unionRect(a, b) {
|
|
106
|
-
const x = Math.min(a.x, b.x);
|
|
107
|
-
const y = Math.min(a.y, b.y);
|
|
108
|
-
const right = Math.max(a.x + a.cx, b.x + b.cx);
|
|
109
|
-
const bottom = Math.max(a.y + a.cy, b.y + b.cy);
|
|
110
|
-
return { x, y, cx: right - x, cy: bottom - y };
|
|
111
|
-
}
|
|
112
|
-
|
|
113
|
-
/**
|
|
114
|
-
* The six lines a rect offers a snap search: three vertical (left, center,
|
|
115
|
-
* right) and three horizontal (top, center, bottom). ADR-0018 §6.2's
|
|
116
|
-
* "sürüklenen kutunun sol/orta-x/sağ ve üst/orta-y/alt, hedefin aynı
|
|
117
|
-
* altısına karşı" rule, defined exactly once.
|
|
118
|
-
*
|
|
119
|
-
* @param {Rect} rect
|
|
120
|
-
* @returns {SnapLines}
|
|
121
|
-
*/
|
|
122
|
-
export function rectLines(rect) {
|
|
123
|
-
return {
|
|
124
|
-
left: rect.x,
|
|
125
|
-
centerX: rect.x + rect.cx / 2,
|
|
126
|
-
right: rect.x + rect.cx,
|
|
127
|
-
top: rect.y,
|
|
128
|
-
centerY: rect.y + rect.cy / 2,
|
|
129
|
-
bottom: rect.y + rect.cy,
|
|
130
|
-
};
|
|
131
|
-
}
|
|
1
|
+
// Pure pt-space rectangle math for the canvas interaction layer (ADR-0018
|
|
2
|
+
// §9/Karar 9). Every function here works on {x, y, cx, cy} — the same shape
|
|
3
|
+
// BoxLayout and Decoration already use (src/model/node.js) — so a caller
|
|
4
|
+
// never converts between coordinate conventions to use this file.
|
|
5
|
+
//
|
|
6
|
+
// `rectLines` is the single definition of "the six snap lines" a rect
|
|
7
|
+
// offers (ADR-0018 Karar 6, §9): snap.js (a later phase) reuses this rather
|
|
8
|
+
// than recomputing left/centerX/right/top/centerY/bottom itself, the same
|
|
9
|
+
// "one definition, several consumers" discipline pageOccupants() applies to
|
|
10
|
+
// "is this a box or a decoration" (page.js).
|
|
11
|
+
//
|
|
12
|
+
// No src/, DOM, or history import — this module is pure data in, data out.
|
|
13
|
+
|
|
14
|
+
/**
|
|
15
|
+
* @typedef {object} Rect
|
|
16
|
+
* @property {number} x
|
|
17
|
+
* @property {number} y
|
|
18
|
+
* @property {number} cx
|
|
19
|
+
* @property {number} cy
|
|
20
|
+
*/
|
|
21
|
+
|
|
22
|
+
/**
|
|
23
|
+
* @typedef {object} SnapLines
|
|
24
|
+
* @property {number} left
|
|
25
|
+
* @property {number} centerX
|
|
26
|
+
* @property {number} right
|
|
27
|
+
* @property {number} top
|
|
28
|
+
* @property {number} centerY
|
|
29
|
+
* @property {number} bottom
|
|
30
|
+
*/
|
|
31
|
+
|
|
32
|
+
/**
|
|
33
|
+
* Extracts the rect portion of anything shaped like a BoxLayout or a
|
|
34
|
+
* Decoration (both carry x/y/cx/cy alongside fields this module does not
|
|
35
|
+
* care about — z, rot, fillHex, paths). Always returns a NEW object: the
|
|
36
|
+
* caller never receives a live reference into the model (invariant #13's
|
|
37
|
+
* discipline applied here even though this is not an IO boundary — a
|
|
38
|
+
* pageOccupants() consumer mutating a returned rect must never reach the
|
|
39
|
+
* real BoxLayout/Decoration entry).
|
|
40
|
+
*
|
|
41
|
+
* @param {{x: number, y: number, cx: number, cy: number}} entry
|
|
42
|
+
* @returns {Rect}
|
|
43
|
+
*/
|
|
44
|
+
export function rectOfLayout(entry) {
|
|
45
|
+
return { x: entry.x, y: entry.y, cx: entry.cx, cy: entry.cy };
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
/**
|
|
49
|
+
* True when `inner` is entirely within `outer`, edges inclusive. A point is
|
|
50
|
+
* just a zero-size rect ({x, y, cx: 0, cy: 0}) — hit-test.js's
|
|
51
|
+
* point-in-rect check reuses this rather than defining its own, the same
|
|
52
|
+
* "one definition" discipline as `rectLines`.
|
|
53
|
+
*
|
|
54
|
+
* @param {Rect} outer
|
|
55
|
+
* @param {Rect} inner
|
|
56
|
+
* @returns {boolean}
|
|
57
|
+
*/
|
|
58
|
+
export function rectContains(outer, inner) {
|
|
59
|
+
return (
|
|
60
|
+
outer.x <= inner.x &&
|
|
61
|
+
inner.x + inner.cx <= outer.x + outer.cx &&
|
|
62
|
+
outer.y <= inner.y &&
|
|
63
|
+
inner.y + inner.cy <= outer.y + outer.cy
|
|
64
|
+
);
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
/**
|
|
68
|
+
* True when `a` and `b` overlap by a non-zero area. Edges touching (sharing
|
|
69
|
+
* a boundary with no overlap) do NOT count — strict inequalities, matching
|
|
70
|
+
* `contenteditable-scale-probe.html`'s `countOverlaps` (the corpus's own
|
|
71
|
+
* overlap-pair count was built the same way).
|
|
72
|
+
*
|
|
73
|
+
* @param {Rect} a
|
|
74
|
+
* @param {Rect} b
|
|
75
|
+
* @returns {boolean}
|
|
76
|
+
*/
|
|
77
|
+
export function rectsIntersect(a, b) {
|
|
78
|
+
return a.x < b.x + b.cx && b.x < a.x + a.cx && a.y < b.y + b.cy && b.y < a.y + a.cy;
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
/**
|
|
82
|
+
* A rect built from two dragged corners can have a negative `cx`/`cy`
|
|
83
|
+
* (dragging up-left of the start point). Returns an equivalent rect with
|
|
84
|
+
* non-negative `cx`/`cy`, flipping `x`/`y` to compensate — the marquee
|
|
85
|
+
* (ADR-0018 Karar 5, a later phase) needs this before it can call
|
|
86
|
+
* `rectContains`/`rectsIntersect`, which assume non-negative size.
|
|
87
|
+
*
|
|
88
|
+
* @param {Rect} rect
|
|
89
|
+
* @returns {Rect}
|
|
90
|
+
*/
|
|
91
|
+
export function normalizeRect(rect) {
|
|
92
|
+
const x = rect.cx < 0 ? rect.x + rect.cx : rect.x;
|
|
93
|
+
const y = rect.cy < 0 ? rect.y + rect.cy : rect.y;
|
|
94
|
+
return { x, y, cx: Math.abs(rect.cx), cy: Math.abs(rect.cy) };
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
/**
|
|
98
|
+
* The smallest rect containing both `a` and `b` — the multi-select bounding
|
|
99
|
+
* box a later phase draws its single move handle around.
|
|
100
|
+
*
|
|
101
|
+
* @param {Rect} a
|
|
102
|
+
* @param {Rect} b
|
|
103
|
+
* @returns {Rect}
|
|
104
|
+
*/
|
|
105
|
+
export function unionRect(a, b) {
|
|
106
|
+
const x = Math.min(a.x, b.x);
|
|
107
|
+
const y = Math.min(a.y, b.y);
|
|
108
|
+
const right = Math.max(a.x + a.cx, b.x + b.cx);
|
|
109
|
+
const bottom = Math.max(a.y + a.cy, b.y + b.cy);
|
|
110
|
+
return { x, y, cx: right - x, cy: bottom - y };
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
/**
|
|
114
|
+
* The six lines a rect offers a snap search: three vertical (left, center,
|
|
115
|
+
* right) and three horizontal (top, center, bottom). ADR-0018 §6.2's
|
|
116
|
+
* "sürüklenen kutunun sol/orta-x/sağ ve üst/orta-y/alt, hedefin aynı
|
|
117
|
+
* altısına karşı" rule, defined exactly once.
|
|
118
|
+
*
|
|
119
|
+
* @param {Rect} rect
|
|
120
|
+
* @returns {SnapLines}
|
|
121
|
+
*/
|
|
122
|
+
export function rectLines(rect) {
|
|
123
|
+
return {
|
|
124
|
+
left: rect.x,
|
|
125
|
+
centerX: rect.x + rect.cx / 2,
|
|
126
|
+
right: rect.x + rect.cx,
|
|
127
|
+
top: rect.y,
|
|
128
|
+
centerY: rect.y + rect.cy / 2,
|
|
129
|
+
bottom: rect.y + rect.cy,
|
|
130
|
+
};
|
|
131
|
+
}
|
package/dist/canvas/gesture.d.ts
CHANGED
|
@@ -127,7 +127,6 @@ export function framePatches(entries: DragEntry[], dx: number, dy: number, limit
|
|
|
127
127
|
*/
|
|
128
128
|
export function framePatchesMatchKeys(previousPatches: import("../commands/box.js").BoxTransformEntry[], patches: import("../commands/box.js").BoxTransformEntry[]): boolean;
|
|
129
129
|
/**
|
|
130
|
-
*
|
|
131
130
|
* Terk (abandon) kapanıştan (closed) AYIRT EDİLEBİLİR tutulur (ADR-0016 §1):
|
|
132
131
|
* a mutation that let an abandoned gesture read back as "closed" would make
|
|
133
132
|
* "the bracket abandons cleanly" impossible to assert — it would only ever
|