How to use tui-code-snippet - 10 common examples

To help you get started, weโ€™ve selected a few tui-code-snippet examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github nhn / tui.calendar / test / app / common / vlayout.spec.js View on Github external
it('resize at 1 splitter between 2 panels.', function() {
            inst.addPanels([
                {height: 100}, // 100,  100
                {isSplitter: true}, //
                {height: 100} // 100,  205
            ], inst.container);
            spyOn(util, 'forEach');
            inst._resize(inst.panels[1], 100, 110);

            // The first panel increased by 10, and the second panel decreased by 10)
            allArgs = util.pluck(util.forEach.calls.argsFor(0)[0], 1);

            expect(allArgs).toEqual([110, 90]);
        });
github nhn / tui.editor / bower_components / tui-editor / src / js / extensions / chart / chart.js View on Github external
function parseCode2DataAndOptions(code, callback) {
  code = trimKeepingTabs(code);
  const [firstCode, secondCode] = code.split(/\n{2,}/);

  // try to parse first code block as `options`
  let options = parseCode2ChartOption(firstCode);
  const url = options && options.editorChart && options.editorChart.url;

  // if first code block is `options` and has `url` option, fetch data from url
  let dataAndOptions;
  if (util.isString(url)) {
    // url option provided
    // fetch data from url
    const success = dataCode => {
      dataAndOptions = _parseCode2DataAndOptions(dataCode, firstCode);
      callback(dataAndOptions);
    };
    const fail = () => callback(null);

    $.get(url).done(success).fail(fail);
  } else {
    // else first block is `data`
    dataAndOptions = _parseCode2DataAndOptions(firstCode, secondCode);
    callback(dataAndOptions);
  }
}
github nhn / tui.editor / src / js / extensions / chart / chart.js View on Github external
function parseCode2DataAndOptions(code, callback) {
  code = trimKeepingTabs(code);
  const [firstCode, secondCode] = code.split(/\n{2,}/);

  // try to parse first code block as `options`
  let options = parseCode2ChartOption(firstCode);
  const url = options && options.editorChart && options.editorChart.url;

  // if first code block is `options` and has `url` option, fetch data from url
  let dataAndOptions;
  if (util.isString(url)) {
    // url option provided
    // fetch data from url
    const success = dataCode => {
      dataAndOptions = _parseCode2DataAndOptions(dataCode, firstCode);
      callback(dataAndOptions);
    };
    const fail = () => callback(null);

    $.get(url).done(success).fail(fail);
  } else {
    // else first block is `data`
    dataAndOptions = _parseCode2DataAndOptions(firstCode, secondCode);
    callback(dataAndOptions);
  }
}
github nhn / tui.editor / src / js / editor.js View on Github external
useCommandShortcut: this.options.useCommandShortcut
    });

    if (this.options.customConvertor) {
      // eslint-disable-next-line new-cap
      this.convertor = new this.options.customConvertor(this.eventManager);
    } else {
      this.convertor = new Convertor(this.eventManager);
    }

    if (this.options.useDefaultHTMLSanitizer) {
      this.convertor.initHtmlSanitizer();
    }

    if (this.options.hooks) {
      util.forEach(this.options.hooks, (fn, key) => this.addHook(key, fn));
    }

    if (this.options.events) {
      util.forEach(this.options.events, (fn, key) => this.on(key, fn));
    }

    this.layout = new Layout(options, this.eventManager);

    this.i18n = i18n;
    this.i18n.setCode(this.options.language);

    this.setUI(this.options.UI || new DefaultUI(this));

    this.mdEditor = MarkdownEditor.factory(this.layout.getMdEditorContainerEl(), this.eventManager, this.options);
    this.preview = new MarkdownPreview(
      this.layout.getPreviewEl(),
github nhn / tui.editor / src / js / editor.js View on Github external
// eslint-disable-next-line new-cap
      this.convertor = new this.options.customConvertor(this.eventManager);
    } else {
      this.convertor = new Convertor(this.eventManager);
    }

    if (this.options.useDefaultHTMLSanitizer) {
      this.convertor.initHtmlSanitizer();
    }

    if (this.options.hooks) {
      util.forEach(this.options.hooks, (fn, key) => this.addHook(key, fn));
    }

    if (this.options.events) {
      util.forEach(this.options.events, (fn, key) => this.on(key, fn));
    }

    this.layout = new Layout(options, this.eventManager);

    this.i18n = i18n;
    this.i18n.setCode(this.options.language);

    this.setUI(this.options.UI || new DefaultUI(this));

    this.mdEditor = MarkdownEditor.factory(this.layout.getMdEditorContainerEl(), this.eventManager, this.options);
    this.preview = new MarkdownPreview(
      this.layout.getPreviewEl(),
      this.eventManager,
      this.convertor,
      false,
      this.options.previewDelayTime);
