Skip to content

Commit

Permalink
feat:check-video-and-image-accept-list
Browse files Browse the repository at this point in the history
  • Loading branch information
wybieshang committed Mar 26, 2024
1 parent 72c91f7 commit 04d1409
Show file tree
Hide file tree
Showing 3 changed files with 64 additions and 37 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -99,42 +99,46 @@ export default {
const MENU_CONF = {};
Object.assign(
MENU_CONF,
this.accept && {
uploadImage: {
server:
this.uploadImgServer || "/gateway/lowcode/api/v1/app/upload",
fieldName: "file",
maxFileSize: 50 * 1024 * 1024, // 50M
// 自定义增加 http header
headers,
// 自定义插入图片
onBeforeUpload: (file) => {
const type = Object.values(file)[0].type.split("/")[1];
if (
!this.acceptList.includes("." + type) ||
!imageTypes.includes(type)
) {
this.$emit("upload-fail", {
value: `不支持上传${type}类型的图片文件`,
});
return false;
{
uploadImage: this.accept
? {
server:
this.uploadImgServer || "/gateway/lowcode/api/v1/app/upload",
fieldName: "file",
maxFileSize: 50 * 1024 * 1024, // 50M
// 自定义增加 http header
headers,
// 自定义插入图片
onBeforeUpload: (file) => {
const type = Object.values(file)[0].type.split("/")[1];
if (
!this.acceptList.includes("." + type) ||
!imageTypes.includes(type)
) {
this.$emit("upload-fail", {
value: `不支持上传${type}类型的图片文件`,
});
return false;
}
return file;
},
customInsert: (res, insertFn) => {
const url = res.result;
insertFn(url);
},
meta: {
viaOriginURL: true,
},
allowedFileTypes: this.acceptEditorList,
disable: true,
}
return file;
},
customInsert: (res, insertFn) => {
const url = res.result;
insertFn(url);
},
meta: {
viaOriginURL: true,
},
allowedFileTypes: this.acceptEditorList,
},
: null,
},
this.acceptVideo && {
{
uploadVideo: {
server:
this.uploadImgServer || "/gateway/lowcode/api/v1/app/upload",
server: this.acceptVideo
? this.uploadImgServer || "/gateway/lowcode/api/v1/app/upload"
: null,
fieldName: "file",
maxFileSize: 1000 * 1024 * 1024, // 1000M
// 自定义增加 http header
Expand Down Expand Up @@ -163,6 +167,7 @@ export default {
},
}
);
console.log("MENU_CONF", MENU_CONF);
return {
readOnly: this.readOnly,
scroll: this.scroll,
Expand Down Expand Up @@ -228,6 +233,20 @@ export default {
},
onFocus(editor) {
this.$emit("focus", { value: this.currentValue, editor });
if (!this.accept) {
this.$nextTick(() => {
this.$el
.querySelector('[data-menu-key="group-image"]')
.parentNode.classList.add("no-accept-disabled");
});
}
if (!this.acceptVideo) {
this.$nextTick(() => {
this.$el
.querySelector('[data-menu-key="group-video"]')
.parentNode.classList.add("no-accept-disabled");
});
}
},
onBlur(editor) {
this.$emit("blur", { value: this.currentValue, editor });
Expand Down Expand Up @@ -295,4 +314,12 @@ export default {
.w-e-textarea-video-container {
max-width: 100%;
}
.no-accept-disabled {
cursor: not-allowed;
pointer-events: none;
}
.no-accept-disabled svg {
fill: var(--w-e-toolbar-disabled-color) !important;
}
</style>
6 changes: 3 additions & 3 deletions packages/cw/cw_text_power_library/manifest
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
Plugin-Version: 1.0.0
Library-Type: Frontend
Metadata-File: usage.json
packages/extension/[email protected].2/dist-theme/demo.html: dist-theme/demo.html
packages/extension/[email protected].2/dist-theme/index.js: dist-theme/index.js
packages/extension/[email protected].2/dist-theme/index.js.map: dist-theme/index.js.map
packages/extension/[email protected].3/dist-theme/demo.html: dist-theme/demo.html
packages/extension/[email protected].3/dist-theme/index.js: dist-theme/index.js
packages/extension/[email protected].3/dist-theme/index.js.map: dist-theme/index.js.map
2 changes: 1 addition & 1 deletion packages/cw/cw_text_power_library/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"name": "cw_text_power_library",
"title": "文本功能依赖库",
"description": "",
"version": "1.1.2",
"version": "1.1.3",
"main": "./index.js",
"author": "",
"repository": "",
Expand Down

0 comments on commit 04d1409

Please sign in to comment.