Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 14 additions & 14 deletions src/web-ui/src/tools/editor/components/MarkdownEditor.scss
Original file line number Diff line number Diff line change
Expand Up @@ -107,16 +107,16 @@

h1 {
font-size: $font-size-3xl;
color: #111111;
border-bottom: 1px solid rgba(17, 17, 17, 0.12);
color: var(--color-text-primary);
border-bottom: 1px solid $border-base;
padding-bottom: $size-gap-3;
text-align: center;
letter-spacing: 0.5px;
}

h2 {
font-size: $font-size-2xl;
border-bottom: 1px solid rgba(255, 255, 255, 0.04);
border-bottom: 1px solid $border-base;
padding-bottom: $size-gap-2;
}

Expand Down Expand Up @@ -145,7 +145,7 @@
padding: 0.2em 0.4em;
margin: 0;
font-size: 100%;
background-color: rgba(255, 255, 255, 0.08);
background-color: $element-bg-subtle;
border-radius: $size-radius-sm;
font-family: $font-family-mono;
color: var(--color-accent-500);
Expand All @@ -157,7 +157,7 @@
font-size: 100%;
line-height: 1.45;
background-color: $element-bg-subtle;
border: 1px solid rgba(255, 255, 255, 0.03);
border: 1px solid $border-base;
border-radius: $size-radius-base;
margin-bottom: $size-gap-4;

