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


TypeScript AlloyEvents.runOnAttached方法代碼示例

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


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

示例1: deriveMenuMovement

export const createMenuFrom = (partialMenu: Partial<MenuTypes.MenuSpec>, columns: number | 'auto', focusMode: FocusMode, presets: Types.PresetTypes): MenuTypes.MenuSpec  => {
  const focusManager = focusMode === FocusMode.ContentFocus ? FocusManagers.highlights() : FocusManagers.dom();

  const movement = deriveMenuMovement(columns, presets);
  const menuMarkers = getMenuMarkers(presets);

  return {
    dom: partialMenu.dom,
    components: partialMenu.components,
    items: partialMenu.items,
    value: partialMenu.value,
    markers: {
      selectedItem: menuMarkers.selectedItem,
      item: menuMarkers.item
    },
    movement,
    fakeFocus: focusMode === FocusMode.ContentFocus,
    focusManager,

    menuBehaviours: SimpleBehaviours.unnamedEvents(columns !== 'auto' ? [ ] : [
      AlloyEvents.runOnAttached((comp, se) => {
        detectSize(comp, 4, menuMarkers.item).each(({ numColumns, numRows }) => {
          Keying.setGridSize(comp, numRows, numColumns);
        });
      })
    ])
  };
};
開發者ID:tinymce,項目名稱:tinymce,代碼行數:28,代碼來源:SingleMenu.ts

示例2: renderBodyPanel

  const checkboxSpec = (() => {
    const memBodyPanel = Memento.record(
      renderBodyPanel({
        items: [
          { type: 'checkbox', name: 'checked', label: 'Checked' },
          { type: 'checkbox', name: 'unchecked', label: 'Unchecked' }
        ]
      }, {
        shared: sharedBackstage
      })
    );

    return {
      dom: {
        tag: 'div'
      },
      components: [
        memBodyPanel.asSpec(),
      ],
      events: AlloyEvents.derive([
        AlloyEvents.runOnAttached((component) => {
          const body = memBodyPanel.get(component);
          Representing.setValue(body, {
            checked: true,
            unchecked: false
          });
        })
      ])
    };
  })();
開發者ID:tinymce,項目名稱:tinymce,代碼行數:30,代碼來源:DialogComponentsDemo.ts

示例3: createPartialChoiceMenu

 }).map((items) => {
   return Option.from(createTieredDataFrom(
     Merger.deepMerge(
       createPartialChoiceMenu(
         Id.generate('menu-value'),
         items,
         (value) => {
           spec.onItemAction(getApi(comp), value);
         },
         spec.columns,
         spec.presets,
         ItemResponse.CLOSE_ON_EXECUTE,
         spec.select.getOr(() => false),
         providersBackstage
       ),
       {
         movement: deriveMenuMovement(spec.columns, spec.presets),
         menuBehaviours: SimpleBehaviours.unnamedEvents(spec.columns !== 'auto' ? [ ] : [
           AlloyEvents.runOnAttached((comp, se) => {
             detectSize(comp, 4, classForPreset(spec.presets)).each(({ numRows, numColumns }) => {
               Keying.setGridSize(comp, numRows, numColumns);
             });
           })
         ])
       } as TieredMenuTypes.PartialMenuSpec
     )
   ));
 });
開發者ID:tinymce,項目名稱:tinymce,代碼行數:28,代碼來源:ToolbarButtons.ts

示例4: runWithApi

const onControlAttached = <T>(info: OnControlAttachedType<T>, editorOffCell: Cell<OnDestroy<T>>) => {
  return AlloyEvents.runOnAttached((comp) => {
    const run = runWithApi(info, comp);
    run((api) => {
      const onDestroy = info.onSetup(api);
      if (onDestroy !== null && onDestroy !== undefined) {
        editorOffCell.set(onDestroy);
      }
    });
  });
};
開發者ID:tinymce,項目名稱:tinymce,代碼行數:11,代碼來源:Controls.ts

