Skip to content

Commit

Permalink
pretty context menu (#12)
Browse files Browse the repository at this point in the history
* pretty context menu

* add res

* add resource to html

* work well

* test local extension
  • Loading branch information
dzylikecode authored Oct 20, 2022
1 parent 00628a5 commit 784b655
Show file tree
Hide file tree
Showing 14 changed files with 321 additions and 159 deletions.
3 changes: 2 additions & 1 deletion .vscodeignore
Original file line number Diff line number Diff line change
Expand Up @@ -9,4 +9,5 @@ vsc-extension-quickstart.md
**/.eslintrc.json
docs/**
node_modules/**
src/**/*.js
src/**/*.js
!src/server/assets/js/*.js
12 changes: 12 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,18 @@ I have fixed all the issues I met. If you find any issues, please report them to

## Release Notes

### 1.3.0

- fix:

- need to reload the VSCode if the `index.html` is changed

now, you can just reopen the Docsify-Preview to make it work

- change

pretty context menu

### 1.2.0

fix: issue
Expand Down
18 changes: 7 additions & 11 deletions jsconfig.json
Original file line number Diff line number Diff line change
@@ -1,13 +1,9 @@
{
"compilerOptions": {
"module": "commonjs",
"target": "ES2020",
"checkJs": true, /* Typecheck .js files. */
"lib": [
"ES2020"
]
},
"exclude": [
"node_modules"
]
"compilerOptions": {
"module": "commonjs",
"target": "ES2020",
"checkJs": true /* Typecheck .js files. */,
"lib": ["ES2020"]
},
"exclude": ["node_modules"]
}
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"name": "docsify-preview",
"displayName": "docsify-Preview",
"description": "write docs easily with docsify",
"version": "1.2.0",
"version": "1.3.0",
"engines": {
"vscode": "^1.71.0"
},
Expand Down
10 changes: 7 additions & 3 deletions src/config.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,12 @@ const fs = require("fs");
const vscode = require("vscode");
const webViewHtmlRelativePath = "src/server/webView.html";
const injectedRelativePath = "src/server/listener/injected.html";
const webViewAssetsRelativePath = "src/server";
let webViewAssetsPath;
let host = "127.0.0.1";
let indexFileName;
let docsifyRootPath;
let extensionPath;
let injectCode;
let port;
let webViewHtmlPath;
let injectedPath;
Expand All @@ -16,8 +17,8 @@ let docsifyIndexFilePath;
function initExtension(context) {
extensionPath = context.extensionPath;
webViewHtmlPath = path.join(extensionPath, webViewHtmlRelativePath);
webViewAssetsPath = path.join(extensionPath, webViewAssetsRelativePath);
injectedPath = path.join(extensionPath, injectedRelativePath);
injectCode = fs.readFileSync(injectedPath, "utf8");
}

