Skip to content

Latest commit

 

History

History
111 lines (88 loc) · 2.49 KB

v2.0-migration-guide.md

File metadata and controls

111 lines (88 loc) · 2.49 KB

TOAST UI CodeSnippet v2.0 Migration Guide

Install

The v2.0 should be installed using the npm command. CodeSnippet does not support bower and CDN anymore.

$ npm install --save tui-code-snippet

Usage

The v2.0 supports importing a single function, so you can import only functions that you need.

var func = require('tui-code-snippet/<folder>/<function>');

// for example,
var inArray = require('tui-code-snippet/array/inArray');
var customEvents = require('tui-code-snippet/customEvents/customEvents');

The folder structure can be found here.

Bundle

Since v2.0, it does not provide bundle files. If you need a bundle file, you should make it yourself using the command npm run bundle.

$ git clone https://github.com/nhn/tui.code-snippet.git
$ cd tui.code-snippet
$ npm install
$ npm run bundle

After executing npm run bundle, the uncompressed(tui-code-snippet.js) and minified(tui-code-snippet.min.js) files are created in the dist folder.

tui.code-snippet/
├─ dist
│  ├─ tui-code-snippet.js
│  ├─ tui-code-snippet.min.js
├─ ...

The entry file is index.js. When you do not modify index.js, all methods of tui.code-snippet will be included in the bundle file. To bundle the methods you need, remove other methods in the entry file.

// index.js
// for example, you need inArray, forEach and isArray methods only.
require('./array/inArray');
require('./collection/forEach');
require('./type/isArray');

Changes

Several functions are added and deprecated in v2.0.

Added functions

The v2.0 is combined with tui.dom, so domEvent and domUtil functions are added.

  • domEvent
    • on
    • once
    • off
    • getMouseButton
    • getMousePosition
    • getTarget
    • stopPropagation
    • preventDefault
  • domUtil
    • css
    • getClass
    • hasClass
    • addClass
    • toggleClass
    • removeClass
    • setData
    • getData
    • removeData
    • removeElement
    • matches
    • closest
    • disableTextSelection
    • enableTextSelection

Deprecated functions

From v2.0, the below functions are not provided anymore.

  • map
  • reduce
  • filter
  • defineModule
  • defineNamespace
  • ExMap
  • bind
  • HashMap
  • Map
  • stamp
  • hasStamp
  • resetLastId
  • keys
  • compareJSON
  • isSameObject
  • hasEncodableString
  • getDuplicatedChar
  • timestamp
  • Popup