@sobree/core 0.1.2 → 0.1.3

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.
@@ -1,4 +1,4 @@
1
- import { BreakRun, DrawingRun, InlineRun, RunProperties } from '../doc/types';
1
+ import { BreakRun, CommentRefRun, DrawingRun, FieldRun, FootnoteRefRun, HyperlinkRun, InlineRun, RunProperties, TabRun, TextRun } from '../doc/types';
2
2
  export interface DeltaOp {
3
3
  /** Text content (string) or embed (object literal). Y.Text differentiates by typeof. */
4
4
  insert: string | EmbedContent;
@@ -6,24 +6,19 @@ export interface DeltaOp {
6
6
  * no marks apply (Yjs preference: omit rather than set empty). */
7
7
  attributes?: Record<string, unknown>;
8
8
  }
9
- /** All non-text run kinds become embed objects in the delta. */
10
- export type EmbedContent = {
11
- __sobree: "break";
12
- type: BreakRun["type"];
13
- } | {
14
- __sobree: "tab";
15
- } | {
16
- __sobree: "field";
17
- instruction: string;
18
- cached?: string;
19
- } | {
20
- __sobree: "drawing";
21
- partPath: string;
22
- widthEmu: number;
23
- heightEmu: number;
24
- placement: DrawingRun["placement"];
25
- altText?: string;
9
+ /** Run kinds that travel as atomic embeds (everything except text,
10
+ * which is the Y.Text string itself, and hyperlink, which flattens to
11
+ * a `link` mark on its children). */
12
+ type EmbedRun = Exclude<InlineRun, TextRun | HyperlinkRun>;
13
+ /** An embed is the run itself, structurally: `kind` becomes the
14
+ * `__sobree` discriminator and `properties` move to the op's
15
+ * attributes. DERIVED from the AST type — a new field on any embed
16
+ * run kind is carried automatically; there is no per-field whitelist
17
+ * that could silently drop it. */
18
+ type EmbedOf<R extends EmbedRun> = Omit<R, "kind" | "properties"> & {
19
+ __sobree: R["kind"];
26
20
  };
21
+ export type EmbedContent = EmbedOf<BreakRun> | EmbedOf<TabRun> | EmbedOf<FieldRun> | EmbedOf<DrawingRun> | EmbedOf<FootnoteRefRun> | EmbedOf<CommentRefRun>;
27
22
  /** The `link` mark — stamped on every char inside a HyperlinkRun. */
28
23
  export interface LinkMark {
29
24
  href: string;
@@ -49,3 +44,4 @@ export declare function attrsToRunProps(attrs: Record<string, unknown> | undefin
49
44
  * Y.Text diff to detect cells that haven't changed.
50
45
  */
51
46
  export declare function deepEqual(a: unknown, b: unknown): boolean;
47
+ export {};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@sobree/core",
3
- "version": "0.1.2",
3
+ "version": "0.1.3",
4
4
  "publishConfig": {
5
5
  "access": "public"
6
6
  },