Shrink ignores what cannot be seen; blank lines at a block's end go
Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
This commit is contained in:
1 parent
bb41047e85
commit
56ab259cd4
5 files changed
+158
-11
No files matched your search
@@ -14,7 +14,7 @@ import { randomId } from './crypto.js';
|
||||
import { textBounds } from './page_model.js';
|
||||
import { TEXT_FRAME_WIDTH, TEXT_MARK } from './page_file.js';
|
||||
import { HOLD_MS, HOLD_SLACK_PX } from './pen_input.js';
|
||||
import { LEFT_GAP, LINE_HEIGHT, TOP_GAP, baselineOf, fontMetrics, layoutText } from './text_layout.js';
|
||||
import { LEFT_GAP, LINE_HEIGHT, TOP_GAP, baselineOf, fontMetrics, layoutText, trimTrailingBlankLines } from './text_layout.js';
|
||||
|
||||
/** @typedef {import('./page_model.js').TextBlock} TextBlock */
|
||||
/** @typedef {import('./page_model.js').TextFont} TextFont */
|
||||
@@ -206,7 +206,10 @@ export class TextEditor {
|
||||
this.field.setSelectionRange(block.text.length, block.text.length);
|
||||
}
|
||||
|
||||
/** Finish editing. An empty block is removed. */
|
||||
/**
|
||||
* Finish editing. The blank lines at the end go (Andy, 2026-10-14),
|
||||
* and an empty block is removed.
|
||||
*/
|
||||
stop() {
|
||||
const block = this.block;
|
||||
if (!block) return;
|
||||
@@ -215,6 +218,7 @@ export class TextEditor {
|
||||
this.field.hidden = true;
|
||||
this.mark.hidden = true;
|
||||
this.field.value = '';
|
||||
trimTrailingBlankLines(block);
|
||||
if (block.text.trim() === '') this.target.removeText(block.id);
|
||||
else this.target.setText(block);
|
||||
this.target.endEdit?.(block.id);
|
||||
|
||||
Reference in new issue
Block a user