Skip to content

Commit

Permalink
Merge pull request #22 from Zuoqiu-Yingyi/dev
Browse files Browse the repository at this point in the history
chore: release v0.2.3
  • Loading branch information
Zuoqiu-Yingyi committed Dec 26, 2023
2 parents 373a48f + c542c0c commit d9bf0d4
Show file tree
Hide file tree
Showing 15 changed files with 209 additions and 73 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/release-please.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ permissions:

env:
PACKAGE_NAME: monaco-editor
PACKAGE_VERSION: 0.2.2
PACKAGE_VERSION: 0.2.3

jobs:
release-please:
Expand Down
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@

* **monaco-editor:** 修复无法在浏览器环境中正确加载的问题 | Fix the issue that cannot be loaded correctly in the browser environment. ([da13865](https://github.com/Zuoqiu-Yingyi/siyuan-plugin-monaco-editor/commit/da1386562cf1cfeaaea95409b74f75a82b146f8f))


## [0.2.1](https://github.com/Zuoqiu-Yingyi/siyuan-plugin-monaco-editor/compare/v0.2.0...v0.2.1) (2023-11-18)


Expand Down
27 changes: 7 additions & 20 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "monaco-editor",
"private": true,
"version": "0.2.2",
"version": "0.2.3",
"type": "module",
"scripts": {
"dev": "vite",
Expand All @@ -15,31 +15,18 @@
"preview": "vite preview",
"check": "svelte-check --tsconfig ./tsconfig.json"
},
"dependencies": {
"@workspace/components": "workspace:^",
"@workspace/types": "workspace:^",
"@workspace/utils": "workspace:^"
},
"devDependencies": {
"@monaco-editor/loader": "^1.4.0",
"@siyuan-community/vditor": "^3.9.6",
"@sveltejs/vite-plugin-svelte": "^3.0.1",
"@tsconfig/svelte": "^4.0.1",
"@types/node": "^20.9.4",
"@types/streamsaver": "^2.0.4",
"deepmerge": "^4.3.1",
"less": "^4.2.0",
"material-icon-theme": "^4.32.0",
"monaco-editor": "^0.44.0",
"monaco-editor": "^0.45.0",
"streamsaver": "^2.0.6",
"svelte": "^4.2.7",
"svelte-check": "^3.6.1",
"svelte-preprocess-less": "^0.4.0",
"ts-node": "^10.9.1",
"tslib": "^2.6.2",
"typescript": "^5.3.2",
"vite": "^4.5.0",
"vite-plugin-static-copy": "^0.16.0",
"xml-js": "^1.6.11"
},
"dependencies": {
"@workspace/components": "workspace:^",
"@workspace/types": "workspace:^",
"@workspace/utils": "workspace:^"
}
}
11 changes: 11 additions & 0 deletions public/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,17 @@ This panel displays the markdown/kramdown source code of the currently edited bl

* Set the default editor for opening `*.md` files
* Default is to open `*.md` files with the Vditor editor
* `Monaco Editor`

* `Editor Word Wrapping Solution`

* Set the word wrapping solution used in the editor
* options

* `off`: Do not wrap
* `on`: Wrap at the visible viewport
* `wordWrapColumn`: Wrap at the custom column width
* `bounded`: Wrap at the minimum of custom column width and viewport width
* `Vditor Editor`

* `Resource File Saving Scheme`
Expand Down
11 changes: 11 additions & 0 deletions public/README_zh_CN.md
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,17 @@

* 设置打开 `*.md` 文件的默认编辑器
* 默认使用 `Vditor` 编辑器打开 `*.md` 文件
* `Monaco 编辑器`

* `编辑器折行方案`

* 指定编辑器中所使用的自动折行方案
* 选项

* `off`: 不换行
* `on`: 在可视区域处换行
* `wordWrapColumn`: 在自定义列宽处换行
* `bounded`: 在自定义列宽和视区宽度中较小的值处换行
* `Vditor 编辑器`

* `资源文件保存方案`
Expand Down
12 changes: 11 additions & 1 deletion public/i18n/en_US.json
Original file line number Diff line number Diff line change
Expand Up @@ -526,7 +526,17 @@
"title": "Global Settings"
},
"monacoTab": {
"title": "Monaco Editor"
"title": "Monaco Editor",
"wordWrap": {
"description": "The word wrapping solution used in the editor",
"options": {
"bounded": "[bounded] Wrap at the minimum of custom column width and viewport width",
"off": "[off] Do not wrap",
"on": "[on] Wrap at the visible viewport",
"wordWrapColumn": "[wordWrapColumn] Wrap at the custom column width"
},
"title": "Editor Word Wrapping Solution <span data-type='fn__code'>wordWrap</span>"
}
},
"title": "Editor Settings",
"vditorTab": {
Expand Down
12 changes: 11 additions & 1 deletion public/i18n/zh_CHT.json
Original file line number Diff line number Diff line change
Expand Up @@ -526,7 +526,17 @@
"title": "全局設置"
},
"monacoTab": {
"title": "Monaco 編輯器"
"title": "Monaco 編輯器",
"wordWrap": {
"description": "編輯器中所使用的自動折行方案",
"options": {
"bounded": "[bounded] 在自定義列寬和視區寬度中較小的值處換行",
"off": "[off] 不換行",
"on": "[on] 在可視區域處換行",
"wordWrapColumn": "[wordWrapColumn] 在自定義列寬處換行"
},
"title": "編輯器折行方案 <code class='fn__code'>wordWrap</code>"
}
},
"title": "編輯器設置",
"vditorTab": {
Expand Down
12 changes: 11 additions & 1 deletion public/i18n/zh_CN.json
Original file line number Diff line number Diff line change
Expand Up @@ -526,7 +526,17 @@
"title": "全局设置"
},
"monacoTab": {
"title": "Monaco 编辑器"
"title": "Monaco 编辑器",
"wordWrap": {
"description": "编辑器中所使用的自动折行方案",
"options": {
"bounded": "[bounded] 在自定义列宽和视区宽度中较小的值处换行",
"off": "[off] 不换行",
"on": "[on] 在可视区域处换行",
"wordWrapColumn": "[wordWrapColumn] 在自定义列宽处换行"
},
"title": "编辑器折行方案 <code class='fn__code'>wordWrap</code>"
}
},
"title": "编辑器设置",
"vditorTab": {
Expand Down
4 changes: 2 additions & 2 deletions public/plugin.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@
"name": "monaco-editor",
"author": "Zuoqiu Yingyi",
"url": "https://github.com/Zuoqiu-Yingyi/siyuan-plugin-monaco-editor",
"version": "0.2.2",
"minAppVersion": "2.10.10",
"version": "0.2.3",
"minAppVersion": "2.11.4",
"keywords": [
"代码",
"代碼",
Expand Down
28 changes: 26 additions & 2 deletions src/components/Editor.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -324,9 +324,33 @@
/**
* {@link Editor.EditorOption.wordWrap}
* Editor.EditorOption.wordWrap === 130
* {@link Editor.EditorOption.wordWrapOverride1}
* Editor.EditorOption.wordWrap === 134
*/
const word_wrap_status = editor.getOption(130) === "off" ? "on" : "off";
updateOptions({ wordWrap: word_wrap_status });
let word_wrap_status: boolean;
switch (editor.getOption(134)) {
case "off":
word_wrap_status = true;
break;
case "on":
word_wrap_status = false;
break;
default:
switch (editor.getOption(130)) {
case "off":
word_wrap_status = true;
break;
case "on":
case "wordWrapColumn":
case "bounded":
default:
word_wrap_status = false;
break;
}
break;
}
updateOptions({ wordWrapOverride1: word_wrap_status ? "on" : "off" });
},
});
Expand Down
29 changes: 28 additions & 1 deletion src/components/Settings.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,13 @@
{ key: AssetsUploadMode.relative, text: i18n.settings.editorSettings.vditorTab.assetsUploadMode.options.relative },
{ key: AssetsUploadMode.absolute, text: i18n.settings.editorSettings.vditorTab.assetsUploadMode.options.absolute },
];
const word_wrap_options = [
{ key: "off", text: i18n.settings.editorSettings.monacoTab.wordWrap.options.off },
{ key: "on", text: i18n.settings.editorSettings.monacoTab.wordWrap.options.on },
{ key: "wordWrapColumn", text: i18n.settings.editorSettings.monacoTab.wordWrap.options.wordWrapColumn },
{ key: "bounded", text: i18n.settings.editorSettings.monacoTab.wordWrap.options.bounded },
];
</script>

