MCPcopy Create free account
hub / github.com/DeepNotesApp/DeepNotes / create

Method create

apps/client/src/code/pages/page/notes/notes.ts:117–158  ·  view source on GitHub ↗
(params: {
    region: PageRegion;
    worldPos?: Vec2;
    center?: boolean;
    destIndex?: number;
    edit?: boolean;
  })

Source from the content-addressed store, hash-verified

115 }
116
117 async create(params: {
118 region: PageRegion;
119 worldPos?: Vec2;
120 center?: boolean;
121 destIndex?: number;
122 edit?: boolean;
123 }) {
124 if (this.page.react.readOnly) {
125 return;
126 }
127
128 const note = this.page.app.serialization.deserialize(
129 internals.pages.defaultNote,
130 params.region,
131 params?.destIndex,
132 ).notes[0];
133
134 await nextTick();
135 await watchUntilTrue(() => note.react.loaded);
136
137 if (params.edit !== false) {
138 await this.page.editing.start(note);
139 }
140
141 note.react.collab.pos.x = params?.worldPos?.x ?? 0;
142 note.react.collab.pos.y = params?.worldPos?.y ?? 0;
143
144 if (params?.center !== false) {
145 const worldSize = note.getWorldRect('note-frame')?.size;
146
147 if (worldSize != null) {
148 const newPos = new Vec2(note.react.collab.pos).add(
149 worldSize.mul(new Vec2(note.react.collab.anchor).subScalar(0.5)),
150 );
151
152 note.react.collab.pos.x = newPos.x;
153 note.react.collab.pos.y = newPos.y;
154 }
155 }
156
157 return note;
158 }
159}

Callers 10

server.tsFile · 0.45
createCheckoutSessionFunction · 0.45
createPortalSessionFunction · 0.45
extensions.tsFile · 0.45
processFindsFunction · 0.45
task-item.tsFile · 0.45
extension.tsFile · 0.45
extension.tsFile · 0.45

Calls 7

watchUntilTrueFunction · 0.90
deserializeMethod · 0.80
mulMethod · 0.80
subScalarMethod · 0.80
startMethod · 0.45
getWorldRectMethod · 0.45
addMethod · 0.45

Tested by

no test coverage detected