本文整理汇总了TypeScript中tinymce/core/api/Editor.Editor.fire方法的典型用法代码示例。如果您正苦于以下问题:TypeScript Editor.fire方法的具体用法?TypeScript Editor.fire怎么用?TypeScript Editor.fire使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类tinymce/core/api/Editor.Editor
的用法示例。
在下文中一共展示了Editor.fire方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。
示例1: if
const getContentFromBody = (editor: Editor, args: GetContentArgs, body: HTMLElement): Content => {
let content;
args.format = args.format ? args.format : defaultFormat;
args.get = true;
args.getInner = true;
if (!args.no_events) {
editor.fire('BeforeGetContent', args);
}
if (args.format === 'raw') {
content = Tools.trim(TrimHtml.trimExternal(editor.serializer, body.innerHTML));
} else if (args.format === 'text') {
content = Zwsp.trim(body.innerText || body.textContent);
} else if (args.format === 'tree') {
return editor.serializer.serialize(body, args);
} else {
content = trimEmptyContents(editor, editor.serializer.serialize(body, args));
}
if (args.format !== 'text' && !isWsPreserveElement(Element.fromDom(body))) {
args.content = Tools.trim(content);
} else {
args.content = content;
}
if (!args.no_events) {
editor.fire('GetContent', args);
}
return args.content;
};
示例2: function
editor.on('KeyUp', function (e) {
const keyCode = e.keyCode;
// If key is prevented then don't add undo level
// This would happen on keyboard shortcuts for example
if (e.isDefaultPrevented()) {
return;
}
if ((keyCode >= 33 && keyCode <= 36) || (keyCode >= 37 && keyCode <= 40) || keyCode === 45 || e.ctrlKey) {
addNonTypingUndoLevel();
editor.nodeChanged();
}
if (keyCode === 46 || keyCode === 8) {
editor.nodeChanged();
}
// Fire a TypingUndo/Change event on the first character entered
if (isFirstTypedCharacter && self.typing && Levels.isEq(Levels.createFromEditor(editor), data[0]) === false) {
if (editor.isDirty() === false) {
setDirty(true);
editor.fire('change', { level: data[0], lastLevel: null });
}
editor.fire('TypingUndo');
isFirstTypedCharacter = false;
editor.nodeChanged();
}
});
示例3: function
const execCommand = function (command, ui, value, args) {
let func, customCommand, state = false;
if (editor.removed) {
return;
}
if (!/^(mceAddUndoLevel|mceEndUndoLevel|mceBeginUndoLevel|mceRepaint)$/.test(command) && (!args || !args.skip_focus)) {
editor.focus();
} else {
SelectionBookmark.restore(editor);
}
args = editor.fire('BeforeExecCommand', { command, ui, value });
if (args.isDefaultPrevented()) {
return false;
}
customCommand = command.toLowerCase();
if ((func = commands.exec[customCommand])) {
func(customCommand, ui, value);
editor.fire('ExecCommand', { command, ui, value });
return true;
}
// Plugin commands
each(editor.plugins, function (p) {
if (p.execCommand && p.execCommand(command, ui, value)) {
editor.fire('ExecCommand', { command, ui, value });
state = true;
return false;
}
});
if (state) {
return state;
}
// Theme commands
if (editor.theme && editor.theme.execCommand && editor.theme.execCommand(command, ui, value)) {
editor.fire('ExecCommand', { command, ui, value });
return true;
}
// Browser commands
try {
state = editor.getDoc().execCommand(command, ui, value);
} catch (ex) {
// Ignore old IE errors
}
if (state) {
editor.fire('ExecCommand', { command, ui, value });
return true;
}
return false;
};
示例4: if
const setContentString = (editor: Editor, body: HTMLElement, content: string, args: SetContentArgs): string => {
let forcedRootBlockName, padd;
// Padd empty content in Gecko and Safari. Commands will otherwise fail on the content
// It will also be impossible to place the caret in the editor unless there is a BR element present
if (content.length === 0 || /^\s+$/.test(content)) {
padd = '<br data-mce-bogus="1">';
// Todo: There is a lot more root elements that need special padding
// so separate this and add all of them at some point.
if (body.nodeName === 'TABLE') {
content = '<tr><td>' + padd + '</td></tr>';
} else if (/^(UL|OL)$/.test(body.nodeName)) {
content = '<li>' + padd + '</li>';
}
forcedRootBlockName = Settings.getForcedRootBlock(editor);
// Check if forcedRootBlock is configured and that the block is a valid child of the body
if (forcedRootBlockName && editor.schema.isValidChild(body.nodeName.toLowerCase(), forcedRootBlockName.toLowerCase())) {
content = padd;
content = editor.dom.createHTML(forcedRootBlockName, editor.settings.forced_root_block_attrs, content);
} else if (!content) {
// We need to add a BR when forced_root_block is disabled on non IE browsers to place the caret
content = '<br data-mce-bogus="1">';
}
editor.dom.setHTML(body, content);
editor.fire('SetContent', args);
} else {
if (args.format !== 'raw') {
content = Serializer({
validate: editor.validate
}, editor.schema).serialize(
editor.parser.parse(content, { isRootContent: true, insert: true })
);
}
args.content = Tools.trim(content);
editor.dom.setHTML(body, args.content);
if (!args.no_events) {
editor.fire('SetContent', args);
}
}
return args.content as string;
};
示例5: each
each(editor.plugins, function (p) {
if (p.execCommand && p.execCommand(command, ui, value)) {
editor.fire('ExecCommand', { command, ui, value });
state = true;
return false;
}
});
示例6: if
const fireEvent = (editor: Editor, eventName: string, e: Event) => {
if (isListening(editor)) {
editor.fire(eventName, e);
} else if (isReadOnly(editor)) {
e.preventDefault();
}
};
示例7: function
const initEditor = function (editor: Editor) {
editor.bindPendingEventDelegates();
editor.initialized = true;
editor.fire('init');
editor.focus(true);
editor.nodeChanged({ initial: true });
editor.execCallback('init_instance_callback', editor);
autoFocus(editor);
};
示例8: isTreeNode
const setContent = (editor: Editor, content: Content, args: SetContentArgs = {}): Content => {
args.format = args.format ? args.format : defaultFormat;
args.set = true;
args.content = isTreeNode(content) ? '' : content;
if (!isTreeNode(content) && !args.no_events) {
editor.fire('BeforeSetContent', args);
content = args.content;
}
return isTreeNode(content) ? setContentTree(editor, content, args) : setContentString(editor, content, args);
};
示例9: function
const fireFormatsMenuEvent = function (editor: Editor, styleSheets, items?) {
menuCtrl = Factory.create('menu', {
items
}).renderTo(document.getElementById('view'));
return editor.fire('renderFormatsMenu', {
control: menuCtrl,
doc: {
styleSheets
}
});
};
示例10: if
const getContent = (editor: Editor, args: GetContentArgs = {}): Content => {
let content;
const body = editor.getBody();
if (editor.removed) {
return '';
}
args.format = args.format ? args.format : defaultFormat;
args.get = true;
args.getInner = true;
if (!args.no_events) {
editor.fire('BeforeGetContent', args);
}
if (args.format === 'raw') {
content = Tools.trim(TrimHtml.trimExternal(editor.serializer, body.innerHTML));
} else if (args.format === 'text') {
content = body.innerText || body.textContent;
} else if (args.format === 'tree') {
return editor.serializer.serialize(body, args);
} else {
content = editor.serializer.serialize(body, args);
}
if (args.format !== 'text') {
args.content = Tools.trim(content);
} else {
args.content = content;
}
if (!args.no_events) {
editor.fire('GetContent', args);
}
return args.content;
};