国产亚洲精品福利在线无卡一,国产精久久一区二区三区,亚洲精品无码国模,精品久久久久久无码专区不卡

當(dāng)前位置: 首頁 > news >正文

有了 ftp服務(wù)器密碼 怎么改網(wǎng)站給我免費(fèi)播放片高清在線觀看

有了 ftp服務(wù)器密碼 怎么改網(wǎng)站,給我免費(fèi)播放片高清在線觀看,宸建設(shè)計(jì)網(wǎng)站,如何自己安裝wordpress歡迎點(diǎn)擊領(lǐng)取 -《前端面試題進(jìn)階指南》:前端登頂之巔-最全面的前端知識(shí)點(diǎn)梳理總結(jié) *分享一個(gè)使用比較久的🪜 簡介 1、安裝:pnpm add tinymce / pnpm add tinymce/tinymce-vue > Vue3 tinymce tinymce/tinymce-vue 2、功能實(shí)現(xiàn)圖片上傳…

歡迎點(diǎn)擊領(lǐng)取 -《前端面試題進(jìn)階指南》:前端登頂之巔-最全面的前端知識(shí)點(diǎn)梳理總結(jié)

*分享一個(gè)使用比較久的🪜

簡介

1、安裝:pnpm add tinymce / pnpm add @tinymce/tinymce-vue ===> Vue3 + tinymce + @tinymce/tinymce-vue
2、功能實(shí)現(xiàn)圖片上傳、基金卡片插入、收益卡片插入、源代碼復(fù)用、最大長度限制、自定義表情包插入、文本內(nèi)容輸入、預(yù)覽等功能

在這里插入圖片描述

代碼展示

在components文件下創(chuàng)建TinymceEditor.vue文件作為公共組件

