2 Commits

Author SHA1 Message Date
jonny f2f1ff2c10 Bump manifest version and update changelog
Update manifest.json to version 2026.03.11 and set version_name to "Supports 0.18.0 - 0.26.x". Also add a README changelog entry for 2026-03-10 noting remembered drag window size and removal of drag window animation. This prepares a small release update and documents the recent UI tweak.
2026-03-09 20:07:57 +08:00
jonny 5fac00b5ce - feat:记忆拖拽窗口大小和优化动画效果
Add persistent, robust scaling for the proportional editor and remove CSS transitions that interfered with instant restores. Introduces a storageKey, parseScale, applyScaleInstant and logic to restore scale synchronously from localStorage (for immediate UX) and asynchronously from chrome.storage.sync (best-effort), keeping localStorage in sync. Ensures pending RAF updates are flushed before persisting and guards against missing APIs or invalid values. Also removes transition properties in main.css so scale restores remain immediate and predictable.
2026-03-09 20:00:42 +08:00
4 changed files with 74 additions and 5 deletions
+1
View File
@@ -5,6 +5,7 @@ Chrome 应用商店:<https://chrome.google.com/webstore/detail/memos-bber/cbhj
一个通过浏览器插件发布 [Memos](https://usememos.com/) 的插件。基于 iSpeak-bber 修改,原作者为 [DreamyTZK](https://www.antmoe.com/)。
## 更新日志
- 20260310 记忆拖拽窗口大小,移除拖拽窗口动画
- 20260309 右键发送选中文本保持原格式,增加全屏和窗口放大功能
### 20260308 向前兼容到0.18.0,可能再往前也行,只测试到0.18.0
- 20260307 增加语言切换按钮以及韩语和日语支持,
-3
View File
@@ -44,9 +44,6 @@ a{color: #555;}
background-color: rgb(255,255,255);
margin-top:0.8rem;
padding: 0.6rem;
transition-property: all;
transition-timing-function: cubic-bezier(.4,0,.2,1);
transition-duration: .15s;
}
.memo-editor{
position: relative;
+71
View File
@@ -39,6 +39,8 @@ function initProportionalEditorResize() {
editor.style.minWidth = `${baseW}px`
editor.style.minHeight = `${baseH}px`
const storageKey = 'popupEditorScale'
let maxScale = 1
const computeMaxScale = () => {
// In popup mode, allow scaling up to Chrome's max popup size.
@@ -69,6 +71,15 @@ function initProportionalEditorResize() {
let rafId = 0
let pendingScale = null
const parseScale = (raw) => {
const s = typeof raw === 'number' && Number.isFinite(raw)
? raw
: typeof raw === 'string' && raw.trim() !== '' && !Number.isNaN(Number(raw))
? Number(raw)
: 1
return s > 0 ? s : 1
}
const readCurrentScale = () => {
const w = parseFloat(editor.style.width || '')
const h = parseFloat(editor.style.height || '')
@@ -83,6 +94,47 @@ function initProportionalEditorResize() {
editor.style.height = `${Math.round(baseH * s)}px`
}
const applyScaleInstant = (scale) => {
// In case CSS transitions exist (or get reintroduced), keep restores immediate.
const prevTransition = editor.style.transition
editor.style.transition = 'none'
applyScale(scale)
window.requestAnimationFrame(function () {
editor.style.transition = prevTransition
})
}
// Restore previously saved scale synchronously (localStorage) first.
// This makes the popup *feel* synchronous because it can apply before async chrome.storage returns.
let restoredFromLocal = false
let localScale = 1
try {
const raw = window.localStorage ? window.localStorage.getItem(storageKey) : null
const s = parseScale(raw)
if (s && s !== 1) {
localScale = s
restoredFromLocal = true
applyScaleInstant(s)
}
} catch (_) {
// ignore
}
// Restore from chrome.storage.sync (best-effort) and keep localStorage in sync.
try {
chrome.storage.sync.get({ [storageKey]: 1 }, function (items) {
const raw = items ? items[storageKey] : 1
const s = parseScale(raw)
const shouldApply = !restoredFromLocal || Math.abs(s - localScale) > 1e-6
if (shouldApply) applyScaleInstant(s)
try {
if (window.localStorage) window.localStorage.setItem(storageKey, String(s))
} catch (_) {}
})
} catch (_) {
// ignore
}
const scheduleApply = () => {
if (rafId) return
rafId = window.requestAnimationFrame(() => {
@@ -122,6 +174,25 @@ function initProportionalEditorResize() {
const endDrag = () => {
dragging = false
// Flush any pending RAF update before persisting.
if (pendingScale != null) {
applyScale(pendingScale)
pendingScale = null
}
// Persist current scale (best-effort).
try {
const s = readCurrentScale()
if (typeof s === 'number' && Number.isFinite(s)) {
try {
if (window.localStorage) window.localStorage.setItem(storageKey, String(s))
} catch (_) {}
chrome.storage.sync.set({ [storageKey]: s })
}
} catch (_) {
// ignore
}
}
handle.addEventListener('pointerup', endDrag)
+2 -2
View File
@@ -2,8 +2,8 @@
"manifest_version": 3,
"name": "__MSG_extName__",
"default_locale": "en",
"version": "2026.03.10",
"version_name": "Supports 0.18.0 to the latest version",
"version": "2026.03.11",
"version_name": "Supports 0.18.0 - 0.26.x",
"action": {
"default_popup": "popup.html",
"default_icon": "assets/logo_24x24.png",