示例5: Cell

export const renderCustomEditor = (spec: CustomEditorFoo): SimpleSpec => {
  const editorApi = Cell(Option.none());

  const memReplaced = Memento.record({
    dom: {
      tag: spec.tag
    }
  });

  const initialValue = Cell(Option.none());

  return {
    dom: {
      tag: 'div',
      classes: [ 'tox-custom-editor' ]
    },
    behaviours: Behaviour.derive([
      AddEventsBehaviour.config('editor-foo-events', [
        AlloyEvents.runOnAttached((component) => {
          memReplaced.getOpt(component).each((ta) => {
            spec.init(ta.element().dom()).then((ea) => {
              initialValue.get().each((cvalue) => {
                ea.setValue(cvalue);
              });

              initialValue.set(Option.none());
              editorApi.set(Option.some(ea));
            });
          });
        })
      ]),
      Representing.config({
        store: {
          mode: 'manual',
          getValue: () => editorApi.get().fold(
            () => initialValue.get().getOr(''),
            (ed) => ed.getValue()
          ),
          setValue: (component, value) => {
            editorApi.get().fold(
              () => {
                initialValue.set(Option.some(value));
              },
              (ed) => ed.setValue(value)
            );
          }
        }
      }),

      ComposingConfigs.self()
    ]),
    components: [memReplaced.asSpec()]
  };
};
開發者ID:tinymce,項目名稱:tinymce,代碼行數:54,代碼來源:CustomEditor.ts

示例6: makePanels

const makeSidebar = (panelConfigs: SidebarConfig) => SlotContainer.sketch((parts) => {
  return {
    dom: {
      tag: 'div',
      classes: ['tox-sidebar__pane-container'],
    },
    components: makePanels(parts, panelConfigs),
    slotBehaviours: SimpleBehaviours.unnamedEvents([
      AlloyEvents.runOnAttached((slotContainer) => SlotContainer.hideAllSlots(slotContainer))
    ])
  };
});
開發者ID:tinymce,項目名稱:tinymce,代碼行數:12,代碼來源:Sidebar.ts

示例7: replaceCountText

export const renderWordCount = (editor: Editor, providersBackstage: UiFactoryBackstageProviders): SimpleSpec => {
  const replaceCountText = (comp, count, mode) => Replacing.set(comp, [ GuiFactory.text(providersBackstage.translate(['{0} ' + mode, count[mode]])) ]);
  return Button.sketch({
    dom: {
      // The tag for word count was changed to 'button' as Jaws does not read out spans.
      // Word count is just a toggle and changes modes between words and characters.
      tag: 'button',
      classes: [ 'tox-statusbar__wordcount' ]
    },
    components: [ ],
    buttonBehaviours: Behaviour.derive([
      Tabstopping.config({ }),
      Replacing.config({ }),
      Representing.config({
        store: {
          mode: 'memory',
          initialValue: {
            mode: WordCountMode.Words,
            count: { words: 0, characters: 0 }
          }
        }
      }),
      AddEventsBehaviour.config('wordcount-events', [
        AlloyEvents.run(SystemEvents.tapOrClick(), (comp) => {
          const currentVal = Representing.getValue(comp);
          const newMode = currentVal.mode === WordCountMode.Words ? WordCountMode.Characters : WordCountMode.Words;
          Representing.setValue(comp, { mode: newMode, count: currentVal.count });
          replaceCountText(comp, currentVal.count, newMode);
        }),
        AlloyEvents.runOnAttached((comp) => {
          editor.on('wordCountUpdate', (e) => {
            const { mode } = Representing.getValue(comp);
            Representing.setValue(comp, { mode, count: e.wordCount });
            replaceCountText(comp, e.wordCount, mode);
          });
        })
      ])
    ]),
    eventOrder: {
      [SystemEvents.tapOrClick()]: [ 'wordcount-events', 'alloy.base.behaviour' ]
    }
  });
};
開發者ID:tinymce,項目名稱:tinymce,代碼行數:43,代碼來源:WordCount.ts