Expand All @@ -175,7 +175,7 @@
blockquote {
padding: $size-gap-3 $size-gap-4;
color: var(--color-text-muted);
border-left: 3px solid rgba(255, 255, 255, 0.15);
border-left: 3px solid $border-base;
margin: 0 0 $size-gap-4 0;
background: $element-bg-subtle;
border-radius: 0 $size-radius-base $size-radius-base 0;
Expand Down Expand Up @@ -263,28 +263,28 @@
margin-bottom: $size-gap-4;
border-radius: $size-radius-base;
overflow: hidden;
border: 1px solid rgba(255, 255, 255, 0.04);
border: 1px solid $border-base;

th {
font-weight: $font-weight-semibold;
padding: $size-gap-2 $size-gap-3;
border: 1px solid rgba(255, 255, 255, 0.04);
border: 1px solid $border-base;
background: $element-bg-soft;
color: var(--color-text-primary);
}

td {
padding: $size-gap-2 $size-gap-3;
border: 1px solid rgba(255, 255, 255, 0.03);
border: 1px solid $border-base;
}

tr {
background-color: transparent;
border-top: 1px solid rgba(255, 255, 255, 0.03);
border-top: 1px solid $border-base;
transition: background-color $motion-fast $easing-standard;

&:nth-child(2n) {
background-color: rgba(255, 255, 255, 0.01);
background-color: color-mix(in srgb, var(--color-text-primary) 2%, transparent);
}

&:hover {
Expand All @@ -306,8 +306,8 @@
margin: $size-gap-6 0;
background: linear-gradient(90deg,
transparent 0%,
rgba(255, 255, 255, 0.1) 20%,
rgba(255, 255, 255, 0.1) 80%,
color-mix(in srgb, var(--color-text-muted) 30%, transparent) 20%,
color-mix(in srgb, var(--color-text-muted) 30%, transparent) 80%,
transparent 100%);
border: 0;
border-radius: 1px;
Expand Down Expand Up @@ -358,7 +358,7 @@
margin: $size-gap-4 0;
padding: $size-gap-4;
background: $element-bg-subtle;
border: 1px solid rgba(255, 255, 255, 0.03);
border: 1px solid $border-base;
border-radius: $size-radius-base;
overflow-x: auto;

Expand Down
13 changes: 13 additions & 0 deletions src/web-ui/src/tools/editor/components/MarkdownEditor.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,10 @@ const MarkdownEditor: React.FC<MarkdownEditorProps> = ({
const lastModifiedTimeRef = useRef<number>(0);
const lastJumpPositionRef = useRef<{ filePath: string; line: number } | null>(null);
const onContentChangeRef = useRef(onContentChange);
const contentRef = useRef(content);
const lastReportedDirtyRef = useRef<boolean | null>(null);
onContentChangeRef.current = onContentChange;
contentRef.current = content;

const basePath = React.useMemo(() => {
if (!filePath) return undefined;
Expand Down Expand Up @@ -106,6 +109,7 @@ const MarkdownEditor: React.FC<MarkdownEditorProps> = ({
if (!isUnmountedRef.current) {
setContent(fileContent);
setHasChanges(false);
lastReportedDirtyRef.current = false;
setTimeout(() => {
editorRef.current?.setInitialContent?.(fileContent);
}, 0);
Expand Down Expand Up @@ -148,6 +152,7 @@ const MarkdownEditor: React.FC<MarkdownEditorProps> = ({
} else if (initialContent !== undefined) {
setContent(initialContent);
setHasChanges(false);
lastReportedDirtyRef.current = false;
setTimeout(() => {
editorRef.current?.setInitialContent?.(initialContent);
}, 0);
Expand Down Expand Up @@ -181,6 +186,7 @@ const MarkdownEditor: React.FC<MarkdownEditorProps> = ({
if (!isUnmountedRef.current) {
editorRef.current?.markSaved?.();
setHasChanges(false);
lastReportedDirtyRef.current = false;
if (onContentChangeRef.current) {
onContentChangeRef.current(content, false);
}
Expand All @@ -200,11 +206,18 @@ const MarkdownEditor: React.FC<MarkdownEditorProps> = ({
}, [content, filePath, workspacePath, hasChanges, onSave, t]);

const handleContentChange = useCallback((newContent: string) => {
contentRef.current = newContent;
setContent(newContent);
}, []);

const handleDirtyChange = useCallback((isDirty: boolean) => {
setHasChanges(isDirty);
if (lastReportedDirtyRef.current === isDirty) {
return;
}

lastReportedDirtyRef.current = isDirty;
onContentChangeRef.current?.(contentRef.current, isDirty);
}, []);

const handleSave = useCallback((_value: string) => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,17 @@ export const InlineAiPreviewBlock: React.FC<InlineAiPreviewBlockProps> = ({
onReject,
onRetry,
}) => {
const handlePointerDown: React.PointerEventHandler<HTMLElement> = (event) => {
// Keep ProseMirror from stealing focus and remounting the widget before click fires.
event.preventDefault();
event.stopPropagation();
};

const handleMouseDown: React.MouseEventHandler<HTMLElement> = (event) => {
event.preventDefault();
event.stopPropagation();
};

const statusText =
status === 'submitting' || status === 'streaming'
? labels.streaming
Expand All @@ -47,7 +58,11 @@ export const InlineAiPreviewBlock: React.FC<InlineAiPreviewBlockProps> = ({
const previewStateClass = `m-editor-inline-ai-preview--${status}`;

return (
<div className={`m-editor-inline-ai-preview m-editor-inline-ai-preview--inline ${previewStateClass}`}>
<div
className={`m-editor-inline-ai-preview m-editor-inline-ai-preview--inline ${previewStateClass}`}
onPointerDownCapture={handlePointerDown}
onMouseDownCapture={handleMouseDown}
>
<div className="m-editor-inline-ai-preview__header">
<span className="m-editor-inline-ai-preview__title">{labels.title}</span>
<span className="m-editor-inline-ai-preview__status">{statusText}</span>
Expand Down
5 changes: 2 additions & 3 deletions src/web-ui/src/tools/editor/meditor/components/Preview.scss
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@
margin: $size-gap-4 0;
padding: $size-gap-4;
background: $element-bg-subtle;
border: 1px solid rgba(255, 255, 255, 0.03);
border: 1px solid $border-base;
border-radius: $size-radius-base;
overflow-x: auto;

Expand Down Expand Up @@ -70,7 +70,7 @@

&-divider {
border: none;
border-top: 1px dashed rgba(255, 255, 255, 0.08);
border-top: 1px dashed $border-base;
margin: $size-gap-1 0;
}

Expand All @@ -80,4 +80,3 @@
word-break: break-word;
}
}

14 changes: 7 additions & 7 deletions src/web-ui/src/tools/editor/meditor/components/TiptapEditor.scss
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@

h1 {
font-size: $font-size-3xl;
color: #111111;
color: var(--color-text-primary);
text-align: center;
}

Expand Down Expand Up @@ -114,7 +114,7 @@
blockquote {
margin: 0;
padding-left: $size-gap-3;
border-left: 3px solid rgba(255, 255, 255, 0.15);
border-left: 3px solid $border-base;
}

pre {
Expand Down Expand Up @@ -309,8 +309,8 @@
height: 3.5rem;
padding-right: $size-gap-2;
border-radius: 999px;
background: rgba(255, 255, 255, 0.03);
border-color: rgba(255, 255, 255, 0.1);
background: $element-bg-subtle;
border-color: $border-base;
}

.bitfun-input {
Expand All @@ -330,7 +330,7 @@
padding: 0 $size-gap-2;
height: 2rem;
border-radius: 999px;
background: rgba(255, 255, 255, 0.05);
background: $element-bg-subtle;
color: var(--color-text-muted);
font-size: $font-size-xs;
white-space: nowrap;
Expand Down Expand Up @@ -389,8 +389,8 @@
transition: background $motion-fast $easing-standard, border-color $motion-fast $easing-standard, color $motion-fast $easing-standard;

&:hover {
background: rgba(255, 255, 255, 0.04);
border-color: rgba(255, 255, 255, 0.08);
background: $element-bg-subtle;
border-color: $border-base;
}
}

Expand Down
Loading
Loading