Tui.editor: editor.getValue is not a method

Created on 19 Mar 2020  路  8Comments  路  Source: nhn/tui.editor

Describe the bug

807 removed getValue/setValue

while vue-editor still using it

https://github.com/nhn/tui.editor/blob/d50474ea25a67b71897723e875750ab4e75cbe34/apps/vue-editor/src/Editor.vue#L68

and type definition is not updated.

https://github.com/nhn/tui.editor/blob/d50474ea25a67b71897723e875750ab4e75cbe34/apps/editor/index.d.ts#L588

To Reproduce

  1. Try to use vue-editor
  2. Input event never emit

Expected behavior

No code using removed method

Desktop (please complete the following information):

  • OS: Windows 7
  • Browser Chrome 80
  • Version 2.0.0
Question Vue inactive

Most helpful comment

It's already documented right here: Instance methods

this.$refs.toastuiEditor.invoke('getHtml');

Anyway the best way to ask these kind of questions it's to open another issue with the question label 馃憤

Thank you very much , this help me a lot.

Btw,I have already open an issue before this comment.

All 8 comments

Hi guy, I am using this editor in my application too.Could you show me some example code that getting the value of the content?
I wrap it in my component and I've tried

console.log(this.$refs.editor.getHtml);

Every time it prints 'undefined' in console.

It's already documented right here: Instance methods

this.$refs.toastuiEditor.invoke('getHtml');

Anyway the best way to ask these kind of questions it's to open another issue with the question label 馃憤

It's already documented right here: Instance methods

this.$refs.toastuiEditor.invoke('getHtml');

Anyway the best way to ask these kind of questions it's to open another issue with the question label 馃憤

Thank you very much , this help me a lot.

Btw,I have already open an issue before this comment.

I get this Error Uncaught TypeError: t.editor.getValue is not a function if v-model="editorContent" is set to the component. How can I fix it?

I'm currently listening the change event as a workaround

<Editor ref="editor" @change="onEditorChange" />

And then assign the document content to a data property:

methods: {
  onEditorChange() {
    this.content = this.$refs.editor.invoke('getMarkdown')
  },
}

Note that you can invoke any available method, such as getHtml

@pepeloper Thank you.

I implemented it in the same way

onChange(event: any) {
  const markdownText = this.invoke('getMarkdown')
  this.$emit(
    'input',
    (typeof this.value === 'undefined' || this.value === null) &&
      markdownText === ''
      ? this.value
      : markdownText,
  )
},
invoke(tuiMethodName: string) {
  return this.$refs.toastuiEditor.invoke(tuiMethodName)
}

However, if v-model does not work, we need to check the case, when value is undefined or null. It will otherwise change undefined and null values to empty string ''

This issue has been automatically marked as inactive because there hasn鈥檛 been much going on it lately. It is going to be closed after 7 days. Thanks!

This issue will be closed due to inactivity. Thanks for your contribution!

Was this page helpful?
0 / 5 - 0 ratings

Related issues

lovemine picture lovemine  路  4Comments

igasparetto picture igasparetto  路  4Comments

Rorke76753 picture Rorke76753  路  4Comments

aarangara picture aarangara  路  3Comments

koliyo picture koliyo  路  4Comments