oasis-editor 0.0.382 → 0.0.384

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 { EditorParagraphNode, EditorState, EditorTextRun } from '../model.js';
1
+ import { EditorParagraphNode, EditorPosition, EditorState, EditorTextRun } from '../model.js';
2
2
  export declare const hasFieldMarkers: (p: EditorParagraphNode) => boolean;
3
3
  /** The paragraph-local mutation gate deliberately remains conservative.
4
4
  * The story graph knows cross-paragraph topology, but mutation commands have
@@ -11,8 +11,19 @@ export declare function fieldRangeProtected(p: EditorParagraphNode, start: numbe
11
11
  /** Single-paragraph text edits, not structural edits. Closed caret boundaries
12
12
  * deliberately remain ambiguous; a nonempty range may abut a field but may
13
13
  * never remove a character within it or straddle an invisible field. */
14
- export declare function fieldInlineRangeProtected(state: EditorState, p: EditorParagraphNode, start: number, end: number): boolean;
14
+ export declare function fieldInlineRangeProtected(state: EditorState, p: EditorParagraphNode, start: number, end: number, affinity?: EditorPosition["fieldBoundaryAffinity"]): boolean;
15
15
  export declare function fieldInlineSelectionProtected(state: EditorState): boolean;
16
+ /** Affinity is deliberately opt-in, and only for an exact, valid raw
17
+ * collapsed position. Never infer it from normalized visible offsets. */
18
+ export declare function fieldInsertionProtected(state: EditorState): boolean;
19
+ /** Split only at an exterior position. A field's complete marker group
20
+ * travels to one side of the new paragraph break, never both. */
21
+ export declare function fieldParagraphSplitProtected(state: EditorState): boolean;
22
+ /** Remove an exterior paragraph break without reordering any run. The
23
+ * structural break itself has an unambiguous side relative to each group:
24
+ * after all controls in the left paragraph, before all in the right. */
25
+ export declare function fieldParagraphJoinProtected(state: EditorState, left: EditorParagraphNode, right: EditorParagraphNode): boolean;
26
+ export declare function fieldParagraphJoinAffinity(left: EditorParagraphNode, right: EditorParagraphNode): EditorPosition["fieldBoundaryAffinity"];
16
27
  export declare function hasUnresolvedFieldStory(state: EditorState): boolean;
17
28
  export declare function fieldSelectionProtected(state: EditorState): boolean;
18
29
  /** Rebuild a range without ever sending invisible controls to a text mapper.
@@ -1,11 +1,11 @@
1
- import { EditorParagraphNode, EditorTextRun } from '../model.js';
2
- export declare function insertRunsAtOffset(paragraph: EditorParagraphNode, offset: number, textRuns: EditorTextRun[]): EditorParagraphNode;
1
+ import { EditorParagraphNode, EditorPosition, EditorTextRun } from '../model.js';
2
+ export declare function insertRunsAtOffset(paragraph: EditorParagraphNode, offset: number, textRuns: EditorTextRun[], affinity?: EditorPosition["fieldBoundaryAffinity"]): EditorParagraphNode;
3
3
  /** Preserve the zero-width field stream during a single-paragraph insertion.
4
- * At ambiguous exact boundaries preserve marker order and insert after the
5
- * encountered markers (before subsequent visible text). General selection
4
+ * At exact boundaries the explicit affinity can place the insertion before all
5
+ * coincident markers; without it, retain the historical after-markers split. General selection
6
6
  * deletion, multi-paragraph splits and field-range semantics require a
7
7
  * story-aware field span model; this is not that model. */
