jialinyyzz commited on
Commit
5785458
·
verified ·
1 Parent(s): 9da9b01

Create fact: one-line how-to under the draft whenever it has text

Browse files
Files changed (3) hide show
  1. page.js +6 -3
  2. page.py +2 -0
  3. style.css +3 -0
page.js CHANGED
@@ -117,7 +117,10 @@
117
  function renderFacts(fresh) {
118
  var panel = $('#facts-panel'), list = $('#facts-list'), cnt = $('#facts-count');
119
  if (!panel || !list) return;
120
- panel.hidden = !facts.length;
 
 
 
121
  if (cnt) cnt.textContent = facts.length > 1 ? String(facts.length) : '';
122
  list.textContent = '';
123
  facts.forEach(function (f, i) {
@@ -350,9 +353,9 @@
350
 
351
  document.addEventListener('input', function (e) {
352
  if (e.target && e.target.closest && e.target.closest('#draft')) {
353
- var n = facts.length;
354
  pruneFacts();
355
- if (facts.length !== n) renderFacts();
356
  updateCount();
357
  updatePop();
358
  }
 
117
  function renderFacts(fresh) {
118
  var panel = $('#facts-panel'), list = $('#facts-list'), cnt = $('#facts-count');
119
  if (!panel || !list) return;
120
+ // shown whenever the draft has text: with no facts yet it explains how to add one
121
+ panel.hidden = !facts.length && !draftValue().trim();
122
+ var hint = $('#facts-hint');
123
+ if (hint) hint.hidden = facts.length > 0;
124
  if (cnt) cnt.textContent = facts.length > 1 ? String(facts.length) : '';
125
  list.textContent = '';
126
  facts.forEach(function (f, i) {
 
353
 
354
  document.addEventListener('input', function (e) {
355
  if (e.target && e.target.closest && e.target.closest('#draft')) {
356
+ var n = facts.length, shown = !$('#facts-panel').hidden;
357
  pruneFacts();
358
+ if (facts.length !== n || shown !== !!draftValue().trim()) renderFacts();
359
  updateCount();
360
  updatePop();
361
  }
page.py CHANGED
@@ -138,6 +138,8 @@ def draft_foot(examples) -> str:
138
  "长文档改写可能出现事实偏差,建议检查结果,或让 AI 把改错的地方纠正一下。")}</span></p>
139
  <div class="factbar" id="facts-panel" hidden>
140
  <span class="factbar-label" data-title-en="{html.escape(FACT_HELP['en'])}" data-title-zh="{html.escape(FACT_HELP['zh'])}">{icon("lock")}{L("Facts", "原样保留")}<span class="factbar-count mono" id="facts-count"></span></span>
 
 
141
  <ul class="factbar-list" id="facts-list"></ul>
142
  </div>
143
  <div class="sheet-foot">
 
138
  "长文档改写可能出现事实偏差,建议检查结果,或让 AI 把改错的地方纠正一下。")}</span></p>
139
  <div class="factbar" id="facts-panel" hidden>
140
  <span class="factbar-label" data-title-en="{html.escape(FACT_HELP['en'])}" data-title-zh="{html.escape(FACT_HELP['zh'])}">{icon("lock")}{L("Facts", "原样保留")}<span class="factbar-count mono" id="facts-count"></span></span>
141
+ <p class="factbar-hint" id="facts-hint">{L("Select a name, number, quote or term in the draft and click Create fact: it comes back word for word.",
142
+ "在草稿里选中名字、数字、引文或术语,点「原样保留」,改写时一字不改。")}</p>
143
  <ul class="factbar-list" id="facts-list"></ul>
144
  </div>
145
  <div class="sheet-foot">
style.css CHANGED
@@ -420,6 +420,9 @@ html[data-lang="zh"] .sec-title { letter-spacing: -.01em; }
420
  .factbar-label svg { width: 15px; height: 15px; color: var(--ink-3); }
421
  .factbar-count { color: var(--ink-3); font-weight: 400; font-size: 11px; }
422
  .factbar-list { list-style: none; margin: 0 !important; padding: 0 !important; display: flex; flex-wrap: wrap; gap: 6px; min-width: 0; }
 
 
 
423
  .fact-chip {
424
  display: inline-flex; align-items: center; gap: 2px; max-width: 260px; height: 26px; margin: 0 !important; padding: 0 3px 0 10px;
425
  border-radius: 999px; background: var(--sunk); border: 1px solid var(--line); font-size: 12.5px; color: var(--ink);
 
420
  .factbar-label svg { width: 15px; height: 15px; color: var(--ink-3); }
421
  .factbar-count { color: var(--ink-3); font-weight: 400; font-size: 11px; }
422
  .factbar-list { list-style: none; margin: 0 !important; padding: 0 !important; display: flex; flex-wrap: wrap; gap: 6px; min-width: 0; }
423
+ .factbar-list:empty { display: none; }
424
+ .factbar-hint { margin: 0 !important; min-height: 26px; display: flex; align-items: center; font-size: 12.5px; line-height: 1.4; color: var(--ink-3); }
425
+ .factbar-hint[hidden] { display: none; }
426
  .fact-chip {
427
  display: inline-flex; align-items: center; gap: 2px; max-width: 260px; height: 26px; margin: 0 !important; padding: 0 3px 0 10px;
428
  border-radius: 999px; background: var(--sunk); border: 1px solid var(--line); font-size: 12.5px; color: var(--ink);