(doc?: string | IDocumentModel | IPublicTypeRootSchema)
| 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) => { |
no test coverage detected