8
- export declare function splitForFieldAdjacentInsertion(paragraph: EditorParagraphNode, offset: number): {
8
+ export declare function splitForFieldAdjacentInsertion(paragraph: EditorParagraphNode, offset: number, affinity?: EditorPosition["fieldBoundaryAffinity"]): {
9
9
  beforeRuns: EditorTextRun[];
10
10
  afterRuns: EditorTextRun[];
11
11
  };
@@ -26,7 +26,7 @@ export type { EditorState, ReviewDisplayMode } from './editorState.js';
26
26
  export { EDITOR_ASSET_REF_PREFIX } from './types/primitives.js';
27
27
  export { DEFAULT_TEXT_STYLE, DEFAULT_PARAGRAPH_STYLE, EFFECTIVE_TEXT_STYLE_DEFAULTS, EFFECTIVE_PARAGRAPH_STYLE_DEFAULTS, } from './styleDefaults.js';
28
28
  export { DEFAULT_EDITOR_PAGE_SETTINGS } from './pageGeometry.js';
29
- export { getParagraphText, getParagraphLength, getRunIndex, getRunStartOffset, paragraphOffsetToPosition, positionToParagraphOffset, } from './queries.js';
29
+ export { getParagraphText, getParagraphLength, getRunIndex, getRunStartOffset, paragraphOffsetToPosition, paragraphOffsetToFieldPosition, hasFieldBoundaryAtOffset, positionToParagraphOffset, } from './queries.js';
30
30
  export { textStyleMerger, paragraphStyleMerger, mergeTextStyles, mergeParagraphStyles, resolveDefaultParagraphStyleId, resolveNamedTextStyle, resolveNamedParagraphStyle, resolveEffectiveTextStyle, resolveEffectiveTextStyleForParagraph, resolveEffectiveParagraphStyle, } from './styleResolution.js';
31
31
  export type { StyleMerger, Mergeable } from './styleResolution.js';
32
32
  export { resolveImageSrc } from './assets.js';
@@ -6,3 +6,7 @@ export declare function getRunIndex(paragraph: EditorParagraphNode, runId: strin
6
6
  export declare function getRunStartOffset(paragraph: EditorParagraphNode, runId: string): number;
7
7
  export declare function paragraphOffsetToPosition(paragraph: EditorParagraphNode, paragraphOffset: number): EditorPosition;
8
8
  export declare function positionToParagraphOffset(paragraph: EditorParagraphNode, position: EditorPosition): number;
9
+ /** The visible offset of a group of zero-width OOXML field controls. */
10
+ export declare function hasFieldBoundaryAtOffset(paragraph: EditorParagraphNode, offset: number): boolean;
11
+ /** Affinity is meaningful only at an existing invisible control group. */
12
+ export declare function paragraphOffsetToFieldPosition(paragraph: EditorParagraphNode, offset: number, affinity?: EditorPosition["fieldBoundaryAffinity"]): EditorPosition;
@@ -6,6 +6,9 @@ export interface EditorPosition {
6
6
  paragraphId: string;
7
7
  runId: string;
8
8
  offset: number;
9
+ /** Explicit side of coincident invisible markers for plain-text insertion.
10
+ * Absent means the existing ambiguous-boundary protection applies. */
11
+ fieldBoundaryAffinity?: "before-markers" | "after-markers";
9
12
  }
10
13
  export interface EditorSelection {
11
14
  anchor: EditorPosition;
@@ -9,5 +9,9 @@ export declare function getFocusParagraph(state: EditorState): {
9
9
  };
10
10
  export declare function deleteSelectionRange(state: EditorState): EditorState;
11
11
  export declare function mapRunsInRange(paragraph: EditorParagraphNode, startOffset: number, endOffset: number, mapper: (run: EditorTextRun) => EditorTextRun): EditorParagraphNode;
12
+ /** Formatting callers with a story-aware selection gate may map an adjacent
13
+ * range in an otherwise unbalanced paragraph. Never rely on local markers:
14
+ * interior cached paragraphs of a multiparagraph field may have none. */
15
+ export declare function mapRunsInStoryRange(state: EditorState, paragraph: EditorParagraphNode, startOffset: number, endOffset: number, mapper: (run: EditorTextRun) => EditorTextRun): EditorParagraphNode;
12
16
  export declare function preserveSelectionByParagraphOffsets(paragraphs: EditorParagraphNode[], normalized: ReturnType<typeof normalizeSelection>): EditorSelection;
13
17
  export declare function collapseToBoundary(state: EditorState, direction: "start" | "end"): EditorState;