| 473 | |
| 474 | // Hidden warm-up DocEditor (creates DS session/cache) then destroys |
| 475 | async function warmDocServerOnce(cfg){ |
| 476 | let host = null, warmEditor = null; |
| 477 | try{ |
| 478 | host = document.createElement('div'); |
| 479 | host.id = 'oo-warm-' + Math.random().toString(36).slice(2); |
| 480 | Object.assign(host.style, { |
| 481 | position:'absolute', left:'-99999px', top:'0', width:'2px', height:'2px', overflow:'hidden' |
| 482 | }); |
| 483 | document.body.appendChild(host); |
| 484 | |
| 485 | const warmCfg = JSON.parse(JSON.stringify(cfg)); |
| 486 | warmCfg.events = Object.assign({}, warmCfg.events, { onAppReady(){}, onDocumentReady(){} }); |
| 487 | |
| 488 | warmEditor = new window.DocsAPI.DocEditor(host.id, warmCfg); |
| 489 | await new Promise(res => setTimeout(res, OO_WARM_MS)); |
| 490 | }catch (e) {} finally{ |
| 491 | try{ warmEditor?.destroyEditor?.(); }catch (e) {} |
| 492 | try{ host?.remove(); }catch (e) {} |
| 493 | } |
| 494 | } |
| 495 | |
| 496 | // Full-screen OO open with hidden warm-up EVERY click, then real editor |
| 497 | async function openOnlyOffice(fileName, folder, sourceId = ''){ |