Giter Site home page Giter Site logo

nhn / toast-ui.vue-editor Goto Github PK

View Code? Open in Web Editor NEW
230.0 11.0 49.0 956 KB

This repository is DEPRECATED! GO TO ๐Ÿ‘‰ https://github.com/nhn/tui.editor/tree/master/apps/vue-editor

License: MIT License

Vue 27.66% JavaScript 72.34%
vue editor

toast-ui.vue-editor's Introduction

โš ๏ธNotice: This repository is deprecated๏ธ๏ธ๏ธ๏ธ๏ธ

TOAST UI Editor Vue Wrapper has been managed separately from the TOAST UI Editor repository. As a result of the distribution of these issues, we decided to deprecated each wrapper repository and manage repository as a mono-repo from the TOAST UI Editor repository.

From now on, please submit issues or contributings related to TOAST UI React Wrapper to TOAST UI Editor repository. Thank you๐Ÿ™‚.

TOAST UI Editor for Vue

This is Vue component wrapping TOAST UI Editor.

vue2 github version npm version license PRs welcome code with hearth by NHN

๐Ÿšฉ Table of Contents

Collect statistics on the use of open source

Vue Wrapper of TOAST UI Editor applies Google Analytics (GA) to collect statistics on the use of open source, in order to identify how widely TOAST UI Editor is used throughout the world. It also serves as important index to determine the future course of projects. location.hostname (e.g. > โ€œui.toast.com") is to be collected and the sole purpose is nothing but to measure statistics on the usage. To disable GA, use the following usageStatistics options when declare Vue Wrapper compoent.

var options = {
    ...
    usageStatistics: false
}

Or, include include tui-code-snippet.js (v1.4.0 or later) and then immediately write the options as follows:

tui.usageStatistics = false;

๐Ÿ’พ Install

Using npm

npm install --save @toast-ui/vue-editor

๐Ÿ“ Editor Usage

Load

You can use Toast UI Editor for Vue as moudule format or namespace. Also you can use Single File Component (SFC of Vue). When using module format and SFC, you should load tui-editor.css, tui-editor-contents.css and codemirror.css in the script.

  • Using Ecmascript module

    import 'tui-editor/dist/tui-editor.css';
    import 'tui-editor/dist/tui-editor-contents.css';
    import 'codemirror/lib/codemirror.css';
    import { Editor } from '@toast-ui/vue-editor'
  • Using Commonjs module

    require('tui-editor/dist/tui-editor.css');
    require('tui-editor/dist/tui-editor-contents.css');
    require('codemirror/lib/codemirror.css');
    var toastui = require('@toast-ui/vue-editor');
    var Editor = toastui.Editor;
  • Using Single File Component

    import 'tui-editor/dist/tui-editor.css';
    import 'tui-editor/dist/tui-editor-contents.css';
    import 'codemirror/lib/codemirror.css';
    import Editor from '@toast-ui/vue-editor/src/Editor.vue'
  • Using namespace

    var Editor = toastui.Editor;

Implement

First implement <editor/> in the template.

<template>
    <editor/>
</template>

And then add Editor to the components in your component or Vue instance like this:

import { Editor } from '@toast-ui/vue-editor'

export default {
  components: {
    'editor': Editor
  }
}

or

import { Editor } from '@toast-ui/vue-editor'
new Vue({
    el: '#app',
    components: {
        'editor': Editor
    }
});

Using v-model

If you use v-model, you have to declare a data for binding. (โ—๏ธ When using the editor in wysiwyg mode, v-model can cause performance degradation.)

In the example below, editorText is binding to the text of the editor.

<template>
    <editor v-model="editorText"/>
</template>
<script>
import { Editor } from '@toast-ui/vue-editor'

export default {
  components: {
    'editor': Editor
  },
  data() {
      return {
          editorText: ''
      }
  }
}
</script>

Props

Name Type Default Description
value String '' This prop can change content of the editor. If you using v-model, don't use it.
options Object following defaultOptions Options of tui.editor. This is for initailize tui.editor.
height String '300px' This prop can control the height of the editor.
previewStyle String 'tab' This prop can change preview style of the editor. (tab or vertical)
mode String 'markdown' This prop can change mode of the editor. (markdownor wysiwyg)
html String - If you want to change content of the editor using html format, use this prop.
visible Boolean true This prop can control visible of the eiditor.
const defaultOptions = {
    minHeight: '200px',
    language: 'en_US',
    useCommandShortcut: true,
    useDefaultHTMLSanitizer: true,
    usageStatistics: true,
    hideModeSwitch: false,
    toolbarItems: [
        'heading',
        'bold',
        'italic',
        'strike',
        'divider',
        'hr',
        'quote',
        'divider',
        'ul',
        'ol',
        'task',
        'indent',
        'outdent',
        'divider',
        'table',
        'image',
        'link',
        'divider',
        'code',
        'codeblock'
    ]
};

Example :

<template>
    <editor
    :value="editorText"
    :options="editorOptions"
    :html="editorHtml"
    :visible="editorVisible"
    previewStyle="vertical"
    height="500px"
    mode="wysiwyg"
    />
</template>
<script>
import { Editor } from '@toast-ui/vue-editor'

export default {
    components: {
        'editor': Editor
    },
    data() {
        return {
            editorText: 'This is initialValue.',
            editorOptions: {
                hideModeSwitch: true
            },
            editorHtml: '',
            editorVisible: true
        };
    },
};
</script>

Event

  • load : It would be emitted when editor fully load
  • change : It would be emitted when content changed
  • stateChange : It would be emitted when format change by cursor position
  • focus : It would be emitted when editor get focus
  • blur : It would be emitted when editor loose focus

Example :

<template>
    <editor
    @load="onEditorLoad"
    @focus="onEditorFocus"
    @blur="onEditorBlur"
    @change="onEditorChange"
    @stateChange="onEditorStateChange"
    />
</template>
<script>
import { Editor } from '@toast-ui/vue-editor'

export default {
    components: {
        'editor': Editor
    },
    methods: {
        onEditorLoad() {
            // implement your code
        },
        onEditorFocus() {
            // implement your code
        },
        onEditorBlur() {
            // implement your code
        },
        onEditorChange() {
            // implement your code
        },
        onEditorStateChange() {
            // implement your code
        },
    }
};
</script>

Method

If you want to more manipulate the Editor, you can use invoke method to call the method of tui.editor. For more information of method, see method of tui.editor.

First, you need to assign ref attribute of <editor/> and then you can use invoke method through this.$refs like this:

<template>
    <editor ref="tuiEditor"/>
</template>
<script>
import { Editor } from '@toast-ui/vue-editor'

export default {
    components: {
        'editor': Editor
    },
    methods: {
        scroll() {
            this.$refs.tuiEditor.invoke('scrollTop', 10);
        },
        moveTop() {
            this.$refs.tuiEditor.invoke('moveCursorToStart');
        },
        getHtml() {
            let html = this.$refs.tuiEditor.invoke('getHtml');
        }
    }
};
</script>

๐Ÿ“ƒ Viewer Usage

Load

  • Using Ecmascript module

    import 'tui-editor/dist/tui-editor-contents.css';
    import 'highlight.js/styles/github.css';
    import { Viewer } from '@toast-ui/vue-editor'
  • Using Commonjs module

    require('tui-editor/dist/tui-editor-contents.css');
    require('highlight.js/styles/github.css'); 
    var toastui = require('@toast-ui/vue-editor');
    var Viewer = toastui.Viewer;
  • Using Single File Component

    import 'tui-editor/dist/tui-editor-contents.css';
    import 'highlight.js/styles/github.css';
    import Viewer from '@toast-ui/vue-editor/src/Viewer.vue'
  • Using namespace

    var Viewer = toastui.Viewer;

Implement

First implement <viewer/> in the template.

<template>
    <viewer/>
</template>

And then add Viewer to the components in your component or Vue instance like this:

import { Viewer } from '@toast-ui/vue-editor'

export default {
  components: {
    'viewer': Viewer
  }
}

or

import { Viewer } from '@toast-ui/vue-editor'
new Vue({
    el: '#app',
    components: {
        'viewer': Viewer
    }
});

Props

Name Type Default Description
value String '' This prop can change content of the viewer.
height String '300px' This prop can control the height of the viewer.
exts Array This prop can apply the extensions of the viewer.

Example :

<template>
    <viewer
    :value="viewerText"
    height="500px"
    />
</template>
<script>
import { Viewer } from '@toast-ui/vue-editor'

export default {
    components: {
        'viewer': Viewer
    },
    data() {
        return {
            viewerText: '# This is Viewer.\n Hello World.',
        };
    },
};
</script>

Event

  • load : It would be emitted when editor fully load
  • change : It would be emitted when content changed
  • stateChange : It would be emitted when format change by cursor position
  • focus : It would be emitted when editor get focus
  • blur : It would be emitted when editor loose focus

Example :

<template>
    <viewer
    @load="onEditorLoad"
    @focus="onEditorFocus"
    @blur="onEditorBlur"
    @change="onEditorChange"
    @stateChange="onEditorStateChange"
    />
</template>

<script>
import { Viewer } from '@toast-ui/vue-editor'

export default {
    components: {
        'viewer': Viewer
    },
    methods: {
        onEditorLoad() {
            // implement your code
        },
        onEditorFocus() {
            // implement your code
        },
        onEditorBlur() {
            // implement your code
        },
        onEditorChange() {
            // implement your code
        },
        onEditorStateChange() {
            // implement your code
        },
    }
};

๐Ÿ”ง Pull Request Steps

TOAST UI products are open source, so you can create a pull request(PR) after you fix issues. Run npm scripts and develop yourself with the following process.

Setup

Fork develop branch into your personal repository. Clone it to local computer. Install node modules. Before starting development, you should check to haveany errors.

$ git clone https://github.com/{your-personal-repo}/[[repo name]].git
$ cd [[repo name]]
$ npm install

Develop

Let's start development!

Pull Request

Before PR, check to test lastly and then check any errors. If it has no error, commit and then push it!

For more information on PR's step, please see links of Contributing section.

๐Ÿ’ฌ Contributing

๐Ÿ“œ License

This software is licensed under the MIT ยฉ NHN.

toast-ui.vue-editor's People

Contributors

arkist avatar changjoo-park avatar js87zz avatar panjiachen avatar sohee-lee7 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

toast-ui.vue-editor's Issues

How can I use exts with Viewer?

Version

@toast-ui/vue-editor 1.0.4
tui-editor 1.3.3

Test Environment

Chrome 73.0.3683.75

Current Behavior

Editor has options prop, but Viewer does not have options prop so that I cannot define exts to use on Viewer.

Expected Behavior

Please add options prop or exts prop to Viewer

NPM Install fails with npm ERR! package.json Non-registry package missing package.json: squire-rte@github:sohee-lee7/Squire#b1e0e1031fa18912d233c204cbe7c7fae4a42621

Version

Latest from NPM

Test Environment

Windows

Current Behavior

npm install --save @toast-ui/vue-editor

Gives error:
npm ERR! code ENOPACKAGEJSON
npm ERR! package.json Non-registry package missing package.json: squire-rte@github:sohee-lee7/Squire#b1e0e1031fa18912d233c204cbe7c7fae4a42621.
npm ERR! package.json npm can't find a package.json file in your current directory.

npm ERR! A complete log of this run can be found in:
npm ERR! C:\Users\mstacey\AppData\Roaming\npm-cache_logs\2019-03-11T10_10_15_631Z-debug.log

All other packages install fine, so it doesn't appear to be a local NPM install issue

Expected Behavior

NPM install works

How to get markdownit ?

Version

"@toast-ui/vue-editor": "^1.1.1"

Test Environment

  • browser: Electron app, chrome

  • OS: Ubuntu18

Current Behavior

I wanted to get markdownit to do some pretreatment(replace some html tag, reformat html ... ) before preview. So I used invoke(getMarkdownitRenderer) . However, I get null.

reference: https://nhn.github.io/tui.editor/api/latest/Convertor.html#.getMarkdownitRenderer

<template>
  <div class="editor">
    <Editor
      ref="editor"
      v-model="editorContent"
      :options="editorOptions"
      height="100%"
      previewStyle="vertical"
      :visible="true"
      mode="markdown"
      @change="mdContentChanged"
    ></Editor>
  </div>
</template>

<script>
import 'tui-editor/dist/tui-editor.css'
import 'tui-editor/dist/tui-editor-contents.css'
import 'codemirror/lib/codemirror.css'
import { Editor } from '@toast-ui/vue-editor'

export default {

  name: 'MDEditor',

  props: ['markdownContent', 'imgPath', 'filePath'],

  components: { Editor },

  created () {
    console.log(this.imgPath)
  },

  mounted: function () {
    console.log(this.$refs.editor.invoke('getMarkdownitRenderer'))
 }
}
</script>

Expected Behavior

How to @import in vue.style-tag

Version

[email protected]
[email protected]
[email protected]
[email protected]

Current Behavior

<style lang="scss" scoped>
@import 'tui-editor/dist/tui-editor.css';
@import 'tui-editor/dist/tui-editor-contents.css';
@import 'codemirror/lib/codemirror.css';
</style>
<script>
import {
    Editor
} from '@toast-ui/vue-editor'
...
</script>

but,

ERROR in ./node_modules/extract-text-webpack-plugin/dist/loader.js?{"omit":1,"remove":true}!./node_modules/vue-style-loader!./node_modules/css-loader?sourceMap!./node_modules/vue-loader/lib/style-compiler?{"optionsId":"0","vue":true,"id":"data-v-69049a82","scoped":true,"sourceMap":true}!./node_modules/sass-loader/lib/loader.js!./node_modules/vue-loader/lib/selector.js?type=styles&index=0!

Module build failed: ModuleNotFoundError: Module not found: Error: Can't resolve './tui-editor-2x.png'

Expected Behavior

Not import script-tag like example.
I wish import in style-tag.

Error: Cannot read property 'classList' of null when trying to load the editor inside a nested component.

Version

2.0.1

Test Environment

Chrome, Mac OS Catalina

Current Behavior

When registering the editor component from within a nested component I get the console error 'Cannot read propertyclassList of null'. The editor loads fine in the parent component, just not the child or grandchild component. The toolbar loads, but no content area.

My structure is as follows:

  1. Page.vue - Editors works as expected
    1.1. PageForm.vue - Editor produces classList error
    1.1.1. PageFormTextarea.vue - Editor produces classList error

Expected Behavior

I would expect the editor to load for each level of component.

Indent/Outdent botton doesn't work in WYSIWYG mode.

Version

"@toast-ui/vue-editor": "^1.1.1"

Test Environment

Chrome
Mac

Current Behavior

// Write example code
      toolbarItems: [
        'heading',
        'bold',
        'italic',
        'divider',
        'hr',
        'quote',
        'divider',
        'image',
        'indent',
        'outdent'
      ],

Expected Behavior

In WYSIWG mode
Use Indent/Outdent button.
It doesn't work.
And could I apply to getHtml()/setHtml() ?
text-indent/padding-left

hahahahahaha
hohohohohoho
blar blar blar blar

==>
hahahahahaha
ย ย ย ย hohohohohoho
blar blar blar blar

and getHtml() setHtml()

list buttons does not fire input event

Version

1.1.1

Test Environment

all

Current Behavior

Write some test highlight it and click on the UL or OL buttons. no imput event is fired.

// Write example code

Expected Behavior

The input event should have been fired as the value changed.

npm error

when npm install get error

Version

Test Environment

npm install --save @toast-ui/vue-editor

Current Behavior

67 verbose node v10.8.0
68 verbose npm  v6.9.0
69 error path git
70 error code ENOENT
71 error errno ENOENT
72 error syscall spawn git
73 error enoent Error while executing:
73 error enoent undefined ls-remote -h -t ssh://[email protected]/sohee-lee7/Squire.git
73 error enoent
73 error enoent
73 error enoent spawn git ENOENT
74 error enoent This is related to npm not being able to find a file.
75 verbose exit [ 1, true ]

Expected Behavior

Cannot use 'invoke' inside load event handler

Version

tui-editor 1.2.9
@toast-ui/vue-editor 1.0.4

Test Environment

Chrome 72.0.3626.119
macOS Mojave 10.14.1

Current Behavior

When I try to use invoke method to call the method of tui.editor inside load event handler,

Error in v-on handler: "TypeError: Cannot read property 'getCodeMirror' of null" occurs.

invoke works well except load error handler.

// Write example code
<template>
    <editor
    ref="tuiEditor"
    @load="onEditorLoad"
    />
</template>
<script>
import { Editor } from '@toast-ui/vue-editor'

export default {
    components: {
        'editor': Editor
    },
    methods: {
        onEditorLoad() {
            const cm = this.$refs.tuiEditor.invoke('getCodeMirror')
        },
    }
};
</script>

It seems that load event has some timing issue that event handler called before registering this.editor property at line 100 of Editor.vue

https://github.com/nhnent/toast-ui.vue-editor/blob/00bb7b3f533dd6b9fe4fd145128ff5939839838c/src/Editor.vue#L100

Expected Behavior

load event should emit after component is ready to go.

[Question] How could call the Vue method in addImageBlobHook

Version

@toast-ui/vue-editor: 1.1.1
vue: 2.6.10

Test Environment

Chrome
IOS

Current Behavior

<template>
  <tui-editor :options="editorOptions" :height="defaultHeight"
              mode="wysiwyg" :visible="true" ref="tuiEditor"
  />
</template>

<script>
import { Editor } from '@toast-ui/vue-editor'

export default {
  components: {
    'tui-editor': Editor
  },
  props: {
    defaultHeight: String
  },
  data: () => ({
    editorOptions: {
      minHeight: '200px',
      language: 'ko_KR',
      useCommandShortcut: true,
      useDefaultHTMLSanitizer: true,
      usageStatistics: false,
      hideModeSwitch: true,
      toolbarItems: [
        'heading',
        'bold',
        'italic',
        'divider',
        'hr',
        'quote',
        'divider',
        'image',
        'link',
        'divider'
      ],
      exts: [
        'colorSyntax'
      ],
      hooks: {
        addImageBlobHook (blob, callback) {
          let url = this.uploadFile(blob) // How can I call a function?
          callback.call('[image]', url) // It works.
          return true
        }
      }
    }
  }),
  methods: {
    uploadFile (blob) {
      const formData = new FormData()
      // blob blar blar blar
      this.axios.post('/api/external/fileUpload', formData, {
        headers: {
          'Content-Type': 'multipart/form-data'
        }
      }).then(res => {
        if (res.data.code !== 0) throw res.data.message
        return res.data.data.imageUrl
      }, () => alert('์‹œ์Šคํ…œ์—์„œ ์˜ค๋ฅ˜๊ฐ€ ๋ฐœ์ƒํ•˜์˜€์Šต๋‹ˆ๋‹ค.'))
        .catch(errorMsg => alert(errorMsg))
        .finally(() => {
          return false
        })
    },
    getHtml () {
      let html = this.$refs.tuiEditor.invoke('getHtml')
      return html
    },
    setHtml (obj) {
      this.$refs.tuiEditor.invoke('setHtml', obj)
    }
  }
}
</script>

<style scoped>

</style>

Expected Behavior

addImageBlobHook call vue method.

I'd like to call my Vue method.
How could I access the Vue method?

vue ์ดˆ๋ณด๋ผ์„œ ์–ด๋–ป๊ฒŒ ์ ‘๊ทผํ• ์ง€ ๋ชจ๋ฅด๊ฒ ์Šต๋‹ˆ๋‹ค.
์ข‹์€ ์—๋””ํ„ฐ๋ฅผ ๋งŒ๋“ค์–ด ์ฃผ์–ด์„œ ๊ฐ์‚ฌํ•ฉ๋‹ˆ๋‹ค.
๋ฉ‹์ง€๊ณ  ํ•œ๊ธ€ ํ˜ธํ™˜ ์ž˜๋œ๋‹ค๋Š” ์—๋””ํ„ฐ๋ฅผ ์“ฐ๊ณ  ์‹ถ์Šต๋‹ˆ๋‹ค.
์ด๋ฏธ์ง€ ์—…๋กœ๋“œ์‹œ ํ›…๋„ ์ œ๊ณตํ•ด์„œ ๋”ฑ ํ•„์š”ํ•ฉ๋‹ˆ๋‹ค. ๋งค์šฐ ์“ฐ๊ณ  ์‹ถ์Šต๋‹ˆ๋‹ค.
๋„์™€์ฃผ์„ธ์š”.

Support inserting text at cursor position

Version

1.1.1

Test Environment

Windows 10 x64, Firefox 71

Question

Consider this either a question or a feature request if what I'm asking is not currently possible. I'd like to programmatically insert a text string at the current cursor position, is this possible?

How can I use color picker on vue-editor?

Version

1.1.1

Test Environment

MacOS

Current Behavior

I couldn't find the guide for setting text color. Can I use font color changing on vue-editor? If so, how can I?

just issuing typo

Version

Test Environment

Current Behavior

// Write example code

Expected Behavior

Hello.
I found a typo while reading README.md.
At 165 line of README.md, '| visible | Boolean | true | This prop can control visible of the eiditor. |
'
I think, 'eiditor' will have to be changed to 'editor'.

I used tui-editor well. Thanks.

CDN version?

Being able to pull this from a CDN for testing and mock ups would be very helpful...

Prop for disabling the editor

I was wondering if it is possible to add a prop that allows the editor to be disabled. I also use this editor to only display the current value, the user has to press an "edit" button to be able to start editing. Right now I made a little workaround myself for this. I just add a div on top of the editor with an opacity. This solution could work find but if the content in the editor is long you can't scroll down. Any plans/possibility to add this? Or anyone else knows a better way to work around this?

Disabling cursorToEnd?

Version

1.1.1

Test Environment

Firefox, Win10

Current Behavior

When I have markdown enabled as default in the editor then the window will automatically scroll to show the editor (if it needs to be scrolled to, to be seen). If I have WYSIWYG enabled as default then the window will not scroll to the editor.

My guess would be that cursorToEnd is true by default. How can I disable this?

Expected Behavior

I'd like the window not to scroll to the editor's position unless I ask it to.

How to POST content?

Version

...
โ”œโ”€โ”€ @toast-ui/[email protected]
โ”œโ”€โ”€ [email protected]

Current Behavior

<template>
    <form method="POST" action="">
        <slot></slot>
        <editor
            :options="editorOptions"
            height="auto"
            previewStyle="vertical"
            mode="wysiwyg"
            name="edit"
        ></editor>
    </form>
</template>

<script>
import "tui-editor/dist/tui-editor.css";
import "tui-editor/dist/tui-editor-contents.css";
import "tui-editor/dist/tui-editor-extTable.js";
import "tui-editor/dist/tui-editor-extColorSyntax.js"; 
import "tui-editor/dist/tui-editor-extScrollSync.js";
import "tui-color-picker/dist/tui-color-picker.css";
import "codemirror/lib/codemirror.css";
import { Editor } from "@toast-ui/vue-editor";

export default {
    components: {
        "editor": Editor
    },
    data: () => ({
        editorOptions: {
            minHeight: "400px",
            language: "ko_KR",
            exts: [
                "table", "colorSyntax", "scrollSync"
            ]
        },
    })
};
</script>

Expected Behavior

I want to post content from a form but editor has only div elements. How can I do this?

<template>
    <form method="POST" action>
        <slot></slot>
        <input v-model="content" type="text" name="content" hidden>
        <editor
            v-model="content"
            :options="editorOptions"
            height="auto"
            previewStyle="vertical"
            mode="wysiwyg"
            name="edit"
        ></editor>
    </form>
</template>

Is this the best way?

How to write `exts`?

Version

1.4.0

Test Environment

linux,webpack,vue
I write one page like below.

<template>
  <editor :exts="exts" />
</template>
<script>
import "tui-editor/dist/tui-editor.css";
import "tui-editor/dist/tui-editor-contents.css";
import "codemirror/lib/codemirror.css";
import { Editor } from "@toast-ui/vue-editor";
import tui from "tui-editor";
tui.defineExtension("youtube", () => {
  console.log("extension is defined");//This sentence is never reached !
});
export default {
  components: { Editor },
  data() {
    return {
      exts: ["youtube"]
    };
  },
  mounted() {},
  methods: {}
};
</script>
<style lang="less">
</style>

Current Behavior

console.log("extension is defined"); this sentence cannot be reached !

Expected Behavior

When I write youtube,it should become one link.

image

But now it doesn't work,how can I run the youtube demo in vue. Can you write one specific ext demo like this link:make new extensions

getHtml returns markdown

Version

@toast-ui/vue-editor 1.1.1

Test Environment

Chrome, vuejs 2.6.11

Current Behavior

I am using vuejs , and npm i @toast-ui/vue-editor
Will try and setup a codepen or jsfiddle, but not familiar how to do this.

When i format a single word with bold, it works fine.
getHtml returns eg <strong>Bolded</strong>

When i format a second word with bold, and look at html (using getHtml), the 2nd bolded word is in markdown eg
**Bolded**
This applies for Italics and Strike Through as well

Expected Behavior

All words formatted should be return HTML when using getHtml function

hooks

vue๋‚˜ nuxt์—์„œ๋Š” hooks์˜ addImageBlob์— ๋Œ€ํ•œ ์„ค๋ช…์ด ์–ธ๊ธ‰๋˜์–ด์žˆ๋Š”๊ฒŒ ์—†์–ด์„œ
ํ˜„์žฌ nuxt๋ฅผ ์‚ฌ์šฉ์ค‘์ธ๋ฐ props๋กœ ์ „๋‹ฌ์ด ๊ฐ€๋Šฅํ•œ ๋ฐฉ๋ฒ•์ด ์žˆ๋‚˜์š”?

Localization feature

Feature Request,

Hi, Thank, You For Such Fabulous Component.
Wouldn't Nice If You Can Localiza The Component To Support Any Language?

NPM error

1.0.0 - 1.0.4

Test Environment

Linux

Current Behavior

When running npm install after including this in my package.json, the install will hang for 10-20 minutes and then I get the following error:
npm ERR! Error while executing:
npm ERR! /usr/bin/git ls-remote -h -t git://github.com/adobe-webplatform/eve.git
npm ERR!
npm ERR! undefined
npm ERR! exited with error code: 128

It's been this way for a couple of days. Any work around or fix?

// Write example code

Expected Behavior

"exts" does not work ?

question

Version

1.0.3

Test Environment

Safari 12.0, macOS Mojave 10.14

Current Behavior

I am looking for an option to use exts.

<template>
  <div id="app">
    <editor v-model="editorText" :options="editorOptions" />
  </div>
</template>

<script>
import { Editor } from '@toast-ui/vue-editor'

export default {
  components: {
    'editor': Editor,
  },
  data() {
      return {
          editorText: '# CCC',
          editorOptions: {
            exts: ['scrollSync', 'colorSyntax', 'uml', 'chart', 'mark', 'table'],
          }
      }
  },
}
</script>

Thank you.

Dynamically change the language

Hi, can you help me please to dynamically change the language ?
onEditorLoad(instance) { this.tuiEditor = instance; },

then changed language by :
this.tuiEditor.i18n.setCode('fr_FR')
console.log( this.tuiEditor.i18n)
gives me this response:

I18n {__ob__: Observer}
_code: "fr_FR"
_langs: (...)

But the toolbar still in English (original)
Need to refresh or reload the component and I dont know how.
Thank you in advance.

error loading editor

hello,

when i load the component i get this error:

[Vue warn]: Error in mounted hook: "TypeError: Cannot read property 'input' of undefined"

found in

---> <TuiEditor> at src/Editor.vue
       <Test2> at D:\WebServer\ZeinTekWebServices\liveroot\Merlin Internal Front End\src\pages\tests\Test2.vue
         <App> at D:\WebServer\ZeinTekWebServices\liveroot\Merlin Internal Front End\src\App.vue
           <Root>

I even tried commenting out some of the input statements i found inside the node modules in the folder @toast-ui/vue-editor but it is not affecting the code, everything is working as if the Editor.vue file is being loaded from somewhere else on my pc. It is very strange.

<template>
	<div id="landing" class="landing">
		<h1 class="temptitle">Test - Toast ui editor only</h1>
		
		<!-- don't use vmodel and value at the same time -->
		<editor
			value="editorText"
		/>
		
	</div>	
</template>

<script>
	import Vue from 'vue'
	import store from '@/store/store.js'
	import { Editor } from '@toast-ui/vue-editor'
	
	export default {
		data () {
			return {
				editorText: 'This is initialValue.',
			}
		},
		
		props: [
			//
		],
		
		components: {
			'editor': Editor,
		},
		
		computed: {
			
		},
		
		methods: {
			
		},
		
		created () {
			//
		},
		
		mounted () {
			//
		}
	}
</script>

<style>
	@import '../../packages/css/tui-editor/1.3.0/dist/tui-editor.css';
	@import '../../packages/css/tui-editor/1.3.0/dist/tui-editor-contents.css';
	@import '../../packages/css/codemirror/2019-05-17/lib/codemirror.css';
	
	.landing {
		background-color: white;
		height: 100%;
	}
</style>

how to set focus on editor component

Version

@toast-ui/vue-editor": "^1.0.4

Test Environment

Chromium Version 74.0.3729.169 (Official Build) Built on Ubuntu , running on Ubuntu 19.04 (64-bit)
Google Chrome Version 74.0.3729.157 (Official Build) (64-bit)

Current Behavior

Set focus does not work. None of the below options work, including the TUI Editor API

mounted () {
    this.$refs.editor.focus()
    this.$nextTick(function() {
      this.$refs.editor.focus()
    })
    this.$refs.editor.invoke('focus')
}

Expected Behavior

Upon render cursor should be set to the contenteditable div

<div contenteditable="true" class="tui-editor-contents tui-editor-contents-placeholder" data-placeholder="Start writing here..."><div>

Same as issue nhn/tui.editor#314 which was closed with no resolution.
Sample image from the github issue above:

Nuxt ์„œ๋ฒ„ ์‚ฌ์ด๋“œ

Version

1.1.1

Test Environment

Nuxt 2.6.2

Current Behavior

์„œ๋ฒ„์‚ฌ์ด๋“œ์—์„œ ๋™์ž‘ ๋ฌธ์˜
ํด๋ผ์ด์–ธํŠธ๋‹จ์—์„œ๋Š” ์ƒ๊ด€ ์—†๋Š”๋ฐ
์„œ๋ฒ„๋‹จ์—์„œ๋Š” ๋กœ๋“œ๋ฅผ ํ•  ์ˆ˜ ์—†๋Š” ๊ฒƒ์ธ๊ฐ€์š”?
์•„๋ž˜ ์ฝ”๋“œ๋Š” index.vue ํŽ˜์ด์ง€ ๋‹จ์—์„œ ํ˜ธ์ถœํ–ˆ์„ ๊ฒฝ์šฐ
์ •์ƒ์ ์œผ๋กœ ์—๋””ํ„ฐ๋ฅผ ๋กœ๋“œํ•ฉ๋‹ˆ๋‹ค.

if(process.client) {
require('tui-editor/dist/tui-editor.css');
require('tui-editor/dist/tui-editor-contents.css');
require('codemirror/lib/codemirror.css');
var toastui = require('@toast-ui/vue-editor');
var Editor = toastui.Editor;
}

// Write example code

Expected Behavior

nuxt.config.js ์ชฝ์—์„œ ์„ ์–ธํ•˜๊ณ  ์‚ฌ์šฉํ•˜๋Š” ๋ฐฉ๋ฒ•์„ ์•Œ๊ณ  ์‹ถ์Šต๋‹ˆ๋‹ค.

How to get HTML Export

i'm using this pack with nuxt.js. Everything work fine but just export how to make HTML ?

This example content:
qweqeqweqeqewq ## 123123123123123 > qweqweqeqeqeqweqeqeqwe - - - * [x] qwe * [x] qweqw * [ ] eqwe * [ ] qwe * [x] 12 * [x] 3123 * [x] 123 * [ ] 123 | qweqw | eqeq | wqeqw | qweqwe | | ----- | ---- | ----- | ------ | | qweqwe | qeq | weqwe

[Bug]Uncaught TypeError: Cannot read property 'msie' of undefined

Version

1.1.1

Test Environment

My package.json version

  "dependencies": {
    "@scenejs/effects": "^1.0.1",
    "@toast-ui/vue-editor": "^1.1.1",

and My component is like this.

import 'tui-editor/dist/tui-editor.css';
import 'tui-editor/dist/tui-editor-contents.css';
import 'codemirror/lib/codemirror.css';
import { Editor } from '@toast-ui/vue-editor'
  import {
    mapActions,
    mapMutations,
    mapState,
  } from 'vuex'
  export default {
    name: 'user',
    components: { 
    'editor': Editor
    },

Current Behavior

Error : [Bug]Uncaught TypeError: Cannot read property 'msie' of undefined
Did I make a mistake?

Expected Behavior

Editor Loaded

Q: Is there a 'viewer' component?

Version

1.0.2

Test Environment

Chrome, Linux

Current Behavior

Looking for a feature to display rendered view

<viewer v-vmodel="inputText" />

Expected Behavior

viewer rendered input

Having trouble doing an async module loading

Version

1.1.1

Test Environment

Windows 10 64 bits / Chrome

Current Behavior

I'm trying to integrate your component in a vuejs app.

I'm having an ultra simple .vue component that uses the Toastui's editor as following
FileName : myEditor.vue

<template>
  <editor v-model="content"></editor>
</template>
<script>
import config from 'config'
import 'tui-editor/dist/tui-editor.css'
import 'tui-editor/dist/tui-editor-contents.css'
import { Editor } from '@toast-ui/vue-editor' 
 
export default {
  name: 'MyEditor',
  components: {
    'editor': Editor
  },
  data() {
    return {
      content:''
    }
  }
}
</script>

This component is imported asyncly as following in a parent component :
FileName : index.vue

export default {
  name: 'MyParentCustomComponent',
  components: {
    'document-editor':  () => import('./myEditor')
  }
}

Then, I have the following error in the console

vue.esm.js:629 [Vue warn]: Failed to resolve async component: function documentEditor() {
      return __webpack_require__.e(/*! import() */ 15).then(__webpack_require__.bind(null, /*! ./MyEditor*/ "./src/components/attachment/MyEditor.vue"));
    }
Reason: TypeError: Cannot assign to read only property 'forEach' of object '#<Object>'

If I remove the async loading, it works like a charm ! But you loose the benefit of chunking...

ERROR Failed to compile with 2 errors

Version

2.0.0

Test Environment

macOS Mojave 10.14.6(18G3020)

Current Behavior

sunggillee@sunggilui-MacBook-Pro:~/Dev/Git/ggomjirak/Refrigerator/admin-server/frontend(feature/noticeโšก) ยป npm run build

> fish-admin@0.1.0 build /Users/sunggillee/Dev/Git/ggomjirak/Refrigerator/admin-server/frontend
> vue-cli-service build


โ ‡  Building for production...

 ERROR  Failed to compile with 2 errors                                                                                                                                      14:10:45

These dependencies were not found:

* tui-editor/dist/tui-editor-contents.css in ./node_modules/cache-loader/dist/cjs.js??ref--12-0!./node_modules/thread-loader/dist/cjs.js!./node_modules/babel-loader/lib!./node_modules/vuetify-loader/lib/loader.js??ref--18-0!./node_modules/cache-loader/dist/cjs.js??ref--0-0!./node_modules/vue-loader/lib??vue-loader-options!./src/views/notice/Notice.vue?vue&type=script&lang=js&
* tui-editor/dist/tui-editor.css in ./node_modules/cache-loader/dist/cjs.js??ref--12-0!./node_modules/thread-loader/dist/cjs.js!./node_modules/babel-loader/lib!./node_modules/vuetify-loader/lib/loader.js??ref--18-0!./node_modules/cache-loader/dist/cjs.js??ref--0-0!./node_modules/vue-loader/lib??vue-loader-options!./src/views/notice/Notice.vue?vue&type=script&lang=js&

To install them, you can run: npm install --save tui-editor/dist/tui-editor-contents.css tui-editor/dist/tui-editor.css
 ERROR  Build failed with errors.
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! fish-admin@0.1.0 build: `vue-cli-service build`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the fish-admin@0.1.0 build script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.

npm ERR! A complete log of this run can be found in:
npm ERR!     /Users/sunggillee/.npm/_logs/2020-03-19T05_10_45_490Z-debug.log

Expected Behavior

build success.

How can I change the link target to "_blank" in the viewer?

Version

1.1.1

Test Environment

Chrome, Mac

Current Behavior

The target of "a" tag in the TUI viewer is set to "_self".

<a href="">link</a>

Expected Behavior

I want to change the target of a tag in the viewer to "_blank".
But I could not find a way.

<a href="" target="_blank">link</a>

The code solved the problem.
https://nhn.github.io/tui.editor/api/latest/editor.js.html#line851
nhn/tui.editor#288

options: {
    linkAttribute: {
        target: '_blank',
        contenteditable: 'false',
        rel: 'noopener noreferrer'
    }
}

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.