REDROOM
PHP 8.2.30
Path:
Logout
Edit File
Size: 2.96 KB
Close
/home/byroehnu/.trash/node_modules11/@adminjs/design-system/node_modules/@tiptap/react/src/useEditor.ts
Text
Base64
import { EditorOptions } from '@tiptap/core' import { DependencyList, useEffect, useRef, useState, } from 'react' import { Editor } from './Editor.js' function useForceUpdate() { const [, setValue] = useState(0) return () => setValue(value => value + 1) } export const useEditor = (options: Partial<EditorOptions> = {}, deps: DependencyList = []) => { const [editor, setEditor] = useState<Editor | null>(null) const forceUpdate = useForceUpdate() const { onBeforeCreate, onBlur, onCreate, onDestroy, onFocus, onSelectionUpdate, onTransaction, onUpdate, } = options const onBeforeCreateRef = useRef(onBeforeCreate) const onBlurRef = useRef(onBlur) const onCreateRef = useRef(onCreate) const onDestroyRef = useRef(onDestroy) const onFocusRef = useRef(onFocus) const onSelectionUpdateRef = useRef(onSelectionUpdate) const onTransactionRef = useRef(onTransaction) const onUpdateRef = useRef(onUpdate) // This effect will handle updating the editor instance // when the event handlers change. useEffect(() => { if (!editor) { return } if (onBeforeCreate) { editor.off('beforeCreate', onBeforeCreateRef.current) editor.on('beforeCreate', onBeforeCreate) onBeforeCreateRef.current = onBeforeCreate } if (onBlur) { editor.off('blur', onBlurRef.current) editor.on('blur', onBlur) onBlurRef.current = onBlur } if (onCreate) { editor.off('create', onCreateRef.current) editor.on('create', onCreate) onCreateRef.current = onCreate } if (onDestroy) { editor.off('destroy', onDestroyRef.current) editor.on('destroy', onDestroy) onDestroyRef.current = onDestroy } if (onFocus) { editor.off('focus', onFocusRef.current) editor.on('focus', onFocus) onFocusRef.current = onFocus } if (onSelectionUpdate) { editor.off('selectionUpdate', onSelectionUpdateRef.current) editor.on('selectionUpdate', onSelectionUpdate) onSelectionUpdateRef.current = onSelectionUpdate } if (onTransaction) { editor.off('transaction', onTransactionRef.current) editor.on('transaction', onTransaction) onTransactionRef.current = onTransaction } if (onUpdate) { editor.off('update', onUpdateRef.current) editor.on('update', onUpdate) onUpdateRef.current = onUpdate } }, [onBeforeCreate, onBlur, onCreate, onDestroy, onFocus, onSelectionUpdate, onTransaction, onUpdate, editor]) useEffect(() => { let isMounted = true const instance = new Editor(options) setEditor(instance) instance.on('transaction', () => { requestAnimationFrame(() => { requestAnimationFrame(() => { if (isMounted) { forceUpdate() } }) }) }) return () => { isMounted = false } }, deps) useEffect(() => { return () => { editor?.destroy() } }, [editor]) return editor }
Save
Close
Exit & Reset
Text mode: syntax highlighting auto-detects file type.
Directory Contents
Dirs: 0 × Files: 12
Delete Selected
Select All
Select None
Sort:
Name
Size
Modified
Enable drag-to-move
Name
Size
Perms
Modified
Actions
BubbleMenu.tsx
1.51 KB
lrw-r--r--
2026-02-28 11:47:04
Edit
Download
Rename
Chmod
Change Date
Delete
OK
Cancel
recursive
OK
Cancel
recursive
OK
Cancel
Context.tsx
1.12 KB
lrw-r--r--
2026-02-28 11:47:04
Edit
Download
Rename
Chmod
Change Date
Delete
OK
Cancel
recursive
OK
Cancel
recursive
OK
Cancel
Editor.ts
489 B
lrw-r--r--
2026-02-28 11:47:04
Edit
Download
Rename
Chmod
Change Date
Delete
OK
Cancel
recursive
OK
Cancel
recursive
OK
Cancel
EditorContent.tsx
3.52 KB
lrw-r--r--
2026-02-28 11:47:04
Edit
Download
Rename
Chmod
Change Date
Delete
OK
Cancel
recursive
OK
Cancel
recursive
OK
Cancel
FloatingMenu.tsx
1.51 KB
lrw-r--r--
2026-02-28 11:47:04
Edit
Download
Rename
Chmod
Change Date
Delete
OK
Cancel
recursive
OK
Cancel
recursive
OK
Cancel
index.ts
379 B
lrw-r--r--
2026-02-28 11:47:04
Edit
Download
Rename
Chmod
Change Date
Delete
OK
Cancel
recursive
OK
Cancel
recursive
OK
Cancel
NodeViewContent.tsx
528 B
lrw-r--r--
2026-02-28 11:47:04
Edit
Download
Rename
Chmod
Change Date
Delete
OK
Cancel
recursive
OK
Cancel
recursive
OK
Cancel
NodeViewWrapper.tsx
561 B
lrw-r--r--
2026-02-28 11:47:04
Edit
Download
Rename
Chmod
Change Date
Delete
OK
Cancel
recursive
OK
Cancel
recursive
OK
Cancel
ReactNodeViewRenderer.tsx
5.92 KB
lrw-r--r--
2026-02-28 11:47:04
Edit
Download
Rename
Chmod
Change Date
Delete
OK
Cancel
recursive
OK
Cancel
recursive
OK
Cancel
ReactRenderer.tsx
2.19 KB
lrw-r--r--
2026-02-28 11:47:04
Edit
Download
Rename
Chmod
Change Date
Delete
OK
Cancel
recursive
OK
Cancel
recursive
OK
Cancel
useEditor.ts
2.96 KB
lrw-r--r--
2026-02-28 11:47:04
Edit
Download
Rename
Chmod
Change Date
Delete
OK
Cancel
recursive
OK
Cancel
recursive
OK
Cancel
useReactNodeView.ts
392 B
lrw-r--r--
2026-02-28 11:47:04
Edit
Download
Rename
Chmod
Change Date
Delete
OK
Cancel
recursive
OK
Cancel
recursive
OK
Cancel
Zip Selected
If ZipArchive is unavailable, a
.tar
will be created (no compression).