本文整理汇总了TypeScript中tinymce/core/api/Editor.Editor.execCommand方法的典型用法代码示例。如果您正苦于以下问题:TypeScript Editor.execCommand方法的具体用法?TypeScript Editor.execCommand怎么用?TypeScript Editor.execCommand使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类tinymce/core/api/Editor.Editor
的用法示例。
在下文中一共展示了Editor.execCommand方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。
示例1:
editor.undoManager.transact(function () {
if (editor.selection.isCollapsed() === false) {
editor.execCommand('Delete');
}
InsertNewLine.insert(editor, event);
});
示例2: function
editor.on('focus', function () {
if (!autoUrlDetectState) {
autoUrlDetectState = true;
try {
editor.execCommand('AutoUrlDetect', false, true);
} catch (ex) {
// Ignore
}
}
});
示例3: setFocusedRange
editor.undoManager.transact(function () {
if (dropContent['mce-internal']) {
editor.execCommand('Delete');
}
setFocusedRange(editor, rng);
content = Utils.trimHtml(content);
if (!dropContent['text/html']) {
clipboard.pasteText(content);
} else {
clipboard.pasteHtml(content, internal);
}
});
示例4: function
return function () {
editor.execCommand('mceToggleFormat', false, fmt);
};
示例5:
editor.undoManager.transact(function () {
firstTextNode.deleteData(0, pattern.start.length);
editor.execCommand(pattern.cmd);
});
示例6: function
}, function () {
editor.execCommand('mceInsertLink', false, url);
});
示例7: function
export default function (editor: Editor) {
let dom: DOMUtils, selection: Selection, formatter;
const commands = { state: {}, exec: {}, value: {} };
let settings = editor.settings,
bookmark;
editor.on('PreInit', function () {
dom = editor.dom;
selection = editor.selection;
settings = editor.settings;
formatter = editor.formatter;
});
/**
* Executes the specified command.
*
* @method execCommand
* @param {String} command Command to execute.
* @param {Boolean} ui Optional user interface state.
* @param {Object} value Optional value for command.
* @param {Object} args Optional extra arguments to the execCommand.
* @return {Boolean} true/false if the command was found or not.
*/
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;
};
/**
* Queries the current state for a command for example if the current selection is "bold".
*
* @method queryCommandState
* @param {String} command Command to check the state of.
* @return {Boolean/Number} true/false if the selected contents is bold or not, -1 if it's not found.
*/
const queryCommandState = function (command) {
let func;
if (editor.quirks.isHidden() || editor.removed) {
return;
}
command = command.toLowerCase();
if ((func = commands.state[command])) {
return func(command);
}
//.........这里部分代码省略.........
示例8: function
const insertLink = function (editor: Editor, url: string) {
editor.execCommand('mceInsertLink', false, { href: url });
collapseSelectionToEnd(editor);
};
示例9: setTimeout
setTimeout(() => { // detach
editor.execCommand('Delete');
}, 0);