@tachybase/plugin-block-comments 1.3.16 → 1.3.18
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 +1 -1
- package/dist/externalVersion.js +3 -3
- package/dist/index.js +4 -4
- package/package.json +6 -6
package/dist/client/index.js
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
(function(c,a){typeof exports=="object"&&typeof module!="undefined"?a(exports,require("react"),require("@tachybase/client"),require("react-i18next"),require("react/jsx-runtime"),require("@tachybase/schema"),require("@ant-design/icons"),require("lodash"),require("antd"),require("dayjs")):typeof define=="function"&&define.amd?define(["exports","react","@tachybase/client","react-i18next","react/jsx-runtime","@tachybase/schema","@ant-design/icons","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.jsxRuntime,c["@tachybase/schema"],c["@ant-design/icons"],c.lodash,c.antd,c.dayjs))})(this,function(c,a,t,T,s,C,D,$,g,I){"use strict";var ae=Object.defineProperty,se=Object.defineProperties;var ie=Object.getOwnPropertyDescriptors;var E=Object.getOwnPropertySymbols;var ce=Object.prototype.hasOwnProperty,le=Object.prototype.propertyIsEnumerable;var V=(c,a,t)=>a in c?ae(c,a,{enumerable:!0,configurable:!0,writable:!0,value:t}):c[a]=t,x=(c,a)=>{for(var t in a||(a={}))ce.call(a,t)&&V(c,t,a[t]);if(E)for(var t of E(a))le.call(a,t)&&V(c,t,a[t]);return c},b=(c,a)=>se(c,ie(a));var M=(c,a,t)=>new Promise((T,s)=>{var C=g=>{try{$(t.next(g))}catch(I){s(I)}},D=g=>{try{$(t.throw(g))}catch(I){s(I)}},$=g=>g.done?T(g.value):Promise.resolve(g.value).then(C,D);$((t=t.apply(c,a)).next())});const L="block-comments";function w(e){return t.tval(e,{ns:L})}function B(){return T.useTranslation(L)}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:w("Quote Reply"),Component:"QuoteReplyCommentActionInitializer",schema:{"x-action":"create","x-decorator":"ACLActionProvider","x-align":"left"},useVisible(){return t.useCollection_deprecated().template!=="sql"}}]}]}),O=({collectionName:e,dataSource:o,association:r,rowKey:n})=>({type:"void","x-acl-action":`${r||e}:view`,"x-decorator":"Comment.Decorator","x-use-decorator-props":"useCommentBlockDecoratorProps","x-decorator-props":{collection:e,dataSource:o,association:r,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":`${r||e}:create`,"x-decorator":"ACLCollectionProvider","x-decorator-props":{collection:e,dataSource:o,association:r}}}}),Q=({filterCollections:e,filterOtherRecordsCollection:o,onlyCurrentDataSource:r,hideSearch:n,showAssociationFields:p,hideOtherRecordsInPopup:d})=>{const{insert:f}=t.useSchemaInitializer(),i=t.useSchemaInitializerItem();a.useContext(C.SchemaOptionsContext);const{getCollection:u}=t.useCollectionManager_deprecated(),y=F=>M(this,[F],function*({item:m,fromOthersInPopup:k}){const v=u(m.name,m.dataSource),S=m.associationField;f(O(S&&!k?{dataSource:m.dataSource,rowKey:v.filterTargetKey||"id",association:`${S.collectionName}.${S.name}`}:{collectionName:m.name,dataSource:m.dataSource,rowKey:v.filterTargetKey||"id"}))});return s.jsx(t.DataBlockInitializer,b(x({},i),{componentType:"Comment",icon:s.jsx(D.CommentOutlined,{}),onlyCurrentDataSource:r,hideSearch:n,filter:e,filterOtherRecordsCollection:o,showAssociationFields:p,hideOtherRecordsInPopup:d,onCreateBlockSchema:y}))},j=a.createContext({});function N(){return a.useContext(j)}const _=new t.SchemaSettings({name:"blockSettings:comment",items:[{name:"title",Component:t.SchemaSettingsBlockTitleItem},{name:"SetTheDataScope",Component:t.SchemaSettingsDataScope,useComponentProps(){var d,f;const{name:e}=t.useCollection_deprecated(),o=C.useFieldSchema(),{form:r}=t.useFormBlockContext(),n=C.useField(),{dn:p}=t.useDesignable();return{collectionName:e,defaultFilter:((f=(d=o==null?void 0:o["x-decorator-props"])==null?void 0:d.params)==null?void 0:f.filter)||{},form:r,onSubmit:({filter:i})=>{i=t.removeNullCondition(i),$.set(o,"x-decorator-props.params.filter",i),n.decoratorProps.params=b(x({},o["x-decorator-props"].params),{page:1}),p.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}=N(),{t:r}=B();return{title:r("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=w("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:w("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=>{const{dataSource:o,association:r,collection:n,children:p}=e,d=`${r||n}`;return s.jsx(G,b(x({},e),{children:s.jsx(t.List.Decorator,b(x({},e),{children:s.jsx(t.CollectionManagerProvider,{dataSource:o,children:s.jsx(t.CollectionProvider,{name:d,children:p})})}))}))}),G=({children:e})=>{const o=C.useFieldSchema(),[r,n]=a.useState(!1),{dn:p}=t.useDesignable(),d=a.useCallback(i=>{const u=x(x({},o["x-component-props"]),i);o["x-component-props"]=u,p.emit("patch",{schema:{"x-uid":o["x-uid"],"x-component-props":o["x-component-props"]}}),p.refresh()},[p,o]),f=a.useCallback(i=>{d({createAble:i}),n(i)},[n,d]);return a.useEffect(()=>{var u;const i=(u=p.current["x-component-props"])==null?void 0:u.createAble;n(i!=null?i:!0)},[]),s.jsx(j.Provider,{value:{createAble:r,setCreateAble:f},children:e})},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}}}}}),H=C.observer(({editing:e,setEditing:o,children:r})=>{var v,S,P;const n=C.useField(),{t:p}=B(),{componentCls:d}=q(),f=t.useCollectionParentRecordData(),{resource:i,service:u}=t.useBlockRequestContext(),y=a.useCallback(()=>M(this,null,function*(){var h,l;yield i.update({filterByTk:(h=n.value)==null?void 0:h.id,values:{content:(l=n==null?void 0:n.value)==null?void 0:l.content}}),u.refresh()}),[i,u,n.value]),m=t.useCollectionFields(),k=a.useMemo(()=>{var l;const h=m.find(A=>A.name==="content");return(l=h==null?void 0:h.uiSchema)==null?void 0:l["x-component-props"]},[m]),F=()=>{o(!1),y(),n.form.setFieldState(`${n.address}.content`,h=>{h.pattern="readPretty"})};return s.jsx(t.RecordProvider,{record:n.value,parent:f,children:s.jsxs("div",{className:`${d}-item-container`,children:[s.jsx("div",{className:`${d}-item-container-line`}),s.jsxs(g.Card,{size:"small",title:s.jsxs("div",{className:`${d}-item-title`,children:[s.jsxs("div",{className:`${d}-item-title-left`,children:[s.jsx("span",{children:p("commented")}),s.jsx(g.Tooltip,{title:I((v=n==null?void 0:n.value)==null?void 0:v.createdAt).format("YYYY-MM-DD HH:mm:ss"),children:s.jsx("span",{children:I((S=n==null?void 0:n.value)==null?void 0:S.createdAt).fromNow()})})]}),s.jsx("div",{className:`${d}-item-title-right`,children:r})]}),children:[s.jsx(C.RecursionField,{name:"content",basePath:n.address,schema:{type:"string",name:"content","x-component":"MarkdownVditor","x-component-props":b(x({},k),{value:(P=n==null?void 0:n.value)==null?void 0:P.content}),"x-read-pretty":!0}}),e&&s.jsxs("div",{className:`${d}-item-editor-button-area`,children:[s.jsx(g.Button,{onClick:()=>{n.form.setFieldState(`${n.address}.content`,h=>{h.pattern="readPretty"}),o(!1)},children:p("Cancel")}),s.jsx(g.Button,{type:"primary",onClick:F,children:p("Update Comment")})]})]})]})})}),Y=t.withDynamicSchemaProps(e=>{var S,P;const o=C.useFieldSchema(),r=C.useField(),[n]=a.useState(new Map),{wrapSSR:p,hashId:d,componentCls:f}=q(),{service:i}=t.useBlockRequestContext(),{run:u,params:y}=i,m=(S=i==null?void 0:i.data)==null?void 0:S.meta,k=a.useCallback(h=>{if(n.has(h))return n.get(h);const l=new C.Schema({type:"object",properties:{[h]:o.properties.item}});return n.set(h,l),l},[o.properties,n]),F=a.useCallback((h,l)=>{u(b(x({},y==null?void 0:y[0]),{page:h,pageSize:l}))},[u,y]),v=!m||m.count<=m.pageSize?!1:{onChange:F,total:(m==null?void 0:m.count)||0,pageSize:(m==null?void 0:m.pageSize)||10,current:(m==null?void 0:m.page)||1};return i!=null&&i.loading?s.jsx("div",{style:{display:"flex",justifyContent:"center"},children:s.jsx(g.Spin,{spinning:!0})}):p(s.jsx("div",{className:`${f} ${d}`,children:s.jsx(g.List,b(x({},e),{pagination:v,children:s.jsx("div",{style:{display:"flex",flexDirection:"column"},children:(P=r.value)!=null&&P.length?r.value.map((h,l)=>s.jsx("div",{style:{position:"relative",padding:`${l===0?0:"10px"} 0 ${l===r.value.length-1?0:"10px"} 0`},children:s.jsx(C.RecursionField,{basePath:r.address,name:l,onlyRenderProperties:!0,schema:k(l)})},l)):null})}))}))});function X(){var h;const e=C.useField(),o=a.useCallback(l=>{e.setValue(b(x({},e.value),{content:l}))},[e]),{t:r}=B(),{wrapSSR:n,componentCls:p,hashId:d}=q(),f=a.useMemo(()=>{var l,A;return((A=(l=e.value)==null?void 0:l.content)==null?void 0:A.trim().length)>0},[e.value]),{resource:i,service:u}=t.useBlockRequestContext(),y=a.useCallback(()=>M(this,null,function*(){yield i.create({values:e.value}),o(""),u.refresh()}),[i,e,u,o]),{createAble:m}=N(),k=t.useACLActionParamsContext(),{designable:F}=t.useDesignable(),v=!F&&(((h=e==null?void 0:e.data)==null?void 0:h.hidden)||!k),S=t.useCollectionFields(),P=a.useMemo(()=>{var l,A;return(A=(l=S.find(re=>re.name==="content"))==null?void 0:l.uiSchema)==null?void 0:A["x-component-props"]},[S]);return!m||v?null:n(s.jsxs("div",{style:{marginTop:10},className:`${p} ${d}`,children:[s.jsx(C.RecursionField,{basePath:e.address,name:"content",schema:{name:"content",type:"string","x-component":"MarkdownVditor","x-component-props":b(x({},P),{onChange:l=>{o(l)}}),"x-read-pretty":!1,"x-read-only":!1}}),s.jsx(g.Button,{style:{marginTop:10},type:"primary",disabled:!f,onClick:y,children:r("Comment")})]}))}function J(){var d;const e=C.useField(),{t:o}=B(),r=t.useACLActionParamsContext(),{designable:n}=t.useDesignable(),p=a.useCallback(()=>{var y;const f=e.address.slice(0,e.address.length-4).concat("submit.content"),i=e.address.slice(0,e.address.length-2).concat("content"),u=(y=e.form.getValuesIn(i))!=null?y:"";e.form.setValuesIn(f,Z(u))},[e.address,e.form]);return!n&&((d=e==null?void 0:e.data)!=null&&d.hidden||!r)?null:s.jsx("a",{style:{fontSize:14},onClick:p,children:o("Quote Reply")})}function Z(e){return e.split(`
|
|
1
|
+
(function(c,a){typeof exports=="object"&&typeof module!="undefined"?a(exports,require("react"),require("@tachybase/client"),require("react-i18next"),require("react/jsx-runtime"),require("@tachybase/schema"),require("@ant-design/icons"),require("lodash"),require("antd"),require("dayjs")):typeof define=="function"&&define.amd?define(["exports","react","@tachybase/client","react-i18next","react/jsx-runtime","@tachybase/schema","@ant-design/icons","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.jsxRuntime,c["@tachybase/schema"],c["@ant-design/icons"],c.lodash,c.antd,c.dayjs))})(this,function(c,a,t,T,s,C,D,$,g,I){"use strict";var ae=Object.defineProperty,se=Object.defineProperties;var ie=Object.getOwnPropertyDescriptors;var E=Object.getOwnPropertySymbols;var ce=Object.prototype.hasOwnProperty,le=Object.prototype.propertyIsEnumerable;var V=(c,a,t)=>a in c?ae(c,a,{enumerable:!0,configurable:!0,writable:!0,value:t}):c[a]=t,x=(c,a)=>{for(var t in a||(a={}))ce.call(a,t)&&V(c,t,a[t]);if(E)for(var t of E(a))le.call(a,t)&&V(c,t,a[t]);return c},b=(c,a)=>se(c,ie(a));var M=(c,a,t)=>new Promise((T,s)=>{var C=g=>{try{$(t.next(g))}catch(I){s(I)}},D=g=>{try{$(t.throw(g))}catch(I){s(I)}},$=g=>g.done?T(g.value):Promise.resolve(g.value).then(C,D);$((t=t.apply(c,a)).next())});const L="block-comments";function w(e){return t.tval(e,{ns:L})}function B(){return T.useTranslation(L)}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:w("Quote Reply"),Component:"QuoteReplyCommentActionInitializer",schema:{"x-action":"create","x-decorator":"ACLActionProvider","x-align":"left"},useVisible(){return t.useCollection_deprecated().template!=="sql"}}]}]}),O=({collectionName:e,dataSource:o,association:r,rowKey:n})=>({type:"void","x-acl-action":`${r||e}:view`,"x-decorator":"Comment.Decorator","x-use-decorator-props":"useCommentBlockDecoratorProps","x-decorator-props":{collection:e,dataSource:o,association:r,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":`${r||e}:create`,"x-decorator":"ACLCollectionProvider","x-decorator-props":{collection:e,dataSource:o,association:r}}}}),Q=({filterCollections:e,filterOtherRecordsCollection:o,onlyCurrentDataSource:r,hideSearch:n,showAssociationFields:p,hideOtherRecordsInPopup:d})=>{const{insert:f}=t.useSchemaInitializer(),i=t.useSchemaInitializerItem();a.useContext(C.SchemaOptionsContext);const{getCollection:u}=t.useCollectionManager_deprecated(),y=F=>M(null,[F],function*({item:m,fromOthersInPopup:k}){const v=u(m.name,m.dataSource),S=m.associationField;f(O(S&&!k?{dataSource:m.dataSource,rowKey:v.filterTargetKey||"id",association:`${S.collectionName}.${S.name}`}:{collectionName:m.name,dataSource:m.dataSource,rowKey:v.filterTargetKey||"id"}))});return s.jsx(t.DataBlockInitializer,b(x({},i),{componentType:"Comment",icon:s.jsx(D.CommentOutlined,{}),onlyCurrentDataSource:r,hideSearch:n,filter:e,filterOtherRecordsCollection:o,showAssociationFields:p,hideOtherRecordsInPopup:d,onCreateBlockSchema:y}))},j=a.createContext({});function N(){return a.useContext(j)}const _=new t.SchemaSettings({name:"blockSettings:comment",items:[{name:"title",Component:t.SchemaSettingsBlockTitleItem},{name:"SetTheDataScope",Component:t.SchemaSettingsDataScope,useComponentProps(){var d,f;const{name:e}=t.useCollection_deprecated(),o=C.useFieldSchema(),{form:r}=t.useFormBlockContext(),n=C.useField(),{dn:p}=t.useDesignable();return{collectionName:e,defaultFilter:((f=(d=o==null?void 0:o["x-decorator-props"])==null?void 0:d.params)==null?void 0:f.filter)||{},form:r,onSubmit:({filter:i})=>{i=t.removeNullCondition(i),$.set(o,"x-decorator-props.params.filter",i),n.decoratorProps.params=b(x({},o["x-decorator-props"].params),{page:1}),p.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}=N(),{t:r}=B();return{title:r("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=w("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:w("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=>{const{dataSource:o,association:r,collection:n,children:p}=e,d=`${r||n}`;return s.jsx(G,b(x({},e),{children:s.jsx(t.List.Decorator,b(x({},e),{children:s.jsx(t.CollectionManagerProvider,{dataSource:o,children:s.jsx(t.CollectionProvider,{name:d,children:p})})}))}))}),G=({children:e})=>{const o=C.useFieldSchema(),[r,n]=a.useState(!1),{dn:p}=t.useDesignable(),d=a.useCallback(i=>{const u=x(x({},o["x-component-props"]),i);o["x-component-props"]=u,p.emit("patch",{schema:{"x-uid":o["x-uid"],"x-component-props":o["x-component-props"]}}),p.refresh()},[p,o]),f=a.useCallback(i=>{d({createAble:i}),n(i)},[n,d]);return a.useEffect(()=>{var u;const i=(u=p.current["x-component-props"])==null?void 0:u.createAble;n(i!=null?i:!0)},[]),s.jsx(j.Provider,{value:{createAble:r,setCreateAble:f},children:e})},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}}}}}),H=C.observer(({editing:e,setEditing:o,children:r})=>{var v,S,P;const n=C.useField(),{t:p}=B(),{componentCls:d}=q(),f=t.useCollectionParentRecordData(),{resource:i,service:u}=t.useBlockRequestContext(),y=a.useCallback(()=>M(null,null,function*(){var h,l;yield i.update({filterByTk:(h=n.value)==null?void 0:h.id,values:{content:(l=n==null?void 0:n.value)==null?void 0:l.content}}),u.refresh()}),[i,u,n.value]),m=t.useCollectionFields(),k=a.useMemo(()=>{var l;const h=m.find(A=>A.name==="content");return(l=h==null?void 0:h.uiSchema)==null?void 0:l["x-component-props"]},[m]),F=()=>{o(!1),y(),n.form.setFieldState(`${n.address}.content`,h=>{h.pattern="readPretty"})};return s.jsx(t.RecordProvider,{record:n.value,parent:f,children:s.jsxs("div",{className:`${d}-item-container`,children:[s.jsx("div",{className:`${d}-item-container-line`}),s.jsxs(g.Card,{size:"small",title:s.jsxs("div",{className:`${d}-item-title`,children:[s.jsxs("div",{className:`${d}-item-title-left`,children:[s.jsx("span",{children:p("commented")}),s.jsx(g.Tooltip,{title:I((v=n==null?void 0:n.value)==null?void 0:v.createdAt).format("YYYY-MM-DD HH:mm:ss"),children:s.jsx("span",{children:I((S=n==null?void 0:n.value)==null?void 0:S.createdAt).fromNow()})})]}),s.jsx("div",{className:`${d}-item-title-right`,children:r})]}),children:[s.jsx(C.RecursionField,{name:"content",basePath:n.address,schema:{type:"string",name:"content","x-component":"MarkdownVditor","x-component-props":b(x({},k),{value:(P=n==null?void 0:n.value)==null?void 0:P.content}),"x-read-pretty":!0}}),e&&s.jsxs("div",{className:`${d}-item-editor-button-area`,children:[s.jsx(g.Button,{onClick:()=>{n.form.setFieldState(`${n.address}.content`,h=>{h.pattern="readPretty"}),o(!1)},children:p("Cancel")}),s.jsx(g.Button,{type:"primary",onClick:F,children:p("Update Comment")})]})]})]})})}),Y=t.withDynamicSchemaProps(e=>{var S,P;const o=C.useFieldSchema(),r=C.useField(),[n]=a.useState(new Map),{wrapSSR:p,hashId:d,componentCls:f}=q(),{service:i}=t.useBlockRequestContext(),{run:u,params:y}=i,m=(S=i==null?void 0:i.data)==null?void 0:S.meta,k=a.useCallback(h=>{if(n.has(h))return n.get(h);const l=new C.Schema({type:"object",properties:{[h]:o.properties.item}});return n.set(h,l),l},[o.properties,n]),F=a.useCallback((h,l)=>{u(b(x({},y==null?void 0:y[0]),{page:h,pageSize:l}))},[u,y]),v=!m||m.count<=m.pageSize?!1:{onChange:F,total:(m==null?void 0:m.count)||0,pageSize:(m==null?void 0:m.pageSize)||10,current:(m==null?void 0:m.page)||1};return i!=null&&i.loading?s.jsx("div",{style:{display:"flex",justifyContent:"center"},children:s.jsx(g.Spin,{spinning:!0})}):p(s.jsx("div",{className:`${f} ${d}`,children:s.jsx(g.List,b(x({},e),{pagination:v,children:s.jsx("div",{style:{display:"flex",flexDirection:"column"},children:(P=r.value)!=null&&P.length?r.value.map((h,l)=>s.jsx("div",{style:{position:"relative",padding:`${l===0?0:"10px"} 0 ${l===r.value.length-1?0:"10px"} 0`},children:s.jsx(C.RecursionField,{basePath:r.address,name:l,onlyRenderProperties:!0,schema:k(l)})},l)):null})}))}))});function X(){var h;const e=C.useField(),o=a.useCallback(l=>{e.setValue(b(x({},e.value),{content:l}))},[e]),{t:r}=B(),{wrapSSR:n,componentCls:p,hashId:d}=q(),f=a.useMemo(()=>{var l,A;return((A=(l=e.value)==null?void 0:l.content)==null?void 0:A.trim().length)>0},[e.value]),{resource:i,service:u}=t.useBlockRequestContext(),y=a.useCallback(()=>M(null,null,function*(){yield i.create({values:e.value}),o(""),u.refresh()}),[i,e,u,o]),{createAble:m}=N(),k=t.useACLActionParamsContext(),{designable:F}=t.useDesignable(),v=!F&&(((h=e==null?void 0:e.data)==null?void 0:h.hidden)||!k),S=t.useCollectionFields(),P=a.useMemo(()=>{var l,A;return(A=(l=S.find(re=>re.name==="content"))==null?void 0:l.uiSchema)==null?void 0:A["x-component-props"]},[S]);return!m||v?null:n(s.jsxs("div",{style:{marginTop:10},className:`${p} ${d}`,children:[s.jsx(C.RecursionField,{basePath:e.address,name:"content",schema:{name:"content",type:"string","x-component":"MarkdownVditor","x-component-props":b(x({},P),{onChange:l=>{o(l)}}),"x-read-pretty":!1,"x-read-only":!1}}),s.jsx(g.Button,{style:{marginTop:10},type:"primary",disabled:!f,onClick:y,children:r("Comment")})]}))}function J(){var d;const e=C.useField(),{t:o}=B(),r=t.useACLActionParamsContext(),{designable:n}=t.useDesignable(),p=a.useCallback(()=>{var y;const f=e.address.slice(0,e.address.length-4).concat("submit.content"),i=e.address.slice(0,e.address.length-2).concat("content"),u=(y=e.form.getValuesIn(i))!=null?y:"";e.form.setValuesIn(f,Z(u))},[e.address,e.form]);return!n&&((d=e==null?void 0:e.data)!=null&&d.hidden||!r)?null:s.jsx("a",{style:{fontSize:14},onClick:p,children:o("Quote Reply")})}function Z(e){return e.split(`
|
|
2
2
|
`).map(o=>`> ${o}`).join(`
|
|
3
3
|
`)}function R(e){const{t:o}=B(),r={type:"void",title:o("Quote Reply"),"x-component":"QuoteReplyCommentActionButton"};return s.jsx(t.ActionInitializer,b(x({},e),{schema:r}))}function ee(){var f;const e=C.useField(),{t:o}=B(),[r,n]=a.useState(!1),p=t.useACLActionParamsContext(),{designable:d}=t.useDesignable();return a.useEffect(()=>{const i=e.address.slice(0,e.address.length-2);e.form.setFieldState(i.concat("content"),u=>{u.pattern=r?"editable":"readPretty"}),e.form.setFieldState(i,u=>{u.componentProps=b(x({},u.componentProps),{editing:r,setEditing:n})})},[r,e.address,e.form]),!d&&((f=e==null?void 0:e.data)!=null&&f.hidden||!p)?null:s.jsx("a",{style:{fontSize:14},onClick:()=>{n(!0)},children:o("Edit")})}function te(e){const o={type:"void",title:'{{t("Edit")}}',"x-component":"UpdateCommentActionButton"};return s.jsx(t.ActionInitializer,b(x({},e),{schema:o}))}function oe(e){const{association:o}=e;return{parentRecord:t.useParentRecordCommon(o),params:{pageSize:100,appends:["createdBy"],sort:["createdAt"]}}}const z=()=>null;z.ActionBar=t.ActionBar,z.List=Y,z.Item=H,z.Decorator=W,z.Submit=X;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:w("Comment"),Component:"CommentBlockInitializer",useComponentProps(){return{filterCollections({collection:o}){return o.template==="comment"}}}}),this.app.schemaInitializerManager.addItem("popup:common:addBlock","dataBlocks.comment",{title:w("Comment"),Component:"CommentBlockInitializer",useVisible(){const o=t.useCollection();return a.useMemo(()=>o.fields.some(r=>t.canMakeAssociationBlock(r)&&["hasMany","belongsToMany"].includes(r.type)),[o.fields])},useComponentProps(){const o=t.useCollectionManager();return{onlyCurrentDataSource:!0,filterCollections({associationField:r}){if(r){if(!["hasMany","belongsToMany"].includes(r.type))return!1;const n=o.getCollection(r.target);return(n==null?void 0:n.template)==="comment"}return!1},filterOtherRecordsCollection(r){return(r==null?void 0:r.template)==="comment"},showAssociationFields:!0,hideOtherRecordsInPopup:!1,hideSearch:!0}}}),this.app.addComponents({CommentBlockInitializer:Q,Comment:z,UpdateCommentActionInitializer:te,UpdateCommentActionButton:ee,QuoteReplyCommentActionButton:J,QuoteReplyCommentActionInitializer:R}),this.app.addScopes({useCommentBlockDecoratorProps:oe}),this.schemaSettingsManager.add(_),this.schemaInitializerManager.add(U)})}}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": "1.3.
|
|
2
|
+
"@tachybase/client": "1.3.18",
|
|
3
3
|
"react": "18.3.1",
|
|
4
|
-
"@tachybase/schema": "1.3.
|
|
4
|
+
"@tachybase/schema": "1.3.18",
|
|
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": "1.3.
|
|
10
|
+
"@tachybase/server": "1.3.18"
|
|
11
11
|
};
|
package/dist/index.js
CHANGED
|
@@ -26,12 +26,12 @@ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__ge
|
|
|
26
26
|
mod
|
|
27
27
|
));
|
|
28
28
|
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
29
|
-
var
|
|
30
|
-
__export(
|
|
29
|
+
var index_exports = {};
|
|
30
|
+
__export(index_exports, {
|
|
31
31
|
default: () => import_server.default
|
|
32
32
|
});
|
|
33
|
-
module.exports = __toCommonJS(
|
|
34
|
-
__reExport(
|
|
33
|
+
module.exports = __toCommonJS(index_exports);
|
|
34
|
+
__reExport(index_exports, require("./server"), module.exports);
|
|
35
35
|
var import_server = __toESM(require("./server"));
|
|
36
36
|
// Annotate the CommonJS export names for ESM import in node:
|
|
37
37
|
0 && (module.exports = {
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@tachybase/plugin-block-comments",
|
|
3
3
|
"displayName": "Comments",
|
|
4
|
-
"version": "1.3.
|
|
4
|
+
"version": "1.3.18",
|
|
5
5
|
"description": "Comments",
|
|
6
6
|
"keywords": [
|
|
7
7
|
"Others"
|
|
@@ -14,13 +14,13 @@
|
|
|
14
14
|
"dayjs": "1.11.13",
|
|
15
15
|
"lodash": "^4.17.21",
|
|
16
16
|
"react-i18next": "^15.2.0",
|
|
17
|
-
"@tachybase/components": "1.3.
|
|
18
|
-
"@tachybase/schema": "1.3.
|
|
17
|
+
"@tachybase/components": "1.3.18",
|
|
18
|
+
"@tachybase/schema": "1.3.18"
|
|
19
19
|
},
|
|
20
20
|
"peerDependencies": {
|
|
21
|
-
"@tachybase/client": "1.3.
|
|
22
|
-
"@tachybase/test": "1.3.
|
|
23
|
-
"@tachybase/server": "1.3.
|
|
21
|
+
"@tachybase/client": "1.3.18",
|
|
22
|
+
"@tachybase/test": "1.3.18",
|
|
23
|
+
"@tachybase/server": "1.3.18"
|
|
24
24
|
},
|
|
25
25
|
"description.zh-CN": "评论",
|
|
26
26
|
"displayName.zh-CN": "评论",
|