nx-kv 0.65.0 → 0.65.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +36 -0
- package/package.json +1 -1
- package/src/core/db/seed-templates.ts +2 -86
- package/src/modules/localtask/task-lifecycle.ts +1 -1
- package/src/modules/promptplug/delivery.ts +151 -0
- package/src/modules/promptplug/factory.ts +3 -3
- package/src/modules/promptplug/index.ts +3 -1
- package/src/modules/promptplug/plugins/getloop.ts +8 -7
- package/src/modules/{tasktool/plugins/goal-template.ts → promptplug/plugins/goal-prompt.ts} +4 -3
- package/src/modules/tasktool/delivery.ts +231 -0
- package/src/modules/tasktool/get.ts +2 -2
- package/src/modules/tasktool/plugins/taskgoal-store.ts +1 -1
- package/src/modules/tasktool/plugins/timegoal-task-store.ts +2 -2
- package/src/modules/tasktool/plugins/waitgoal-config.ts +1 -25
- package/src/modules/tasktool/plugins/waitgoal.ts +0 -4
- package/src/modules/tasktool/preview.ts +3 -4
- package/src/modules/tasktool/wait.ts +16 -283
- package/src/modules/templates/actions/templates-default.ts +2 -5
- package/src/modules/templates/actions/templates-update.ts +1 -3
- package/src/modules/templates/service.ts +11 -13
- package/src/modules/templates/support.ts +0 -15
- package/src/web/frontend/App.tsx +0 -12
- package/src/web/frontend/api/client.generated.ts +2 -2
- package/src/web/frontend/components/md/live-block.tsx +1 -5
- package/src/web/frontend/components/md/md-panes-root.tsx +0 -4
- package/src/web/frontend/components/md/md-panes.tsx +1 -11
- package/src/web/frontend/modules/md/styles/docs.css +0 -7
- package/src/web/frontend/modules/md/styles/editor.css +0 -17
- package/src/web/frontend/modules/md/use-templates.ts +3 -13
- package/src/web/frontend/page/dir/index.tsx +3 -15
- package/src/web/frontend/page/dir/task-actions.ts +1 -16
- package/src/web/frontend/page/dir/task.tsx +2 -16
- package/src/web/frontend/page/group/index.tsx +6 -19
- package/src/web/frontend/page/settings/index.tsx +1 -1
- package/src/web/frontend/page/templates/index.tsx +5 -54
- package/src/web/frontend/page/templates/manage.tsx +1 -5
- package/src/web/frontend/page/templates/style.css +1 -43
- package/src/web/frontend/page/templates/template-list.tsx +7 -15
- package/src/web/frontend/routes/route-eq.ts +2 -3
- package/src/web/frontend/routes/templates.ts +0 -10
- package/src/web/frontend/styles-v2/shell.css +7 -0
- package/src/web/frontend/types.ts +2 -1
- package/src/web/public/assets/{bar-csH6ZW39.js → bar-Dc5Tq1eE.js} +1 -1
- package/src/web/public/assets/{composer-launch-Ba9cBxhb.js → composer-launch-fp2IzGzQ.js} +1 -1
- package/src/web/public/assets/{composer-panel-7SHKllt5.js → composer-panel-Dh681iO6.js} +1 -1
- package/src/web/public/assets/dir-d16q1GLe.js +3 -0
- package/src/web/public/assets/{doc-BmGb9F-k.js → doc-DRSKD0Re.js} +1 -1
- package/src/web/public/assets/group-Dc3ZgW24.js +1 -0
- package/src/web/public/assets/{index-D1wpt-oL.css → index-BIVxGd6t.css} +1 -1
- package/src/web/public/assets/index-Bg0m8gbJ.js +2 -0
- package/src/web/public/assets/{md-history-DVI47hu4.js → md-history-DNtgaIdH.js} +6 -6
- package/src/web/public/assets/{refs-P8HrKv4T.js → refs-TzxZYy7T.js} +1 -1
- package/src/web/public/assets/{repo-form-modal-BiBZ63DZ.js → repo-form-modal-Dg3hJWUV.js} +1 -1
- package/src/web/public/assets/{repos-B9D8q6U7.js → repos-uNqSR5YB.js} +1 -1
- package/src/web/public/assets/task-DuFOXLPC.js +11 -0
- package/src/web/public/assets/{task-utils-DPGXUIOk.js → task-utils-DAPxKm4c.js} +1 -1
- package/src/web/public/assets/templates-CwYDIBYn.css +1 -0
- package/src/web/public/assets/templates-DNiGvmdq.js +10 -0
- package/src/web/public/assets/{use-rail-drag-TGx8CLcY.js → use-rail-drag-DxIYcszo.js} +1 -1
- package/src/web/public/index.html +6 -7
- package/src/web/frontend/modules/md/fill-session.ts +0 -36
- package/src/web/frontend/modules/md/new-task-from-template.ts +0 -22
- package/src/web/frontend/modules/md/task-intent.ts +0 -29
- package/src/web/frontend/modules/prompts/render-template-body.ts +0 -14
- package/src/web/frontend/modules/prompts/template-preview.ts +0 -62
- package/src/web/frontend/page/templates/fill.tsx +0 -126
- package/src/web/public/assets/dir-D5AImCiy.js +0 -3
- package/src/web/public/assets/fill-session-fHxQHFaD.js +0 -1
- package/src/web/public/assets/group-CTktws14.js +0 -1
- package/src/web/public/assets/index-Byb7MFTl.js +0 -2
- package/src/web/public/assets/new-task-from-template-DDWu4yR4.js +0 -1
- package/src/web/public/assets/render-template-body-bXdedFig.js +0 -1
- package/src/web/public/assets/task-BBk0TQZi.js +0 -11
- package/src/web/public/assets/task-intent-CX5DZccN.js +0 -1
- package/src/web/public/assets/templates-BN9i9-6c.js +0 -11
- package/src/web/public/assets/templates-plA8R7jJ.css +0 -1
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/index-Byb7MFTl.js","assets/popup-DZ2Khv2c.js","assets/popup-BAvk7J7u.css","assets/workspace-DojQ3RP4.js","assets/repo-form-modal-BiBZ63DZ.js","assets/button-3JlUeln_.js","assets/button-DA4lNJeC.css","assets/doc-BmGb9F-k.js","assets/app-context-BqCBcDsx.js","assets/md-history-DVI47hu4.js","assets/frontmatter-CN6IlxWU.js","assets/status-tag-8cLH8hl9.js","assets/md-history-CLIs9Dr0.css","assets/use-rail-drag-TGx8CLcY.js","assets/list-filter-CWxiOSg_.js","assets/route-crumb-C4DgkJ8G.js","assets/board-view-BVennxTs.js","assets/doc-Iuxssa-b.css","assets/model-CtG2jIDv.js","assets/render-template-body-bXdedFig.js","assets/index-D1wpt-oL.css"])))=>i.map(i=>d[i]);
|
|
2
|
-
import{a as e,d as t,f as n,h as r,i,l as a}from"./popup-DZ2Khv2c.js";import{v as o}from"./workspace-DojQ3RP4.js";import{n as s}from"./app-context-BqCBcDsx.js";import{t as c}from"./button-3JlUeln_.js";import{a as l,d as u,i as d,n as f,r as p,s as m,t as h}from"./md-history-DVI47hu4.js";import{n as g,t as _}from"./list-filter-CWxiOSg_.js";import{n as v,t as y}from"./route-crumb-C4DgkJ8G.js";import{a as b,f as x,l as S,n as C,o as w,p as T}from"./index-Byb7MFTl.js";import{a as E,i as D,n as O,o as k,t as A}from"./fill-session-fHxQHFaD.js";import{t as j}from"./manage-session-CS8UvmUd.js";import{t as M}from"./task-intent-CX5DZccN.js";var N=r(n(),1),P=t(),F={topic:`目录`,repo:`项目`,group:`组`};function I(){let e=s(),t=e.rows||[],n=e.repoData?.repos||[],r=e.repoData?.boards||[];return(0,N.useMemo)(()=>{let e=new Map;for(let n of t)n&&n.key&&e.set(String(n.key),n.name||n.key);let i=new Map;for(let e of n)e&&e.key&&(e.type||`repo`)!==`group`&&i.set(String(e.key),e.name||e.key);let a=new Map;for(let e of n)e&&(e.type||``)===`group`&&e.key&&a.set(String(e.key),e.name||e.key);for(let e of r){let t=String(e&&(e.key||e.id)||``);t&&a.set(t,e&&e.name||t)}return{topicByKey:e,repoByKey:i,groupByKey:a,topics:t,repos:n,boards:r}},[t,n,r])}function L(e,t){if(e===`*`)return`全局`;let n=String(e).indexOf(`:`);if(n<0)return String(e);let r=String(e).slice(0,n),i=String(e).slice(n+1),a=F[r]||r,o=``;return r===`topic`?o=t.topicByKey.get(i)||``:r===`repo`?o=t.repoByKey.get(i)||``:r===`group`&&(o=t.groupByKey.get(i)||``),o?`${a} · ${o}`:`${a} ${/^[0-9a-f]{16}$/.test(i)?`${i.slice(0,6)}…`:i}`}function R({scope:e,onChange:t,originTopic:n=``,catalog:r,classPrefix:i=`setp`}){let o=a(),s=I(),c=r||s,[l,u]=(0,N.useState)(null),d=Array.isArray(e)?e:[],f=d.includes(`*`),p=d.filter(e=>e!==`*`),m=i,h=n?c.topicByKey.get(n)||(/^[0-9a-f]{16}$/.test(n)?`${n.slice(0,6)}…`:n):``,g=async e=>{try{await t(e)}catch(e){o(String(e.message||e))}},_=async e=>{if(d.includes(e)){o(`已经在可见范围里了`),u(null);return}await g([...d,e]),u(null)},v=(0,N.useMemo)(()=>{if(l===`topic`)return(c.topics||[]).filter(e=>e&&e.key).map(e=>({entry:`topic:${e.key}`,label:e.name||e.key,sub:e.cwd||``}));if(l===`repo`)return(c.repos||[]).filter(e=>e&&e.key&&(e.type||`repo`)!==`group`&&e.key!==`__unbound__`).map(e=>({entry:`repo:${e.key}`,label:e.name||e.key,sub:e.key}));if(l===`group`){let e=new Set,t=[];for(let n of c.repos||[])n&&(n.type||``)===`group`&&n.key&&!e.has(n.key)&&(e.add(n.key),t.push({entry:`group:${n.key}`,label:n.name||n.key,sub:n.key}));for(let n of c.boards||[]){let r=n&&(n.key||n.id);r&&!e.has(r)&&(e.add(r),t.push({entry:`group:${r}`,label:n&&n.name||r,sub:String(r)}))}return t}return[]},[l,c]);return(0,P.jsxs)(`div`,{className:`${m}-scope-block`,children:[(0,P.jsx)(`div`,{className:`${m}-scope`,children:d.map(e=>(0,P.jsxs)(`button`,{type:`button`,className:`${m}-scope-chip on`,title:`${e} —— 点击移除`,onClick:()=>g(d.filter(t=>t!==e)),children:[L(e,c),` ×`]},e))}),(0,P.jsxs)(`div`,{className:`${m}-scope-add`,children:[(0,P.jsx)(`span`,{className:`${m}-scope-add-label`,children:`添加`}),(0,P.jsx)(`button`,{type:`button`,className:`${m}-scope-add-btn`,disabled:f,title:f?`已绑定全局`:`加上「全局」绑定(与目录/项目/组平级)`,onClick:()=>!f&&g([`*`,...p]),children:`全局`}),[`topic`,`repo`,`group`].map(e=>(0,P.jsx)(`button`,{type:`button`,className:`${m}-scope-add-btn`+(l===e?` on`:``),onClick:()=>u(l===e?null:e),children:F[e]},e)),h?(0,P.jsxs)(`span`,{className:`${m}-scope-origin`,title:`创建于主题 ${n}`,children:[`创建于 `,h]}):null]}),l&&(0,P.jsx)(`div`,{className:`${m}-scope-pick`,role:`listbox`,"aria-label":`选择可见对象`,children:v.length?v.map(e=>(0,P.jsxs)(`button`,{type:`button`,className:`${m}-scope-pick-it`,disabled:d.includes(e.entry),title:e.sub||e.entry,onClick:()=>_(e.entry),children:[(0,P.jsx)(`span`,{className:`${m}-scope-pick-name`,children:e.label}),d.includes(e.entry)?(0,P.jsx)(`span`,{className:`${m}-scope-pick-done`,children:`已加`}):null]},e.entry)):(0,P.jsx)(`div`,{className:`${m}-scope-pick-empty`,children:`暂无可选项`})})]})}function z(e){return String(e||``).split(`
|
|
3
|
-
`).map(e=>e.trim().replace(/^#{1,6}\s+/,``).replace(/^[-*+]\s+\[[ x]\]\s*/i,``).replace(/^[-*+]\s+/,``).replace(/^>\s?/,``).replace(/\{\{\s*([^}{\s][^{}]*?)\s*\}\}/g,`〔$1〕`)).filter(Boolean).slice(0,2).join(` · `)}function B(){let t=s(),n=t.tpl,r=a(),{dialog:o,node:l}=i(),[d,f]=(0,N.useState)(null),[p,m]=(0,N.useState)(null),[h,v]=(0,N.useState)(!1),[y,b]=(0,N.useState)(``),x=e=>t.onNavigate?.(e);if(!n)return(0,P.jsx)(`div`,{className:`rp-page tpl-page`,children:(0,P.jsx)(`div`,{className:`muted`,style:{padding:20},children:`模板服务未就绪…`})});if(n.unsupported)return(0,P.jsx)(`div`,{className:`rp-page tpl-page`,children:(0,P.jsx)(`div`,{className:`muted`,style:{padding:20},children:`当前服务比面板旧——重启面板后才有模板功能。`})});let S=n.templates||[],C=_(S,y,e=>[e.name,z(e.body),(e.scope||[]).join(` `)]),w=async(e,t)=>{if(!h){v(!0);try{await e(),t&&r(t)}catch(e){r(String(e.message||e))}finally{v(!1)}}},T=async e=>{await o({title:`删除模板「${e.name}」`,danger:!0,okText:`删除`})&&await w(()=>n.remove(e.id),`已删除「${e.name}」`)};return(0,P.jsxs)(`div`,{className:`rp-page tpl-page`,children:[l,(0,P.jsxs)(`div`,{className:`page-head`,children:[(0,P.jsxs)(`div`,{className:`title-block`,children:[(0,P.jsxs)(`h2`,{children:[(0,P.jsx)(e,{name:`list`,size:16}),` 任务模板`]}),(0,P.jsxs)(`p`,{className:`muted tpl-head-note`,children:[`新建任务时的正文骨架;带 `,(0,P.jsx)(`code`,{children:`{{content}}`}),` 的段落可在填写页填值。`]})]}),(0,P.jsx)(`div`,{className:`acts`,children:(0,P.jsxs)(c,{variant:`primary`,small:!0,disabled:h,onClick:()=>x(`#/templates/new`),children:[(0,P.jsx)(e,{name:`plus`,size:13}),` 新建`]})})]}),!S.length&&(0,P.jsx)(`div`,{className:`muted`,style:{padding:`8px 2px`},children:`还没有模板(内置默认模板加载中…)。`}),S.length>1?(0,P.jsx)(`div`,{className:`tpl-search`,children:(0,P.jsx)(g,{value:y,onChange:b,placeholder:`搜索名称 / 正文 / 可见范围…`,title:`过滤任务模板`,count:C.length,className:`wide`})}):null,(0,P.jsxs)(`div`,{className:`tpl-list`,children:[C.map(t=>{let r=t.id===n.defaultId,i=d===t.id,a=p===t.id,o=k(t.body);return(0,P.jsxs)(`div`,{className:`tpl-card`+(r?` is-default`:``),children:[(0,P.jsxs)(`div`,{className:`tpl-card-head`,children:[(0,P.jsx)(`span`,{className:`tpl-card-name`,children:t.name}),r&&(0,P.jsx)(`span`,{className:`tpl-badge`,children:`默认`}),t.builtin&&(0,P.jsx)(`span`,{className:`tpl-badge soft`,children:`内置`}),o.length>0&&(0,P.jsxs)(`span`,{className:`tpl-badge slot`,title:o.join(`、`),children:[(0,P.jsx)(e,{name:`list`,size:11}),` `,o.length]}),(0,P.jsx)(`span`,{className:`grow tpl-card-grow`}),(0,P.jsxs)(`div`,{className:`tpl-card-acts`,children:[(0,P.jsx)(`button`,{type:`button`,className:`iconbtn`,title:a?`收起预览`:`预览`,onClick:()=>m(a?null:t.id),children:(0,P.jsx)(e,{name:`monitor`,size:14})}),(0,P.jsx)(`button`,{type:`button`,className:`iconbtn`+(i?` is-on`:``),title:`可见范围`,disabled:h,onClick:()=>f(i?null:t.id),children:(0,P.jsx)(e,{name:`globe`,size:14})}),(0,P.jsx)(`button`,{type:`button`,className:`iconbtn`,title:`编辑`,disabled:h,onClick:()=>x(`#/templates/edit/${encodeURIComponent(t.id)}`),children:(0,P.jsx)(e,{name:`edit`,size:14})}),!r&&(0,P.jsx)(`button`,{type:`button`,className:`iconbtn`,title:`设为默认`,disabled:h,onClick:()=>w(()=>n.setDefault(t.id),`默认模板已设为「${t.name}」`),children:(0,P.jsx)(e,{name:`star`,size:14})}),!t.builtin&&(0,P.jsx)(`button`,{type:`button`,className:`iconbtn`,title:`删除`,disabled:h,onClick:()=>T(t),children:(0,P.jsx)(e,{name:`trash`,size:14})})]})]}),(0,P.jsx)(`div`,{className:`tpl-card-sum`,children:z(t.body)||`(空模板)`}),i&&(0,P.jsx)(`div`,{className:`tpl-card-scope`,children:(0,P.jsx)(R,{scope:t.scope,originTopic:t.originTopic,onChange:e=>n.update(t.id,{scope:e})})}),a&&(0,P.jsx)(`div`,{className:`tpl-preview`,children:(0,P.jsx)(`div`,{className:`tpl-preview-body mdw-lp-view`,dangerouslySetInnerHTML:{__html:u(D(t.body,t.values))}})})]},t.id)}),S.length&&!C.length?(0,P.jsx)(`div`,{className:`muted`,style:{padding:`8px 2px`},children:`(没有匹配的模板)`}):null]})]})}function V({config:t}){let n=s(),r=a(),i=(0,N.useMemo)(()=>O(t?.id),[t?.id]),o=(0,N.useMemo)(()=>(n.tpl?.templates||[]).find(e=>e.id===(i||{})?.templateId)||null,[n.tpl?.templates,i]),l=(0,N.useMemo)(()=>o?k(o.body):[],[o]),[u,d]=(0,N.useState)(()=>{let e={};for(let t of l)e[t]=String((o?.values||{})[t]??``);return e});if(!i||!o)return(0,P.jsxs)(`div`,{className:`rp-page tpl-fill-page`,children:[(0,P.jsx)(y,{}),(0,P.jsx)(`div`,{className:`pad muted`,children:`参数会话已失效——请从「新建任务」下拉重新选择模板。`})]});let f=(e,t)=>d(n=>({...n,[e]:t})),p=e=>{let a={};i.board&&(a.board=i.board),i.project&&(a.project=i.project);let s=E({id:o.id,body:o.body,values:o.values},a,u),c=S(),l=i.groupId||i.dirKey||``,d=w(T(l),c);x(d,{title:``,body:s}),e&&M(d,{submit:!0}),A(t?.id);let f=i.groupId?{groupId:i.groupId,task:c,name:`新任务`}:{dirKey:i.dirKey,task:c,name:`新任务`};n.openPage?.(f),r(e?`正在提交任务…`:`已进入草稿编辑`)};return(0,P.jsxs)(`div`,{className:`rp-page tpl-fill-page`,children:[(0,P.jsx)(y,{}),(0,P.jsxs)(`div`,{className:`page-head`,children:[(0,P.jsxs)(`div`,{className:`title-block`,children:[(0,P.jsxs)(`h2`,{children:[(0,P.jsx)(e,{name:`list`,size:16}),` 填写模板参数`]}),(0,P.jsxs)(`p`,{className:`muted tpl-head-note`,children:[`「`,o.name,`」· 全部可选,留空即为空白。生成的是纯文本任务,编辑页不会再出现槽位框。`]})]}),(0,P.jsx)(`div`,{className:`acts`,children:(0,P.jsxs)(c,{variant:`secondary`,small:!0,onClick:()=>n.onNavigate?.(v()||`#/templates`),children:[(0,P.jsx)(e,{name:`back`,size:13}),` 返回`]})})]}),(0,P.jsx)(`div`,{className:`tpl-fill-body`,children:l.length===0?(0,P.jsx)(`div`,{className:`muted tpl-fill-empty`,children:`这条模板没有参数槽位,可直接进入任务编辑。`}):l.map(e=>(0,P.jsxs)(`label`,{className:`tpl-fill-field`,children:[(0,P.jsx)(`span`,{className:`tpl-fill-label`,children:e}),(0,P.jsx)(`textarea`,{className:`tpl-fill-input`,value:u[e]??``,placeholder:`填写「${e}」(可留空)`,onChange:t=>f(e,t.target.value),rows:4})]},e))}),(0,P.jsxs)(`div`,{className:`tpl-fill-foot`,children:[(0,P.jsxs)(c,{variant:`secondary`,onClick:()=>p(!1),children:[(0,P.jsx)(e,{name:`edit`,size:13}),` 进入编辑页(草稿)`]}),(0,P.jsxs)(c,{variant:`primary`,onClick:()=>p(!0),children:[(0,P.jsx)(e,{name:`check`,size:13}),` 直接提交`]})]})]})}function H({config:t}){let n=s(),r=a(),i=n.tpl,o=(0,N.useMemo)(()=>j(t?.id),[t?.id]),l=C(o?{topic:o.topic||``,group:o.group||``,repo:o.repo||``}:{topic:`__no_topic__`}),[u,d]=(0,N.useState)(``),[f,p]=(0,N.useState)(null),[m,h]=(0,N.useState)(null),[v,x]=(0,N.useState)(null),[S,w]=(0,N.useState)(!1),T=l.templates||[],E=_(T,u,e=>[e.name,e.body,(e.scope||[]).join(` `),k(e.body).join(` `)]),D=async(e,t)=>{if(!S){w(!0);try{await e(),t&&r(t)}catch(e){r(String(e.message||e))}finally{w(!1)}}},O=async(e,t)=>{if(e===t)return;let n=T.map(e=>e.id),r=n.indexOf(e),a=n.indexOf(t);r<0||a<0||(n.splice(r,1),n.splice(a,0,e),await D(()=>i.reorder(n)))},A=()=>{let e=o?.group?[`group:${o.group}`]:o?.repo?[`repo:${o.repo}`]:o?.topic?[`topic:${o.topic}`]:[];b(async()=>{let{openTemplateEditor:e}=await import(`./index-Byb7MFTl.js`).then(e=>e.i);return{openTemplateEditor:e}},__vite__mapDeps([0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20])).then(({openTemplateEditor:t})=>{n.model&&t(n.model,{mode:`new`,scope:e,topic:o?.topic||``,name:``})})},M=o?.label||o?.topic||o?.group||o?.repo||`本主题`;return(0,P.jsxs)(`div`,{className:`rp-page tpl-mng-page`,children:[(0,P.jsx)(y,{}),(0,P.jsxs)(`div`,{className:`page-head`,children:[(0,P.jsxs)(`div`,{className:`title-block`,children:[(0,P.jsxs)(`h2`,{children:[(0,P.jsx)(e,{name:`gear`,size:16}),` 管理模板 · `,M]}),(0,P.jsx)(`p`,{className:`muted tpl-head-note`,children:`只显示本主题可见的模板。拖动左侧把手调整顺序,点图标改可见范围;搜索框会同步隐藏不匹配的行。`})]}),(0,P.jsx)(`div`,{className:`acts`,children:(0,P.jsxs)(c,{variant:`primary`,small:!0,disabled:S,onClick:A,children:[(0,P.jsx)(e,{name:`plus`,size:13}),` 新建模板`]})})]}),(0,P.jsx)(`div`,{className:`tpl-mng-search`,children:(0,P.jsx)(g,{value:u,onChange:d,placeholder:`搜索名称 / 正文 / 槽位 / 可见范围…`,title:`过滤本主题模板`,count:E.length,className:`wide`})}),T.length?(0,P.jsx)(`div`,{className:`tpl-mng-list`,children:E.map(t=>{let r=t.id===i?.defaultId,a=k(t.body);return(0,P.jsxs)(`div`,{className:[`tpl-mng-row`,f===t.id?`is-dragging`:``,m===t.id&&f!==t.id?`is-over`:``].filter(Boolean).join(` `),draggable:!0,onDragStart:e=>{p(t.id),e.dataTransfer.effectAllowed=`move`},onDragOver:e=>{e.preventDefault(),e.dataTransfer.dropEffect=`move`,h(t.id)},onDrop:e=>{e.preventDefault(),h(null),f&&O(f,t.id),p(null)},onDragEnd:()=>{p(null),h(null)},children:[(0,P.jsx)(`span`,{className:`tpl-mng-grip`,title:`拖动排序`,children:(0,P.jsx)(e,{name:`grip`,size:14})}),(0,P.jsxs)(`div`,{className:`tpl-mng-main`,children:[(0,P.jsxs)(`div`,{className:`tpl-mng-line`,children:[(0,P.jsx)(`span`,{className:`tpl-mng-name`,children:t.name}),r&&(0,P.jsx)(`span`,{className:`tpl-badge`,children:`默认`}),t.builtin&&(0,P.jsx)(`span`,{className:`tpl-badge soft`,children:`内置`}),a.length>0&&(0,P.jsxs)(`span`,{className:`tpl-badge soft`,children:[`槽位 `,a.length]})]}),(t.scope||[]).length>0&&!v&&(0,P.jsxs)(`div`,{className:`tpl-mng-scope-sum muted`,children:[`可见:`,(t.scope||[]).join(` / `)]})]}),(0,P.jsxs)(`div`,{className:`tpl-mng-acts`,children:[(0,P.jsx)(`button`,{type:`button`,className:`iconbtn`,title:`可见范围`,onClick:()=>x(v===t.id?null:t.id),children:(0,P.jsx)(e,{name:`globe`,size:14})}),(0,P.jsx)(`button`,{type:`button`,className:`iconbtn`,title:`编辑`,onClick:()=>n.onNavigate?.(`#/templates/edit/${encodeURIComponent(t.id)}`),children:(0,P.jsx)(e,{name:`edit`,size:14})}),!r&&(0,P.jsx)(`button`,{type:`button`,className:`iconbtn`,title:`设为默认`,disabled:S,onClick:()=>D(()=>i.setDefault(t.id),`默认模板已设为「${t.name}」`),children:(0,P.jsx)(e,{name:`star`,size:14})}),!t.builtin&&(0,P.jsx)(`button`,{type:`button`,className:`iconbtn`,title:`删除`,disabled:S,onClick:()=>D(()=>i.remove(t.id),`已删除「${t.name}」`),children:(0,P.jsx)(e,{name:`trash`,size:14})})]}),v===t.id&&(0,P.jsx)(`div`,{className:`tpl-mng-scope`,children:(0,P.jsx)(R,{scope:t.scope,originTopic:t.originTopic,onChange:e=>i.update(t.id,{scope:e})})})]},t.id)})}):(0,P.jsx)(`div`,{className:`muted`,style:{padding:`8px 2px`},children:`本主题下没有可见模板。`})]})}var U=e=>`tpl:${e||`new`}`,W=/\{\{\s*[^}{\s][^{}]*?\s*\}\}/;function G(e){let t=new Set;return m(e).forEach((e,n)=>{W.test(e)&&t.add(n)}),t}var K=`## 背景
|
|
4
|
-
|
|
5
|
-
{{content}}
|
|
6
|
-
|
|
7
|
-
## 验收
|
|
8
|
-
- [ ] …
|
|
9
|
-
|
|
10
|
-
## 约束
|
|
11
|
-
- …`;function q({templateId:e,initialName:t,initialBody:n,initialValues:r,isNew:i,onSave:o,onClose:s,busy:c}){let m=a(),[g,_]=(0,N.useState)(t||``),[v,b]=(0,N.useState)(n||``),[x,S]=(0,N.useState)(`split`),[C,w]=(0,N.useState)(!1),T=(0,N.useRef)(null),E=(0,N.useRef)(new Map),O=U(i?`new`:e),k=(0,N.useMemo)(()=>u(D(v||``,r)),[v,r]),A=(0,N.useMemo)(()=>G(v||``),[v]),j=A.size,M=(e,t,n=`typing`)=>{f(E.current,O,{title:g,body:v},n),_(e),b(t),w(!0)},F=(e,t=`typing`)=>M(e,v,t),I=(e,t=`op`)=>M(g,e,t),L=()=>{let e=d(E.current,O,{title:g,body:v});e&&(_(e.title||``),b(e.body||``),w(!0))},R=()=>{let e=p(E.current,O,{title:g,body:v});e&&(_(e.title||``),b(e.body||``),w(!0))},z=async()=>{if(!(g||``).trim()){m(`模板名不能为空(标题即名称)`);return}await o({name:g.trim(),body:v}),h(E.current,O),w(!1)};return(0,P.jsx)(`div`,{className:`mdw mdw-tpl-edpage`,"data-mode":x,children:(0,P.jsxs)(`div`,{className:`mdw-main`,children:[(0,P.jsxs)(`div`,{className:`mdw-top`,children:[(0,P.jsx)(y,{}),(0,P.jsxs)(`div`,{className:`mdw-head`,children:[(0,P.jsx)(`div`,{className:`mdw-title`,children:i?`新建模板`:`编辑模板`}),(0,P.jsxs)(`div`,{className:`mdw-path`,children:[`任务模板`,g?` / ${g}`:``,C?` · 未保存`:``]})]})]}),(0,P.jsxs)(`div`,{className:`mdw-toolbar`,children:[(0,P.jsxs)(`div`,{className:`mdw-toolbar-left`,children:[(0,P.jsx)(`div`,{className:`seg`,role:`group`,"aria-label":`编辑模式`,children:[{id:`split`,label:`并排`},{id:`edit`,label:`源码`}].map(e=>(0,P.jsx)(`button`,{type:`button`,className:x===e.id?`on`:``,onClick:()=>S(e.id),children:e.label},e.id))}),(0,P.jsx)(`span`,{className:`tpl-slot-hint`+(j?``:` is-none`),title:`插槽只有这一个名字;可以出现多次,共用同一个值`,children:j?(0,P.jsxs)(P.Fragment,{children:[`插槽 `,(0,P.jsx)(`b`,{children:j}),` 处 · `,(0,P.jsx)(`code`,{children:`{{content}}`}),` 可填,其余只读`]}):(0,P.jsxs)(P.Fragment,{children:[`还没有插槽 —— 正文里写 `,(0,P.jsx)(`code`,{children:`{{content}}`}),`,那段在任务里就可填`]})})]}),(0,P.jsxs)(`div`,{className:`mdw-actions`,role:`group`,"aria-label":`模板操作`,children:[(0,P.jsx)(`button`,{type:`button`,className:`btn ghost sm`,disabled:c,onClick:s,children:`关闭`}),(0,P.jsx)(`button`,{type:`button`,className:`btn sm primary`,disabled:c||!C,onClick:z,children:i?`创建`:`保存`})]})]}),(0,P.jsx)(l,{mode:x,title:g,body:v,previewHtml:k,tplSlotBlocks:A,onTitle:F,onBody:I,docKey:O,editorApiRef:T,onSave:z,onUndo:L,onRedo:R,attachments:[]})]})})}function J({config:e,model:t,tabId:n}){let r=s(),i=r.tpl,c=a(),[l,u]=(0,N.useState)(!1),d=e||{},f=d.mode||(d.id?`edit`:``),p=f===`new`,m=d.id||``;if(f===`fill`)return(0,P.jsx)(V,{config:d});if(f===`manage`)return(0,P.jsx)(H,{config:d});let h=()=>{let e=v();if(e&&r.onNavigate){r.onNavigate(e);return}if(r.onNavigate){r.onNavigate(`#/overview`);return}if(t&&n)try{t.doAction(o.deleteTab(n))}catch{}};if(!i)return(0,P.jsxs)(`div`,{className:`mdw-tpl-panel`,children:[(0,P.jsx)(y,{}),(0,P.jsx)(`div`,{className:`pad muted`,children:`模板服务未就绪 —— 面板还在装载。`})]});if(!p&&!m)return(0,P.jsx)(B,{});let g=p?null:(i.templates||[]).find(e=>e.id===m);if(!p&&!g)return(0,P.jsxs)(`div`,{className:`mdw-tpl-panel`,children:[(0,P.jsx)(y,{}),(0,P.jsxs)(`div`,{className:`pad muted`,children:[`找不到模板「`,m,`」——可能已删除。`]})]});let _=async({name:e,body:t})=>{u(!0);try{if(p){let n={};Array.isArray(d.scope)&&(n.scope=d.scope),d.topic&&(n.topic=d.topic),await i.add(e,t,!1,n),c(`已创建模板`)}else await i.update(m,{name:e,body:t}),c(`已保存模板`);h()}catch(e){c(String(e.message||e))}finally{u(!1)}},b=p?d.name||``:g?.name??``,x=p?K:g?.body??``,S=p?null:g?.values??null;return(0,P.jsx)(q,{templateId:m,initialName:b,initialBody:x,initialValues:S,isNew:p,busy:l,onSave:_,onClose:h},p?`new:${d.topic||``}:${(d.scope||[]).join(`,`)}`:m)}export{J as default};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
.tpl-page{flex-direction:column;gap:12px;display:flex}.tpl-head-note{margin:2px 0 0;font-size:12px}.tpl-head-note code,.tpl-slot-hint code{background:var(--soft,#f1f0ec);border:1px solid var(--line,#e4e2dc);border-radius:4px;padding:0 4px;font:400 11.5px ui-monospace,Consolas,monospace}.tpl-slot-hint{white-space:nowrap;text-overflow:ellipsis;color:var(--mdw-accent,#2f6f5e);margin-left:10px;font-size:11px;overflow:hidden}.tpl-slot-hint b{font-weight:600}.tpl-slot-hint.is-none{color:var(--mid,#8a8578)}.mdw-tpl-edpage .mdw-lp-slot{opacity:1}.mdw-tpl-edpage .mdw-lp-block.is-slot{box-shadow:inset 3px 0 0 var(--mdw-accent-line,#b7d4c8)}.tpl-search{padding:2px 0 8px}.tpl-list{flex-direction:column;gap:8px;min-width:0;display:flex}.tpl-card{border:1px solid var(--line,#e4e2dc);background:var(--paper,#fff);border-radius:10px;flex-direction:column;gap:6px;min-width:0;padding:10px 12px;display:flex}.tpl-card.is-default{border-color:var(--mdw-accent-line,#b7d4c8)}.tpl-card-head{flex-wrap:wrap;align-items:center;gap:8px;min-width:0;display:flex}.tpl-card-name{font-size:13px;font-weight:600}.tpl-badge{background:var(--mdw-accent-soft,#e8f2ee);color:var(--mdw-accent,#2f6f5e);border:1px solid var(--mdw-accent-line,#b7d4c8);border-radius:999px;padding:0 6px;font-size:10.5px;line-height:1.7}.tpl-badge.soft{background:var(--soft,#f1f0ec);color:var(--mid,#8a8578);border-color:var(--line,#e4e2dc)}.tpl-card-slots{background:var(--mdw-accent-soft,#e8f2ee);color:var(--mdw-accent,#2f6f5e);border:1px solid var(--mdw-accent-line,#b7d4c8);text-overflow:ellipsis;white-space:nowrap;border-radius:999px;max-width:340px;padding:0 6px;font-size:10.5px;line-height:1.7;overflow:hidden}.tpl-card-grow{flex:auto;min-width:0;max-width:none}.tpl-card-acts{flex-wrap:wrap;justify-content:flex-end;align-items:center;gap:6px;display:flex}.tpl-card-sum{color:var(--ink-2,#4b515a);-webkit-line-clamp:2;-webkit-box-orient:vertical;font-size:11.5px;line-height:1.6;display:-webkit-box;overflow:hidden}.tpl-card-scope{border-top:1px dashed var(--line,#e4e2dc);padding-top:6px}.tpl-preview{border:1px dashed var(--line,#e4e2dc);background:var(--soft,#f7f6f3);border-radius:8px;flex-direction:column;gap:6px;margin-top:2px;padding:9px 11px;display:flex}.tpl-preview-note{color:var(--mid,#8a8578);font-size:10.5px}.tpl-preview-body{min-width:0;max-height:300px;overflow:auto}.tpl-card-hint{color:var(--mid,#8a8578);font-size:11px;line-height:1.6}.tpl-card-hint code{background:var(--soft,#f1f0ec);border:1px solid var(--line,#e4e2dc);border-radius:3px;padding:0 3px;font:400 10.5px ui-monospace,Consolas,monospace}.tpl-fill-page{gap:12px}.tpl-fill-page .page-head h2{align-items:center;gap:7px;display:flex}.tpl-fill-body{border:1px solid var(--line,#e4e2dc);background:var(--paper,#fff);border-radius:10px;flex-direction:column;gap:14px;min-width:0;max-width:720px;padding:14px;display:flex}.tpl-fill-field{flex-direction:column;gap:6px;min-width:0;display:flex}.tpl-fill-label{color:var(--ink-2,#4b515a);font-size:12px;font-weight:600}.tpl-fill-input{resize:vertical;box-sizing:border-box;width:100%;min-height:84px;color:var(--ink,#222);background:var(--paper,#fff);border:1px solid var(--line,#e4e2dc);border-radius:8px;padding:8px 10px;font:400 12.5px/1.6 inherit}.tpl-fill-input:focus{border-color:var(--mdw-accent-line,#b7d4c8);outline:none}.tpl-fill-empty{padding:8px 0}.tpl-fill-foot{justify-content:flex-end;gap:8px;max-width:720px;display:flex}.tpl-mng-page{gap:12px}.tpl-mng-page .page-head h2{align-items:center;gap:7px;display:flex}.tpl-mng-search{padding:2px 0 6px}.tpl-mng-list{flex-direction:column;gap:6px;min-width:0;display:flex}.tpl-mng-row{border:1px solid var(--line,#e4e2dc);background:var(--paper,#fff);border-radius:9px;grid-template-columns:22px minmax(0,1fr) auto;align-items:center;gap:8px;padding:8px 10px;display:grid}.tpl-mng-row.is-dragging{opacity:.5}.tpl-mng-row.is-over{border-color:var(--mdw-accent,#2f6f5e);box-shadow:inset 0 -2px 0 var(--mdw-accent,#2f6f5e)}.tpl-mng-grip{cursor:grab;color:var(--mid,#8a8578);justify-content:center;align-items:center;display:flex}.tpl-mng-grip:active{cursor:grabbing}.tpl-mng-main{min-width:0}.tpl-mng-line{flex-wrap:wrap;align-items:center;gap:6px;min-width:0;display:flex}.tpl-mng-name{color:var(--ink,#222);font-size:12.5px;font-weight:600}.tpl-mng-scope-sum{text-overflow:ellipsis;white-space:nowrap;margin-top:3px;font-size:10.5px;overflow:hidden}.tpl-mng-acts{align-items:center;gap:2px;display:flex}.tpl-mng-scope{border-top:1px dashed var(--line,#e4e2dc);grid-column:1/-1;padding-top:8px}.tpl-badge.slot{align-items:center;gap:3px;display:inline-flex}.tpl-card .iconbtn.is-on{background:var(--mdw-accent-soft,#e8f2ee);color:var(--mdw-accent,#2f6f5e)}.tpl-page .page-head h2,.tpl-mng-page .page-head h2{align-items:center;gap:7px;display:flex}
|