An open-source, privacy-first, self-hosted knowledge workspace where humans and AI agents work together 开源、隐私优先、自托管的知识工作空间,让人与智能体在此协作
TypeScript agentic-aiai-agentknowledge-baselocal-firstmarkdownmcpmindmapnote-takingself-hostedsiyuanworkspace
:sparkles: Focus primary field when opening calendar entries https://github.com/siyuan-note/siyuan/issues/19819
Daniel649e1d961bea
diff --git a/app/guide/20210808180117-6v0mkxr/20200923234011-ieuun1p/20210808180303-xaduj2o/20240208172514-9dsv6na.sy b/app/guide/20210808180117-6v0mkxr/20200923234011-ieuun1p/20210808180303-xaduj2o/20240208172514-9dsv6na.syindex eaf412e94e..53683f46b6 100644--- a/app/guide/20210808180117-6v0mkxr/20200923234011-ieuun1p/20210808180303-xaduj2o/20240208172514-9dsv6na.sy+++ b/app/guide/20210808180117-6v0mkxr/20200923234011-ieuun1p/20210808180303-xaduj2o/20240208172514-9dsv6na.sy@@ -7,7 +7,7 @@"id": "20240208172514-9dsv6na","title": "Database","type": "doc",- "updated": "20260923103343"+ "updated": "20260924110133"},"Children": [{@@ -687,7 +687,7 @@"HeadingLevel": 3,"Properties": {"id": "20260920225154-tz8a00o",- "updated": "20260923103343"+ "updated": "20260924110133"},"Children": [{@@ -716,7 +716,7 @@"ListData": {},"Properties": {"id": "20260920225154-qqxdh7e",- "updated": "20260923095432"+ "updated": "20260924110133"},"Children": [{@@ -830,7 +830,7 @@},"Properties": {"id": "20260920225154-ronkl9y",- "updated": "20260921201901"+ "updated": "20260924110133"},"Children": [{@@ -838,12 +838,12 @@"Type": "NodeParagraph","Properties": {"id": "20260920225154-3lkyx9g",- "updated": "20260921201901"+ "updated": "20260924110133"},"Children": [{"Type": "NodeText",- "Data": "Editing: Click an entry to open its existing database entry editor. With an ordinary date field, use the plus button on a day to create an entry, drag an entry to move its dates, or drag its end handles to adjust its range. Use No date beside the view filter to search undated entries, then drag one onto a day or select it and choose a day, including on touch screens. This assigns an all-day date; clearing it returns the entry to the undated list. Date changes support undo. On touch screens, use the move handle on an existing calendar entry to drag it. New entries focus the primary field automatically. Dragging previews the resulting dates and highlights their cells; changes are saved on release. The context menu also offers copying, creating and binding documents, adding to another database, editing fields, and creating an entry on the selected date"+ "Data": "Editing: Click an entry to open its existing database entry editor. With an ordinary date field, use the plus button on a day to create an entry, drag an entry to move its dates, or drag its end handles to adjust its range. Use No date beside the view filter to search undated entries, then drag one onto a day or select it and choose a day, including on touch screens. This assigns an all-day date; clearing it returns the entry to the undated list. Date changes support undo. On touch screens, use the move handle on an existing calendar entry to drag it. Opening or creating an entry automatically focuses the primary field. Dragging previews the resulting dates and highlights their cells; changes are saved on release. The context menu also offers copying, creating and binding documents, adding to another database, editing fields, and creating an entry on the selected date"}]}diff --git a/app/guide/20210808180117-czj9bvb/20200812220555-lj3enxa/20210808180321-hbvl5c2/20240208113259-nykkvaq.sy b/app/guide/20210808180117-czj9bvb/20200812220555-lj3enxa/20210808180321-hbvl5c2/20240208113259-nykkvaq.syindex bb41c6e06c..cd1fc8ef2a 100644--- a/app/guide/20210808180117-czj9bvb/20200812220555-lj3enxa/20210808180321-hbvl5c2/20240208113259-nykkvaq.sy+++ b/app/guide/20210808180117-czj9bvb/20200812220555-lj3enxa/20210808180321-hbvl5c2/20240208113259-nykkvaq.sy@@ -7,7 +7,7 @@"id": "20240208113259-nykkvaq","title": "数据库","type": "doc",- "updated": "20260923103343"+ "updated": "20260924110133"},"Children": [{@@ -687,7 +687,7 @@"HeadingLevel": 3,"Properties": {"id": "20260920225154-xtg5hn3",- "updated": "20260923103343"+ "updated": "20260924110133"},"Children": [{@@ -716,7 +716,7 @@"ListData": {},"Properties": {"id": "20260920225154-09h9ysf",- "updated": "20260923095432"+ "updated": "20260924110133"},"Children": [{@@ -830,7 +830,7 @@},"Properties": {"id": "20260920225154-4u642qz",- "updated": "20260921201901"+ "updated": "20260924110133"},"Children": [{@@ -838,12 +838,12 @@"Type": "NodeParagraph","Properties": {"id": "20260920225154-gev35tw",- "updated": "20260921201901"+ "updated": "20260924110133"},"Children": [{"Type": "NodeText",- "Data": "编辑条目:点击条目使用现有数据库条目编辑界面。使用普通日期字段时,可通过日期格内的加号创建条目,拖动条目调整日期,或拖动两端调整日期范围。点击视图筛选旁的无日期按钮,可搜索未安排的条目;将条目拖到日期格,或先选中条目再点选日期格,触屏设备也可使用后一种方式。排期会填写全天日期,清空日期后条目会回到无日期列表。日期修改支持撤销,触屏设备可拖动日历中已有条目上的移动手柄。新建后自动聚焦主键字段;拖动时预览调整后的日期范围并高亮对应日期格,松手后保存。右键菜单还支持复制、新建文档并绑定、添加到其他数据库、编辑字段及在所选日期新建条目"+ "Data": "编辑条目:点击条目使用现有数据库条目编辑界面。使用普通日期字段时,可通过日期格内的加号创建条目,拖动条目调整日期,或拖动两端调整日期范围。点击视图筛选旁的无日期按钮,可搜索未安排的条目;将条目拖到日期格,或先选中条目再点选日期格,触屏设备也可使用后一种方式。排期会填写全天日期,清空日期后条目会回到无日期列表。日期修改支持撤销,触屏设备可拖动日历中已有条目上的移动手柄。点击或新建条目后自动聚焦主键字段;拖动时预览调整后的日期范围并高亮对应日期格,松手后保存。右键菜单还支持复制、新建文档并绑定、添加到其他数据库、编辑字段及在所选日期新建条目"}]}diff --git a/app/guide/20211226090932-5lcq56f/20211226115423-d5z1joq/20211226121203-rjjngpz/20240208171522-y7dxcno.sy b/app/guide/20211226090932-5lcq56f/20211226115423-d5z1joq/20211226121203-rjjngpz/20240208171522-y7dxcno.syindex f9afdc7f2b..b56ffa3743 100644--- a/app/guide/20211226090932-5lcq56f/20211226115423-d5z1joq/20211226121203-rjjngpz/20240208171522-y7dxcno.sy+++ b/app/guide/20211226090932-5lcq56f/20211226115423-d5z1joq/20211226121203-rjjngpz/20240208171522-y7dxcno.sy@@ -7,7 +7,7 @@"id": "20240208171522-y7dxcno","title": "資料庫","type": "doc",- "updated": "20260923103343"+ "updated": "20260924110133"},"Children": [{@@ -687,7 +687,7 @@"HeadingLevel": 3,"Properties": {"id": "20260920225154-xknvq29",- "updated": "20260923103343"+ "updated": "20260924110133"},"Children": [{@@ -716,7 +716,7 @@"ListData": {},"Properties": {"id": "20260920225154-mpwyzfe",- "updated": "20260923095432"+ "updated": "20260924110133"},"Children": [{@@ -830,7 +830,7 @@},"Properties": {"id": "20260920225154-8jo2ad8",- "updated": "20260921201901"+ "updated": "20260924110133"},"Children": [{@@ -838,12 +838,12 @@"Type": "NodeParagraph","Properties": {"id": "20260920225154-wxzch42",- "updated": "20260921201901"+ "updated": "20260924110133"},"Children": [{"Type": "NodeText",- "Data": "編輯項目:點擊項目使用既有資料庫項目編輯介面。使用一般日期欄位時,可透過日期格內的加號建立項目,拖曳項目調整日期,或拖曳兩端調整日期範圍。點擊檢視篩選旁的無日期按鈕,可搜尋尚未安排的項目;將項目拖到日期格,或先選取項目再點選日期格,觸控裝置也可使用後一種方式。安排時會填入全天日期,清空日期後項目會回到無日期清單。日期修改支援復原,觸控裝置可拖曳日曆中既有項目上的移動把手。新增後自動聚焦主鍵欄位;拖曳時預覽調整後的日期範圍並醒目提示對應日期格,放開後儲存。右鍵選單也支援複製、新建文件並綁定、新增至其他資料庫、編輯欄位及在所選日期新增項目"+ "Data": "編輯項目:點擊項目使用既有資料庫項目編輯介面。使用一般日期欄位時,可透過日期格內的加號建立項目,拖曳項目調整日期,或拖曳兩端調整日期範圍。點擊檢視篩選旁的無日期按鈕,可搜尋尚未安排的項目;將項目拖到日期格,或先選取項目再點選日期格,觸控裝置也可使用後一種方式。安排時會填入全天日期,清空日期後項目會回到無日期清單。日期修改支援復原,觸控裝置可拖曳日曆中既有項目上的移動把手。點擊或新增項目後自動聚焦主鍵欄位;拖曳時預覽調整後的日期範圍並醒目提示對應日期格,放開後儲存。右鍵選單也支援複製、新建文件並綁定、新增至其他資料庫、編輯欄位及在所選日期新增項目"}]}diff --git a/app/guide/20240530133126-axarxgx/20240530101000-4qitucx/20240530101000-g3ugxml/20240530101000-3eaevtp.sy b/app/guide/20240530133126-axarxgx/20240530101000-4qitucx/20240530101000-g3ugxml/20240530101000-3eaevtp.syindex 16d9fc6d48..97f23a307f 100644--- a/app/guide/20240530133126-axarxgx/20240530101000-4qitucx/20240530101000-g3ugxml/20240530101000-3eaevtp.sy+++ b/app/guide/20240530133126-axarxgx/20240530101000-4qitucx/20240530101000-g3ugxml/20240530101000-3eaevtp.sy@@ -8,7 +8,7 @@"id": "20240530101000-3eaevtp","title": "データベース","type": "doc",- "updated": "20260923103343"+ "updated": "20260924110133"},"Children": [{@@ -688,7 +688,7 @@"HeadingLevel": 3,"Properties": {"id": "20260920225154-vntgfc2",- "updated": "20260923103343"+ "updated": "20260924110133"},"Children": [{@@ -717,7 +717,7 @@"ListData": {},"Properties": {"id": "20260920225154-wh2lupo",- "updated": "20260923095432"+ "updated": "20260924110133"},"Children": [{@@ -831,7 +831,7 @@},"Properties": {"id": "20260920225154-cng1h41",- "updated": "20260921201901"+ "updated": "20260924110133"},"Children": [{@@ -839,12 +839,12 @@"Type": "NodeParagraph","Properties": {"id": "20260920225154-ibvcks0",- "updated": "20260921201901"+ "updated": "20260924110133"},"Children": [{"Type": "NodeText",- "Data": "編集:エントリをクリックすると既存のデータベースエントリ編集画面が開きます。通常の日付フィールドでは、日付欄のプラスボタンで作成し、エントリのドラッグで日付を移動し、両端のドラッグで範囲を変更できます。ビューのフィルターの横にある日付なしボタンから未設定のエントリを検索し、日付欄へドラッグするか、エントリを選択して日付欄を選ぶと予定を設定できます。後者はタッチ画面でも使用できます。終日の予定として設定され、日付を消すと一覧に戻ります。日付の変更は元に戻せます。タッチ画面ではカレンダー内の既存エントリの移動ハンドルをドラッグします。作成後は主キーフィールドに自動でフォーカスします。ドラッグ中は変更後の日付範囲をプレビューし、対象の日付欄を強調表示します。変更は放したときに保存されます。右クリックメニューからコピー、文書の作成と関連付け、別のデータベースへの追加、フィールドの編集、選択した日付での新規作成も行えます"+ "Data": "編集:エントリをクリックすると既存のデータベースエントリ編集画面が開きます。通常の日付フィールドでは、日付欄のプラスボタンで作成し、エントリのドラッグで日付を移動し、両端のドラッグで範囲を変更できます。ビューのフィルターの横にある日付なしボタンから未設定のエントリを検索し、日付欄へドラッグするか、エントリを選択して日付欄を選ぶと予定を設定できます。後者はタッチ画面でも使用できます。終日の予定として設定され、日付を消すと一覧に戻ります。日付の変更は元に戻せます。タッチ画面ではカレンダー内の既存エントリの移動ハンドルをドラッグします。エントリをクリックするか作成すると、主キーフィールドに自動でフォーカスします。ドラッグ中は変更後の日付範囲をプレビューし、対象の日付欄を強調表示します。変更は放したときに保存されます。右クリックメニューからコピー、文書の作成と関連付け、別のデータベースへの追加、フィールドの編集、選択した日付での新規作成も行えます"}]}diff --git a/app/src/editor/databaseRow.ts b/app/src/editor/databaseRow.tsindex 38e8f472f8..830c79df95 100644--- a/app/src/editor/databaseRow.ts+++ b/app/src/editor/databaseRow.ts@@ -6,7 +6,7 @@ import {Protyle} from "../protyle";import {getEditorHorizontalPadding} from "../protyle/ui/padding";import {searchMarkRender} from "../protyle/render/searchMarkRender";import {registerDatabaseRowRefresh} from "../protyle/render/av/databaseRowRefresh";-import {focusNewDatabasePrimary} from "../protyle/render/av/primaryFocus";+import {focusDatabasePrimary} from "../protyle/render/av/primaryFocus";export const newDatabaseRowModel = (options: {app: App,@@ -72,7 +72,7 @@ export const newDatabaseRowModel = (options: {previousBodyElement.replaceWith(element);updateLayout(custom);updateTitle(custom, element);- focusNewDatabasePrimary(custom.element, contextProtyle, data);+ focusDatabasePrimary(custom.element, contextProtyle, data);if (!data.keywords?.length) {return;}diff --git a/app/src/protyle/render/av/calendar/render.ts b/app/src/protyle/render/av/calendar/render.tsindex e3590c2126..0bb16c38b6 100644--- a/app/src/protyle/render/av/calendar/render.ts+++ b/app/src/protyle/render/av/calendar/render.ts@@ -40,6 +40,7 @@ const openCalendarItem = (protyle: IProtyle, blockElement: HTMLElement, row: IAVitemID: row.id, valueID: primary.id || primary.value.id,title: primary.value.block?.content || window.siyuan.languages.untitled,boundBlockID: primary.value.block?.id, isDetached: !!primary.value.isDetached,+ focusPrimary: true,});};diff --git a/app/src/protyle/render/av/openDatabaseRow.ts b/app/src/protyle/render/av/openDatabaseRow.tsindex 2e19194fa3..539f4f9736 100644--- a/app/src/protyle/render/av/openDatabaseRow.ts+++ b/app/src/protyle/render/av/openDatabaseRow.ts@@ -13,7 +13,7 @@ import {Custom} from "../../../layout/dock/Custom";/// #endifimport {searchMarkRender} from "../searchMarkRender";import {registerDatabaseRowRefresh} from "./databaseRowRefresh";-import {focusNewDatabasePrimary} from "./primaryFocus";+import {focusDatabasePrimary} from "./primaryFocus";export interface IDatabaseRowOpenData {avID: string;@@ -99,7 +99,7 @@ const openMobileDatabaseRow = (protyle: Pick<IProtyle, "app">, data: IDatabaseRorowElement.querySelector(".protyle-db-row__title span").textContent = currentTitle;}highlightDatabaseRow(contextProtyle, rowElement, data);- focusNewDatabasePrimary(rowElement, contextProtyle, data);+ focusDatabasePrimary(rowElement, contextProtyle, data);}, {avID: data.avID,itemID: data.itemID,@@ -133,7 +133,7 @@ const showDatabaseRowPreview = (model: Editor, data: IDatabaseRowOpenData) => {editorProtyle.contentElement.scrollTop = 0;editorProtyle.databaseAttributePanel?.afterRender(() => {highlightDatabaseRow(editorProtyle, editorProtyle.contentElement, data);- focusNewDatabasePrimary(editorProtyle.contentElement, editorProtyle, data);+ focusDatabasePrimary(editorProtyle.contentElement, editorProtyle, data);});};@@ -198,7 +198,7 @@ export const openDatabaseRowByData = async (protyle: Pick<IProtyle, "app">, dataeditorProtyle.contentElement.scrollTop = 0;editorProtyle.databaseAttributePanel?.afterRender(() => {highlightDatabaseRow(editorProtyle, editorProtyle.contentElement, data);- focusNewDatabasePrimary(editorProtyle.contentElement, editorProtyle, data);+ focusDatabasePrimary(editorProtyle.contentElement, editorProtyle, data);});}, true);return true;diff --git a/app/src/protyle/render/av/primaryFocus.test.ts b/app/src/protyle/render/av/primaryFocus.test.tsindex d959024870..8f31ee576e 100644--- a/app/src/protyle/render/av/primaryFocus.test.ts+++ b/app/src/protyle/render/av/primaryFocus.test.ts@@ -5,7 +5,7 @@ import {join} from "node:path";import {runInNewContext} from "node:vm";import * as ts from "typescript";-test("new database items focus once without replacing template text or stealing focus on refresh", () => {+test("database items focus once without replacing existing text or stealing focus on refresh", () => {let focused = 0;let caret = -1;const input = {value: "Template title", focus: () => { focused++; },@@ -16,18 +16,18 @@ test("new database items focus once without replacing template text or stealingrunInNewContext(ts.transpileModule(readFileSync(join(__dirname, "primaryFocus.ts"), "utf8"), {compilerOptions: {module: ts.ModuleKind.CommonJS, target: ts.ScriptTarget.ES2022},}).outputText, {exports, window, require: () => ({popTextCell: () => assert.fail("plain primary should use its input")})});- const {focusNewDatabasePrimary} = exports as typeof import("./primaryFocus");+ const {focusDatabasePrimary} = exports as typeof import("./primaryFocus");const request = {avID: "av", itemID: "row", focusPrimary: true};const protyle = {options: {}} as IProtyle;- focusNewDatabasePrimary(root, protyle, request);+ focusDatabasePrimary(root, protyle, request);assert.equal(focused, 1);assert.equal(caret, input.value.length);assert.equal(input.value, "Template title");- focusNewDatabasePrimary(root, protyle, request);+ focusDatabasePrimary(root, protyle, request);assert.equal(focused, 1);for (const mode of ["disabled", "publish", "created", "snapshot"]) {window.siyuan.isPublish = mode === "publish";- focusNewDatabasePrimary(root, {disabled: mode === "disabled", options: {history: {[mode]: "archive"}}} as IProtyle,+ focusDatabasePrimary(root, {disabled: mode === "disabled", options: {history: {[mode]: "archive"}}} as IProtyle,{...request, focusPrimary: true});}assert.equal(focused, 1);diff --git a/app/src/protyle/render/av/primaryFocus.ts b/app/src/protyle/render/av/primaryFocus.tsindex c9361362b6..bce6c5ea71 100644--- a/app/src/protyle/render/av/primaryFocus.ts+++ b/app/src/protyle/render/av/primaryFocus.ts@@ -1,7 +1,7 @@import {popTextCell} from "./cell";-// 新建条目只在首次完成渲染后进入主键编辑,刷新不重复聚焦,也不覆盖模板内容。-export const focusNewDatabasePrimary = (root: Element, protyle: IProtyle,+// 打开条目后只在首次完成渲染时进入主键编辑,刷新不重复聚焦,也不覆盖现有内容。+export const focusDatabasePrimary = (root: Element, protyle: IProtyle,request: {avID: string; itemID: string; focusPrimary?: boolean}) => {if (!request.focusPrimary || !root.isConnected) {return;