@2kog/pkg-editor 0.0.4 → 0.0.6

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@2kog/pkg-editor",
3
- "version": "0.0.4",
3
+ "version": "0.0.6",
4
4
  "description": "Custom Tinymce、Article Renderer",
5
5
  "scripts": {
6
6
  "serve": "npm run dev",
@@ -3,7 +3,12 @@
3
3
  <slot name="prepend"></slot>
4
4
 
5
5
  <div class="c-editor-header">
6
- <Upload v-if="attachmentEnable" @insert="insertAttachments" :uploadFn="attachmentUploadFn" :domain="attachmentCdnDomain" />
6
+ <Upload
7
+ v-if="attachmentEnable"
8
+ @insert="insertAttachments"
9
+ :uploadFn="attachmentUploadFn"
10
+ :domain="attachmentCdnDomain"
11
+ />
7
12
  </div>
8
13
 
9
14
  <slot></slot>
@@ -29,7 +34,7 @@
29
34
  import Editor from "@tinymce/tinymce-vue";
30
35
  import Upload from "./Upload";
31
36
  import hljs_languages from "../assets/js/hljs_languages.js";
32
- import GlobalConf from '../../config/global.js';
37
+ import GlobalConf from "../../config/global.js";
33
38
 
34
39
  export default {
35
40
  name: "Tinymce",
@@ -60,7 +65,6 @@ export default {
60
65
  default: true,
61
66
  },
62
67
 
63
-
64
68
  // 是否启用附件上传
65
69
  attachmentEnable: {
66
70
  type: Boolean,
@@ -76,7 +80,10 @@ export default {
76
80
  type: String,
77
81
  default: "",
78
82
  },
79
-
83
+ tinymceDev: {
84
+ type: Boolean,
85
+ default: false,
86
+ },
80
87
  },
81
88
  emits: ["update:modelValue"],
82
89
  data: function () {
@@ -93,7 +100,9 @@ export default {
93
100
  convert_urls: false,
94
101
 
95
102
  // 样式
96
- content_css: process.env.VUE_APP_TINYMCE_DEV === "true" ? `http://localhost:5120/skins/content/default/content.min.css` : `${this.tinymceAssetsDomain}/static/tinymce/skins/content/default/content.min.css`,
103
+ content_css: this.tinymceDev
104
+ ? `http://localhost:5120/skins/content/default/content.min.css`
105
+ : `${this.tinymceAssetsDomain}/static/tinymce/skins/content/default/content.min.css`,
97
106
  body_class: "c-article c-article-editor c-article-tinymce",
98
107
  height: this.height || 800,
99
108
  autosave_ask_before_unload: false,
@@ -85,6 +85,11 @@ import { ElButton, ElDialog, ElIcon } from "element-plus";
85
85
  import { Plus, UploadFilled, Delete, Check } from "@element-plus/icons-vue";
86
86
  import { imgTypes, videoTypes } from "../../config/global.js";
87
87
 
88
+ const documentTypes = ["pdf", "doc", "docx", "txt", "md", "rtf", "ppt", "pptx"];
89
+ const spreadsheetTypes = ["xls", "xlsx", "csv", "tsv"];
90
+ const archiveTypes = ["zip", "rar", "7z", "tar", "gz"];
91
+ const attachmentTypes = [...imgTypes, ...videoTypes, ...documentTypes, ...spreadsheetTypes, ...archiveTypes];
92
+
88
93
  export default {
89
94
  name: "Upload",
90
95
  components: {
@@ -157,6 +162,10 @@ export default {
157
162
  },
158
163
  },
159
164
  computed: {
165
+ accept: function () {
166
+ const types = this.onlyImage ? imgTypes : attachmentTypes;
167
+ return types.map((type) => `.${type}`).join(",");
168
+ },
160
169
  buttonTXT: function () {
161
170
  return this.selectedCount ? "插 入" : "确 定";
162
171
  },
@@ -271,6 +280,9 @@ export default {
271
280
  }
272
281
  });
273
282
  },
283
+ onExceed: function () {
284
+ this.$message.warning(`一次最多上传 ${this.limit} 个文件`);
285
+ },
274
286
  isImage(file) {
275
287
  let ext = file.name.split(".").pop();
276
288
  return imgTypes.includes(ext);