修复日记长文输入布局并减少输入时正文回传

This commit is contained in:
2026-10-11 09:22:29 +08:00
parent 5365e13963
commit 1bafb01741
7 changed files with 25 additions and 8 deletions
+13
View File
@@ -1,6 +1,7 @@
const test=require('node:test');
const assert=require('node:assert/strict');
const path=require('node:path');
const fs=require('node:fs');
const createLoader=require('./load-module.cjs');
function setup(file,api={}) {
let definition,id=0;const timers=new Map(),storage=new Map(),writes=[];
@@ -15,6 +16,18 @@ test('diary input continues past 100 characters and never rewrites the native te
e.patches.length=0;
for(const length of [100,101,140,1000,5000]){const value='字'.repeat(length);e.page.onContentInput({detail:{value}});assert.equal(e.page.data.form.content,value);assert.equal(e.page.data.contentLength,length);}
assert.ok(e.patches.every(patch=>!('editorContent' in patch)));
assert.ok(e.patches.every(patch=>!('form.content' in patch)));
}
});
test('both diary templates explicitly allow 5000 characters and grow with long text',()=>{
for(const file of ['publish/publish','diary_edit/diary_edit']){
const base=path.join(__dirname,'../pages',file);
const template=fs.readFileSync(base+'.wxml','utf8');
const editor=template.match(/<textarea\b[^>]*class="[^"]*diary-editor[^"]*"[^>]*\/>/)[0];
assert.match(editor,/maxlength="5000"/);
assert.match(editor,/auto-height="\{\{true\}\}"/);
const styles=fs.readFileSync(base+'.wxss','utf8');
assert.doesNotMatch(styles,/textarea\.diary-editor\s*\{[^}]*[;{]\s*height\s*:/);
}
});
test('rapid typing writes a single draft, and leaving the page flushes the newest content',()=>{