{"id":4443,"date":"2024-10-27T16:38:26","date_gmt":"2024-10-27T08:38:26","guid":{"rendered":"https:\/\/blog.odjbinail.cn\/?p=4443"},"modified":"2024-11-18T23:37:00","modified_gmt":"2024-11-18T15:37:00","slug":"%e5%9c%a8vue3-0%e9%a1%b9%e7%9b%ae%e4%b8%ad%e4%bd%bf%e7%94%a8tinymce%e5%af%8c%e6%96%87%e6%9c%ac%e7%bc%96%e8%be%91%e5%99%a8","status":"publish","type":"post","link":"https:\/\/blog.odjbinail.cn\/?p=4443","title":{"rendered":"\u5728vue3.0\u9879\u76ee\u4e2d\u4f7f\u7528Tinymce\u5bcc\u6587\u672c\u7f16\u8f91\u5668"},"content":{"rendered":"<h2>TinyMCE \u7b80\u4ecb<\/h2>\n<ul>\n<li>TinyMCE \u662f\u4e00\u6b3e\u6613\u7528\u3001\u4e14\u529f\u80fd\u5f3a\u5927\u7684\u6240\u89c1\u5373\u6240\u5f97\u7684\u5bcc\u6587\u672c\u7f16\u8f91\u5668<\/li>\n<li>\u521a\u5f00\u59cb\u4f7f\u7528\u5b98\u7f51\u7684\u5199\u6cd5, \u53d1\u73b0\u5b89\u88c5\u63d2\u4ef6\u90fd\u662f\u653e\u5728\u4e91\u7aef\u7684, \u521d\u59cb\u5316\u52a0\u8f7d\u592a\u6162, \u6211\u5c31\u9009\u62e9\u4e86\u672c\u5730\u90e8\u7f72, \u7136\u540e\u89e3\u51b3\u4e86\u8fd9\u4e2a tinymce \u521d\u59cb\u5316\u52a0\u8f7d\u592a\u6162\u7684\u95ee\u9898, \u4ece\u800c\u5728 vue3 \u9879\u76ee\u4e2d\u96c6\u6210 tinymce \u5bcc\u6587\u672c\u7f16\u8f91\u5668<\/li>\n<\/ul>\n<h2>\u6f14\u793a\u6548\u679c<\/h2>\n<p><img data-original=\"https:\/\/blog.odjbinail.cn\/wp-content\/uploads\/2023\/08\/2024102721401842.png\"  alt=\"\" \/><\/p>\n<noscript><img decoding=\"async\" src=\"https:\/\/blog.odjbinail.cn\/wp-content\/uploads\/2023\/08\/2024102721401842.png\" alt=\"\" \/><\/p><\/noscript>\n<h2>\u7248\u672c\u8bf4\u660e<\/h2>\n<ul>\n<li>&quot;vue&quot;: &quot;^3.2.47&quot;,<\/li>\n<li>&quot;@tinymce\/tinymce-vue&quot;: &quot;^4.0.7&quot;,  \u652f\u6301 vue3.0 \u7248\u672c, \u4f46\u4e0d\u652f\u6301 2.0 \u7248\u672c<\/li>\n<li>&quot;tinymce&quot;: &quot;^5.0.4&quot;,<\/li>\n<\/ul>\n<h2>\u5b89\u88c5<\/h2>\n<p>\u547d\u4ee4\u884c\u64cd\u4f5c<\/p>\n<pre class=\"prettyprint linenums\" ><code>npm install --save &quot;@tinymce\/tinymce-vue@^4&quot;\nnpm install --save &quot;tinymce&quot;<\/code><\/pre>\n<h2>\u521b\u5efa\u7ec4\u4ef6 Tinymce.vue<\/h2>\n<ul>\n<li>\u5728 src\/components \u76ee\u5f55\u521b\u5efa\u7ec4\u4ef6 Tinymce.vue<\/li>\n<\/ul>\n<h2>\u6ce8\u610f<\/h2>\n<ul>\n<li>\n<p>\u7f16\u8f91\u5668\u672c\u8eab\u662f\u82f1\u6587\u7f16\u8f91\u5668\uff0c\u6240\u4ee5\u8fd8\u9700\u8981\u4e0b\u8f7d\u672c\u5730\u5316\u6587\u4ef6\uff08\u4e0b\u8f7d\u8fd9\u4e2a\uff09<br \/>\n<a href=\"https:\/\/www.tiny.cloud\/get-tiny\/language-packages\/\" title=\"\u8bed\u8a00\u5305 |\u53ef\u4fe1\u5bcc\u6587\u672c\u7f16\u8f91\u5668 |TinyMCE\">\u8bed\u8a00\u5305 |\u53ef\u4fe1\u5bcc\u6587\u672c\u7f16\u8f91\u5668 |TinyMCE<\/a><\/p>\n<\/li>\n<li>\n<p>\/langs\/zh_CN.js : \u8fd9\u662f\u6c49\u5316\u8def\u5f84, \u5c06\u4e0b\u8f7d\u7684 zh_CN.js \u653e\u4e8e\u9879\u76ee\u6839\u76ee\u5f55 public\/langs\/\u91cc\u9762<\/p>\n<\/li>\n<\/ul>\n<pre class=\"prettyprint linenums\" ><code> skin_url: &#039;\/skins\/ui\/oxide&#039;, \/\/\u76ae\u80a4\n content_css: &#039;\/skins\/content\/default\/content.css&#039;,<\/code><\/pre>\n<ul>\n<li>\u5c06\/node_modules\/tinymce \u91cc\u9762\u7684 skins \u6837\u5f0f\u6587\u4ef6\u590d\u5236\u5230 public \u91cc\u9762, \u7528\u4e8e\u8d4b\u503c skin_url \u548c content_css<\/li>\n<\/ul>\n<p><img data-original=\"https:\/\/blog.odjbinail.cn\/wp-content\/uploads\/2023\/08\/2023082816320640.png\"  alt=\"\" \/><\/p>\n<noscript><img decoding=\"async\" src=\"https:\/\/blog.odjbinail.cn\/wp-content\/uploads\/2023\/08\/2023082816320640.png\" alt=\"\" \/><\/p><\/noscript>\n<h2>\u9644\u4ef6\u4e0a\u4f20<\/h2>\n<h3>\u9644\u4ef6\u4e0a\u4f20\u4f4d\u7f6e<\/h3>\n<p><img data-original=\"https:\/\/blog.odjbinail.cn\/wp-content\/uploads\/2023\/08\/2024102721441248.png\"  alt=\"\" \/><\/p>\n<noscript><img decoding=\"async\" src=\"https:\/\/blog.odjbinail.cn\/wp-content\/uploads\/2023\/08\/2024102721441248.png\" alt=\"\" \/><\/p><\/noscript>\n<h3>\u9644\u4ef6\u4e0a\u4f20\u51fd\u6570<\/h3>\n<pre class=\"prettyprint linenums\" ><code> file_picker_callback: (callback, value, meta) =&gt; {\n    \/\/ \u4f7f\u7528\u6848\u4f8b http:\/\/tinymce.ax-z.cn\/general\/upload-images.php\n    \/\/ meta.filetype  \/\/\u6839\u636e\u8fd9\u4e2a\u5224\u65ad\u70b9\u51fb\u7684\u662f\u4ec0\u4e48 file image media\n    let filetype; \/\/\u9650\u5236\u6587\u4ef6\u7684\u4e0a\u4f20\u7c7b\u578b,\u9700\u8981\u4ec0\u4e48\u5c31\u6dfb\u52a0\u4ec0\u4e48\u7684\u540e\u7f00\n    if (meta.filetype == &quot;image&quot;) {\n      filetype = &quot;.jpg, .jpeg, .png, .gif, .ico, .svg&quot;;\n    } else if (meta.filetype == &quot;media&quot;) {\n      filetype = &quot;.mp3, .mp4, .avi, .mov&quot;;\n    } else {\n      filetype =\n          &quot;.pdf, .txt, .zip, .rar, .7z, .doc, .docx, .xls, .xlsx, .ppt, .pptx, .mp3, .mp4, .jpg, .jpeg, .png, .gif, .ico, .svg&quot;;\n    }\n    let inputElem = document.createElement(&quot;input&quot;); \/\/\u521b\u5efa\u6587\u4ef6\u9009\u62e9\n    inputElem.setAttribute(&quot;type&quot;, &quot;file&quot;);\n    inputElem.setAttribute(&quot;accept&quot;, filetype);\n    inputElem.click();\n    inputElem.onchange = () =&gt; {\n      let file = inputElem.files[0]; \/\/\u83b7\u53d6\u6587\u4ef6\u4fe1\u606f\n      let xhr, formData;\n      xhr = new XMLHttpRequest();\n      xhr.withCredentials = false;\n      xhr.open(&#039;POST&#039;, url);\/\/url \u662f\u540e\u7aef\u9644\u4ef6\u4e0a\u4f20\u63a5\u53e3\n      xhr.setRequestHeader(\n        &#039;Authorization&#039;,getToken()\n      )\/\/\u8bbe\u7f6e\u5934\u90e8 token\n      let loading= ElLoading.service({\n        lock: true,\n        text: &#039;\u6587\u4ef6\u4e0a\u4f20\u4e2d...&#039;,\n        background: &#039;rgba(0, 0, 0, 0.7)&#039;,\n      })\n      xhr.onload = function() {\n        let res;\n        res = JSON.parse(xhr.responseText);\n          ElNotification({\n            title: &#039;\u63d0\u793a&#039;,\n            message: res.code === 1000 ? &#039;\u4e0a\u4f20\u6210\u529f&#039; : &#039;\u4e0a\u4f20\u5931\u8d25&#039;,\n            type: res.code === 1000 ? &#039;success&#039; : &#039;error&#039;\n          })\n        loading.close()\n        const fileUrl = res.data.url;\n        callback(fileUrl+&#039;?fileName=&#039;+res.data.originalFilename, {text:file.name ,title: file.name });\n      };\n      formData = new FormData();\n      formData.append(&#039;file&#039;, file, file.name );\n      xhr.send(formData);\n    };\n  },<\/code><\/pre>\n<p>\u6ce8:<\/p>\n<ul>\n<li>\u9644\u4ef6\u4e0a\u4f20\u56de\u8c03\uff0c\u7b2c\u4e00\u4e2a\u53c2\u6570\u662f\u6587\u4ef6\u5730\u5740 ( \u643a\u5e26 fileName \u53c2\u6570, \u7528\u4e8e\u6587\u4ef6\u4e0b\u8f7d\u65f6\u663e\u793a\u539f\u6587\u4ef6\u540d )\uff1b\u7b2c\u4e8c\u4e2a\u53c2\u6570\u662f Object, \u5206\u522b\u662f text ( \u8bbe\u7f6e\u663e\u793a\u7684\u6587\u672c\u4fe1\u606f )\uff0c\u548c title ( \u6807\u9898 )<\/li>\n<\/ul>\n<pre class=\"prettyprint linenums\" ><code>callback(fileUrl+&#039;?fileName=&#039;+res.data.originalFilename, {text:file.name ,title: file.name });<\/code><\/pre>\n<h3>\u9644\u4ef6\u4e0a\u4f20\u6210\u529f\u540e\u663e\u793a\u6548\u679c<\/h3>\n<p><img data-original=\"https:\/\/blog.odjbinail.cn\/wp-content\/uploads\/2023\/08\/2024102722074578.png\"  alt=\"\" \/><\/p>\n<noscript><img decoding=\"async\" src=\"https:\/\/blog.odjbinail.cn\/wp-content\/uploads\/2023\/08\/2024102722074578.png\" alt=\"\" \/><\/p><\/noscript>\n<h2>\u9644\u4ef6\u4e0b\u8f7d<\/h2>\n<ul>\n<li>\u70b9\u51fb\u6587\u4ef6\u540d\u65b9\u53ef\u4e0b\u8f7d<\/li>\n<\/ul>\n<p><img data-original=\"https:\/\/blog.odjbinail.cn\/wp-content\/uploads\/2023\/08\/2024102722110196.png\"  alt=\"\" \/><\/p>\n<noscript><img decoding=\"async\" src=\"https:\/\/blog.odjbinail.cn\/wp-content\/uploads\/2023\/08\/2024102722110196.png\" alt=\"\" \/><\/p><\/noscript>\n<h3>\u5bcc\u6587\u672c\u7f16\u8f91\u5668\u7684\u5185\u5bb9\u8be6\u60c5\u5c55\u793a<\/h3>\n<p><img data-original=\"https:\/\/blog.odjbinail.cn\/wp-content\/uploads\/2023\/08\/2024102722212950.png\"  alt=\"\" \/><\/p>\n<noscript><img decoding=\"async\" src=\"https:\/\/blog.odjbinail.cn\/wp-content\/uploads\/2023\/08\/2024102722212950.png\" alt=\"\" \/><\/p><\/noscript>\n<pre class=\"prettyprint linenums\" ><code>&lt;div class=&quot;article-a&quot; v-html=&quot;formData.articleContent&quot; @click=&quot;clickHandle&quot;&gt;&lt;\/div&gt;<\/code><\/pre>\n<ul>\n<li>\u4e3a div \u8bbe\u7f6e class=&quot;article-a&quot; \u5c5e\u6027, \u53ef\u4ee5\u4e3a\u521a\u521a\u4e0a\u4f20\u7684\u9644\u4ef6\u540d\u8bbe\u7f6e\u989c\u8272<\/li>\n<\/ul>\n<pre class=\"prettyprint linenums\" ><code>.article-a {\n  a {\n    color: #409eff !important;\n    &amp;:hover {\n      text-decoration: underline !important;\n    }\n  }\n}<\/code><\/pre>\n<ul>\n<li>\u4e3a div \u8bbe\u7f6e @click=&quot;clickHandle&quot; , \u7ed1\u5b9a\u70b9\u51fb\u4e8b\u4ef6 ( \u539f\u6587\u4ef6\u540d\u4e0b\u8f7d )<\/li>\n<\/ul>\n<pre class=\"prettyprint linenums\" ><code>const clickHandle = (e) =&gt; {\n  if (e.target.nodeName == &quot;A&quot;) {\n    e.preventDefault()\n    let url = e.target.href.split(&#039;?&#039;)[0];\n    const searchParams = new URLSearchParams(e.target.href.split(&#039;?&#039;)[1])\n    const fileId = searchParams.get(&#039;fileId&#039;);\n    const fileName = searchParams.get(&#039;fileName&#039;);\n    let item = {\n      url,\n      fileName\n    }\n    download(item)\n  }\n}<\/code><\/pre>\n<pre class=\"prettyprint linenums\" ><code>const download = (row) =&gt; {\n  const x = new window.XMLHttpRequest();\n  x.open(&#039;GET&#039;, row.url, true);\n  x.responseType = &#039;blob&#039;;\n  x.onload = () =&gt; {\n    const url = window.URL.createObjectURL(x.response);\n    const a = document.createElement(&#039;a&#039;);\n    a.href = url;\n    a.download = row.fileName;\n    a.click();\n  };\n  x.send();\n}<\/code><\/pre>\n<h2>\u5b8c\u6574\u4ee3\u7801<\/h2>\n<pre class=\"prettyprint linenums\" ><code>&lt;template&gt;\n  &lt;div class=&quot;tinymce-boxz&quot;&gt;\n    &lt;Editor v-model=&quot;content&quot; :init=&quot;init&quot;\/&gt;\n  &lt;\/div&gt;\n&lt;\/template&gt;\n\n&lt;script setup&gt;\nimport tinymce from &#039;tinymce&#039;\nimport Editor from &quot;@tinymce\/tinymce-vue&quot;;\nimport {defineProps} from &quot;vue&quot;;\nimport {ElMessage} from &quot;element-plus&quot;;\nimport {getToken} from &#039;@\/utils\/auth&#039;\nimport axios from &quot;axios&quot;;\n\nimport &#039;tinymce\/themes\/silver&#039;\nimport &#039;tinymce\/icons\/default\/icons&#039;\nimport &#039;tinymce\/plugins\/preview&#039;\nimport &#039;tinymce\/plugins\/searchreplace&#039;\nimport &#039;tinymce\/plugins\/autolink&#039;\nimport &#039;tinymce\/plugins\/directionality&#039;\nimport &#039;tinymce\/plugins\/visualblocks&#039;\nimport &#039;tinymce\/plugins\/visualchars&#039;\nimport &#039;tinymce\/plugins\/advlist&#039;\nimport &#039;tinymce\/plugins\/fullscreen&#039;\nimport &#039;tinymce\/plugins\/image&#039;\nimport &#039;tinymce\/plugins\/link&#039;\nimport &#039;tinymce\/plugins\/media&#039;\nimport &#039;tinymce\/plugins\/template&#039;\nimport &#039;tinymce\/plugins\/code&#039;\nimport &#039;tinymce\/plugins\/codesample&#039;\nimport &#039;tinymce\/plugins\/table&#039;\nimport &#039;tinymce\/plugins\/pagebreak&#039;\nimport &#039;tinymce\/plugins\/nonbreaking&#039;\nimport &#039;tinymce\/plugins\/anchor&#039;\nimport &#039;tinymce\/plugins\/insertdatetime&#039;\nimport &#039;tinymce\/plugins\/lists&#039;\nimport &#039;tinymce\/plugins\/wordcount&#039;\nimport &#039;tinymce\/plugins\/autosave&#039;\n\nconst emit = defineEmits([&#039;update:value&#039;])\nconst props = defineProps({\n  \/\/\u9ed8\u8ba4\u503c\n  value: {\n    type: String,\n    default: &quot;&quot;,\n  },\n  imageUrl: {\n    type: String,\n    default: &quot;&quot;,\n  },\n  fileUrl: {\n    type: String,\n    default: &quot;&quot;,\n  },\n  plugins: {\n    type: [String, Array],\n    default:\n        &quot;preview searchreplace autolink directionality visualblocks visualchars fullscreen image link media template code codesample table pagebreak nonbreaking anchor insertdatetime advlist lists wordcount autosave&quot;,\n  },\n  toolbar: {\n    type: [String, Array],\n    default: [\n      &quot;fullscreen undo redo restoredraft | cut copy paste pastetext | forecolor backcolor bold italic underline strikethrough link anchor | alignleft aligncenter alignright alignjustify outdent indent | bullist numlist | blockquote subscript superscript removeformat &quot;,\n      &quot;styleselect formatselect fontselect fontsizeselect |  table image axupimgs media  pagebreak insertdatetime  selectall visualblocks searchreplace | code preview | indent2em lineheight formatpainter&quot;,\n    ],\n  },\n  fontFormats: {\n    type: [String, Array],\n    default: &quot;\u5fae\u8f6f\u96c5\u9ed1=Microsoft YaHei,Helvetica Neue,PingFang SC,sans-serif;\u82f9\u679c\u82f9\u65b9=PingFang SC,Microsoft YaHei,sans-serif;\u5b8b\u4f53=simsun,serif;\u4eff\u5b8b\u4f53=FangSong,serif;\u9ed1\u4f53=SimHei,sans-serif;Arial=arial,helvetica,sans-serif;Arial Black=arial black,avant garde;Book Antiqua=book antiqua,palatino;&quot;\n  }\n})\nconst content = ref(props.value);\nconst imgUrl = ref();\nconst init = reactive({\n  language_url: &#039;\/langs\/zh_CN.js&#039;, \/\/\u6c49\u5316\u8def\u5f84\u662f\u81ea\u5b9a\u4e49\u7684\n  skin_url: &#039;\/skins\/ui\/oxide&#039;, \/\/\u76ae\u80a4\n  content_css: &#039;\/skins\/content\/default\/content.css&#039;,\n  language: &#039;zh_CN&#039;,\n  placeholder: &quot;\u5728\u8fd9\u91cc\u8f93\u5165\u6587\u5b57&quot;, \/\/textarea \u4e2d\u7684\u63d0\u793a\u4fe1\u606f\n  min_width: 320,\n  min_height: 220,\n  height: 500, \/\/\u6ce8\uff1a\u5f15\u5165 autoresize \u63d2\u4ef6\u65f6\uff0c\u6b64\u5c5e\u6027\u5931\u6548\n  resize: &quot;both&quot;, \/\/\u7f16\u8f91\u5668\u5bbd\u9ad8\u662f\u5426\u53ef\u53d8\uff0cfalse-\u5426,true-\u9ad8\u53ef\u53d8\uff0c&#039;both&#039;-\u5bbd\u9ad8\u5747\u53ef\uff0c\u6ce8\u610f\u5f15\u53f7\n  promotion: false,\n  branding: false, \/\/tiny \u6280\u672f\u652f\u6301\u4fe1\u606f\u662f\u5426\u663e\u793a\n  statusbar: false,  \/\/\u6700\u4e0b\u65b9\u7684\u5143\u7d20\u8def\u5f84\u548c\u5b57\u6570\u7edf\u8ba1\u90a3\u4e00\u680f\u662f\u5426\u663e\u793a\n  elementpath: false, \/\/\u5143\u7d20\u8def\u5f84\u662f\u5426\u663e\u793a\n  font_formats: props.fontFormats,  \/\/\u5b57\u4f53\u6837\u5f0f\n  plugins: props.plugins, \/\/\u63d2\u4ef6\u914d\u7f6e axupimgs indent2em\n  toolbar: props.toolbar, \/\/\u5de5\u5177\u680f\u914d\u7f6e\uff0c\u8bbe\u4e3a false \u5219\u9690\u85cf\n  menubar: &quot;file edit view format table tools&quot;, \/\/\u83dc\u5355\u680f\u914d\u7f6e\uff0c\u8bbe\u4e3a false \u5219\u9690\u85cf\uff0c\u4e0d\u914d\u7f6e\u5219\u9ed8\u8ba4\u663e\u793a\u5168\u90e8\u83dc\u5355\uff0c\u4e5f\u53ef\u81ea\u5b9a\u4e49\u914d\u7f6e--\u67e5\u770b http:\/\/tinymce.ax-z.cn\/configure\/editor-appearance.php --\u641c\u7d22\u201c\u81ea\u5b9a\u4e49\u83dc\u5355\u201d\n  \/\/ images_upload_url: &#039;\/apib\/api-upload\/uploadimg&#039;,  \/\/\u540e\u7aef\u5904\u7406\u7a0b\u5e8f\u7684 url\uff0c\u5efa\u8bae\u76f4\u63a5\u81ea\u5b9a\u4e49\u4e0a\u4f20\u51fd\u6570 image_upload_handler\uff0c\u8fd9\u4e2a\u5c31\u53ef\u4ee5\u4e0d\u7528\u4e86\n  \/\/ images_upload_base_path: &#039;\/demo&#039;,  \/\/\u76f8\u5bf9\u57fa\u672c\u8def\u5f84--\u5173\u4e8e\u56fe\u7247\u4e0a\u4f20\u5efa\u8bae\u67e5\u770b--http:\/\/tinymce.ax-z.cn\/general\/upload-images.php\n  paste_data_images: true, \/\/\u56fe\u7247\u662f\u5426\u53ef\u7c98\u8d34\n  file_picker_types: &quot;file image media&quot;, \/\/file image media \u5206\u522b\u5bf9\u5e94\u4e09\u4e2a\u7c7b\u578b\u6587\u4ef6\u7684\u4e0a\u4f20\uff1alink \u63d2\u4ef6\uff0cimage \u548c axupimgs \u63d2\u4ef6\uff0cmedia \u63d2\u4ef6\u3002\u60f3\u5c4f\u853d\u67d0\u4e2a\u63d2\u4ef6\u7684\u4e0a\u4f20\u5c31\u53bb\u6389\u5bf9\u5e94\u7684\u53c2\u6570\n  \/\/ \u6587\u4ef6\u4e0a\u4f20\u5904\u7406\u51fd\u6570\n  setup: function (editor) {\n    editor.on(&#039;change&#039;, function (e) {\n      tinymce.activeEditor.save();\/\/\u6267\u884c\u81ea\u52a8\u4fdd\u5b58\n    });\n  },\n  \/\/\u6b64\u5904\u4e3a\u56fe\u7247\u4e0a\u4f20\u5904\u7406\u51fd\u6570\n  images_upload_handler: (blobInfo, success) =&gt; {\n    let formData = new FormData()\n    formData.append(&#039;file&#039;, blobInfo.blob())\n    \/\/\u4e0a\u4f20\u56fe\u7247\u63a5\u53e3 \u4e0a\u4f20\u6210\u529f\u540e\u8fd4\u56de\u56fe\u7247\u5730\u5740\uff0c\u7528\u4e8e\u663e\u793a\u5728\u5bcc\u6587\u672c\u4e2d\n    uploadFile(formData, props.imageUrl, success)\n  },\n  file_picker_callback: (callback, value, meta) =&gt; {\n    \/\/ \u4f7f\u7528\u6848\u4f8b http:\/\/tinymce.ax-z.cn\/general\/upload-images.php\n    \/\/ meta.filetype  \/\/\u6839\u636e\u8fd9\u4e2a\u5224\u65ad\u70b9\u51fb\u7684\u662f\u4ec0\u4e48 file image media\n    let filetype; \/\/\u9650\u5236\u6587\u4ef6\u7684\u4e0a\u4f20\u7c7b\u578b,\u9700\u8981\u4ec0\u4e48\u5c31\u6dfb\u52a0\u4ec0\u4e48\u7684\u540e\u7f00\n    if (meta.filetype == &quot;image&quot;) {\n      filetype = &quot;.jpg, .jpeg, .png, .gif, .ico, .svg&quot;;\n    } else if (meta.filetype == &quot;media&quot;) {\n      filetype = &quot;.mp3, .mp4, .avi, .mov&quot;;\n    } else {\n      filetype =\n          &quot;.pdf, .txt, .zip, .rar, .7z, .doc, .docx, .xls, .xlsx, .ppt, .pptx, .mp3, .mp4, .jpg, .jpeg, .png, .gif, .ico, .svg&quot;;\n    }\n    let inputElem = document.createElement(&quot;input&quot;); \/\/\u521b\u5efa\u6587\u4ef6\u9009\u62e9\n    inputElem.setAttribute(&quot;type&quot;, &quot;file&quot;);\n    inputElem.setAttribute(&quot;accept&quot;, filetype);\n    inputElem.click();\n    inputElem.onchange = () =&gt; {\n      let file = inputElem.files[0]; \/\/\u83b7\u53d6\u6587\u4ef6\u4fe1\u606f\n      let reader = new FileReader();\n      reader.readAsDataURL(file);\n      reader.onload = function () {\n        let id = &quot;blobid&quot; + new Date().getTime();\n        let blobCache = tinymce.activeEditor.editorUpload.blobCache;\n        let base64 = reader.result.split(&quot;,&quot;)[1];\n        let blobInfo = blobCache.create(id, file, base64);\n        blobCache.add(blobInfo);\n        callback(blobInfo.blobUri(), {alt: file.name});\n      };\n    };\n  },\n});\n\/\/\u5185\u5bb9\u6709\u53d8\u5316\uff0c\u5c31\u66f4\u65b0\u5185\u5bb9\uff0c\u5c06\u503c\u8fd4\u56de\u7ed9\u7236\u7ec4\u4ef6\nwatch(() =&gt; {\n  emit(&quot;update:value&quot;, content.value);\n});\n\/\/\u56fe\u7247\u4e0a\u4f20\u51fd\u6570\nconst uploadFile = (formData, url,success) =&gt; {\n  axios.post(\n      &#039;http:\/\/192.168.xx.xx:xxxx&#039; + url,\/\/\u4e0a\u4f20\u63a5\u53e3 \u5b8c\u6574 url\n      formData,\n      {\n        headers: {\n          &#039;Content-Type&#039;: &#039;multipart\/form-data&#039;,\n          Authorization: getToken()\n        }\n      }\n  ).then(res =&gt; {\n    \/\/ if (res.status !== 200) {\n    \/\/   ElMessage.error(&quot;\u4e0a\u4f20\u5931\u8d25!&quot;)\n    \/\/ }\n    let data = res.data\n    if (data.code !== 1000) {\n      ElMessage.error(data.msg)\n    }else {\n      success(data.data.url)\n    }\n  })\n}\n&lt;\/script&gt;\n&lt;style scoped&gt;\n.tinymce-boxz &gt; textarea {\n  display: none;\n}\n&lt;\/style&gt;\n&lt;style&gt;\n\/* \u9690\u85cf apikey \u6ca1\u6709\u7ed1\u5b9a\u5f53\u524d\u57df\u540d\u7684\u63d0\u793a *\/\n.tox-notifications-container .tox-notification--warning {\n  display: none !important;\n}\n\n.tox.tox-tinymce {\n  max-width: 100%;\n}\n&lt;\/style&gt;<\/code><\/pre>\n<h2>\u9875\u9762\u4e0a\u5f15\u7528<\/h2>\n<ul>\n<li>\/notice\/file \u4e0a\u4f20\u6587\u4ef6\u63a5\u53e3<\/li>\n<\/ul>\n<pre class=\"prettyprint linenums\" ><code>&lt;Tinymce image-url=&quot;\/notice\/file&quot; file-url=&quot;\/notice\/file&quot; v-model:value=&quot;form.noticeContent&quot;\/&gt;<\/code><\/pre>\n","protected":false},"excerpt":{"rendered":"<p>TinyMCE \u7b80\u4ecb TinyMCE \u662f\u4e00\u6b3e\u6613\u7528\u3001\u4e14\u529f\u80fd\u5f3a\u5927\u7684\u6240\u89c1\u5373\u6240\u5f97\u7684\u5bcc\u6587\u672c\u7f16\u8f91\u5668 \u521a\u5f00\u59cb\u4f7f\u7528\u5b98\u7f51\u7684\u5199\u6cd5, [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[],"class_list":["post-4443","post","type-post","status-publish","format-standard","hentry","category-1"],"_links":{"self":[{"href":"https:\/\/blog.odjbinail.cn\/index.php?rest_route=\/wp\/v2\/posts\/4443","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/blog.odjbinail.cn\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/blog.odjbinail.cn\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/blog.odjbinail.cn\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/blog.odjbinail.cn\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=4443"}],"version-history":[{"count":12,"href":"https:\/\/blog.odjbinail.cn\/index.php?rest_route=\/wp\/v2\/posts\/4443\/revisions"}],"predecessor-version":[{"id":4764,"href":"https:\/\/blog.odjbinail.cn\/index.php?rest_route=\/wp\/v2\/posts\/4443\/revisions\/4764"}],"wp:attachment":[{"href":"https:\/\/blog.odjbinail.cn\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=4443"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/blog.odjbinail.cn\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=4443"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/blog.odjbinail.cn\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=4443"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}