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


TypeScript Tools.explode函數代碼示例

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


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

示例1:

const getFontSizeClasses = (editor: Editor): string[] => Tools.explode(editor.getParam('font_size_classes', ''));
開發者ID:danielpunkass,項目名稱:tinymce,代碼行數:1,代碼來源:Settings.ts

示例2: tabHandler

  function tabHandler(e) {
    let x, el, v, i;

    if (e.keyCode !== VK.TAB || e.ctrlKey || e.altKey || e.metaKey || e.isDefaultPrevented()) {
      return;
    }

    function find(direction) {
      el = DOM.select(':input:enabled,*[tabindex]:not(iframe)');

      function canSelectRecursive(e) {
        return e.nodeName === 'BODY' || (e.type !== 'hidden' &&
          e.style.display !== 'none' &&
          e.style.visibility !== 'hidden' && canSelectRecursive(e.parentNode));
      }

      function canSelect(el) {
        return /INPUT|TEXTAREA|BUTTON/.test(el.tagName) && EditorManager.get(e.id) && el.tabIndex !== -1 && canSelectRecursive(el);
      }

      Tools.each(el, function (e, i) {
        if (e.id === editor.id) {
          x = i;
          return false;
        }
      });
      if (direction > 0) {
        for (i = x + 1; i < el.length; i++) {
          if (canSelect(el[i])) {
            return el[i];
          }
        }
      } else {
        for (i = x - 1; i >= 0; i--) {
          if (canSelect(el[i])) {
            return el[i];
          }
        }
      }

      return null;
    }

    v = Tools.explode(Settings.getTabFocus(editor));

    if (v.length === 1) {
      v[1] = v[0];
      v[0] = ':prev';
    }

    // Find element to focus
    if (e.shiftKey) {
      if (v[0] === ':prev') {
        el = find(-1);
      } else {
        el = DOM.get(v[0]);
      }
    } else {
      if (v[1] === ':next') {
        el = find(1);
      } else {
        el = DOM.get(v[1]);
      }
    }

    if (el) {
      const focusEditor = EditorManager.get(el.id || el.name);

      if (el.id && focusEditor) {
        focusEditor.focus();
      } else {
        Delay.setTimeout(function () {
          if (!Env.webkit) {
            window.focus();
          }

          el.focus();
        }, 10);
      }

      e.preventDefault();
    }
  }
開發者ID:danielpunkass,項目名稱:tinymce,代碼行數:83,代碼來源:Keyboard.ts

示例3: function

const overrideFormats = function (editor) {
  const alignElements = 'p,h1,h2,h3,h4,h5,h6,td,th,div,ul,ol,li,table,img',
    fontSizes = Tools.explode(editor.settings.font_size_style_values),
    schema = editor.schema;

  // Override some internal formats to produce legacy elements and attributes
  editor.formatter.register({
    // Change alignment formats to use the deprecated align attribute
    alignleft: { selector: alignElements, attributes: { align: 'left' } },
    aligncenter: { selector: alignElements, attributes: { align: 'center' } },
    alignright: { selector: alignElements, attributes: { align: 'right' } },
    alignjustify: { selector: alignElements, attributes: { align: 'justify' } },

    // Change the basic formatting elements to use deprecated element types
    bold: [
      { inline: 'b', remove: 'all' },
      { inline: 'strong', remove: 'all' },
      { inline: 'span', styles: { fontWeight: 'bold' } }
    ],
    italic: [
      { inline: 'i', remove: 'all' },
      { inline: 'em', remove: 'all' },
      { inline: 'span', styles: { fontStyle: 'italic' } }
    ],
    underline: [
      { inline: 'u', remove: 'all' },
      { inline: 'span', styles: { textDecoration: 'underline' }, exact: true }
    ],
    strikethrough: [
      { inline: 'strike', remove: 'all' },
      { inline: 'span', styles: { textDecoration: 'line-through' }, exact: true }
    ],

    // Change font size and font family to use the deprecated font element
    fontname: { inline: 'font', attributes: { face: '%value' } },
    fontsize: {
      inline: 'font',
      attributes: {
        size (vars) {
          return Tools.inArray(fontSizes, vars.value) + 1;
        }
      }
    },

    // Setup font elements for colors as well
    forecolor: { inline: 'font', attributes: { color: '%value' } },
    hilitecolor: { inline: 'font', styles: { backgroundColor: '%value' } }
  });

  // Check that deprecated elements are allowed if not add them
  Tools.each('b,i,u,strike'.split(','), function (name) {
    schema.addValidElements(name + '[*]');
  });

  // Add font element if it's missing
  if (!schema.getElementRule('font')) {
    schema.addValidElements('font[face|size|color|style]');
  }

  // Add the missing and depreacted align attribute for the serialization engine
  Tools.each(alignElements.split(','), function (name) {
    const rule = schema.getElementRule(name);

    if (rule) {
      if (!rule.attributes.align) {
        rule.attributes.align = {};
        rule.attributesOrder.push('align');
      }
    }
  });
};
開發者ID:danielpunkass,項目名稱:tinymce,代碼行數:71,代碼來源:Formats.ts


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