Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
saveSelectionRange(core);
}
}
),
new DOMEventHandler(core, 'keypress', PluginEventType.KeyPress, event => onKeyPress(core, event as KeyboardEvent)),
new DOMEventHandler(core, 'keydown', PluginEventType.KeyDown),
new DOMEventHandler(core, 'keyup', PluginEventType.KeyUp),
new DOMEventHandler(core, 'compositionstart', null, () => (core.isInIME = true)),
new DOMEventHandler(
core,
'compositionend',
PluginEventType.CompositionEnd,
() => (core.isInIME = false)
),
new DOMEventHandler(core, 'mousedown', PluginEventType.MouseDown),
new DOMEventHandler(core, 'mouseup', PluginEventType.MouseUp),
new DOMEventHandler(core, 'mouseover', PluginEventType.MouseOver),
new DOMEventHandler(core, 'mouseout', PluginEventType.MouseOut),
new DOMEventHandler(core, 'paste', PluginEventType.Paste),
new DOMEventHandler(core, 'copy', PluginEventType.Copy, () => {}),
new DOMEventHandler(core, 'focus', PluginEventType.Focus, () => {
// Restore the last saved selection first
if (core.cachedSelectionRange && !core.disableRestoreSelectionOnFocus) {
restoreSelection(core);
}
core.cachedSelectionRange = null;
}),
];
if (isIEorEdge) {
// we do saving selection when editor loses focus, which normally can be done in onBlur event
private createEventHandlers() {
this.eventDisposers = [
attachDomEvent(this.core, 'input', null, this.stopPropagation),
attachDomEvent(this.core, 'keypress', PluginEventType.KeyPress, this.onKeyPress),
attachDomEvent(this.core, 'keydown', PluginEventType.KeyDown, this.stopPropagation),
attachDomEvent(this.core, 'keyup', PluginEventType.KeyUp, this.stopPropagation),
attachDomEvent(this.core, 'mousedown', PluginEventType.MouseDown),
attachDomEvent(this.core, 'mouseup', PluginEventType.MouseUp),
attachDomEvent(this.core, 'compositionstart', null, () => (this.inIME = true)),
attachDomEvent(
this.core,
'compositionend',
PluginEventType.CompositionEnd,
() => (this.inIME = false)
),
attachDomEvent(this.core, 'focus', null, () => {
// Restore the last saved selection first
if (this.core.cachedSelectionRange && !this.disableRestoreSelectionOnFocus) {
restoreSelection(this.core);
}
this.core.cachedSelectionRange = null;
}),
attachDomEvent(this.core, IS_IE_OR_EDGE ? 'beforedeactivate' : 'blur', null, () => {
saveSelectionRange(this.core);
public onPluginEvent(event: PluginEvent): void {
if (
event.eventType == PluginEventType.KeyUp ||
event.eventType == PluginEventType.MouseUp ||
event.eventType == PluginEventType.ContentChanged
) {
this.ribbons.forEach(ribbon => ribbon.onFormatChange());
}
}
onPluginEvent(event: PluginEvent) {
if (
event.eventType == PluginEventType.KeyUp ||
event.eventType == PluginEventType.MouseUp ||
event.eventType == PluginEventType.ContentChanged
) {
this.updateFormatState();
}
}
public willHandleEventExclusively(event: PluginEvent): boolean {
return this._isSuggesting && (event.eventType === PluginEventType.KeyDown || event.eventType === PluginEventType.KeyUp || event.eventType === PluginEventType.MouseUp);
}
private renderEvent(event: PluginEvent): JSX.Element {
switch (event.eventType) {
case PluginEventType.KeyDown:
case PluginEventType.KeyPress:
case PluginEventType.KeyUp:
return (
<span>
Key=
{event.rawEvent.which}
</span>
);
case PluginEventType.MouseDown:
case PluginEventType.MouseUp:
return (
<span>
Button=
{event.rawEvent.button}, SrcElement=
{event.rawEvent.target && getTagOfNode(event.rawEvent.target as Node)},
PageX=
{event.rawEvent.pageX}, PageY=
{event.rawEvent.pageY}
</span>
);
case PluginEventType.ContentChanged:
return (
<span>
Source=
{event.source}, Data=
</span>
public onPluginEvent(event: PluginEvent): void {
if (event.eventType == PluginEventType.MouseUp) {
const anchor = this.editor.getElementAtCursor(
'A',
event.rawEvent.srcElement
) as HTMLAnchorElement;
if (anchor) {
if (this.onLinkClick) {
this.onLinkClick(anchor, event.rawEvent);
return;
}
let href: string;
if (
!Browser.isFirefox &&
(href = this.tryGetHref(anchor)) &&
(Browser.isMac ? event.rawEvent.metaKey : event.rawEvent.ctrlKey)
onPluginEvent(event: PluginEvent) {
if (
this.ribbon &&
(event.eventType == PluginEventType.KeyUp ||
event.eventType == PluginEventType.MouseUp ||
event.eventType == PluginEventType.ContentChanged)
) {
this.ribbon.forceUpdate();
}
}
}