當前位置: 首頁>>代碼示例>>TypeScript>>正文


TypeScript Tools.extend函數代碼示例

本文整理匯總了TypeScript中tinymce/core/api/util/Tools.extend函數的典型用法代碼示例。如果您正苦於以下問題:TypeScript extend函數的具體用法?TypeScript extend怎麽用?TypeScript extend使用的例子?那麽, 這裏精選的函數代碼示例或許可以為您提供幫助。


在下文中一共展示了extend函數的10個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的TypeScript代碼示例。

示例1: function

const applyDataToElement = function (editor, tableElm, data) {
  const dom = editor.dom;
  const attrs: any = {};
  let styles: any = {};

  attrs.class = data.class;

  styles.height = Util.addSizeSuffix(data.height);

  if (dom.getAttrib(tableElm, 'width') && !shouldStyleWithCss(editor)) {
    attrs.width = Util.removePxSuffix(data.width);
  } else {
    styles.width = Util.addSizeSuffix(data.width);
  }

  if (shouldStyleWithCss(editor)) {
    styles['border-width'] = Util.addSizeSuffix(data.border);
    styles['border-spacing'] = Util.addSizeSuffix(data.cellspacing);

    Tools.extend(attrs, {
      'data-mce-border-color': data.borderColor,
      'data-mce-cell-padding': data.cellpadding,
      'data-mce-border': data.border
    });
  } else {
    Tools.extend(attrs, {
      border: data.border,
      cellpadding: data.cellpadding,
      cellspacing: data.cellspacing
    });
  }

  // TODO: this has to be reworked somehow, for example by introducing dedicated option, which
  // will control whether child TD/THs should be processed or not
  if (shouldStyleWithCss(editor)) {
    if (tableElm.children) {
      for (let i = 0; i < tableElm.children.length; i++) {
        styleTDTH(dom, tableElm.children[i], {
          'border-width': Util.addSizeSuffix(data.border),
          'border-color': data.borderColor,
          'padding': Util.addSizeSuffix(data.cellpadding)
        });
      }
    }
  }

  if (data.style) {
    // merge the styles from Advanced tab on top
    Tools.extend(styles, dom.parseStyle(data.style));
  } else {
    // ... otherwise take styles from original elm and update them
    styles = Tools.extend({}, dom.parseStyle(dom.getAttrib(tableElm, 'style')), styles);
  }

  attrs.style = dom.serializeStyle(styles);
  dom.setAttribs(tableElm, attrs);
};
開發者ID:abstask,項目名稱:tinymce,代碼行數:57,代碼來源:TableDialog.ts

示例2: function

const extractDataFromElement = function (editor: Editor, elm: HTMLElement) {
  const dom = editor.dom;
  const data: FormData = {
    width: dom.getStyle(elm, 'width') || dom.getAttrib(elm, 'width'),
    height: dom.getStyle(elm, 'height') || dom.getAttrib(elm, 'height'),
    scope: dom.getAttrib(elm, 'scope'),
    class: dom.getAttrib(elm, 'class'),
    type: elm.nodeName.toLowerCase(),
    style: '',
    align: '',
    valign: ''
  };

  Tools.each('left center right'.split(' '), function (name: string) {
    if (editor.formatter.matchNode(elm, 'align' + name)) {
      data.align = name;
    }
  });

  Tools.each('top middle bottom'.split(' '), function (name: string) {
    if (editor.formatter.matchNode(elm, 'valign' + name)) {
      data.valign = name;
    }
  });

  if (hasAdvancedCellTab(editor)) {
    Tools.extend(data, Helpers.extractAdvancedStyles(dom, elm));
  }

  return data;
};
開發者ID:danielpunkass,項目名稱:tinymce,代碼行數:31,代碼來源:CellDialog.ts

示例3: FormItem

    items.each(function (ctrl) {
      let formItem;
      const label = ctrl.settings.label;

      if (label) {
        formItem = new FormItem(Tools.extend({
          items: {
            type: 'label',
            id: ctrl._id + '-l',
            text: label,
            flex: 0,
            forId: ctrl._id,
            disabled: ctrl.disabled()
          }
        }, self.settings.formItemDefaults));

        formItem.type = 'formitem';
        ctrl.aria('labelledby', ctrl._id + '-l');

        if (typeof ctrl.settings.flex === 'undefined') {
          ctrl.settings.flex = 1;
        }

        self.replace(ctrl, formItem);
        formItem.add(ctrl);
      }
    });
開發者ID:danielpunkass,項目名稱:tinymce,代碼行數:27,代碼來源:Form.ts

