zoukankan      html  css  js  c++  java
  • kindeditor自定义插件插入视频代码

    kindeditor自定义插件插入视频代码

    1、添加插件js

    目录:/kindeditor/plugins/diy_video/diy_video.js

    KindEditor.plugin('diy_video', function (K) {
        var self = this, name = 'diy_video';
        self.clickToolbar(name, function () {
            var lang = self.lang(name + '.'),
                html = ['<div style="padding:10px 20px;">',
                    '<p style="color:red">支持优酷、爱奇艺、土豆、腾讯视频、56等视频网站【<span style="color:green">通用代码</span>】</p>',
                    '<textarea class="ke-textarea" style="408px;height:260px;" placeholder="代码格式如下:
    
    <iframe height=498 width=510 src=http://player.youku.com/embed/XMzE4ODg3MjgyOA== frameborder=0 allowfullscreen></iframe>"></textarea>',
                    '</div>'].join(''),
                dialog = self.createDialog({
                    name: name,
                     450,
                    title: self.lang(name),
                    body: html,
                    yesBtn: {
                        name: self.lang('yes'),
                        click: function (e) {
                            var code = textarea.val(),
                                html = '' + code + '';
                            if (K.trim(code) === '') {
                                alert("请输入视频代码!");
                                textarea[0].focus();
                                return;
                            }
                            self.insertHtml(html).hideDialog().focus();
                        }
                    }
                }),
                textarea = K('textarea', dialog.div);
            textarea[0].focus();
        });
    });
    KindEditor.lang({
        diy_video: '视频代码'
    });

    2、新增插件样式

    <style type="text/css">
            .ke-icon-diy_video {background-image: url("/edit_html/plugins/diy_video/diy_video.png") !important;width: 16px;height: 16px;background-size: 16px;}
        </style>

    3、调用

    <script type="text/javascript">
            KindEditor.lang({
                diy_video: '视频代码'
            });
            var editor;
            KindEditor.ready(function(K) {
                editor = K.create('#editHtml', {
                    '700px',
                    height:'400px',
                    resizeType : 1,
                    filterMode:true,
                    allowImageUpload : true,
                    items : [
                        'fontname', 'fontsize', '|', 'forecolor', 'hilitecolor', 'bold', 'italic', 'underline',
                        'removeformat', 'plainpaste','|', 'justifyleft', 'justifycenter', 'justifyright',
                        'quickformat', 'link', 'unlink', 'diy_video', 'fullscreen']
                });
            });
        </script>

    说明:其他插件类似照搬即可

  • 相关阅读:
    join()方法的使用
    synchronized关键字
    voliatle关键字
    一.线程概述
    NIO demo
    同步阻塞I/O
    Ubuntu16.04.1 安装Nginx
    垃圾收集
    如何从头开始安装 wordpress
    centos 6 安装 gnu c++ 等开发工具
  • 原文地址:https://www.cnblogs.com/webapi/p/7911025.html
Copyright © 2011-2022 走看看