oasis-editor 0.0.394 → 0.0.395

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.
@@ -15068,16 +15068,28 @@ while (n === s[++o] && n === s[++o] && n === s[++o] && n === s[++o] && n === s[+
15068
15068
  if ("STYLEREF" === t.command) {
15069
15069
  const e = r[0];
15070
15070
  if (!e || "quoted" !== e.kind && "word" !== e.kind || !e.value.trim() || e.value.length > 128 || /[\r\n\t\\]/.test(e.value)) return;
15071
- if (1 === r.length) return {
15071
+ let t, n = !1;
15072
+ for (const o of r.slice(1)) {
15073
+ if ("switch" !== o.kind) return;
15074
+ const e = o.value.toLowerCase();
15075
+ if ("l" === e) {
15076
+ if (n) return;
15077
+ n = !0;
15078
+ } else {
15079
+ if ("n" !== e && "p" !== e) return;
15080
+ if (t) return;
15081
+ t = "n" === e ? "number" : "position";
15082
+ }
15083
+ }
15084
+ return t ? {
15072
15085
  type: "STYLEREF",
15073
15086
  style: e.value,
15074
- lastOnPage: !1
15075
- };
15076
- if (2 !== r.length || "switch" !== r[1]?.kind || "l" !== r[1].value.toLowerCase()) return;
15077
- return {
15087
+ lastOnPage: n,
15088
+ output: t
15089
+ } : {
15078
15090
  type: "STYLEREF",
15079
15091
  style: e.value,
15080
- lastOnPage: !0
15092
+ lastOnPage: n
15081
15093
  };
15082
15094
  }
15083
15095
  if ("SEQ" === t.command) {
@@ -15179,7 +15191,7 @@ while (n === s[++o] && n === s[++o] && n === s[++o] && n === s[++o] && n === s[+
15179
15191
  kind: "style-text",
15180
15192
  name: e.style,
15181
15193
  lastOnPage: e.lastOnPage
15182
- }], o = t.styleRefText?.(e.style, e.lastOnPage);
15194
+ }], o = t.styleRefText?.(e.style, e.lastOnPage, e.output ?? "text");
15183
15195
  return "string" == typeof o && o.length > 0 ? {
15184
15196
  status: "resolved",
15185
15197
  text: o,
@@ -27,6 +27,7 @@ export type EvaluatableField = SequenceField | {
27
27
  type: "STYLEREF";
28
28
  style: string;
29
29
  lastOnPage: boolean;
30
+ output?: "number" | "position";
30
31
  };
31
32
  export type FieldDependency = {
32
33
  kind: "page" | "document-pages" | "section" | "section-pages";
@@ -58,7 +59,7 @@ export interface FieldEvaluationContext {
58
59
  bookmarkText?: (name: string) => string | null | undefined;
59
60
  bookmarkPage?: (name: string) => number | null | undefined;
60
61
  /** Exact resolved style text for a body occurrence or repeated page story. */
61
- styleRefText?: (name: string, lastOnPage: boolean) => string | undefined;
62
+ styleRefText?: (name: string, lastOnPage: boolean, output: "text" | "number" | "position") => string | undefined;
62
63
  }
63
64
  export interface TemporalFieldContext extends TemporalFormattingOptions {
64
65
  now?: number;
@@ -1,8 +1,15 @@
1
1
  import { EditorDocument, EditorLayoutDocument } from '../model.js';
2
+ export type StyleRefOutput = "text" | "number" | "position";
3
+ export interface StyleRefOptions {
4
+ output?: StyleRefOutput;
5
+ offset?: number;
6
+ zone?: "header" | "footer";
7
+ locale?: "en-US" | "pt-BR";
8
+ }
2
9
  /** Read-only lookup of paragraph styles and source-certified paginated text.
3
10
  * No DOM, layout mutations, speculative style inheritance, or evaluation of
4
11
  * a nested field's cached output. Duplicate style names remain ambiguous. */
5
12
  export declare function createStyleRefIndex(document: EditorDocument, layout?: EditorLayoutDocument): {
6
- forBody: (paragraphId: string, name: string, _lastOnPage?: boolean) => string | undefined;
7
- forPage: (pageIndex: number, name: string, lastOnPage?: boolean) => string | undefined;
13
+ forBody: (paragraphId: string, name: string, lastOnPage?: boolean, opts?: StyleRefOptions) => string | undefined;
14
+ forPage: (pageIndex: number, name: string, lastOnPage?: boolean, opts?: StyleRefOptions) => string | undefined;
8
15
  };