NodeJs的ueditor配置注意事项

本文介绍了解决UEditor中图片超出编辑器宽度的问题的方法,通过CSS样式限制图片最大宽度,并详细展示了如何配置服务端接口来支持UEditor的各种功能。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

图片:
在iframe.css加img{max-width:100%},解决上传图片超出编辑器宽度问题
在展示页面中需要在,包裹ueditor生成的html的元素中也加上:img{max-width:100%},解决图片过大又未设置宽度超出容器宽度问题


地址:
ueditor.config.js
1:UEDITOR_HOME_URL为当前ueditor的路径地址,eg: '/assets/plugins/ueditor/'
2:serverUrl为服务端设置的ueditor接口地址,eg: '/ueditor/ue'


服务端:
1:安装ueditor包
2:静态文件夹,如:public,下添加ueditor.config.json服务端配置文件
3:添加路由处理
app.use("/ueditor/ue", ueditor(path.join(__dirname, 'public'), function (req, res, next) {
    var ActionType = req.query.action;
    if (ActionType === 'uploadimage' || ActionType === 'uploadfile' || ActionType === 'uploadvideo') {
        var file_url = '/img/ueditor/';
        if (ActionType === 'uploadfile') {
            file_url = '/file/ueditor/';
        }
        if (ActionType === 'uploadvideo') {
            file_url = '/video/ueditor/';
        }
        res.ue_up(file_url);
        res.setHeader('Content-Type', 'text/html');
    }
    else if (ActionType === 'listimage') {
        var dir_url = '/images/ueditor/';
        res.ue_list(dir_url);
    }
    else {
        res.setHeader('Content-Type', 'application/json');
        res.redirect('/ueditor/ueditor.config.json')
    }

}));


若字数统计有误,修改源码:ueditor.all.js

getContentLength: function (ingoneHtml, tagNames) {
    var count = this.getContent(false,false,true).length;
    if (ingoneHtml) {
        tagNames = (tagNames || []).concat([ 'hr', 'img', 'iframe']);
        count = this.getContentTxt().replace(/[\t\r\n]+/g, '').length;
        for (var i = 0, ci; ci = tagNames[i++];) {
            count += this.document.getElementsByTagName(ci).length;
        }
    }
    //return count;
return count + 260;//修改为这},

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值