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


TypeScript Obj.each方法代碼示例

本文整理匯總了TypeScript中@ephox/katamari.Obj.each方法的典型用法代碼示例。如果您正苦於以下問題:TypeScript Obj.each方法的具體用法?TypeScript Obj.each怎麽用?TypeScript Obj.each使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在@ephox/katamari.Obj的用法示例。


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

示例1: getDimensions

export const resize = (editor: Editor, deltas, resizeType: ResizeTypes) => {
  const container = Element.fromDom(editor.getContainer());

  const dimensions = getDimensions(editor, deltas, resizeType, Height.get(container), Width.get(container));
  Obj.each(dimensions, (val, dim) => Css.set(container, dim, Utils.numToPx(val)));
  Events.fireResizeEditor(editor);
};
開發者ID:tinymce,項目名稱:tinymce,代碼行數:7,代碼來源:Resize.ts

示例2: function

UnitTest.test('tinymce.plugins.paste.browser.NewlinesTest', function () {
  Theme();
  PastePlugin();

  // testing Newlines.isPlainText()
  const textCases = [
    {
      label: 'Basic Chrome markup (including span-wrapped tab)',
      content: '<div><span style="white-space:pre">  </span>a</div><div><br></div><div>b</div>',
      isText: true
    },
    {
      label: 'Case shouldn\'t matter',
      content: '<DIV>a</DIV><DIV><BR></DIV>',
      isText: true
    },
    {
      label: 'Support all BR types',
      content: '<br><br />',
      isText: true
    },
    {
      label: 'Basic IE markup',
      content: '<p>a</p><p><br></p><p>b</p>',
      isText: true
    },
    {
      label: 'White-space wrapper (Chrome)',
      content: '<div><span style="white-space: pre;"> </span>a</div>',
      isText: true
    },
    {
      label: 'White-space wrapper (Chrome) with additional styles',
      content: '<div><span style="white-space: pre; color: red;"> </span>a</div>',
      isText: false
    },
    {
      label: 'Allowed tag but with attributes qualifies string as not a plain text',
      content: '<br data-mce-bogus="all" />',
      isText: false
    }
  ];

  // only DIV,P,BR and SPAN[style="white-space:pre"] tags are allowed in "plain text" string
  Arr.each('a,abbr,address,article,aside,audio,b,bdi,bdo,blockquote,button,cite,code,del,details,dfn,dl,em,embed,fieldset,figure,footer,form,h1,h2,h3,h4,h5,h6,header,hgroup,hr,i,ins,label,menu,nav,noscript,object,ol,pre,q,s,script,section,select,small,strong,style,sub,sup,svg,table,textarea,time,u,ul,var,video,wbr'.split(','),
    function (tag) {
      const content = '<p>a</p><' + tag + '>b</' + tag + '><p>c<br>d</p>';
      textCases.push({
        label: tag.toUpperCase() + ' tag should qualify content (' + content + ') as not a plain text',
        content,
        isText: false
      });
    }
  );

  Obj.each(textCases, function (c) {
    Assertions.assertEq(c.label || 'Asserting: ' + c.content, c.isText, Newlines.isPlainText(c.content));
  });
});
開發者ID:abstask,項目名稱:tinymce,代碼行數:59,代碼來源:NewlinesTest.ts

示例3: PasteBin

 Chain.op(function (editor: any) {
   const pasteBin = PasteBin(editor);
   Obj.each(cases, function (c, i) {
     getPasteBinParent(editor).appendChild(editor.dom.createFragment(c.content));
     Assertions.assertEq(c.label || 'Asserting paste bin case ' + i, c.result, pasteBin.getHtml());
     pasteBin.remove();
   });
 }),
開發者ID:tinymce,項目名稱:tinymce,代碼行數:8,代碼來源:PasteBinTest.ts

示例4: PasteBin

 return Chain.op(function (editor) {
   const pasteBin = PasteBin(editor);
   Obj.each(cases, function (c, i) {
     editor.getBody().innerHTML = c.content;
     Assertions.assertEq(c.label || 'Asserting paste bin case ' + i, c.result, pasteBin.getHtml());
     pasteBin.remove();
   });
 });
開發者ID:aha-app,項目名稱:tinymce-word-paste-filter,代碼行數:8,代碼來源:PasteBinTest.ts

示例5:

 Arr.each(keys, (key) => {
   Obj.each(items, (itemValue, itemKey, _) => {
     const comparisonValue = baseData[key];
     if (comparisonValue !== '' && key === itemKey) {
       if (comparisonValue !== itemValue) {
         baseData[key] = '';
       }
     }
   });
 });
開發者ID:tinymce,項目名稱:tinymce,代碼行數:10,代碼來源:Helpers.ts

