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

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

ppt做視頻模板下載網(wǎng)站有哪些100個(gè)關(guān)鍵詞

ppt做視頻模板下載網(wǎng)站有哪些,100個(gè)關(guān)鍵詞,河北購物網(wǎng)站開發(fā)公司,機(jī)關(guān)單位網(wǎng)站建設(shè)管理制度當(dāng)前文檔是 wangEditor v4 版本的。 wangEditor v5 已經(jīng)正式發(fā)布,可參考文檔。 v5 發(fā)布之后,v4 將不再開發(fā)新功能。 介紹 English documentation wangEditor4 —— 輕量級 web 富文本編輯器,配置方便,使用簡單。 官網(wǎng)&#…

當(dāng)前文檔是 wangEditor v4 版本的。

wangEditor v5 已經(jīng)正式發(fā)布,可參考文檔。

v5 發(fā)布之后,v4 將不再開發(fā)新功能。

介紹

English documentation

wangEditor4?—— 輕量級 web 富文本編輯器,配置方便,使用簡單。

  • 官網(wǎng):www.wangeditor.com
  • 文檔:www.wangeditor.com/v4
  • 源碼:github.com/wangeditor-team/wangEditor?(歡迎 star)

1:npm 安裝 wangeditor

wangeditor v4 npm i wangeditor --save

基本使用:

<div id="div1"><p>歡迎使用 <b>wangEditor</b> 富文本編輯器</p>
</div>
<script type="text/javascript">const E = window.wangEditorconst editor = new E('#div1')editor.create()
</script>

2:構(gòu)建引入 wangeditor

import E from 'wangeditor'

3:創(chuàng)建html

<div ref="editorRef"></div>

根據(jù) ref 設(shè)置 編輯器元素高度,實(shí)例化 wangeditor

const editorRef = ref()
editor = new E(editorRef.value)

4:配置菜單

默認(rèn)情況下,顯示所有菜單

 // 配置菜單欄,刪減菜單,調(diào)整順序
editor.config.menus = ['bold','head','link','italic','underline'
]
?

5:圖片相關(guān)處理

5.1 上傳圖片限制

editor.config.uploadImgMaxLength = 3

5.2 上傳圖片大小限制

editor.config.uploadImgMaxSize: 10 * 1024 * 1024, // 10M

5.3 請求頭的設(shè)置

uploadImgServer: props.action, // 配置 server 接口地址
uploadImgHeaders: {Authorization: `Bearer ${getPiniaToken()}`,'X-Requested-With': 'XMLHttpRequest',
},

5.4 上傳請求接口

editor.config.customUploadImg = function (resultFiles, insertImgFn) {// resultFiles 是 input 中選中的文件列表// insertImgFn 是獲取圖片 url 后,插入到編輯器的方法
?// 上傳圖片,返回結(jié)果,將圖片插入到編輯器中insertImgFn(imgUrl)
}

5.5 上傳前的鉤子函數(shù)

editor.config.uploadImgHooks = {// 上傳圖片之前before: function(xhr) {console.log(xhr)
?// 可阻止圖片上傳return {prevent: true,msg: '需要提示給用戶的錯(cuò)誤信息'}},// 圖片上傳并返回了結(jié)果,圖片插入已成功success: function(xhr) {console.log('success', xhr)},// 圖片上傳并返回了結(jié)果,但圖片插入時(shí)出錯(cuò)了fail: function(xhr, editor, resData) {console.log('fail', resData)},// 上傳圖片出錯(cuò),一般為 http 請求的錯(cuò)誤error: function(xhr, editor, resData) {console.log('error', xhr, resData)},// 上傳圖片超時(shí)timeout: function(xhr) {console.log('timeout')},// 圖片上傳并返回了結(jié)果,想要自己把圖片插入到編輯器中// 例如服務(wù)器端返回的不是 { errno: 0, data: [...] } 這種格式,可使用 customInsertcustomInsert: function(insertImgFn, result) {// result 即服務(wù)端返回的接口console.log('customInsert', result)
?// insertImgFn 可把圖片插入到編輯器,傳入圖片 src ,執(zhí)行函數(shù)即可insertImgFn(result.data[0])}
}

如果使用了 customUploadImg 自定義上傳事件,那么 wangeditor 其他的圖片上傳api將會(huì)失效,例如: uploadImgServeruploadImgHeadersuploadImgHooks

