MCPcopy Index your code
hub / github.com/alibaba/lowcode-engine / open

Method open

packages/designer/src/project/project.ts:312–347  ·  view source on GitHub ↗
(doc?: string | IDocumentModel | IPublicTypeRootSchema)

Source from the content-addressed store, hash-verified

310 }
311
312 open(doc?: string | IDocumentModel | IPublicTypeRootSchema): IDocumentModel | null {
313 if (!doc) {
314 const got = this.documents.find((item) => item.isBlank());
315 if (got) {
316 return got.open();
317 }
318 doc = this.createDocument();
319 return doc.open();
320 }
321 if (typeof doc === 'string' || typeof doc === 'number') {
322 const got = this.documents.find((item) => item.fileName === String(doc) || String(item.id) === String(doc));
323 if (got) {
324 return got.open();
325 }
326
327 const data = this.data.componentsTree.find((data) => data.fileName === String(doc));
328 if (data) {
329 doc = this.createDocument(data);
330 return doc.open();
331 }
332
333 return null;
334 } else if (isDocumentModel(doc)) {
335 return doc.open();
336 }
337 // else if (isPageSchema(doc)) {
338 // 暂时注释掉,影响了 diff 功能
339 // const foundDoc = this.documents.find(curDoc => curDoc?.rootNode?.id && curDoc?.rootNode?.id === doc?.id);
340 // if (foundDoc) {
341 // foundDoc.remove();
342 // }
343 // }
344
345 doc = this.createDocument(doc);
346 return doc.open();
347 }
348
349 checkExclusive(activeDoc: DocumentModel) {
350 this.documents.forEach((doc) => {

Callers 1

loadMethod · 0.95

Calls 5

createDocumentMethod · 0.95
isDocumentModelFunction · 0.90
findMethod · 0.65
isBlankMethod · 0.65
openMethod · 0.65

Tested by

no test coverage detected