UNPKG

@lobehub/editor

Version:

A powerful and extensible rich text editor built on Meta's Lexical framework, providing a modern editing experience with React integration.

35 lines (34 loc) 1.25 kB
import { IS_APPLE } from '@lexical/utils'; export var nodeDetect = function nodeDetect() { return typeof process !== 'undefined' && process.versions && !!process.versions.node; }; export var browserDetect = function browserDetect() { return typeof window !== 'undefined' && window.document !== undefined; }; export var isNode = nodeDetect(); export var isBrowser = browserDetect(); export var macOSDetect = function macOSDetect() { if (isNode) { return process.platform === 'darwin'; } if (isBrowser) { return window.navigator.platform.includes('Mac'); } return false; }; export var isMac = macOSDetect(); // TODO: 这些常量已经迁移到 @/const/hotkey,建议使用新的统一定义 // 为了向后兼容性保留,但应该逐步迁移到新的 PLATFORM_MODIFIER /** @deprecated 请使用 @/const/hotkey 中的 PLATFORM_MODIFIER.MOD */ export var CONTROL_OR_META = { ctrlKey: !IS_APPLE, metaKey: IS_APPLE }; /** @deprecated 请使用 @/const/hotkey 中的 PLATFORM_MODIFIER.MOD_SHIFT */ export var CONTROL_OR_META_AND_SHIFT = { ctrlKey: !IS_APPLE, metaKey: IS_APPLE, shiftKey: true }; export { IS_FIREFOX, IS_APPLE as isApple } from '@lexical/utils'; export var isOnServerSide = typeof window === 'undefined';