From 9af82bea838716b2ef58ed52885866e13ffbcbea Mon Sep 17 00:00:00 2001 From: keep <1603421097@qq.com> Date: Sat, 18 Apr 2026 22:30:00 +0800 Subject: [PATCH 1/3] =?UTF-8?q?feat(editor):=20=E6=B7=BB=E5=8A=A0=E4=BB=A3?= =?UTF-8?q?=E7=A0=81=E8=87=AA=E5=8A=A8=E4=BF=9D=E5=AD=98=E5=92=8C=E5=88=86?= =?UTF-8?q?=E4=BA=AB=E5=8A=9F=E8=83=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 添加自动保存编辑器状态到本地存储功能 实现通过URL分享代码功能 新增格式化代码和分享按钮 --- editor/index.html | 10 ++- editor/index.js | 220 ++++++++++++++++++++++++++++++++++++++++++---- 2 files changed, 208 insertions(+), 22 deletions(-) diff --git a/editor/index.html b/editor/index.html index ede19d9..cd160f6 100644 --- a/editor/index.html +++ b/editor/index.html @@ -3,12 +3,11 @@ + + - - - @@ -30,6 +29,11 @@

Editor

+
+ + + +
-
+
-
+
diff --git a/editor/index.js b/editor/index.js index 5e7a98b..eec3396 100644 --- a/editor/index.js +++ b/editor/index.js @@ -292,6 +292,8 @@ function loadCodeWithMode(modeId, code) { $('#editor').empty(); editor = monaco.editor.create(document.getElementById('editor'), { model: null, + automaticLayout: true, + scrollBeyondLastLine: false, }); setupAutoSave(); } From 9493b1df4d7393f20a4100837ca37c869c4236e0 Mon Sep 17 00:00:00 2001 From: keep <1603421097@qq.com> Date: Sat, 18 Apr 2026 22:46:28 +0800 Subject: [PATCH 3/3] =?UTF-8?q?feat(=E7=BC=96=E8=BE=91=E5=99=A8):=20?= =?UTF-8?q?=E6=B7=BB=E5=8A=A0=E5=88=86=E4=BA=AB=E9=93=BE=E6=8E=A5=E5=8A=9F?= =?UTF-8?q?=E8=83=BD=E5=B9=B6=E7=A7=BB=E9=99=A4diff=E7=BC=96=E8=BE=91?= =?UTF-8?q?=E5=99=A8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 添加分享链接容器及复制/导出功能,改进用户体验 移除失效的diff编辑器相关代码 添加UTF-8字符集声明 --- editor/index.html | 12 ++++++++++++ editor/index.js | 47 ++++++++++++++++++++++++++++++++++++++++------- 2 files changed, 52 insertions(+), 7 deletions(-) diff --git a/editor/index.html b/editor/index.html index bee0ace..f0a6890 100644 --- a/editor/index.html +++ b/editor/index.html @@ -1,4 +1,5 @@ + @@ -43,6 +44,17 @@

Editor

+ diff --git a/editor/index.js b/editor/index.js index eec3396..bd9b551 100644 --- a/editor/index.js +++ b/editor/index.js @@ -191,6 +191,16 @@ function initializeEditor() { var shareURL = generateShareURL(); + // 显示分享链接容器 + $('#share-url-container').show(); + $('#share-url-input').val(shareURL); + }); + + // 复制链接按钮 + $("#copy-url-btn").click(function() { + var shareURL = $('#share-url-input').val(); + if (!shareURL) return; + // 创建一个临时输入框来复制 URL var tempInput = document.createElement('input'); tempInput.value = shareURL; @@ -199,16 +209,39 @@ function initializeEditor() { document.execCommand('copy'); document.body.removeChild(tempInput); - alert('分享链接已复制到剪贴板:\n' + shareURL); + // 提示用户 + var originalText = $('#copy-url-btn').text(); + $('#copy-url-btn').text('已复制!'); + setTimeout(function() { + $('#copy-url-btn').text(originalText); + }, 2000); + }); + + // 导出链接按钮 + $("#export-url-btn").click(function() { + var shareURL = $('#share-url-input').val(); + if (!shareURL) return; + + // 创建一个包含 URL 的文本文件 + var blob = new Blob([shareURL], { type: 'text/plain' }); + var url = window.URL.createObjectURL(blob); + var a = document.createElement('a'); + a.href = url; + a.download = 'editor-share-url.txt'; + document.body.appendChild(a); + a.click(); + document.body.removeChild(a); + window.URL.revokeObjectURL(url); }); - loadDiffSample(); + // 移除 diff 编辑器功能,因为相关的示例文件 URL 已失效且页面中没有对应元素 + // loadDiffSample(); - $('#inline-diff-checkbox').change(function () { - diffEditor.updateOptions({ - renderSideBySide: !$(this).is(':checked') - }); - }); + // $('#inline-diff-checkbox').change(function () { + // diffEditor.updateOptions({ + // renderSideBySide: !$(this).is(':checked') + // }); + // }); }); window.onresize = function () {