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