示例4: function

  suite.test('Parse script elements', function () {
    let counter, parser;

    counter = createCounter(writer);
    parser = SaxParser(counter, schema);
    writer.reset();
    parser.parse('text1<em><script>// <b>tag</b></s' + 'cript>text2</em>');
    LegacyUnit.equal(writer.getContent(), 'text1<em><script>// <b>tag</b></s' + 'cript>text2</em>', 'Parse script element.');
    LegacyUnit.deepEqual(counter.counts, { start: 2, end: 2, text: 3 }, 'Parse script element counts.');

    counter = createCounter(writer);
    parser = SaxParser(counter, schema);
    writer.reset();
    parser.parse('text1<em><script id="id">// <b>tag</b></s' + 'cript>text2</em>');
    LegacyUnit.equal(
      writer.getContent(),
      'text1<em><script id="id">// <b>tag</b></s' + 'cript>text2</em>',
      'Parse script element with attributes.'
    );
    LegacyUnit.deepEqual(counter.counts, { start: 2, end: 2, text: 3 }, 'Parse script element with attributes counts.');

    counter = createCounter(writer);
    parser = SaxParser(counter, schema);
    writer.reset();
    parser.parse('text1<em><script></s' + 'cript>text2</em>');
    LegacyUnit.equal(writer.getContent(), 'text1<em><script></s' + 'cript>text2</em>', 'Parse empty script element.');
    LegacyUnit.deepEqual(counter.counts, { text: 2, start: 2, end: 2 }, 'Parse empty script element counts.');

    counter = createCounter(writer);
    parser = SaxParser(Tools.extend({ validate: true }, counter), Schema({ invalid_elements: 'script' }));
    writer.reset();
    parser.parse('text1<em><s' + 'cript>text2</s' + 'cript>text3</em>');
    LegacyUnit.equal(writer.getContent(), 'text1<em>text3</em>', 'Parse invalid script element.');
    LegacyUnit.deepEqual(counter.counts, { text: 2, start: 1, end: 1 }, 'Parse invalid script element (count).');
  });
開發者ID:abstask,項目名稱:tinymce,代碼行數:35,代碼來源:SaxParserTest.ts

示例5: function

const extractDataFromElement = function (editor, elm) {
  const dom = editor.dom;
  const data: any = {
    width: dom.getStyle(elm, 'width') || dom.getAttrib(elm, 'width'),
    height: dom.getStyle(elm, 'height') || dom.getAttrib(elm, 'height'),
    scope: dom.getAttrib(elm, 'scope'),
    class: dom.getAttrib(elm, 'class')
  };

  data.type = elm.nodeName.toLowerCase();

  Tools.each('left center right'.split(' '), function (name) {
    if (editor.formatter.matchNode(elm, 'align' + name)) {
      data.align = name;
    }
  });

  Tools.each('top middle bottom'.split(' '), function (name) {
    if (editor.formatter.matchNode(elm, 'valign' + name)) {
      data.valign = name;
    }
  });

  if (editor.settings.table_cell_advtab !== false) {
    Tools.extend(data, Helpers.extractAdvancedStyles(dom, elm));
  }

  return data;
};
開發者ID:,項目名稱:,代碼行數:29,代碼來源:

示例6: function

 const createPanel = function (settings) {
   return Factory.create(Tools.extend({
     type: 'panel',
     layout: 'absolute',
     width: 200,
     height: 200
   }, settings)).renderTo(viewBlock.get()).reflow();
 };
開發者ID:abstask,項目名稱:tinymce,代碼行數:8,代碼來源:AbsoluteLayoutTest.ts

示例7: function

  const createPanel = function (settings) {
    EventUtils.Event.clean(viewBlock.get());
    viewBlock.update('');

    return Factory.create(Tools.extend({
      type: 'panel'
    }, settings)).renderTo(viewBlock.get()).reflow();
  };
開發者ID:abstask,項目名稱:tinymce,代碼行數:8,代碼來源:PanelTest.ts

示例8: function

  const createButton = function (settings) {
    EventUtils.Event.clean(viewBlock.get());
    viewBlock.update('');

    return Factory.create(Tools.extend({
      type: 'button'
    }, settings)).renderTo(viewBlock.get());
  };
開發者ID:abstask,項目名稱:tinymce,代碼行數:8,代碼來源:ButtonTest.ts

示例9: getUrl

const matchPattern = (url: string): UrlPattern => {
  const pattern = urlPatterns.filter((pattern) => pattern.regex.test(url));

  if (pattern.length > 0) {
    return Tools.extend({}, pattern[0], { url: getUrl(pattern[0], url) });
  } else {
    return null;
  }
};
開發者ID:tinymce,項目名稱:tinymce,代碼行數:9,代碼來源:UrlPatterns.ts

示例10:

    onSubmit: (api) => {
      const nuData = api.getData();

      const headHtml = Parser.dataToHtml(editor, Tools.extend(data, nuData), headState.get());

      headState.set(headHtml);

      api.close();
    }
開發者ID:tinymce,項目名稱:tinymce,代碼行數:9,代碼來源:Dialog.ts


注:本文中的tinymce/core/api/util/Tools.extend函數示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。