File tree Expand file tree Collapse file tree 3 files changed +12
-0
lines changed
Expand file tree Collapse file tree 3 files changed +12
-0
lines changed Original file line number Diff line number Diff 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 ( ) {
Original file line number Diff line number Diff 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
Original file line number Diff line number Diff 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 /**
You can’t perform that action at this time.
0 commit comments