@weasel-js/text-tools 1.19.1 → 2.0.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/README.md +8 -8
- package/dist/chunk-VLXWRY3D.js +1179 -0
- package/dist/chunk-VLXWRY3D.js.map +1 -0
- package/dist/index.d.ts +33 -398
- package/dist/index.js +9 -1105
- package/dist/index.js.map +1 -1
- package/dist/presets-oTMEI2UF.d.ts +378 -0
- package/dist/presets.d.ts +9 -0
- package/dist/presets.js +3 -0
- package/dist/presets.js.map +1 -0
- package/package.json +23 -18
|
@@ -0,0 +1,378 @@
|
|
|
1
|
+
import { SceneNode, View, NodePaintCtx, NodeShapeEntry, RectPose, InheritedPaint, Scene, MinSize, InsertNodeFactory, Tool, FeaturePreset, NodeRoutingEntry } from '@weasel-js/core';
|
|
2
|
+
import { DrawCommand } from '@weasel-js/renderer';
|
|
3
|
+
import * as _weasel_js_paint from '@weasel-js/paint';
|
|
4
|
+
import { Fill, Inherit, Stroke, Paint } from '@weasel-js/paint';
|
|
5
|
+
import { Point2, ToolOptionsSpec } from '@weasel-js/routing';
|
|
6
|
+
import { TextStyle, StyledRun, TextVerticalAlign, TextFit, TextPose, TextPaint } from '@weasel-js/text';
|
|
7
|
+
import { Path, Rect } from '@weasel-js/geom';
|
|
8
|
+
import { UseTextEditReturn } from '@weasel-js/text-dom';
|
|
9
|
+
import { InsertToolOptions } from '@weasel-js/editing';
|
|
10
|
+
|
|
11
|
+
/** A scene `drawOne` that leaves out one node's glyphs. */
|
|
12
|
+
type EditingDrawOne = <TNode extends SceneNode<unknown, string, unknown>>(node: TNode, pose: unknown, view?: View, ctx?: NodePaintCtx) => DrawCommand[];
|
|
13
|
+
/** `base`, `defaultDrawOne` by default, less the text commands of the node `editingId` names. */
|
|
14
|
+
declare function drawOneWithoutEditedText(editingId: string | null, base?: EditingDrawOne): EditingDrawOne;
|
|
15
|
+
/** `cmds` with every text command gone, at any depth, and any group left
|
|
16
|
+
* empty by it — a clipped node's glyphs ride in one. What the canvas keeps of
|
|
17
|
+
* a node an editor's overlay stands in for. */
|
|
18
|
+
declare function withoutText(cmds: readonly DrawCommand[]): DrawCommand[];
|
|
19
|
+
|
|
20
|
+
/**
|
|
21
|
+
* What a text node with a `background` draws around its box: an edge in a
|
|
22
|
+
* shade of the background, and a shadow under it. Described once here, and
|
|
23
|
+
* drawn by the canvas painter and written by the SVG export from it.
|
|
24
|
+
*/
|
|
25
|
+
|
|
26
|
+
/** A rule just inside a text node's box, in its background's color mixed toward black. */
|
|
27
|
+
interface TextEdge {
|
|
28
|
+
/** World units. */
|
|
29
|
+
width: number;
|
|
30
|
+
/** How far toward black, 0..1, mixed in OKLab, so the edge keeps the background's hue. */
|
|
31
|
+
shade: number;
|
|
32
|
+
}
|
|
33
|
+
/** The shadow a text node's background casts: black at `alpha`, offset and blurred in world units. */
|
|
34
|
+
interface TextShadow {
|
|
35
|
+
x: number;
|
|
36
|
+
y: number;
|
|
37
|
+
blur: number;
|
|
38
|
+
alpha: number;
|
|
39
|
+
}
|
|
40
|
+
/** A text node's frame, ready to draw: each part `null` when there is none. */
|
|
41
|
+
interface TextFrame {
|
|
42
|
+
/** Filled in `color`, each path at its own entry in `alphas`, under the background. `opacity` is deprecated:
|
|
43
|
+
* one value for every path, which leaves a blurred shadow's interior at about 70% of `color`. */
|
|
44
|
+
shadow: {
|
|
45
|
+
paths: Path[];
|
|
46
|
+
alphas: number[];
|
|
47
|
+
color: string;
|
|
48
|
+
opacity: number;
|
|
49
|
+
} | null;
|
|
50
|
+
/** Stroked in `color` at `width`, over the background. */
|
|
51
|
+
edge: {
|
|
52
|
+
path: Path;
|
|
53
|
+
color: string;
|
|
54
|
+
width: number;
|
|
55
|
+
} | null;
|
|
56
|
+
}
|
|
57
|
+
/** `background`'s color mixed `shade` of the way to black, or `null` for a background with no single color. */
|
|
58
|
+
declare function edgeColor(background: Fill, shade: number): string | null;
|
|
59
|
+
/** The frame of a text node with `d`'s background, edge and shadow, round `box`. */
|
|
60
|
+
declare function textFrameOf(d: {
|
|
61
|
+
background?: Fill | null;
|
|
62
|
+
edge?: TextEdge;
|
|
63
|
+
shadow?: TextShadow;
|
|
64
|
+
}, box: Rect): TextFrame;
|
|
65
|
+
|
|
66
|
+
/** The `data` a `kit:text` node carries. */
|
|
67
|
+
interface TextNodeData {
|
|
68
|
+
text: string;
|
|
69
|
+
style?: TextStyle;
|
|
70
|
+
runs?: readonly StyledRun[];
|
|
71
|
+
fill?: Fill | Inherit | null;
|
|
72
|
+
stroke?: Stroke | Inherit | null;
|
|
73
|
+
verticalAlign?: TextVerticalAlign;
|
|
74
|
+
/** Paint for the whole pose box, drawn under the glyphs. `fill` is the
|
|
75
|
+
* glyphs' own paint, so a box behind them needs a key of its own. */
|
|
76
|
+
background?: Fill | null;
|
|
77
|
+
/** World units between the pose box and the box the text lays out in, on
|
|
78
|
+
* every side. */
|
|
79
|
+
padding?: number;
|
|
80
|
+
/** What happens to text that runs past the pose box: `'visible'` (the
|
|
81
|
+
* default) draws it there, `'clip'` cuts it at the box's edge. */
|
|
82
|
+
overflow?: TextOverflow;
|
|
83
|
+
/** `'shrink'` sets the text at the largest size, at most its own, whose
|
|
84
|
+
* lines fit the box inside `padding`. Default `'none'`. */
|
|
85
|
+
fit?: TextFit;
|
|
86
|
+
/** A rule just inside the box in a shade of `background`. Needs a solid background. */
|
|
87
|
+
edge?: TextEdge;
|
|
88
|
+
/** The shadow `background` casts. Needs a background. */
|
|
89
|
+
shadow?: TextShadow;
|
|
90
|
+
}
|
|
91
|
+
/** How a text node treats lines that run past its box. */
|
|
92
|
+
type TextOverflow = 'visible' | 'clip';
|
|
93
|
+
/** The box a text node's lines lay out in: its pose box, inset by
|
|
94
|
+
* `data.padding` and never past its center. */
|
|
95
|
+
declare function textBoxOf(d: Pick<TextNodeData, 'padding'>, p: RectPose): Rect;
|
|
96
|
+
/** A `kit:text` node as the `TextPose` every text consumer reads, in the box
|
|
97
|
+
* {@link textBoxOf} insets. The stroke goes through the same resolver every
|
|
98
|
+
* other node kind's does, so one carrying no paint is dropped here rather
|
|
99
|
+
* than throwing in the renderer. */
|
|
100
|
+
declare function textPoseOf(d: TextNodeData, p: RectPose, inherited?: InheritedPaint): TextPose;
|
|
101
|
+
/** The node shape that paints a text node: one whose data carries a `text` string, drawn at its box pose. */
|
|
102
|
+
declare const TEXT_PAINTER: NodeShapeEntry<unknown, RectPose>;
|
|
103
|
+
/** The view scale `d` lays out at: `scale` when its style or a run sizes
|
|
104
|
+
* something in `{ px }`, else 1, so world-sized text keeps its memo through a zoom. */
|
|
105
|
+
declare function textLayoutScale(d: Pick<TextNodeData, 'style' | 'runs'>, scale: number | undefined): number;
|
|
106
|
+
|
|
107
|
+
/** Shape the default projections expect `data` to satisfy. All fields
|
|
108
|
+
* optional so any object satisfies the constraint — projections fill in
|
|
109
|
+
* the gaps for non-default shapes. */
|
|
110
|
+
interface DefaultTextData {
|
|
111
|
+
text?: string;
|
|
112
|
+
style?: TextStyle;
|
|
113
|
+
runs?: readonly StyledRun[];
|
|
114
|
+
fill?: Fill | Inherit | null;
|
|
115
|
+
stroke?: Stroke | Inherit | null;
|
|
116
|
+
verticalAlign?: TextVerticalAlign;
|
|
117
|
+
padding?: number;
|
|
118
|
+
overflow?: TextOverflow;
|
|
119
|
+
fit?: TextFit;
|
|
120
|
+
}
|
|
121
|
+
/** All-optional projections + fontSize fallback. */
|
|
122
|
+
interface UseSceneTextEditOptions<TData> {
|
|
123
|
+
/**
|
|
124
|
+
* Is this node text? A double-click opens an edit only on a node that
|
|
125
|
+
* answers yes, and passes through any other to the text under it. Default:
|
|
126
|
+
* `isTextData`, the test `inferredNodeRouting` classifies a text node by. Pass one when `getText` reads some other shape.
|
|
127
|
+
*/
|
|
128
|
+
isText?: (data: TData) => boolean;
|
|
129
|
+
/** Read plain text from `data`. Default: `data.text ?? ''`. */
|
|
130
|
+
getText?: (data: TData) => string;
|
|
131
|
+
/** Read style from `data`. Default: `data.style`. */
|
|
132
|
+
getStyle?: (data: TData) => TextStyle | undefined;
|
|
133
|
+
/** Read the node's paint from `data`. Default: `data.fill` / `data.stroke`. */
|
|
134
|
+
getPaint?: (data: TData) => TextPaint | undefined;
|
|
135
|
+
/** Read rich-text runs from `data`. Default: `data.runs`. */
|
|
136
|
+
getRuns?: (data: TData) => readonly StyledRun[] | undefined;
|
|
137
|
+
/** Read the box vertical alignment from `data`. Default: `data.verticalAlign`. */
|
|
138
|
+
getVerticalAlign?: (data: TData) => TextVerticalAlign | undefined;
|
|
139
|
+
/** Read the inset from the node's box to its text from `data`. Default: `data.padding`. */
|
|
140
|
+
getPadding?: (data: TData) => number | undefined;
|
|
141
|
+
/** Read whether the node cuts its text at its box from `data`. The overlay
|
|
142
|
+
* then does too, and scrolls the text in the box while it is edited.
|
|
143
|
+
* Default: `data.overflow`. */
|
|
144
|
+
getOverflow?: (data: TData) => TextOverflow | undefined;
|
|
145
|
+
/** Read how the node's text size answers to its box from `data`. The overlay
|
|
146
|
+
* sets the text at the size the canvas fits it to. Default: `data.fit`. */
|
|
147
|
+
getFit?: (data: TData) => TextFit | undefined;
|
|
148
|
+
/** Produce updated data with new text. Default: `{ ...data, text }`. */
|
|
149
|
+
setText?: (data: TData, text: string) => TData;
|
|
150
|
+
/** Produce updated data with new runs. Default: `{ ...data, runs }`. */
|
|
151
|
+
setRuns?: (data: TData, runs: StyledRun[]) => TData;
|
|
152
|
+
/**
|
|
153
|
+
* Produce updated data with a new node-wide style. Default:
|
|
154
|
+
* `{ ...data, style }`. Written only when a range toggle has to *clear* a
|
|
155
|
+
* flag the node itself sets — the run algebra is additive, so that edit
|
|
156
|
+
* lowers the node flag and raises it on the runs outside the range. See
|
|
157
|
+
* `useTextEdit`'s `setStyle`.
|
|
158
|
+
*
|
|
159
|
+
* An edit's text, runs, and style are folded through these three and
|
|
160
|
+
* written as one `scene.update`, so a commit is one undo step.
|
|
161
|
+
*/
|
|
162
|
+
setStyle?: (data: TData, style: TextStyle) => TData;
|
|
163
|
+
/**
|
|
164
|
+
* The view to project the overlay through. Omit it and the view is read
|
|
165
|
+
* live from the weasel canvas mounted inside `container` (the first, when
|
|
166
|
+
* there are several). With no canvas there, the node's world box is passed
|
|
167
|
+
* through as screen pixels.
|
|
168
|
+
*
|
|
169
|
+
* A thunk is re-read on every projection; a plain `View` is the value from
|
|
170
|
+
* the render that supplied it.
|
|
171
|
+
*/
|
|
172
|
+
view?: View | (() => View);
|
|
173
|
+
/**
|
|
174
|
+
* Forwarded to `useTextEdit`: is `el` part of the editor's own chrome?
|
|
175
|
+
* Focus moving into it does not end the edit. Wire it to whatever renders
|
|
176
|
+
* the character controls.
|
|
177
|
+
*/
|
|
178
|
+
isEditorChrome?: (el: Element) => boolean;
|
|
179
|
+
/** Forwarded to `useTextEdit`: what Escape does to the edit. */
|
|
180
|
+
escape?: 'cancel' | 'commit';
|
|
181
|
+
/** Forwarded to `useTextEdit`: how long an edit waits for its face. */
|
|
182
|
+
fontHold?: number;
|
|
183
|
+
/** Forwarded to `useTextEdit`: called as an edit of the node `id` opens,
|
|
184
|
+
* whichever way it was started. */
|
|
185
|
+
onStart?: (id: string) => void;
|
|
186
|
+
/** Forwarded to `useTextEdit`: called as the edit of `id` closes, after
|
|
187
|
+
* any commit has been written to the scene. */
|
|
188
|
+
onEnd?: (id: string) => void;
|
|
189
|
+
}
|
|
190
|
+
/** Return shape extends `UseTextEditReturn` with what the `textEdit` dep
|
|
191
|
+
* answers: a double-click on a canvas inside `container` reaches the editor
|
|
192
|
+
* through it, with no handler of the host's. */
|
|
193
|
+
interface UseSceneTextEditReturn extends UseTextEditReturn {
|
|
194
|
+
/** The top-most unlocked text node at world point `at`, and the caret at
|
|
195
|
+
* the glyph there: what `TextEditDep.textAt` wants. */
|
|
196
|
+
textAt: (at: Point2) => {
|
|
197
|
+
id: string;
|
|
198
|
+
caret: number;
|
|
199
|
+
} | null;
|
|
200
|
+
/** The `isText` option asked of the node with this id: what
|
|
201
|
+
* `TextEditDep.isTextNode` wants, so both ways into an edit agree. */
|
|
202
|
+
isTextNode: (id: string) => boolean;
|
|
203
|
+
/**
|
|
204
|
+
* `defaultDrawOne`, less the glyphs of the node being edited: the overlay
|
|
205
|
+
* stands in for its text, and the rest of the node, a `background` among
|
|
206
|
+
* it, goes on painting. A `<SceneCanvas>` inside `container` drawing this
|
|
207
|
+
* scene already leaves those glyphs out; this is for anything else that
|
|
208
|
+
* draws the node.
|
|
209
|
+
*/
|
|
210
|
+
drawOne: EditingDrawOne;
|
|
211
|
+
}
|
|
212
|
+
/** Wire in-place text editing on a scene: mounts a DOM editing overlay over
|
|
213
|
+
* the node being edited and writes the result back as an undoable op.
|
|
214
|
+
* `<SceneCanvas>`'s own editor stands down for any canvas inside `container`
|
|
215
|
+
* and answers its `textEdit` dep with this one, so the canvas's double-click
|
|
216
|
+
* (`enterTextEdit.doubleClick`) and a text tool open this editor, and such a
|
|
217
|
+
* canvas leaves out the glyphs of the node being edited. */
|
|
218
|
+
declare function useSceneTextEdit<TData extends DefaultTextData, TLayer extends string, TPose extends RectPose = RectPose>(scene: Scene<TData, TLayer, TPose>, container: HTMLElement | null, options?: UseSceneTextEditOptions<TData>): UseSceneTextEditReturn;
|
|
219
|
+
|
|
220
|
+
/**
|
|
221
|
+
* The canvas's own text editor: the one `enterTextEdit` reaches, from a text
|
|
222
|
+
* or sticky tool or a double-click on a text node, when the host has wired
|
|
223
|
+
* none of its own. `textTools.text` mounts it inside the canvas. It stands down for
|
|
224
|
+
* a host editor: a `useSceneTextEdit` of its scene whose container holds the canvas, which
|
|
225
|
+
* the `textEdit` dep then answers with, or a `textEdit` dep registered over it.
|
|
226
|
+
*/
|
|
227
|
+
|
|
228
|
+
/** The canvas's own editor: `useSceneTextEdit`'s options, or `false` for none. */
|
|
229
|
+
type CanvasTextEditorOptions<TData = DefaultTextData> = false | UseSceneTextEditOptions<TData>;
|
|
230
|
+
|
|
231
|
+
/** How a sticky note looks as it is made, named as the text node it becomes
|
|
232
|
+
* names them. Every field has a default, in {@link STICKY_DEFAULTS}. */
|
|
233
|
+
interface StickyStyle {
|
|
234
|
+
/** The note itself, painted over its whole box. */
|
|
235
|
+
background?: Fill;
|
|
236
|
+
/** The text's paint. */
|
|
237
|
+
fill?: Fill;
|
|
238
|
+
/** World units from the note's edge to its text, on every side. */
|
|
239
|
+
padding?: number;
|
|
240
|
+
/** Typography for the note's text. */
|
|
241
|
+
style?: TextStyle;
|
|
242
|
+
verticalAlign?: TextVerticalAlign;
|
|
243
|
+
/** What happens to text that outgrows the note. */
|
|
244
|
+
overflow?: TextOverflow;
|
|
245
|
+
/** The rule round the note, in a darker shade of its paper. */
|
|
246
|
+
edge?: TextEdge;
|
|
247
|
+
/** The shadow the note casts. */
|
|
248
|
+
shadow?: TextShadow;
|
|
249
|
+
/** The smallest note a drag makes or a resize leaves, in world units. */
|
|
250
|
+
minSize?: MinSize;
|
|
251
|
+
/** The note a click makes, centered on the click, in world units. A drag
|
|
252
|
+
* makes the note it draws. */
|
|
253
|
+
size?: {
|
|
254
|
+
width: number;
|
|
255
|
+
height: number;
|
|
256
|
+
};
|
|
257
|
+
}
|
|
258
|
+
/** A sticky insert's extras: the tool's {@link StickyStyle}, and its `paper` and `ink` options, the paints that
|
|
259
|
+
* stand over `background` and `fill`. */
|
|
260
|
+
type StickyLook = StickyStyle & {
|
|
261
|
+
paper?: Paint | null;
|
|
262
|
+
ink?: Paint | null;
|
|
263
|
+
};
|
|
264
|
+
/** The look a sticky note takes for any field its tool leaves out. */
|
|
265
|
+
declare const STICKY_DEFAULTS: {
|
|
266
|
+
readonly background: {
|
|
267
|
+
readonly paint: {
|
|
268
|
+
readonly kind: "solid";
|
|
269
|
+
readonly color: "#fff1a6ff";
|
|
270
|
+
};
|
|
271
|
+
};
|
|
272
|
+
readonly fill: _weasel_js_paint.PaintedFill;
|
|
273
|
+
readonly padding: 12;
|
|
274
|
+
readonly style: {
|
|
275
|
+
readonly fontSize: 18;
|
|
276
|
+
readonly align: "center";
|
|
277
|
+
readonly wrap: true;
|
|
278
|
+
};
|
|
279
|
+
readonly verticalAlign: "center";
|
|
280
|
+
readonly overflow: "clip";
|
|
281
|
+
readonly edge: {
|
|
282
|
+
readonly width: 1;
|
|
283
|
+
readonly shade: 0.18;
|
|
284
|
+
};
|
|
285
|
+
readonly shadow: {
|
|
286
|
+
readonly x: 0;
|
|
287
|
+
readonly y: 2;
|
|
288
|
+
readonly blur: 6;
|
|
289
|
+
readonly alpha: 0.18;
|
|
290
|
+
};
|
|
291
|
+
readonly minSize: {
|
|
292
|
+
readonly width: 48;
|
|
293
|
+
readonly height: 48;
|
|
294
|
+
};
|
|
295
|
+
readonly size: {
|
|
296
|
+
readonly width: 160;
|
|
297
|
+
readonly height: 160;
|
|
298
|
+
};
|
|
299
|
+
};
|
|
300
|
+
/**
|
|
301
|
+
* A sticky note's `data`: a text node with a `background`, so the `kit:text`
|
|
302
|
+
* painter draws it and the text editor edits it with no sticky case of its
|
|
303
|
+
* own. `look` is the `sticky` insert's extras, which carry the tool's
|
|
304
|
+
* {@link StickyStyle}.
|
|
305
|
+
*/
|
|
306
|
+
declare function stickyData(look: StickyLook & {
|
|
307
|
+
text?: string;
|
|
308
|
+
}): TextNodeData & {
|
|
309
|
+
minSize: MinSize;
|
|
310
|
+
};
|
|
311
|
+
/** The `sticky` insert as an `InsertNodeFactory`: what `textTools.text` installs, for a canvas that wraps it — to tag
|
|
312
|
+
* the data with a `kind`, say — under `insertNodeFactories`. An empty note opens for typing, as text does. */
|
|
313
|
+
declare const stickyNodeFactory: InsertNodeFactory;
|
|
314
|
+
|
|
315
|
+
/** Options for `useStickyTool`: the look of the notes it makes, and the
|
|
316
|
+
* insert behaviors every drag-to-insert tool takes. Keep object options
|
|
317
|
+
* stable across renders: a new one rebuilds the tool. */
|
|
318
|
+
interface UseStickyToolOptions extends InsertToolOptions, StickyStyle {
|
|
319
|
+
}
|
|
320
|
+
/** The sticky tool's options: the note's paper and its ink, its own rather than shared with the shape tools.
|
|
321
|
+
* Both inserts read them, the drag's and the click's. */
|
|
322
|
+
declare const STICKY_TOOL_OPTIONS: ToolOptionsSpec;
|
|
323
|
+
/**
|
|
324
|
+
* Sticky-note tool. A drag draws a note through `insertAction`, a click
|
|
325
|
+
* places one of `size` through `placeAction`, and either drops into the new
|
|
326
|
+
* note's caret. Neither makes a note smaller than `minSize`, and the note
|
|
327
|
+
* keeps it as the floor a resize stops at. A click on a selected note edits it.
|
|
328
|
+
*
|
|
329
|
+
* The note is minted by the `insert` dep's `sticky` kind (`textTools.text`'s
|
|
330
|
+
* `stickyNodeFactory`), as a text node with a `background` (see `stickyData`); the look rides on the bindings' params
|
|
331
|
+
* as that insert's extras, and its paper and ink are the tool's options
|
|
332
|
+
* (`background` and `fill` set their defaults). A consumer wanting its own node overrides the dep
|
|
333
|
+
* (`insertNodeFactories.sticky`), not the tool.
|
|
334
|
+
*/
|
|
335
|
+
declare function createStickyTool(options?: UseStickyToolOptions): Tool;
|
|
336
|
+
/** {@link createStickyTool}, rebuilt only when an option changes. */
|
|
337
|
+
declare function useStickyTool(options?: UseStickyToolOptions): Tool;
|
|
338
|
+
|
|
339
|
+
/** Routes a leaf whose `data.text` is a string as `'text'`, ahead of the canvas's own routing, so an
|
|
340
|
+
* SVG-imported text node carrying a fallback `path` routes to text edit. */
|
|
341
|
+
declare const textNodeRouting: NodeRoutingEntry;
|
|
342
|
+
/** Options for {@link createTextPreset}. */
|
|
343
|
+
interface TextPresetOptions<TData = DefaultTextData> {
|
|
344
|
+
/** The canvas's own editor: `useSceneTextEdit`'s options, or `false` for none. Default `{}`. It mounts its
|
|
345
|
+
* overlay in the canvas's offset parent, so the canvas wants a positioned ancestor, and stands down for a
|
|
346
|
+
* host's own editor: a `useSceneTextEdit` of its scene whose container holds the canvas, or a `textEdit` dep a child of
|
|
347
|
+
* the canvas registers. Wire one of those for character controls, which read the edit's state. */
|
|
348
|
+
editor?: CanvasTextEditorOptions<TData>;
|
|
349
|
+
}
|
|
350
|
+
/**
|
|
351
|
+
* The text node kind and its editing, configured by `options`: the `kit:text` painter, whose glyphs are its
|
|
352
|
+
* outline; `'text'` routing and properties; the `text` and `sticky` inserts; the canvas's own editor and the
|
|
353
|
+
* `textEdit` dep; `enterTextEdit`, a double-click opening text in place (`enterTextEditAt`), and a click on a path
|
|
354
|
+
* effect's hidden text opening it (`editEffectText`); and plain-text paste.
|
|
355
|
+
*/
|
|
356
|
+
declare function createTextPreset<TData = DefaultTextData>(options?: TextPresetOptions<TData>): FeaturePreset;
|
|
357
|
+
/** {@link createTextPreset} with its defaults. */
|
|
358
|
+
declare const textPreset: FeaturePreset;
|
|
359
|
+
/** Options for {@link createTextToolsPreset}: the insert behaviors both tools take, and the sticky notes' look. */
|
|
360
|
+
interface TextToolsPresetOptions extends Pick<UseStickyToolOptions, 'behaviors' | 'share'> {
|
|
361
|
+
sticky?: Omit<UseStickyToolOptions, 'behaviors' | 'share'>;
|
|
362
|
+
/** The text preset the tools need, for a canvas configuring its editor. Default {@link textPreset}. */
|
|
363
|
+
text?: FeaturePreset;
|
|
364
|
+
}
|
|
365
|
+
/** The text and sticky-note tools, with the text preset whose actions they bind and editing's `presets.insert`,
|
|
366
|
+
* whose `insert` action and dep they insert through. */
|
|
367
|
+
declare function createTextToolsPreset(options?: TextToolsPresetOptions): FeaturePreset;
|
|
368
|
+
/** {@link createTextToolsPreset} with its defaults. */
|
|
369
|
+
declare const textToolsPreset: FeaturePreset;
|
|
370
|
+
/**
|
|
371
|
+
* A whiteboard: text and the sticky note on an open canvas you pan and zoom, with the select tool, moving,
|
|
372
|
+
* resizing and editing what is on it. A note is the sticky tool's, a text node with a `background`. A pencil is
|
|
373
|
+
* `@weasel-js/path-tools`' `usePencilTool`, passed in `tools`.
|
|
374
|
+
*/
|
|
375
|
+
declare const whiteboardPreset: FeaturePreset;
|
|
376
|
+
|
|
377
|
+
export { withoutText as A, textPreset as B, textToolsPreset as F, whiteboardPreset as G, STICKY_DEFAULTS as S, STICKY_TOOL_OPTIONS as a, TEXT_PAINTER as d, createStickyTool as m, createTextPreset as n, createTextToolsPreset as o, drawOneWithoutEditedText as p, edgeColor as q, stickyNodeFactory as r, stickyData as s, textBoxOf as t, textFrameOf as u, textLayoutScale as v, textNodeRouting as w, textPoseOf as x, useSceneTextEdit as y, useStickyTool as z };
|
|
378
|
+
export type { CanvasTextEditorOptions as C, DefaultTextData as D, EditingDrawOne as E, TextNodeData as T, UseStickyToolOptions as U, StickyLook as b, StickyStyle as c, TextEdge as e, TextFrame as f, TextOverflow as g, TextPresetOptions as h, TextShadow as i, TextToolsPresetOptions as j, UseSceneTextEditOptions as k, UseSceneTextEditReturn as l };
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
export { B as text, F as textTools, G as whiteboard } from './presets-oTMEI2UF.js';
|
|
2
|
+
import '@weasel-js/core';
|
|
3
|
+
import '@weasel-js/renderer';
|
|
4
|
+
import '@weasel-js/paint';
|
|
5
|
+
import '@weasel-js/routing';
|
|
6
|
+
import '@weasel-js/text';
|
|
7
|
+
import '@weasel-js/geom';
|
|
8
|
+
import '@weasel-js/text-dom';
|
|
9
|
+
import '@weasel-js/editing';
|
package/dist/presets.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":[],"names":[],"mappings":"","file":"presets.js"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@weasel-js/text-tools",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "2.0.0",
|
|
4
4
|
"description": "Text for a weasel canvas, as presets an app opts into: the text node kind and its painter, the in-place editor, the text and sticky-note tools, and plain-text paste.",
|
|
5
5
|
"weasel": {
|
|
6
6
|
"tier": "plugin"
|
|
@@ -16,6 +16,10 @@
|
|
|
16
16
|
"types": "./dist/index.d.ts",
|
|
17
17
|
"import": "./dist/index.js"
|
|
18
18
|
},
|
|
19
|
+
"./presets": {
|
|
20
|
+
"types": "./dist/presets.d.ts",
|
|
21
|
+
"import": "./dist/presets.js"
|
|
22
|
+
},
|
|
19
23
|
"./package.json": "./package.json"
|
|
20
24
|
},
|
|
21
25
|
"author": "orochi235",
|
|
@@ -41,28 +45,29 @@
|
|
|
41
45
|
"test": "node ../../scripts/package-test.mjs"
|
|
42
46
|
},
|
|
43
47
|
"dependencies": {
|
|
44
|
-
"@weasel-js/cursor": "
|
|
45
|
-
"@weasel-js/editing": "
|
|
46
|
-
"@weasel-js/font": "
|
|
47
|
-
"@weasel-js/
|
|
48
|
-
"@weasel-js/
|
|
49
|
-
"@weasel-js/
|
|
50
|
-
"@weasel-js/
|
|
51
|
-
"@weasel-js/
|
|
52
|
-
"@weasel-js/
|
|
53
|
-
"@weasel-js/
|
|
54
|
-
"@weasel-js/
|
|
55
|
-
"
|
|
56
|
-
"@weasel-js/text": "1.19.1",
|
|
57
|
-
"@weasel-js/text-dom": "1.19.1"
|
|
48
|
+
"@weasel-js/cursor": "2.0.0",
|
|
49
|
+
"@weasel-js/editing": "2.0.0",
|
|
50
|
+
"@weasel-js/font": "2.0.0",
|
|
51
|
+
"@weasel-js/paint": "2.0.0",
|
|
52
|
+
"@weasel-js/quantity": "2.0.0",
|
|
53
|
+
"@weasel-js/react": "2.0.0",
|
|
54
|
+
"@weasel-js/registry": "2.0.0",
|
|
55
|
+
"@weasel-js/renderer": "2.0.0",
|
|
56
|
+
"@weasel-js/routing": "2.0.0",
|
|
57
|
+
"@weasel-js/text": "2.0.0",
|
|
58
|
+
"@weasel-js/text-dom": "2.0.0",
|
|
59
|
+
"polygon-clipping": "^0.15.7"
|
|
58
60
|
},
|
|
59
61
|
"peerDependencies": {
|
|
60
|
-
"@weasel-js/core": "
|
|
61
|
-
"@weasel-js/geom": "
|
|
62
|
+
"@weasel-js/core": "2.0.0",
|
|
63
|
+
"@weasel-js/geom": "2.0.0",
|
|
62
64
|
"react": ">=18"
|
|
63
65
|
},
|
|
64
66
|
"devDependencies": {
|
|
65
|
-
"@weasel-js/bidi": "
|
|
67
|
+
"@weasel-js/bidi": "2.0.0",
|
|
68
|
+
"@weasel-js/icons": "2.0.0",
|
|
69
|
+
"@weasel-js/path-tools": "2.0.0",
|
|
70
|
+
"@weasel-js/prefs-schema": "2.0.0"
|
|
66
71
|
},
|
|
67
72
|
"publishConfig": {
|
|
68
73
|
"access": "public",
|