Skip to content

Commit

Permalink
🐛 fix: example code of outline
Browse files Browse the repository at this point in the history
  • Loading branch information
frostime committed Dec 20, 2024
1 parent 2959790 commit 351bf3c
Show file tree
Hide file tree
Showing 4 changed files with 5 additions and 4 deletions.
1 change: 1 addition & 0 deletions public/example/exp-outline.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ const query = async () => {
let ans = await Query.request('/api/outline/getDocOutline', {
id: Query.root_id(protyle)
});
ans = Query.wrapit(ans);
const iterate = (data) => {
for (let item of data) {
if (item.count > 0) {
Expand Down
2 changes: 1 addition & 1 deletion public/types.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
* @name sy-query-view
* @author frostime
* @version 1.0.2
* @updated 2024-12-20T14:03:43.400Z
* @updated 2024-12-20T14:21:48.772Z
*/

declare module 'siyuan' {
Expand Down
4 changes: 2 additions & 2 deletions src/user-help/examples.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
* @Author : frostime
* @Date : 2024-12-11 18:24:00
* @FilePath : /src/user-help/examples.ts
* @LastEditTime : 2024-12-15 11:18:12
* @LastEditTime : 2024-12-20 22:21:09
* @Description :
*/
import { getFileBlob, readDir } from "@/api";
Expand Down Expand Up @@ -40,7 +40,7 @@ const Description = {
"exp-gpt-translate.js": () => i18n.src_userhelp_examplests.random_text_translate,
"exp-doc-tree.js": () => i18n.src_userhelp_examplests.query_doc_tree,
"exp-month-todo-kanban.js": () => i18n.src_userhelp_examplests.unfinished_task_monthly,
"exp-month-todo-timelines.js": () => i18n.src_userhelp_examplests.query_unfinished_tasks
"exp-month-todo-timeline.js": () => i18n.src_userhelp_examplests.query_unfinished_tasks
};

const addSection = (title: string, content: string) => {
Expand Down
2 changes: 1 addition & 1 deletion src/user-help/sy-doc.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ const compareVersion = (v1: string, v2: string) => {
}

const OutlineCode = `
> {{//!js_esc_newline_const query = async () => {_esc_newline_ let dv = Query.DataView(protyle, item, top);_esc_newline_ let ans = await Query.request('/api/outline/getDocOutline', {_esc_newline_ id: Query.root_id(protyle)_esc_newline_ });_esc_newline_ const iterate = (data) => {_esc_newline_ for (let item of data) {_esc_newline_ if (item.count > 0) {_esc_newline_ let subtocs = iterate(item.blocks ?? item.children);_esc_newline_ item.children = Query.wrapBlocks(subtocs);_esc_newline_ }_esc_newline_ }_esc_newline_ return data;_esc_newline_ }_esc_newline_ let tocs = iterate(ans);_esc_newline_ dv.addmd('### Outline');_esc_newline_ dv.addlist(tocs, {_esc_newline_ renderer: b => \`[\${b.name || b.content}](\${b.asurl})\`,_esc_newline_ columns: 2_esc_newline_ });_esc_newline_ dv.render();_esc_newline_}_esc_newline__esc_newline_return query();}}
> {{//!js_esc_newline_const query = async () => {_esc_newline_ let dv = Query.DataView(protyle, item, top);_esc_newline_ let ans = await Query.request('/api/outline/getDocOutline', {_esc_newline_ id: Query.root_id(protyle)_esc_newline_ });_esc_newline_ ans = Query.wrapit(ans);_esc_newline_ const iterate = (data) => {_esc_newline_ for (let item of data) {_esc_newline_ if (item.count > 0) {_esc_newline_ let subtocs = iterate(item.blocks ?? item.children);_esc_newline_ item.children = Query.wrapBlocks(subtocs);_esc_newline_ }_esc_newline_ }_esc_newline_ return data;_esc_newline_ }_esc_newline_ let tocs = iterate(ans);_esc_newline_ dv.addlist(tocs, {_esc_newline_ renderer: b => \`[\${b.name || b.content}](\${b.asurl})\`,_esc_newline_ columns: 2_esc_newline_ });_esc_newline_ dv.render();_esc_newline_}_esc_newline__esc_newline_return query();}}
`.trim();


Expand Down

0 comments on commit 351bf3c

Please sign in to comment.