@meltemi/diagrams-editor 1.10.0 → 1.10.18
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/dist/arrange.d.ts +54 -1
- package/dist/arrange.d.ts.map +1 -1
- package/dist/arrange.js +209 -7
- package/dist/arrange.js.map +1 -1
- package/dist/canvas/index.d.ts +1 -0
- package/dist/canvas/index.d.ts.map +1 -1
- package/dist/canvas/index.js +1 -0
- package/dist/canvas/index.js.map +1 -1
- package/dist/canvas/keyboard.d.ts +21 -2
- package/dist/canvas/keyboard.d.ts.map +1 -1
- package/dist/canvas/keyboard.js +19 -0
- package/dist/canvas/keyboard.js.map +1 -1
- package/dist/canvas/palette.d.ts +41 -1
- package/dist/canvas/palette.d.ts.map +1 -1
- package/dist/canvas/palette.js +42 -0
- package/dist/canvas/palette.js.map +1 -1
- package/dist/canvas/pens.d.ts +10 -0
- package/dist/canvas/pens.d.ts.map +1 -0
- package/dist/canvas/pens.js +29 -0
- package/dist/canvas/pens.js.map +1 -0
- package/dist/canvas/protocol.d.ts +359 -16
- package/dist/canvas/protocol.d.ts.map +1 -1
- package/dist/canvas/protocol.js +83 -3
- package/dist/canvas/protocol.js.map +1 -1
- package/dist/catalog.d.ts +5 -0
- package/dist/catalog.d.ts.map +1 -1
- package/dist/catalog.js +1 -1
- package/dist/catalog.js.map +1 -1
- package/dist/clipboard.d.ts.map +1 -1
- package/dist/clipboard.js +39 -2
- package/dist/clipboard.js.map +1 -1
- package/dist/effects.d.ts.map +1 -1
- package/dist/effects.js +7 -4
- package/dist/effects.js.map +1 -1
- package/dist/exports.d.ts +6 -0
- package/dist/exports.d.ts.map +1 -1
- package/dist/exports.js +11 -9
- package/dist/exports.js.map +1 -1
- package/dist/fonts.d.ts +63 -0
- package/dist/fonts.d.ts.map +1 -0
- package/dist/fonts.js +175 -0
- package/dist/fonts.js.map +1 -0
- package/dist/index.d.ts +1 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js.map +1 -1
- package/dist/inspector.d.ts.map +1 -1
- package/dist/inspector.js +339 -67
- package/dist/inspector.js.map +1 -1
- package/dist/layouts.d.ts +3 -2
- package/dist/layouts.d.ts.map +1 -1
- package/dist/layouts.js +4 -2
- package/dist/layouts.js.map +1 -1
- package/dist/messages/en.d.ts +51 -0
- package/dist/messages/en.d.ts.map +1 -1
- package/dist/messages/en.js +51 -0
- package/dist/messages/en.js.map +1 -1
- package/dist/messages/es.d.ts.map +1 -1
- package/dist/messages/es.js +33 -0
- package/dist/messages/es.js.map +1 -1
- package/dist/messages/index.d.ts +33 -0
- package/dist/messages/index.d.ts.map +1 -1
- package/dist/messages/keys.d.ts.map +1 -1
- package/dist/messages/keys.js +24 -0
- package/dist/messages/keys.js.map +1 -1
- package/dist/messages/services.d.ts +124 -1
- package/dist/messages/services.d.ts.map +1 -1
- package/dist/messages/services.js +142 -16
- package/dist/messages/services.js.map +1 -1
- package/dist/render.d.ts +5 -0
- package/dist/render.d.ts.map +1 -1
- package/dist/render.js +4 -2
- package/dist/render.js.map +1 -1
- package/dist/sequence.d.ts +37 -8
- package/dist/sequence.d.ts.map +1 -1
- package/dist/sequence.js +409 -38
- package/dist/sequence.js.map +1 -1
- package/dist/services/actions.d.ts.map +1 -1
- package/dist/services/actions.js +54 -0
- package/dist/services/actions.js.map +1 -1
- package/dist/services/completion.d.ts.map +1 -1
- package/dist/services/completion.js +100 -10
- package/dist/services/completion.js.map +1 -1
- package/dist/services/docs.d.ts +5 -0
- package/dist/services/docs.d.ts.map +1 -1
- package/dist/services/docs.js +7 -0
- package/dist/services/docs.js.map +1 -1
- package/dist/services/hover.d.ts +5 -0
- package/dist/services/hover.d.ts.map +1 -1
- package/dist/services/hover.js +152 -20
- package/dist/services/hover.js.map +1 -1
- package/dist/services/navigation.d.ts.map +1 -1
- package/dist/services/navigation.js +6 -3
- package/dist/services/navigation.js.map +1 -1
- package/dist/services/stories.d.ts.map +1 -1
- package/dist/services/stories.js +31 -3
- package/dist/services/stories.js.map +1 -1
- package/dist/session.d.ts +65 -3
- package/dist/session.d.ts.map +1 -1
- package/dist/session.js +707 -50
- package/dist/session.js.map +1 -1
- package/dist/syntax.d.ts.map +1 -1
- package/dist/syntax.js +3 -0
- package/dist/syntax.js.map +1 -1
- package/dist/text-places.d.ts +15 -3
- package/dist/text-places.d.ts.map +1 -1
- package/dist/text-places.js +136 -15
- package/dist/text-places.js.map +1 -1
- package/dist/themes.d.ts +0 -2
- package/dist/themes.d.ts.map +1 -1
- package/dist/themes.js +16 -12
- package/dist/themes.js.map +1 -1
- package/package.json +21 -16
package/dist/canvas/palette.d.ts
CHANGED
|
@@ -1,5 +1,45 @@
|
|
|
1
1
|
import { type ShapeSize } from "@meltemi/diagrams-layout/shapes";
|
|
2
|
-
import { type CanvasProfile, type ShapeName } from "./protocol.js";
|
|
2
|
+
import { type CanvasProfile, type PenStyle, type ShapeName } from "./protocol.js";
|
|
3
|
+
/** The names of the six fixed colours a sticky's menu offers beside the theme's `sticky`. */
|
|
4
|
+
export type StickyColourName = "yellow" | "pink" | "green" | "blue" | "orange" | "purple";
|
|
5
|
+
/**
|
|
6
|
+
* The fixed colours of stickies, in the order the sticky button's menu and the strip's fill row
|
|
7
|
+
* show them: pastels that stay the same in a dark theme, as paper does, written as
|
|
8
|
+
* `style <id> { fill "<hex>" }`. Their names are words of the canvas's catalog.
|
|
9
|
+
*/
|
|
10
|
+
export declare const STICKY_COLOURS: readonly {
|
|
11
|
+
readonly name: StickyColourName;
|
|
12
|
+
readonly hex: string;
|
|
13
|
+
}[];
|
|
14
|
+
/** The widths the pen menu offers, in pixels. */
|
|
15
|
+
export declare const PEN_WIDTHS: {
|
|
16
|
+
readonly thin: 2;
|
|
17
|
+
readonly medium: 4;
|
|
18
|
+
readonly thick: 8;
|
|
19
|
+
};
|
|
20
|
+
/**
|
|
21
|
+
* The highlighter: a pen of its own colour (the theme's `highlight` until another is chosen),
|
|
22
|
+
* always 20 wide and 35 % opaque, so the text under it stays readable.
|
|
23
|
+
*/
|
|
24
|
+
export declare const HIGHLIGHTER: {
|
|
25
|
+
readonly width: 20;
|
|
26
|
+
readonly opacity: 0.35;
|
|
27
|
+
readonly stroke: "@highlight";
|
|
28
|
+
};
|
|
29
|
+
/** The colour of a pen whose style writes none: the theme's `ink`. */
|
|
30
|
+
export declare const DEFAULT_PEN_STROKE = "@ink";
|
|
31
|
+
/**
|
|
32
|
+
* The width of a pen whose style writes none: the layout's `DEFAULT_PEN_WIDTH`, mirrored so that
|
|
33
|
+
* the canvas page does not load the engine (a test pins it).
|
|
34
|
+
*/
|
|
35
|
+
export declare const DEFAULT_PEN_WIDTH = 3;
|
|
36
|
+
/**
|
|
37
|
+
* The `style` of `createPen` for a stroke of the pen or the highlighter, with only what differs
|
|
38
|
+
* from a stroke's defaults: the pen writes `stroke` when its colour is not `@ink` and `width`
|
|
39
|
+
* when it is not 3; the highlighter always writes its colour, width 20 and opacity 0.35 (`width`
|
|
40
|
+
* is the pen's and does not apply to it). Empty when nothing differs, which writes no `style`.
|
|
41
|
+
*/
|
|
42
|
+
export declare function penStyleFor(tool: "pen" | "highlighter", width: number, colour: string): PenStyle;
|
|
3
43
|
/**
|
|
4
44
|
* The relation kinds of the palette's arrow button, in the order its menu lists them and R cycles
|
|
5
45
|
* through them: `->`, `-->`, the lines without heads `--` and `---`, then the two-way `<->` and
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"palette.d.ts","sourceRoot":"","sources":["../../src/canvas/palette.ts"],"names":[],"mappings":"AAAA,OAAO,EAAe,KAAK,SAAS,EAAE,MAAM,iCAAiC,CAAC;AAC9E,OAAO,EAAU,KAAK,aAAa,EAAE,KAAK,SAAS,EAAE,MAAM,eAAe,CAAC;
|
|
1
|
+
{"version":3,"file":"palette.d.ts","sourceRoot":"","sources":["../../src/canvas/palette.ts"],"names":[],"mappings":"AAAA,OAAO,EAAe,KAAK,SAAS,EAAE,MAAM,iCAAiC,CAAC;AAC9E,OAAO,EAAU,KAA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AAC,IAAI,EAAE,OAAO,GAAG,QAAQ,CAAC;IAAC,QAAQ,CAAC,KAAK,EAAE,KAAK,GAAG,MAAM,GAAG,MAAM,CAAA;CAAE,CAEhF;AAED;;;GAGG;AACH,wBAAgB,SAAS,CAAC,KAAK,EAAE,SAAS,GAAG,SAAS,CAErD;AAOD;;;;GAIG;AACH,wBAAgB,UAAU,CAAC,KAAK,EAAE,MAAM,EAAE,MAAM,EAAE,CAAC,KAAK,EAAE,SAAS,KAAK,MAAM,GAAG,SAAS,EAAE,CAc3F"}
|
package/dist/canvas/palette.js
CHANGED
|
@@ -1,5 +1,47 @@
|
|
|
1
1
|
import { SHAPE_SIZES } from "@meltemi/diagrams-layout/shapes";
|
|
2
2
|
import { SHAPES } from "./protocol.js";
|
|
3
|
+
/**
|
|
4
|
+
* The fixed colours of stickies, in the order the sticky button's menu and the strip's fill row
|
|
5
|
+
* show them: pastels that stay the same in a dark theme, as paper does, written as
|
|
6
|
+
* `style <id> { fill "<hex>" }`. Their names are words of the canvas's catalog.
|
|
7
|
+
*/
|
|
8
|
+
export const STICKY_COLOURS = [
|
|
9
|
+
{ name: "yellow", hex: "#fff59d" },
|
|
10
|
+
{ name: "pink", hex: "#f8bbd0" },
|
|
11
|
+
{ name: "green", hex: "#c8e6c9" },
|
|
12
|
+
{ name: "blue", hex: "#bbdefb" },
|
|
13
|
+
{ name: "orange", hex: "#ffe0b2" },
|
|
14
|
+
{ name: "purple", hex: "#e1bee7" },
|
|
15
|
+
];
|
|
16
|
+
/** The widths the pen menu offers, in pixels. */
|
|
17
|
+
export const PEN_WIDTHS = { thin: 2, medium: 4, thick: 8 };
|
|
18
|
+
/**
|
|
19
|
+
* The highlighter: a pen of its own colour (the theme's `highlight` until another is chosen),
|
|
20
|
+
* always 20 wide and 35 % opaque, so the text under it stays readable.
|
|
21
|
+
*/
|
|
22
|
+
export const HIGHLIGHTER = { width: 20, opacity: 0.35, stroke: "@highlight" };
|
|
23
|
+
/** The colour of a pen whose style writes none: the theme's `ink`. */
|
|
24
|
+
export const DEFAULT_PEN_STROKE = "@ink";
|
|
25
|
+
/**
|
|
26
|
+
* The width of a pen whose style writes none: the layout's `DEFAULT_PEN_WIDTH`, mirrored so that
|
|
27
|
+
* the canvas page does not load the engine (a test pins it).
|
|
28
|
+
*/
|
|
29
|
+
export const DEFAULT_PEN_WIDTH = 3;
|
|
30
|
+
/**
|
|
31
|
+
* The `style` of `createPen` for a stroke of the pen or the highlighter, with only what differs
|
|
32
|
+
* from a stroke's defaults: the pen writes `stroke` when its colour is not `@ink` and `width`
|
|
33
|
+
* when it is not 3; the highlighter always writes its colour, width 20 and opacity 0.35 (`width`
|
|
34
|
+
* is the pen's and does not apply to it). Empty when nothing differs, which writes no `style`.
|
|
35
|
+
*/
|
|
36
|
+
export function penStyleFor(tool, width, colour) {
|
|
37
|
+
if (tool === "highlighter") {
|
|
38
|
+
return { stroke: colour, width: HIGHLIGHTER.width, opacity: HIGHLIGHTER.opacity };
|
|
39
|
+
}
|
|
40
|
+
return {
|
|
41
|
+
...(colour !== DEFAULT_PEN_STROKE ? { stroke: colour } : {}),
|
|
42
|
+
...(width !== DEFAULT_PEN_WIDTH ? { width } : {}),
|
|
43
|
+
};
|
|
44
|
+
}
|
|
3
45
|
/**
|
|
4
46
|
* The relation kinds of the palette's arrow button, in the order its menu lists them and R cycles
|
|
5
47
|
* through them: `->`, `-->`, the lines without heads `--` and `---`, then the two-way `<->` and
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"palette.js","sourceRoot":"","sources":["../../src/canvas/palette.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAkB,MAAM,iCAAiC,CAAC;AAC9E,OAAO,EAAE,MAAM,
|
|
1
|
+
{"version":3,"file":"palette.js","sourceRoot":"","sources":["../../src/canvas/palette.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAkB,MAAM,iCAAiC,CAAC;AAC9E,OAAO,EAAE,MAAM,EAAqD,MA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,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC,EAAE,MAAM,CAAC,KAAK,CAAC,CAAC,CAAC;QACrD,IAAI,KAAK,CAAC,IAAI,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,IAAI,CAAC,UAAU,CAAC,MAAM,CAAC,CAAC;YAAE,OAAO,CAAC,CAAC;QAC5D,IAAI,KAAK,CAAC,IAAI,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,IAAI,CAAC,KAAK,CAAC,QAAQ,CAAC,CAAC,IAAI,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,IAAI,CAAC,UAAU,CAAC,MAAM,CAAC,CAAC,CAAC;YACpF,OAAO,CAAC,CAAC;QACX,OAAO,KAAK,CAAC,IAAI,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,IAAI,CAAC,QAAQ,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;IAC9D,CAAC,CAAC;IACF,OAAO,MAAM,CAAC,GAAG,CAAC,CAAC,KAAK,EAAE,EAAE,CAAC,CAAC,EAAE,KAAK,EAAE,IAAI,EAAE,IAAI,CAAC,KAAK,CAAC,EAAE,CAAC,CAAC;SACzD,MAAM,CAAC,CAAC,KAAK,EAAE,EAAE,CAAC,KAAK,CAAC,IAAI,IAAI,CAAC,CAAC;SAClC,IAAI,CAAC,CAAC,CAAC,EAAE,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,IAAI,GAAG,CAAC,CAAC,IAAI,CAAC;SAC/B,GAAG,CAAC,CAAC,KAAK,EAAE,EAAE,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC;AACjC,CAAC"}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import type { Box, Point } from "./geometry.js";
|
|
2
|
+
/**
|
|
3
|
+
* The points of a pen stroke scaled from its bounds to a new box, as a resize handle scales them:
|
|
4
|
+
* the box of the points (the bounds less half the stroke's width on every side) maps onto the new
|
|
5
|
+
* box less the same margin, so that the stroke keeps its width and its bounds become the box.
|
|
6
|
+
* Along an axis the stroke has no extent on (a dot, a level or upright stroke), it sits in the
|
|
7
|
+
* middle of the box. Diagram coordinates in, diagram coordinates out.
|
|
8
|
+
*/
|
|
9
|
+
export declare function scalePenPoints(points: readonly Point[], bounds: Box, box: Box, width: number): Point[];
|
|
10
|
+
//# sourceMappingURL=pens.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"pens.d.ts","sourceRoot":"","sources":["../../src/canvas/pens.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,GAAG,EAAE,KAAK,EAAE,MAAM,eAAe,CAAC;AAiBhD;;;;;;GAMG;AACH,wBAAgB,cAAc,CAC5B,MAAM,EAAE,SAAS,KAAK,EAAE,EACxB,MAAM,EAAE,GAAG,EACX,GAAG,EAAE,GAAG,EACR,KAAK,EAAE,MAAM,GACZ,KAAK,EAAE,CAOT"}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
/** A box less `margin` on every side, never less than empty. */
|
|
2
|
+
function inset(box, margin) {
|
|
3
|
+
return {
|
|
4
|
+
x: box.x + margin,
|
|
5
|
+
y: box.y + margin,
|
|
6
|
+
width: Math.max(0, box.width - 2 * margin),
|
|
7
|
+
height: Math.max(0, box.height - 2 * margin),
|
|
8
|
+
};
|
|
9
|
+
}
|
|
10
|
+
/** A coordinate mapped from one span to another; the middle of the new span from none. */
|
|
11
|
+
function mapped(value, from, size, to, toSize) {
|
|
12
|
+
return size > 0 ? to + ((value - from) * toSize) / size : to + toSize / 2;
|
|
13
|
+
}
|
|
14
|
+
/**
|
|
15
|
+
* The points of a pen stroke scaled from its bounds to a new box, as a resize handle scales them:
|
|
16
|
+
* the box of the points (the bounds less half the stroke's width on every side) maps onto the new
|
|
17
|
+
* box less the same margin, so that the stroke keeps its width and its bounds become the box.
|
|
18
|
+
* Along an axis the stroke has no extent on (a dot, a level or upright stroke), it sits in the
|
|
19
|
+
* middle of the box. Diagram coordinates in, diagram coordinates out.
|
|
20
|
+
*/
|
|
21
|
+
export function scalePenPoints(points, bounds, box, width) {
|
|
22
|
+
const from = inset(bounds, width / 2);
|
|
23
|
+
const to = inset(box, width / 2);
|
|
24
|
+
return points.map((p) => ({
|
|
25
|
+
x: mapped(p.x, from.x, from.width, to.x, to.width),
|
|
26
|
+
y: mapped(p.y, from.y, from.height, to.y, to.height),
|
|
27
|
+
}));
|
|
28
|
+
}
|
|
29
|
+
//# sourceMappingURL=pens.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"pens.js","sourceRoot":"","sources":["../../src/canvas/pens.ts"],"names":[],"mappings":"AAEA,gEAAgE;AAChE,SAAS,KAAK,CAAC,GAAQ,EAAE,MAAc;IACrC,OAAO;QACL,CAAC,EAAE,GAAG,CAAC,CAAC,GAAG,MAAM;QACjB,CAAC,EAAE,GAAG,CAAC,CAAC,GAAG,MAAM;QACjB,KAAK,EAAE,IAAI,CAAC,GAAG,CAAC,CAAC,EAAE,GAAG,CAAC,KAAK,GAAG,CAAC,GAAG,MAAM,CAAC;QAC1C,MAAM,EAAE,IAAI,CAAC,GAAG,CAAC,CAAC,EAAE,GAAG,CAAC,MAAM,GAAG,CAAC,GAAG,MAAM,CAAC;KAC7C,CAAC;AACJ,CAAC;AAED,0FAA0F;AAC1F,SAAS,MAAM,CAAC,KAAa,EAAE,IAAY,EAAE,IAAY,EAAE,EAAU,EAAE,MAAc;IACnF,OAAO,IAAI,GAAG,CAAC,CAAC,CAAC,CAAC,EAAE,GAAG,CAAC,CAAC,KAAK,GAAG,IAAI,CAAC,GAAG,MAAM,CAAC,GAAG,IAAI,CAAC,CAAC,CAAC,EAAE,GAAG,MAAM,GAAG,CAAC,CAAC;AAC5E,CAAC;AAED;;;;;;GAMG;AACH,MAAM,UAAU,cAAc,CAC5B,MAAwB,EACxB,MAAW,EACX,GAAQ,EACR,KAAa;IAEb,MAAM,IAAI,GAAG,KAA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