-
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(monaco-editor): 实现侧边栏编辑器 | Implement sidebar editor.
- Loading branch information
1 parent
7d5ac79
commit bae5ddd
Showing
25 changed files
with
1,225 additions
and
153 deletions.
There are no files selected for viewing
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Empty file.
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,22 @@ | ||
{ | ||
"displayName": "Code Editor" | ||
"displayName": "Code Editor", | ||
"dock": { | ||
"kramdown": { | ||
"ariaLabel": "Edit kramdown" | ||
}, | ||
"title": "Code Edit" | ||
}, | ||
"editor": { | ||
"action": { | ||
"save": { | ||
"label": "Save" | ||
}, | ||
"saveAs": { | ||
"label": "Save As" | ||
}, | ||
"toggleWordWrap": { | ||
"label": "Toggle Word Wrap" | ||
} | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,22 @@ | ||
{ | ||
"displayName": "代碼編輯器" | ||
"displayName": "程式碼編輯器", | ||
"dock": { | ||
"kramdown": { | ||
"ariaLabel": "編輯 kramdown" | ||
}, | ||
"title": "程式碼編輯" | ||
}, | ||
"editor": { | ||
"action": { | ||
"save": { | ||
"label": "保存" | ||
}, | ||
"saveAs": { | ||
"label": "另存為" | ||
}, | ||
"toggleWordWrap": { | ||
"label": "切換自動換行" | ||
} | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,22 @@ | ||
{ | ||
"displayName": "代码编辑器" | ||
"displayName": "代码编辑器", | ||
"dock": { | ||
"kramdown": { | ||
"ariaLabel": "编辑 kramdown" | ||
}, | ||
"title": "代码编辑" | ||
}, | ||
"editor": { | ||
"action": { | ||
"save": { | ||
"label": "保存" | ||
}, | ||
"saveAs": { | ||
"label": "另存为" | ||
}, | ||
"toggleWordWrap": { | ||
"label": "切换自动换行" | ||
} | ||
} | ||
} | ||
} |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
{ | ||
"name": "monaco-editor", | ||
"author": "Zuoqiu Yingyi", | ||
"url": "https://github.com/Zuoqiu-Yingyi/siyuan-plugin-webview", | ||
"version": "0.0.0", | ||
"minAppVersion": "2.9.5", | ||
"backends": [ | ||
"all" | ||
], | ||
"frontends": [ | ||
"desktop", | ||
"desktop-window", | ||
"browser-desktop" | ||
], | ||
"displayName": { | ||
"default": "Code Editor", | ||
"zh_CN": "代码编辑器", | ||
"zh_CHT": "程式碼編輯器" | ||
}, | ||
"description": { | ||
"default": "Use the <a href='https://microsoft.github.io/monaco-editor/'>Monaco Editor</a> to view and edit code.", | ||
"zh_CN": "使用 <a href='https://microsoft.github.io/monaco-editor/'>Monaco Editor</a> 查看与编辑代码。", | ||
"zh_CHT": "使用 <a href='https://microsoft.github.io/monaco-editor/'>Monaco Editor</a> 檢視與編輯程式碼。" | ||
}, | ||
"readme": { | ||
"default": "README.md", | ||
"zh_CN": "README_zh_CN.md", | ||
"zh_CHT": "README_zh_CN.md" | ||
}, | ||
"funding": { | ||
"openCollective": "", | ||
"patreon": "", | ||
"github": "", | ||
"custom": [ | ||
"https://afdian.net/a/zuoqiu", | ||
"https://ko-fi.com/zuoqiu" | ||
] | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,74 @@ | ||
<!-- | ||
Copyright (C) 2023 Zuoqiu Yingyi | ||
This program is free software: you can redistribute it and/or modify | ||
it under the terms of the GNU Affero General Public License as | ||
published by the Free Software Foundation, either version 3 of the | ||
License, or (at your option) any later version. | ||
This program is distributed in the hope that it will be useful, | ||
but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
GNU Affero General Public License for more details. | ||
You should have received a copy of the GNU Affero General Public License | ||
along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
--> | ||
|
||
<script lang="ts"> | ||
import type { ComponentEvents } from "svelte"; | ||
import Bar from "@workspace/components/siyuan/dock/block/Bar.svelte"; | ||
import Editor from "./Editor.svelte"; | ||
import regexp from "@workspace/utils/regexp"; | ||
import type { IBar } from "@workspace/components/siyuan/dock/block/index"; | ||
import type MonacoEditorPlugin from "@/index"; | ||
import type { IDockEditor } from "@/types/editor"; | ||
export let plugin: InstanceType<typeof MonacoEditorPlugin>; // 插件对象 | ||
export let id: string; // 块 ID | ||
export let kramdown: boolean; // 是否启用 kramdown 模式 | ||
export let bar: IBar; // 标题栏配置 | ||
export let editor: IDockEditor; // 编辑器配置 | ||
$: { | ||
if (regexp.id.test(id)) { | ||
if (kramdown) { | ||
plugin.client | ||
.getBlockKramdown({ id }) | ||
.then(response => { | ||
editor.modified.value = response.data.kramdown; | ||
}) | ||
.catch(err => plugin.logger.error(err)); | ||
} else { | ||
// TODO: markdown 模式 | ||
} | ||
} | ||
} | ||
function save(e: ComponentEvents<Editor>["save"]) { | ||
if (kramdown) { | ||
plugin.client | ||
.updateBlock({ | ||
id, | ||
dataType: "markdown", | ||
data: e.detail.value, | ||
}) | ||
.catch(err => plugin.logger.error(err)); | ||
} else { | ||
// TODO: markdown 模式 | ||
} | ||
} | ||
</script> | ||
|
||
<Bar {...bar} /> | ||
<Editor | ||
on:save={save} | ||
{...editor} | ||
{plugin} | ||
embed={true} | ||
savable={true} | ||
locale={globalThis.siyuan.config.lang} | ||
/> |
Oops, something went wrong.