Move "Show on … too" to the foot of the relation menu
Docs / build (push) Canceled after 0s
Docs / deploy (push) Canceled after 0s
CI / go (Media) (push) Successful in 10m29s
CI / go (Server) (push) Failing after 18m53s
CI / go (Web-App) (push) Successful in 14m26s
CI / frontend (push) Failing after 7m47s
CI / desktop (ubuntu-latest) (push) Failing after 1h24m30s
CI / desktop (macos-latest) (push) Canceled after 0s
CI / desktop (windows-latest) (push) Canceled after 0s
CI / mobile (push) Failing after 5m42s
CI / docker (push) Successful in 1h11m11s

It sat between the lists of databases and read like one of them. It is
now a "+" action below the page search, like other add buttons.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
tajniak81andClaude Opus 5.5 committed 2026-11-16 20:11:40 +01:00
1 parent 68c14e116d
commit 7fa5df53e5
2 files changed
+20 -15

No files matched your search

+1 -1
View File
@@ -161,7 +161,7 @@ img.ProseMirror-separator {
`);return{...c,raw:u}}},addCommands(){return{insertTable:({rows:e=3,cols:t=3,withHeaderRow:n=!0}={})=>({tr:r,dispatch:i,editor:a})=>{let o=fP(a.schema,e,t,n);if(i){let e=r.selection.from+1;r.replaceSelectionWith(o).scrollIntoView().setSelection(T.near(r.doc.resolve(e)))}return!0},addColumnBefore:()=>({state:e,dispatch:t})=>VM(e,t),addColumnAfter:()=>({state:e,dispatch:t})=>HM(e,t),deleteColumn:()=>({state:e,dispatch:t})=>{let n=vu(e.selection.$from,e=>e.type.name===`table`);return WM(e,t&&(e=>{n&&hP(e,n.pos),t(e)}))},addRowBefore:()=>({state:e,dispatch:t})=>qM(e,t),addRowAfter:()=>({state:e,dispatch:t})=>JM(e,t),deleteRow:()=>({state:e,dispatch:t})=>{let n=vu(e.selection.$from,e=>e.type.name===`table`);return XM(e,t&&(e=>{n&&hP(e,n.pos),t(e)}))},deleteTable:()=>({state:e,dispatch:t})=>lN(e,t),mergeCells:()=>({state:e,dispatch:t})=>$M(e,t),splitCell:()=>({state:e,dispatch:t})=>eN(e,t),toggleHeaderColumn:()=>({state:e,dispatch:t})=>aN(`column`)(e,t),toggleHeaderRow:()=>({state:e,dispatch:t})=>aN(`row`)(e,t),toggleHeaderCell:()=>({state:e,dispatch:t})=>oN(e,t),mergeOrSplit:()=>({state:e,dispatch:t})=>$M(e,t)?!0:eN(e,t),setCellAttribute:(e,t)=>({state:n,dispatch:r})=>nN(e,t)(n,r),goToNextCell:()=>({state:e,dispatch:t})=>cN(1)(e,t),goToPreviousCell:()=>({state:e,dispatch:t})=>cN(-1)(e,t),fixTables:()=>({state:e,dispatch:t})=>(t&&LM(e),!0),setCellSelection:e=>({tr:t,dispatch:n})=>{if(n){let n=kM.create(t.doc,e.anchorCell,e.headCell);t.setSelection(n)}return!0}}},addKeyboardShortcuts(){return{Tab:()=>this.editor.commands.goToNextCell()?!0:this.editor.can().addRowAfter()?this.editor.chain().addRowAfter().goToNextCell().run():!1,"Shift-Tab":()=>this.editor.commands.goToPreviousCell(),Backspace:mP,"Mod-Backspace":mP,Delete:mP,"Mod-Delete":mP}},addProseMirrorPlugins(){return[...this.options.resizable&&this.editor.isEditable?[MN({handleWidth:this.options.handleWidth,cellMinWidth:this.options.cellMinWidth,defaultCellMinWidth:this.options.cellMinWidth,View:null,lastColumnResizable:this.options.lastColumnResizable})]:[],KN({allowTableNodeSelection:this.options.allowTableNodeSelection}),TP()]},addNodeView(){let e=this.options.View;return e?({node:t,view:n,HTMLAttributes:r})=>{let i=A(this.options.HTMLAttributes,r);return new e(t,this.options.cellMinWidth,n,i)}:null},extendNodeSchema(e){return{tableRole:Nu(k(e,`tableRole`,{name:e.name,options:e.options,storage:e.storage}))}}}),DP=Tp.create({name:`tableKit`,addExtensions(){let e=[];return this.options.table!==!1&&e.push(EP.configure(this.options.table)),this.options.tableCell!==!1&&e.push(rP.configure(this.options.tableCell)),this.options.tableHeader!==!1&&e.push(iP.configure(this.options.tableHeader)),this.options.tableRow!==!1&&e.push(aP.configure(this.options.tableRow)),e}}),OP=Tp.create({name:`textAlign`,addOptions(){return{types:[],alignments:[`left`,`center`,`right`,`justify`],defaultAlignment:null}},addGlobalAttributes(){return[{types:this.options.types,attributes:{textAlign:{default:this.options.defaultAlignment,parseHTML:e=>{let t=e.style.textAlign;return this.options.alignments.includes(t)?t:this.options.defaultAlignment},renderHTML:e=>!Pf(e.textAlign)||!this.options.alignments.includes(e.textAlign)?{}:{style:`text-align: ${e.textAlign}`}}}}]},addCommands(){return{setTextAlign:e=>({commands:t})=>this.options.alignments.includes(e)?this.options.types.map(n=>t.updateAttributes(n,{textAlign:e})).some(e=>e):!1,unsetTextAlign:()=>({commands:e})=>this.options.types.map(t=>e.resetAttributes(t,`textAlign`)).some(e=>e),toggleTextAlign:e=>({editor:t,commands:n})=>this.options.alignments.includes(e)?t.isActive({textAlign:e})?n.unsetTextAlign():n.setTextAlign(e):!1}},addKeyboardShortcuts(){return{"Mod-Shift-l":()=>this.editor.commands.setTextAlign(`left`),"Mod-Shift-e":()=>this.editor.commands.setTextAlign(`center`),"Mod-Shift-r":()=>this.editor.commands.setTextAlign(`right`),"Mod-Shift-j":()=>this.editor.commands.setTextAlign(`justify`)}}});function kP(){return[Bk.configure({HTMLAttributes:{class:`dw-tasks`}}),zk.configure({nested:!0})]}function AP(){return[DP.configure({table:{resizable:!0,cellMinWidth:60,HTMLAttributes:{class:`dw-table`}}})]}var jP=OP.configure({types:[`heading`,`paragraph`],alignments:[`left`,`center`,`right`]}),MP=Tp.create({name:`headingShortcuts`,addKeyboardShortcuts(){let e={"Mod-Shift-0":()=>this.editor.commands.setParagraph()};for(let t of[1,2,3,4,5,6])e[`Mod-Shift-${t}`]=()=>this.editor.commands.toggleHeading({level:t});return e}}),NP=/(?:^|\s)(==(?!\s+==)((?:[^=]+))==(?!\s+==))$/,PP=/(?:^|\s)(==(?!\s+==)((?:[^=]+))==(?!\s+==))/g,FP=_p.create({name:`highlight`,addOptions(){return{multicolor:!1,HTMLAttributes:{}}},addAttributes(){return this.options.multicolor?{color:{default:null,parseHTML:e=>e.getAttribute(`data-color`)||Af(e,`background-color`)||e.style.backgroundColor,renderHTML:e=>Pf(e.color)?{"data-color":e.color,style:`background-color: ${e.color}; color: inherit`}:{}}}:{}},parseHTML(){return[{tag:`mark`}]},renderHTML({HTMLAttributes:e}){retuLine truncated
`)){if(!o){a.push(``);continue}let e=``;for(let s of o.split(/(\s+)/)){let o=e+s;if(!e||$F(o,t,r,i)<=n)e=o;else for(a.push(e.trimEnd()),e=s.trimStart();e&&$F(e,t,r,i)>n;){let o=e.length-1;for(;o>1&&$F(e.slice(0,o),t,r,i)>n;)o--;a.push(e.slice(0,o)),e=e.slice(o)}}a.push(e)}return a}function tI(e,t){let n=t===0?18:15,r=t===0?600:400,i=eI(e||` `,n,260,YF,r),a=Math.max(...i.map(e=>$F(e,n,YF,r)),t===0?60:40);return{w:Math.ceil(a)+(t===0?32:24),h:i.length*Math.round(n*1.4)+(t===0?20:14)}}var nI=56,rI=14;function iI(e){let t=Object.entries(e).filter(([,t])=>!t.parent||!e[t.parent]);return t.sort((e,t)=>e[1].pos-t[1].pos||(e[0]<t[0]?-1:1)),t[0]?.[0]??null}function aI(e,t){return Object.entries(e).filter(([e,n])=>n.parent===t&&e!==t).sort((e,t)=>e[1].pos-t[1].pos||(e[0]<t[0]?-1:1)).map(([e])=>e)}function oI(e,t,n){let r=iI(e),i=new Map,a=[];if(!r)return{root:``,boxes:i,edges:a,bounds:{x:0,y:0,w:0,h:0}};let o=new Map,s=new Set,c=(t,r)=>{if(!(s.has(t)||r>50)){s.add(t),o.set(t,n(e[t].text,r));for(let n of aI(e,t))c(n,r+1)}};c(r,0);let l=t=>aI(e,t).filter(e=>o.has(e)),u=new Map,d=e=>{let t=u.get(e);if(t!==void 0)return t;let n=l(e),r=n.reduce((e,t)=>e+d(t),0)+rI*Math.max(0,n.length-1),i=Math.max(o.get(e).h,r);return u.set(e,i),i},f=(e,t,n,r,a,s)=>{let c=o.get(e),u=a===1?t:t-c.w;i.set(e,{id:e,x:u,y:n-c.h/2,w:c.w,h:c.h,depth:r,dir:a,parent:s}),p(e,l(e),a===1?u+c.w+nI:u-nI,n,r+1,a)},p=(e,t,n,r,i,a)=>{let o=r-(t.reduce((e,t)=>e+d(t),0)+rI*Math.max(0,t.length-1))/2;for(let r of t){let t=d(r);f(r,n,o+t/2,i,a,e),o+=t+rI}},m=o.get(r);i.set(r,{id:r,x:0,y:0,w:m.w,h:m.h,depth:0,dir:1,parent:``});let h=m.h/2,g=l(r);if(t===`right`)p(r,g,m.w+nI,h,1,1);else if(t===`left`)p(r,g,-56,h,1,-1);else{let e=Math.ceil(g.length/2);p(r,g.slice(0,e),m.w+nI,h,1,1),p(r,g.slice(e),-56,h,1,-1)}for(let e of i.values()){if(!e.parent)continue;let t=i.get(e.parent),n=e.dir===1?[t.x+t.w,t.y+t.h/2]:[t.x,t.y+t.h/2],r=e.dir===1?[e.x,e.y+e.h/2]:[e.x+e.w,e.y+e.h/2];a.push({from:n,to:r,child:e.id})}let _=1/0,v=1/0,y=-1/0,b=-1/0;for(let e of i.values())_=Math.min(_,e.x),v=Math.min(v,e.y),y=Math.max(y,e.x+e.w),b=Math.max(b,e.y+e.h);return{root:r,boxes:i,edges:a,bounds:{x:_,y:v,w:y-_,h:b-v}}}function sI(e,t,n,r){let i=e.boxes.get(n);if(!i)return null;if(r===`ArrowUp`||r===`ArrowDown`){let a=i.parent?aI(t,i.parent).filter(t=>e.boxes.get(t)?.dir===i.dir):[];return a[a.indexOf(n)+(r===`ArrowUp`?-1:1)]??null}let a=r===`ArrowRight`?1:-1;return i.parent?a===i.dir?aI(t,n)[0]??null:i.parent:aI(t,n).find(t=>e.boxes.get(t)?.dir===a)??null}function cI(e,t){let n=(e[0]+t[0])/2;return`M${e[0]} ${e[1]} C${n} ${e[1]} ${n} ${t[1]} ${t[0]} ${t[1]}`}function lI(e,t,n,r=e=>e){return e*r(.5-t*(.5-n))}function uI(e){return[-e[0],-e[1]]}function dI(e,t){return[e[0]+t[0],e[1]+t[1]]}function fI(e,t){return[e[0]-t[0],e[1]-t[1]]}function pI(e,t){return[e[0]*t,e[1]*t]}function mI(e,t){return[e[0]/t,e[1]/t]}function hI(e){return[e[1],-e[0]]}function gI(e,t){return e[0]*t[0]+e[1]*t[1]}function _I(e,t){return e[0]===t[0]&&e[1]===t[1]}function vI(e){return Math.hypot(e[0],e[1])}function yI(e){return e[0]*e[0]+e[1]*e[1]}function bI(e,t){return yI(fI(e,t))}function xI(e){return mI(e,vI(e))}function SI(e,t){return Math.hypot(e[1]-t[1],e[0]-t[0])}function CI(e,t,n){let r=Math.sin(n),i=Math.cos(n),a=e[0]-t[0],o=e[1]-t[1],s=a*i-o*r,c=a*r+o*i;return[s+t[0],c+t[1]]}function wI(e,t,n){return dI(e,pI(fI(t,e),n))}function TI(e,t,n){return dI(e,pI(t,n))}var{min:EI,PI:DI}=Math,OI=.275,kI=DI+1e-4;function AI(e,t={}){let{size:n=16,smoothing:r=.5,thinning:i=.5,simulatePressure:a=!0,easing:o=e=>e,start:s={},end:c={},last:l=!1}=t,{cap:u=!0,easing:d=e=>e*(2-e)}=s,{cap:f=!0,easing:p=e=>--e*e*e+1}=c;if(e.length===0||n<=0)return[];let m=e[e.length-1].runningLength,h=s.taper===!1?0:s.taper===!0?Math.max(n,m):s.taper,g=c.taper===!1?0:c.taper===!0?Math.max(n,m):c.taper,_=(n*r)**2,v=[],y=[],b=e.slice(0,10).reduce((e,t)=>{let r=t.pressure;if(a){let i=EI(1,t.distance/n);r=EI(1,e+(EI(1,1-i)-e)*(i*OI))}return(e+r)/2},e[0].pressure),x=lI(n,i,e[e.length-1].pressure,o),S,C=e[0].vector,ee=e[0].point,te=ee,ne=ee,re=te,ie=!1;for(let t=0;t<e.length;t++){let{pressure:r}=e[t],{point:s,vector:c,distance:l,runningLength:u}=e[t];if(t<e.length-1&&m-u<3)continue;if(i){if(a){let e=EI(1,l/n),t=EI(1,1-e);r=EI(1,b+(t-b)*(e*OI))}x=lI(n,i,r,o)}else x=n/2;S===void 0&&(S=x);let f=u<h?d(u/h):1,ae=m-u<g?p((m-u)/g):1;x=Math.max(.01,x*Math.min(f,ae));let oe=(t<e.length-1?e[t+1]:e[t]).vector,se=t<e.length-1?gI(c,oe):1,ce=gI(c,C)<0&&!ie,le=se!==null&&se<0;if(ce||le){let e=pI(hI(C),x);for(let t=0;t<=1;t+=.07692307692307693)ne=CI(fI(s,e),s,kI*t),v.push(ne),re=CI(dI(s,e),s,kI*-t),y.push(re);ee=ne,te=re,le&&(ie=!0);continue}if(ie=!1,t===e.length-1){let e=pI(hI(c),x);v.push(fI(s,e)),y.push(dI(s,e));continue}let ue=pI(hI(wI(oe,c,se)),x);ne=fI(s,ue),(t<=1||bI(ee,ne)>_)&&(v.push(ne),ee=ne),re=dI(s,ue),(t<=1||bI(te,re)>_)&&(y.push(re),te=re),b=r,C=c}let ae=e[0].point.slice(0,2),oe=e.length>1?e[e.length-1].point.slice(0,2):dI(e[0].point,[1,1]),se=[],ce=[];if(eLine truncated
`:n(e)).join(``),r=(e,i)=>{for(let a of e)if(a.type===`heading`){let e=Number(a.attrs?.level)||1;t.push({text:n(a),size:[0,26,21,18,16,16,16][e]??16,weight:650})}else if(a.type===`paragraph`)t.push({text:i+n(a),size:15,weight:400});else if(a.type===`listItem`||a.type===`taskItem`){let e=a.type===`taskItem`?a.attrs?.checked?`☑ `:`☐ `:`• `,[i,...o]=a.content??[];i&&t.push({text:e+n(i),size:15,weight:400}),r(o,` `)}else a.type===`codeBlock`?t.push({text:n(a),size:13,weight:400}):a.content?.length&&r(a.content,i)};return r(e,``),t}function mR(e,t,n,r,i,a,o=400,s=`start`){let c=Math.round(r*1.35);return n.map((n,l)=>`<text x="${e}" y="${t+r+l*c}" font-size="${r}" font-family="${LL(a)}" font-weight="${o}" fill="${i}" text-anchor="${s}" xml:space="preserve">${LL(n)}</text>`).join(``)}async function hR(e){if(e.startsWith(`data:`))return e;try{let t=await fetch(e,{credentials:`include`});if(!t.ok)return null;let n=await t.blob();return await new Promise(e=>{let t=new FileReader;t.onload=()=>e(typeof t.result==`string`?t.result:null),t.onerror=()=>e(null),t.readAsDataURL(n)})}catch{return null}}async function gR(e){let t=fR(e.root),n=e.elements.filter(e=>e.type!==`group`),r=GP(WP(n.map(t=>e.boxOf(t)))??{x:0,y:0,w:400,h:300},32),i=t(`ink`,`line`),a=[];for(let r of n){let n=e.boxOf(r),o=r.rotate?` rotate(${r.rotate} ${n.w/2} ${n.h/2})`:``,s=e=>`<g transform="translate(${n.x} ${n.y})${o}">${e}</g>`;switch(r.type){case`shape`:{let e=eI(r.text,r.fontSize,Math.max(20,n.w-16)),i=Math.round(r.fontSize*1.35),o=n.h/2-e.length*i/2-r.fontSize*.25;a.push(s(GL(r,t)+(r.text?mR(n.w/2,o,e,r.fontSize,t(r.textColor,`line`),YF,400,`middle`):``)));break}case`text`:{let e=QF(r.font),i=r.w?eI(r.text,r.fontSize,r.w,e):r.text.split(`
`),o=r.align===`center`?n.w/2:r.align===`right`?n.w:0,c=r.align===`center`?`middle`:r.align===`right`?`end`:`start`;a.push(s(mR(o,0,i,r.fontSize,t(r.color,`line`),e,r.bold?650:400,c)));break}case`connector`:{let n=e.routeOf(r);if(a.push(qL(r,n,t)),r.label){let e=Math.min(240,r.label.length*8+16);a.push(`<rect x="${n.mid[0]-e/2}" y="${n.mid[1]-12}" width="${e}" height="24" rx="4" fill="${t(`paper`,`line`)}"/>`+mR(n.mid[0],n.mid[1]-12+3,[r.label],13,i,YF,400,`middle`))}break}case`brush`:a.push(s(YL(r,t)));break;case`frame`:a.push(s(`<rect width="${n.w}" height="${n.h}" rx="8" fill="${t(r.background,`fill`)===`none`?`none`:t(r.background,`fill`)}" stroke="${t(`gray`,`line`)}" stroke-width="1.5"/>`+mR(4,-24,[r.title],13,t(`gray`,`line`),YF,600)));break;case`note`:{let o=e.noteBody(r),c=o?pR(XL(o)):[],l=18,u=`<rect width="${n.w}" height="${n.h}" rx="8" fill="${t(r.background,`fill`)}" stroke="${t(`gray`,`fill`)}"/>`;if(r.page&&e.pageTitle){let t=eI(e.pageTitle,26,n.w-48,YF,650);u+=mR(24,l-4,t,26,i,YF,650),l+=t.length*35+8}for(let e of c){let t=eI(e.text,e.size,n.w-48,YF,e.weight);if(u+=mR(24,l,t,e.size,i,YF,e.weight),l+=t.length*Math.round(e.size*1.35)+8,l>n.h-12)break}a.push(s(u));break}case`image`:{let i=await hR(e.resolve(r.src));a.push(s(i?`<image href="${LL(i)}" width="${n.w}" height="${n.h}" preserveAspectRatio="xMidYMid meet"/>`:`<rect width="${n.w}" height="${n.h}" fill="${t(`ink`,`fill`)}"/>`));break}case`embed`:a.push(s(`<rect width="${n.w}" height="${n.h}" rx="8" fill="${t(`paper`,`fill`)}" stroke="${t(`gray`,`fill`)}"/>`+mR(16,16,eI(r.url,13,n.w-32),13,t(`blue`,`line`),YF)));break;case`mindmap`:{let n=e.layoutOf(r),o=t(r.color,`line`),s=t(r.color,`fill`),c=n.edges.map(e=>`<path d="${cI(e.from,e.to)}" fill="none" stroke="${o}" stroke-width="2"/>`).join(``);for(let e of n.boxes.values()){let n=e.depth===0?18:15,a=e.depth===0?600:400,l=e.depth===0?o:e.depth===1?s:t(`paper`,`line`),u=e.depth===0?t(`paper`,`line`):i;c+=`<rect x="${e.x}" y="${e.y}" width="${e.w}" height="${e.h}" rx="${e.depth===0?10:8}" fill="${l}" stroke="${o}" stroke-width="${e.depth===0?0:1.5}"/>`;let d=eI(r.nodes[e.id]?.text||` `,n,260,YF,a);c+=mR(e.x+e.w/2,e.y+(e.h-d.length*Math.round(n*1.4))/2-2,d,n,u,YF,a,`middle`)}a.push(`<g transform="translate(${r.x} ${r.y})">${c}</g>`);break}}}return{svg:`<svg xmlns="http://www.w3.org/2000/svg" width="${Math.ceil(r.w)}" height="${Math.ceil(r.h)}" viewBox="${r.x} ${r.y} ${r.w} ${r.h}"><rect x="${r.x}" y="${r.y}" width="${r.w}" height="${r.h}" fill="${t(`paper`,`line`)}"/>${a.join(``)}</svg>`,box:r}}async function _R(e,t){let{svg:n,box:r}=await gR(t),i=new Blob([n],{type:`image/svg+xml`});if(e===`svg`)return i;let a=Math.min(2,8192/Math.max(r.w,r.h,1)),o=URL.createObjectURL(i);try{let e=await new Promise((e,t)=>{let n=new Image;n.onload=()=>e(n),n.onerror=()=>t(Error(`could not draw the canvas`)),n.src=o}),t=document.createElement(`canvas`);t.width=Math.ceil(r.w*a),t.height=Math.ceil(r.h*a);let n=t.getContext(`2d`);if(!n)throw Error(`could not draw the canvas`);return n.drawImage(e,0,0,t.width,t.height),await new Promise((e,n)=>t.toBlob(t=>t?e(t):n(Error(`could not draw the canvas`)),`image/png`))}finally{URL.revokeObjectURL(o)}}var vR=.1,yR=4,bR=`http://www.w3.org/2000/svg`,xR=e=>e instanceof HTMLElement&&(e.isContentEditable||e.tagName===`INPUT`||e.tagName===`TEXTAREA`),SR=class{opts;store;labels;root;styles;editable;tool=`select`;shapeKind;selected=new Set;activeNode=null;editing=null;entered=null;world;overlay;ui;view={x:0,y:0,zoom:1};rendered=new Map;measured=new Map;layouts=new Map;routes=new Map;previews=new Map;drag=null;guides=[];marquee=null;hover=null;raf=0;spaceDown=!1;pointers=new Map;pinch=null;presenting=null;comments=[];activeComment=``;resize=typeof ResizeObserver>`u`?null:new ResizeObserver(e=>this.onResize(e));unsub;cleanups=[];saveTimer;constructor(e,t){this.opts=t,this.labels=t.labels??mF,this.editable=t.editable,this.styles=LF(t.styles),this.shapeKind=this.styles.shape.shape,this.store=new iR(t.doc,{undo:t.undo!==!1}),this.root=document.createElement(`div`),this.root.className=`dw-cv`,this.root.tabIndex=0,this.root.setAttribute(`role`,`application`),this.root.dataset.testid=`edgeless-canvas`,this.world=document.createElement(`div`),this.world.className=`dw-cv-world`,this.overlay=document.createElementNS(bR,`svg`),this.overlay.classList.add(`dw-cv-overlay`),this.root.append(this.world,this.overlay),e.append(this.root),this.ui=new dR(this),this.root.classList.toggle(`dw-cv-readonly`,!this.editable),this.unsub=this.store.onChange(()=>this.schedule()),this.listen(),this.render(),this.restoreView()||this.fit(void 0,!1),this.applyView()}destroy(){cancelAnimationFrame(this.raf),clearTimeout(this.saveTimer),this.saveView(),this.unsub(),this.resize?.disconnect();for(let e of this.cleanups)e();for(let e of this.rendered.values())e.note?.destroy();this.rendered.clear(),this.ui.destroy(),this.store.destroy(),this.root.remove()}setEditable(e){if(e!==this.editable){this.editable=e,this.roLine truncated
`),o=r.align===`center`?n.w/2:r.align===`right`?n.w:0,c=r.align===`center`?`middle`:r.align===`right`?`end`:`start`;a.push(s(mR(o,0,i,r.fontSize,t(r.color,`line`),e,r.bold?650:400,c)));break}case`connector`:{let n=e.routeOf(r);if(a.push(qL(r,n,t)),r.label){let e=Math.min(240,r.label.length*8+16);a.push(`<rect x="${n.mid[0]-e/2}" y="${n.mid[1]-12}" width="${e}" height="24" rx="4" fill="${t(`paper`,`line`)}"/>`+mR(n.mid[0],n.mid[1]-12+3,[r.label],13,i,YF,400,`middle`))}break}case`brush`:a.push(s(YL(r,t)));break;case`frame`:a.push(s(`<rect width="${n.w}" height="${n.h}" rx="8" fill="${t(r.background,`fill`)===`none`?`none`:t(r.background,`fill`)}" stroke="${t(`gray`,`line`)}" stroke-width="1.5"/>`+mR(4,-24,[r.title],13,t(`gray`,`line`),YF,600)));break;case`note`:{let o=e.noteBody(r),c=o?pR(XL(o)):[],l=18,u=`<rect width="${n.w}" height="${n.h}" rx="8" fill="${t(r.background,`fill`)}" stroke="${t(`gray`,`fill`)}"/>`;if(r.page&&e.pageTitle){let t=eI(e.pageTitle,26,n.w-48,YF,650);u+=mR(24,l-4,t,26,i,YF,650),l+=t.length*35+8}for(let e of c){let t=eI(e.text,e.size,n.w-48,YF,e.weight);if(u+=mR(24,l,t,e.size,i,YF,e.weight),l+=t.length*Math.round(e.size*1.35)+8,l>n.h-12)break}a.push(s(u));break}case`image`:{let i=await hR(e.resolve(r.src));a.push(s(i?`<image href="${LL(i)}" width="${n.w}" height="${n.h}" preserveAspectRatio="xMidYMid meet"/>`:`<rect width="${n.w}" height="${n.h}" fill="${t(`ink`,`fill`)}"/>`));break}case`embed`:a.push(s(`<rect width="${n.w}" height="${n.h}" rx="8" fill="${t(`paper`,`fill`)}" stroke="${t(`gray`,`fill`)}"/>`+mR(16,16,eI(r.url,13,n.w-32),13,t(`blue`,`line`),YF)));break;case`mindmap`:{let n=e.layoutOf(r),o=t(r.color,`line`),s=t(r.color,`fill`),c=n.edges.map(e=>`<path d="${cI(e.from,e.to)}" fill="none" stroke="${o}" stroke-width="2"/>`).join(``);for(let e of n.boxes.values()){let n=e.depth===0?18:15,a=e.depth===0?600:400,l=e.depth===0?o:e.depth===1?s:t(`paper`,`line`),u=e.depth===0?t(`paper`,`line`):i;c+=`<rect x="${e.x}" y="${e.y}" width="${e.w}" height="${e.h}" rx="${e.depth===0?10:8}" fill="${l}" stroke="${o}" stroke-width="${e.depth===0?0:1.5}"/>`;let d=eI(r.nodes[e.id]?.text||` `,n,260,YF,a);c+=mR(e.x+e.w/2,e.y+(e.h-d.length*Math.round(n*1.4))/2-2,d,n,u,YF,a,`middle`)}a.push(`<g transform="translate(${r.x} ${r.y})">${c}</g>`);break}}}return{svg:`<svg xmlns="http://www.w3.org/2000/svg" width="${Math.ceil(r.w)}" height="${Math.ceil(r.h)}" viewBox="${r.x} ${r.y} ${r.w} ${r.h}"><rect x="${r.x}" y="${r.y}" width="${r.w}" height="${r.h}" fill="${t(`paper`,`line`)}"/>${a.join(``)}</svg>`,box:r}}async function _R(e,t){let{svg:n,box:r}=await gR(t),i=new Blob([n],{type:`image/svg+xml`});if(e===`svg`)return i;let a=Math.min(2,8192/Math.max(r.w,r.h,1)),o=URL.createObjectURL(i);try{let e=await new Promise((e,t)=>{let n=new Image;n.onload=()=>e(n),n.onerror=()=>t(Error(`could not draw the canvas`)),n.src=o}),t=document.createElement(`canvas`);t.width=Math.ceil(r.w*a),t.height=Math.ceil(r.h*a);let n=t.getContext(`2d`);if(!n)throw Error(`could not draw the canvas`);return n.drawImage(e,0,0,t.width,t.height),await new Promise((e,n)=>t.toBlob(t=>t?e(t):n(Error(`could not draw the canvas`)),`image/png`))}finally{URL.revokeObjectURL(o)}}var vR=.1,yR=4,bR=`http://www.w3.org/2000/svg`,xR=e=>e instanceof HTMLElement&&(e.isContentEditable||e.tagName===`INPUT`||e.tagName===`TEXTAREA`),SR=class{opts;store;labels;root;styles;editable;tool=`select`;shapeKind;selected=new Set;activeNode=null;editing=null;entered=null;world;overlay;ui;view={x:0,y:0,zoom:1};rendered=new Map;measured=new Map;layouts=new Map;routes=new Map;previews=new Map;drag=null;guides=[];marquee=null;hover=null;raf=0;spaceDown=!1;pointers=new Map;pinch=null;presenting=null;comments=[];activeComment=``;resize=typeof ResizeObserver>`u`?null:new ResizeObserver(e=>this.onResize(e));unsub;cleanups=[];saveTimer;constructor(e,t){this.opts=t,this.labels=t.labels??mF,this.editable=t.editable,this.styles=LF(t.styles),this.shapeKind=this.styles.shape.shape,this.store=new iR(t.doc,{undo:t.undo!==!1}),this.root=document.createElement(`div`),this.root.className=`dw-cv`,this.root.tabIndex=0,this.root.setAttribute(`role`,`application`),this.root.dataset.testid=`edgeless-canvas`,this.world=document.createElement(`div`),this.world.className=`dw-cv-world`,this.overlay=document.createElementNS(bR,`svg`),this.overlay.classList.add(`dw-cv-overlay`),this.root.append(this.world,this.overlay),e.append(this.root),this.ui=new dR(this),this.root.classList.toggle(`dw-cv-readonly`,!this.editable),this.unsub=this.store.onChange(()=>this.schedule()),this.listen(),this.render(),this.restoreView()||this.fit(void 0,!1),this.applyView()}destroy(){cancelAnimationFrame(this.raf),clearTimeout(this.saveTimer),this.saveView(),this.unsub(),this.resize?.disconnect();for(let e of this.cleanups)e();for(let e of this.rendered.values())e.note?.destroy();this.rendered.clear(),this.ui.destroy(),this.store.destroy(),this.root.remove()}setEditable(e){if(e!==this.editable){this.editable=e,this.roLine truncated
`||e===`\r`?(r.push(i),n.push(r),r=[],i=``,e===`\r`&&s[o+1]===`
`&&o++):i+=e,o++}return(i!==``||r.length)&&(r.push(i),n.push(r)),n}function mB(e,t){return e.includes(t)||/["\r\n]/.test(e)||/^\s|\s$/.test(e)?`"${e.replace(/"/g,`""`)}"`:e}function hB(e,t=`,`){return e.map(e=>e.map(e=>mB(e,t)).join(t)).join(`\r
`)}function gB(e,t,n){return hB([t.map(e=>e.name),...n.map(e=>t.map(t=>ZR(e,t)))])}function _B(e){let t=e.map(e=>e.trim()).filter(Boolean);if(!t.length)return`text`;if(t.every(e=>YR(e)!==null))return`number`;if(t.every(e=>/^\d{4}-\d{2}-\d{2}/.test(e)))return`date`;if(t.every(e=>/^(true|false|yes|no)$/i.test(e)))return`checkbox`;if(t.every(e=>/^https?:\/\/\S+$/.test(e)))return`link`;let n=new Set(t.map(e=>e.toLowerCase()));return t.length>=4&&n.size<=Math.max(2,t.length/3)&&t.every(e=>e.length<=40)?`select`:`text`}function vB(e,t,n){let r=e.trim();if(!r)return null;let i=e=>{let t=n.find(t=>t.name.toLowerCase()===e.toLowerCase());return t||(t={id:LR(),name:e,color:cz(n)},n.push(t)),t.id};switch(t.type){case`number`:return YR(r);case`progress`:{let e=YR(r.replace(`%`,``));return e===null?null:Math.max(0,Math.min(100,Math.round(e)))}case`checkbox`:return/^(true|yes|1|x|✓|done)$/i.test(r);case`date`:return qR(r)||null;case`select`:return i(r);case`multiSelect`:return[...new Set(r.split(/[,;]/).map(e=>e.trim()).filter(Boolean).map(i))];case`member`:case`attachment`:case`createdBy`:case`createdTime`:return null;default:return r}}function yB(e,t=`,`){let n=pB(e,t).filter(e=>e.some(e=>e.trim())),r=n[0]??[],i=n.slice(1),a=r.map((e,t)=>({id:LR(),name:e.trim()||`${t+1}`,type:t===0?`title`:_B(i.map(e=>e[t]??``))}));for(let e of a)e.type===`select`&&(e.options=[]);return{columns:a,rows:i.map(e=>{let t={};return a.forEach((n,r)=>{let i=vB(e[r]??``,n,n.options??[]);i!==null&&(!Array.isArray(i)||i.length)&&(t[n.id]=i)}),t})}}function bB(e,t){let n=[];return{index:e.map(e=>{let r=t.find(t=>t.name.trim().toLowerCase()===e.trim().toLowerCase());return!r&&e.trim()&&n.push(e.trim()),r??null}),missing:n}}function xB(e,t,n,r){let i=I(`select`,{class:`dw-db-select`,"aria-label":n});for(let n of t){let t=I(`option`,{value:n.value},n.label);n.value===e&&(t.selected=!0),i.append(t)}return i.addEventListener(`change`,()=>r(i.value)),i.addEventListener(`keydown`,e=>e.stopPropagation()),i}var SB=e=>e.map(e=>({value:e.id,label:e.name||`…`}));function CB(e,t,n,r){let i=e.labels;if(!$R(n.op))return null;if(t.type===`select`||t.type===`multiSelect`)return xB(typeof n.value==`string`?n.value:``,[{value:``,label:`—`},...(t.options??[]).map(e=>({value:e.id,label:e.name}))],i.value,r);let a=t.type===`date`||t.type===`createdTime`?`date`:t.type===`number`||t.type===`progress`?`number`:`text`,o=I(`input`,{class:`dw-db-input dw-db-input--small`,type:a,"aria-label":i.value,placeholder:i.value});return o.value=n.value===void 0||n.value===null?``:String(n.value),o.addEventListener(`keydown`,e=>e.stopPropagation()),o.addEventListener(`change`,()=>r(a===`number`?o.value===``?null:Number(o.value):o.value)),o}function wB(e,t,n){let r=e.store,i=e.labels,a=e.db.columns,o=structuredClone(n.filters),s=()=>r?.updateView(n.id,{filters:o}),c=()=>{t.replaceChildren(),o.length>1&&t.append(xB(n.filterMode,[{value:`and`,label:i.matchAll},{value:`or`,label:i.matchAny}],i.filter,e=>{n.filterMode=e,r?.updateView(n.id,{filterMode:n.filterMode})})),o.length||t.append(I(`p`,{class:`dw-db-pop__empty`},i.noFilters)),o.forEach((n,r)=>{let l=a.find(e=>e.id===n.column);if(!l)return;let u=QR(l.type),d=I(`div`,{class:`dw-db-pop__line`},xB(n.column,SB(a),i.filter,e=>{let t=a.find(t=>t.id===e);o[r]={column:e,op:QR(t.type)[0]},s(),c()}),xB(n.op,u.map(e=>({value:e,label:OR(i,e)})),i.filter,e=>{o[r]={...n,op:e},$R(e)||delete o[r].value,s(),c()}),CB(e,l,n,e=>{o[r]={...o[r],value:e},s()}),kB(i.remove,()=>{o.splice(r,1),s(),c()}));t.append(d)}),r&&t.append(AB(i.addFilter,()=>{let e=a.find(e=>e.type!==`title`)??a[0];o.push({column:e.id,op:QR(e.type)[0]}),s(),c()}))};c()}function TB(e,t,n){let r=e.store,i=e.labels,a=e.db.columns,o=structuredClone(n.sorts),s=()=>r?.updateView(n.id,{sorts:o}),c=()=>{t.replaceChildren(),o.length||t.append(I(`p`,{class:`dw-db-pop__empty`},i.noSorts)),o.forEach((e,n)=>{t.append(I(`div`,{class:`dw-db-pop__line`},xB(e.column,SB(a),i.sort,t=>{o[n]={...e,column:t},s()}),xB(e.desc?`desc`:`asc`,[{value:`asc`,label:i.ascending},{value:`desc`,label:i.descending}],i.sort,t=>{o[n]={...e,desc:t===`desc`},s()}),kB(i.remove,()=>{o.splice(n,1),s(),c()})))}),r&&t.append(AB(i.addSort,()=>{let e=new Set(o.map(e=>e.column)),t=a.find(t=>!e.has(t.id))??a[0];o.push({column:t.id,desc:!1}),s(),c()}))};c()}function EB(e,t,n){let r=e.store,i=e.labels,a=e.db.columns.filter(e=>zR.includes(e.type)),o=a.map(e=>({value:e.id,label:e.name||ER(i,e.type)}));n.type!==`kanban`&&o.unshift({value:``,label:i.noGrouping}),t.append(I(`label`,{class:`dw-db-pop__label`},i.groupBy),a.length||n.type!==`kanban`?xB(n.groupBy??``,o,i.groupBy,e=>r?.updateView(n.id,{groupBy:e||null})):I(`p`,{class:`dw-db-pop__empty`},i.noGroupColumn))}function DB(e,t,n){let r=e.store,i=e.labels,a=e.db.columns.filter(e=>e.type===`date`||e.type===`createdTime`);t.append(I(`label`,{class:`dw-db-pop__label`},i.dateColumn),a.length?xB(n.dateColumn??``,[{value:``,label:`—`},...a.map(e=>({value:e.id,label:e.name||ER(i,e.tyLine truncated
+19 -14
View File
@@ -4,7 +4,7 @@
// which records a cell links to, and what a rollup calculates.
import type { DbContext } from "./cells";
import { h, popover } from "./dom";
import { h, icon, popover } from "./dom";
import { fill, typeLabel, type DatabaseLabels } from "./labels";
import { linkedIds, rollupFnsFor, type DatabaseChoice, type RelationTarget, type RollupConfig, type RollupFn } from "./linked";
import { cellText, titleColumn, type Column, type DbData, type Row } from "./model";
@@ -104,19 +104,6 @@ export function relationTargetPanel(ctx: DbContext, anchor: Element, col: Column
};
drawLocal();
box.append(h("div", { class: "dw-db-pop__title" }, l.relationPick), list);
// A one-way relation on this page can get its other side in one step.
if (current && !current.back && linked.addBack && linked.writable?.(current)) {
const other = linked.read(current);
const has = other?.columns.some((c) => c.relation?.back === col.id && linked.pointsHere?.(current, c.relation));
if (other && !has) {
const btn = h("button", { type: "button", class: "dw-db__btn" }, fill(l.relationShowOn, other.title || l.untitled));
btn.addEventListener("click", () => {
linked.addBack!(current, col.id, ctx.db.title || col.name || l.typeRelation);
close();
});
box.append(btn);
}
}
if (linked.searchPages && linked.databasesOn) {
const input = h("input", { class: "dw-db-input", placeholder: l.relationSearchPage, "aria-label": l.relationOtherPage });
const found = h("div", { class: "dw-db-pop__list", role: "listbox" });
@@ -147,6 +134,24 @@ export function relationTargetPanel(ctx: DbContext, anchor: Element, col: Column
input.addEventListener("keydown", (e) => e.stopPropagation());
box.append(h("div", { class: "dw-db-pop__heading" }, l.relationOtherPage), input, found);
}
// A one-way relation on this page can get its other side in one step.
if (current && !current.back && linked.addBack && linked.writable?.(current)) {
const other = linked.read(current);
const has = other?.columns.some((c) => c.relation?.back === col.id && linked.pointsHere?.(current, c.relation));
if (other && !has) {
const btn = h(
"button",
{ type: "button", class: "dw-db__btn dw-db-pop__add" },
icon("plus", 14),
h("span", {}, fill(l.relationShowOn, other.title || l.untitled)),
);
btn.addEventListener("click", () => {
linked.addBack!(current, col.id, ctx.db.title || col.name || l.typeRelation);
close();
});
box.append(btn);
}
}
},
{ class: "dw-db-pop--choices", label: l.relationTo, onClose: onDone },
);