vzcode 0.6.0 → 0.8.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +0 -1
- package/dist/assets/index-80e9e6df.js +89 -0
- package/dist/assets/index-ccd52a89.css +1 -0
- package/dist/index.html +3 -3
- package/package.json +18 -17
- package/src/client/App.tsx +40 -93
- package/src/client/CodeEditor/getOrCreateEditor.ts +115 -0
- package/src/client/CodeEditor/index.tsx +50 -0
- package/src/client/{json1PresenceDisplay.js → CodeEditor/json1PresenceDisplay.js} +2 -2
- package/src/client/CodeEditor/style.scss +11 -0
- package/src/client/CodeEditor/widgets.ts +48 -0
- package/src/client/{settings.jsx → Settings.tsx} +18 -39
- package/src/client/Sidebar/DirectoryListing.tsx +6 -5
- package/src/client/Sidebar/FileListing.tsx +1 -1
- package/src/client/Sidebar/Listing.tsx +3 -3
- package/src/client/Sidebar/index.tsx +13 -12
- package/src/client/TabList/index.tsx +82 -0
- package/src/client/TabList/style.scss +32 -0
- package/src/client/main.jsx +1 -1
- package/src/client/style.scss +0 -44
- package/src/client/themes.ts +31 -0
- package/src/client/{Sidebar/useOpenDirectories.ts → useOpenDirectories.ts} +17 -11
- package/src/client/useTabsState.ts +51 -0
- package/src/types.ts +12 -0
- package/dist/assets/index-41607816.js +0 -89
- package/dist/assets/index-8bac68c9.css +0 -1
- package/src/client/CodeEditor.jsx +0 -31
- package/src/client/getOrCreateEditor.js +0 -85
- /package/src/client/{json1PresenceBroadcast.js → CodeEditor/json1PresenceBroadcast.js} +0 -0
|
@@ -1 +0,0 @@
|
|
|
1
|
-
.vz-sidebar{height:100%;width:200px;background:rgb(54,65,89);display:flex;flex-direction:column;justify-content:space-between}.vz-sidebar .full-box{padding:7px;display:flex;flex-direction:row;align-items:center;justify-content:space-between}.vz-sidebar .files{overflow:auto}.vz-sidebar .file-or-directory{display:flex;flex-direction:row;align-items:center;justify-content:space-between;cursor:pointer;margin:0 10px;color:#dbdde1;border-radius:5px}.vz-sidebar .link-name{margin-top:30px;margin-left:10px;color:#9aa0ac;font-size:12px;text-decoration:none}.vz-sidebar .new-btn{justify-content:right;margin-right:10px;cursor:pointer}.vz-sidebar .utils{display:flex}.vz-sidebar .utilities{margin-right:3px}.vz-sidebar .file-or-directory:hover,.vz-sidebar .settings:hover{background-color:#4a5469}.vz-sidebar .name{display:flex;text-overflow:ellipsis;white-space:nowrap;overflow:hidden}.vz-sidebar .indentation{margin-left:20px}.vz-sidebar .arrow-wrapper{margin-right:4px}.vz-sidebar .settings{height:30px;color:#dbdde1;cursor:pointer;display:flex;align-items:center;justify-content:center;padding:14px 0;margin:10px;border-radius:5px}:root{--vzcode-font-family: ui-monospace, SFMono-Regular, SF Mono, Menlo, Consolas, Liberation Mono, monospace}::-webkit-scrollbar{width:10px;height:10px}::-webkit-scrollbar-track{background:rgb(41,44,52)}::-webkit-scrollbar-thumb{background:rgb(37,37,38)}::-webkit-scrollbar-thumb:hover{background:#555}html,body,#root,.app{height:100%}.app{background-color:#292c34;font-family:Poppins,sans-serif;display:flex}.app .left{display:flex}.app .right{display:flex;flex:1;flex-direction:column;min-width:0}.app .right .tab-list{display:flex;background-color:#252526}.app .right .tab-list .tab{background:rgb(45,45,45);color:#fff;font-family:var(--vzcode-font-family);align-items:center;display:flex;padding-top:2px;padding-left:10px;padding-right:10px;border-top-left-radius:10px;border-top-right-radius:10px;margin-top:5px;margin-left:2px;margin-right:2px;cursor:pointer}.app .right .tab-list .tab .tab-close{margin-left:5px}.app .right .tab-list .tab .tab-close:hover{border-radius:30%;background-color:#252526}.app .right .tab-list .tab.active{background-color:#292c34}.app .right .editor{flex:1;display:flex;font-family:var(--vzcode-font-family);overflow-x:auto}.themes{color:#252526}
|
|
@@ -1,31 +0,0 @@
|
|
|
1
|
-
import { useRef, useLayoutEffect } from 'react';
|
|
2
|
-
import { getOrCreateEditor } from './getOrCreateEditor';
|
|
3
|
-
|
|
4
|
-
export const CodeEditor = ({
|
|
5
|
-
activeFileId,
|
|
6
|
-
shareDBDoc,
|
|
7
|
-
localPresence,
|
|
8
|
-
docPresence,
|
|
9
|
-
theme,
|
|
10
|
-
}) => {
|
|
11
|
-
const ref = useRef();
|
|
12
|
-
|
|
13
|
-
// useEffect was buggy in that sometimes ref.current was undefined.
|
|
14
|
-
// useLayoutEffect seems to solve that issue.
|
|
15
|
-
useLayoutEffect(() => {
|
|
16
|
-
const editor = getOrCreateEditor({
|
|
17
|
-
fileId: activeFileId,
|
|
18
|
-
shareDBDoc,
|
|
19
|
-
localPresence,
|
|
20
|
-
docPresence,
|
|
21
|
-
theme,
|
|
22
|
-
});
|
|
23
|
-
ref.current.appendChild(editor.dom);
|
|
24
|
-
|
|
25
|
-
return () => {
|
|
26
|
-
ref.current.removeChild(editor.dom);
|
|
27
|
-
};
|
|
28
|
-
}, [shareDBDoc, activeFileId]);
|
|
29
|
-
|
|
30
|
-
return <div className="editor" ref={ref} />;
|
|
31
|
-
};
|
|
@@ -1,85 +0,0 @@
|
|
|
1
|
-
import { EditorView, basicSetup } from 'codemirror';
|
|
2
|
-
import { Compartment, EditorState } from '@codemirror/state';
|
|
3
|
-
import { javascript } from '@codemirror/lang-javascript';
|
|
4
|
-
import { markdown } from '@codemirror/lang-markdown';
|
|
5
|
-
import { html } from '@codemirror/lang-html';
|
|
6
|
-
import { css } from '@codemirror/lang-css';
|
|
7
|
-
import { json1Sync } from 'codemirror-ot';
|
|
8
|
-
import { json1Presence, textUnicode } from '../ot';
|
|
9
|
-
import { json1PresenceBroadcast } from './json1PresenceBroadcast';
|
|
10
|
-
import { json1PresenceDisplay } from './json1PresenceDisplay';
|
|
11
|
-
|
|
12
|
-
// Singleton cache of CodeMirror instances
|
|
13
|
-
// These are created, but never destroyed.
|
|
14
|
-
// TODO consider invalidating this cache at some point.
|
|
15
|
-
// * Keys are file ids
|
|
16
|
-
// * Values are CodeMirror instances
|
|
17
|
-
const editorCache = new Map();
|
|
18
|
-
|
|
19
|
-
// Gets or creates a CodeMirror editor for the given file id.
|
|
20
|
-
export const getOrCreateEditor = ({
|
|
21
|
-
fileId,
|
|
22
|
-
shareDBDoc,
|
|
23
|
-
localPresence,
|
|
24
|
-
docPresence,
|
|
25
|
-
theme
|
|
26
|
-
}) => {
|
|
27
|
-
const data = shareDBDoc.data;
|
|
28
|
-
|
|
29
|
-
const fileExtension = data[fileId].name.split('.').pop();
|
|
30
|
-
|
|
31
|
-
// The path for this file in the ShareDB document.
|
|
32
|
-
const path = [fileId, 'text'];
|
|
33
|
-
|
|
34
|
-
let themeSet = new Compartment();
|
|
35
|
-
|
|
36
|
-
const extensions = [
|
|
37
|
-
// This plugin implements multiplayer editing,
|
|
38
|
-
// real-time synchronozation of changes across clients.
|
|
39
|
-
// Does not deal with showing others' cursors.
|
|
40
|
-
json1Sync({
|
|
41
|
-
shareDBDoc,
|
|
42
|
-
path,
|
|
43
|
-
json1: json1Presence,
|
|
44
|
-
textUnicode,
|
|
45
|
-
}),
|
|
46
|
-
|
|
47
|
-
// Deals with broadcasting changes in cursor location and selection.
|
|
48
|
-
json1PresenceBroadcast({ path, localPresence }),
|
|
49
|
-
|
|
50
|
-
// Deals with receiving the broadcas from other clients and displaying them.
|
|
51
|
-
json1PresenceDisplay({ path, docPresence }),
|
|
52
|
-
|
|
53
|
-
basicSetup,
|
|
54
|
-
themeSet.of(theme),
|
|
55
|
-
];
|
|
56
|
-
|
|
57
|
-
if (
|
|
58
|
-
fileExtension === 'js' ||
|
|
59
|
-
fileExtension === 'json' ||
|
|
60
|
-
fileExtension == 'jsx' ||
|
|
61
|
-
fileExtension == 'ts'
|
|
62
|
-
) {
|
|
63
|
-
extensions.push(javascript());
|
|
64
|
-
} else if (fileExtension === 'html') {
|
|
65
|
-
extensions.push(html());
|
|
66
|
-
} else if (fileExtension === 'css') {
|
|
67
|
-
extensions.push(css());
|
|
68
|
-
} else if (fileExtension === 'md') {
|
|
69
|
-
extensions.push(markdown());
|
|
70
|
-
}
|
|
71
|
-
|
|
72
|
-
let editor = editorCache.get(fileId);
|
|
73
|
-
if (!editor) {
|
|
74
|
-
editor = new EditorView({
|
|
75
|
-
state: EditorState.create({
|
|
76
|
-
doc: data[fileId].text,
|
|
77
|
-
extensions,
|
|
78
|
-
}),
|
|
79
|
-
});
|
|
80
|
-
|
|
81
|
-
// Populate the cache.
|
|
82
|
-
editorCache.set(fileId, editor);
|
|
83
|
-
}
|
|
84
|
-
return editor;
|
|
85
|
-
};
|
|
File without changes
|