亚洲在线久爱草,狠狠天天香蕉网,天天搞日日干久草,伊人亚洲日本欧美

為了賬號安全,請及時綁定郵箱和手機立即綁定
已解決430363個問題,去搜搜看,總會有你想問的

simditor-markdown 無法監聽事件

simditor-markdown 無法監聽事件

大話西游666 2018-10-11 14:15:32
有沒有大神遇到過 tower的開源編輯器simditor使用了 simditor-markdown 擴展就無法監聽事件了react, jsx:    componentDidMount () {      this.initEditor()    }        initEditor = () => {      this.editor = new Simditor({        textarea: this.textArea,        markdown: true,        toolbar: ['title', 'bold', 'italic', 'underline', 'code', 'blockquote', '|', 'ol', 'ul', '|', 'markdown']      })      this.editor.setValue(marked(this.props.content))      this.editor.on('valuechanged', (e, src) => {       this.props.onTextChange(toMarkdown(this.editor.getValue()))      })    }Tag:<textarea ref={textarea => (this.textArea = textarea)} />拜托了.
查看完整描述

1 回答

?
慕尼黑8549860

TA貢獻1818條經驗 獲得超11個贊

解決方法: 覆寫源碼的獲取value, 包裝標簽方法(繼續didMount下):

    const editorNote = this
    simditorMarkdown.prototype._convert = function () {
      const text = this.textarea.val();
      editorNote.props.onTextChange(text)
      const markdownText = marked(text);      // textarea
      this.editor.textarea.val(markdownText);      // tag
      this.editor.body.html(markdownText);      // 包了層div
      this.editor.formatter.format();      return this.editor.formatter.decorate();
    };    this.editor.setValue(marked(this.props.content))

另外分享下: 表單組件建議用onchange,今天有個上傳組件手賤寫成了onClick, 剛開始以為state沒有改變的原因,后來注意到了.


查看完整回答
反對 回復 2018-11-08
  • 1 回答
  • 0 關注
  • 539 瀏覽
慕課專欄
更多

添加回答

舉報

0/150
提交
取消
微信客服

購課補貼
聯系客服咨詢優惠詳情

幫助反饋 APP下載

慕課網APP
您的移動學習伙伴

公眾號

掃描二維碼
關注慕課網微信公眾號