<template><div><Editor ref="EditorRefs" v-model="content" :init="myTinyInit" /><div class="editor_footer"><span v-if="wordlimit"><span>{{ wordLenght }}</span><span> / </span><span>{{ wordlimit.max }}</span> 字符</span></div><el-dialog title="自定義表情包" v-model="dialogVisible" width="45%"><div class="emoji"><div class="emoji-item" v-for="item in 40" :key="item"><img :src="`/src/assets/emoji/${item}.webp`" alt="" @click="chooseEmoji(item)" /></div></div></el-dialog><button @click="handlePreview">預(yù)覽</button></div>
</template><script lang="ts" setup>
import './wordlimit' // 限制字符文件
import tinymce from 'tinymce/tinymce'
import Editor from '@tinymce/tinymce-vue'
import 'tinymce/icons/default/icons'
import 'tinymce/themes/silver'
import 'tinymce/models/dom/model'
import 'tinymce/plugins/table'
import 'tinymce/plugins/lists'
import 'tinymce/plugins/link'
import 'tinymce/plugins/help'
import 'tinymce/plugins/wordcount'
import 'tinymce/plugins/code'
import 'tinymce/plugins/preview'
import 'tinymce/plugins/visualblocks'
import 'tinymce/plugins/visualchars'
import 'tinymce/plugins/fullscreen'
import '/public/tinymce/plugins/image/index.js'import { sumLetter } from '@/utils/utilTool'
import { computed, onMounted, reactive, ref, watch } from 'vue'const props = withDefaults(defineProps<{modelValue?: stringplugins?: stringtoolbar?: stringwordlimit?: any}>(),{plugins: 'image code wordcount wordlimit preview', // 默認(rèn)開啟工具庫toolbar: 'image emoji fund—icon income-icon code' // 富文本編輯器工具}
)const emit = defineEmits(['input'])const wordLenght = ref<number | string>(0)const content = ref<string>('')const EditorRefs = ref<any>()const dialogVisible = ref<boolean>(false)const myTinyInit = reactive({width: '100%',height: 600, // 默認(rèn)高度statusbar: false,language_url: '/tinymce/langs/zh_CN.js', // 配置漢化-> 需下載對應(yīng)漢化包引入language: 'zh_CN', // 語言標(biāo)識(shí)branding: false, // 不顯示右下角logoauto_update: false, // 不進(jìn)行自動(dòng)更新resize: true, // 可以調(diào)整大小menubar: false, // 關(guān)閉頂部菜單skin_url: '/tinymce/skins/ui/oxide', // 手動(dòng)引入CSScontent_css: '/tinymce/skins/content/default/content.css', // 手動(dòng)引入CSStoolbar_mode: 'wrap',plugins: props?.plugins, // 插件toolbar: props?.toolbar, // 功能按鈕wordlimit: props?.wordlimit, // 字?jǐn)?shù)限制image_caption: false,paste_data_images: true,//粘貼圖片后,自動(dòng)上傳urlconverter_callback: function (url, node, on_save, name) {return url},images_upload_handler: (blobInfo) =>new Promise((resolve, reject) => {console.log(blobInfo.blob())const formData = new FormData()formData.append('file', blobInfo.blob(), blobInfo.filename())resolve('https://szx-bucket1.oss-cn-hangzhou.aliyuncs.com/picgo/image-20230512090059968.png')// axios//   .post(`/api/backend/upload`, formData, {//     headers: {//       'Content-Type': 'multipart/form-data',//       Authorization: 'Bearer ' + store.state.user.accessToken,//     },//   })//   .then((res) => {//     if (res.data.code === 1) {//       resolve(`/image_manipulation${res.data.data.filePath}`)//     } else {//       ElNotification.warning(res.data.msg)//     }//   })//   .catch((error) => {//     reject(error)//   })}),setup: (editor) => { // 自定義圖標(biāo)內(nèi)容及觸發(fā)點(diǎn)擊事件等功能editor.ui.registry.addIcon('fund—icon','<svg t="1696250970925" class="icon" viewBox="0 0 1024 1024" version="1.1" xmlns="http://www.w3.org/2000/svg" p-id="24834" width="21" height="21"><path d="M512 133.12c208.91648 0 378.88 169.96352 378.88 378.88s-169.96352 378.88-378.88 378.88-378.88-169.96352-378.88-378.88 169.96352-378.88 378.88-378.88m0-71.68c-248.83712 0-450.56 201.72288-450.56 450.56s201.72288 450.56 450.56 450.56 450.56-201.72288 450.56-450.56-201.72288-450.56-450.56-450.56z" fill="#2c2c2c" p-id="24835"></path><path d="M624.74752 263.6288a35.72224 35.72224 0 0 0-25.344 10.496L512 361.52832 424.59648 274.1248a35.73248 35.73248 0 0 0-25.344-10.496 35.84 35.84 0 0 0-25.344 61.17888L451.07712 401.9712H348.16a35.84 35.84 0 1 0 0 71.68h128v66.56H348.16a35.84 35.84 0 1 0 0 71.68h128v133.12a35.84 35.84 0 1 0 71.68 0v-133.12h128a35.84 35.84 0 1 0 0-71.68h-128v-66.56h128a35.84 35.84 0 1 0 0-71.68h-102.91712l77.16352-77.16352a35.84 35.84 0 0 0-25.33888-61.17888z" fill="#2c2c2c" p-id="24836"></path></svg>')editor.ui.registry.addIcon('income-icon','<svg t="1696250530786" class="icon" viewBox="0 0 1024 1024" version="1.1" xmlns="http://www.w3.org/2000/svg" p-id="15004" width="21" height="21"><path d="M920 152v720H104V152h816z m-67.2 67.2H171.2v585.6h681.6V219.2z" fill="#2c2c2c" p-id="15005"></path><path d="M32 152m7 0l946 0q7 0 7 7l0 53.2q0 7-7 7l-946 0q-7 0-7-7l0-53.2q0-7 7-7Z" fill="#2c2c2c" p-id="15006"></path><path d="M450.906 417.788l122.187 122.19 115.4-115.401 47.518 47.517-115.4 115.4-47.517 47.518-122.189-122.19-115.399 115.401-47.517-47.517 162.917-162.918z" fill="#2c2c2c" p-id="15007"></path><path d="M300.8 718.4H368v86.4h-67.2v-86.4z m120-86.4H488v172.8h-67.2V632z m120 48H608v124.8h-67.2V680z m120-67.2H728v192h-67.2v-192z" fill="#2c2c2c" p-id="15008"></path></svg>')editor.ui.registry.addButton('emoji', {icon: 'emoji',tooltip: '自定義表情包',onAction: () => {dialogVisible.value = true}})editor.ui.registry.addButton('fund—icon', {icon: 'fund—icon',tooltip: '基金',onAction: () => {editor.insertContent('Hello')}})editor.ui.registry.addButton('income-icon', {icon: 'income-icon',tooltip: '曬收益',onAction: () => {editor.insertContent('Hello')}})},init_instance_callback: (editor: any) => {editor.on('input', () => getEditorWordLen())}
})const initContent = computed(() => {return props.modelValue
})// 選擇自定義表情包
const chooseEmoji = (item) => {const editor = EditorRefs.value.getEditor()const range = editor.selection.getRng()const imgNode = editor.getDoc().createElement('img')imgNode.width = 32imgNode.height = 32imgNode.style = 'vertical-align: bottom;'imgNode.src = `/src/assets/emoji/${item}.webp` // 注意寫你的項(xiàng)目相對路徑range.insertNode(imgNode)dialogVisible.value = falseeditor.execCommand('seleceAll')editor.selection.getRng().collapse()editor.focus()
}const getEditorWordLen = () => {const content = tinymce.activeEditor.getContent({ format: 'text' })const wordObj = sumLetter(content)wordLenght.value = wordObj?.txt?.length || 0
}const handlePreview = () => {const editor = tinymce.activeEditoreditor.on('preview', (editor) => {console.log(editor)})
}onMounted(() => {tinymce.init({})setTimeout(() => getEditorWordLen(), 800)
})watch(initContent,(newVal) => {content.value = newVal},{ deep: true, immediate: true }
)watch(content,(newVal) => {emit('input', newVal)},{ deep: true }
)
</script><script lang="ts">
export default { name: 'TinymceEditor' }
</script><style scoped lang="scss">
.emoji {display: flex;flex-wrap: wrap;
}.emoji-item {display: flex;justify-content: center;align-items: center;margin-left: 10px;margin-bottom: 8px;cursor: pointer;img {width: 48px;height: 48px;}
}.editor_footer {margin-top: 20px;font-size: 13px;
}
</style>

創(chuàng)建wordlimit.ts文件,作為限制字符的觸發(fā)條件

import tinymce from 'tinymce/tinymce'
import { ElMessage } from 'element-plus'
import { sumLetter } from '@/utils/utilTool'tinymce.PluginManager.add('wordlimit', function (editor): any {const pluginName = '字?jǐn)?shù)限制'const app = tinymce.util.Tools.resolve('tinymce.util.Delay')const Tools = tinymce.util.Tools.resolve('tinymce.util.Tools')const wordlimit_event = editor.getParam('ax_wordlimit_event', 'SetContent Undo Redo Keyup input paste')const options = editor.getParam('wordlimit', {}, 'object')let close = nullconst toast = function (message) {close && close.close()close = ElMessage.error(message)return}// 默認(rèn)配置const defaults = {spaces: false, // 是否含空格isInput: false, // 是否在超出后還可以輸入maxMessage: '超出最大輸入字符數(shù)量!',changeCallback: () => {}, // 自定義的回調(diào)方法changeMaxCallback: () => {},toast // 提示彈窗}class WordLimit {constructor(editor, options) {options = Tools.extend(defaults, options)let preCount = 0let _wordCount = 0let oldContent = editor.getContent()const WordCount = editor.plugins.wordcounteditor.on(wordlimit_event, function (e) {const content = editor.getContent() || e.content || ''if (!options.spaces) {_wordCount = WordCount.body.getCharacterCount()} else {_wordCount = WordCount.body.getCharacterCountWithoutSpaces()}options.changeCallback({...options,editor,num: _wordCount,content,...sumLetter(content)})if (_wordCount > options.max) {preCount = _wordCountif (options.isInput == !1) {editor.setContent(oldContent)if (!options.spaces) {_wordCount = WordCount.body.getCharacterCount()} else {_wordCount = WordCount.body.getCharacterCountWithoutSpaces()}}editor.getBody().blur()editor.fire('wordlimit', {maxCount: options.max,wordCount: _wordCount,preCount: preCount,isPaste: e.type === 'paste' || e.paste || false})toast('最多只能輸入' + options.max + '個(gè)字')}oldContent = editor.getContent()})}}const setup = function () {if (!options && !options.max) return falseif (!editor.plugins.wordcount) return toast('請先在tinymce的plugins配置wordlimit之前加入wordcount插件')app.setEditorTimeout(editor,function () {const editDom = editor.getContainer()const wordNum: any = editDom.querySelector('button.tox-statusbar__wordcount')const statusbarpath: any = editDom.querySelector('.tox-statusbar__path')statusbarpath ? statusbarpath.remove() : void nullif (wordNum?.innerText?.indexOf('字符') == -1) wordNum.click()new WordLimit(editor, options)},300)}setup()return {getMetadata: function () {return {name: pluginName}}}
})
使用
<template><div class="post_contaniner"><div style="width: 100%"><TinymceEditor v-model="content" @input="inputContent" :wordlimit="{ max: 300 }" /></div></div>
</template><script lang="ts" setup>
import { ref } from 'vue'const content = ref('Hello World')const inputContent = (newVal) => {console.log(newVal)content.value = newVal
}
</script><style scoped lang="scss">
.post_contaniner {.right {flex: 1;box-shadow: 0 1px 10px 3px #dbdbdb;margin-right: 10px;padding: 10px;box-sizing: border-box;}
}
</style>
http://aloenet.com.cn/news/33549.html

相關(guān)文章:

  • 網(wǎng)站域名代辦百度搜索鏈接
  • 國外做的好的醫(yī)療網(wǎng)站網(wǎng)站域名服務(wù)器查詢
  • 怎么自己做個(gè)網(wǎng)站搜索引擎優(yōu)化論文
  • 做決定網(wǎng)站域名注冊后怎么使用
  • java做網(wǎng)站需要數(shù)據(jù)庫嗎站長之家音效素材
  • 100m的網(wǎng)站 數(shù)據(jù)庫seo快速排名優(yōu)化公司
  • 拓展培訓(xùn)東莞網(wǎng)站建設(shè)東莞關(guān)鍵詞排名seo
  • 岳陽做網(wǎng)站哪家好企業(yè)網(wǎng)站制作哪家好
  • 深圳網(wǎng)站建設(shè)大公司好seo排名點(diǎn)擊器原理
  • html網(wǎng)站建設(shè)實(shí)錄免費(fèi)b站推廣網(wǎng)站不
  • 佛山響應(yīng)式網(wǎng)站設(shè)計(jì)公司的seo是什么意思
  • linode 搭建wordpress關(guān)鍵詞優(yōu)化推廣公司
  • 丹東做網(wǎng)站的吉林seo管理平臺(tái)
  • 商城網(wǎng)站設(shè)計(jì)公司百度推廣登錄入口官網(wǎng)網(wǎng)址
  • 建站平臺(tái)的基礎(chǔ)概念查詢關(guān)鍵詞排名工具
  • 佛山家具網(wǎng)站建設(shè)公司淘寶seo優(yōu)化是什么意思
  • 建設(shè)局職責(zé)seo網(wǎng)絡(luò)推廣外包公司
  • 做百度網(wǎng)站每年的費(fèi)用多少合適太原高級seo主管
  • 常州制作網(wǎng)站最全的搜索引擎
  • 哪里做網(wǎng)站做得好windows優(yōu)化大師有用嗎
  • app模板制作軟件徐州網(wǎng)站建設(shè)方案優(yōu)化
  • airbnb網(wǎng)站建設(shè)分析網(wǎng)上哪里接app推廣單
  • 臨漳企業(yè)做網(wǎng)站推廣河北seo人員
  • 什么樣的網(wǎng)站必須做備案貼吧高級搜索
  • 用什么網(wǎng)站做動(dòng)感相冊競價(jià)推廣托管
  • 個(gè)人網(wǎng)站可以做企業(yè)網(wǎng)站嗎如何在百度上發(fā)自己的廣告?
  • 用flash做網(wǎng)站系統(tǒng)優(yōu)化的例子
  • 網(wǎng)站開發(fā) 定制 合同優(yōu)化大師使用方法
  • 如何用爬蟲做網(wǎng)站監(jiān)控百度指數(shù)怎么查
  • 做dm素材網(wǎng)站重慶網(wǎng)站快速排名提升