@docmentis/udoc-editor 0.0.1 → 0.8.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.
- package/LICENSE-APACHE +202 -0
- package/LICENSE-MIT +21 -0
- package/README.md +48 -0
- package/dist/arrange.d.ts +37 -0
- package/dist/arrange.d.ts.map +1 -0
- package/dist/arrange.js +431 -0
- package/dist/arrange.js.map +1 -0
- package/dist/clipboard.d.ts +12 -0
- package/dist/clipboard.d.ts.map +1 -0
- package/dist/clipboard.js +101 -0
- package/dist/clipboard.js.map +1 -0
- package/dist/commands.d.ts +12 -0
- package/dist/commands.d.ts.map +1 -0
- package/dist/commands.js +225 -0
- package/dist/commands.js.map +1 -0
- package/dist/components/ComboBox.d.ts +38 -0
- package/dist/components/ComboBox.d.ts.map +1 -0
- package/dist/components/ComboBox.js +57 -0
- package/dist/components/ComboBox.js.map +1 -0
- package/dist/components/ModeSwitch.d.ts +15 -0
- package/dist/components/ModeSwitch.d.ts.map +1 -0
- package/dist/components/ModeSwitch.js +94 -0
- package/dist/components/ModeSwitch.js.map +1 -0
- package/dist/components/NewSlideModal.d.ts +41 -0
- package/dist/components/NewSlideModal.d.ts.map +1 -0
- package/dist/components/NewSlideModal.js +136 -0
- package/dist/components/NewSlideModal.js.map +1 -0
- package/dist/components/PageControls.d.ts +78 -0
- package/dist/components/PageControls.d.ts.map +1 -0
- package/dist/components/PageControls.js +201 -0
- package/dist/components/PageControls.js.map +1 -0
- package/dist/components/PageSettingsModal.d.ts +27 -0
- package/dist/components/PageSettingsModal.d.ts.map +1 -0
- package/dist/components/PageSettingsModal.js +273 -0
- package/dist/components/PageSettingsModal.js.map +1 -0
- package/dist/components/PaintOptionsModal.d.ts +19 -0
- package/dist/components/PaintOptionsModal.d.ts.map +1 -0
- package/dist/components/PaintOptionsModal.js +103 -0
- package/dist/components/PaintOptionsModal.js.map +1 -0
- package/dist/components/TextControls.d.ts +49 -0
- package/dist/components/TextControls.d.ts.map +1 -0
- package/dist/components/TextControls.js +452 -0
- package/dist/components/TextControls.js.map +1 -0
- package/dist/context-menu.d.ts +46 -0
- package/dist/context-menu.d.ts.map +1 -0
- package/dist/context-menu.js +144 -0
- package/dist/context-menu.js.map +1 -0
- package/dist/edit-client.d.ts +121 -0
- package/dist/edit-client.d.ts.map +1 -0
- package/dist/edit-client.js +154 -0
- package/dist/edit-client.js.map +1 -0
- package/dist/edit-command.d.ts +7 -0
- package/dist/edit-command.d.ts.map +1 -0
- package/dist/edit-command.js +18 -0
- package/dist/edit-command.js.map +1 -0
- package/dist/edit-mode.d.ts +19 -0
- package/dist/edit-mode.d.ts.map +1 -0
- package/dist/edit-mode.js +214 -0
- package/dist/edit-mode.js.map +1 -0
- package/dist/editor.d.ts +101 -0
- package/dist/editor.d.ts.map +1 -0
- package/dist/editor.js +101 -0
- package/dist/editor.js.map +1 -0
- package/dist/fonts/faces.d.ts +28 -0
- package/dist/fonts/faces.d.ts.map +1 -0
- package/dist/fonts/faces.js +38 -0
- package/dist/fonts/faces.js.map +1 -0
- package/dist/fonts/preview.d.ts +98 -0
- package/dist/fonts/preview.d.ts.map +1 -0
- package/dist/fonts/preview.js +149 -0
- package/dist/fonts/preview.js.map +1 -0
- package/dist/formatting-marks.d.ts +23 -0
- package/dist/formatting-marks.d.ts.map +1 -0
- package/dist/formatting-marks.js +55 -0
- package/dist/formatting-marks.js.map +1 -0
- package/dist/grips.d.ts +14 -0
- package/dist/grips.d.ts.map +1 -0
- package/dist/grips.js +459 -0
- package/dist/grips.js.map +1 -0
- package/dist/i18n/ar.d.ts +4 -0
- package/dist/i18n/ar.d.ts.map +1 -0
- package/dist/i18n/ar.js +175 -0
- package/dist/i18n/ar.js.map +1 -0
- package/dist/i18n/de.d.ts +4 -0
- package/dist/i18n/de.d.ts.map +1 -0
- package/dist/i18n/de.js +175 -0
- package/dist/i18n/de.js.map +1 -0
- package/dist/i18n/en.d.ts +5 -0
- package/dist/i18n/en.d.ts.map +1 -0
- package/dist/i18n/en.js +176 -0
- package/dist/i18n/en.js.map +1 -0
- package/dist/i18n/es.d.ts +4 -0
- package/dist/i18n/es.d.ts.map +1 -0
- package/dist/i18n/es.js +175 -0
- package/dist/i18n/es.js.map +1 -0
- package/dist/i18n/fr.d.ts +4 -0
- package/dist/i18n/fr.d.ts.map +1 -0
- package/dist/i18n/fr.js +175 -0
- package/dist/i18n/fr.js.map +1 -0
- package/dist/i18n/index.d.ts +21 -0
- package/dist/i18n/index.d.ts.map +1 -0
- package/dist/i18n/index.js +42 -0
- package/dist/i18n/index.js.map +1 -0
- package/dist/i18n/ja.d.ts +4 -0
- package/dist/i18n/ja.d.ts.map +1 -0
- package/dist/i18n/ja.js +175 -0
- package/dist/i18n/ja.js.map +1 -0
- package/dist/i18n/ko.d.ts +4 -0
- package/dist/i18n/ko.d.ts.map +1 -0
- package/dist/i18n/ko.js +175 -0
- package/dist/i18n/ko.js.map +1 -0
- package/dist/i18n/messages.d.ts +316 -0
- package/dist/i18n/messages.d.ts.map +1 -0
- package/dist/i18n/messages.js +2 -0
- package/dist/i18n/messages.js.map +1 -0
- package/dist/i18n/pt-BR.d.ts +4 -0
- package/dist/i18n/pt-BR.d.ts.map +1 -0
- package/dist/i18n/pt-BR.js +175 -0
- package/dist/i18n/pt-BR.js.map +1 -0
- package/dist/i18n/ru.d.ts +4 -0
- package/dist/i18n/ru.d.ts.map +1 -0
- package/dist/i18n/ru.js +175 -0
- package/dist/i18n/ru.js.map +1 -0
- package/dist/i18n/zh-CN.d.ts +4 -0
- package/dist/i18n/zh-CN.d.ts.map +1 -0
- package/dist/i18n/zh-CN.js +175 -0
- package/dist/i18n/zh-CN.js.map +1 -0
- package/dist/i18n/zh-TW.d.ts +4 -0
- package/dist/i18n/zh-TW.d.ts.map +1 -0
- package/dist/i18n/zh-TW.js +175 -0
- package/dist/i18n/zh-TW.js.map +1 -0
- package/dist/icons.d.ts +97 -0
- package/dist/icons.d.ts.map +1 -0
- package/dist/icons.js +103 -0
- package/dist/icons.js.map +1 -0
- package/dist/index.d.ts +9 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +14 -0
- package/dist/index.js.map +1 -0
- package/dist/insert.d.ts +21 -0
- package/dist/insert.d.ts.map +1 -0
- package/dist/insert.js +129 -0
- package/dist/insert.js.map +1 -0
- package/dist/menu-action.d.ts +73 -0
- package/dist/menu-action.d.ts.map +1 -0
- package/dist/menu-action.js +89 -0
- package/dist/menu-action.js.map +1 -0
- package/dist/mode.d.ts +21 -0
- package/dist/mode.d.ts.map +1 -0
- package/dist/mode.js +17 -0
- package/dist/mode.js.map +1 -0
- package/dist/new-slide.d.ts +21 -0
- package/dist/new-slide.d.ts.map +1 -0
- package/dist/new-slide.js +63 -0
- package/dist/new-slide.js.map +1 -0
- package/dist/page-controls.d.ts +20 -0
- package/dist/page-controls.d.ts.map +1 -0
- package/dist/page-controls.js +99 -0
- package/dist/page-controls.js.map +1 -0
- package/dist/paint.d.ts +52 -0
- package/dist/paint.d.ts.map +1 -0
- package/dist/paint.js +262 -0
- package/dist/paint.js.map +1 -0
- package/dist/ruler.d.ts +10 -0
- package/dist/ruler.d.ts.map +1 -0
- package/dist/ruler.js +97 -0
- package/dist/ruler.js.map +1 -0
- package/dist/state.d.ts +85 -0
- package/dist/state.d.ts.map +1 -0
- package/dist/state.js +28 -0
- package/dist/state.js.map +1 -0
- package/dist/styles.d.ts +2 -0
- package/dist/styles.d.ts.map +1 -0
- package/dist/styles.js +758 -0
- package/dist/styles.js.map +1 -0
- package/dist/tabs.d.ts +11 -0
- package/dist/tabs.d.ts.map +1 -0
- package/dist/tabs.js +153 -0
- package/dist/tabs.js.map +1 -0
- package/dist/text-format.d.ts +114 -0
- package/dist/text-format.d.ts.map +1 -0
- package/dist/text-format.js +315 -0
- package/dist/text-format.js.map +1 -0
- package/dist/tools.d.ts +35 -0
- package/dist/tools.d.ts.map +1 -0
- package/dist/tools.js +41 -0
- package/dist/tools.js.map +1 -0
- package/dist/version.d.ts +2 -0
- package/dist/version.d.ts.map +1 -0
- package/dist/version.js +7 -0
- package/dist/version.js.map +1 -0
- package/dist/worker/handlers.d.ts +11 -0
- package/dist/worker/handlers.d.ts.map +1 -0
- package/dist/worker/handlers.js +127 -0
- package/dist/worker/handlers.js.map +1 -0
- package/dist/worker/protocol.d.ts +190 -0
- package/dist/worker/protocol.d.ts.map +1 -0
- package/dist/worker/protocol.js +2 -0
- package/dist/worker/protocol.js.map +1 -0
- package/dist/worker/worker-source.d.ts +3 -0
- package/dist/worker/worker-source.d.ts.map +1 -0
- package/dist/worker/worker-source.js +11 -0
- package/dist/worker/worker.d.ts +2 -0
- package/dist/worker/worker.d.ts.map +1 -0
- package/dist/worker/worker.js +6 -0
- package/dist/worker/worker.js.map +1 -0
- package/package.json +68 -5
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"paint.d.ts","sourceRoot":"","sources":["../src/paint.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAGR,UAAU,EAEV,SAAS,EAKZ,MAAM,sBAAsB,CAAC;AAU9B,OAAO,KAAK,EACR,QAAQ,EACR,YAAY,EAEZ,SAAS,EAET,aAAa,EACb,gBAAgB,EAChB,WAAW,EAGX,WAAW,EACd,MAAM,6BAA6B,CAAC;AAErC,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,YAAY,CAAC;AAQ5C;;;wEAGwE;AACxE,wBAAgB,mBAAmB,CAAC,KAAK,EAAE,SAAS,GAAG,UAAU,GAAG,IAAI,CAcvE;AAED;gDACgD;AAChD,wBAAgB,kBAAkB,CAAC,KAAK,EAAE,SAAS,GAAG,SAAS,CAG9D;AAkFD;;+DAE+D;AAC/D,MAAM,WAAW,UAAU;IACvB,KAAK,EAAE,SAAS,CAAC;IACjB,+BAA+B;IAC/B,MAAM,EAAE,MAAM,CAAC;IACf,IAAI,EAAE,QAAQ,CAAC;CAClB;AAED,yEAAyE;AACzE,wBAAgB,gBAAgB,CAAC,IAAI,EAAE,WAAW;2BAShB,SAAS,KAAG,OAAO,CAAC,IAAI,CAAC;8BAgBtB,UAAU,KAAG,OAAO,CAAC,IAAI,CAAC;EAgB9D;AAED,4DAA4D;AAC5D,MAAM,MAAM,UAAU,GAAG,UAAU,CAAC,OAAO,gBAAgB,CAAC,CAAC;AAiB7D;;;;;GAKG;AACH,MAAM,WAAW,WAAW;IACxB,QAAQ,CAAC,SAAS,EAAE,MAAM,CAAC,YAAY,EAAE,SAAS,CAAC,CAAC;IACpD,QAAQ,CAAC,UAAU,EAAE,WAAW,CAAC;CACpC;AAED,6CAA6C;AAC7C,wBAAgB,iBAAiB,IAAI,WAAW,CAU/C;AAED;;;;;;GAMG;AACH,wBAAgB,YAAY,CACxB,GAAG,EAAE,gBAAgB,EACrB,OAAO,EAAE;IAAE,EAAE,EAAE,MAAM,CAAC;IAAC,IAAI,EAAE,MAAM,CAAC;IAAC,OAAO,EAAE,YAAY,CAAA;CAAE,EAC5D,KAAK,EAAE,SAAS,GACjB,aAAa,CA4Ff"}
|
package/dist/paint.js
ADDED
|
@@ -0,0 +1,262 @@
|
|
|
1
|
+
import { applyPaintBar, buildPaintPanel, createDropdownButton, DEFAULT_OFFICE_THEME, displayToActivePaint, paintSwatch, themeSwatches, } from "@docmentis/udoc-ui/internal";
|
|
2
|
+
import { editState } from "./state.js";
|
|
3
|
+
/** Split an `#rrggbb` hex into its three bytes (`0..255`). */
|
|
4
|
+
function hexToRgbBytes(hex) {
|
|
5
|
+
const n = parseInt(hex.replace("#", ""), 16);
|
|
6
|
+
return [(n >> 16) & 0xff, (n >> 8) & 0xff, n & 0xff];
|
|
7
|
+
}
|
|
8
|
+
/** A picker paint as a `PaintColor`, or `null` for "no fill": a solid sRGB
|
|
9
|
+
* color, or a theme pick kept as a `schemeClr` reference with its tint/shade
|
|
10
|
+
* transforms so it re-themes. The shared color construction behind
|
|
11
|
+
* {@link paintToDrawingFill} and the text highlight (a bare color). */
|
|
12
|
+
export function paintToDrawingColor(paint) {
|
|
13
|
+
switch (paint.kind) {
|
|
14
|
+
case "none":
|
|
15
|
+
return null;
|
|
16
|
+
case "solid": {
|
|
17
|
+
const [r, g, b] = hexToRgbBytes(paint.hex);
|
|
18
|
+
return { base: { sRgb: { r, g, b } }, transforms: [] };
|
|
19
|
+
}
|
|
20
|
+
case "theme":
|
|
21
|
+
return {
|
|
22
|
+
base: { scheme: schemeSlot(paint.slot) },
|
|
23
|
+
transforms: paint.transforms.map(toDrawingTransform),
|
|
24
|
+
};
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
/** A picker paint as a `PaintFill`: a solid / theme color wrapped as a solid
|
|
28
|
+
* fill, or explicit `"none"` for "no fill". */
|
|
29
|
+
export function paintToDrawingFill(paint) {
|
|
30
|
+
const color = paintToDrawingColor(paint);
|
|
31
|
+
return color ? { solid: color } : "none";
|
|
32
|
+
}
|
|
33
|
+
function toDrawingTransform(t) {
|
|
34
|
+
return t.kind === "tint" ? { tint: t.value } : { shade: t.value };
|
|
35
|
+
}
|
|
36
|
+
/** Map a `schemeClr` slot token to the `PaintSchemeColor` wire name. */
|
|
37
|
+
const SCHEME_TOKEN = {
|
|
38
|
+
tx1: "text1",
|
|
39
|
+
bg1: "background1",
|
|
40
|
+
tx2: "text2",
|
|
41
|
+
bg2: "background2",
|
|
42
|
+
accent1: "accent1",
|
|
43
|
+
accent2: "accent2",
|
|
44
|
+
accent3: "accent3",
|
|
45
|
+
accent4: "accent4",
|
|
46
|
+
accent5: "accent5",
|
|
47
|
+
accent6: "accent6",
|
|
48
|
+
};
|
|
49
|
+
function schemeSlot(slot) {
|
|
50
|
+
return SCHEME_TOKEN[slot] ?? "text1";
|
|
51
|
+
}
|
|
52
|
+
/** A composed stroke as a `DrawingML` `Line`: its paint plus weight (points) and
|
|
53
|
+
* a preset dash. */
|
|
54
|
+
function paintToDrawingLine(stroke) {
|
|
55
|
+
return {
|
|
56
|
+
width: stroke.weight,
|
|
57
|
+
cap: null,
|
|
58
|
+
compound: null,
|
|
59
|
+
align: null,
|
|
60
|
+
fill: paintToDrawingFill(stroke.paint),
|
|
61
|
+
dash: dashToDrawing(stroke.dash),
|
|
62
|
+
join: null,
|
|
63
|
+
headEnd: null,
|
|
64
|
+
tailEnd: null,
|
|
65
|
+
};
|
|
66
|
+
}
|
|
67
|
+
function dashToDrawing(dash) {
|
|
68
|
+
switch (dash) {
|
|
69
|
+
case "solid":
|
|
70
|
+
return { preset: "solid" };
|
|
71
|
+
case "dash":
|
|
72
|
+
return { preset: "dash" };
|
|
73
|
+
case "dot":
|
|
74
|
+
return { preset: "dot" };
|
|
75
|
+
case "dashDot":
|
|
76
|
+
return { preset: "dashDot" };
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
function paintToBrush(paint) {
|
|
80
|
+
if (paint.kind === "none")
|
|
81
|
+
return null;
|
|
82
|
+
const [r, g, b] = hexToRgbBytes(paint.hex);
|
|
83
|
+
return { solid: { colorSpace: "deviceRgb", components: [r / 255, g / 255, b / 255] } };
|
|
84
|
+
}
|
|
85
|
+
/** A PDF stroking line: the weight (points) and a dash array derived from the
|
|
86
|
+
* preset, scaled by the width so it reads consistently at any weight. */
|
|
87
|
+
function portableStrokeLine(weight, dash) {
|
|
88
|
+
const line = {
|
|
89
|
+
width: weight,
|
|
90
|
+
lineCap: dash === "dot" || dash === "dashDot" ? "round" : "butt",
|
|
91
|
+
lineJoin: "miter",
|
|
92
|
+
miterLimit: 10,
|
|
93
|
+
dashArray: null,
|
|
94
|
+
dashOffset: 0,
|
|
95
|
+
};
|
|
96
|
+
const w = weight || 1;
|
|
97
|
+
const array = dash === "dash"
|
|
98
|
+
? [3 * w, 3 * w]
|
|
99
|
+
: dash === "dot"
|
|
100
|
+
? [w, 2 * w]
|
|
101
|
+
: dash === "dashDot"
|
|
102
|
+
? [3 * w, 2 * w, w, 2 * w]
|
|
103
|
+
: null;
|
|
104
|
+
if (array)
|
|
105
|
+
line.dashArray = array;
|
|
106
|
+
return line;
|
|
107
|
+
}
|
|
108
|
+
/** The Fill / Line edits of the selection, on the shell `host` lends. */
|
|
109
|
+
export function createPaintEdits(host) {
|
|
110
|
+
const { store, client, commit } = host;
|
|
111
|
+
// Fill / Line — the picker's paint applied to the current selection. The
|
|
112
|
+
// payload is the open doc type's own model style, built here (the host builds
|
|
113
|
+
// model JSON, like `insertObject`), then sent through the same `executeOnSelection`
|
|
114
|
+
// seam; the doc-type binder replaces the shape's fill / line or the path's
|
|
115
|
+
// non-stroking / stroking style. "No Fill" on a PDF path (not expressible as a
|
|
116
|
+
// device style) is skipped.
|
|
117
|
+
function fillSelection(paint) {
|
|
118
|
+
if (store.getState().docType === "presentation") {
|
|
119
|
+
return commit(() => client.executeOnSelection({ kind: "setShapeFill", fill: paintToDrawingFill(paint) }));
|
|
120
|
+
}
|
|
121
|
+
const brush = paintToBrush(paint);
|
|
122
|
+
if (!brush)
|
|
123
|
+
return Promise.resolve();
|
|
124
|
+
return commit(() => client.executeOnSelection({
|
|
125
|
+
kind: "object",
|
|
126
|
+
edit: { kind: "setNonstrokingStyle", style: { brush, alpha: 1, overprint: false } },
|
|
127
|
+
}));
|
|
128
|
+
}
|
|
129
|
+
// The whole composed stroke (color + weight + dash), since the engine sets the
|
|
130
|
+
// outline as one value.
|
|
131
|
+
function strokeSelection(stroke) {
|
|
132
|
+
if (store.getState().docType === "presentation") {
|
|
133
|
+
return commit(() => client.executeOnSelection({ kind: "setShapeLine", line: paintToDrawingLine(stroke) }));
|
|
134
|
+
}
|
|
135
|
+
const brush = paintToBrush(stroke.paint);
|
|
136
|
+
if (!brush)
|
|
137
|
+
return Promise.resolve();
|
|
138
|
+
const line = portableStrokeLine(stroke.weight, stroke.dash);
|
|
139
|
+
return commit(() => client.executeOnSelection({
|
|
140
|
+
kind: "object",
|
|
141
|
+
edit: { kind: "setStrokingStyle", style: { brush, alpha: 1, overprint: false, line } },
|
|
142
|
+
}));
|
|
143
|
+
}
|
|
144
|
+
return { fillSelection, strokeSelection };
|
|
145
|
+
}
|
|
146
|
+
/**
|
|
147
|
+
* The doc types whose color pickers show the "Theme Colors" block above the
|
|
148
|
+
* standard swatches: the OOXML office types, whose color model is
|
|
149
|
+
* theme-relative (a `schemeClr` re-themes) — not PDF or images (device colors
|
|
150
|
+
* only). The block shows the document's resolved palette (from the engine's
|
|
151
|
+
* `themePalette()`) when it has landed, the stand-in Office palette until then.
|
|
152
|
+
*/
|
|
153
|
+
const THEMED = new Set(["presentation", "spreadsheet", "wordprocessing"]);
|
|
154
|
+
/** The picker's Theme Colors row: the current slide's resolved palette mapped
|
|
155
|
+
* to swatches, or the stand-in when the engine reported no theme. */
|
|
156
|
+
function mapThemeColors(palette) {
|
|
157
|
+
return palette ? themeSwatches(palette) : DEFAULT_OFFICE_THEME;
|
|
158
|
+
}
|
|
159
|
+
/** A {@link PaintMemory} at its defaults. */
|
|
160
|
+
export function createPaintMemory() {
|
|
161
|
+
return {
|
|
162
|
+
lastPaint: {
|
|
163
|
+
fill: { kind: "solid", hex: "#4472c4" },
|
|
164
|
+
stroke: { kind: "solid", hex: "#000000" },
|
|
165
|
+
text: { kind: "solid", hex: "#000000" },
|
|
166
|
+
highlight: { kind: "solid", hex: "#ffff00" },
|
|
167
|
+
},
|
|
168
|
+
lastStroke: { weight: 1, dash: "solid" },
|
|
169
|
+
};
|
|
170
|
+
}
|
|
171
|
+
/**
|
|
172
|
+
* A Fill / Line / Text Color dropdown of `channel`, for command `id` drawn with
|
|
173
|
+
* `icon`: the channel glyph over a color bar reflecting the *selection's* color,
|
|
174
|
+
* the caret opening the color panel (rebuilt on each open). A mirror — clicking
|
|
175
|
+
* always opens the picker (no last-color re-apply); each render keeps the
|
|
176
|
+
* swatch in sync with the selection.
|
|
177
|
+
*/
|
|
178
|
+
export function paintControl(env, command, tools) {
|
|
179
|
+
const { i18n, paintMemory: memory } = tools;
|
|
180
|
+
const { channel } = command;
|
|
181
|
+
const selectionPaint = () => editState(env.store.getState()).selectionPaint;
|
|
182
|
+
// Apply the current stroke (color + weight + dash) to the selection — the
|
|
183
|
+
// whole composed value, since the engine sets the outline as one thing;
|
|
184
|
+
// the color rides from the last pick.
|
|
185
|
+
const applyStroke = () => void tools.paint.strokeSelection({
|
|
186
|
+
paint: memory.lastPaint.stroke,
|
|
187
|
+
weight: memory.lastStroke.weight,
|
|
188
|
+
dash: memory.lastStroke.dash,
|
|
189
|
+
});
|
|
190
|
+
// Apply a picked paint: fill / text / highlight send the color; stroke
|
|
191
|
+
// sends the composed stroke (its last-used weight / dash ride along).
|
|
192
|
+
const applyPaint = (paint) => {
|
|
193
|
+
if (channel === "fill")
|
|
194
|
+
void tools.paint.fillSelection(paint);
|
|
195
|
+
else if (channel === "text")
|
|
196
|
+
void tools.text.textFillSelection(paint);
|
|
197
|
+
else if (channel === "highlight")
|
|
198
|
+
void tools.text.textHighlightSelection(paint);
|
|
199
|
+
else
|
|
200
|
+
applyStroke();
|
|
201
|
+
};
|
|
202
|
+
// Commit a picked paint: remember it (for the composed stroke re-send and
|
|
203
|
+
// the recent row) and apply it. The trigger swatch isn't touched here — it
|
|
204
|
+
// mirrors the selection, so it updates when the resulting report lands.
|
|
205
|
+
const commitPaint = (paint) => {
|
|
206
|
+
memory.lastPaint[channel] = paint;
|
|
207
|
+
if (paint.kind !== "none")
|
|
208
|
+
env.pushRecent(channel, paint.hex);
|
|
209
|
+
applyPaint(paint);
|
|
210
|
+
};
|
|
211
|
+
// The color panel — doc-type aware (Office shows the theme block, PDF
|
|
212
|
+
// standard colors only). Rebuilt on each open so recent / active reflect
|
|
213
|
+
// current state. `close` is the dropdown's.
|
|
214
|
+
const panelConfig = (close) => {
|
|
215
|
+
const state = env.store.getState();
|
|
216
|
+
return {
|
|
217
|
+
i18n,
|
|
218
|
+
variant: channel,
|
|
219
|
+
// Office docs ({@link THEMED}) show the Theme Colors
|
|
220
|
+
// block — the document's resolved palette when the engine reported
|
|
221
|
+
// one, else the stand-in; PDF passes `null` for standard colors only.
|
|
222
|
+
theme: state.docType !== null && THEMED.has(state.docType)
|
|
223
|
+
? mapThemeColors(editState(state).themePalette)
|
|
224
|
+
: null,
|
|
225
|
+
recent: env.recentPaint[channel],
|
|
226
|
+
// Ring the *selection's* color as active (the design's true
|
|
227
|
+
// "active"): a solid color or explicit no-fill; nothing for mixed /
|
|
228
|
+
// unknown.
|
|
229
|
+
active: displayToActivePaint(selectionPaint()[channel]),
|
|
230
|
+
stroke: channel === "stroke" ? memory.lastStroke : null,
|
|
231
|
+
onPick: (paint) => {
|
|
232
|
+
commitPaint(paint);
|
|
233
|
+
close();
|
|
234
|
+
},
|
|
235
|
+
onWeight: (pt) => {
|
|
236
|
+
memory.lastStroke.weight = pt;
|
|
237
|
+
applyStroke();
|
|
238
|
+
close();
|
|
239
|
+
},
|
|
240
|
+
onDash: (dash) => {
|
|
241
|
+
memory.lastStroke.dash = dash;
|
|
242
|
+
applyStroke();
|
|
243
|
+
close();
|
|
244
|
+
},
|
|
245
|
+
// No `onMoreOptions`: the More Options row waits for the advanced
|
|
246
|
+
// dialog to hold the richer fill / line surface.
|
|
247
|
+
};
|
|
248
|
+
};
|
|
249
|
+
const dd = createDropdownButton({ icon: paintSwatch(command.icon, selectionPaint()[channel]), label: env.label }, {
|
|
250
|
+
menuLabel: i18n.t("ribbon.paintOptions", { label: env.label }),
|
|
251
|
+
onOpen: () => buildPaintPanel(dd.menu, panelConfig(() => dd.controller.close())),
|
|
252
|
+
});
|
|
253
|
+
dd.trigger.dataset.command = command.id;
|
|
254
|
+
return {
|
|
255
|
+
el: dd.el,
|
|
256
|
+
// The swatch mirrors the selection.
|
|
257
|
+
sync: (state) => applyPaintBar(dd.trigger, editState(state).selectionPaint[channel]),
|
|
258
|
+
close: () => dd.controller.close(),
|
|
259
|
+
destroy: () => dd.destroy(),
|
|
260
|
+
};
|
|
261
|
+
}
|
|
262
|
+
//# sourceMappingURL=paint.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"paint.js","sourceRoot":"","sources":["../src/paint.ts"],"names":[],"mappings":"AAcA,OAAO,EAC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|
+
import type { Action, GuideBand, Store, UIState } from "@docmentis/udoc-ui/internal";
|
|
2
|
+
/** The ruler band. Paints only a ruler projection; any other leaves the strips
|
|
3
|
+
* cleared to their band background until one lands. */
|
|
4
|
+
export declare const RULER: GuideBand;
|
|
5
|
+
/** Whether the ruler shows in `state`: a ruled doc type in edit mode, with the
|
|
6
|
+
* preference on. */
|
|
7
|
+
export declare function rulerShown(state: UIState): boolean;
|
|
8
|
+
/** Show or hide the ruler in `store` — a user preference, kept across documents. */
|
|
9
|
+
export declare function setShowRuler(store: Store<UIState, Action>, visible: boolean): void;
|
|
10
|
+
//# sourceMappingURL=ruler.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ruler.d.ts","sourceRoot":"","sources":["../src/ruler.ts"],"names":[],"mappings":"AAKA,OAAO,KAAK,EAAE,MAAM,EAAc,SAAS,EAAE,KAAK,EAAE,OAAO,EAAE,MAAM,6BAA6B,CAAC;AAyFjG;wDACwD;AACxD,eAAO,MAAM,KAAK,EAAE,SAKnB,CAAC;AAEF;qBACqB;AACrB,wBAAgB,UAAU,CAAC,KAAK,EAAE,OAAO,GAAG,OAAO,CAElD;AAED,oFAAoF;AACpF,wBAAgB,YAAY,CAAC,KAAK,EAAE,KAAK,CAAC,OAAO,EAAE,MAAM,CAAC,EAAE,OAAO,EAAE,OAAO,GAAG,IAAI,CAElF"}
|
package/dist/ruler.js
ADDED
|
@@ -0,0 +1,97 @@
|
|
|
1
|
+
import { editState, updateEditState } from "./state.js";
|
|
2
|
+
/** The doc types the engine measures with a ruler: the paged ones. */
|
|
3
|
+
const RULED = new Set(["portable", "presentation", "wordprocessing"]);
|
|
4
|
+
/** A screen-fixed UI font for the labels — not the document's fonts. */
|
|
5
|
+
const UI_FONT = `-apple-system, BlinkMacSystemFont, "Segoe UI", system-ui, sans-serif`;
|
|
6
|
+
function stroke(ctx, color, x0, y0, x1, y1) {
|
|
7
|
+
ctx.strokeStyle = color;
|
|
8
|
+
ctx.lineWidth = 1;
|
|
9
|
+
ctx.beginPath();
|
|
10
|
+
ctx.moveTo(x0, y0);
|
|
11
|
+
ctx.lineTo(x1, y1);
|
|
12
|
+
ctx.stroke();
|
|
13
|
+
}
|
|
14
|
+
function drawAxis(canvas, ctx, axis, thickness, orient) {
|
|
15
|
+
const { colors } = canvas;
|
|
16
|
+
const size = Math.min(11, Math.max(8, thickness * 0.5));
|
|
17
|
+
ctx.font = `${size}px ${UI_FONT}`;
|
|
18
|
+
const majorLen = thickness * 0.3;
|
|
19
|
+
const minorLen = thickness * 0.16;
|
|
20
|
+
const figCenter = (thickness - majorLen) / 2;
|
|
21
|
+
// Shift the horizontal ruler's marks (along x) to ride the content canvas
|
|
22
|
+
// mid-resize; the vertical ruler tracks height, which isn't shifted. See
|
|
23
|
+
// `GuideBands.setContentShift`. `0` when settled.
|
|
24
|
+
ctx.save();
|
|
25
|
+
if (orient === "h")
|
|
26
|
+
ctx.translate(canvas.shiftX, 0);
|
|
27
|
+
for (const m of axis.marks) {
|
|
28
|
+
const len = m.major ? majorLen : minorLen;
|
|
29
|
+
const p = m.position;
|
|
30
|
+
// Ticks hang from the inner (content) edge toward the outer, on the
|
|
31
|
+
// soft `grid` they share with the ruler edge and the header separators.
|
|
32
|
+
if (orient === "h")
|
|
33
|
+
stroke(ctx, colors.grid, p, thickness, p, thickness - len);
|
|
34
|
+
else
|
|
35
|
+
stroke(ctx, colors.grid, thickness, p, thickness - len, p);
|
|
36
|
+
if (m.label != null) {
|
|
37
|
+
ctx.fillStyle = colors.text;
|
|
38
|
+
if (orient === "h")
|
|
39
|
+
ctx.fillText(m.label, m.position, figCenter);
|
|
40
|
+
else
|
|
41
|
+
ctx.fillText(m.label, figCenter, m.position);
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
ctx.restore();
|
|
45
|
+
}
|
|
46
|
+
/**
|
|
47
|
+
* Fill the ruler's corner box and mark only the junction dot — the single
|
|
48
|
+
* pixel both the top ruler's bottom edge and the left ruler's right edge pass
|
|
49
|
+
* through, which each stops just short of, leaving the corner open. Unlike the
|
|
50
|
+
* header the ruler frames only its content-facing edge and has no grid to
|
|
51
|
+
* continue, so the corner takes the meeting point alone rather than edges drawn
|
|
52
|
+
* across the box.
|
|
53
|
+
*/
|
|
54
|
+
function drawCorner(canvas) {
|
|
55
|
+
const corner = canvas.prepare("corner");
|
|
56
|
+
if (!corner)
|
|
57
|
+
return;
|
|
58
|
+
const { ctx, w, h } = corner;
|
|
59
|
+
ctx.fillStyle = canvas.colors.grid;
|
|
60
|
+
ctx.fillRect(w - 1, h - 1, 1, 1);
|
|
61
|
+
}
|
|
62
|
+
function drawRuler(guide, canvas) {
|
|
63
|
+
const { colors } = canvas;
|
|
64
|
+
const top = canvas.prepare("top");
|
|
65
|
+
if (top && guide.horizontal) {
|
|
66
|
+
drawAxis(canvas, top.ctx, guide.horizontal, top.h, "h");
|
|
67
|
+
// The ruler's inner (content-facing) edge line — a baseline the ticks
|
|
68
|
+
// hang from, framing the ruler off the page below (mirrors the header
|
|
69
|
+
// band's bottom border). The same soft `grid` as the ticks.
|
|
70
|
+
stroke(top.ctx, colors.grid, 0, top.h - 0.5, top.w, top.h - 0.5);
|
|
71
|
+
}
|
|
72
|
+
const left = canvas.prepare("left");
|
|
73
|
+
if (left && guide.vertical) {
|
|
74
|
+
drawAxis(canvas, left.ctx, guide.vertical, left.w, "v");
|
|
75
|
+
stroke(left.ctx, colors.grid, left.w - 0.5, 0, left.w - 0.5, left.h);
|
|
76
|
+
}
|
|
77
|
+
drawCorner(canvas);
|
|
78
|
+
}
|
|
79
|
+
/** The ruler band. Paints only a ruler projection; any other leaves the strips
|
|
80
|
+
* cleared to their band background until one lands. */
|
|
81
|
+
export const RULER = {
|
|
82
|
+
thickness: 22,
|
|
83
|
+
draw(guide, canvas) {
|
|
84
|
+
if (guide.type === "ruler")
|
|
85
|
+
drawRuler(guide, canvas);
|
|
86
|
+
},
|
|
87
|
+
};
|
|
88
|
+
/** Whether the ruler shows in `state`: a ruled doc type in edit mode, with the
|
|
89
|
+
* preference on. */
|
|
90
|
+
export function rulerShown(state) {
|
|
91
|
+
return editState(state).showRuler && state.mode === "edit" && state.docType !== null && RULED.has(state.docType);
|
|
92
|
+
}
|
|
93
|
+
/** Show or hide the ruler in `store` — a user preference, kept across documents. */
|
|
94
|
+
export function setShowRuler(store, visible) {
|
|
95
|
+
updateEditState(store, { showRuler: visible });
|
|
96
|
+
}
|
|
97
|
+
//# sourceMappingURL=ruler.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ruler.js","sourceRoot":"","sources":["../src/ruler.ts"],"names":[],"mappings":"AAMA,OAAO,EAAE,SAAS,EAAE,eAAe,EAAE,MAAM,YAAY,CAAC;AAKxD,sEAAsE;AACtE,MAAM,KAAK,GAA0B,IAAI,GAAG,CAAW,CAAC,UAAU,EAAE,cAAc,EAAE,gBAAgB,CAAC,CAAC,CAAC;AAEvG,wEAAwE;AACxE,MAAM,OAAO,GAAG,sEAAsE,CAAC;AAEvF,SAAS,MAAM,CAAC,GAA6B,EAAE,KAAa,EAAE,EAAU,EAAE,EAAU,EAAE,EAAU,EAAE,EAAU;IACxG,GAAG,CAAC,WAAW,GAAG,KAAK,CAAC;IACxB,GAAG,CAAC,SAAS,GAAG,CAAC,CAAC;IAClB,GAAG,CAAC,SAAS,EAAE,CAAC;IAChB,GAAG,CAAC,MAAM,CAAC,EAAE,EAAE,EAAE,CAAC,CAAC;IACnB,GAAG,CAAC,MAAM,CAAC,EAAE,EAAE,EAAE,CAAC,CAAC;IACnB,GAAG,CAAC,MAAM,EAAE,CAAC;AACjB,CAAC;AAED,SAAS,QAAQ,CACb,MAAkB,EAClB,GAA6B,EAC7B,IAAe,EACf,SAAiB,EACjB,MAAiB;IAEjB,MAAM,EAAE,MAAM,EAAE,GAAG,MAAM,CAAC;IAC1B,MAAM,IAAI,GAAG,IAAI,CAAC,GAAG,CAAC,EAAE,EAAE,IAAI,CAAC,GAAG,C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,IAAI,KAAK,CAAC,QAAQ,EAAE,CAAC;QACzB,QAAQ,CAAC,MAAM,EAAE,IAAI,CAAC,GAAG,EAAE,KAAK,CAAC,QAAQ,EAAE,IAAI,CAAC,CAAC,EAAE,GAAG,CAAC,CAAC;QACxD,MAAM,CAAC,IAAI,CAAC,GAAG,EAAE,MAAM,CAAC,IAAI,EAAE,IAAI,CAAC,CAAC,GAAG,GAAG,EAAE,CAAC,EAAE,IAAI,CAAC,CAAC,GAAG,GAAG,EAAE,IAAI,CAAC,CAAC,CAAC,CAAC;IACzE,CAAC;IACD,UAAU,CAAC,MAAM,CAAC,CAAC;AACvB,CAAC;AAED;wDACwD;AACxD,MAAM,CAAC,MAAM,KAAK,GAAc;IAC5B,SAAS,EAAE,EAAE;IACb,IAAI,CAAC,KAAK,EAAE,MAAM;QACd,IAAI,KAAK,CAAC,IAAI,KAAK,OAAO;YAAE,SAAS,CAAC,KAAK,EAAE,MAAM,CAAC,CAAC;IACzD,CAAC;CACJ,CAAC;AAEF;qBACqB;AACrB,MAAM,UAAU,UAAU,CAAC,KAAc;IACrC,OAAO,SAAS,CAAC,KAAK,CAAC,CAAC,SAAS,IAAI,KAAK,CAAC,IAAI,KAAK,MAAM,IAAI,KAAK,CAAC,OAAO,KAAK,IAAI,IAAI,KAAK,CAAC,GAAG,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC;AACrH,CAAC;AAED,oFAAoF;AACpF,MAAM,UAAU,YAAY,CAAC,KAA6B,EAAE,OAAgB;IACxE,eAAe,CAAC,KAAK,EAAE,EAAE,SAAS,EAAE,OAAO,EAAE,CAAC,CAAC;AACnD,CAAC"}
|
package/dist/state.d.ts
ADDED
|
@@ -0,0 +1,85 @@
|
|
|
1
|
+
import type { FontFamilySummary } from "@docmentis/udoc-wasm";
|
|
2
|
+
import type { Action, CommandContext, SelectionPaint, SelectionTextFormat, Store, ThemePalette, UIState } from "@docmentis/udoc-ui/internal";
|
|
3
|
+
import type { EditorMode } from "./mode.js";
|
|
4
|
+
export interface EditState {
|
|
5
|
+
/**
|
|
6
|
+
* Whether formatting marks (`¶`, a dot per space, a tab's arrow, `↵`) are
|
|
7
|
+
* drawn over the text — the ribbon's Show Formatting Marks toggle. A user
|
|
8
|
+
* preference, off by default; the marks are editing chrome, so what reaches
|
|
9
|
+
* the engine is `showFormattingMarks` in edit mode on a wordprocessing
|
|
10
|
+
* document.
|
|
11
|
+
*/
|
|
12
|
+
showFormattingMarks: boolean;
|
|
13
|
+
/**
|
|
14
|
+
* Whether the page ruler is shown (paged doc types — PDF / DOCX / PPTX). A
|
|
15
|
+
* user preference the host toggles; the ruler is additionally suppressed in
|
|
16
|
+
* `view` mode (a reading pose needs no measurement chrome). A spreadsheet's
|
|
17
|
+
* row/column headers are essential and never gated by this.
|
|
18
|
+
*/
|
|
19
|
+
showRuler: boolean;
|
|
20
|
+
/**
|
|
21
|
+
* The current slide's resolved theme color palette (the picker's "Theme
|
|
22
|
+
* Colors"), or null with no document open or for doc types without a theme
|
|
23
|
+
* (only presentations carry one). Pulled on open and on slide change; the
|
|
24
|
+
* color dropdowns map it to swatches for the picker.
|
|
25
|
+
*/
|
|
26
|
+
themePalette: ThemePalette | null;
|
|
27
|
+
/**
|
|
28
|
+
* Every available font family, sorted by name — the Text tab's font picker
|
|
29
|
+
* list. Each carries its name and its `sourceType`, which is what a picker
|
|
30
|
+
* showing specimens needs: the browser can draw a `Local` / `Url` /
|
|
31
|
+
* `Google` family in its own face, and the rest have no bytes outside wasm.
|
|
32
|
+
* Not the faces — nothing here reads them, and at ~1800 families they are
|
|
33
|
+
* three quarters of what would cross.
|
|
34
|
+
*
|
|
35
|
+
* Stable across the session (only opening a document changes it), so it's
|
|
36
|
+
* pulled **once** on open and cached. Empty with no document open or for a
|
|
37
|
+
* doc type with no text font registry (PDF/image).
|
|
38
|
+
*/
|
|
39
|
+
fontFamilies: readonly FontFamilySummary[];
|
|
40
|
+
/**
|
|
41
|
+
* The subset of {@link fontFamilies} that is loaded — parsed and in hand —
|
|
42
|
+
* which the picker lists first, above a divider.
|
|
43
|
+
*
|
|
44
|
+
* Re-pulled whenever the picker opens rather than cached with the full list:
|
|
45
|
+
* fonts materialize lazily, so this grows through the session as the
|
|
46
|
+
* document composes and as fonts are picked, while the full list stays put.
|
|
47
|
+
*/
|
|
48
|
+
loadedFontFamilyNames: readonly string[];
|
|
49
|
+
/**
|
|
50
|
+
* The current selection's resolved character format (font / bold / italic)
|
|
51
|
+
* — the Text tab mirrors it. Pushed from the worker's selection reports,
|
|
52
|
+
* projected from the engine's selection properties; never derived here.
|
|
53
|
+
* `EMPTY_SELECTION_TEXT_FORMAT` with no document open, a non-text
|
|
54
|
+
* selection, or none.
|
|
55
|
+
*/
|
|
56
|
+
selectionText: SelectionTextFormat;
|
|
57
|
+
/**
|
|
58
|
+
* The current selection's resolved color per channel (fill / stroke / text)
|
|
59
|
+
* — the Fill / Line / Text Color dropdowns swatch it. Pushed from the
|
|
60
|
+
* worker's selection reports, projected from the engine's selection
|
|
61
|
+
* properties; never derived here. `EMPTY_SELECTION_PAINT` with no document
|
|
62
|
+
* open, a channel the doc type doesn't surface, or none.
|
|
63
|
+
*/
|
|
64
|
+
selectionPaint: SelectionPaint;
|
|
65
|
+
/** The modes the host lets the user switch between (drives the mode
|
|
66
|
+
* switcher, which offers those the session is entitled to —
|
|
67
|
+
* `modeEntitled`). */
|
|
68
|
+
allowedModes: readonly EditorMode[];
|
|
69
|
+
/** Whether the mode switcher is shown (host override; default
|
|
70
|
+
* `allowedModes.length > 1`). */
|
|
71
|
+
showModeSwitch: boolean;
|
|
72
|
+
/** Whether the Align dropdown aligns to the page/slide instead of the
|
|
73
|
+
* selection's own bounds (the "Align to page" toggle). Sticky across menu
|
|
74
|
+
* opens so the chosen reference persists. */
|
|
75
|
+
alignToPage: boolean;
|
|
76
|
+
}
|
|
77
|
+
/** Edit mode's state at start. */
|
|
78
|
+
export declare const INITIAL_EDIT_STATE: EditState;
|
|
79
|
+
/** Edit mode's state in `state`. */
|
|
80
|
+
export declare function editState(state: UIState): EditState;
|
|
81
|
+
/** Edit mode's state in a command's context — what its predicates read. */
|
|
82
|
+
export declare function editStateOf(context: CommandContext): EditState;
|
|
83
|
+
/** Change edit mode's state in `store` by `change`. */
|
|
84
|
+
export declare function updateEditState(store: Store<UIState, Action>, change: Partial<EditState>): void;
|
|
85
|
+
//# sourceMappingURL=state.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"state.d.ts","sourceRoot":"","sources":["../src/state.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,sBAAsB,CAAC;AAE9D,OAAO,KAAK,EACR,MAAM,EACN,cAAc,EACd,cAAc,EACd,mBAAmB,EACnB,KAAK,EACL,YAAY,EACZ,OAAO,EACV,MAAM,6BAA6B,CAAC;AAErC,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,WAAW,CAAC;AAE5C,MAAM,WAAW,SAAS;IACtB;;;;;;OAMG;IACH,mBAAmB,EAAE,OAAO,CAAC;IAE7B;;;;;OAKG;IACH,SAAS,EAAE,OAAO,CAAC;IAEnB;;;;;OAKG;IACH,YAAY,EAAE,YAAY,GAAG,IAAI,CAAC;IAElC;;;;;;;;;;;OAWG;IACH,YAAY,EAAE,SAAS,iBAAiB,EAAE,CAAC;IAE3C;;;;;;;OAOG;IACH,qBAAqB,EAAE,SAAS,MAAM,EAAE,CAAC;IAEzC;;;;;;OAMG;IACH,aAAa,EAAE,mBAAmB,CAAC;IAEnC;;;;;;OAMG;IACH,cAAc,EAAE,cAAc,CAAC;IAE/B;;2BAEuB;IACvB,YAAY,EAAE,SAAS,UAAU,EAAE,CAAC;IAEpC;sCACkC;IAClC,cAAc,EAAE,OAAO,CAAC;IAExB;;kDAE8C;IAC9C,WAAW,EAAE,OAAO,CAAC;CACxB;AAED,kCAAkC;AAClC,eAAO,MAAM,kBAAkB,EAAE,SAWhC,CAAC;AAEF,oCAAoC;AACpC,wBAAgB,SAAS,CAAC,KAAK,EAAE,OAAO,GAAG,SAAS,CAEnD;AAED,2EAA2E;AAC3E,wBAAgB,WAAW,CAAC,OAAO,EAAE,cAAc,GAAG,SAAS,CAE9D;AAED,uDAAuD;AACvD,wBAAgB,eAAe,CAAC,KAAK,EAAE,KAAK,CAAC,OAAO,EAAE,MAAM,CAAC,EAAE,MAAM,EAAE,OAAO,CAAC,SAAS,CAAC,GAAG,IAAI,CAE/F"}
|
package/dist/state.js
ADDED
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import { EMPTY_SELECTION_PAINT, EMPTY_SELECTION_TEXT_FORMAT } from "@docmentis/udoc-ui/internal";
|
|
2
|
+
import { ALL_MODES } from "./mode.js";
|
|
3
|
+
/** Edit mode's state at start. */
|
|
4
|
+
export const INITIAL_EDIT_STATE = {
|
|
5
|
+
showFormattingMarks: false,
|
|
6
|
+
showRuler: true,
|
|
7
|
+
themePalette: null,
|
|
8
|
+
fontFamilies: [],
|
|
9
|
+
loadedFontFamilyNames: [],
|
|
10
|
+
selectionText: EMPTY_SELECTION_TEXT_FORMAT,
|
|
11
|
+
selectionPaint: EMPTY_SELECTION_PAINT,
|
|
12
|
+
allowedModes: ALL_MODES,
|
|
13
|
+
showModeSwitch: true,
|
|
14
|
+
alignToPage: false,
|
|
15
|
+
};
|
|
16
|
+
/** Edit mode's state in `state`. */
|
|
17
|
+
export function editState(state) {
|
|
18
|
+
return state.extension;
|
|
19
|
+
}
|
|
20
|
+
/** Edit mode's state in a command's context — what its predicates read. */
|
|
21
|
+
export function editStateOf(context) {
|
|
22
|
+
return context.extension;
|
|
23
|
+
}
|
|
24
|
+
/** Change edit mode's state in `store` by `change`. */
|
|
25
|
+
export function updateEditState(store, change) {
|
|
26
|
+
store.dispatch({ type: "SET_EXTENSION_STATE", extension: { ...editState(store.getState()), ...change } });
|
|
27
|
+
}
|
|
28
|
+
//# sourceMappingURL=state.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"state.js","sourceRoot":"","sources":["../src/state.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,qBAAqB,EAAE,2BAA2B,EAAE,MAAM,6BAA6B,CAAC;AAUjG,OAAO,EAAE,SAAS,EAAE,MAAM,WAAW,CAAC;AAsFtC,kCAAkC;AAClC,MAAM,CAAC,MAAM,kBAAkB,GAAc;IACzC,mBAAmB,EAAE,KAAK;IAC1B,SAAS,EAAE,IAAI;IACf,YAAY,EAAE,IAAI;IAClB,YAAY,EAAE,EAAE;IAChB,qBAAqB,EAAE,EAAE;IACzB,aAAa,EAAE,2BAA2B;IAC1C,cAAc,EAAE,qBAAqB;IACrC,YAAY,EAAE,SAAS;IACvB,cAAc,EAAE,IAAI;IACpB,WAAW,EAAE,KAAK;CACrB,CAAC;AAEF,oCAAoC;AACpC,MAAM,UAAU,SAAS,CAAC,KAAc;IACpC,OAAO,KAAK,CAAC,SAAsB,CAAC;AACxC,CAAC;AAED,2EAA2E;AAC3E,MAAM,UAAU,WAAW,CAAC,OAAuB;IAC/C,OAAO,OAAO,CAAC,SAAsB,CAAC;AAC1C,CAAC;AAED,uDAAuD;AACvD,MAAM,UAAU,eAAe,CAAC,KAA6B,EAAE,MAA0B;IACrF,KAAK,CAAC,QAAQ,CAAC,EAAE,IAAI,EAAE,qBAAqB,EAAE,SAAS,EAAE,EAAE,GAAG,SAAS,CAAC,KAAK,CAAC,QAAQ,EAAE,CAAC,EAAE,GAAG,MAAM,EAAE,EAAE,CAAC,CAAC;AAC9G,CAAC"}
|
package/dist/styles.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"styles.d.ts","sourceRoot":"","sources":["../src/styles.ts"],"names":[],"mappings":"AAQA,eAAO,MAAM,YAAY,QA6uBxB,CAAC"}
|