以上都是修改在 editor.config,可以直接在 定義一個(gè)對象在editor.config中,看自己的需求:

6:設(shè)置是否源碼模式

wangeditor 4 不支持源碼模式,但可以自定義新增菜單

wangeditor 中創(chuàng)建 dom,按照官方文檔寫法如下:

 ?constructor(editor: E) {// data-title屬性表示當(dāng)鼠標(biāo)懸停在該按鈕上時(shí)提示該按鈕的功能簡述const $elem = $(`<div class="w-e-menu" data-title="源碼"><i style="font-style: normal">源碼</i></div>`)super($elem, editor)}

給新增的dom菜單添加事件

// 菜單點(diǎn)擊事件
clickHandler() {this.switchMode()this.tryChangeActive()
}

修改源碼模式

enum Mode {// 源碼模式Source = 'source',// 實(shí)時(shí)預(yù)覽模式Live = 'live',
}

上面使用了枚舉定義,也可以不需要做,看自己的使用方式

在這里判斷模式狀態(tài)

 this.mode = this.isSouceMode() ? Mode.Live : Mode.Source

重新設(shè)置編輯器內(nèi)容

let html = this.editor.txt.html() || ''

切換為源碼模式,替換內(nèi)容

使用字符串replace()函數(shù)查找字符進(jìn)行轉(zhuǎn)換,輸出為源碼Html

html = html.replace(/</g, '&lt;').replace(/>/g, '&gt;').replace(/ /g, '&nbsp;')

源碼轉(zhuǎn)換為文本內(nèi)容

 html = this.editor.txt.text().replace(/&lt;/gi, '<').replace(/&gt;/gi, '>').replace(/&nbsp;/gi, ' ')

菜單激活事件,每次切換菜單的時(shí)候要調(diào)用下wangeditor 方法,否則編輯器不知道你當(dāng)前菜單(擴(kuò)展)有哪些

tryChangeActive() {if (this.isSouceMode()) {this.active()} else {this.unActive()}}

其他,擴(kuò)展菜單可以參考文檔案例:https://codepen.io/xiaokyo-the-bold/pen/ZEpWBeo

7:案例

擴(kuò)展菜單class

export default class sourceMenu extends BtnMenu {mode = Mode.Live
?constructor(editor: E) {const $elem = $(`<div class="w-e-menu" data-title="源碼"><i style="font-style: normal">源碼</i></div>`)super($elem, editor)}
?// 菜單點(diǎn)擊事件clickHandler() {this.switchMode()this.tryChangeActive()}tryChangeActive() {if (this.isSouceMode()) {this.active()} else {this.unActive()}}
?isSouceMode() {return this.mode === Mode.Source}
?switchMode() {this.mode = this.isSouceMode() ? Mode.Live : Mode.Sourcelet html = this.editor.txt.html() || ''if (this.isSouceMode()) {html = html.replace(/</g, '&lt;').replace(/>/g, '&gt;').replace(/ /g, '&nbsp;')} else :html = this.editor.txt.text().replace(/&lt;/gi, '<').replace(/&gt;/gi, '>').replace(/&nbsp;/gi, ' ')}this.editor.txt.html(html)}
}

在頁面加載時(shí),初始化wangeditor配置

 ?editor.create()editor.txt.html(props.modelValue) // 初始化重新設(shè)置編輯器內(nèi)容

部分代碼

