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

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

react.js 中如何使用 Simditor ?

react.js 中如何使用 Simditor ?

米琪卡哇伊 2018-08-09 09:14:59
最近項目中需要使用到富文本編輯器,項目是一個 Meteor with react 項目,所以就準備采用simditor,但是官方文檔很少,也沒有給出后臺配置說明。我現在不解的是,怎么儲存數據?怎么使用儲存的數據進行展示?他是怎么保存編輯時候的格式的?還有圖片的插入問題。望大神指點,給出思路。第一次用接觸富文本編輯器
查看完整描述

2 回答

?
智慧大石

TA貢獻1946條經驗 獲得超3個贊

代碼片段供參考:

  componentDidMount() {

    var textbox = ReactDOM.findDOMNode(this.refs.textarea);

    this.editor = new Simditor({

      textarea: $(textbox),

      toolbar: ['title', 'bold', 'italic', 'underline', 'strikethrough', 'fontScale', 'color',

        'ol', 'ul', 'blockquote', 'code', 'table', 'link', 'image', 'indent', 'outdent', 'alignment', 'hr']

    });

    this.editor.on("valuechanged", (e, src) => {

      this.props.fields.body.onChange(this.editor.getValue());

    });

  }


  componentDidUpdate (prevProps) {

    if (prevProps.body !== this.props.body) {

      this.editor.setValue(this.props.body);

    }

  }

<textarea className="form-control" ref='textarea' rows="50" {...body}/>

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

添加回答

舉報

0/150
提交
取消
微信客服

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

幫助反饋 APP下載

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

公眾號

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