mirror of
https://github.com/priyanshujain/margin.git
synced 2026-10-02 11:07:04 +00:00
changes
This commit is contained in:
1 parent
f47e822497
commit
11df8697b1
3 files changed
+44
-7
No files matched your search
Generated
+1
-1
@@ -4713,7 +4713,7 @@ checksum = "3e2e65a1a2e43cfcb47a895c4c8b10d1f4a61097f9f254f183aee60cad9c651d"
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "margin-app"
|
name = "margin-app"
|
||||||
version = "0.1.6"
|
version = "0.1.7"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"base64 0.22.1",
|
"base64 0.22.1",
|
||||||
"fontdb",
|
"fontdb",
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
import { useCallback, useEffect, useState } from "react";
|
import { useCallback, useEffect, useLayoutEffect, useRef, useState } from "react";
|
||||||
import type { Editor as TiptapEditor } from "@tiptap/react";
|
import type { Editor as TiptapEditor } from "@tiptap/react";
|
||||||
import { Sidebar } from "./Sidebar";
|
import { Sidebar } from "./Sidebar";
|
||||||
import { Dock } from "./Dock";
|
import { Dock } from "./Dock";
|
||||||
@@ -258,15 +258,13 @@ export function EditorView() {
|
|||||||
<article className="sheet">
|
<article className="sheet">
|
||||||
<header className="chapter-opener">
|
<header className="chapter-opener">
|
||||||
<div className="chapter-num">{eyebrow}</div>
|
<div className="chapter-num">{eyebrow}</div>
|
||||||
<input
|
<ChapterTitleInput
|
||||||
className="chapter-title-input"
|
|
||||||
value={chapter.noTitle ? "" : chapter.title}
|
value={chapter.noTitle ? "" : chapter.title}
|
||||||
placeholder={
|
placeholder={
|
||||||
chapter.noTitle ? "No title" : kind === "body" ? "Chapter title" : kind === "part" ? "Part title (optional)" : "Page title"
|
chapter.noTitle ? "No title" : kind === "body" ? "Chapter title" : kind === "part" ? "Part title (optional)" : "Page title"
|
||||||
}
|
}
|
||||||
spellCheck={false}
|
disabled={!!chapter.noTitle}
|
||||||
disabled={chapter.noTitle}
|
onChange={(value) => setChapterTitle(chapter.id, value)}
|
||||||
onChange={(e) => setChapterTitle(chapter.id, e.target.value)}
|
|
||||||
/>
|
/>
|
||||||
{(chapter.noTitle || !chapter.title.trim()) && (
|
{(chapter.noTitle || !chapter.title.trim()) && (
|
||||||
<label className="no-title-check">
|
<label className="no-title-check">
|
||||||
@@ -336,3 +334,38 @@ export function EditorView() {
|
|||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function ChapterTitleInput({
|
||||||
|
value,
|
||||||
|
placeholder,
|
||||||
|
disabled,
|
||||||
|
onChange,
|
||||||
|
}: {
|
||||||
|
value: string;
|
||||||
|
placeholder: string;
|
||||||
|
disabled: boolean;
|
||||||
|
onChange: (value: string) => void;
|
||||||
|
}) {
|
||||||
|
const ref = useRef<HTMLTextAreaElement>(null);
|
||||||
|
|
||||||
|
useLayoutEffect(() => {
|
||||||
|
const el = ref.current;
|
||||||
|
if (!el) return;
|
||||||
|
el.style.height = "auto";
|
||||||
|
el.style.height = `${el.scrollHeight}px`;
|
||||||
|
}, [value, disabled]);
|
||||||
|
|
||||||
|
return (
|
||||||
|
<textarea
|
||||||
|
ref={ref}
|
||||||
|
className="chapter-title-input"
|
||||||
|
rows={1}
|
||||||
|
value={value}
|
||||||
|
placeholder={placeholder}
|
||||||
|
spellCheck={false}
|
||||||
|
disabled={disabled}
|
||||||
|
onKeyDown={(e) => e.key === "Enter" && e.preventDefault()}
|
||||||
|
onChange={(e) => onChange(e.target.value)}
|
||||||
|
/>
|
||||||
|
);
|
||||||
|
}
|
||||||
@@ -654,6 +654,7 @@ body.resizing {
|
|||||||
}
|
}
|
||||||
|
|
||||||
.chapter-title-input {
|
.chapter-title-input {
|
||||||
|
display: block;
|
||||||
width: 100%;
|
width: 100%;
|
||||||
margin: 15px 0 0;
|
margin: 15px 0 0;
|
||||||
padding: 0;
|
padding: 0;
|
||||||
@@ -666,6 +667,9 @@ body.resizing {
|
|||||||
line-height: 1.16;
|
line-height: 1.16;
|
||||||
letter-spacing: -0.01em;
|
letter-spacing: -0.01em;
|
||||||
color: var(--ink);
|
color: var(--ink);
|
||||||
|
resize: none;
|
||||||
|
overflow: hidden;
|
||||||
|
overflow-wrap: break-word;
|
||||||
}
|
}
|
||||||
|
|
||||||
.chapter-title-input:focus {
|
.chapter-title-input:focus {
|
||||||
|
|||||||
Reference in new issue
Block a user