vue toast_TOAST Vue的UI编辑器

vue toast

toast-ui.vue编辑器 (toast-ui.vue-editor)

This is Vue component wrapping TOAST UI Editor.

这是包装TOAST UI Editor的Vue组件。

tui.editor

收集有关开源使用的统计信息 (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.

TOAST UI Editor的Vue Wrapper应用Google Analytics(分析)(GA)来收集有关开源使用情况的统计信息,以便确定TOAST UI Editor在全世界的使用范围。 它也是确定项目未来走向的重要指标。 要收集location.hostname(例如>“ ui.toast.com”),其唯一目的只是测量使用情况统计信息。要禁用GA,请在声明Vue Wrapper usageStatistics时使用以下usageStatistics选项。

var options = {
    ...
    usageStatistics: false
}

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

或者,包括include tui-code-snippet.js ( v1.4.0更高版本 ),然后立即编写以下选项:

tui.usageStatistics = false;

💾安装 (💾 Install)

使用npm (Using npm)

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

🔨用法 (🔨 Usage)

If you want to more details, see Tutorials 👀

如果您想了解更多详细信息,请参见教程 👀

加载 (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.

您可以将Toast UI Editor for Vue用作模块格式或名称空间。 您也可以使用单一文件组件(Vue的SFC)。 使用模块格式和SFC时,应在脚本中加载tui-editor.csstui-editor-contents.csscodemirror.css

  • Using Ecmascript module

    使用Ecmascript模块

    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

    使用Commonjs模块

    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.

首先在模板中实现<editor/>

<template>
    <editor/>
</template>

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

然后添加Editorcomponents在组件或VUE实例是这样的:

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
    }
});

使用v模型 (Using v-model)

If you use v-model, you have to declare a data for binding.

如果使用v-model,则必须声明要绑定的data

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

在下面的示例中, editorText绑定到编辑器的文本。

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

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

道具 (Props)

NameTypeDefaultDescription
valueString''This prop can change content of the editor. If you using v-model, don't use it.
optionsObjectfollowing defaultOptionsOptions of tui.editor. This is for initailize tui.editor.
heightString'300px'This prop can control the height of the editor.
previewStyleString'tab'This prop can change preview style of the editor. (tab or vertical)
modeString'markdown'This prop can change mode of the editor. (markdownor wysiwyg)
htmlString-If you want change content of the editor using html format, use this prop.
visibleBooleantrueThis prop can control visible of the eiditor.
名称 类型 默认 描述
'' 该道具可以改变编辑器的内容。 如果您使用v-model ,请不要使用它
选项 目的 以下defaultOptions tui.editor的选项。 这是为了使tui.editor无效。
高度 '300px' 该道具可以控制编辑器的高度。
PreviewStyle '标签' 该道具可以改变编辑器的预览风格。 ( tabvertical )
模式 '降价' 该道具可以改变编辑器的模式。 ( markdownwysiwyg )
html -- 如果要使用html格式更改编辑器的内容,请使用此道具。
可见 布尔型 真正 该道具可以控制看守者。
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'
    ]
};

事件 (Event)

  • load : It would be emitted when editor fully load

    load:编辑器完全加载时会发出

  • change : It would be emitted when content changed

    change:内容更改时会发出

  • stateChange : It would be emitted when format change by cursor position

    stateChange:通过光标位置更改格式时将发出

  • focus : It would be emitted when editor get focus

    focus:当编辑器获得焦点时将发出

  • blur : It would be emitted when editor loose focus

    模糊:当编辑器失去焦点时会发出

方法 (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.

如果要更多地操纵编辑器,则可以使用invoke方法来调用tui.editor方法。 有关method的更多信息,请参见tui.editor的method

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

首先,您需要分配<editor/> ref属性,然后可以通过this.$refs使用invoke方法,如下所示:

<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>

🔧拉取步骤 (🔧 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.

TOAST UI产品是开源的,因此您可以在解决问题后创建提取请求(PR)。 运行npm脚本并通过以下过程开发自己。

建立 (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.

develop分支develop到您的个人存储库中。 克隆到本地计算机。 安装节点模块。 在开始开发之前,您应该检查是否有任何错误。

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

翻译自: https://vuejsexamples.com/toast-ui-editor-for-vue/

vue toast

  • 0
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值