Skip to content

Commit

Permalink
Merge branch 'dev'
Browse files Browse the repository at this point in the history
  • Loading branch information
frostime committed Nov 19, 2023
2 parents 7b7877c + 5e42eac commit 751d203
Show file tree
Hide file tree
Showing 15 changed files with 430 additions and 143 deletions.
Binary file modified icon.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
"minimist": "^1.2.8",
"rollup-plugin-livereload": "^2.0.5",
"sass": "^1.62.1",
"siyuan": "^0.8.3",
"siyuan": "^0.8.8",
"svelte": "^3.57.0",
"ts-node": "^10.9.1",
"typescript": "^5.0.4",
Expand Down
6 changes: 3 additions & 3 deletions plugin.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,10 @@
"name": "sy-docs-flow",
"author": "frostime",
"url": "https://github.com/frostime/sy-docs-flow",
"version": "0.3.1",
"minAppVersion": "2.10.3",
"version": "0.4.0",
"minAppVersion": "2.10.14",
"backends": ["all"],
"frontends": ["all"],
"frontends": ["desktop", "desktop-window", "browser-desktop", "browser-mobile"],
"displayName": {
"en_US": "Documents Flow",
"zh_CN": "文档流"
Expand Down
107 changes: 107 additions & 0 deletions src/components/config/default-setting.svelte
Original file line number Diff line number Diff line change
@@ -0,0 +1,107 @@
<script lang="ts">
import { createEventDispatcher, onMount } from "svelte";
import SettingPanel from "@/libs/setting-panel.svelte";
import { setting } from "@/settings";
import { i18n } from "@/utils";
const I18N = i18n.defaultSetting;
export let group: string = "";
export let display: boolean = true;
export let settingValue = {};
export let descriptioin = I18N.descriptioin;
const SettingItemsValue = {
protyleScroll: setting.protyleScroll,
protyleBreadcrumb: setting.protyleBreadcrumb,
protyleReadonly: setting.protyleReadonly,
dynamicLoadingEnabled: setting.dynamicLoadingEnabled,
dynamicLoadingCapacity: setting.dynamicLoadingCapacity,
dynamicLoadingShift: setting.dynamicLoadingShift,
};
let DefaultSettingItems: ISettingItem[] = [];
onMount(() => {
for (let key in settingValue) {
if (key in SettingItemsValue) {
SettingItemsValue[key] = settingValue[key];
}
}
DefaultSettingItems = [
{
type: 'checkbox',
title: I18N.scrollMode.title,
text: I18N.scrollMode.text,
key: 'protyleScroll',
value: SettingItemsValue.protyleScroll
},
{
type: 'checkbox',
title: I18N.displayBreadcrumb.title,
text: I18N.displayBreadcrumb.text,
key: 'protyleBreadcrumb',
value: SettingItemsValue.protyleBreadcrumb
},
{
type: 'checkbox',
title: I18N.protyleReadonly.title,
text: I18N.protyleReadonly.text,
key: 'protyleReadonly',
value: SettingItemsValue.protyleReadonly
},
{
type: 'checkbox',
title: I18N.dynamicLoading.title,
text: I18N.dynamicLoading.text,
key: 'dynamicLoadingEnabled',
value: SettingItemsValue.dynamicLoadingEnabled
},
{
type: 'number',
title: I18N.dynamicLoadingCapacity.title,
text: I18N.dynamicLoadingCapacity.text,
key: 'dynamicLoadingCapacity',
value: SettingItemsValue.dynamicLoadingCapacity
},
{
type: 'number',
title: I18N.dynamicLoadingShift.title,
text: I18N.dynamicLoadingShift.text,
key: 'dynamicLoadingShift',
value: SettingItemsValue.dynamicLoadingShift
},
];
});
const dispatch = createEventDispatcher();
function onChanged( {detail}) {
dispatch("changed", detail);
}
</script>

<SettingPanel
{group}
settingItems={DefaultSettingItems}
{display}
on:changed={onChanged}
>
<div slot="top" class="fn__flex b3-label">
💡 {descriptioin}
</div>
</SettingPanel>


<style lang="scss">
div[slot="top"] {
color: var(--b3-theme-primary);
font-weight: bold;
font-size: 1.2em;
}
</style>


70 changes: 70 additions & 0 deletions src/components/config/global-setting.svelte
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
<!--
Copyright (c) 2023 by Yp Z (frostime). All Rights Reserved.
Author : Yp Z
Date : 2023-11-19 17:53:31
FilePath : /src/components/config/global-setting.svelte
LastEditTime : 2023-11-19 19:35:52
Description :
-->
<!--
Copyright (c) 2023 by Yp Z (frostime). All Rights Reserved.
Author : Yp Z
Date : 2023-11-19 17:53:31
FilePath : /src/components/config/global-setting.svelte
LastEditTime : 2023-11-19 19:10:51
Description :
-->
<script lang="ts">
import DefaultSetting from "./default-setting.svelte";
import { setting } from "@/settings";
let groups: string[] = ["🌈 Default"];
let focusGroup = groups[0];
/********** Events **********/
interface ChangeEvent {
group: string;
key: string;
value: any;
}
const onChanged = ({ detail }: CustomEvent<ChangeEvent>) => {
if (detail.group === groups[0]) {
setting.set(detail.key, detail.value);
}
};
</script>

<div class="fn__flex-1 fn__flex config__panel">
<ul class="b3-tab-bar b3-list b3-list--background">
{#each groups as group}
<li
data-name="editor"
class:b3-list-item--focus={group === focusGroup}
class="b3-list-item"
on:click={() => {
focusGroup = group;
}}
on:keydown={() => {}}
>
<span class="b3-list-item__text">{group}</span>
</li>
{/each}
</ul>
<div class="config__tab-wrap">
<DefaultSetting
group={groups[0]}
display={focusGroup === groups[0]}
on:changed={onChanged}
/>
</div>
</div>

<style lang="scss">
.config__panel {
height: 100%;
}
.config__panel > ul > li {
padding-left: 1rem;
}
</style>
83 changes: 72 additions & 11 deletions src/components/docs-flow/docs-flow.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,16 @@
Author : Yp Z
Date : 2023-07-28 20:49:27
FilePath : /src/components/docs-flow/docs-flow.svelte
LastEditTime : 2023-09-02 17:39:11
LastEditTime : 2023-11-19 20:09:35
Description :
-->
<script lang="ts">
import { Dialog } from "siyuan";
import { fly } from "svelte/transition";
import Protyle from "./protyle.svelte";
import { createEventDispatcher } from "svelte";
import { i18n } from "../../utils";
import DefaultSetting from "../config/default-setting.svelte";
export let app: any;
export let listDocuemntsId: DocumentId[] = [];
Expand Down Expand Up @@ -77,6 +79,58 @@
});
}
function onOpenConfig() {
console.log("onOpenConfig", config);
let dialog = new Dialog({
title: 'Config',
content: `<div id="SettingPanel"></div>`,
width: "780px",
height: "500px",
destroyCallback: () => {
// console.log(changedConfig);
if (changedConfig?.['protyleScroll'] !== undefined) {
config.scroll = changedConfig['protyleScroll'];
}
if (changedConfig?.['protyleBreadcrumb'] !== undefined) {
config.breadcrumb = changedConfig['protyleBreadcrumb'];
}
if (changedConfig?.['protyleReadonly'] !== undefined) {
config.readonly = changedConfig['protyleReadonly'];
}
if (changedConfig?.['dynamicLoadingEnabled'] !== undefined) {
config.dynamicLoading.enabled = changedConfig['dynamicLoadingEnabled'];
}
if (changedConfig?.['dynamicLoadingCapacity'] !== undefined) {
config.dynamicLoading.capacity = changedConfig['dynamicLoadingCapacity'];
}
if (changedConfig?.['dynamicLoadingShift'] !== undefined) {
config.dynamicLoading.shift = changedConfig['dynamicLoadingShift'];
}
onConfigChanged();
}
});
const ele: HTMLElement = dialog.element.querySelector("#SettingPanel");
ele.style.height = "100%";
let changedConfig = {};
let settingComp = new DefaultSetting({
target: ele,
props: {
descriptioin: i18n.defaultSetting.descriptioinSpecific,
settingValue: {
protyleScroll: config.scroll,
protyleBreadcrumb: config.breadcrumb,
protyleReadonly: config.readonly,
dynamicLoadingEnabled: config.dynamicLoading.enabled,
dynamicLoadingCapacity: config.dynamicLoading.capacity,
dynamicLoadingShift: config.dynamicLoading.shift
}
}
});
settingComp.$on("changed", ({detail}) => {
changedConfig[detail.key] = detail.value;
});
}
const reload = () => {
loadIdList = [];
onConfigChanged();
Expand Down Expand Up @@ -145,14 +199,14 @@
for="enableScroll"
style="margin-top: 0px;"
>
{i18n.displayBreadcrumb}
{i18n.defaultSetting.scrollMode.title}
</label>
<input
id="displayBreadcrumb"
id="enableScroll"
class="b3-switch fn__flex-center"
type="checkbox"
bind:checked={config.breadcrumb}
on:change={onConfigChanged}
bind:checked={config.scroll}
on:change={reload}
/>

<span class="fn__space" />
Expand All @@ -162,31 +216,38 @@
for="enableScroll"
style="margin-top: 0px;"
>
{i18n.dynamicLoading}
{i18n.defaultSetting.displayBreadcrumb.title}
</label>
<input
id="enableScroll"
id="displayBreadcrumb"
class="b3-switch fn__flex-center"
type="checkbox"
bind:checked={config.dynamicLoading.enabled}
on:change={reload}
bind:checked={config.breadcrumb}
on:change={onConfigChanged}
/>

<span class="fn__space" />

<label
class="b3-label__text"
for="enableScroll"
style="margin-top: 0px;"
>
{i18n.scrollMode}
{i18n.defaultSetting.dynamicLoading.title}
</label>
<input
id="enableScroll"
class="b3-switch fn__flex-center"
type="checkbox"
bind:checked={config.scroll}
bind:checked={config.dynamicLoading.enabled}
on:change={reload}
/>

<span class="fn__space" />

<button class="b3-button" on:click={onOpenConfig}>
{i18n.button.moreConfig}
</button>
<span class="fn__space" />
<button class="b3-button" on:click={onRenameThis}
>{i18n.nameTab}</button
Expand Down
17 changes: 5 additions & 12 deletions src/i18n/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,14 +1,7 @@
> 征集新的图标中, 有比较好的图标设计欢迎来发 issue.
>
> We are currently collecting new icons. If you have excellent icon designs, please feel free to submit an issue.
## 文档流插件 v0.4.0

## 文档流插件 v0.3.1

优化了 Eventbus, 允许外部调用的时候传入配置,详情见 README

## Document Flow Plugin v0.3.1

Optimized Eventbus to allow passing configurations during external event-bus calls.

Please refer to the README for more details.
- Fix bug: [#35](https://github.com/frostime/sy-docs-flow/issues/35)
- 增加设置功能, 允许用户配置文档流的默认选项
- 允许用户完整配置单个文档流内所有选项
- 更换了图标

Loading

0 comments on commit 751d203

Please sign in to comment.