示例6: assertMarker

const sAssertGetAll = (editor: Editor, expected: Record<string, number>, name: string) => Step.sync(() => {
  const annotations = editor.annotator.getAll(name);
  const keys = Obj.keys(annotations);
  const sortedKeys = Arr.sort(keys);
  const expectedKeys = Arr.sort(Obj.keys(expected));
  Assertions.assertEq('Checking keys of getAll response', expectedKeys, sortedKeys);
  Obj.each(annotations, (markers, uid) => {
    Assertions.assertEq('Checking number of markers for uid', expected[uid], markers.length);
    assertMarker(editor, { uid, name }, markers);
  });
});
開發者ID:tinymce,項目名稱:tinymce,代碼行數:11,代碼來源:AnnotationAsserts.ts

示例7: function

  const cAssertClipboardPaste = function (expected, data) {
    const chains = [];

    Obj.each(data, function (data, label) {
      chains.push(
        cFireFakePasteEvent(data),
        Chain.control(
          cAssertEditorContent(label, expected),
          Guard.tryUntil('Wait for paste to succeed.', 100, 1000)
        ),
        cClearEditor()
      );
    });

    return Chain.fromChains(chains);
  };
開發者ID:aha-app,項目名稱:tinymce-word-paste-filter,代碼行數:16,代碼來源:PlainTextPasteTest.ts

示例8: getAllOxide

const initIcons = (editor: Editor) => {
  const iconPackName: string = Tools.trim(editor.settings.icons);
  const currentIcons = editor.ui.registry.getAll().icons;

  const defaultIcons = getAllOxide();
  const loadIcons = {
    ...defaultIcons,
    ...IconManager.get(iconPackName).icons
  };

  Obj.each(loadIcons, (svgData, icon) => {
    // Don't override an icon registered manually
    if (!Obj.has(currentIcons, icon)) {
      editor.ui.registry.addIcon(icon, svgData);
    }
  });
};
開發者ID:tinymce,項目名稱:tinymce,代碼行數:17,代碼來源:Init.ts

示例9:

 return Chain.op<InlinePatternMatch[]>((actualMatches) => {
   Assertions.assertEq('Pattern count does not match', expectedMatches.length, actualMatches.length);
   for (let i = 0; i < expectedMatches.length; i++) {
     const expected = expectedMatches[i];
     const actual = actualMatches[i];
     const pattern = actual.pattern;
     Obj.each(expected.pattern, (value, key) => {
       if (Obj.has<any, string>(pattern, key)) {
         Assertions.assertEq('Pattern ' + (i + 1) + ' property `' + key + '` is not equal', value, pattern[key]);
       } else {
         assert.fail('Pattern ' + (i + 1) + ' property `' + key + '` is missing');
       }
     });
     // prepend a 0 because we always add a root node
     Assertions.assertEq('start path does not match', [0].concat(expected.start), actual.range.start);
     Assertions.assertEq('end path does not match', [0].concat(expected.end), actual.range.end);
   }
 });
開發者ID:tinymce,項目名稱:tinymce,代碼行數:18,代碼來源:FindInlinePatternTest.ts

示例10: callback

const updateAndFireChangeCallbacks = (editor: Editor, elm: Element, currentFormats: Cell<FormatCallbacks>, formatChangeData: RegisteredFormats) => {
  const formatsList = Obj.keys(currentFormats.get());
  const newFormats: FormatCallbacks = { };
  const matchedFormats: FormatCallbacks = { };

  // Ignore bogus nodes like the <a> tag created by moveStart()
  const parents = Arr.filter(FormatUtils.getParents(editor.dom, elm), (node) => {
    return node.nodeType === 1 && !node.getAttribute('data-mce-bogus');
  });

  // Check for new formats
  Obj.each(formatChangeData, (data: FormatData, format: string) => {
    Tools.each(parents, (node: Node) => {
      if (editor.formatter.matchNode(node, format, {}, data.similar)) {
        if (formatsList.indexOf(format) === -1) {
          // Execute callbacks
          Arr.each(data.callbacks, (callback: FormatChangeCallback) => {
            callback(true, { node, format, parents });
          });

          newFormats[format] = data.callbacks;
        }

        matchedFormats[format] = data.callbacks;
        return false;
      }

      if (MatchFormat.matchesUnInheritedFormatSelector(editor, node, format)) {
        return false;
      }
    });
  });

  // Check if current formats still match
  const remainingFormats = filterRemainingFormats(currentFormats.get(), matchedFormats, elm, parents);

  // Update the current formats
  currentFormats.set({
    ...newFormats,
    ...remainingFormats
  });
};
開發者ID:tinymce,項目名稱:tinymce,代碼行數:42,代碼來源:FormatChanged.ts


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