- Preview unavailable
-
- Switch to edit mode to fix the issue.
-
+
+ {mdViewMode === 'preview' ? (
+
+
+ Preview unavailable
+
+ Switch to edit mode to fix the issue.
+
+ }
+ >
+
+
+
+ ) : (
+
+ {
+ // read-only
+ }}
+ readOnly={true}
+ className="h-full"
+ extensions={editorExtensions}
+ onViewReady={(view) => { editorViewRef.current = view; }}
+ onViewDestroy={() => { editorViewRef.current = null; }}
+ blockWidgets={blockWidgets}
+ highlightLines={lineSelection
+ ? {
+ start: Math.min(lineSelection.start, lineSelection.end),
+ end: Math.max(lineSelection.start, lineSelection.end),
}
- >
-
-
-
- ) : (
-
- {
- // read-only
- }}
- readOnly={true}
- className="h-full [&_.cm-scroller]:pb-[var(--oc-plan-comment-pad)] [&_.cm-scroller]:relative"
- extensions={editorExtensions}
- onViewReady={(view) => { editorViewRef.current = view; }}
- onViewDestroy={() => { editorViewRef.current = null; }}
- highlightLines={lineSelection
- ? {
- start: Math.min(lineSelection.start, lineSelection.end),
- end: Math.max(lineSelection.start, lineSelection.end),
- }
- : undefined}
- lineNumbersConfig={{
- domEventHandlers: {
- mousedown: (view, line, event) => {
- if (!(event instanceof MouseEvent)) return false;
- if (event.button !== 0) return false;
- event.preventDefault();
- const lineNumber = view.state.doc.lineAt(line.from).number;
-
- if (isMobile && lineSelection && !event.shiftKey) {
- const start = Math.min(lineSelection.start, lineSelection.end, lineNumber);
- const end = Math.max(lineSelection.start, lineSelection.end, lineNumber);
- setLineSelection({ start, end });
- isSelectingRef.current = false;
- selectionStartRef.current = null;
- // Mobile tap-extend is atomic, so we don't start drag
- setIsDragging(false);
- return true;
- }
-
- isSelectingRef.current = true;
- selectionStartRef.current = lineNumber;
- setIsDragging(true);
-
- if (lineSelection && event.shiftKey) {
- const start = Math.min(lineSelection.start, lineNumber);
- const end = Math.max(lineSelection.end, lineNumber);
- setLineSelection({ start, end });
- } else {
- setLineSelection({ start: lineNumber, end: lineNumber });
- }
-
- return true;
- },
- mouseover: (view, line, event) => {
- if (!(event instanceof MouseEvent)) return false;
- if (event.buttons !== 1) return false;
- if (!isSelectingRef.current || selectionStartRef.current === null) return false;
+ : undefined}
+ lineNumbersConfig={{
+ domEventHandlers: {
+ mousedown: (view, line, event) => {
+ if (!(event instanceof MouseEvent)) return false;
+ if (event.button !== 0) return false;
+ event.preventDefault();
const lineNumber = view.state.doc.lineAt(line.from).number;
- const start = Math.min(selectionStartRef.current, lineNumber);
- const end = Math.max(selectionStartRef.current, lineNumber);
+
+ if (isMobile && lineSelection && !event.shiftKey) {
+ const start = Math.min(lineSelection.start, lineSelection.end, lineNumber);
+ const end = Math.max(lineSelection.start, lineSelection.end, lineNumber);
setLineSelection({ start, end });
- setIsDragging(true);
- return false;
- },
- mouseup: () => {
isSelectingRef.current = false;
selectionStartRef.current = null;
setIsDragging(false);
- return false;
- },
+ return true;
+ }
+
+ isSelectingRef.current = true;
+ selectionStartRef.current = lineNumber;
+ setIsDragging(true);
+
+ if (lineSelection && event.shiftKey) {
+ const start = Math.min(lineSelection.start, lineNumber);
+ const end = Math.max(lineSelection.end, lineNumber);
+ setLineSelection({ start, end });
+ } else {
+ setLineSelection({ start: lineNumber, end: lineNumber });
+ }
+
+ return true;
},
- }}
- />
- {floatingComments}
-
- )}
+ mouseover: (view, line, event) => {
+ if (!(event instanceof MouseEvent)) return false;
+ if (event.buttons !== 1) return false;
+ if (!isSelectingRef.current || selectionStartRef.current === null) return false;
+ const lineNumber = view.state.doc.lineAt(line.from).number;
+ const start = Math.min(selectionStartRef.current, lineNumber);
+ const end = Math.max(selectionStartRef.current, lineNumber);
+ setLineSelection({ start, end });
+ setIsDragging(true);
+ return false;
+ },
+ mouseup: () => {
+ isSelectingRef.current = false;
+ selectionStartRef.current = null;
+ setIsDragging(false);
+ return false;
+ },
+ },
+ }}
+ />