mirror of
https://github.com/mountain-loop/yaak.git
synced 2026-04-05 08:47:05 +02:00
Adjust markdown editor
This commit is contained in:
@@ -4,13 +4,14 @@ import { useRef } from 'react';
|
|||||||
import Markdown from 'react-markdown';
|
import Markdown from 'react-markdown';
|
||||||
import remarkGfm from 'remark-gfm';
|
import remarkGfm from 'remark-gfm';
|
||||||
import { useKeyValue } from '../hooks/useKeyValue';
|
import { useKeyValue } from '../hooks/useKeyValue';
|
||||||
import {Editor} from "./core/Editor/Editor";
|
import type { EditorProps } from './core/Editor/Editor';
|
||||||
|
import { Editor } from './core/Editor/Editor';
|
||||||
import { IconButton } from './core/IconButton';
|
import { IconButton } from './core/IconButton';
|
||||||
import { SplitLayout } from './core/SplitLayout';
|
import { SplitLayout } from './core/SplitLayout';
|
||||||
import { VStack } from './core/Stacks';
|
import { VStack } from './core/Stacks';
|
||||||
import { Prose } from './Prose';
|
import { Prose } from './Prose';
|
||||||
|
|
||||||
interface Props {
|
interface Props extends Pick<EditorProps, 'heightMode'> {
|
||||||
placeholder: string;
|
placeholder: string;
|
||||||
className?: string;
|
className?: string;
|
||||||
defaultValue: string;
|
defaultValue: string;
|
||||||
@@ -18,7 +19,14 @@ interface Props {
|
|||||||
name: string;
|
name: string;
|
||||||
}
|
}
|
||||||
|
|
||||||
export function MarkdownEditor({ className, defaultValue, onChange, name, placeholder }: Props) {
|
export function MarkdownEditor({
|
||||||
|
className,
|
||||||
|
defaultValue,
|
||||||
|
onChange,
|
||||||
|
name,
|
||||||
|
placeholder,
|
||||||
|
heightMode,
|
||||||
|
}: Props) {
|
||||||
const containerRef = useRef<HTMLDivElement>(null);
|
const containerRef = useRef<HTMLDivElement>(null);
|
||||||
|
|
||||||
const [width] = useSize(containerRef.current);
|
const [width] = useSize(containerRef.current);
|
||||||
@@ -39,13 +47,14 @@ export function MarkdownEditor({ className, defaultValue, onChange, name, placeh
|
|||||||
|
|
||||||
const editor = (
|
const editor = (
|
||||||
<Editor
|
<Editor
|
||||||
className="max-w-xl"
|
hideGutter
|
||||||
|
wrapLines
|
||||||
|
className="max-w-2xl max-h-full"
|
||||||
language="markdown"
|
language="markdown"
|
||||||
defaultValue={defaultValue}
|
defaultValue={defaultValue}
|
||||||
onChange={onChange}
|
onChange={onChange}
|
||||||
placeholder={placeholder}
|
placeholder={placeholder}
|
||||||
hideGutter
|
heightMode={heightMode}
|
||||||
wrapLines
|
|
||||||
/>
|
/>
|
||||||
);
|
);
|
||||||
|
|
||||||
@@ -96,11 +105,11 @@ export function MarkdownEditor({ className, defaultValue, onChange, name, placeh
|
|||||||
<div
|
<div
|
||||||
ref={containerRef}
|
ref={containerRef}
|
||||||
className={classNames(
|
className={classNames(
|
||||||
'w-full h-full pt-1.5 group rounded-md grid grid-cols-[minmax(0,1fr)_auto]',
|
'w-full h-full pt-1.5 group rounded-md grid grid-cols-[minmax(0,1fr)_auto] grid-rows-1 gap-x-1.5',
|
||||||
className,
|
className,
|
||||||
)}
|
)}
|
||||||
>
|
>
|
||||||
<div className="pr-8 h-full w-full">{contents}</div>
|
<div className="h-full w-full">{contents}</div>
|
||||||
<VStack
|
<VStack
|
||||||
space={1}
|
space={1}
|
||||||
className="bg-surface opacity-20 group-hover:opacity-100 transition-opacity transform-gpu"
|
className="bg-surface opacity-20 group-hover:opacity-100 transition-opacity transform-gpu"
|
||||||
|
|||||||
@@ -16,7 +16,7 @@ export function WorkspaceSettingsDialog({ workspaceId }: Props) {
|
|||||||
if (workspace == null) return null;
|
if (workspace == null) return null;
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<VStack space={3} className="pb-3">
|
<VStack space={3} className="pb-3 max-h-[50vh]">
|
||||||
<PlainInput
|
<PlainInput
|
||||||
label="Workspace Name"
|
label="Workspace Name"
|
||||||
defaultValue={workspace.name}
|
defaultValue={workspace.name}
|
||||||
@@ -29,6 +29,7 @@ export function WorkspaceSettingsDialog({ workspaceId }: Props) {
|
|||||||
className="min-h-[10rem] border border-border px-2"
|
className="min-h-[10rem] border border-border px-2"
|
||||||
defaultValue={workspace.description}
|
defaultValue={workspace.description}
|
||||||
onChange={(description) => updateWorkspace.mutate({ description })}
|
onChange={(description) => updateWorkspace.mutate({ description })}
|
||||||
|
heightMode='auto'
|
||||||
/>
|
/>
|
||||||
</VStack>
|
</VStack>
|
||||||
);
|
);
|
||||||
|
|||||||
@@ -49,7 +49,7 @@ export const WorkspaceActionsDropdown = memo(function WorkspaceActionsDropdown({
|
|||||||
const extraItems: DropdownItem[] = [
|
const extraItems: DropdownItem[] = [
|
||||||
{
|
{
|
||||||
key: 'workspace-settings',
|
key: 'workspace-settings',
|
||||||
label: 'Settings',
|
label: 'Workspace Settings',
|
||||||
leftSlot: <Icon icon="settings" />,
|
leftSlot: <Icon icon="settings" />,
|
||||||
onSelect: async () => {
|
onSelect: async () => {
|
||||||
dialog.show({
|
dialog.show({
|
||||||
|
|||||||
Reference in New Issue
Block a user