@@ -18,8 +18,11 @@ function EverythingCanvas({
1818 autoFocus,
1919 hideUi,
2020 initialSnapshot,
21- plugins, // we could replace showAction, pass plugins to action button
2221} ) {
22+ const parts = persistance . split ( "/" ) ;
23+ const creatorId = parts [ 0 ] ;
24+
25+
2326 const [ store ] = useState ( ( ) => {
2427 if ( initialSnapshot ) {
2528 const newStore = createTLStore ( {
@@ -33,10 +36,34 @@ function EverythingCanvas({
3336 } ) ;
3437
3538 const setAppToState = useCallback ( ( editor ) => {
36- // Do something
37- // Once the canvas mounts
38- // Can we set widget on top of canvas
39- } , [ ] ) ;
39+ editor . user . updateUserPreferences ( {
40+ id : creatorId ,
41+ } )
42+
43+ editor . getInitialMetaForShape = ( _shape ) => {
44+ return {
45+ createdBy : editor . user . getId ( ) ,
46+ createdAt : Date . now ( ) ,
47+ updatedBy : editor . user . getId ( ) ,
48+ updatedAt : Date . now ( ) ,
49+ } ;
50+ } ;
51+ // We can also use the sideEffects API to modify a shape before
52+ // its change is committed to the database. This will run for
53+ // all shapes whenever they are updated.
54+ // editor.sideEffects.registerBeforeChangeHandler(
55+ // "shape",
56+ // (record, _prev, source) => {
57+ // if (source !== "user") return record;
58+ // record.meta = {
59+ // ...record.meta,
60+ // updatedBy: editor.user.getId(),
61+ // updatedAt: Date.now(),
62+ // };
63+ // return record;
64+ // }
65+ // );
66+ } , [ creatorId ] ) ;
4067
4168 return (
4269 < div className = { "tldraw__editor" } >
@@ -58,7 +85,7 @@ function EverythingCanvas({
5885 autoFocus = { autoFocus ?? true }
5986 hideUi = { hideUi ?? false }
6087 >
61- < ActionButton plugins = { plugins } />
88+ < ActionButton />
6289 < TldrawLogo />
6390 </ Tldraw >
6491 </ div >
0 commit comments