示例8:

const getToolbarbehaviours = (toolbarSpec, modeName, overflowOpt) => {
  const onAttached = AlloyEvents.runOnAttached(function (component) {
    const groups = Arr.map(toolbarSpec.initGroups, renderToolbarGroup);
    AlloyToolbar.setGroups(component, groups);
  });

  const eventBehaviours = overflowOpt.fold(() => [
    onAttached
  ],
    (memOverflow) => [
      onAttached,
      AlloyEvents.run('alloy.toolbar.toggle', (toolbar, se) => {
        toolbarSpec.getSink().toOption().each((sink) => {
          memOverflow.getOpt(sink).fold(() => {
            // overflow isn't there yet ... so add it, and return the built thing
            const builtoverFlow = GuiFactory.build(memOverflow.asSpec());
            Attachment.attach(sink, builtoverFlow);
            Positioning.position(sink, toolbarSpec.backstage.shared.anchors.toolbarOverflow(), builtoverFlow);
            SplitAlloyToolbar.refresh(toolbar);
            SplitAlloyToolbar.getMoreButton(toolbar).each(Focusing.focus);
            Keying.focusIn(builtoverFlow);
            // return builtoverFlow;
          }, (builtOverflow) => {
            Attachment.detach(builtOverflow);
          });
        });
      })
    ]
  );
  return Behaviour.derive([
    Keying.config({
      // Tabs between groups
      mode: modeName,
      onEscape: toolbarSpec.onEscape,
      selector: '.tox-toolbar__group'
    }),
    AddEventsBehaviour.config('toolbar-events', eventBehaviours)
  ]);
};
開發者ID:tinymce,項目名稱:tinymce,代碼行數:39,代碼來源:CommonToolbar.ts

示例9:

  const wrapInPopDialog = (toolbarSpec: AlloySpec) => {
    return {
      dom: {
        tag: 'div',
        classes: ['tox-pop__dialog'],
      },
      components: [toolbarSpec],
      behaviours: Behaviour.derive([
        Keying.config({
          mode: 'acyclic'
        }),

        AddEventsBehaviour.config('pop-dialog-wrap-events', [
          AlloyEvents.runOnAttached((comp) => {
            editor.shortcuts.add('ctrl+F9', 'focus statusbar', () => Keying.focusIn(comp));
          }),
          AlloyEvents.runOnDetached((comp) => {
            editor.shortcuts.remove('ctrl+F9');
          })
        ])
      ])
    };
  };
開發者ID:tinymce,項目名稱:tinymce,代碼行數:23,代碼來源:ContextToolbar.ts

示例10: interpretInForm

          AlloyForm.sketch((parts) => {
            return {
              dom: {
                tag: 'div',
                classes: [ 'tox-form' ]
              },
              components: Arr.map(tab.items, (item) => interpretInForm(parts, item, backstage)),
              formBehaviours: Behaviour.derive([
                Keying.config({
                  mode: 'acyclic',
                  useTabstopAt: Fun.not(NavigableObject.isPseudoStop)
                }),

                AddEventsBehaviour.config('TabView.form.events', [
                  AlloyEvents.runOnAttached(setDataOnForm),
                  AlloyEvents.runOnDetached(updateDataWithForm)
                ]),
                Receiving.config({
                  channels: Objects.wrapAll([
                    {
                      key: SendDataToSectionChannel,
                      value:  {
                        onReceive: updateDataWithForm
                      }
                    },
                    {
                      key: SendDataToViewChannel,
                      value: {
                        onReceive: setDataOnForm
                      }
                    }
                  ])
                })
              ])
            };
          })
開發者ID:tinymce,項目名稱:tinymce,代碼行數:36,代碼來源:TabPanel.ts


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