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


TypeScript Obj.keys方法代碼示例

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


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

示例1: 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

示例2:

const getMultipleToolbarsSetting = (editor: Editor) => {
  const keys = Obj.keys(editor.settings);
  const toolbarKeys = Arr.filter(keys, (key) => /^toolbar([1-9])$/.test(key));
  const toolbars = Arr.map(toolbarKeys, (key) => editor.getParam(key, false, 'string'));
  const toolbarArray = Arr.filter(toolbars, (toolbar) => typeof toolbar === 'string');
  return toolbarArray.length > 0 ? Option.some(toolbarArray) : Option.none();
};
開發者ID:tinymce,項目名稱:tinymce,代碼行數:7,代碼來源:Settings.ts

示例3: updateCallbacks

  const onNodeChange = Throttler.last(() => {
    const callbackMap = changeCallbacks.get();
    const annotations = Arr.sort(Obj.keys(callbackMap));
    Arr.each(annotations, (name) => {
      updateCallbacks(name, (data) => {
        const prev = data.previous.get();
        identify(editor, Option.some(name)).fold(
          () => {
            if (prev.isSome()) {
              // Changed from something to nothing.
              fireNoAnnotation(name);
              data.previous.set(Option.none());
            }
          },
          ({ uid, name, elements }) => {
            // Changed from a different annotation (or nothing)
            if (! prev.is(uid)) {
              fireCallbacks(name, uid, elements);
              data.previous.set(Option.some(uid));
            }
          }
        );

        return {
          previous: data.previous,
          listeners: data.listeners
        };
      });
    });
  }, 30);
開發者ID:tinymce,項目名稱:tinymce,代碼行數:30,代碼來源:AnnotationChanges.ts

示例4: function

 const setData = function (mime, content) {
   data[mime] = content;
   result.types = Obj.keys(data);
   result.items = Arr.map(result.types, function (type) {
     return createDataTransferItem(type, data[type]);
   });
 };
開發者ID:aha-app,項目名稱:tinymce-word-paste-filter,代碼行數:7,代碼來源:MockDataTransfer.ts

示例5:

  const normalizeCss = (cssText: string) => {
    const css = DOMUtils.DOM.styles.parse(cssText);
    const newCss = {};

    Arr.each(Obj.keys(css).sort(), (key) => {
      newCss[key] = css[key];
    });

    return DOMUtils.DOM.styles.serialize(newCss);
  };
開發者ID:danielpunkass,項目名稱:tinymce,代碼行數:10,代碼來源:ImageDataTest.ts

示例6: function

const init = function (realm, editor) {
  const allFormats = Obj.keys(editor.formatter.get());
  Arr.each(allFormats, function (command) {
    editor.formatter.formatChanged(command, function (state) {
      fireChange(realm, command, state);
    });
  });

  Arr.each([ 'ul', 'ol' ], function (command) {
    editor.selection.selectorChanged(command, function (state, data) {
      fireChange(realm, command, state);
    });
  });
};
開發者ID:danielpunkass,項目名稱:tinymce,代碼行數:14,代碼來源:FormatChangers.ts

示例7: 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

示例8:

const getSharedValues = (data) => {
  // Mutates baseData to return an object that contains only the values
  // that were the same across all objects in data
  const baseData = data[0];
  const comparisonData = data.slice(1);
  const keys = Obj.keys(baseData);

  Arr.each(comparisonData, (items) => {
    Arr.each(keys, (key) => {
      Obj.each(items, (itemValue, itemKey, _) => {
        const comparisonValue = baseData[key];
        if (comparisonValue !== '' && key === itemKey) {
          if (comparisonValue !== itemValue) {
            baseData[key] = '';
          }
        }
      });
    });
  });

  return baseData;
};
開發者ID:tinymce,項目名稱:tinymce,代碼行數:22,代碼來源:Helpers.ts

示例9: doEnrich

    return Arr.map(items, (item) => {
      const keys = Obj.keys(item);
      // If it is a submenu, enrich all the subitems.
      if (Objects.hasKey(item, 'items')) {
        const newItems = doEnrich(item.items);
        return Merger.deepMerge(
          enrichMenu(item),
          {
            getStyleItems: () => newItems
          }
        ) as FormatItem;
      } else if (Objects.hasKey(item, 'format')) {
        return enrichSupported(item);

        // NOTE: This branch is added from the original StyleFormats in mobile
      } else if (keys.length === 1 && Arr.contains(keys, 'title')) {
        return Merger.deepMerge(item, { type: 'separator' }) as FormatItem;

      } else {
        return enrichCustom(item);
      }
    });
開發者ID:tinymce,項目名稱:tinymce,代碼行數:22,代碼來源:FormatRegister.ts

示例10: Cell

const makePanels = (parts: SlotContainerTypes.SlotContainerParts, panelConfigs: SidebarConfig) => {
  const specs = Arr.map(Obj.keys(panelConfigs), (name) => {
    const spec = panelConfigs[name];
    const bridged = ValueSchema.getOrDie(BridgeSidebar.createSidebar(spec));
    return {
      name,
      getApi,
      onSetup: bridged.onSetup,
      onShow: bridged.onShow,
      onHide: bridged.onHide
    };
  });

  return Arr.map(specs, (spec) => {
    const editorOffCell = Cell(Fun.noop);
    return parts.slot(
      spec.name,
      {
        dom: {
          tag: 'div',
          classes: ['tox-sidebar__pane']
        },
        behaviours: SimpleBehaviours.unnamedEvents([
          onControlAttached(spec, editorOffCell),
          onControlDetached(spec, editorOffCell),
          AlloyEvents.run<SystemEvents.AlloySlotVisibilityEvent>(SystemEvents.slotVisibility(), (sidepanel, se) => {
            const data = se.event();
            const optSidePanelSpec = Arr.find(specs, (config) => config.name === data.name());
            optSidePanelSpec.each((sidePanelSpec) => {
              const handler = data.visible() ? sidePanelSpec.onShow : sidePanelSpec.onHide;
              handler(sidePanelSpec.getApi(sidepanel));
            });
          })
        ])
      }
    );
  });
};
開發者ID:tinymce,項目名稱:tinymce,代碼行數:38,代碼來源:Sidebar.ts


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