codemirror实现浏览器中打开本地电脑文件夹目录树及多tab选项卡编辑文本文件代码
代码语言:html
所属分类:其他
代码描述:codemirror实现浏览器中打开本地电脑文件夹目录树及多tab选项卡编辑文本文件代码,通过showDirectoryPicker来直接在浏览器中操作本地电脑任意文件夹中的文件和子目录,模仿vscode直接多tab选项卡打开和编辑文本文件及代码,还能保存修改后的代码,切换tab和关闭编辑器,目录树种可单击折叠目录,双击文件右侧打开。
代码标签: codemirror 浏览器 打开 本地 电脑 文件夹 目录 树 多 tab 选项卡 编辑 文本 文
下面为部分代码预览,完整代码请点击下载或在bfwstudio webide中打开
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Code Editor</title>
<link rel='stylesheet' href='//repo.bfw.wiki/bfwrepo/js/codemirror/lib/codemirror.css'>
<link rel='stylesheet' href='//repo.bfw.wiki/bfwrepo/js/codemirror/theme/material.css'>
<style>
/* 自定义滚动条样式 */
::-webkit-scrollbar {
width: 10px;
height: 10px;
}
::-webkit-scrollbar-track {
background: #1e1e1e;
border-radius: 5px;
}
::-webkit-scrollbar-thumb {
background: #444;
border-radius: 5px;
}
::-webkit-scrollbar-thumb:hover {
background: #555;
}
/* Firefox 滚动条样式 */
* {
scrollbar-color: #444 #1e1e1e;
scrollbar-width: thin;
}
body {
margin: 0;
padding: 0;
display: flex;
height: 100vh;
font-family: Arial, sans-serif;
background-color: #1e1e1e;
color: white;
overflow: hidden;
}
#sidebar {
width: 250px;
background-color: #252526;
padding: 10px;
overflow-y: auto;
border-right: 1px solid #444;
}
#editor {
flex: 1;
background-color: #1e1e1e;
display: flex;
flex-direction: column;
overflow: hidden;
}
.file-item, .folder-item {
cursor: pointer;
padding: 5px;
margin: 5px 0;
border-radius: 3px;
display: flex;
align-items: center;
}
.file-item:hover, .folder-item:hover {
background-color: #2a2d2e;
}
.folder-item::before, .file-item::before {
content: '';
display: inline-block;
width: 16px;
height: 16px;
margin-right: 5px;
background-size: cover;
}
.folder-item::before {
background-image: url('data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHZpZXdCb3g9IjAgMCAyNCAyNCIgZmlsbD0id2hpdGUiPjxwYXRoIGQ9Ik0xMCA0SDRjLTEuMSAwLTEuOTkuOS0xLjk5IDJMMiAxOGMwIDEuMS45IDIgMiAyaDE2YzEuMSAwIDItLjkgMi0yVjhjMC0xLjEtLjktMi0yLTJoLThsLTItMnoiLz48L3N2Zz4=');
}
.file-item::before {
background-image:.........完整代码请登录后点击上方下载按钮下载查看
















网友评论0