日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問(wèn) 生活随笔!

生活随笔

當(dāng)前位置: 首頁(yè) > 前端技术 > vue >内容正文

vue

vue2.0项目中使用Ueditor富文本编辑器应用中出现的问题

發(fā)布時(shí)間:2024/6/30 vue 32 豆豆
生活随笔 收集整理的這篇文章主要介紹了 vue2.0项目中使用Ueditor富文本编辑器应用中出现的问题 小編覺(jué)得挺不錯(cuò)的,現(xiàn)在分享給大家,幫大家做個(gè)參考.

1、如何設(shè)置config中的內(nèi)容

readonly:true,//只讀模式
wordCount:false,//是否開(kāi)啟字?jǐn)?shù)統(tǒng)計(jì)
enableAutoSave: false,//自動(dòng)保存功能

重點(diǎn):enableAutoSave不一定生效,怎么辦?

ueditor.config.js文件中設(shè)置enableAutoSave參數(shù)為false就可以關(guān)閉本地保存功能。

?//啟用自動(dòng)保存
?,enableAutoSave: false

ueditor1.4.3版本是沒(méi)有效果的,需要修改代碼,在ueditor1.5.0版本已經(jīng)得到修復(fù)。

修改方法
ueditor.all.js文件

找到

// plugins/autosave.js
UE.plugin.register('autosave', function (){

??? var me = this,
??????? //無(wú)限循環(huán)保護(hù)
??????? lastSaveTime = new Date(),
??????? //最小保存間隔時(shí)間
??????? MIN_TIME = 20,
??????? //auto save key
??????? saveKey = null;

??? function save ( editor ) {

??????? var saveData;

??????? if ( new Date() – lastSaveTime < MIN_TIME ) {
??????????? return;
??????? }

??????? if ( !editor.hasContents() ) {
??????????? //這里不能調(diào)用命令來(lái)刪除, 會(huì)造成事件死循環(huán)
??????????? saveKey && me.removePreferences( saveKey );
??????????? return;
??????? }

??????? lastSaveTime = new Date();

??????? editor._saveFlag = null;

??????? saveData = me.body.innerHTML;

??????? if ( editor.fireEvent( "beforeautosave", {
??????????? content: saveData
??????? } ) === false ) {
??????????? return;
??????? }

??????? me.setPreferences( saveKey, saveData );

??????? editor.fireEvent( "afterautosave", {
??????????? content: saveData
??????? } );

??? }

??? return {
??????? defaultOptions: {
??????????? //默認(rèn)間隔時(shí)間
??????????? saveInterval: 500
??????? },
??????? bindEvents:{
??????????? 'ready':function(){

??????????????? var _suffix = "-drafts-data",
??????????????????? key = null;

??????????????? if ( me.key ) {
??????????????????? key = me.key + _suffix;
??????????????? } else {
??????????????????? key = ( me.container.parentNode.id || 'ue-common' ) + _suffix;
??????????????? }

??????????????? //頁(yè)面地址+編輯器ID?保持唯一
??????????????? saveKey = ( location.protocol + location.host + location.pathname ).replace( /[.:\/]/g, '_' ) + key;

??????????? },

??????????? 'contentchange': function () {
?? ????????????//新增加的代碼
??????????????? if (!me.getOpt('enableAutoSave')) {
??????????????????? return;
??????????????? }

??????????????? if ( !saveKey ) {
??????????????????? return;
??????????????? }

??????????????? if ( me._saveFlag ) {
??????????????????? window.clearTimeout( me._saveFlag );
??????????????? }

??????????????? if ( me.options.saveInterval > 0 ) {

??????????????????? me._saveFlag = window.setTimeout( function () {

??????????????????????? save( me );

??????????????????? }, me.options.saveInterval );

??????????????? } else {

??????????????????? save(me);

??????????????? }

??????????? }
??????? },
??????? commands:{
??????????? 'clearlocaldata':{
??????????????? execCommand:function (cmd, name) {
??????????????????? if ( saveKey && me.getPreferences( saveKey ) ) {
??????????????????????? me.removePreferences( saveKey )
??????????????????? }
??????????????? },
??????????????? notNeedUndo: true,
??????????????? ignoreContentChange:true
??????????? },

??????????? 'getlocaldata':{
??????????????? execCommand:function (cmd, name) {
??????????????????? return saveKey ? me.getPreferences( saveKey ) || '' : '';
??????????????? },
??????????????? notNeedUndo: true,
??????????????? ignoreContentChange:true
??????????? },

??????????? 'drafts':{
??????????????? execCommand:function (cmd, name) {
??????????????????? if ( saveKey ) {
??????????????????????? me.body.innerHTML = me.getPreferences( saveKey ) || '<p>'+domUtils.fillHtml+'</p>';
??????????????????????? me.focus(true);
??????????????????? }
??????????????? },
??????????????? queryCommandState: function () {
??????????????????? return saveKey ? ( me.getPreferences( saveKey ) === null ? -1 : 0 ) : -1;
??????????????? },
??????????????? notNeedUndo: true,
??????????????? ignoreContentChange:true
??????????? }
??????? }
??? }

});

以下是新增加的代碼
if (!me.getOpt('enableAutoSave')) {
??? return;
}

ueditor1.4.3版本自動(dòng)保存關(guān)閉不了
https://github.com/fex-team/ueditor/issues/470

已在1.5.0分支修改
https://github.com/fex-team/ueditor/blob/dev-1.5.0/_src/plugins/autosave.js#L71-73

轉(zhuǎn)載于:https://www.cnblogs.com/warter00774/p/8665135.html

總結(jié)

以上是生活随笔為你收集整理的vue2.0项目中使用Ueditor富文本编辑器应用中出现的问题的全部?jī)?nèi)容,希望文章能夠幫你解決所遇到的問(wèn)題。

如果覺(jué)得生活随笔網(wǎng)站內(nèi)容還不錯(cuò),歡迎將生活随笔推薦給好友。