本文整理汇总了TypeScript中tinymce/core/api/Editor.on函数的典型用法代码示例。如果您正苦于以下问题:TypeScript on函数的具体用法?TypeScript on怎么用?TypeScript on使用的例子?那么, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了on函数的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。
示例1: function
const setup = (editor: Editor, oldSize: Cell<number>) => {
editor.on('init', () => {
const overflowPadding = Settings.getAutoResizeOverflowPadding(editor);
const dom = editor.dom;
dom.setStyles(editor.getBody(), {
'paddingLeft': overflowPadding,
'paddingRight': overflowPadding,
// IE & Edge have a min height of 150px by default on the body, so override that
'min-height': 0
});
});
editor.on('NodeChange SetContent keyup FullscreenStateChanged ResizeContent', function (e) {
resize(editor, oldSize);
});
if (Settings.shouldAutoResizeOnInit(editor)) {
editor.on('init', () => {
// Hit it 20 times in 100 ms intervals
wait(editor, oldSize, 20, 100, () => {
// Hit it 5 times in 1 sec intervals
wait(editor, oldSize, 5, 1000);
});
});
}
};
示例2: function
suite.test('OpenWindow/CloseWindow events', function (editor: Editor) {
let openWindowArgs, closeWindowArgs;
editor.on('CloseWindow', function (e) {
closeWindowArgs = e;
});
editor.on('OpenWindow', function (e) {
openWindowArgs = e;
editor.windowManager.close();
});
editor.windowManager.open({
title: 'Find and Replace',
body: {
type: 'panel',
items: []
},
buttons: []
});
LegacyUnit.equal(openWindowArgs.type, 'openwindow');
LegacyUnit.equal(closeWindowArgs.type, 'closewindow');
editor.off('CloseWindow OpenWindow');
});
示例3: resetTimer
editor.on('init', () => {
// FIX: Make it go away when the action makes it go away. E.g. deleting a column deletes the table.
editor.on('click keyup SetContent ObjectResized ResizeEditor', (e) => {
// Fixing issue with chrome focus on img.
resetTimer(
Delay.setEditorTimeout(editor, launchContextToolbar, 0)
);
});
editor.on('focusout', (e) => {
Delay.setEditorTimeout(editor, () => {
if (Focus.search(sink.element()).isNone() && Focus.search(contextbar.element()).isNone()) {
lastAnchor.set(Option.none());
InlineView.hide(contextbar);
}
}, 0);
});
editor.on('NodeChange', (e) => {
Focus.search(contextbar.element()).fold(
() => {
resetTimer(
Delay.setEditorTimeout(editor, launchContextToolbar, 0)
);
},
(_) => {
}
);
});
});
示例4: Plugin
function Plugin(editor: Editor) {
const resizeHandler = ResizeHandler(editor);
const cellSelection = CellSelection(editor, resizeHandler.lazyResize);
const actions = TableActions(editor, resizeHandler.lazyWire);
const selections = Selections(editor);
const selectionTargets = SelectionTargets(editor, selections);
const clipboardRows = Cell(Option.none());
Commands.registerCommands(editor, actions, cellSelection, selections, clipboardRows);
Clipboard.registerEvents(editor, selections, actions, cellSelection);
MenuItems.addMenuItems(editor, selectionTargets);
Buttons.addButtons(editor, selectionTargets);
Buttons.addToolbars(editor);
editor.on('PreInit', function () {
editor.serializer.addTempAttr(Ephemera.firstSelected());
editor.serializer.addTempAttr(Ephemera.lastSelected());
});
if (hasTabNavigation(editor)) {
editor.on('keydown', function (e: KeyboardEvent) {
TabContext.handle(e, editor, actions, resizeHandler.lazyWire);
});
}
editor.on('remove', function () {
resizeHandler.destroy();
cellSelection.destroy();
});
return getApi(editor, clipboardRows);
}
示例5: function
const setup = function (editor: Editor, headState, footState) {
editor.on('BeforeSetContent', function (evt) {
handleSetContent(editor, headState, footState, evt);
});
editor.on('GetContent', function (evt) {
handleGetContent(editor, headState.get(), footState.get(), evt);
});
};
示例6: if
const setup = (api: AutocompleterUiApi, editor: Editor) => {
editor.on('keypress', api.onKeypress.throttle);
editor.on('remove', api.onKeypress.cancel);
const redirectKeyToItem = (item, e) => {
AlloyTriggers.emitWith(item, NativeEvents.keydown(), { raw: e });
};
editor.on('keydown', (e) => {
const getItem = () => {
return api.getView().bind(Highlighting.getHighlighted);
};
// Pressing <backspace> updates the autocompleter
if (e.which === 8) {
api.onKeypress.throttle(e);
}
if (api.isActive()) {
// Pressing <esc> closes the autocompleter
if (e.which === 27) {
api.closeIfNecessary();
// Pressing <space> closes the autocompleter
} else if (e.which === 32) {
api.closeIfNecessary();
// Pressing <enter> executes any item currently selected, or does nothing
} else if (e.which === 13) {
getItem().each(AlloyTriggers.emitExecute);
e.preventDefault();
// Pressing <down> either highlights the first option, or moves down the menu
} else if (e.which === 40) {
getItem().fold(
// No current item, so highlight the first one
() => {
api.getView().each(Highlighting.highlightFirst);
},
// There is a current item, so move down in the menu
(item) => {
redirectKeyToItem(item, e);
}
);
e.preventDefault();
// Pressing <up>, <left>, <right> gets redirected to the selected item
} else if (e.which === 37 || e.which === 38 || e.which === 39 ) {
getItem().each(
(item) => {
redirectKeyToItem(item, e);
e.preventDefault();
}
);
}
}
});
};
示例7: Cell
const setupEvents = (editor: Editor) => {
const contentWindow = editor.getWin();
const initialDocEle = editor.getDoc().documentElement;
const lastWindowDimensions = Cell(Position(contentWindow.innerWidth, contentWindow.innerHeight));
const lastDocumentDimensions = Cell(Position(initialDocEle.offsetWidth, initialDocEle.offsetHeight));
const resize = () => {
// Don't use the initial doc ele, as there's a small chance it may have changed
const docEle = editor.getDoc().documentElement;
// Check if the window or document dimensions have changed and if so then trigger a content resize event
const outer = lastWindowDimensions.get();
const inner = lastDocumentDimensions.get();
if (outer.left() !== contentWindow.innerWidth || outer.top() !== contentWindow.innerHeight) {
lastWindowDimensions.set(Position(contentWindow.innerWidth, contentWindow.innerHeight));
Events.fireResizeContent(editor);
} else if (inner.left() !== docEle.offsetWidth || inner.top() !== docEle.offsetHeight) {
lastDocumentDimensions.set(Position(docEle.offsetWidth, docEle.offsetHeight));
Events.fireResizeContent(editor);
}
};
DOM.bind(contentWindow, 'resize', resize);
// Bind to async load events and trigger a content resize event if the size has changed
const elementLoad = DomEvent.capture(Element.fromDom(editor.getBody()), 'load', resize);
editor.on('remove', () => {
elementLoad.unbind();
DOM.unbind(contentWindow, 'resize', resize);
});
};
示例8: return
onSetup: (api) => {
const nodeChangeHandler = () => {
api.setActive(isCodeSampleSelection(editor));
};
editor.on('NodeChange', nodeChangeHandler);
return () => editor.off('NodeChange', nodeChangeHandler);
},
示例9: onAction
setup: (editor: Editor) => {
editor.ui.registry.addButton('annotate-alpha', {
text: 'Annotate',
onAction() {
const comment = prompt('Comment with?');
editor.annotator.annotate('alpha', {
comment
});
editor.focus();
},
onSetup (btnApi) {
editor.annotator.annotationChanged('alpha', (state, name, obj) => {
btnApi.setDisabled(state);
});
return () => {};
}
});
editor.on('init', () => {
editor.annotator.register('alpha', {
persistent: true,
decorate: (uid, data) => {
return {
attributes: {
'data-mce-comment': data.comment ? data.comment : '',
'data-mce-author': data.author ? data.author : 'anonymous'
}
};
}
});
});
},
示例10: return
onSetup: (buttonApi) => {
const handleToggle = () => buttonApi.setActive(isActive());
editor.on('ToggleSidebar', handleToggle);
return () => {
editor.off('ToggleSidebar', handleToggle);
};
}