Skip to content

Commit

Permalink
🔖 v2.3.5
Browse files Browse the repository at this point in the history
  • Loading branch information
Achuan-2 committed Nov 4, 2024
1 parent b7e0e6c commit 0c75606
Show file tree
Hide file tree
Showing 7 changed files with 252 additions and 57 deletions.
85 changes: 85 additions & 0 deletions 1.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,85 @@

(async () => {

window.addEventListener('keydown', function (event) {
// 检查是否按下了 Alt 键和数字 5 键
if (event.altKey && event.key === '5') {
// 模拟按钮点击
console.log('Alt + 5 被按下了!');
dailynoteAddDatabase();
}
});

async function dailynoteAddDatabase() {
//设置日记自动存放的数据库块id
dbBlockId = '20240911002857-lgav146';
// 获取当前选择笔记本
boxid = window.siyuan.storage["local-dailynoteid"]

// 调用/api/filetree/createDailyNote获得日记id
const create_dailynote_result = await fetchSyncPost('/api/filetree/createDailyNote', { notebook: boxid, app: siyuan.ws.app.appId })
const docID = create_dailynote_result.data.id;

// 添加日记到数据库中
const db = await getDataBySql(`SELECT * FROM blocks where type ='av' and id='${dbBlockId}'`);
if (db.length === 0) error("未找到数据库文档块,请检查数据库文档块id是否正确");
const avId = db.map(av => getDataAvIdFromHtml(av.markdown))[0];


// 组装文档数据参数
const srcs = {
"id": docID,
"isDetached": false,
};
const input = {
"avID": avId,
"blockID": dbBlockId,
'srcs': srcs

}
const result = await fetchSyncPost('/api/av/addAttributeViewBlocks', input)
//console.log(result);




function getDataAvIdFromHtml(htmlString) {
// 使用正则表达式匹配data-av-id的值
const match = htmlString.match(/data-av-id="([^"]+)"/);
if (match && match[1]) {
return match[1]; // 返回匹配的值
}
return ""; // 如果没有找到匹配项,则返回空
}
async function getDataBySql(sql) {
const result = await fetchSyncPost('/api/query/sql', { "stmt": sql });
if (result.code !== 0) {
console.error("查询数据库出错", result.msg);
return [];
}
return result.data;
}
async function fetchSyncPost(url, data, returnType = 'json') {
const init = {
method: "POST",
};
if (data) {
if (data instanceof FormData) {
init.body = data;
} else {
init.body = JSON.stringify(data);
}
}
try {
const res = await fetch(url, init);
const res2 = returnType === 'json' ? await res.json() : await res.text();
return res2;
} catch (e) {
console.log(e);
return returnType === 'json' ? { code: e.code || 1, msg: e.message || "", data: null } : "";
}
}

}

})();
3 changes: 2 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
## v2.3.4 / 2024.11.03
## v2.3.5 / 2024.11.03
- 💄Tsundoku 引述块大大增强
* 引述块添加背景色,嵌套引述块的border颜色为对应颜色
* 引述块添加卡片背景色,嵌套引述块的border颜色可以进一步修改
* 引述块添加不同背景色,对代码块样式进行优化


## v2.3.3 / 2024.11.03
Expand Down
6 changes: 2 additions & 4 deletions style/editor.css
Original file line number Diff line number Diff line change
Expand Up @@ -528,13 +528,11 @@ mark {
}

/* -----------------------加粗----------------------- */
.protyle-wysiwyg span[data-type~='strong'] {
.protyle-wysiwyg span[data-type~='strong'] {
color: inherit;
}

[data-theme-mode="dark"] .protyle-wysiwyg span[data-type~='strong'] {
color: #81ebcf;
}


/* -----------------------块引用----------------------- */
.protyle-wysiwyg [data-node-id] span[data-type~=block-ref]:not(.av__celltext),
Expand Down
Loading

0 comments on commit 0c75606

Please sign in to comment.