UNPKG

1.72 kBJavaScriptView Raw
1/**
2 * Copyright (c) Facebook, Inc. and its affiliates.
3 *
4 * This source code is licensed under the MIT license found in the
5 * LICENSE file in the root directory of this source tree.
6 *
7 * @format
8 *
9 * @emails oncall+draft_js
10 */
11'use strict';
12
13var UserAgent = require("fbjs/lib/UserAgent");
14
15var onBeforeInput = require("./editOnBeforeInput");
16
17var onBlur = require("./editOnBlur");
18
19var onCompositionStart = require("./editOnCompositionStart");
20
21var onCopy = require("./editOnCopy");
22
23var onCut = require("./editOnCut");
24
25var onDragOver = require("./editOnDragOver");
26
27var onDragStart = require("./editOnDragStart");
28
29var onFocus = require("./editOnFocus");
30
31var onInput = require("./editOnInput");
32
33var onKeyDown = require("./editOnKeyDown");
34
35var onPaste = require("./editOnPaste");
36
37var onSelect = require("./editOnSelect");
38
39var isChrome = UserAgent.isBrowser('Chrome');
40var isFirefox = UserAgent.isBrowser('Firefox');
41var selectionHandler = isChrome || isFirefox ? onSelect : function (e) {};
42var DraftEditorEditHandler = {
43 onBeforeInput: onBeforeInput,
44 onBlur: onBlur,
45 onCompositionStart: onCompositionStart,
46 onCopy: onCopy,
47 onCut: onCut,
48 onDragOver: onDragOver,
49 onDragStart: onDragStart,
50 onFocus: onFocus,
51 onInput: onInput,
52 onKeyDown: onKeyDown,
53 onPaste: onPaste,
54 onSelect: onSelect,
55 // In certain cases, contenteditable on chrome does not fire the onSelect
56 // event, causing problems with cursor positioning. Therefore, the selection
57 // state update handler is added to more events to ensure that the selection
58 // state is always synced with the actual cursor positions.
59 onMouseUp: selectionHandler,
60 onKeyUp: selectionHandler
61};
62module.exports = DraftEditorEditHandler;
\No newline at end of file