编程语言
首页 > 编程语言> > tiptap 编辑器显示源码

tiptap 编辑器显示源码

作者:互联网

    showSource() {
      let _this = this
      _this.isHTML = !_this.isHTML
      let _source = this.editor.getHTML()

      if (_this.isHTML) {
        _source = _source.replace(/</g, "<").replace(/>/g, ">").replace(/ /g, " ")
      } else {
        _source = _source.replace(/</ig, "<").replace(/>/ig, ">").replace(/ /ig, " ")
      }
      _source = _source.replace(/<p><p>/ig,'<p>').replace(/<\/p><\/p>/ig,'</p>')
      this.editor.commands.setContent(_source);
      
    }
isHTML = false;

标签:tiptap,isHTML,replace,source,编辑器,源码,let,editor,ig
来源: https://www.cnblogs.com/zhpblog/p/15465836.html