@tachybase/plugin-block-comments 0.23.40 → 0.23.47
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/dist/client/index.js +2 -2
- package/dist/externalVersion.js +3 -3
- package/package.json +6 -6
package/dist/client/index.js
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
(function(c,n){typeof exports=="object"&&typeof module!="undefined"?n(exports,require("react"),require("@tachybase/client"),require("react-i18next"),require("@tachybase/schema"),require("@ant-design/icons"),require("react/jsx-runtime"),require("lodash"),require("antd"),require("dayjs")):typeof define=="function"&&define.amd?define(["exports","react","@tachybase/client","react-i18next","@tachybase/schema","@ant-design/icons","react/jsx-runtime","lodash","antd","dayjs"],n):(c=typeof globalThis!="undefined"?globalThis:c||self,n(c["@tachybase/plugin-block-comments"]={},c.react,c["@tachybase/client"],c["react-i18next"],c["@tachybase/schema"],c["@ant-design/icons"],c.jsxRuntime,c.lodash,c.antd,c.dayjs))})(this,function(c,n,t,T,u,L,r,F,x,B){"use strict";var re=Object.defineProperty,se=Object.defineProperties;var ie=Object.getOwnPropertyDescriptors;var Q=Object.getOwnPropertySymbols;var ce=Object.prototype.hasOwnProperty,le=Object.prototype.propertyIsEnumerable;var N=(c,n,t)=>n in c?re(c,n,{enumerable:!0,configurable:!0,writable:!0,value:t}):c[n]=t,b=(c,n)=>{for(var t in n||(n={}))ce.call(n,t)&&N(c,t,n[t]);if(Q)for(var t of Q(n))le.call(n,t)&&N(c,t,n[t]);return c},v=(c,n)=>se(c,ie(n));var A=(c,n,t)=>N(c,typeof n!="symbol"?n+"":n,t);var D=(c,n,t)=>new Promise((T,u)=>{var L=x=>{try{F(t.next(x))}catch(B){u(B)}},r=x=>{try{F(t.throw(x))}catch(B){u(B)}},F=x=>x.done?T(x.value):Promise.resolve(x.value).then(L,r);F((t=t.apply(c,n)).next())});function M(e){return t.tval(e,{ns:E})}const E="block-comments";function z(){return T.useTranslation(E)}const U=new t.SchemaInitializer({name:"comment:configureItemActions",title:'{{t("Configure actions")}}',icon:"SettingOutlined",items:[{type:"itemGroup",name:"enableActions",title:'{{t("Enable actions")}}',children:[{name:"edit",title:'{{t("Edit")}}',Component:"UpdateCommentActionInitializer",schema:{"x-action":"update","x-decorator":"ACLActionProvider","x-align":"left"},useVisible(){const e=t.useCollection_deprecated();return(e.template!=="view"||(e==null?void 0:e.writableView))&&e.template!=="sql"}},{name:"delete",title:'{{t("Delete")}}',Component:"DestroyActionInitializer",schema:{"x-component":"Action.Link","x-action":"destroy","x-decorator":"ACLActionProvider","x-align":"left"},useVisible(){return t.useCollection_deprecated().template!=="sql"}},{name:"reply",title:M("Quote Reply"),Component:"QuoteReplyCommentActionInitializer",schema:{"x-action":"create","x-decorator":"ACLActionProvider","x-align":"left"},useVisible(){return t.useCollection_deprecated().template!=="sql"}}]}]}),_=({collectionName:e,dataSource:o,association:a,rowKey:l})=>({type:"void","x-acl-action":`${a||e}:view`,"x-decorator":"Comment.Decorator","x-use-decorator-props":"useCommentBlockDecoratorProps","x-decorator-props":{collection:e,dataSource:o,association:a,readPretty:!0,action:"list",runWhenParamsChanged:!0},"x-component":"CardItem","x-toolbar":"BlockSchemaToolbar","x-settings":"blockSettings:comment",properties:{list:{type:"array","x-component":"Comment.List",properties:{item:{type:"object","x-component":"Comment.Item","x-read-pretty":!0,properties:{actionBar:{type:"void","x-align":"left","x-initializer":"comment:configureItemActions","x-component":"ActionBar","x-component-props":{layout:"one-column"}}}}}},submit:{type:"string","x-component":"Comment.Submit","x-acl-action":`${a||e}:create`,"x-decorator":"ACLCollectionProvider","x-decorator-props":{collection:e,dataSource:o,association:a}}}}),H=({filterCollections:e,filterOtherRecordsCollection:o,onlyCurrentDataSource:a,hideSearch:l,showAssociationFields:C,hideOtherRecordsInPopup:h})=>{const{insert:s}=t.useSchemaInitializer(),i=t.useSchemaInitializerItem();n.useContext(u.SchemaOptionsContext);const{getCollection:d}=t.useCollectionManager_deprecated();return r.jsx(t.DataBlockInitializer,v(b({},i),{componentType:"Comment",icon:r.jsx(L.CommentOutlined,{}),onlyCurrentDataSource:a,hideSearch:l,filter:e,filterOtherRecordsCollection:o,showAssociationFields:C,hideOtherRecordsInPopup:h,onCreateBlockSchema:w=>D(this,[w],function*({item:f,fromOthersInPopup:m}){const P=d(f.name,f.dataSource),k=f.associationField;s(_(k&&!m?{dataSource:f.dataSource,rowKey:P.filterTargetKey||"id",association:`${k.collectionName}.${k.name}`}:{collectionName:f.name,dataSource:f.dataSource,rowKey:P.filterTargetKey||"id"}))})}))},V=n.createContext({});function O(){return n.useContext(V)}const K=new t.SchemaSettings({name:"blockSettings:comment",items:[{name:"title",Component:t.SchemaSettingsBlockTitleItem},{name:"SetTheDataScope",Component:t.SchemaSettingsDataScope,useComponentProps(){var h,s;const{name:e}=t.useCollection_deprecated(),o=u.useFieldSchema(),{form:a}=t.useFormBlockContext(),l=u.useField(),{dn:C}=t.useDesignable();return{collectionName:e,defaultFilter:((s=(h=o==null?void 0:o["x-decorator-props"])==null?void 0:h.params)==null?void 0:s.filter)||{},form:a,onSubmit:({filter:i})=>{i=t.removeNullCondition(i),F.set(o,"x-decorator-props.params.filter",i),l.decoratorProps.params=v(b({},o["x-decorator-props"].params),{page:1}),C.emit("patch",{schema:{"x-uid":o["x-uid"],"x-decorator-props":o["x-decorator-props"]}})}}}},{name:"divider",type:"divider"},{name:"EnableCreate",type:"switch",useComponentProps(){const{setCreateAble:e,createAble:o}=O(),{t:a}=z();return{title:a("Enable Create"),checked:o,onChange:e}}},{name:"remove",type:"remove",componentProps:{removeParentsIfNoChildren:!0,breakRemoveOn:{"x-component":"Grid"}}}]});class W extends t.CollectionTemplate{constructor(){super(...arguments);A(this,"name","comment");A(this,"title",M("Comment Collection"));A(this,"order",2);A(this,"color","orange");A(this,"default",{fields:[{name:"content",type:"text",length:"long",interface:"vditor",deletable:!1,uiSchema:{type:"string",title:M("Comment Content"),interface:"vditor","x-component":"MarkdownVditor"}}]});A(this,"presetFieldsDisabled",!0);A(this,"configurableProperties",t.getConfigurableProperties("title","name","inherits","category","description","presetFields"))}}const G=t.withDynamicSchemaProps(e=>{let o;return r.jsx(Y,v(b({},e),{children:r.jsx(t.List.Decorator,v(b({},e),{children:r.jsx(t.CollectionManagerProvider,{dataSource:e.dataSource,children:r.jsx(t.CollectionProvider,{name:`${(o=e.association)!=null?o:e.collection}`,children:e.children})})}))}))});function Y(e){u.useField();const o=u.useFieldSchema(),[a,l]=n.useState(!1),{dn:C}=t.useDesignable();n.useEffect(()=>{var d;const i=(d=C.current["x-component-props"])==null?void 0:d.createAble;l(i===void 0?!0:i)},[]);const h=n.useCallback(i=>{const d=Object.assign({},o["x-component-props"],i);o["x-component-props"]=d,C.emit("patch",{schema:{"x-uid":o["x-uid"],"x-component-props":o["x-component-props"]}}),C.refresh()},[C,o]),s=n.useCallback(i=>{h({createAble:i}),l(i)},[l,h]);return r.jsx(V.Provider,{value:{createAble:a,setCreateAble:s},children:e.children})}const q=t.genStyleHook("tb-comment",e=>{const{componentCls:o}=e;return{[o]:{[`${o}-item-container-container`]:{"&:first-child":{border:"5px solid #d0d7deb3",position:"relative",zIndex:1,borderRadius:8}},[`${o}-item-container-border`]:{border:"1px solid #d0d7deb3",position:"relative",zIndex:1,borderRadius:8},[`${o}-item-container-line`]:{position:"absolute",top:0,bottom:0,content:"",display:"block",width:2,left:16,backgroundColor:"#d0d7deb3",zIndex:0},".ant-list-pagination":{marginTop:e.marginXS},".ant-card-head":{padding:"0 !important",fontWeight:"normal",backgroundColor:"#f6f8fa"},[`${o}-item-title`]:{color:"#636c76",display:"flex",alignItems:"center",paddingLeft:16,borderRadius:"8px 8px 0 0 ",justifyContent:"space-between",flexWrap:"wrap",[`${o}-item-title-left`]:{backgroundColor:"#f6f8fa",color:"#636c76",display:"flex",alignItems:"center",columnGap:6,"span:first-child":{fontWeight:"bold",fontSize:14},"span:not(:first-child)":{fontWeight:"normal",fontSize:14}},[`${o}-item-title-right`]:{marginRight:16,flexShrink:0}},[`${o}-item-editor`]:{position:"relative",zIndex:2,backgroundColor:"white",borderRadius:"0 0 8px 8px",[`${o}-item-editor-button-area`]:{marginTop:10,display:"flex",columnGap:5}}}}}),X=u.observer(({editing:e,setEditing:o,children:a})=>{var S,g;let l,C,h;const s=u.useField(),{t:i}=z(),{componentCls:d}=q(),f=t.useCollectionParentRecordData(),{resource:m,service:w}=t.useBlockRequestContext(),P=n.useCallback(()=>D(this,null,function*(){var p,y;yield m.update({filterByTk:(p=s.value)==null?void 0:p.id,values:{content:(y=s==null?void 0:s.value)==null?void 0:y.content}}),w.refresh()}),[m,w,s.value]),k=t.useCollectionFields(),I=n.useMemo(()=>{let p,y;return(y=(p=k.find(j=>j.name==="content"))==null?void 0:p.uiSchema)==null?void 0:y["x-component-props"]},[k]);return r.jsx(t.RecordProvider,{record:s.value,parent:f,children:r.jsxs("div",{className:`${d}-item-container`,children:[r.jsx("div",{className:`${d}-item-container-line`}),r.jsx(x.Card,{size:"small",title:r.jsxs("div",{className:`${d}-item-title`,children:[r.jsxs("div",{className:`${d}-item-title-left`,children:[r.jsx("span",{children:(C=(l=s==null?void 0:s.value)==null?void 0:l.createdBy)==null?void 0:C.nickname}),r.jsx("span",{children:i("commented")}),r.jsx(x.Tooltip,{title:B((h=s==null?void 0:s.value)==null?void 0:h.createdAt).format("YYYY-MM-DD HH:mm:ss"),children:r.jsx("span",{children:B((S=s==null?void 0:s.value)==null?void 0:S.createdAt).fromNow()})})]}),r.jsx("div",{className:`${d}-item-title-right`,children:a})]}),children:r.jsxs("div",{className:`${d}-item-editor`,children:[r.jsx(u.RecursionField,{basePath:s.address,name:"content",schema:{type:"string",name:"content","x-component":"MarkdownVditor","x-component-props":v(b({},I),{value:(g=s==null?void 0:s.value)==null?void 0:g.content}),"x-read-pretty":!0}}),e&&r.jsxs("div",{className:`${d}-item-editor-button-area`,children:[r.jsx(x.Button,{onClick:()=>{s.form.setFieldState(`${s.address}.content`,p=>{p.pattern="readPretty"}),o(!1)},children:i("Cancel")}),r.jsx(x.Button,{type:"primary",onClick:()=>{o(!1),P(),s.form.setFieldState(`${s.address}.content`,p=>{p.pattern="readPretty"})},children:i("Update Comment")})]})]})})]})})}),J=t.withDynamicSchemaProps(e=>{var k,I;const o=u.useFieldSchema(),a=u.useField(),[l]=n.useState(new Map),{wrapSSR:C,hashId:h,componentCls:s}=q();u.useForm();const{service:i}=t.useBlockRequestContext(),{run:d,params:f}=i,m=(k=i==null?void 0:i.data)==null?void 0:k.meta,w=n.useCallback(S=>(l.has(S)||l.set(S,new u.Schema({type:"object",properties:{[S]:o.properties.item}})),l.get(S)),[o.properties,l]),P=n.useCallback((S,g)=>{d(v(b({},f==null?void 0:f[0]),{page:S,pageSize:g}))},[d,f]);return i!=null&&i.loading?r.jsx("div",{style:{display:"flex",justifyContent:"center"},children:r.jsx(x.Spin,{spinning:!0})}):C(r.jsx("div",{className:`${s} ${h}`,children:r.jsx(x.List,v(b({},e),{pagination:!m||m.count<=m.pageSize?!1:{onChange:P,total:(m==null?void 0:m.count)||0,pageSize:(m==null?void 0:m.pageSize)||10,current:(m==null?void 0:m.page)||1},children:r.jsx("div",{style:{display:"flex",flexDirection:"column"},children:(I=a.value)!=null&&I.length?a.value.map((S,g)=>{const p=g===0,y=g===a.value.length-1;return r.jsx("div",{style:{position:"relative",padding:`${p?0:"10px"} 0 ${y?0:"10px"} 0`},children:r.jsx(u.RecursionField,{basePath:a.address,name:g,onlyRenderProperties:!0,schema:w(g)})},g)}):null})}))}))});function Z(){var g;const e=u.useField(),o=n.useCallback(p=>{e.setValue(v(b({},e.value),{content:p}))},[e]),{t:a}=z(),{wrapSSR:l,componentCls:C,hashId:h}=q(),s=n.useMemo(()=>{var p,y;return((y=(p=e.value)==null?void 0:p.content)==null?void 0:y.trim().length)>0},[e.value]),{resource:i,service:d}=t.useBlockRequestContext(),f=n.useCallback(()=>D(this,null,function*(){yield i.create({values:e.value}),o(""),d.refresh()}),[i,e,d,o]),{createAble:m}=O(),w=t.useACLActionParamsContext(),{designable:P}=t.useDesignable(),k=!P&&(((g=e==null?void 0:e.data)==null?void 0:g.hidden)||!w),I=t.useCollectionFields(),S=n.useMemo(()=>{var p,y;return(y=(p=I.find(j=>j.name==="content"))==null?void 0:p.uiSchema)==null?void 0:y["x-component-props"]},[I]);return!m||k?null:l(r.jsxs("div",{style:{marginTop:10},className:`${C} ${h}`,children:[r.jsx(u.RecursionField,{basePath:e.address,name:"content",schema:{type:"string","x-component":"MarkdownVditor","x-component-props":v(b({},S),{onChange:p=>{o(p)}}),"x-read-pretty":!1,"x-read-only":!1,name:"content"}}),r.jsx(x.Button,{disabled:!s,onClick:f,type:"primary",style:{marginTop:10},children:a("Comment")})]}))}function R(){var h;const e=u.useField(),{t:o}=z(),a=t.useACLActionParamsContext(),{designable:l}=t.useDesignable(),C=n.useCallback(()=>{var f;const s=e.address.slice(0,e.address.length-4).concat("submit.content"),i=e.address.slice(0,e.address.length-2).concat("content"),d=(f=e.form.getValuesIn(i))!=null?f:"";e.form.setValuesIn(s,`${d.split(`
|
|
1
|
+
(function(c,a){typeof exports=="object"&&typeof module!="undefined"?a(exports,require("react"),require("@tachybase/client"),require("react-i18next"),require("@tachybase/schema"),require("@ant-design/icons"),require("react/jsx-runtime"),require("lodash"),require("antd"),require("dayjs")):typeof define=="function"&&define.amd?define(["exports","react","@tachybase/client","react-i18next","@tachybase/schema","@ant-design/icons","react/jsx-runtime","lodash","antd","dayjs"],a):(c=typeof globalThis!="undefined"?globalThis:c||self,a(c["@tachybase/plugin-block-comments"]={},c.react,c["@tachybase/client"],c["react-i18next"],c["@tachybase/schema"],c["@ant-design/icons"],c.jsxRuntime,c.lodash,c.antd,c.dayjs))})(this,function(c,a,t,D,u,T,r,w,x,I){"use strict";var ae=Object.defineProperty,re=Object.defineProperties;var se=Object.getOwnPropertyDescriptors;var V=Object.getOwnPropertySymbols;var ie=Object.prototype.hasOwnProperty,ce=Object.prototype.propertyIsEnumerable;var O=(c,a,t)=>a in c?ae(c,a,{enumerable:!0,configurable:!0,writable:!0,value:t}):c[a]=t,b=(c,a)=>{for(var t in a||(a={}))ie.call(a,t)&&O(c,t,a[t]);if(V)for(var t of V(a))ce.call(a,t)&&O(c,t,a[t]);return c},v=(c,a)=>re(c,se(a));var M=(c,a,t)=>new Promise((D,u)=>{var T=x=>{try{w(t.next(x))}catch(I){u(I)}},r=x=>{try{w(t.throw(x))}catch(I){u(I)}},w=x=>x.done?D(x.value):Promise.resolve(x.value).then(T,r);w((t=t.apply(c,a)).next())});function F(e){return t.tval(e,{ns:j})}const j="block-comments";function B(){return D.useTranslation(j)}const Q=new t.SchemaInitializer({name:"comment:configureItemActions",title:'{{t("Configure actions")}}',icon:"SettingOutlined",items:[{type:"itemGroup",name:"enableActions",title:'{{t("Enable actions")}}',children:[{name:"edit",title:'{{t("Edit")}}',Component:"UpdateCommentActionInitializer",schema:{"x-action":"update","x-decorator":"ACLActionProvider","x-align":"left"},useVisible(){const e=t.useCollection_deprecated();return(e.template!=="view"||(e==null?void 0:e.writableView))&&e.template!=="sql"}},{name:"delete",title:'{{t("Delete")}}',Component:"DestroyActionInitializer",schema:{"x-component":"Action.Link","x-action":"destroy","x-decorator":"ACLActionProvider","x-align":"left"},useVisible(){return t.useCollection_deprecated().template!=="sql"}},{name:"reply",title:F("Quote Reply"),Component:"QuoteReplyCommentActionInitializer",schema:{"x-action":"create","x-decorator":"ACLActionProvider","x-align":"left"},useVisible(){return t.useCollection_deprecated().template!=="sql"}}]}]}),U=({collectionName:e,dataSource:o,association:n,rowKey:l})=>({type:"void","x-acl-action":`${n||e}:view`,"x-decorator":"Comment.Decorator","x-use-decorator-props":"useCommentBlockDecoratorProps","x-decorator-props":{collection:e,dataSource:o,association:n,readPretty:!0,action:"list",runWhenParamsChanged:!0},"x-component":"CardItem","x-toolbar":"BlockSchemaToolbar","x-settings":"blockSettings:comment",properties:{list:{type:"array","x-component":"Comment.List",properties:{item:{type:"object","x-component":"Comment.Item","x-read-pretty":!0,properties:{actionBar:{type:"void","x-align":"left","x-initializer":"comment:configureItemActions","x-component":"ActionBar","x-component-props":{layout:"one-column"}}}}}},submit:{type:"string","x-component":"Comment.Submit","x-acl-action":`${n||e}:create`,"x-decorator":"ACLCollectionProvider","x-decorator-props":{collection:e,dataSource:o,association:n}}}}),_=({filterCollections:e,filterOtherRecordsCollection:o,onlyCurrentDataSource:n,hideSearch:l,showAssociationFields:h,hideOtherRecordsInPopup:C})=>{const{insert:s}=t.useSchemaInitializer(),i=t.useSchemaInitializerItem();a.useContext(u.SchemaOptionsContext);const{getCollection:d}=t.useCollectionManager_deprecated();return r.jsx(t.DataBlockInitializer,v(b({},i),{componentType:"Comment",icon:r.jsx(T.CommentOutlined,{}),onlyCurrentDataSource:n,hideSearch:l,filter:e,filterOtherRecordsCollection:o,showAssociationFields:h,hideOtherRecordsInPopup:C,onCreateBlockSchema:$=>M(this,[$],function*({item:f,fromOthersInPopup:m}){const P=d(f.name,f.dataSource),k=f.associationField;s(U(k&&!m?{dataSource:f.dataSource,rowKey:P.filterTargetKey||"id",association:`${k.collectionName}.${k.name}`}:{collectionName:f.name,dataSource:f.dataSource,rowKey:P.filterTargetKey||"id"}))})}))},N=a.createContext({});function E(){return a.useContext(N)}const H=new t.SchemaSettings({name:"blockSettings:comment",items:[{name:"title",Component:t.SchemaSettingsBlockTitleItem},{name:"SetTheDataScope",Component:t.SchemaSettingsDataScope,useComponentProps(){var C,s;const{name:e}=t.useCollection_deprecated(),o=u.useFieldSchema(),{form:n}=t.useFormBlockContext(),l=u.useField(),{dn:h}=t.useDesignable();return{collectionName:e,defaultFilter:((s=(C=o==null?void 0:o["x-decorator-props"])==null?void 0:C.params)==null?void 0:s.filter)||{},form:n,onSubmit:({filter:i})=>{i=t.removeNullCondition(i),w.set(o,"x-decorator-props.params.filter",i),l.decoratorProps.params=v(b({},o["x-decorator-props"].params),{page:1}),h.emit("patch",{schema:{"x-uid":o["x-uid"],"x-decorator-props":o["x-decorator-props"]}})}}}},{name:"divider",type:"divider"},{name:"EnableCreate",type:"switch",useComponentProps(){const{setCreateAble:e,createAble:o}=E(),{t:n}=B();return{title:n("Enable Create"),checked:o,onChange:e}}},{name:"remove",type:"remove",componentProps:{removeParentsIfNoChildren:!0,breakRemoveOn:{"x-component":"Grid"}}}]});class K extends t.CollectionTemplate{constructor(){super(...arguments),this.name="comment",this.title=F("Comment Collection"),this.order=2,this.color="orange",this.default={fields:[{name:"content",type:"text",length:"long",interface:"vditor",deletable:!1,uiSchema:{type:"string",title:F("Comment Content"),interface:"vditor","x-component":"MarkdownVditor"}}]},this.presetFieldsDisabled=!0,this.configurableProperties=t.getConfigurableProperties("title","name","inherits","category","description","presetFields")}}const W=t.withDynamicSchemaProps(e=>{let o;return r.jsx(G,v(b({},e),{children:r.jsx(t.List.Decorator,v(b({},e),{children:r.jsx(t.CollectionManagerProvider,{dataSource:e.dataSource,children:r.jsx(t.CollectionProvider,{name:`${(o=e.association)!=null?o:e.collection}`,children:e.children})})}))}))});function G(e){u.useField();const o=u.useFieldSchema(),[n,l]=a.useState(!1),{dn:h}=t.useDesignable();a.useEffect(()=>{var d;const i=(d=h.current["x-component-props"])==null?void 0:d.createAble;l(i===void 0?!0:i)},[]);const C=a.useCallback(i=>{const d=Object.assign({},o["x-component-props"],i);o["x-component-props"]=d,h.emit("patch",{schema:{"x-uid":o["x-uid"],"x-component-props":o["x-component-props"]}}),h.refresh()},[h,o]),s=a.useCallback(i=>{C({createAble:i}),l(i)},[l,C]);return r.jsx(N.Provider,{value:{createAble:n,setCreateAble:s},children:e.children})}const L=t.genStyleHook("tb-comment",e=>{const{componentCls:o}=e;return{[o]:{[`${o}-item-container-container`]:{"&:first-child":{border:"5px solid #d0d7deb3",position:"relative",zIndex:1,borderRadius:8}},[`${o}-item-container-border`]:{border:"1px solid #d0d7deb3",position:"relative",zIndex:1,borderRadius:8},[`${o}-item-container-line`]:{position:"absolute",top:0,bottom:0,content:"",display:"block",width:2,left:16,backgroundColor:"#d0d7deb3",zIndex:0},".ant-list-pagination":{marginTop:e.marginXS},".ant-card-head":{padding:"0 !important",fontWeight:"normal",backgroundColor:"#f6f8fa"},[`${o}-item-title`]:{color:"#636c76",display:"flex",alignItems:"center",paddingLeft:16,borderRadius:"8px 8px 0 0 ",justifyContent:"space-between",flexWrap:"wrap",[`${o}-item-title-left`]:{backgroundColor:"#f6f8fa",color:"#636c76",display:"flex",alignItems:"center",columnGap:6,"span:first-child":{fontWeight:"bold",fontSize:14},"span:not(:first-child)":{fontWeight:"normal",fontSize:14}},[`${o}-item-title-right`]:{marginRight:16,flexShrink:0}},[`${o}-item-editor`]:{position:"relative",zIndex:2,backgroundColor:"white",borderRadius:"0 0 8px 8px",[`${o}-item-editor-button-area`]:{marginTop:10,display:"flex",columnGap:5}}}}}),Y=u.observer(({editing:e,setEditing:o,children:n})=>{var S,g;let l,h,C;const s=u.useField(),{t:i}=B(),{componentCls:d}=L(),f=t.useCollectionParentRecordData(),{resource:m,service:$}=t.useBlockRequestContext(),P=a.useCallback(()=>M(this,null,function*(){var p,y;yield m.update({filterByTk:(p=s.value)==null?void 0:p.id,values:{content:(y=s==null?void 0:s.value)==null?void 0:y.content}}),$.refresh()}),[m,$,s.value]),k=t.useCollectionFields(),A=a.useMemo(()=>{let p,y;return(y=(p=k.find(q=>q.name==="content"))==null?void 0:p.uiSchema)==null?void 0:y["x-component-props"]},[k]);return r.jsx(t.RecordProvider,{record:s.value,parent:f,children:r.jsxs("div",{className:`${d}-item-container`,children:[r.jsx("div",{className:`${d}-item-container-line`}),r.jsx(x.Card,{size:"small",title:r.jsxs("div",{className:`${d}-item-title`,children:[r.jsxs("div",{className:`${d}-item-title-left`,children:[r.jsx("span",{children:(h=(l=s==null?void 0:s.value)==null?void 0:l.createdBy)==null?void 0:h.nickname}),r.jsx("span",{children:i("commented")}),r.jsx(x.Tooltip,{title:I((C=s==null?void 0:s.value)==null?void 0:C.createdAt).format("YYYY-MM-DD HH:mm:ss"),children:r.jsx("span",{children:I((S=s==null?void 0:s.value)==null?void 0:S.createdAt).fromNow()})})]}),r.jsx("div",{className:`${d}-item-title-right`,children:n})]}),children:r.jsxs("div",{className:`${d}-item-editor`,children:[r.jsx(u.RecursionField,{basePath:s.address,name:"content",schema:{type:"string",name:"content","x-component":"MarkdownVditor","x-component-props":v(b({},A),{value:(g=s==null?void 0:s.value)==null?void 0:g.content}),"x-read-pretty":!0}}),e&&r.jsxs("div",{className:`${d}-item-editor-button-area`,children:[r.jsx(x.Button,{onClick:()=>{s.form.setFieldState(`${s.address}.content`,p=>{p.pattern="readPretty"}),o(!1)},children:i("Cancel")}),r.jsx(x.Button,{type:"primary",onClick:()=>{o(!1),P(),s.form.setFieldState(`${s.address}.content`,p=>{p.pattern="readPretty"})},children:i("Update Comment")})]})]})})]})})}),X=t.withDynamicSchemaProps(e=>{var k,A;const o=u.useFieldSchema(),n=u.useField(),[l]=a.useState(new Map),{wrapSSR:h,hashId:C,componentCls:s}=L();u.useForm();const{service:i}=t.useBlockRequestContext(),{run:d,params:f}=i,m=(k=i==null?void 0:i.data)==null?void 0:k.meta,$=a.useCallback(S=>(l.has(S)||l.set(S,new u.Schema({type:"object",properties:{[S]:o.properties.item}})),l.get(S)),[o.properties,l]),P=a.useCallback((S,g)=>{d(v(b({},f==null?void 0:f[0]),{page:S,pageSize:g}))},[d,f]);return i!=null&&i.loading?r.jsx("div",{style:{display:"flex",justifyContent:"center"},children:r.jsx(x.Spin,{spinning:!0})}):h(r.jsx("div",{className:`${s} ${C}`,children:r.jsx(x.List,v(b({},e),{pagination:!m||m.count<=m.pageSize?!1:{onChange:P,total:(m==null?void 0:m.count)||0,pageSize:(m==null?void 0:m.pageSize)||10,current:(m==null?void 0:m.page)||1},children:r.jsx("div",{style:{display:"flex",flexDirection:"column"},children:(A=n.value)!=null&&A.length?n.value.map((S,g)=>{const p=g===0,y=g===n.value.length-1;return r.jsx("div",{style:{position:"relative",padding:`${p?0:"10px"} 0 ${y?0:"10px"} 0`},children:r.jsx(u.RecursionField,{basePath:n.address,name:g,onlyRenderProperties:!0,schema:$(g)})},g)}):null})}))}))});function J(){var g;const e=u.useField(),o=a.useCallback(p=>{e.setValue(v(b({},e.value),{content:p}))},[e]),{t:n}=B(),{wrapSSR:l,componentCls:h,hashId:C}=L(),s=a.useMemo(()=>{var p,y;return((y=(p=e.value)==null?void 0:p.content)==null?void 0:y.trim().length)>0},[e.value]),{resource:i,service:d}=t.useBlockRequestContext(),f=a.useCallback(()=>M(this,null,function*(){yield i.create({values:e.value}),o(""),d.refresh()}),[i,e,d,o]),{createAble:m}=E(),$=t.useACLActionParamsContext(),{designable:P}=t.useDesignable(),k=!P&&(((g=e==null?void 0:e.data)==null?void 0:g.hidden)||!$),A=t.useCollectionFields(),S=a.useMemo(()=>{var p,y;return(y=(p=A.find(q=>q.name==="content"))==null?void 0:p.uiSchema)==null?void 0:y["x-component-props"]},[A]);return!m||k?null:l(r.jsxs("div",{style:{marginTop:10},className:`${h} ${C}`,children:[r.jsx(u.RecursionField,{basePath:e.address,name:"content",schema:{type:"string","x-component":"MarkdownVditor","x-component-props":v(b({},S),{onChange:p=>{o(p)}}),"x-read-pretty":!1,"x-read-only":!1,name:"content"}}),r.jsx(x.Button,{disabled:!s,onClick:f,type:"primary",style:{marginTop:10},children:n("Comment")})]}))}function Z(){var C;const e=u.useField(),{t:o}=B(),n=t.useACLActionParamsContext(),{designable:l}=t.useDesignable(),h=a.useCallback(()=>{var f;const s=e.address.slice(0,e.address.length-4).concat("submit.content"),i=e.address.slice(0,e.address.length-2).concat("content"),d=(f=e.form.getValuesIn(i))!=null?f:"";e.form.setValuesIn(s,`${d.split(`
|
|
2
2
|
`).map(m=>`> ${m}`).join(`
|
|
3
|
-
`)}`)},[e.address,e.form]);return!l&&((
|
|
3
|
+
`)}`)},[e.address,e.form]);return!l&&((C=e==null?void 0:e.data)!=null&&C.hidden||!n)?null:r.jsx("a",{style:{fontSize:14},onClick:h,children:o("Quote Reply")})}function R(e){const{t:o}=B(),n={type:"void",title:o("Quote Reply"),"x-component":"QuoteReplyCommentActionButton"};return r.jsx(t.ActionInitializer,v(b({},e),{schema:n}))}function ee(){var s;const e=u.useField(),{t:o}=B(),[n,l]=a.useState(!1),h=t.useACLActionParamsContext(),{designable:C}=t.useDesignable();return a.useEffect(()=>{const i=e.address.slice(0,e.address.length-2);e.form.setFieldState(i.concat("content"),d=>{d.pattern=n?"editable":"readPretty"}),e.form.setFieldState(i,d=>{d.componentProps=v(b({},d.componentProps),{editing:n,setEditing:l})})},[n,e.address,e.form]),!C&&((s=e==null?void 0:e.data)!=null&&s.hidden||!h)?null:r.jsx("a",{style:{fontSize:14},onClick:()=>{l(!0)},children:o("Edit")})}function te(e){const o={type:"void",title:'{{t("Edit")}}',"x-component":"UpdateCommentActionButton"};return r.jsx(t.ActionInitializer,v(b({},e),{schema:o}))}function oe(e){let o;return e.association&&(o=t.useParentRecordCommon(e.association)),{parentRecord:o,params:{pageSize:100,appends:["createdBy"],sort:["createdAt"]}}}const z=()=>null;z.ActionBar=t.ActionBar,z.List=X,z.Item=Y,z.Decorator=W,z.Submit=J;class ne extends t.Plugin{load(){return M(this,null,function*(){this.app.dataSourceManager.addCollectionTemplates([K]),this.app.schemaInitializerManager.addItem("page:addBlock","dataBlocks.comment",{title:F("Comment"),Component:"CommentBlockInitializer",useComponentProps(){return{filterCollections({collection:o}){return o.template==="comment"}}}}),this.app.schemaInitializerManager.addItem("popup:common:addBlock","dataBlocks.comment",{title:F("Comment"),Component:"CommentBlockInitializer",useVisible(){const o=t.useCollection();return a.useMemo(()=>o.fields.some(n=>t.canMakeAssociationBlock(n)&&["hasMany","belongsToMany"].includes(n.type)),[o.fields])},useComponentProps(){const o=t.useCollectionManager();return{onlyCurrentDataSource:!0,filterCollections({associationField:n}){if(n){if(!["hasMany","belongsToMany"].includes(n.type))return!1;const l=o.getCollection(n.target);return(l==null?void 0:l.template)==="comment"}return!1},filterOtherRecordsCollection(n){return(n==null?void 0:n.template)==="comment"},showAssociationFields:!0,hideOtherRecordsInPopup:!1,hideSearch:!0}}}),this.app.addComponents({CommentBlockInitializer:_,Comment:z,UpdateCommentActionInitializer:te,UpdateCommentActionButton:ee,QuoteReplyCommentActionButton:Z,QuoteReplyCommentActionInitializer:R}),this.app.addScopes({useCommentBlockDecoratorProps:oe}),this.schemaSettingsManager.add(H),this.schemaInitializerManager.add(Q)})}}c.default=ne,Object.defineProperties(c,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}})});
|
package/dist/externalVersion.js
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
module.exports = {
|
|
2
|
-
"@tachybase/client": "0.23.
|
|
2
|
+
"@tachybase/client": "0.23.47",
|
|
3
3
|
"react": "18.3.1",
|
|
4
|
-
"@tachybase/schema": "0.23.
|
|
4
|
+
"@tachybase/schema": "0.23.47",
|
|
5
5
|
"@ant-design/icons": "5.3.7",
|
|
6
6
|
"lodash": "4.17.21",
|
|
7
7
|
"antd": "5.22.5",
|
|
8
8
|
"dayjs": "1.11.13",
|
|
9
9
|
"react-i18next": "15.2.0",
|
|
10
|
-
"@tachybase/server": "0.23.
|
|
10
|
+
"@tachybase/server": "0.23.47"
|
|
11
11
|
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@tachybase/plugin-block-comments",
|
|
3
|
-
"version": "0.23.
|
|
3
|
+
"version": "0.23.47",
|
|
4
4
|
"main": "dist/server/index.js",
|
|
5
5
|
"dependencies": {},
|
|
6
6
|
"devDependencies": {
|
|
@@ -9,13 +9,13 @@
|
|
|
9
9
|
"dayjs": "1.11.13",
|
|
10
10
|
"lodash": "^4.17.21",
|
|
11
11
|
"react-i18next": "^15.2.0",
|
|
12
|
-
"@tachybase/
|
|
13
|
-
"@tachybase/
|
|
12
|
+
"@tachybase/components": "0.23.47",
|
|
13
|
+
"@tachybase/schema": "0.23.47"
|
|
14
14
|
},
|
|
15
15
|
"peerDependencies": {
|
|
16
|
-
"@tachybase/
|
|
17
|
-
"@tachybase/
|
|
18
|
-
"@tachybase/test": "0.23.
|
|
16
|
+
"@tachybase/client": "0.23.47",
|
|
17
|
+
"@tachybase/server": "0.23.47",
|
|
18
|
+
"@tachybase/test": "0.23.47"
|
|
19
19
|
},
|
|
20
20
|
"description.zh-CN": "评论",
|
|
21
21
|
"displayName.zh-CN": "评论",
|