Tinymce实现不可编辑状态

文本编辑器禁用 Tinymce实现不可编辑状态

最近遇到了一个需求,指定某个Tinymce控件不可编辑。在Tinymce官方文档中找了好久没有可以设置为不可编辑的配置。于是换了个思路,使用遮罩层。没有什么是遮罩层搞不定的!

动态绑定class属性,当点击详情按钮的时候,文本编辑器不能编辑; 当点击编辑按钮时,文本编辑器可以编辑和修改。

 

<div :class="[showMethod?'disable':'']">
            <Tinymce ref="editor" v-model="formData.announcement" :height="300" />
          </div>
<style>
.disable{
    position:relative;
    left:0;
    top:0;
    opacity:.5;
    width:100%;
    height:300rpx;
    background:#000;
    z-index:998;
    /*pointer-events: none; 是可以点击下面的事件,但是因为div是包着tinymac的,所以无效 */
    pointer-events: none;
  }
</style>

  • 0
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 1
    评论
您可以使用 TinyMCE 的插件来实现状态栏显示最大可输入字数。以下是一些步骤: 1. 下载并引入“wordcount”插件。您可以从 TinyMCE 官方网站下载该插件,并将其引入到您的页面中。 2. 将该插件添加到 TinyMCE 的配置中。在 TinyMCE 的配置对象中添加“wordcount”插件,如下所示: ``` tinymce.init({ selector: 'textarea', plugins: 'wordcount', toolbar: false, statusbar: true }); ``` 3. 在状态栏中显示最大可输入字数。将“wordcount_max”选项添加到 TinyMCE 的配置对象中,并在状态栏中显示该选项的值。例如: ``` tinymce.init({ selector: 'textarea', plugins: 'wordcount', toolbar: false, statusbar: true, setup: function (editor) { editor.on('init', function () { var maxCount = 200; // 最大字数 var wordCountPlugin = tinymce.activeEditor.plugins.wordcount; var wordCountContainer = wordCountPlugin.getContainer(); var wordCountLabel = wordCountContainer.firstChild; wordCountLabel.innerHTML += ' / ' + maxCount; }); editor.on('keyup', function () { var maxCount = 200; // 最大字数 var wordCountPlugin = tinymce.activeEditor.plugins.wordcount; var wordCountContainer = wordCountPlugin.getContainer(); var wordCountLabel = wordCountContainer.firstChild; var currentCount = wordCountPlugin.getCount(); if (currentCount > maxCount) { wordCountLabel.style.color = 'red'; } else { wordCountLabel.style.color = 'inherit'; } wordCountLabel.innerHTML = '字数:' + currentCount + ' / ' + maxCount; }); } }); ``` 这里的代码假设最大可输入字数为200。请根据您的实际需求进行更改。

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值