当前位置: 首页>>代码示例>>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;未经允许,请勿转载。