Compare commits

...

2 Commits

Author SHA1 Message Date
Jim Liu 宝玉 502d2448b2 chore: release v1.28.3 2026-02-03 11:06:59 -06:00
Jim Liu 宝玉 b9e48d9483 fix(baoyu-post-to-wechat): fix placeholder matching to avoid WECHATIMGPH_1 matching WECHATIMGPH_10 2026-02-03 11:06:41 -06:00
4 changed files with 30 additions and 11 deletions
+1 -1
View File
@@ -6,7 +6,7 @@
}, },
"metadata": { "metadata": {
"description": "Skills shared by Baoyu for improving daily work efficiency", "description": "Skills shared by Baoyu for improving daily work efficiency",
"version": "1.28.2" "version": "1.28.3"
}, },
"plugins": [ "plugins": [
{ {
+5
View File
@@ -2,6 +2,11 @@
English | [中文](./CHANGELOG.zh.md) English | [中文](./CHANGELOG.zh.md)
## 1.28.3 - 2026-02-03
### Fixes
- `baoyu-post-to-wechat`: fix placeholder matching issue where `WECHATIMGPH_1` incorrectly matched `WECHATIMGPH_10`.
## 1.28.2 - 2026-02-03 ## 1.28.2 - 2026-02-03
### Fixes ### Fixes
+5
View File
@@ -2,6 +2,11 @@
[English](./CHANGELOG.md) | 中文 [English](./CHANGELOG.md) | 中文
## 1.28.3 - 2026-02-03
### 修复
- `baoyu-post-to-wechat`:修复占位符匹配问题(`WECHATIMGPH_1` 错误匹配 `WECHATIMGPH_10`)。
## 1.28.2 - 2026-02-03 ## 1.28.2 - 2026-02-03
### 修复 ### 修复
@@ -273,22 +273,31 @@ async function selectAndReplacePlaceholder(session: ChromeSession, placeholder:
const editor = document.querySelector('.ProseMirror'); const editor = document.querySelector('.ProseMirror');
if (!editor) return false; if (!editor) return false;
const placeholder = ${JSON.stringify(placeholder)};
const walker = document.createTreeWalker(editor, NodeFilter.SHOW_TEXT, null, false); const walker = document.createTreeWalker(editor, NodeFilter.SHOW_TEXT, null, false);
let node; let node;
while ((node = walker.nextNode())) { while ((node = walker.nextNode())) {
const text = node.textContent || ''; const text = node.textContent || '';
const idx = text.indexOf(${JSON.stringify(placeholder)}); let searchStart = 0;
if (idx !== -1) { let idx;
node.parentElement.scrollIntoView({ behavior: 'smooth', block: 'center' }); // Search for exact match (not prefix of longer placeholder like XIMGPH_1 in XIMGPH_10)
while ((idx = text.indexOf(placeholder, searchStart)) !== -1) {
const afterIdx = idx + placeholder.length;
const charAfter = text[afterIdx];
// Exact match if next char is not a digit
if (charAfter === undefined || !/\\d/.test(charAfter)) {
node.parentElement.scrollIntoView({ behavior: 'smooth', block: 'center' });
const range = document.createRange(); const range = document.createRange();
range.setStart(node, idx); range.setStart(node, idx);
range.setEnd(node, idx + ${placeholder.length}); range.setEnd(node, idx + placeholder.length);
const sel = window.getSelection(); const sel = window.getSelection();
sel.removeAllRanges(); sel.removeAllRanges();
sel.addRange(range); sel.addRange(range);
return true; return true;
}
searchStart = afterIdx;
} }
} }
return false; return false;