@pixerate/editor-svelte 0.8.1 → 0.9.0

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/index.d.ts CHANGED
@@ -1,5 +1,11 @@
1
1
  import type { Component } from "svelte";
2
- import type { Editor, Content, Extensions, EditorOptions, FocusPosition } from "@tiptap/core";
2
+ import type {
3
+ Editor,
4
+ Content,
5
+ Extensions,
6
+ EditorOptions,
7
+ FocusPosition,
8
+ } from "@tiptap/core";
3
9
  import type {
4
10
  Template,
5
11
  TemplateVersion,
@@ -96,8 +102,8 @@ import type {
96
102
  CellCoordinate,
97
103
  CellRange,
98
104
  CellData,
99
- SpreadsheetDataSource
100
- } from '@pixerate/editor';
105
+ SpreadsheetDataSource,
106
+ } from "@pixerate/editor";
101
107
 
102
108
  export interface SpreadsheetEditorProps {
103
109
  sheetState: ReturnType<typeof createReactiveSpreadsheet>;
@@ -107,8 +113,16 @@ export interface SpreadsheetEditorProps {
107
113
  class?: string;
108
114
  customCellRenderer?:
109
115
  | ((cell: CellData, col: SpreadsheetColumn, row: SpreadsheetRow) => any)
110
- | ((args: { cell: CellData; col: SpreadsheetColumn; row: SpreadsheetRow }) => any)
111
- | ((args: { row: SpreadsheetRow; col: SpreadsheetColumn; cell: CellData }) => any);
116
+ | ((args: {
117
+ cell: CellData;
118
+ col: SpreadsheetColumn;
119
+ row: SpreadsheetRow;
120
+ }) => any)
121
+ | ((args: {
122
+ row: SpreadsheetRow;
123
+ col: SpreadsheetColumn;
124
+ cell: CellData;
125
+ }) => any);
112
126
  onAddColumnClick?: () => void;
113
127
  onColumnHeaderClick?: (col: SpreadsheetColumn) => void;
114
128
  onColumnResize?: (colId: string, width: number) => void;
@@ -122,7 +136,9 @@ export interface FormulaBarProps {
122
136
  export declare const SpreadsheetEditor: Component<SpreadsheetEditorProps>;
123
137
  export declare const FormulaBar: Component<FormulaBarProps>;
124
138
 
125
- export declare function createReactiveSpreadsheet(options?: SpreadsheetControllerOptions): {
139
+ export declare function createReactiveSpreadsheet(
140
+ options?: SpreadsheetControllerOptions,
141
+ ): {
126
142
  readonly document: SpreadsheetDocument;
127
143
  readonly activeCell: CellCoordinate | null;
128
144
  readonly selectedRange: CellRange | null;
@@ -136,7 +152,7 @@ export declare function createReactiveSpreadsheet(options?: SpreadsheetControlle
136
152
  startEditing(row?: number, col?: number, initialVal?: string): void;
137
153
  commitEditing(val?: string): void;
138
154
  cancelEditing(): void;
139
- moveCursor(dir: 'up' | 'down' | 'left' | 'right', extend?: boolean): void;
155
+ moveCursor(dir: "up" | "down" | "left" | "right", extend?: boolean): void;
140
156
  insertColumn(index: number, config?: Partial<SpreadsheetColumn>): void;
141
157
  deleteColumn(colId: string): void;
142
158
  insertRow(index: number, config?: Partial<SpreadsheetRow>): void;
@@ -152,3 +168,47 @@ export declare function createReactiveSpreadsheet(options?: SpreadsheetControlle
152
168
  undo(): void;
153
169
  redo(): void;
154
170
  };
171
+
172
+ export interface NavigationGuardOptions {
173
+ isDirty: boolean;
174
+ enabled?: boolean;
175
+ onBlocked?: (url: string) => void;
176
+ }
177
+
178
+ export interface NavigationGuardActionReturn {
179
+ update(newOptions: NavigationGuardOptions): void;
180
+ destroy(): void;
181
+ }
182
+
183
+ export declare function navigationGuard(
184
+ node: HTMLElement,
185
+ options: NavigationGuardOptions,
186
+ ): NavigationGuardActionReturn;
187
+
188
+ export interface CreateNavigationGuardOptions {
189
+ isDirty: boolean | (() => boolean);
190
+ enabled?: boolean | (() => boolean);
191
+ onNavigate?: (url: string) => void;
192
+ onBlocked?: (url: string) => void;
193
+ }
194
+
195
+ export interface NavigationGuardManager {
196
+ readonly showConfirm: boolean;
197
+ setShowConfirm(show: boolean): void;
198
+ readonly pendingUrl: string | null;
199
+ intercept(url: string): boolean;
200
+ confirmLeave(): void;
201
+ cancelLeave(): void;
202
+ destroy(): void;
203
+ }
204
+
205
+ export declare function createNavigationGuard(
206
+ options: CreateNavigationGuardOptions,
207
+ ): NavigationGuardManager;
208
+
209
+ export {
210
+ DirtyTracker,
211
+ createDirtyTracker,
212
+ defaultIsEqual,
213
+ } from "@pixerate/editor";
214
+ export type { DirtyTrackerOptions } from "@pixerate/editor";