@nocobase/plugin-field-markdown-vditor 1.7.0-beta.8 → 1.7.0
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/LICENSE.txt +4 -4
- package/dist/client/478dab5e65264134.js +10 -0
- package/dist/client/a798fc52cca9cf19.js +10 -0
- package/dist/client/index.js +1 -1
- package/dist/client/interfaces/markdown-vditor.d.ts +1 -1
- package/dist/client/locale/index.d.ts +1 -0
- package/dist/externalVersion.js +6 -5
- package/dist/locale/de-DE.json +7 -2
- package/dist/locale/en-US.json +8 -3
- package/dist/locale/it-IT.json +8 -3
- package/dist/locale/ja-JP.json +8 -3
- package/dist/locale/ko-KR.json +8 -3
- package/dist/locale/zh-CN.json +8 -3
- package/dist/node_modules/fs-extra/package.json +1 -1
- package/dist/server/plugin.d.ts +1 -0
- package/dist/server/plugin.js +52 -0
- package/package.json +2 -2
- package/dist/client/f6096fba148d0234.js +0 -10
- package/dist/client/fcbbcbf234712f1d.js +0 -10
package/dist/server/plugin.js
CHANGED
|
@@ -43,6 +43,8 @@ module.exports = __toCommonJS(plugin_exports);
|
|
|
43
43
|
var import_server = require("@nocobase/server");
|
|
44
44
|
var import_fs_extra = __toESM(require("fs-extra"));
|
|
45
45
|
var import_path = __toESM(require("path"));
|
|
46
|
+
var import_package = __toESM(require("../../package.json"));
|
|
47
|
+
const namespace = import_package.default.name;
|
|
46
48
|
class PluginFieldMarkdownVditorServer extends import_server.Plugin {
|
|
47
49
|
async afterAdd() {
|
|
48
50
|
}
|
|
@@ -50,6 +52,56 @@ class PluginFieldMarkdownVditorServer extends import_server.Plugin {
|
|
|
50
52
|
}
|
|
51
53
|
async load() {
|
|
52
54
|
await this.copyVditorDist();
|
|
55
|
+
this.setResource();
|
|
56
|
+
this.app.acl.allow("vditor", "check", "loggedIn");
|
|
57
|
+
}
|
|
58
|
+
setResource() {
|
|
59
|
+
this.app.resourceManager.define({
|
|
60
|
+
name: "vditor",
|
|
61
|
+
actions: {
|
|
62
|
+
check: async (context, next) => {
|
|
63
|
+
var _a, _b, _c;
|
|
64
|
+
const { fileCollectionName } = context.action.params;
|
|
65
|
+
let storage;
|
|
66
|
+
const fileCollection = this.db.getCollection(fileCollectionName || "attachments");
|
|
67
|
+
const storageName = (_a = fileCollection == null ? void 0 : fileCollection.options) == null ? void 0 : _a.storage;
|
|
68
|
+
if (storageName) {
|
|
69
|
+
storage = await this.db.getRepository("storages").findOne({
|
|
70
|
+
where: {
|
|
71
|
+
name: storageName
|
|
72
|
+
}
|
|
73
|
+
});
|
|
74
|
+
} else {
|
|
75
|
+
storage = await this.db.getRepository("storages").findOne({
|
|
76
|
+
where: {
|
|
77
|
+
default: true
|
|
78
|
+
}
|
|
79
|
+
});
|
|
80
|
+
}
|
|
81
|
+
if (!storage) {
|
|
82
|
+
context.throw(
|
|
83
|
+
400,
|
|
84
|
+
context.t("Storage configuration not found. Please configure a storage provider first.", {
|
|
85
|
+
ns: namespace
|
|
86
|
+
})
|
|
87
|
+
);
|
|
88
|
+
}
|
|
89
|
+
const isSupportToUploadFiles = storage.type !== "s3-compatible" || ((_b = storage.options) == null ? void 0 : _b.baseUrl) && ((_c = storage.options) == null ? void 0 : _c.public);
|
|
90
|
+
const storageInfo = {
|
|
91
|
+
id: storage.id,
|
|
92
|
+
title: storage.title,
|
|
93
|
+
name: storage.name,
|
|
94
|
+
type: storage.type,
|
|
95
|
+
rules: storage.rules
|
|
96
|
+
};
|
|
97
|
+
context.body = {
|
|
98
|
+
isSupportToUploadFiles: !!isSupportToUploadFiles,
|
|
99
|
+
storage: storageInfo
|
|
100
|
+
};
|
|
101
|
+
await next();
|
|
102
|
+
}
|
|
103
|
+
}
|
|
104
|
+
});
|
|
53
105
|
}
|
|
54
106
|
async copyVditorDist() {
|
|
55
107
|
const dist = import_path.default.resolve(__dirname, "../../dist/client/vditor/dist");
|
package/package.json
CHANGED
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
"displayName.zh-CN": "数据表字段:Markdown(Vditor)",
|
|
5
5
|
"description": "Used to store Markdown and render it using Vditor editor, supports common Markdown syntax such as list, code, quote, etc., and supports uploading images, recordings, etc.It also allows for instant rendering, where what you see is what you get.",
|
|
6
6
|
"description.zh-CN": "用于存储 Markdown,并使用 Vditor 编辑器渲染,支持常见 Markdown 语法,如列表,代码,引用等,并支持上传图片,录音等。同时可以做到即时渲染,所见即所得。",
|
|
7
|
-
"version": "1.7.0
|
|
7
|
+
"version": "1.7.0",
|
|
8
8
|
"license": "AGPL-3.0",
|
|
9
9
|
"main": "dist/server/index.js",
|
|
10
10
|
"homepage": "https://docs.nocobase.com/handbook/field-markdown-vditor",
|
|
@@ -27,5 +27,5 @@
|
|
|
27
27
|
"keywords": [
|
|
28
28
|
"Collection fields"
|
|
29
29
|
],
|
|
30
|
-
"gitHead": "
|
|
30
|
+
"gitHead": "767ae089e404a104d718962272289c0bec01803a"
|
|
31
31
|
}
|
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* This file is part of the NocoBase (R) project.
|
|
3
|
-
* Copyright (c) 2020-2024 NocoBase Co., Ltd.
|
|
4
|
-
* Authors: NocoBase Team.
|
|
5
|
-
*
|
|
6
|
-
* This project is dual-licensed under AGPL-3.0 and NocoBase Commercial License.
|
|
7
|
-
* For more information, please refer to: https://www.nocobase.com/agreement.
|
|
8
|
-
*/
|
|
9
|
-
|
|
10
|
-
"use strict";(self.webpackChunk_nocobase_plugin_field_markdown_vditor=self.webpackChunk_nocobase_plugin_field_markdown_vditor||[]).push([["363"],{287:function(e,t,r){r.r(t),r.d(t,{MarkdownVditor:function(){return R},default:function(){return _}});var n=r("505"),o=r("772"),a=r("721"),l=r("156"),i=r.n(l),u=r("825"),c=r.n(u),d=r("555"),f=function(){var e=(0,o.usePlugin)(d.PluginFieldMarkdownVditorClient);return!e.dependencyLoaded&&(e.initVditorDependency(),e.dependencyLoaded=!0),e.getCDN()},s=(0,o.genStyleHook)("nb-field-markdown-vditor",function(e){var t,r,n;return t={},r=e.componentCls,n={".vditor-reset":{fontSize:"".concat(e.fontSize,"px !important")},".vditor":{borderRadius:8},".vditor .vditor-content":{borderRadius:"0 0 8px 8px",overflow:"hidden"},".vditor .vditor-toolbar":{paddingLeft:" 16px !important",borderRadius:"8px 8px 0 0"},".vditor .vditor-content .vditor-ir .vditor-reset":{paddingLeft:" 16px !important"}},r in t?Object.defineProperty(t,r,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[r]=n,t});function v(e,t){(null==t||t>e.length)&&(t=e.length);for(var r=0,n=Array(t);r<t;r++)n[r]=e[r];return n}function p(e,t){return function(e){if(Array.isArray(e))return e}(e)||function(e,t){var r,n,o=null==e?null:"undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(null!=o){var a=[],l=!0,i=!1;try{for(o=o.call(e);!(l=(r=o.next()).done)&&(a.push(r.value),!t||a.length!==t);l=!0);}catch(e){i=!0,n=e}finally{try{!l&&null!=o.return&&o.return()}finally{if(i)throw n}}return a}}(e,t)||function(e,t){if(e){if("string"==typeof e)return v(e,t);var r=Object.prototype.toString.call(e).slice(8,-1);if("Object"===r&&e.constructor&&(r=e.constructor.name),"Map"===r||"Set"===r)return Array.from(r);if("Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r))return v(e,t)}}(e,t)||function(){throw TypeError("Invalid attempt to destructure non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}var m=function(e){if(e){var t=document.createRange();return t.selectNodeContents(e),t.getBoundingClientRect().width}};function y(e){var t,r=(0,l.useRef)(null),n=s(),o=n.wrapSSR,a=n.componentCls,u=n.hashId,d=f();return(0,l.useEffect)(function(){var t;c().preview(r.current,null!==(t=e.value)&&void 0!==t?t:"",{mode:"light",cdn:d})},[e.value]),o(i().createElement("div",{className:"".concat(u," ").concat(a)},i().createElement("div",{ref:r,style:function(e){for(var t=1;t<arguments.length;t++){var r=null!=arguments[t]?arguments[t]:{},n=Object.keys(r);"function"==typeof Object.getOwnPropertySymbols&&(n=n.concat(Object.getOwnPropertySymbols(r).filter(function(e){return Object.getOwnPropertyDescriptor(r,e).enumerable}))),n.forEach(function(t){var n,o,a;n=e,o=t,a=r[t],o in n?Object.defineProperty(n,o,{value:a,enumerable:!0,configurable:!0,writable:!0}):n[o]=a})}return e}({border:"none"},null!==(t=null==e?void 0:e.style)&&void 0!==t?t:{})})))}var b=(0,o.withDynamicSchemaProps)(function(e){var t,r=(0,n.useField)(),o=null!==(t=e.value)&&void 0!==t?t:r.value,u=f(),d=(0,l.useRef)(),s=p((0,l.useState)(!1),2),v=s[0],b=s[1],h=p((0,l.useState)(!1),2),g=h[0],w=h[1],S=p((0,l.useState)(""),2),R=S[0],_=S[1],C=(0,l.useRef)();(0,l.useEffect)(function(){if(e.value&&r.value){if(e.ellipsis)c().md2html(e.value,{mode:"light",cdn:u}).then(function(e){var t,r,n;_((t=e,(r=document.createElement("div")).innerHTML=t,n=r.innerText,r=null,(null==n?void 0:n.replace(/[\n\r]/g,""))||""))}).catch(function(){return _("")});else{var t;c().preview(d.current,null!==(t=e.value)&&void 0!==t?t:r.value,{mode:"light",cdn:u})}}},[e.value,e.ellipsis,r.value]);var E=(0,l.useCallback)(function(){var e;if(!C.current)return!1;return m(C.current)>(null===(e=C.current)||void 0===e?void 0:e.offsetWidth)},[C]);return e.ellipsis?i().createElement(a.Popover,{open:v,onOpenChange:function(e){b(g&&e)},content:i().createElement(y,{value:o,style:{maxWidth:500,maxHeight:400,overflowY:"auto"}})},i().createElement("div",{ref:C,style:{overflow:"hidden",overflowWrap:"break-word",textOverflow:"ellipsis",whiteSpace:"nowrap",wordBreak:"break-all"},onMouseEnter:function(e){var t=e.target;E()&&w(t.scrollWidth>=t.clientWidth)}},R)):i().createElement(y,{value:o})}),h=r("767");function g(e,t){(null==t||t>e.length)&&(t=e.length);for(var r=0,n=Array(t);r<t;r++)n[r]=e[r];return n}var w=["en_US","fr_FR","pt_BR","ja_JP","ko_KR","ru_RU","sv_SE","zh_CN","zh_TW"],S=(0,o.withDynamicSchemaProps)(function(e){var t,r,n=e.disabled,a=e.onChange,u=e.value,d=e.fileCollection,v=e.toolbar;var p=(t=(0,l.useState)(!1),r=2,function(e){if(Array.isArray(e))return e}(t)||function(e,t){var r,n,o=null==e?null:"undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(null!=o){var a=[],l=!0,i=!1;try{for(o=o.call(e);!(l=(r=o.next()).done)&&(a.push(r.value),!t||a.length!==t);l=!0);}catch(e){i=!0,n=e}finally{try{!l&&null!=o.return&&o.return()}finally{if(i)throw n}}return a}}(t,2)||function(e,t){if(e){if("string"==typeof e)return g(e,t);var r=Object.prototype.toString.call(e).slice(8,-1);if("Object"===r&&e.constructor&&(r=e.constructor.name),"Map"===r||"Set"===r)return Array.from(r);if("Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r))return g(e,t)}}(t,r)||function(){throw TypeError("Invalid attempt to destructure non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()),m=p[0],y=p[1],b=(0,l.useRef)(),S=(0,l.useRef)(!1),R=(0,l.useRef)(null),_=(0,l.useRef)(null),C=(0,o.useApp)(),E=(0,o.useAPIClient)(),O=f(),x=s(),k=x.wrapSSR,A=x.hashId,j=x.componentCls,P=E.auth.locale||"en-US",N=(0,l.useMemo)(function(){var e=P.replace(/-/g,"_");return w.includes(e)?e:"en_US"},[P]);return(0,l.useEffect)(function(){if(R.current){var e=d||"attachments",t=null!=v?v:h.K,r=new(c())(R.current,{value:null!=u?u:"",lang:N,cache:{enable:!1},undoDelay:0,preview:{math:{engine:"KaTeX"}},toolbar:t,fullscreen:{index:1200},cdn:O,minHeight:200,after:function(){b.current=r,y(!0),r.setValue(null!=u?u:""),n?r.disabled():r.enable()},input:function(e){a(e)},upload:{url:C.getApiUrl("".concat(e,":create")),headers:E.getHeaders(),multiple:!1,fieldName:"file",max:0x40000000,format:function(e,t){var r,n,o,a=JSON.parse(t);return JSON.stringify({msg:"",code:0,data:{errFiles:[],succMap:(r={},n=a.data.filename,o=a.data.url,n in r?Object.defineProperty(r,n,{value:o,enumerable:!0,configurable:!0,writable:!0}):r[n]=o,r)}})}}});return function(){var e;null===(e=b.current)||void 0===e||e.destroy(),b.current=void 0}}},[d,null==v?void 0:v.join(",")]),(0,l.useEffect)(function(){if(m&&b.current){var e=b.current;if(u!==e.getValue()){e.setValue(null!=u?u:"");var t,r=null===(t=R.current)||void 0===t?void 0:t.querySelector("div.vditor-content > div.vditor-ir > pre");if(r){var n=document.createRange(),o=window.getSelection();o&&(n.selectNodeContents(r),n.collapse(!1),o.removeAllRanges(),o.addRange(n))}}}},[u,m]),(0,l.useEffect)(function(){m&&b.current&&(n?b.current.disabled():b.current.enable())},[n,m]),(0,l.useLayoutEffect)(function(){if(R.current){var e=new ResizeObserver(function(e){var t=!0,r=!1,n=void 0;try{for(var o,a=e[Symbol.iterator]();!(t=(o=a.next()).done);t=!0){var l,i=o.value.target;i.className.includes("vditor--fullscreen")?(document.body.appendChild(i),S.current=!0):S.current&&(null===(l=_.current)||void 0===l||l.appendChild(i),S.current=!1)}}catch(e){r=!0,n=e}finally{try{!t&&null!=a.return&&a.return()}finally{if(r)throw n}}});return e.observe(R.current),function(){e.unobserve(R.current)}}},[]),k(i().createElement("div",{ref:_,className:"".concat(A," ").concat(j)},i().createElement("div",{id:A,ref:R})))}),R=(0,o.withDynamicSchemaProps)((0,n.connect)(S,(0,n.mapReadPretty)(b))),_=R}}]);
|