Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

When use markdown model, the event is not work. #11

Open
chunhei2008 opened this issue Jun 9, 2016 · 6 comments
Open

When use markdown model, the event is not work. #11

chunhei2008 opened this issue Jun 9, 2016 · 6 comments

Comments

@chunhei2008
Copy link

chunhei2008 commented Jun 9, 2016

var Simditor = require('simditor');
require('to-markdown');
require('marked');
require('../../../dist/simditor-markdown/lib/simditor-markdown.js');
export default {
  props:['content'],
  ready:function(){
    var self = this;
    var editor = new Simditor({
        textarea: $('#simditor-component-editor'),
        markdown: true,
        toolbar: ['title', 'bold', 'italic', 'underline', 'strikethrough', 'color', '|', 'ol', 'ul', 'blockquote', 'code', 'table', '|', 'link', 'image', 'hr', '|', 'indent', 'outdent', 'alignment', '|', 'markdown']
      });
      editor.setValue(self.content);
      editor.on("valuechanged", function(){
          self.content = editor.getValue();
          console.log(editor.getValue());
      });
  }
}

marddown model the event is not work, but normal model is work well

@l-7-l
Copy link

l-7-l commented Jan 5, 2017

解决了么? 我的再markdown下事件也无法监听

@l-7-l
Copy link

l-7-l commented Jan 5, 2017

@l-7-l
Copy link

l-7-l commented Jan 6, 2017

componentWillReceiveProps 单词写错了......

@uerbin
Copy link

uerbin commented Feb 14, 2017

修改 _convert 函数,触发markdownchanged事件,然后editor 同时监听此事件

 SimditorMarkdown.prototype._convert = function() {
    var markdownText, text;
    text = this.textarea.val();
    markdownText = marked(text);
    this.editor.textarea.val(markdownText);
    this.editor.body.html(markdownText);
    this.editor.formatter.format();
    // Fix 修复事件无法问题
    this.editor.triggerHandler('markdownchanged');
    return this.editor.formatter.decorate();
  };

@uerbin
Copy link

uerbin commented Feb 14, 2017

这里的问题原因是 simditor-Markdown 自己也监听了 valuechanged 事件做了处理

@uerbin
Copy link

uerbin commented Feb 14, 2017

或者 把simditor-markdown.js 中监听 valuechanged事件去了,valuechanged时手动设置Markdown的值

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants