root commited on
Commit
b18394e
·
1 Parent(s): 8a6a2bc

批注原句改过时带到大致位置

Browse files
fanqie/dist/index.html CHANGED
@@ -8,7 +8,7 @@
8
  <title>小说写作台</title>
9
  <link rel="icon" href="data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 64 64'%3E%3Crect width='64' height='64' rx='12' fill='%23b8432f'/%3E%3Ctext x='32' y='44' font-size='34' text-anchor='middle' fill='%23fff' font-family='serif'%3E%E6%96%87%3C/text%3E%3C/svg%3E" />
10
  <script>try{var t=localStorage.getItem('xs_theme');if(t==='night')document.documentElement.dataset.theme='night'}catch(e){}</script>
11
- <script type="module" crossorigin src="/assets/index-C12HIUpY.js"></script>
12
  <link rel="stylesheet" crossorigin href="/assets/index-D_zwU3UE.css">
13
  </head>
14
  <body>
 
8
  <title>小说写作台</title>
9
  <link rel="icon" href="data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 64 64'%3E%3Crect width='64' height='64' rx='12' fill='%23b8432f'/%3E%3Ctext x='32' y='44' font-size='34' text-anchor='middle' fill='%23fff' font-family='serif'%3E%E6%96%87%3C/text%3E%3C/svg%3E" />
10
  <script>try{var t=localStorage.getItem('xs_theme');if(t==='night')document.documentElement.dataset.theme='night'}catch(e){}</script>
11
+ <script type="module" crossorigin src="/assets/index-qhWvnfsQ.js"></script>
12
  <link rel="stylesheet" crossorigin href="/assets/index-D_zwU3UE.css">
13
  </head>
14
  <body>
public/assets/{index-C12HIUpY.js → index-qhWvnfsQ.js} RENAMED
The diff for this file is too large to render. See raw diff
 
public/index.html CHANGED
@@ -8,7 +8,7 @@
8
  <title>小说写作台</title>
9
  <link rel="icon" href="data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 64 64'%3E%3Crect width='64' height='64' rx='12' fill='%23b8432f'/%3E%3Ctext x='32' y='44' font-size='34' text-anchor='middle' fill='%23fff' font-family='serif'%3E%E6%96%87%3C/text%3E%3C/svg%3E" />
10
  <script>try{var t=localStorage.getItem('xs_theme');if(t==='night')document.documentElement.dataset.theme='night'}catch(e){}</script>
11
- <script type="module" crossorigin src="/assets/index-C12HIUpY.js"></script>
12
  <link rel="stylesheet" crossorigin href="/assets/index-D_zwU3UE.css">
13
  </head>
14
  <body>
 
8
  <title>小说写作台</title>
9
  <link rel="icon" href="data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 64 64'%3E%3Crect width='64' height='64' rx='12' fill='%23b8432f'/%3E%3Ctext x='32' y='44' font-size='34' text-anchor='middle' fill='%23fff' font-family='serif'%3E%E6%96%87%3C/text%3E%3C/svg%3E" />
10
  <script>try{var t=localStorage.getItem('xs_theme');if(t==='night')document.documentElement.dataset.theme='night'}catch(e){}</script>
11
+ <script type="module" crossorigin src="/assets/index-qhWvnfsQ.js"></script>
12
  <link rel="stylesheet" crossorigin href="/assets/index-D_zwU3UE.css">
13
  </head>
14
  <body>
ui-src/src/rooms/Editor.tsx CHANGED
@@ -134,10 +134,17 @@ export default function ChapterEditor({ ctx, chapter }: { ctx: BookCtx; chapter:
134
  const n = located.find(x => x.note_id === nid)
135
  setInspector(true); setTab('notes')
136
  if (!n) return toast('这条批注已被删除', 'err')
137
- if (n.at < 0) { setActiveNote(nid); if (n.quote) toast('原句已经改动过,正文里找不到原位置了', 'err'); return }
 
 
 
 
 
 
 
138
  setReviewMode(true)
139
  setTimeout(() => { setActiveNote(''); setTimeout(() => setActiveNote(nid), 0) }, 250)
140
- }, [ready, nb.notes, located])
141
  const onScroll = () => {
142
  const el = scrollRef.current
143
  if (!el) return
 
134
  const n = located.find(x => x.note_id === nid)
135
  setInspector(true); setTab('notes')
136
  if (!n) return toast('这条批注已被删除', 'err')
137
+ if (n.at < 0) {
138
+ setActiveNote(nid)
139
+ if (!n.quote) return
140
+ // 原句已改:带到原来的大致位置
141
+ const r = text.length ? Math.min(1, Math.max(0, (n.start || 0) / text.length)) : 0
142
+ requestAnimationFrame(() => { const el = scrollRef.current; if (el) { lastRatio.current = r; el.scrollTo({ top: r * (el.scrollHeight - el.clientHeight), behavior: 'smooth' }) } })
143
+ toast('这句已经改过了,已带你到原来的大致位置', 'ok'); return
144
+ }
145
  setReviewMode(true)
146
  setTimeout(() => { setActiveNote(''); setTimeout(() => setActiveNote(nid), 0) }, 250)
147
+ }, [ready, nb.notes, located, text])
148
  const onScroll = () => {
149
  const el = scrollRef.current
150
  if (!el) return