github nhn / tui.image-editor / src / js / ui.js View on Github external
_makeSubMenu() {
        snippet.forEach(this.options.menu, menuName => {
            const SubComponentClass = SUB_UI_COMPONENT[menuName.replace(/^[a-z]/, $0 => $0.toUpperCase())];

            // make menu element
            this._makeMenuElement(menuName);

            // menu btn element
            this._els[menuName] = this._menuElement.querySelector(`#tie-btn-${menuName}`);

            // submenu ui instance
            this[menuName] = new SubComponentClass(this._subMenuElement, {
                locale: this._locale,
                iconStyle: this.theme.getStyle('submenu.icon'),
                menuBarPosition: this.options.menuBarPosition,
                usageStatistics: this.options.usageStatistics
            });
        });
github nhn / tui.chart / src / js / plugins / raphaelLineTypeBase.js View on Github external
_hideDot(dot, groupIndex, opacity) {
        const prev = this._prevDotAttributes[groupIndex];
        let {outDotStyle} = this;

        // if prev data exists, use prev.r
        // there is dot disappearing issue, when hideDot
        if (prev && !snippet.isUndefined(opacity)) {
            outDotStyle = snippet.extend({
                'r': prev.r,
                'stroke': prev.stroke,
                'fill': prev.fill,
                'stroke-opacity': prev['stroke-opacity'],
                'stroke-width': prev['stroke-width'],
                'fill-opacity': prev['fill-opacity']
            });
        }

        dot.attr(outDotStyle);
        if (dot.node) {
            dot.node.setAttribute('filter', '');
        }

        this.resetSeriesOrder(groupIndex);
    }
github nhn / tui.editor / bower_components / tui-editor / src / js / extensions / chart / chart.js View on Github external
function setDefaultOptions(options, chartContainer) {
  options = util.extend({
    editorChart: {},
    chart: {},
    chartExportMenu: {}
  }, options);

  let {width, height} = options.chart;
  const isWidthUndefined = util.isUndefined(width);
  const isHeightUndefined = util.isUndefined(height);
  if (isWidthUndefined || isHeightUndefined) {
    // if no width or height specified, set width and height to container width
    const {
      width: containerWidth
    } = chartContainer.getBoundingClientRect();
    options.chart.width = isWidthUndefined ? containerWidth : width;
    options.chart.height = isHeightUndefined ? containerWidth : height;
  }

  options.editorChart.type = options.editorChart.type ? `${options.editorChart.type}Chart` : 'columnChart';
  options.chartExportMenu.visible = options.chartExportMenu.visible || false;

  return options;
}
github nhn / tui.calendar / src / js / view / month / weekdayInMonth.js View on Github external
WeekdayInMonth.prototype._getRenderLimitIndex = function(panelHeight) {
    var opt = this.options;
    var containerHeight = panelHeight || this.getViewBound().height;
    var gridHeaderHeight = util.pick(opt, 'grid', 'header', 'height') || 0;
    var gridFooterHeight = util.pick(opt, 'grid', 'footer', 'height') || 0;
    var visibleScheduleCount = opt.visibleScheduleCount || 0;
    var count;

    containerHeight -= (gridHeaderHeight + gridFooterHeight);

    count = mfloor(containerHeight / (opt.scheduleHeight + opt.scheduleGutter));

    if (!visibleScheduleCount) {
        visibleScheduleCount = count;
    }

    return mmin(count, visibleScheduleCount); // subtraction for '+n' label block
};
github nhn / tui.calendar / src / js / view / week / week.js View on Github external
this.children.each(function(childView) {
        var matrices;
        var viewName = util.pick(childView.options, 'viewName');
        childView.render(viewModel);

        if (viewName) {
            matrices = viewModel.schedulesInDateRange[viewName]; // DayGrid limits schedule count by visibleScheduleCount after rendering it.

            if (util.isArray(matrices)) {
                self._invokeAfterRenderSchedule(matrices);
            } else {
                util.forEach(matrices, function(matricesOfDay) {
                    self._invokeAfterRenderSchedule(matricesOfDay);
                });
            }
        }
    });