onMounted(() => {editor = new E(editorRef.value)// 擴(kuò)展自定義【源碼】菜單const sourceMenuKey = 'source'editor.menus.extend(sourceMenuKey, sourceMenu)// 配置Object.assign(editor.config, {zIndex: 1,focus: false,height: props.height,menus: [sourceMenuKey, // 源碼菜單'head','bold','fontSize','fontName','italic','underline','strikeThrough','indent','lineHeight','foreColor','backColor','link','list','todo','justify','quote','emoticon','image',// 'video', // 移除視頻菜單'table','code','splitLine','undo','redo',],uploadFileName: 'file',uploadImgParams: {path: props.path,},uploadImgServer: '', // 配置 server 接口地址uploadImgHeaders: {Authorization: 'token','X-Requested-With': 'XMLHttpRequest',},// 限制上傳的最大圖片數(shù)量uploadImgMaxLength: 2,// 單個(gè)文件的最大體積限制,默認(rèn)為 10MuploadImgMaxSize: 5 * 1024 * 1024, // 5McustomUploadImg: (files: Blob[], insertImgFn: (path: string) => void) => {try {const imgData = new FormData()for (let i in files) {imgData.append(`file`, files[i])}// 請求接口,并通過 ? insertImgFn()函數(shù) 插入到編輯器中// imgUrl 是從接口返回的圖片地址insertImgFn(imgUrl)} catch (error) {message.error('圖片上傳失敗,請重新上傳')}},
?uploadImgHooks: {customInsert: function (insertImgFn: (path: string) => void, res: Recordable) {// res即遠(yuǎn)程請求的response// insertImgFn 可把圖片插入到編輯器,傳入圖片 src ,執(zhí)行函數(shù)即可insertImgFn(res.data.path as string)},},onchange() {let sourceMenu = editor?.menus.menuList.find((item) => item.key === sourceMenuKey)emit('update:isActive', sourceMenu?.isActive)emit('update:modelValue', editor!.txt.html())},onblur() {lock = true},})editor.create()editor.txt.html(‘回顯時(shí)的內(nèi)容’) // 初始化重新設(shè)置編輯器內(nèi)容watchEffect(() => {props.disabled ? editor?.disable() : editor?.enable()})
})
onBeforeUnmount(() => {editor!.destroy()editor = null
})

http://m.aloenet.com.cn/news/1273.html

相關(guān)文章:

  • 自己做網(wǎng)站嗎百度店鋪怎么入駐
  • 重慶網(wǎng)站制seo關(guān)鍵詞怎么選
  • 網(wǎng)頁制作教程百度云網(wǎng)頁seo優(yōu)化
  • 九江網(wǎng)站建設(shè)優(yōu)化公司營銷的方法手段有哪些
  • 亞馬遜網(wǎng)網(wǎng)站建設(shè)規(guī)劃報(bào)告微信客戶管理
  • 福田做網(wǎng)站報(bào)價(jià)網(wǎng)站優(yōu)化推廣方法
  • 河南便宜網(wǎng)站建設(shè)搜索引擎營銷的簡稱是
  • 橋梁建設(shè)雜志網(wǎng)站運(yùn)營培訓(xùn)班學(xué)費(fèi)大概多少
  • wordpress網(wǎng)站導(dǎo)航模板網(wǎng)絡(luò)營銷師證書有用嗎
  • 互聯(lián)網(wǎng) 網(wǎng)站建設(shè)搜狗收錄提交入口
  • 營銷型外貿(mào)網(wǎng)站制作鄭州網(wǎng)絡(luò)推廣平臺(tái)有哪些
  • 網(wǎng)站pv統(tǒng)計(jì)方法電商seo與sem是什么
  • 怎做連接網(wǎng)站百度手機(jī)關(guān)鍵詞排名工具
  • 日本做暖網(wǎng)站泰安百度推廣公司
  • h5網(wǎng)站網(wǎng)站建設(shè)今天發(fā)生的重大新聞
  • 新華區(qū)設(shè)計(jì)網(wǎng)站公司短視頻培訓(xùn)要多少學(xué)費(fèi)
  • 廣州快速建站哪家服務(wù)專業(yè)百度搜圖片功能
  • http網(wǎng)站開發(fā)汨羅網(wǎng)站seo
  • 網(wǎng)站制作最便宜比較靠譜的推廣公司
  • 做logo的著名網(wǎng)站東莞網(wǎng)站關(guān)鍵詞優(yōu)化排名
  • 私自建立賭博網(wǎng)站判決書網(wǎng)絡(luò)推廣渠道和方式
  • 天津網(wǎng)站經(jīng)營性備案seo描述快速排名
  • python數(shù)據(jù)分析做網(wǎng)站百度總部投訴電話
  • 網(wǎng)站內(nèi)部鏈接有什么作用有什么平臺(tái)可以發(fā)廣告
  • 邢臺(tái)建網(wǎng)站找誰指數(shù)型基金
  • 深圳最新疫情防控信息亻seo關(guān)鍵詞優(yōu)化軟件
  • 如何做收機(jī)微網(wǎng)站seo排名優(yōu)化推廣報(bào)價(jià)
  • 做公司+網(wǎng)站建設(shè)價(jià)格低谷歌賬號(hào)注冊
  • 網(wǎng)易云外鏈wordpressseo服務(wù)商
  • 新手做市場分析的網(wǎng)站抖音信息流廣告怎么投放