@sobree/core 0.1.33 → 0.1.35

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.
@@ -30,6 +30,19 @@ export interface InlineFramesContext {
30
30
  /** Theme colour palette (from `word/theme/theme1.xml`) so textbox /
31
31
  * shape fills declared as `<a:schemeClr>` resolve instead of vanishing. */
32
32
  theme?: ThemePalette;
33
+ /**
34
+ * Body content width in EMU (page width − left/right margins). Needed
35
+ * only to lay out a paragraph that holds MORE THAN ONE inline drawing
36
+ * (a tab-separated row of "Place Illustration here" boxes): the boxes
37
+ * are merged into one frame whose coordinate system IS the content
38
+ * column, so each box's x is a true fraction of the column. Absent ⇒
39
+ * single-drawing paragraphs only, no row layout.
40
+ */
41
+ contentWidthEmu?: number;
42
+ /** `<w:defaultTabStop>` in twips — the grid a `<w:tab>` advances to when
43
+ * the paragraph declares no explicit `<w:tabs>`. Drives the column
44
+ * positions of a multi-drawing row. Absent ⇒ Word's 720-twip default. */
45
+ defaultTabStopTwips?: number;
33
46
  }
34
47
  /**
35
48
  * One InlineFrame plus the source DOM nodes it came from.
@@ -0,0 +1,27 @@
1
+ /**
2
+ * Expand DrawingML PRESET geometries that a CSS box can't draw — arrows,
3
+ * callouts, and the like — into an SVG outline. Box-expressible presets
4
+ * (rect / ellipse / roundedRect / line) stay as geometry enums via
5
+ * `readGeometry`; this module only handles presets that genuinely need a
6
+ * path, and returns `null` for everything else so that fallback stands.
7
+ *
8
+ * The outline is emitted in the frame's OWN `widthEmu × heightEmu` box so
9
+ * the renderer's `preserveAspectRatio="none"` scale is 1:1 — a normalised
10
+ * square box would shear the arrowhead when the frame isn't square.
11
+ *
12
+ * Adjustment handles (`<a:avLst><a:gd name="adjN" fmla="val …"/>`) tune
13
+ * the shaft thickness and head length; absent ⇒ ECMA-376 factory
14
+ * defaults. Reading them keeps the shape faithful to the source instead
15
+ * of guessing proportions.
16
+ */
17
+ export interface PresetPath {
18
+ widthEmu: number;
19
+ heightEmu: number;
20
+ d: string;
21
+ }
22
+ /** Expand the shape's `<a:prstGeom>` into a path, or `null` when the
23
+ * preset is box-expressible / unmodelled (caller keeps `readGeometry`). */
24
+ export declare function expandPresetGeometry(wsp: Element, dims: {
25
+ widthEmu: number;
26
+ heightEmu: number;
27
+ }): PresetPath | null;
@@ -1,8 +1,10 @@
1
1
  import { FrameBorder } from '../../doc/types';
2
2
  import { ThemePalette } from './colors';
3
3
  /** Map `<a:prstGeom prst>` to the AST's preset geometry enum; unknown
4
- * presets fall back to `rect`. (Custom geometry is handled separately by
5
- * the anchored reader via `customGeometry`.) */
4
+ * presets fall back to `rect`. Only the box-expressible presets live
5
+ * here those a CSS rectangle (± border-radius) can draw. Presets that
6
+ * need a real outline (arrows, callouts) are expanded to an SVG path by
7
+ * `presetGeometry`, and `<a:custGeom>` by `customGeometry`. */
6
8
  export declare function readGeometry(wsp: Element): "rect" | "ellipse" | "roundedRect" | "line";
7
9
  /**
8
10
  * First `<a:solidFill>` directly inside the shape's `spPr` (wps or pic) —
@@ -0,0 +1,30 @@
1
+ import { Block } from '../../doc/types';
2
+ import { EditorContext } from '../context';
3
+ /** Clipboard MIME for a Sobree block payload. The `+json` suffix and the
4
+ * `web ` prefix browsers add for custom types both round-trip our reader. */
5
+ export declare const BLOCKS_MIME = "application/x-sobree-blocks+json";
6
+ /** Serialise blocks for the clipboard. */
7
+ export declare function serializeBlocks(blocks: readonly Block[]): string;
8
+ /** Parse a clipboard payload back to blocks, or `null` when the data isn't
9
+ * ours / is malformed (caller then falls back to plain-text paste). */
10
+ export declare function parseBlocks(data: string | undefined | null): Block[] | null;
11
+ /**
12
+ * The whole blocks a selection covers, or `null` when the selection isn't
13
+ * block-level (a caret, or a partial selection inside one block).
14
+ */
15
+ export declare function selectedWholeBlocks(ctx: EditorContext): Block[] | null;
16
+ /** `copy` handler: write the covered whole blocks, or let the browser run
17
+ * its default plain-text copy when none are covered. */
18
+ export declare function onCopy(ctx: EditorContext, e: ClipboardEvent): void;
19
+ /** `cut` handler: copy the covered whole blocks AND remove them (in
20
+ * track-changes mode `deleteBlock` marks them instead). A partial in-block
21
+ * selection falls through to the browser's default text cut. */
22
+ export declare function onCut(ctx: EditorContext, e: ClipboardEvent): void;
23
+ /**
24
+ * Paste handler hook for a structured block payload. Returns `true` when it
25
+ * consumed the event (block paste), `false` to let the normal text/image
26
+ * paste run. Inserts the pasted blocks after the caret's block, in order.
27
+ */
28
+ export declare function tryPasteBlocks(ctx: EditorContext, e: ClipboardEvent): boolean;
29
+ /** Insert `blocks` (deep-cloned, fresh ids) after the caret's block. */
30
+ export declare function pasteBlocksAfterCaret(ctx: EditorContext, blocks: readonly Block[]): void;