<Panels
Expand Down Expand Up @@ -320,7 +327,27 @@
<div
data-type={tabs.editor[1].name}
class:fn__none={tabs.editor[1].key !== focusTab}
/>
>
<!-- 自动折行方案 -->
<Item
title={i18n.settings.editorSettings.monacoTab.wordWrap.title}
text={i18n.settings.editorSettings.monacoTab.wordWrap.description}
block={true}
>
<Input
slot="input"
type={ItemType.select}
settingKey="editor.wordWrap"
settingValue={config.editor.options.wordWrap}
block={true}
options={word_wrap_options}
on:changed={async e => {
config.editor.options.wordWrap = e.detail.value;
await updated();
}}
/>
</Item>
</div>

<!-- 标签页 3 - Vditor 编辑器设置 -->
<div
Expand Down
1 change: 0 additions & 1 deletion src/configs/default.ts
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,6 @@ export function siyuanConfig2EditorOptions(config = globalThis.siyuan.config): I
mouseWheelZoom: config.editor.fontSizeScrollZoom,
readOnly: config.editor.readOnly,
tabSize: config.editor.codeTabSpaces,
wordWrap: config.editor.wordWrap ? "on" : "off",
theme: config.appearance.mode === 0 ? "vs" : "vs-dark",
};
}
Expand Down
21 changes: 17 additions & 4 deletions src/handlers/inbox.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ export interface IInboxHandler extends IHandler {

export interface IInboxHandlerOptions extends IBaseHandlerOptions {
id: string; // 收集箱 ID
format: "markdown" | "html"; // 收集箱内容格式
}

export class InboxHandler extends Handler {
Expand All @@ -50,11 +51,23 @@ export class InboxHandler extends Handler {
});

/* 生成的处理器 */
const modified: IEditorModel = (() => {
switch (options.format) {
default:
case "markdown":
return {
value: response.data.shorthandMd,
language: "markdown",
};
case "html":
return {
value: response.data.shorthandContent,
language: "html",
};
}
})();
const handler: IInboxHandler = {
modified: {
value: response.data.shorthandContent,
language: "markdown",
},
modified,
options: {
tabSize: this.customTabSize,
},
Expand Down
22 changes: 12 additions & 10 deletions src/iframes/editor.ts
Original file line number Diff line number Diff line change
Expand Up @@ -42,16 +42,18 @@ const logger = new Logger(`${manifest.name}-editor-${(() => {
}
})()}`);

var editor: InstanceType<typeof Editor> = new Editor({
target: globalThis.document.body,
props: {
plugin: {
name: manifest.name,
i18n,
logger,
var editor: InstanceType<typeof Editor> = !FLAG_ELECTRON
? new Editor({
target: globalThis.document.body,
props: {
plugin: {
name: manifest.name,
i18n,
logger,
},
},
},
}); // 编辑器组件
})
: null; // 编辑器组件

const bridge = new EditorBridgeSlave(
() => {
Expand All @@ -60,7 +62,7 @@ const bridge = new EditorBridgeSlave(
"editor-init",
e => {
const { data } = e.data;

// logger.debug(data);

/* 编辑器已存在则销毁原编辑器 */
if (editor) {
Expand Down

0 comments on commit d9bf0d4

Please sign in to comment.