MCPcopy Create free account
hub / github.com/Easy-Editor/EasyEditor / open

Method open

packages/core/src/project/project.ts:183–212  ·  view source on GitHub ↗

* open or create a document

(idOrDoc?: string | Document | RootSchema)

Source from the content-addressed store, hash-verified

181 * open or create a document
182 */
183 open(idOrDoc?: string | Document | RootSchema) {
184 if (!idOrDoc) {
185 const got = this.documents.find(item => item.isBlank())
186 if (got) {
187 return got.open()
188 }
189 return this.createDocument().open()
190 }
191
192 if (typeof idOrDoc === 'string' || typeof idOrDoc === 'number') {
193 const got = this.documents.find(item => item.fileName === String(idOrDoc) || String(item.id) === String(idOrDoc))
194 if (got) {
195 return got.open()
196 }
197
198 const data = this.data.componentsTree.find(data => data.fileName === String(idOrDoc))
199 if (data) {
200 const doc = this.createDocument(data)
201 return doc.open()
202 }
203
204 return null
205 }
206 if (isDocument(idOrDoc)) {
207 return idOrDoc.open()
208 }
209
210 const newDoc = this.createDocument(idOrDoc)
211 return newDoc.open()
212 }
213
214 /**
215 * suspense other documents

Callers 4

loadMethod · 0.95
initMethod · 0.45
previewFunction · 0.45
previewFunction · 0.45

Calls 4

createDocumentMethod · 0.95
isDocumentFunction · 0.90
findMethod · 0.80
isBlankMethod · 0.80

Tested by

no test coverage detected