synchro du labo (0bf0da65) : app.blade.php, README.md

This commit is contained in:
cloudion
2026-11-03 22:41:30 +00:00
parent f86b954014
commit fbf441c295
2 changed files with 222 additions and 2 deletions

View File

@@ -1,3 +1,21 @@
# ploxion-word # 📄 Word
PLOXION · Traitement de texte : documents à mise en forme riche (titres, listes, images), export HTML/PDF. Persisté sur ton compte. · fournit: document, texte, office, outil Traitement de texte : documents à mise en forme riche (titres, listes, images), export HTML/PDF. Persisté sur ton compte.
| | |
| --- | --- |
| id | `word` |
| fournit | `document` `texte` `office` `outil` |
| bions qu'il nomme | `jOSApps` `jOSBoxion` `jOSFiles` `jOSLive` |
| fichiers | `app.blade.php` |
| dans le labo | `resources/views/ploxions/word/` (dépôt `my_website2`) |
## Contribuer
- **Dans le xer** : https://labo.j0bot.ch/px/atelier?ploxion=word — prends-le, modifie-le, vois-le tourner, « ⧗ envoyer le tsoin ».
- **Dans VS Code** : `xb prendre word` (ou l'extension xerboxion › ⇩ Prendre), puis ⧗ Envoyer.
- Le chemin complet : https://labo.j0bot.ch/px/contribuer
Ce dépôt est un **miroir** du labo (synchronisé par `bin/ploxions-forge.mjs`, depuis le commit `0bf0da65`) : une modif se propose par un tsoin ou une branche du labo, pas directement ici.
© 2026 chill-tekk · ne pas nuire

202
app.blade.php Normal file
View File

@@ -0,0 +1,202 @@
{{-- PL0XI0N word 📄 — traitement de texte (le « Word » du xer). 100% client-side, ZÉRO CDN
(marche même sur l'onion). Documents persistés sur ton compte (jOSBoxion ns 'word' +
localStorage). Édition riche (contentEditable + execCommand), export HTML/impression PDF.
(25.09, docs/dev/33 § Créer des fichiers) LE CONTRAT « OUVRIR CE FICHIER » (jOSFiles.fichier) : ouvert avec un fichier du xerboxion
(au montage, ou déjà ouvert par le bus ploxion.word.cmd {cmd:'fichier', fichier:<jeton>}), Word le montre comme un document de plus
(⌗ dans la liste) et l'enregistre DANS CE FICHIER, au format du fichier : .wdoc = {name, html} · .html = le HTML · .txt / .md = le
texte. Un document-fichier ne va jamais dans la liste du compte (jOSBoxion word/docs) ni dans une session live : il vit dans son
fichier. Le HTML lu d'un fichier passe par la liste blanche jOSFiles.fichier.html (un fichier reçu d'un pote n'exécute rien).
(relecture adverse 25.09) Un .html que cette liste blanche ne garde pas ENTIER (une page complète, des classes, un formulaire…) est
montré en LECTURE SEULE : jamais réécrit en fragment filtré ; « ouvrir avec › Texte / Code » l'édite tel quel. --}}
<style>
.wd{display:flex;height:100%;min-height:0;background:var(--xr-bg,#0b1220);color:var(--xr-text,#e7f0ff);font-family:var(--xr-font-ui,system-ui)}
.wd *{box-sizing:border-box;-webkit-tap-highlight-color:transparent}
.wd__side{flex:0 0 210px;min-width:0;border-right:1px solid var(--xr-border,#22324f);background:var(--xr-surface,#0c1320);display:flex;flex-direction:column}
.wd__side h4{margin:0;padding:12px 13px;font-size:.82rem;color:var(--xr-accent,#3fe0d0);display:flex;align-items:center;gap:6px}
.wd__new{margin:0 10px 8px;cursor:pointer;border:none;border-radius:9px;background:var(--xr-accent,#3fe0d0);color:#08111b;font-weight:800;padding:9px;font-size:.82rem}
.wd__list{flex:1;min-height:0;overflow:auto;padding:0 8px 10px}
.wd__d{display:flex;align-items:center;gap:7px;padding:9px 10px;border-radius:9px;cursor:pointer;font-size:.84rem;color:var(--xr-text,#e7f0ff)}
.wd__d:hover{background:color-mix(in srgb,var(--xr-accent,#3fe0d0) 9%,transparent)}
.wd__d.on{background:color-mix(in srgb,var(--xr-accent,#3fe0d0) 16%,transparent)}
.wd__d .nm{flex:1;min-width:0;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}
.wd__d .x{opacity:.5;cursor:pointer} .wd__d .x:hover{opacity:1;color:#f99}
.wd__main{flex:1;min-width:0;display:flex;flex-direction:column}
.wd__tb{flex:0 0 auto;display:flex;flex-wrap:wrap;gap:3px;padding:7px 9px;border-bottom:1px solid var(--xr-border,#22324f);background:var(--xr-surface,#0c1320);align-items:center}
.wd__tb button,.wd__tb select{cursor:pointer;border:1px solid var(--xr-border,#22324f);background:var(--xr-bg,#0b1220);color:var(--xr-text,#e7f0ff);border-radius:7px;min-width:30px;height:30px;font-size:.85rem;padding:0 6px}
.wd__tb button:active{filter:brightness(1.3)} .wd__tb .sep{width:1px;height:20px;background:var(--xr-border,#22324f);margin:0 3px}
.wd__tb input[type=color]{width:30px;height:30px;padding:1px;border:1px solid var(--xr-border,#22324f);border-radius:7px;background:none;cursor:pointer}
.wd__title{flex:0 0 auto;padding:7px 12px;border-bottom:1px solid var(--xr-border,#22324f);background:var(--xr-bg,#0b1220)}
.wd__title input{width:100%;background:none;border:0;outline:none;color:var(--xr-text,#e7f0ff);font-size:1.05rem;font-weight:700}
.wd__scroll{flex:1;min-height:0;overflow:auto;padding:22px;display:flex;justify-content:center;background:#0a0f18}
.wd__page{width:min(820px,100%);min-height:100%;background:#fdfdfb;color:#1a1a1a;border-radius:6px;box-shadow:0 8px 30px rgba(0,0,0,.4);
padding:54px 60px;font-family:Georgia,'Times New Roman',serif;font-size:16px;line-height:1.6;outline:none}
.wd__page:empty:before{content:attr(data-ph);color:#aaa}
.wd__page img{max-width:100%}
.wd__st{font-size:.68rem;color:var(--xr-muted,#8aa0c0);margin-left:auto;padding-right:6px}
@media(max-width:768px){ .wd__side{flex-basis:0;display:none} .wd.showlist .wd__side{display:flex;flex-basis:100%} .wd.showlist .wd__main{display:none} .wd__page{padding:26px 22px} }
</style>
<script>
(function () {
"use strict";
var ID='word', NS='word', KEY='xb:word';
function ls(k,d){ try{ return JSON.parse(localStorage.getItem(k))||d; }catch(e){ return d; } }
function uid(){ return 'w'+Date.now().toString(36)+Math.floor(Math.random()*1e4).toString(36); }
function esc(s){ return (s==null?'':String(s)).replace(/[&<>"]/g,function(c){return {'&':'&amp;','<':'&lt;','>':'&gt;','"':'&quot;'}[c];}); }
function csrf(){return window.jOSb&&window.jOSb.csrf?window.jOSb.csrf():(function(){var m=document.querySelector('meta[name=csrf-token]');return m?(m.getAttribute('content')||m.content||''):'';})();}
// (relecture adverse 25.09) un document DISTANT (la session live) n'apporte jamais « fichier » ni « sale » (un collaborateur ne fait pas
// passer un document du compte pour un fichier : il ne s'enregistrerait plus, persist() jetait) et ne touche jamais un document-fichier d'ici
function distant(x){ if(!x||typeof x!=='object') return null; if(x.fichier||x.sale||x.lecture){ x=Object.assign({},x); delete x.fichier; delete x.sale; delete x.lecture; } return x; }
function mergeInto(arr, remote, auth){ var m={}; arr.forEach(function(x){m[x.id]=x;});
remote.forEach(function(x){ x=distant(x); if(!x||!x.id)return; var l=m[x.id]; if(l&&l.fichier) return; if(!l){arr.push(x);m[x.id]=x;} else if((x.m||0)>=(l.m||0)){ for(var k in x)l[k]=x[k]; } });
if(auth){ for(var i=arr.length-1;i>=0;i--){ if(!arr[i].fichier && !remote.some(function(x){return x.id===arr[i].id;})) arr.splice(i,1); } } } // un document-fichier n'est pas à la session
function describe(){
var docs = ls(KEY,[]);
return { v:1, id:ID, title:'Word', icon:'📄', items:[
{ p:1, kind:'stat', label:'documents', value:docs.length }
]};
}
function mount(container, ctx) {
var docs=ls(KEY,[]), cur=null, saveT=null, live=null;
var FX=window.jOSFiles&&window.jOSFiles.fichier, fx0=(FX&&FX.de)?FX.de(ID,ctx):null, offFx=null; // (25.09) le fichier confié au montage
container.classList.add('wd');
container.innerHTML =
'<div class="wd__side"><h4>📄 Documents</h4><button class="wd__new" data-new>+ nouveau</button><div class="wd__list" data-list></div></div>'
+ '<div class="wd__main">'
+ ' <div class="wd__tb" data-tb></div>'
+ ' <div class="wd__title"><input data-title placeholder="Document sans titre"></div>'
+ ' <div class="wd__scroll"><div class="wd__page" data-page contenteditable="true" data-ph="Écris ton document ici…"></div></div>'
+ '</div>';
var listEl=container.querySelector('[data-list]'), tbEl=container.querySelector('[data-tb]'),
titleEl=container.querySelector('[data-title]'), page=container.querySelector('[data-page]');
// toolbar
function cmd(c,v){ page.focus(); try{ document.execCommand(c,false,v); }catch(e){} schedule(); }
var TB=[
['B','<b>B</b>','bold'],['I','<i>I</i>','italic'],['U','<u>U</u>','underline'],['S','<s>S</s>','strikeThrough'],['sep'],
['H1','H1','h1'],['H2','H2','h2'],['P','P','p'],['sep'],
['•','• liste','insertUnorderedList'],['1.','1. liste','insertOrderedList'],['❝','citation','quote'],['sep'],
['⯇','gauche','justifyLeft'],['≡','centre','justifyCenter'],['⯈','droite','justifyRight'],['sep']
];
var tbHtml=TB.map(function(b){ if(b[0]==='sep') return '<span class="sep"></span>';
return '<button data-c="'+b[2]+'" title="'+esc(b[1])+'">'+b[0]+'</button>'; }).join('');
tbHtml+='<select data-size title="taille"><option value="">Taille</option><option value="2">petit</option><option value="3">normal</option><option value="5">grand</option><option value="7">énorme</option></select>';
tbHtml+='<input type="color" data-color title="couleur du texte" value="#1a1a1a">';
tbHtml+='<span class="sep"></span><button data-img title="image">🖼</button><button data-link title="lien">🔗</button><button data-clear title="effacer le format">⌫</button>';
tbHtml+='<span class="sep"></span><button data-fsopen title="ouvrir un fichier">📂</button><button data-fssave title="enregistrer sous">💾</button><button data-exp title="télécharger (.html)">⬇</button><button data-print title="imprimer / PDF">🖨</button>';
tbHtml+='<input type="file" accept="image/*" hidden data-file><span class="wd__st" data-st></span>';
tbEl.innerHTML=tbHtml;
tbEl.querySelectorAll('[data-c]').forEach(function(b){ b.onclick=function(){ var c=b.getAttribute('data-c');
if(c==='h1'||c==='h2'||c==='p'||c==='quote'){ cmd('formatBlock', c==='quote'?'blockquote':c); } else cmd(c); }; });
tbEl.querySelector('[data-size]').onchange=function(){ if(this.value) cmd('fontSize',this.value); this.value=''; };
tbEl.querySelector('[data-color]').oninput=function(){ cmd('foreColor',this.value); };
tbEl.querySelector('[data-clear]').onclick=function(){ cmd('removeFormat'); };
tbEl.querySelector('[data-link]').onclick=function(){ var u=prompt('URL du lien'); if(u) cmd('createLink',u); };
var fileIn=tbEl.querySelector('[data-file]');
tbEl.querySelector('[data-img]').onclick=function(){ fileIn.click(); };
fileIn.onchange=function(){ if(!fileIn.files||!fileIn.files[0]) return; var f=fileIn.files[0];
upload(f,function(url){ if(url) cmd('insertImage',url); }); fileIn.value=''; };
tbEl.querySelector('[data-exp]').onclick=function(){ if(!cur) return;
var html='<!doctype html><meta charset="utf-8"><title>'+esc(cur.name)+'</title><body style="font-family:Georgia,serif;max-width:800px;margin:40px auto;line-height:1.6">'+page.innerHTML+'</body>';
var a=document.createElement('a'); a.href='data:text/html;charset=utf-8,'+encodeURIComponent(html); a.download=(cur.name||'document')+'.html'; a.click(); };
tbEl.querySelector('[data-fssave]').onclick=function(){ if(!cur||!window.jOSFiles) return; window.jOSFiles.pick({mode:'save',ext:['wdoc'],name:(cur.name||'document')+'.wdoc'}).then(function(p){ if(p) window.jOSFiles.writeJSON(p,{name:cur.name,html:page.innerHTML}); }); };
tbEl.querySelector('[data-fsopen]').onclick=function(){ if(!window.jOSFiles) return; window.jOSFiles.pick({mode:'open',ext:['wdoc','html','txt','md']}).then(function(p){ if(!p) return; window.jOSFiles.readText(p).then(function(txt){ if(txt==null) return; var html=txt, name=p.split('/').pop();
if(/\.wdoc$/.test(p)){ try{ var o=JSON.parse(txt); html=o.html||''; name=o.name||name; }catch(e){} }
// (25.09) le HTML d'un fichier est une DONNÉE : la liste blanche (un .html piégé n'exécute rien) ; un .txt / .md reste du texte
var coupe=!!(FX&&FX.limite&&String(html).length>FX.limite); // (relecture adverse) relu coupé : la copie ne l'est pas en silence
html=/\.(wdoc|html?)$/i.test(p)?(FX&&FX.html?FX.html(html):esc(html)):texteEnHtml(txt);
var d={id:uid(),name:name,html:html,t:Date.now()}; docs.push(d); persist(); open(d.id); container.classList.remove('showlist'); if(coupe) statut('⚠ '+p.split('/').pop()+' : relu en partie (plus de 4 Mo) — ce document n\'en a qu\'une partie, le fichier reste intact'); }); }); };
tbEl.querySelector('[data-print]').onclick=function(){ var w=window.open('','_blank'); if(!w) return;
w.document.write('<!doctype html><meta charset="utf-8"><title>'+esc(cur.name)+'</title><body style="font-family:Georgia,serif;max-width:800px;margin:30px auto;line-height:1.6">'+page.innerHTML+'</body>'); w.document.close(); w.focus(); setTimeout(function(){ w.print(); },250); };
function upload(file,cb){ var fd=new FormData(); fd.append('file',file);
fetch('/share-media',{method:'POST',body:fd,headers:{'X-CSRF-TOKEN':csrf(),'X-Requested-With':'XMLHttpRequest'},credentials:'same-origin'})
.then(function(r){return r.ok?r.json():null;}).then(function(d){ if(d&&d.url){cb(d.url);return;} var rd=new FileReader(); rd.onload=function(){cb(rd.result);}; rd.readAsDataURL(file); })
.catch(function(){ var rd=new FileReader(); rd.onload=function(){cb(rd.result);}; rd.readAsDataURL(file); }); }
// (25.09) un document-fichier vit dans SON fichier : jamais dans la liste du compte ni dans la session live
function propres(){ return docs.filter(function(d){ return !d.fichier; }); }
function persist(){ var l=propres(); try{ localStorage.setItem(KEY,JSON.stringify(l)); }catch(e){}
try{ var b=window.jOSBoxion; if(b&&b.saveSoon) b.saveSoon(NS,'docs',l); }catch(e){}
if(live&&cur&&!cur.fichier) live.dirty('docs',cur);
docs.forEach(function(d){ if(d.fichier&&d.sale) ecrireFichier(d); }); }
// ── le contrat « ouvrir ce fichier » (jOSFiles.fichier) ──
function texteEnHtml(t){ return esc(String(t==null?'':t)).split(/\r?\n/).join('<br>'); }
function htmlEnTexte(html){ var b=null; try{ b=new DOMParser().parseFromString('<!doctype html><body>'+String(html||'')+'</body>','text/html').body; }catch(e){ b=null; } if(!b) return String(html||'');
var out=''; (function w(n){ for(var c=n.firstChild;c;c=c.nextSibling){ if(c.nodeType===3){ out+=c.nodeValue; continue; } if(c.nodeType!==1) continue; var t=c.tagName;
if(t==='BR'){ out+='\n'; continue; } var bloc=/^(P|DIV|LI|H[1-6]|BLOCKQUOTE|PRE|TR|UL|OL|TABLE)$/.test(t); if(bloc&&out&&!/\n$/.test(out)) out+='\n'; w(c); if(bloc&&!/\n$/.test(out)) out+='\n'; } })(b);
return sansInsecables(out.replace(/\n$/,'')); }
// (relecture adverse 25.09) contentEditable tape des U+00A0 pour garder une suite d'espaces, un retrait, une espace en fin de ligne :
// dans un .txt / .md ils redeviennent des espaces (le retrait d'un bloc de code markdown marche encore) ; une insécable isolée entre
// deux mots (« 10 € », « bonjour ! ») venue du fichier reste telle quelle
function sansInsecables(t){ return String(t).split('\n').map(function(l){ return l.replace(/[ \u00a0]{2,}/g,function(m){ return m.replace(/\u00a0/g,' '); }).replace(/^\u00a0+|\u00a0+$/g,function(m){ return m.replace(/\u00a0/g,' '); }); }).join('\n'); }
function statut(t){ var st=tbEl.querySelector('[data-st]'); if(st) st.textContent=t; }
function ecrireFichier(d){ if(!d||!d.fichier||!d.sale||d.lecture||typeof d.fichier.ecrire!=='function') return; d.sale=false; var h=d.fichier, x=h.ext;
// (relecture adverse) un .html s'écrit PASSÉ par la liste blanche : ce que Word ne garde pas (le collé d'une page web : classes, styles
// hors liste) ne rend jamais le fichier « pas entier » — rouvert, il resterait sinon en lecture seule
var c=x==='wdoc'?{name:d.name||'',html:d.html||''}:(x==='html'||x==='htm')?((FX&&FX.html)?FX.html(d.html||''):(d.html||'')):htmlEnTexte(d.html||'');
h.ecrire(c).then(function(ok){ if(!ok) d.sale=true; if(cur===d) statut(ok?'💾 '+h.nom:'⚠ '+h.nom+' pas enregistré'); }); }
// (relecture adverse 25.09) DÉJÀ OUVERT avec des changements en route (pas encore partis, ou un envoi en vol) : on le montre tel quel —
// relu à ce moment, le fichier dit encore l'avant : l'écran reculait et la frappe suivante effaçait la dernière du fichier
function enRoute(d){ return !!(d&&d.fichier&&(d.sale||(typeof d.fichier.occupe==='function'&&d.fichier.occupe()))); }
function dejaOuvert(h){ return docs.filter(function(x){ return x.fichier&&x.fichier.chemin===h.chemin; })[0]||null; }
function prendreFichier(h){ if(!h) return; var d0=dejaOuvert(h), avant=enRoute(d0);
if(avant){ open(d0.id); container.classList.remove('showlist'); statut('⌗ '+h.nom); return; }
statut('ouverture de '+h.nom+'…');
h.texte().then(function(txt){
var d1=dejaOuvert(h); if(enRoute(d1)){ open(d1.id); container.classList.remove('showlist'); statut('⌗ '+h.nom); return; }
if(txt==null){ statut('⚠ fichier introuvable : '+h.nom); return; }
var html='', name=h.tige, lecture=false;
if(h.ext==='wdoc'){ var o=null; try{ o=String(txt).trim()?JSON.parse(txt):{}; }catch(e){ o=null; }
if(!o||typeof o!=='object'||Array.isArray(o)){ statut('⚠ '+h.nom+' : pas un document Word (.wdoc)'); return; }
html=FX.html(typeof o.html==='string'?o.html:''); if(typeof o.name==='string'&&o.name.trim()) name=o.name.slice(0,120);
if(typeof o.html==='string'&&FX.limite&&o.html.length>FX.limite) lecture=true; } // (relecture adverse) relu COUPÉ (plus de 4 Mo de HTML : des photos en data:) : jamais réécrit coupé
else if(h.ext==='html'||h.ext==='htm'){ html=FX.html(txt); lecture=!!((FX.fidele&&!FX.fidele(txt))||(FX.limite&&String(txt).length>FX.limite)); }
else html=texteEnHtml(txt);
var d=docs.filter(function(x){ return x.fichier&&x.fichier.chemin===h.chemin; })[0];
if(d){ d.html=html; d.name=name; d.fichier=h; d.sale=false; d.lecture=lecture; } else { d={id:uid(),name:name,html:html,t:Date.now(),fichier:h,lecture:lecture}; docs.push(d); }
open(d.id); container.classList.remove('showlist'); statut(lecture?'🔒 '+h.nom+' : Word ne le garde pas entier (une page complète, ou trop lourd) — montré en lecture seule, le fichier reste intact'+(h.ext==='wdoc'?'':' (« ouvrir avec › Texte » pour l\'éditer tel quel)'):'⌗ '+h.nom);
}); }
function schedule(){ if(!cur) return; cur.html=page.innerHTML; cur.name=titleEl.value; cur.t=Date.now(); if(cur.fichier) cur.sale=true;
var st=tbEl.querySelector('[data-st]'); if(st) st.textContent='enregistré';
clearTimeout(saveT); saveT=setTimeout(function(){ persist(); },500); }
page.addEventListener('input', schedule);
titleEl.addEventListener('input', function(){ schedule(); renderList(); });
function renderList(){ listEl.innerHTML = docs.slice().sort(function(a,b){return (b.t||0)-(a.t||0);}).map(function(d){
return '<div class="wd__d'+(cur&&d.id===cur.id?' on':'')+'" data-id="'+esc(d.id)+'"'+(d.fichier?' title="'+esc(d.fichier.chemin)+'"':'')+'><span class="nm">'+(d.fichier?(d.lecture?'🔒 ':'⌗ '):'📄 ')+esc(d.name||'sans titre')+'</span><span class="x" data-del="'+d.id+'">✕</span></div>'; }).join('')
|| '<div style="padding:12px;color:var(--xr-muted,#8aa0c0);font-size:.82rem">Aucun document.</div>';
listEl.querySelectorAll('[data-id]').forEach(function(e){ e.onclick=function(ev){ if(ev.target.hasAttribute('data-del')) return; open(e.getAttribute('data-id')); container.classList.remove('showlist'); }; });
listEl.querySelectorAll('[data-del]').forEach(function(e){ e.onclick=function(ev){ ev.stopPropagation(); var id=e.getAttribute('data-del');
var dd=docs.filter(function(d){return d.id===id;})[0]; if(dd&&dd.fichier){ if(dd.sale) ecrireFichier(dd); } else if(live) live.remove('docs',id); // (relecture adverse) un document ⌗ fermé : sa dernière frappe part dans son fichier ; il n'est pas à la session
docs=docs.filter(function(d){return d.id!==id;}); persist(); if(cur&&cur.id===id){ cur=docs[0]||null; loadCur(); } renderList(); }; }); }
function open(id){ cur=docs.filter(function(d){return d.id===id;})[0]||null; loadCur(); renderList(); }
function loadCur(){ page.contentEditable=(cur&&cur.lecture)?'false':'true'; titleEl.readOnly=!!(cur&&cur.lecture); if(!cur){ titleEl.value=''; page.innerHTML=''; return; } titleEl.value=cur.name||''; page.innerHTML=cur.html||''; }
container.querySelector('[data-new]').onclick=function(){ var d={id:uid(),name:'',html:'',t:Date.now()}; docs.push(d); persist(); open(d.id); titleEl.focus(); container.classList.remove('showlist'); };
// sync compte (jOSBoxion) : remplace si le local est vide
try{ if(window.jOSBoxion&&window.jOSBoxion.load){ Promise.resolve(window.jOSBoxion.load(NS,'docs')).then(function(v){
if(Array.isArray(v)&&v.length&&!propres().length){ docs=v.concat(docs.filter(function(d){ return d.fichier; })); try{localStorage.setItem(KEY,JSON.stringify(v));}catch(e){} if(!cur){ open(v.slice().sort(function(a,b){return (b.t||0)-(a.t||0);})[0].id); } renderList(); }
}).catch(function(){}); } }catch(e){}
if(docs.length){ open(docs.slice().sort(function(a,b){return (b.t||0)-(a.t||0);})[0].id); } else if(!fx0) { container.querySelector('[data-new]').click(); }
renderList();
// (25.09) le fichier confié : au montage, puis (déjà ouvert) par le bus — un jeton, jamais un nom
if(fx0) prendreFichier(fx0);
if(FX&&FX.ecouter) offFx=FX.ecouter(ID, prendreFichier, ctx);
// ---- collab live ----
if(window.jOSLive){ live=window.jOSLive.session(NS,{ urlParam:'doc', busy:function(){ return document.activeElement===page||document.activeElement===titleEl; },
onRemote:function(cols,del,auth){ if(!cols.docs) return; mergeInto(docs,cols.docs,auth); try{localStorage.setItem(KEY,JSON.stringify(propres()));}catch(e){} /* (relecture adverse) jamais un document-fichier dans xb:word */
var focused=document.activeElement===page||document.activeElement===titleEl;
if(cur){ var fresh=docs.filter(function(d){return d.id===cur.id;})[0]; if(!fresh){ cur=docs[0]||null; loadCur(); } else if(fresh!==cur){ cur=fresh; if(!focused) loadCur(); } }
renderList(); } });
tbEl.appendChild(window.jOSLive.ui(live,{pxId:'word', seed:function(){ propres().forEach(function(d){ live.dirty('docs',d); }); }})); }
return { unmount:function(){ if(offFx) offFx(); if(live)live.off(); if(saveT){ clearTimeout(saveT); persist(); } container.classList.remove('wd'); container.innerHTML=''; } };
}
window.jOSApps=window.jOSApps||{};
window.jOSApps[ID]={ manifest:{ id:ID, name:'Word', icon:'📄' }, mount: mount, describe: describe };
})();
</script>