function getConfigurationForWorkspace() {
Expand All @@ -41,6 +42,9 @@ module.exports = {
get webViewHtmlPath() {
return webViewHtmlPath;
},
get webViewAssetsPath() {
return webViewAssetsPath;
},
host,
get port() {
return port;
Expand All @@ -64,7 +68,7 @@ module.exports = {
return extensionPath;
},
get injectCode() {
return injectCode;
return fs.readFileSync(injectedPath, "utf8");
},
get panelIconPath() {
return vscode.Uri.file(path.join(this.extensionPath, "assets/icon.svg"));
Expand Down
112 changes: 112 additions & 0 deletions src/server/assets/css/contextMenu-lib-font.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,112 @@
/* cyrillic-ext */
@font-face {
font-family: 'Roboto';
font-style: normal;
font-weight: 300;
src: url(https://fonts.gstatic.com/s/roboto/v30/KFOlCnqEu92Fr1MmSU5fCRc4EsA.woff2) format('woff2');
unicode-range: U+0460-052F, U+1C80-1C88, U+20B4, U+2DE0-2DFF, U+A640-A69F, U+FE2E-FE2F;
}
/* cyrillic */
@font-face {
font-family: 'Roboto';
font-style: normal;
font-weight: 300;
src: url(https://fonts.gstatic.com/s/roboto/v30/KFOlCnqEu92Fr1MmSU5fABc4EsA.woff2) format('woff2');
unicode-range: U+0301, U+0400-045F, U+0490-0491, U+04B0-04B1, U+2116;
}
/* greek-ext */
@font-face {
font-family: 'Roboto';
font-style: normal;
font-weight: 300;
src: url(https://fonts.gstatic.com/s/roboto/v30/KFOlCnqEu92Fr1MmSU5fCBc4EsA.woff2) format('woff2');
unicode-range: U+1F00-1FFF;
}
/* greek */
@font-face {
font-family: 'Roboto';
font-style: normal;
font-weight: 300;
src: url(https://fonts.gstatic.com/s/roboto/v30/KFOlCnqEu92Fr1MmSU5fBxc4EsA.woff2) format('woff2');
unicode-range: U+0370-03FF;
}
/* vietnamese */
@font-face {
font-family: 'Roboto';
font-style: normal;
font-weight: 300;
src: url(https://fonts.gstatic.com/s/roboto/v30/KFOlCnqEu92Fr1MmSU5fCxc4EsA.woff2) format('woff2');
unicode-range: U+0102-0103, U+0110-0111, U+0128-0129, U+0168-0169, U+01A0-01A1, U+01AF-01B0, U+1EA0-1EF9, U+20AB;
}
/* latin-ext */
@font-face {
font-family: 'Roboto';
font-style: normal;
font-weight: 300;
src: url(https://fonts.gstatic.com/s/roboto/v30/KFOlCnqEu92Fr1MmSU5fChc4EsA.woff2) format('woff2');
unicode-range: U+0100-024F, U+0259, U+1E00-1EFF, U+2020, U+20A0-20AB, U+20AD-20CF, U+2113, U+2C60-2C7F, U+A720-A7FF;
}
/* latin */
@font-face {
font-family: 'Roboto';
font-style: normal;
font-weight: 300;
src: url(https://fonts.gstatic.com/s/roboto/v30/KFOlCnqEu92Fr1MmSU5fBBc4.woff2) format('woff2');
unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+2000-206F, U+2074, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}
/* cyrillic-ext */
@font-face {
font-family: 'Roboto';
font-style: normal;
font-weight: 400;
src: url(https://fonts.gstatic.com/s/roboto/v30/KFOmCnqEu92Fr1Mu72xKOzY.woff2) format('woff2');
unicode-range: U+0460-052F, U+1C80-1C88, U+20B4, U+2DE0-2DFF, U+A640-A69F, U+FE2E-FE2F;
}
/* cyrillic */
@font-face {
font-family: 'Roboto';
font-style: normal;
font-weight: 400;
src: url(https://fonts.gstatic.com/s/roboto/v30/KFOmCnqEu92Fr1Mu5mxKOzY.woff2) format('woff2');
unicode-range: U+0301, U+0400-045F, U+0490-0491, U+04B0-04B1, U+2116;
}
/* greek-ext */
@font-face {
font-family: 'Roboto';
font-style: normal;
font-weight: 400;
src: url(https://fonts.gstatic.com/s/roboto/v30/KFOmCnqEu92Fr1Mu7mxKOzY.woff2) format('woff2');
unicode-range: U+1F00-1FFF;
}
/* greek */
@font-face {
font-family: 'Roboto';
font-style: normal;
font-weight: 400;
src: url(https://fonts.gstatic.com/s/roboto/v30/KFOmCnqEu92Fr1Mu4WxKOzY.woff2) format('woff2');
unicode-range: U+0370-03FF;
}
/* vietnamese */
@font-face {
font-family: 'Roboto';
font-style: normal;
font-weight: 400;
src: url(https://fonts.gstatic.com/s/roboto/v30/KFOmCnqEu92Fr1Mu7WxKOzY.woff2) format('woff2');
unicode-range: U+0102-0103, U+0110-0111, U+0128-0129, U+0168-0169, U+01A0-01A1, U+01AF-01B0, U+1EA0-1EF9, U+20AB;
}
/* latin-ext */
@font-face {
font-family: 'Roboto';
font-style: normal;
font-weight: 400;
src: url(https://fonts.gstatic.com/s/roboto/v30/KFOmCnqEu92Fr1Mu7GxKOzY.woff2) format('woff2');
unicode-range: U+0100-024F, U+0259, U+1E00-1EFF, U+2020, U+20A0-20AB, U+20AD-20CF, U+2113, U+2C60-2C7F, U+A720-A7FF;
}
/* latin */
@font-face {
font-family: 'Roboto';
font-style: normal;
font-weight: 400;
src: url(https://fonts.gstatic.com/s/roboto/v30/KFOmCnqEu92Fr1Mu4mxK.woff2) format('woff2');
unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+2000-206F, U+2074, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}
33 changes: 33 additions & 0 deletions src/server/assets/css/contextMenu.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
ul.contextMenu {
list-style: none;
margin: 0;
padding: 0.3em;
font: 300 15px "Roboto", sans-serif;
position: absolute;
color: white;
box-shadow: 0 12px 15px 0px rgba(0, 0, 0, 0.2);
border-radius: 0.3em;
background-color: #23445e;
}
ul.contextMenu * {
transition: all 0.4s;
}
ul.contextMenu li {
min-width: 150px;
overflow: hidden;
white-space: nowrap;
padding: 12px 15px;
cursor: default;
border-radius: 0.2em;
}
ul.contextMenu li i {
width: 1em;
}
ul.contextMenu li i.fa-file-lines {
position: relative;
left: 2px;
}

ul.contextMenu li:hover {
background-color: #395973;
}
8 changes: 8 additions & 0 deletions src/server/assets/css/main.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
body,
html,
iframe {
height: 100%;
width: 100%;
margin: 0;
padding: 0;
}
2 changes: 2 additions & 0 deletions src/server/assets/js/font-awesome.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 2 additions & 0 deletions src/server/assets/js/jquery.min.js

Large diffs are not rendered by default.

Loading

0 comments on commit 784b655

Please sign in to comment.