富文本编辑器 wangEditor.js

1、引用 wangEditor 相关js  和 css

下载地址:https://files.cnblogs.com/files/kitty-blog/WangEditor.zip

3、页面:

 <div id="editor"> </div>

2、初始化编辑器:

 //初始化编辑器
        function editor_init() {
            var E = window.wangEditor;
            var editor = new E('#editor');
            editor.customConfig.linkCheck = function (text, link) {
               //校验链接地址
                if (isValidatedUrl(link)) {
                    return true;
                } else {
                    return '连接无效';
                }
            };
            editor.customConfig.linkImgCheck = function (text, link) {
                 //校验图片链接地址
                if (isValidatedUrl(link)) {
                    return true;
                } else {
                    return '图片连接无效';
                }
            };
            //自定义emoji 表情(微信)
            editor.customConfig.emotions = [
                {
                    title: '?',
                    type: 'emoji',
                    content: '☀ ☁ ☔ ⛄ ⚡ ? ? ? ? ? ? ? ? ? ❄ ⛅ ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ⌚ ⌛ ⏰ ⏳ ♈ ♉ ♊ ♋ ♌ ♍ ♎ ♏ ♐ ♑ ♒ ♓ ⛎ ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ☺ ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ⛪ ⛲ ? ? ? ? ⚓ ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?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
            editor.customConfig.colors = [
                '#000000',
                '#eeece0',
                '#1c487f',
                '#4d80bf',
                '#c24f4a',
                '#8baa4a',
                '#7b5ba1',
                '#46acc8',
                '#f9963b',
                '#ffffff',
                '#ff84b8',
                '#f44336',
                '#e91e63',
                '#9c27b0',
                '#3f51b5',
                '#2196f3',
                '#03a9f4',
                '#00bcd4',
                '#009688',
                '#4caf50',
                '#cddc39',
                '#ffeb3b',
                '#ffc107',
                '#ff9800',
                '#ff5722',
                '#795548',
                '#9e9e9e',
                '#607d8b'
            ];
            editor.create();
          //判断用户填写内容(这里用的是vue 双向绑定。)
            editor.txt.html(vm.content.length === 0 ? '' : vm.content);
            editor.change = function () {          // 这里是change 不是官方文档中的 onchange
                // 编辑区域内容变化时,实时打印出当前内容
                vm.content = this.txt.html();
            };
        },                                                   

 

转载于:https://www.cnblogs.com/kitty-blog/p/9956603.html

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值