k55k32 / markdown-it-editor

a markdown rich text editor base on markdown-it and vue2
https://k55k32.github.io/markdown-it-editor/
61 stars 8 forks source link

err in load preview #5

Closed Jacknq closed 7 years ago

Jacknq commented 7 years ago

Hi, I get when loading in typescript: tried 1.1.2 and 1.1.4

[Vue warn]: Error in created hook: (found in ) warn @ vue.common.js:560 handleError @ vue.common.js:1445 window.onload @ app.ts:20 vue.common.js:1449TypeError: Cannot read property 'replace' of undefined at Array.e.exports (index.js:2) at n.process (index.js:2) at i.parse (index.js:1) at i.render (index.js:1)

k55k32 commented 7 years ago

Cannot read property 'replace' of undefined You maybe need find out why throw this error. I don't know how to write typescript. So my help is limit. :)

Jacknq commented 7 years ago

Yes but that error occurs in your control loading preview (stated in warning) missing replace.. you might have idea if I need to set some property or so?

k55k32 commented 7 years ago

Could you show me your code. I'll try to look up the error

Jacknq commented 7 years ago

image

usage> <me v-model="post.Content" ref="me"></me>

import { Component, create, getHelper, Vue, Store, Prop, Watch,d, p,Vuex,Lifecycle } from '../../ext1'
import DateTime from "typescript-dotnet-commonjs/System/Time/DateTime"
var multiselect = require('vue-multiselect').default;
//var markdownEditor = require('vue-simplemde').default;
import { MarkdownEditor } from 'markdown-it-editor'
    //var MarkdownEditor = require('markdown-it-editor').default;
import hljs from 'highlightjs' // have to npm install highlight
//import 'highlightjs/styles/github.css'  
    @Component({
        components: { multiselect: multiselect,me:MarkdownEditor }  //multiselect:Multiselect 

    })
    export default class epost extends Vue {
        name = 'editpost'
        id = name;
        mode = 'insert'

        post:d.Post = new d.Post();
        cats:d.Category[] =[] ;
        tags:d.Tag[] = [];

        saved:boolean =false;

          options= {
        highlight (str, lang) { // you can add highlightjs plugin to highlight your code
          if (lang && hljs.getLanguage(lang)) {
            try {
              return hljs.highlight(lang, str).value
            } catch (__) {}
          }
          return '';
        }};
}

maybe its options problem, but this should work i believe

Jacknq commented 7 years ago

It was content that was initialized in mounted. Functionality is there, now I have only problems to load css, buttons are not showing, i need to check.

Jacknq commented 7 years ago

this one was missing in quick guide import './../node_modules/markdown-it-editor/lib/css/iconfont.b300b13.woff'