Skip to content

Commit bbc211c

Browse files
committed
Revert "remove getter for style from slate"
This reverts commit f764549.
1 parent f764549 commit bbc211c

File tree

3 files changed

+12
-0
lines changed

3 files changed

+12
-0
lines changed

src/client/initialize.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -229,6 +229,10 @@ export function initialize<T = {}>(): PluginInstance<T> {
229229
on('wb:plugin:style:update', callback);
230230
return () => off('wb:plugin:style:update', callback);
231231
},
232+
233+
getStyle() {
234+
return execPromise('wb:plugin:style:get');
235+
},
232236
},
233237

234238
destroy() {

src/react/hooks.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -257,6 +257,8 @@ export function usePluginStyle(): PluginStyle | undefined {
257257
const [style, setStyle] = useState<PluginStyle | undefined>(undefined);
258258

259259
useEffect(() => {
260+
// Request initial style data on mount and subscribe to updates
261+
void client.style.getStyle().then(setStyle);
260262
return client.style.subscribeToStyle(setStyle);
261263
}, [client]);
262264

src/types.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -364,6 +364,12 @@ export interface PluginInstance<T = any> {
364364
* @returns Unsubscriber function
365365
*/
366366
subscribeToStyle(callback: (style: PluginStyle) => void): () => void;
367+
368+
/**
369+
* Request current style from workbook
370+
* @returns Promise with current style
371+
*/
372+
getStyle(): Promise<PluginStyle>;
367373
};
368374

369375
/**

0 commit comments

Comments
 (0)