From 5ead47308dd1ce05e4d2ed2336bc1eb0e424b53e Mon Sep 17 00:00:00 2001
From: Shigma <1700011071@pku.edu.cn>
Date: Wed, 26 Sep 2018 21:12:27 +0800
Subject: [PATCH 01/30] initial commit
---
packages/docs/index.mkl | 3 +++
packages/docs/marklet.yml | 1 +
packages/docs/package.json | 12 ++++++++++++
3 files changed, 16 insertions(+)
create mode 100644 packages/docs/index.mkl
create mode 100644 packages/docs/marklet.yml
create mode 100644 packages/docs/package.json
diff --git a/packages/docs/index.mkl b/packages/docs/index.mkl
new file mode 100644
index 0000000..9c8859f
--- /dev/null
+++ b/packages/docs/index.mkl
@@ -0,0 +1,3 @@
+# Marklet
+
+A markup language designed for API manual pages.
diff --git a/packages/docs/marklet.yml b/packages/docs/marklet.yml
new file mode 100644
index 0000000..a5ef50f
--- /dev/null
+++ b/packages/docs/marklet.yml
@@ -0,0 +1 @@
+version: 1.0
diff --git a/packages/docs/package.json b/packages/docs/package.json
new file mode 100644
index 0000000..9fb1a04
--- /dev/null
+++ b/packages/docs/package.json
@@ -0,0 +1,12 @@
+{
+ "name": "@marklet/docs",
+ "private": true,
+ "version": "1.0.0",
+ "description": "",
+ "main": "index.js",
+ "scripts": {
+ "test": "echo \"Error: no test specified\" && exit 1"
+ },
+ "author": "shigma <1700011071@pku.edu.cn>",
+ "license": "MIT"
+}
From d8764c1544aa6c4cf42b01a1595884fe1134706a Mon Sep 17 00:00:00 2001
From: Shigma <1700011071@pku.edu.cn>
Date: Sun, 30 Sep 2018 10:03:57 +0800
Subject: [PATCH 02/30] add some adjustments
---
.vscode/settings.json | 3 +--
packages/docs/marklet.yml | 2 ++
packages/docs/package.json | 3 ---
packages/docs/{ => src}/index.mkl | 0
4 files changed, 3 insertions(+), 5 deletions(-)
rename packages/docs/{ => src}/index.mkl (100%)
diff --git a/.vscode/settings.json b/.vscode/settings.json
index 4c96c16..67167c4 100644
--- a/.vscode/settings.json
+++ b/.vscode/settings.json
@@ -5,10 +5,9 @@
"vue"
],
"files.exclude": {
+ "**/node_modules": true,
"**/package-lock.json": true,
"package.json.lerna_backup": true,
- "packages/**/node_modules": true,
- "packages/**/tsconfig.json": true
},
"editor.wordSeparators": "`~!@#%^&*()-=+[{]}\\|;:'\",.<>/?",
}
\ No newline at end of file
diff --git a/packages/docs/marklet.yml b/packages/docs/marklet.yml
index a5ef50f..dee993a 100644
--- a/packages/docs/marklet.yml
+++ b/packages/docs/marklet.yml
@@ -1 +1,3 @@
version: 1.0
+srcDir: src
+outDir: ../../docs/docs
diff --git a/packages/docs/package.json b/packages/docs/package.json
index 9fb1a04..90d5a80 100644
--- a/packages/docs/package.json
+++ b/packages/docs/package.json
@@ -4,9 +4,6 @@
"version": "1.0.0",
"description": "",
"main": "index.js",
- "scripts": {
- "test": "echo \"Error: no test specified\" && exit 1"
- },
"author": "shigma <1700011071@pku.edu.cn>",
"license": "MIT"
}
diff --git a/packages/docs/index.mkl b/packages/docs/src/index.mkl
similarity index 100%
rename from packages/docs/index.mkl
rename to packages/docs/src/index.mkl
From a4eaf9fcb5fcbc84d981bd60b94d2601d8fc3e0e Mon Sep 17 00:00:00 2001
From: Shigma <1700011071@pku.edu.cn>
Date: Sat, 6 Oct 2018 20:05:47 +0800
Subject: [PATCH 03/30] simple theme initiate
---
README.md | 15 ++++----
build/scss.js | 37 ++++++++++++++++++++
build/sfc2js.js | 26 ++++++++++++++
packages/app/build/transpile.js | 52 +++++++---------------------
packages/app/comp/app.vue | 2 +-
packages/renderer/themes/simple.scss | 50 ++++++++++++++++++++++++++
6 files changed, 134 insertions(+), 48 deletions(-)
create mode 100644 build/scss.js
create mode 100644 build/sfc2js.js
create mode 100644 packages/renderer/themes/simple.scss
diff --git a/README.md b/README.md
index 460db34..ba2bf4f 100644
--- a/README.md
+++ b/README.md
@@ -9,13 +9,14 @@ A markup language designed for API manual pages.
## Packages
-- [markletjs](https://github.com/obstudio/Marklet/tree/master/packages/marklet): [![npm](https://img.shields.io/npm/v/markletjs.svg)](https://www.npmjs.com/package/markletjs)
-- [@marklet/cli](https://github.com/obstudio/Marklet/tree/master/packages/cli): [![npm](https://img.shields.io/npm/v/@marklet/cli.svg)](https://www.npmjs.com/package/@marklet/cli)
-- [@marklet/core](https://github.com/obstudio/Marklet/tree/master/packages/core): [![npm](https://img.shields.io/npm/v/@marklet/core.svg)](https://www.npmjs.com/package/@marklet/core)
-- [@marklet/dev-server](https://github.com/obstudio/Marklet/tree/master/packages/dev-server): [![npm](https://img.shields.io/npm/v/@marklet/dev-server.svg)](https://www.npmjs.com/package/@marklet/dev-server)
-- [@marklet/monaco](https://github.com/obstudio/Marklet/tree/master/packages/monaco): [![npm](https://img.shields.io/npm/v/@marklet/monaco.svg)](https://www.npmjs.com/package/@marklet/monaco)
-- [@marklet/parser](https://github.com/obstudio/Marklet/tree/master/packages/parser): [![npm](https://img.shields.io/npm/v/@marklet/parser.svg)](https://www.npmjs.com/package/@marklet/parser)
-- [@marklet/renderer](https://github.com/obstudio/Marklet/tree/master/packages/renderer): [![npm](https://img.shields.io/npm/v/@marklet/renderer.svg)](https://www.npmjs.com/package/@marklet/renderer)
+| package | version |
+|:-------:|:-------:|
+|[@marklet/cli](https://github.com/obstudio/Marklet/tree/master/packages/cli)|[![npm](https://img.shields.io/npm/v/@marklet/cli.svg)](https://www.npmjs.com/package/@marklet/cli)|
+|[@marklet/core](https://github.com/obstudio/Marklet/tree/master/packages/core)|[![npm](https://img.shields.io/npm/v/@marklet/core.svg)](https://www.npmjs.com/package/@marklet/core)|
+|[@marklet/dev-server](https://github.com/obstudio/Marklet/tree/master/packages/dev-server)|[![npm](https://img.shields.io/npm/v/@marklet/dev-server.svg)](https://www.npmjs.com/package/@marklet/dev-server)|
+|[@marklet/monaco](https://github.com/obstudio/Marklet/tree/master/packages/monaco)|[![npm](https://img.shields.io/npm/v/@marklet/monaco.svg)](https://www.npmjs.com/package/@marklet/monaco)|
+|[@marklet/parser](https://github.com/obstudio/Marklet/tree/master/packages/parser)|[![npm](https://img.shields.io/npm/v/@marklet/parser.svg)](https://www.npmjs.com/package/@marklet/parser)|
+|[@marklet/renderer](https://github.com/obstudio/Marklet/tree/master/packages/renderer)|[![npm](https://img.shields.io/npm/v/@marklet/renderer.svg)](https://www.npmjs.com/package/@marklet/renderer)|
## Usage: CLI
diff --git a/build/scss.js b/build/scss.js
new file mode 100644
index 0000000..a6a6737
--- /dev/null
+++ b/build/scss.js
@@ -0,0 +1,37 @@
+const util = require('./util')
+const sass = require('sass')
+const fs = require('fs')
+
+function load({
+ src,
+ dest,
+ selector,
+ base = '',
+ cache = dest.slice(0, -3) + 'cache.scss',
+}) {
+ let cacheData = ''
+ try {
+ cacheData = fs.readFileSync(util.resolve(base, cache)).toString()
+ } catch (error) { /**/ }
+
+ const source = fs.readFileSync(util.resolve(base, src)).toString()
+ const srcData = selector ? `${selector}{${source}}` : source
+
+ if (srcData === cacheData && fs.existsSync(util.resolve(dest))) {
+ return fs.readFileSync(util.resolve(base, dest)).toString()
+ } else {
+ const destData = sass.renderSync({ data: srcData }).css.toString()
+ fs.writeFileSync(util.resolve(base, dest), destData)
+ fs.writeFileSync(util.resolve(base, cache), srcData)
+ return destData
+ }
+}
+
+function loadAll(...options) {
+ return options.map(load).join('')
+}
+
+module.exports = {
+ load,
+ loadAll,
+}
diff --git a/build/sfc2js.js b/build/sfc2js.js
new file mode 100644
index 0000000..e04bee5
--- /dev/null
+++ b/build/sfc2js.js
@@ -0,0 +1,26 @@
+const sfc2js = require('sfc2js')
+const sass = require('sass')
+const path = require('path')
+
+sfc2js.install({
+ name: 'sass-plugin',
+ version: '1.0',
+ target: 'style',
+ lang: [
+ 'sass',
+ 'scss',
+ 'css',
+ ],
+ default: {
+ includePaths: [],
+ },
+ updated(options) {
+ const dirPath = path.dirname(options.srcPath)
+ this.options.includePaths.push(dirPath)
+ },
+ render(style) {
+ return sass.renderSync({ ...this.options, data: style.content }).css.toString()
+ },
+})
+
+module.exports = sfc2js
diff --git a/packages/app/build/transpile.js b/packages/app/build/transpile.js
index 80d914e..21ece29 100644
--- a/packages/app/build/transpile.js
+++ b/packages/app/build/transpile.js
@@ -1,32 +1,9 @@
+const sass = require('../../../build/scss')
const util = require('../../../build/util')
-const sfc2js = require('sfc2js')
-const sass = require('sass')
-const path = require('path')
-const fs = require('fs')
+const sfc2js = require('../../../build/sfc2js')
util.start()
-sfc2js.install({
- name: 'sass-plugin',
- version: '1.0',
- target: 'style',
- lang: [
- 'sass',
- 'scss',
- 'css',
- ],
- default: {
- includePaths: [],
- },
- updated(options) {
- const dirPath = path.dirname(options.srcPath)
- this.options.includePaths.push(dirPath)
- },
- render(style) {
- return sass.renderSync({ ...this.options, data: style.content }).css.toString()
- },
-})
-
module.exports = sfc2js.transpile({
baseDir: util.resolve(),
srcDir: 'app/comp',
@@ -34,21 +11,16 @@ module.exports = sfc2js.transpile({
enterance: util.isElectron() ? 'app.vue' : '',
})
-let indexCache = ''
-try {
- indexCache = fs.readFileSync(util.resolve('app/temp/index.cache.scss')).toString()
-} catch (error) { /**/ }
-
-const indexData = fs.readFileSync(util.resolve('app/comp/index.scss')).toString()
-
-if (indexData === indexCache && fs.existsSync(util.resolve('app/temp/index.css'))) {
- module.exports.css += fs.readFileSync(util.resolve('app/temp/index.css')).toString()
-} else {
- const indexCSS = sass.renderSync({ data: indexData }).css.toString()
- fs.writeFileSync(util.resolve('app/temp/index.css'), indexCSS)
- fs.writeFileSync(util.resolve('app/temp/index.cache.scss'), indexCache)
- module.exports.css += indexCSS
-}
+module.exports.css += sass.loadAll({
+ base: 'app',
+ src: 'comp/index.scss',
+ dest: 'temp/index.css',
+}, {
+ base: 'renderer',
+ src: 'themes/simple.scss',
+ dest: 'dist/simple.css',
+ selector: '.simple',
+})
if (util.isElectron()) {
const result = sfc2js.transpile({
diff --git a/packages/app/comp/app.vue b/packages/app/comp/app.vue
index 684e3cd..c18b7ea 100644
--- a/packages/app/comp/app.vue
+++ b/packages/app/comp/app.vue
@@ -105,7 +105,7 @@ module.exports = {
diff --git a/packages/renderer/themes/simple.scss b/packages/renderer/themes/simple.scss
new file mode 100644
index 0000000..e5a2f6a
--- /dev/null
+++ b/packages/renderer/themes/simple.scss
@@ -0,0 +1,50 @@
+& {
+ color: #24292e;
+ background-color: #f0f1f2;
+
+ blockquote {
+ color: #606060;
+ border-left-color: #c0c0c0;
+ background-color: #e6e6e6;
+ &.r { border-left-color: #F92672; background-color: #eae3e3 }
+ &.g { border-left-color: #96E22E; background-color: #e3eae3 }
+ &.b { border-left-color: #66D9EF; background-color: #e3e3ea }
+ }
+
+ .usage blockquote {
+ border-color: #f6f6f6 !important;
+ background-color: #e0e0e0;
+ &:not(:last-child) { border-bottom-color: #e0e0e0 }
+ &:not(:first-child) { border-top-color: #e0e0e0 }
+
+ > span:first-child {
+ color: #24292e;
+ em { color: #808080 }
+ }
+ }
+
+ h1 { border-bottom: 4px solid #bababa }
+ h2 { border-bottom: 2px solid #bababa }
+ hr { border-bottom: 1px solid #d0d0d0; background-color: #c8c8c8 }
+
+ table {
+ th, td { border: 1px solid #636363 }
+ tr { background-color: #e0e0e0; border-top: 1px solid #636363 }
+ tr :nth-child(2n) { background-color: #e8e8e8 }
+ }
+
+ a { color: #409eff }
+ img { background-color: transparent }
+ code { background-color: #e0e0e0 }
+ span.comment { color: #454749 }
+
+ .codeblock {
+ background-color: #e0e0e0;
+ &::-webkit-scrollbar-thumb {
+ background-color: #c0c0c0;
+ box-shadow: inset 0 0 4px rgba(255,255,255,0.5);
+ &:hover { background-color: #a8a8a8 }
+ &:window-inactive { background-color: #d0d0d0; box-shadow: none }
+ }
+ }
+}
From 7ea0db382ac22e3fa96bddc46808f7fff97afbfc Mon Sep 17 00:00:00 2001
From: Shigma <1700011071@pku.edu.cn>
Date: Sat, 6 Oct 2018 20:19:26 +0800
Subject: [PATCH 04/30] monaco css
---
.gitignore | 4 +++-
.vscode/settings.json | 1 +
build/scss.js | 19 ++++++++++---------
packages/app/build/transpile.js | 11 +++++++----
packages/app/comp/index.scss | 32 --------------------------------
packages/app/package.json | 4 ++--
packages/monaco/.npmignore | 3 ++-
packages/monaco/index.scss | 31 +++++++++++++++++++++++++++++++
packages/monaco/package.json | 2 +-
9 files changed, 57 insertions(+), 50 deletions(-)
create mode 100644 packages/monaco/index.scss
diff --git a/.gitignore b/.gitignore
index 4db6739..407a7d3 100644
--- a/.gitignore
+++ b/.gitignore
@@ -5,5 +5,7 @@ dist
temp
!test
*.tgz
+*.cache.*
packages/app/main.js
-packages/app/index.html
\ No newline at end of file
+packages/app/index.html
+packages/monaco/index.css
\ No newline at end of file
diff --git a/.vscode/settings.json b/.vscode/settings.json
index 691d6e0..6a2d8de 100644
--- a/.vscode/settings.json
+++ b/.vscode/settings.json
@@ -5,6 +5,7 @@
"vue"
],
"files.exclude": {
+ "**/*.cache.*": true,
"**/node_modules": true,
"**/package-lock.json": true,
"package.json.lerna_backup": true,
diff --git a/build/scss.js b/build/scss.js
index a6a6737..3109223 100644
--- a/build/scss.js
+++ b/build/scss.js
@@ -4,25 +4,26 @@ const fs = require('fs')
function load({
src,
- dest,
+ dest = src,
selector,
base = '',
- cache = dest.slice(0, -3) + 'cache.scss',
+ cache = dest,
+ style = 'compressed',
}) {
let cacheData = ''
try {
- cacheData = fs.readFileSync(util.resolve(base, cache)).toString()
+ cacheData = fs.readFileSync(util.resolve(base, cache + '.cache.scss')).toString()
} catch (error) { /**/ }
- const source = fs.readFileSync(util.resolve(base, src)).toString()
+ const source = fs.readFileSync(util.resolve(base, src + '.scss')).toString()
const srcData = selector ? `${selector}{${source}}` : source
- if (srcData === cacheData && fs.existsSync(util.resolve(dest))) {
- return fs.readFileSync(util.resolve(base, dest)).toString()
+ if (srcData === cacheData && fs.existsSync(util.resolve(dest + '.css'))) {
+ return fs.readFileSync(util.resolve(base, dest + '.css')).toString()
} else {
- const destData = sass.renderSync({ data: srcData }).css.toString()
- fs.writeFileSync(util.resolve(base, dest), destData)
- fs.writeFileSync(util.resolve(base, cache), srcData)
+ const destData = sass.renderSync({ data: srcData, outputStyle: style }).css.toString()
+ fs.writeFileSync(util.resolve(base, dest + '.css'), destData)
+ fs.writeFileSync(util.resolve(base, cache + '.cache.scss'), srcData)
return destData
}
}
diff --git a/packages/app/build/transpile.js b/packages/app/build/transpile.js
index 21ece29..efc63cc 100644
--- a/packages/app/build/transpile.js
+++ b/packages/app/build/transpile.js
@@ -13,13 +13,16 @@ module.exports = sfc2js.transpile({
module.exports.css += sass.loadAll({
base: 'app',
- src: 'comp/index.scss',
- dest: 'temp/index.css',
+ src: 'comp/index',
+ dest: 'temp/index',
}, {
base: 'renderer',
- src: 'themes/simple.scss',
- dest: 'dist/simple.css',
+ src: 'themes/simple',
+ dest: 'dist/simple',
selector: '.simple',
+}, {
+ base: 'monaco',
+ src: 'index',
})
if (util.isElectron()) {
diff --git a/packages/app/comp/index.scss b/packages/app/comp/index.scss
index ef3896f..e9a6dc8 100644
--- a/packages/app/comp/index.scss
+++ b/packages/app/comp/index.scss
@@ -15,35 +15,3 @@ body {
.no-transition {
transition: none !important;
}
-
-.monaco-editor {
- .monaco-scrollable-element {
- > .scrollbar {
- transition: opacity 0.3s ease;
-
- > .slider {
- opacity: 0.5;
- cursor: pointer;
- border-radius: 6px;
- background-color: #c0c4cc;
- transition: opacity 0.3s ease;
-
- &:hover {
- opacity: 1;
- }
- }
-
- &.vertical {
- margin: 4px 0;
- }
-
- &.horizontal {
- margin: 0 4px;
- }
-
- &.invisible.fade {
- transition: opacity 0.8s ease;
- }
- }
- }
-}
diff --git a/packages/app/package.json b/packages/app/package.json
index 113f2fc..5c1037b 100644
--- a/packages/app/package.json
+++ b/packages/app/package.json
@@ -1,6 +1,6 @@
{
"name": "@marklet/app",
- "version": "1.0.10",
+ "version": "1.0.11",
"private": true,
"main": "main.js",
"author": "shigma <1700011071@pku.edu.cn>",
@@ -17,7 +17,7 @@
"url": "https://github.com/obstudio/Marklet/issues"
},
"dependencies": {
- "@marklet/monaco": "^1.2.1",
+ "@marklet/monaco": "^1.3.0",
"@marklet/parser": "^1.5.1",
"@marklet/renderer": "^1.3.1",
"neat-scroll": "^2.0.1",
diff --git a/packages/monaco/.npmignore b/packages/monaco/.npmignore
index f649af7..0e173cc 100644
--- a/packages/monaco/.npmignore
+++ b/packages/monaco/.npmignore
@@ -1 +1,2 @@
-.eslintrc.yml
\ No newline at end of file
+.eslintrc.yml
+*.scss
\ No newline at end of file
diff --git a/packages/monaco/index.scss b/packages/monaco/index.scss
new file mode 100644
index 0000000..11adffb
--- /dev/null
+++ b/packages/monaco/index.scss
@@ -0,0 +1,31 @@
+.monaco-editor {
+ .monaco-scrollable-element {
+ > .scrollbar {
+ transition: opacity 0.3s ease;
+
+ > .slider {
+ opacity: 0.5;
+ cursor: pointer;
+ border-radius: 6px;
+ background-color: #c0c4cc;
+ transition: opacity 0.3s ease;
+
+ &:hover {
+ opacity: 1;
+ }
+ }
+
+ &.vertical {
+ margin: 4px 0;
+ }
+
+ &.horizontal {
+ margin: 0 4px;
+ }
+
+ &.invisible.fade {
+ transition: opacity 0.8s ease;
+ }
+ }
+ }
+}
diff --git a/packages/monaco/package.json b/packages/monaco/package.json
index 3de5bad..982a696 100644
--- a/packages/monaco/package.json
+++ b/packages/monaco/package.json
@@ -1,6 +1,6 @@
{
"name": "@marklet/monaco",
- "version": "1.2.1",
+ "version": "1.3.0",
"description": "A monaco plugin for marklet.",
"author": "jjyyxx <1449843302@qq.com>",
"contributors": [
From 556377c3d2861617d387e046b1dcdfcd7c85332e Mon Sep 17 00:00:00 2001
From: Shigma <1700011071@pku.edu.cn>
Date: Sat, 6 Oct 2018 20:25:55 +0800
Subject: [PATCH 05/30] dark theme initiate
---
{build => packages/app/build}/scss.js | 2 +-
{build => packages/app/build}/sfc2js.js | 0
packages/app/build/transpile.js | 11 ++++--
packages/app/comp/app.vue | 2 +-
packages/renderer/themes/dark.scss | 51 +++++++++++++++++++++++++
5 files changed, 61 insertions(+), 5 deletions(-)
rename {build => packages/app/build}/scss.js (95%)
rename {build => packages/app/build}/sfc2js.js (100%)
create mode 100644 packages/renderer/themes/dark.scss
diff --git a/build/scss.js b/packages/app/build/scss.js
similarity index 95%
rename from build/scss.js
rename to packages/app/build/scss.js
index 3109223..69cca55 100644
--- a/build/scss.js
+++ b/packages/app/build/scss.js
@@ -1,4 +1,4 @@
-const util = require('./util')
+const util = require('../../../build/util')
const sass = require('sass')
const fs = require('fs')
diff --git a/build/sfc2js.js b/packages/app/build/sfc2js.js
similarity index 100%
rename from build/sfc2js.js
rename to packages/app/build/sfc2js.js
diff --git a/packages/app/build/transpile.js b/packages/app/build/transpile.js
index efc63cc..c7be432 100644
--- a/packages/app/build/transpile.js
+++ b/packages/app/build/transpile.js
@@ -1,6 +1,6 @@
-const sass = require('../../../build/scss')
const util = require('../../../build/util')
-const sfc2js = require('../../../build/sfc2js')
+const sfc2js = require('./sfc2js')
+const scss = require('./scss')
util.start()
@@ -11,7 +11,7 @@ module.exports = sfc2js.transpile({
enterance: util.isElectron() ? 'app.vue' : '',
})
-module.exports.css += sass.loadAll({
+module.exports.css += scss.loadAll({
base: 'app',
src: 'comp/index',
dest: 'temp/index',
@@ -20,6 +20,11 @@ module.exports.css += sass.loadAll({
src: 'themes/simple',
dest: 'dist/simple',
selector: '.simple',
+}, {
+ base: 'renderer',
+ src: 'themes/dark',
+ dest: 'dist/dark',
+ selector: '.dark',
}, {
base: 'monaco',
src: 'index',
diff --git a/packages/app/comp/app.vue b/packages/app/comp/app.vue
index c18b7ea..3bd7a09 100644
--- a/packages/app/comp/app.vue
+++ b/packages/app/comp/app.vue
@@ -105,7 +105,7 @@ module.exports = {
diff --git a/packages/renderer/themes/dark.scss b/packages/renderer/themes/dark.scss
new file mode 100644
index 0000000..90aaaa0
--- /dev/null
+++ b/packages/renderer/themes/dark.scss
@@ -0,0 +1,51 @@
+* {
+ color: #fafaf5;
+ background-color: #282828;
+
+ blockquote {
+ color: #c6cbd1;
+ border-left-color: #c0c0c0;
+ background-color: #3d3d3d;
+ &.r { border-left-color: #F92672; background-color: #423939 }
+ &.g { border-left-color: #96E22E; background-color: #394239 }
+ &.b { border-left-color: #66D9EF; background-color: #393942 }
+ }
+
+ .usage blockquote {
+ border-color: #2D2F3F !important;
+ background-color: #393942;
+ &:not(:last-child) { border-bottom-color: #393952 }
+ &:not(:first-child) { border-top-color: #393952 }
+
+ > span:first-child {
+ color: #e1e4e8;
+ em { color: #9697a8 }
+ }
+ }
+
+ pre { background-color: #202020 }
+ h1 { border-bottom: 4px solid #454545 }
+ h2 { border-bottom: 2px solid #454545 }
+ hr { border-bottom: 1px solid #202020; background-color: #282828 }
+
+ table {
+ th, td { border: 1px solid #a0a0a0 }
+ tr { background-color: #282828; border-top: 1px solid #a0a0a0 }
+ tr :nth-child(2n) { background-color: #202020 }
+ }
+
+ a { color: #7fcfff }
+ img { background-color: transparent }
+ code { background-color: #3d3d3d }
+ span.comment { color: #c6cbd1 }
+
+ .codeblock {
+ background-color: #383933;
+ &::-webkit-scrollbar-thumb {
+ background-color: #555555;
+ box-shadow: inset 0 0 4px rgba(0,0,0,0.5);
+ &:hover { background-color: #616161 }
+ &:window-inactive { background-color: #353535; box-shadow: none }
+ }
+ }
+}
\ No newline at end of file
From 92998024894f94889952d8737ffe28de8bd7f0a2 Mon Sep 17 00:00:00 2001
From: Shigma <1700011071@pku.edu.cn>
Date: Sun, 7 Oct 2018 00:29:30 +0800
Subject: [PATCH 06/30] input
---
packages/app/build/transpile.js | 4 -
packages/app/comp/app.vue | 39 ++++++--
packages/app/comp/index.css | 16 ++++
packages/app/comp/index.scss | 17 ----
packages/app/index.dev.html | 1 +
packages/renderer/comp/codeblock.vue | 2 +-
packages/renderer/comp/collapse.vue | 4 +-
packages/renderer/comp/input.vue | 137 +++++++++++++++++++++++++++
packages/renderer/src/index.js | 1 +
packages/renderer/themes/dark.scss | 86 +++++++++--------
packages/renderer/themes/simple.scss | 80 ++++++++--------
11 files changed, 275 insertions(+), 112 deletions(-)
create mode 100644 packages/app/comp/index.css
delete mode 100644 packages/app/comp/index.scss
create mode 100644 packages/renderer/comp/input.vue
diff --git a/packages/app/build/transpile.js b/packages/app/build/transpile.js
index c7be432..3adee4f 100644
--- a/packages/app/build/transpile.js
+++ b/packages/app/build/transpile.js
@@ -12,10 +12,6 @@ module.exports = sfc2js.transpile({
})
module.exports.css += scss.loadAll({
- base: 'app',
- src: 'comp/index',
- dest: 'temp/index',
-}, {
base: 'renderer',
src: 'themes/simple',
dest: 'dist/simple',
diff --git a/packages/app/comp/app.vue b/packages/app/comp/app.vue
index 3bd7a09..7377971 100644
--- a/packages/app/comp/app.vue
+++ b/packages/app/comp/app.vue
@@ -5,10 +5,14 @@ const monacoLoader = require('@marklet/monaco')
Vue.use(monacoLoader)
+const themes = ['simple', 'dark']
+
module.exports = {
el: '#app',
data: () => ({
+ themeInput: '',
+ theme: 'dark',
origin: '',
source: '',
nodes: [],
@@ -25,7 +29,10 @@ module.exports = {
this._editor.setModel(this._model)
this.layout()
}
- }
+ },
+ themeInput(value) {
+ if (themes.includes(value)) this.theme = value
+ },
},
created() {
@@ -96,25 +103,45 @@ module.exports = {
if (newTime - now < deltaTime) requestAnimationFrame(layout)
})
},
+ validateTheme() {
+ return themes.includes(this.themeInput)
+ },
}
}
-
+
diff --git a/packages/renderer/comp/input.vue b/packages/renderer/comp/input.vue
new file mode 100644
index 0000000..b917b53
--- /dev/null
+++ b/packages/renderer/comp/input.vue
@@ -0,0 +1,137 @@
+
+
+
+
+
+
+
diff --git a/packages/renderer/src/index.js b/packages/renderer/src/index.js
index 9ce956e..08a702c 100644
--- a/packages/renderer/src/index.js
+++ b/packages/renderer/src/index.js
@@ -8,6 +8,7 @@ const Renderer = {
Vue.component('mkl-collapse', require('../temp/collapse.vue'))
Vue.component('mkl-heading', require('../temp/heading.vue'))
Vue.component('mkl-inlinelist', require('../temp/inlinelist.vue'))
+ Vue.component('mkl-input', require('../temp/input.vue'))
Vue.component('mkl-list-item', require('../temp/list-item.vue'))
Vue.component('mkl-list', require('../temp/list.vue'))
Vue.component('mkl-nodes', require('../temp/nodes.vue'))
diff --git a/packages/renderer/themes/dark.scss b/packages/renderer/themes/dark.scss
index 90aaaa0..29eff71 100644
--- a/packages/renderer/themes/dark.scss
+++ b/packages/renderer/themes/dark.scss
@@ -1,51 +1,53 @@
-* {
- color: #fafaf5;
- background-color: #282828;
+& {
+ .document {
+ color: #fafaf5;
+ background-color: #282828;
- blockquote {
- color: #c6cbd1;
- border-left-color: #c0c0c0;
- background-color: #3d3d3d;
- &.r { border-left-color: #F92672; background-color: #423939 }
- &.g { border-left-color: #96E22E; background-color: #394239 }
- &.b { border-left-color: #66D9EF; background-color: #393942 }
- }
+ blockquote {
+ color: #c6cbd1;
+ border-left-color: #c0c0c0;
+ background-color: #3d3d3d;
+ &.r { border-left-color: #F92672; background-color: #423939 }
+ &.g { border-left-color: #96E22E; background-color: #394239 }
+ &.b { border-left-color: #66D9EF; background-color: #393942 }
+ }
- .usage blockquote {
- border-color: #2D2F3F !important;
- background-color: #393942;
- &:not(:last-child) { border-bottom-color: #393952 }
- &:not(:first-child) { border-top-color: #393952 }
+ .usage blockquote {
+ border-color: #2D2F3F !important;
+ background-color: #393942;
+ &:not(:last-child) { border-bottom-color: #393952 }
+ &:not(:first-child) { border-top-color: #393952 }
- > span:first-child {
- color: #e1e4e8;
- em { color: #9697a8 }
+ > span:first-child {
+ color: #e1e4e8;
+ em { color: #9697a8 }
+ }
}
- }
- pre { background-color: #202020 }
- h1 { border-bottom: 4px solid #454545 }
- h2 { border-bottom: 2px solid #454545 }
- hr { border-bottom: 1px solid #202020; background-color: #282828 }
-
- table {
- th, td { border: 1px solid #a0a0a0 }
- tr { background-color: #282828; border-top: 1px solid #a0a0a0 }
- tr :nth-child(2n) { background-color: #202020 }
- }
+ pre { background-color: #202020 }
+ h1 { border-bottom: 4px solid #454545 }
+ h2 { border-bottom: 2px solid #454545 }
+ hr { border-bottom: 1px solid #202020; background-color: #282828 }
+
+ table {
+ th, td { border: 1px solid #a0a0a0 }
+ tr { background-color: #282828; border-top: 1px solid #a0a0a0 }
+ tr :nth-child(2n) { background-color: #202020 }
+ }
- a { color: #7fcfff }
- img { background-color: transparent }
- code { background-color: #3d3d3d }
- span.comment { color: #c6cbd1 }
+ a { color: #7fcfff }
+ img { background-color: transparent }
+ code { background-color: #3d3d3d }
+ span.comment { color: #c6cbd1 }
- .codeblock {
- background-color: #383933;
- &::-webkit-scrollbar-thumb {
- background-color: #555555;
- box-shadow: inset 0 0 4px rgba(0,0,0,0.5);
- &:hover { background-color: #616161 }
- &:window-inactive { background-color: #353535; box-shadow: none }
+ .codeblock {
+ background-color: #383933;
+ &::-webkit-scrollbar-thumb {
+ background-color: #555555;
+ box-shadow: inset 0 0 4px rgba(0,0,0,0.5);
+ &:hover { background-color: #616161 }
+ &:window-inactive { background-color: #353535; box-shadow: none }
+ }
}
}
-}
\ No newline at end of file
+}
diff --git a/packages/renderer/themes/simple.scss b/packages/renderer/themes/simple.scss
index e5a2f6a..2fdca1b 100644
--- a/packages/renderer/themes/simple.scss
+++ b/packages/renderer/themes/simple.scss
@@ -1,50 +1,52 @@
& {
- color: #24292e;
- background-color: #f0f1f2;
+ .document {
+ color: #24292e;
+ background-color: #f0f1f2;
- blockquote {
- color: #606060;
- border-left-color: #c0c0c0;
- background-color: #e6e6e6;
- &.r { border-left-color: #F92672; background-color: #eae3e3 }
- &.g { border-left-color: #96E22E; background-color: #e3eae3 }
- &.b { border-left-color: #66D9EF; background-color: #e3e3ea }
- }
+ blockquote {
+ color: #606060;
+ border-left-color: #c0c0c0;
+ background-color: #e6e6e6;
+ &.r { border-left-color: #F92672; background-color: #eae3e3 }
+ &.g { border-left-color: #96E22E; background-color: #e3eae3 }
+ &.b { border-left-color: #66D9EF; background-color: #e3e3ea }
+ }
- .usage blockquote {
- border-color: #f6f6f6 !important;
- background-color: #e0e0e0;
- &:not(:last-child) { border-bottom-color: #e0e0e0 }
- &:not(:first-child) { border-top-color: #e0e0e0 }
+ .usage blockquote {
+ border-color: #f6f6f6 !important;
+ background-color: #e0e0e0;
+ &:not(:last-child) { border-bottom-color: #e0e0e0 }
+ &:not(:first-child) { border-top-color: #e0e0e0 }
- > span:first-child {
- color: #24292e;
- em { color: #808080 }
+ > span:first-child {
+ color: #24292e;
+ em { color: #808080 }
+ }
}
- }
- h1 { border-bottom: 4px solid #bababa }
- h2 { border-bottom: 2px solid #bababa }
- hr { border-bottom: 1px solid #d0d0d0; background-color: #c8c8c8 }
-
- table {
- th, td { border: 1px solid #636363 }
- tr { background-color: #e0e0e0; border-top: 1px solid #636363 }
- tr :nth-child(2n) { background-color: #e8e8e8 }
- }
+ h1 { border-bottom: 4px solid #bababa }
+ h2 { border-bottom: 2px solid #bababa }
+ hr { border-bottom: 1px solid #d0d0d0; background-color: #c8c8c8 }
+
+ table {
+ th, td { border: 1px solid #636363 }
+ tr { background-color: #e0e0e0; border-top: 1px solid #636363 }
+ tr :nth-child(2n) { background-color: #e8e8e8 }
+ }
- a { color: #409eff }
- img { background-color: transparent }
- code { background-color: #e0e0e0 }
- span.comment { color: #454749 }
+ a { color: #409eff }
+ img { background-color: transparent }
+ code { background-color: #e0e0e0 }
+ span.comment { color: #454749 }
- .codeblock {
- background-color: #e0e0e0;
- &::-webkit-scrollbar-thumb {
- background-color: #c0c0c0;
- box-shadow: inset 0 0 4px rgba(255,255,255,0.5);
- &:hover { background-color: #a8a8a8 }
- &:window-inactive { background-color: #d0d0d0; box-shadow: none }
+ .codeblock {
+ background-color: #e0e0e0;
+ &::-webkit-scrollbar-thumb {
+ background-color: #c0c0c0;
+ box-shadow: inset 0 0 4px rgba(255,255,255,0.5);
+ &:hover { background-color: #a8a8a8 }
+ &:window-inactive { background-color: #d0d0d0; box-shadow: none }
+ }
}
}
}
From 85fb4ecdf2b2e8b0b408376b8d904b74ed423591 Mon Sep 17 00:00:00 2001
From: Shigma <1700011071@pku.edu.cn>
Date: Sun, 7 Oct 2018 02:04:20 +0800
Subject: [PATCH 07/30] add some adjustments
---
packages/app/build/transpile.js | 12 ++-
packages/app/comp/app.vue | 19 +++--
packages/app/comp/index.css | 4 +
packages/app/index.dev.html | 1 +
packages/app/package.json | 1 +
packages/monaco/index.scss | 4 +
.../themes/{dark.scss => dark/index.scss} | 0
packages/renderer/themes/dark/monaco.yaml | 76 +++++++++++++++++++
.../themes/{simple.scss => simple/index.scss} | 0
packages/renderer/themes/simple/monaco.yaml | 76 +++++++++++++++++++
10 files changed, 185 insertions(+), 8 deletions(-)
rename packages/renderer/themes/{dark.scss => dark/index.scss} (100%)
create mode 100644 packages/renderer/themes/dark/monaco.yaml
rename packages/renderer/themes/{simple.scss => simple/index.scss} (100%)
create mode 100644 packages/renderer/themes/simple/monaco.yaml
diff --git a/packages/app/build/transpile.js b/packages/app/build/transpile.js
index 3adee4f..bf03b7f 100644
--- a/packages/app/build/transpile.js
+++ b/packages/app/build/transpile.js
@@ -1,6 +1,8 @@
const util = require('../../../build/util')
const sfc2js = require('./sfc2js')
const scss = require('./scss')
+const yaml = require('js-yaml')
+const fs = require('fs')
util.start()
@@ -13,12 +15,12 @@ module.exports = sfc2js.transpile({
module.exports.css += scss.loadAll({
base: 'renderer',
- src: 'themes/simple',
+ src: 'themes/simple/index',
dest: 'dist/simple',
selector: '.simple',
}, {
base: 'renderer',
- src: 'themes/dark',
+ src: 'themes/dark/index',
dest: 'dist/dark',
selector: '.dark',
}, {
@@ -37,6 +39,12 @@ if (util.isElectron()) {
props: ['node'],
},
})
+
+ module.exports.themes = {
+ dark: yaml.safeLoad(fs.readFileSync(util.resolve('renderer/themes/dark/monaco.yaml'))),
+ simple: yaml.safeLoad(fs.readFileSync(util.resolve('renderer/themes/simple/monaco.yaml'))),
+ }
+
module.exports.css += result.css
module.exports.plugin = result.app
}
diff --git a/packages/app/comp/app.vue b/packages/app/comp/app.vue
index 7377971..830b1fb 100644
--- a/packages/app/comp/app.vue
+++ b/packages/app/comp/app.vue
@@ -30,6 +30,11 @@ module.exports = {
this.layout()
}
},
+ theme(value) {
+ if (window.monaco) {
+ window.monaco.editor.setTheme(value)
+ }
+ },
themeInput(value) {
if (themes.includes(value)) this.theme = value
},
@@ -42,6 +47,9 @@ module.exports = {
this._lexer = new DocumentLexer()
monacoLoader.then((monaco) => {
+ themes.forEach((name) => {
+ monaco.editor.defineTheme(name, window.result.themes[name])
+ })
const model = monaco.editor.createModel(this.source, 'marklet')
model.onDidChangeContent(() => this.checkChange())
const nodes = this.nodes
@@ -56,7 +64,7 @@ module.exports = {
window.vm = this
monacoLoader.then((monaco) => {
- monaco.editor.setTheme('vs')
+ monaco.editor.setTheme(this.theme)
this._editor = monaco.editor.create(this.$refs.input, {
model: null,
language: 'marklet',
@@ -103,9 +111,6 @@ module.exports = {
if (newTime - now < deltaTime) requestAnimationFrame(layout)
})
},
- validateTheme() {
- return themes.includes(this.themeInput)
- },
}
}
@@ -114,7 +119,7 @@ module.exports = {
-
+
@@ -131,6 +136,8 @@ module.exports = {
left: 0;
right: 0;
height: 40px;
+ box-sizing: border-box;
+ border-bottom: 2px solid;
.mkl-input {
font-size: 14px;
@@ -150,7 +157,7 @@ module.exports = {
width: 50%;
}
-> .mkl-scroll.document {
+> .mkl-scroll {
left: 50%;
right: 0;
diff --git a/packages/app/comp/index.css b/packages/app/comp/index.css
index df3a6d2..c602397 100644
--- a/packages/app/comp/index.css
+++ b/packages/app/comp/index.css
@@ -9,6 +9,10 @@ body {
"微软雅黑",
Arial,
sans-serif;
+ transition:
+ color 0.3s ease,
+ background-color 0.3s ease,
+ border-color 0.3s ease;
}
.no-transition {
diff --git a/packages/app/index.dev.html b/packages/app/index.dev.html
index 1d1959b..d7018da 100644
--- a/packages/app/index.dev.html
+++ b/packages/app/index.dev.html
@@ -15,6 +15,7 @@
const style = document.createElement('style')
style.innerText = result.css
document.head.appendChild(style)
+ window.result = result
Vue.use(result.plugin)
new Vue(result.app)
diff --git a/packages/app/package.json b/packages/app/package.json
index 5c1037b..558d4ca 100644
--- a/packages/app/package.json
+++ b/packages/app/package.json
@@ -20,6 +20,7 @@
"@marklet/monaco": "^1.3.0",
"@marklet/parser": "^1.5.1",
"@marklet/renderer": "^1.3.1",
+ "js-yaml": "^3.12.0",
"neat-scroll": "^2.0.1",
"vue": "^2.5.17"
}
diff --git a/packages/monaco/index.scss b/packages/monaco/index.scss
index 11adffb..f3e17a5 100644
--- a/packages/monaco/index.scss
+++ b/packages/monaco/index.scss
@@ -1,4 +1,8 @@
.monaco-editor {
+ .decorationsOverviewRuler {
+ display: none;
+ }
+
.monaco-scrollable-element {
> .scrollbar {
transition: opacity 0.3s ease;
diff --git a/packages/renderer/themes/dark.scss b/packages/renderer/themes/dark/index.scss
similarity index 100%
rename from packages/renderer/themes/dark.scss
rename to packages/renderer/themes/dark/index.scss
diff --git a/packages/renderer/themes/dark/monaco.yaml b/packages/renderer/themes/dark/monaco.yaml
new file mode 100644
index 0000000..ca9add3
--- /dev/null
+++ b/packages/renderer/themes/dark/monaco.yaml
@@ -0,0 +1,76 @@
+base: vs-dark
+rules: []
+inherit: true
+
+colors:
+ dropdown.background: '#414339'
+ list.activeSelectionBackground: '#75715E'
+ list.focusBackground: '#414339'
+ dropdown.listBackground: '#1e1f1c'
+ list.inactiveSelectionBackground: '#414339'
+ list.hoverBackground: '#3e3d32'
+ list.dropBackground: '#414339'
+ list.highlightForeground: '#f8f8f2'
+ button.background: '#75715E'
+ editor.background: '#272822'
+ editor.foreground: '#f8f8f2'
+ selection.background: '#ccccc7'
+ editor.selectionHighlightBackground: '#575b6180'
+ editor.selectionBackground: '#878b9180'
+ editor.wordHighlightBackground: '#4a4a7680'
+ editor.wordHighlightStrongBackground: '#6a6a9680'
+ editor.lineHighlightBackground: '#3e3d32'
+ editorLineNumber.activeForeground: '#c2c2bf'
+ editorCursor.foreground: '#f8f8f0'
+ editorWhitespace.foreground: '#464741'
+ editorIndentGuide.background: '#464741'
+ editorIndentGuide.activeBackground: '#767771'
+ editorGroupHeader.tabsBackground: '#1e1f1c'
+ editorGroup.dropBackground: '#41433980'
+ tab.inactiveBackground: '#414339'
+ tab.border: '#1e1f1c'
+ tab.inactiveForeground: '#ccccc7'
+ widget.shadow: '#000000'
+ progressBar.background: '#75715E'
+ badge.background: '#75715E'
+ badge.foreground: '#f8f8f2'
+ editorLineNumber.foreground: '#90908a'
+ panelTitle.activeForeground: '#f8f8f2'
+ panelTitle.activeBorder: '#75715E'
+ panelTitle.inactiveForeground: '#75715E'
+ panel.border: '#414339'
+ titleBar.activeBackground: '#1e1f1c'
+ statusBar.background: '#414339'
+ statusBar.noFolderBackground: '#414339'
+ statusBar.debuggingBackground: '#75715E'
+ activityBar.background: '#272822'
+ activityBar.foreground: '#f8f8f2'
+ activityBar.dropBackground: '#414339'
+ sideBar.background: '#1e1f1c'
+ sideBarSectionHeader.background: '#272822'
+ pickerGroup.foreground: '#75715E'
+ input.background: '#414339'
+ inputOption.activeBorder: '#75715E'
+ focusBorder: '#75715E'
+ editorWidget.background: '#1e1f1c'
+ debugToolBar.background: '#1e1f1c'
+ diffEditor.insertedTextBackground: '#66852880'
+ diffEditor.removedTextBackground: '#90274A80'
+ inputValidation.errorBackground: '#90274A'
+ inputValidation.errorBorder: '#f92672'
+ inputValidation.warningBackground: '#848528'
+ inputValidation.warningBorder: '#e2e22e'
+ inputValidation.infoBackground: '#546190'
+ inputValidation.infoBorder: '#819aff'
+ editorHoverWidget.background: '#414339'
+ editorHoverWidget.border: '#75715E'
+ editorSuggestWidget.background: '#272822'
+ editorSuggestWidget.border: '#75715E'
+ editorGroup.border: '#414339'
+ peekView.border: '#75715E'
+ peekViewEditor.background: '#272822'
+ peekViewResult.background: '#1e1f1c'
+ peekViewTitle.background: '#1e1f1c'
+ peekViewResult.selectionBackground: '#414339'
+ peekViewResult.matchHighlightBackground: '#75715E'
+ peekViewEditor.matchHighlightBackground: '#75715E'
diff --git a/packages/renderer/themes/simple.scss b/packages/renderer/themes/simple/index.scss
similarity index 100%
rename from packages/renderer/themes/simple.scss
rename to packages/renderer/themes/simple/index.scss
diff --git a/packages/renderer/themes/simple/monaco.yaml b/packages/renderer/themes/simple/monaco.yaml
new file mode 100644
index 0000000..8652b36
--- /dev/null
+++ b/packages/renderer/themes/simple/monaco.yaml
@@ -0,0 +1,76 @@
+base: vs
+rules: []
+inherit: true
+
+colors:
+ dropdown.background: '#ffffff'
+ list.activeSelectionBackground: '#75715E'
+ list.focusBackground: '#ffffff'
+ dropdown.listBackground: '#efeff2'
+ list.inactiveSelectionBackground: '#E5EBF1'
+ list.hoverBackground: '#E8E8E8'
+ list.dropBackground: '#ffffff'
+ list.highlightForeground: '#007acc'
+ button.background: '#75715E'
+ editor.background: '#ffffff'
+ editor.foreground: '#24292e'
+ selection.background: '#ccccc7'
+ editor.selectionHighlightBackground: '#ADD6FF4D'
+ editor.selectionBackground: '#5badff80'
+ editor.wordHighlightBackground: '#4a4a7680'
+ editor.wordHighlightStrongBackground: '#6a6a9680'
+ editor.lineHighlightBackground: '#fffbdd'
+ editorLineNumber.activeForeground: '#0b0b59'
+ editorCursor.foreground: '#000000'
+ editorWhitespace.foreground: '#464741'
+ editorIndentGuide.background: '#eeeeee'
+ editorIndentGuide.activeBackground: '#939393'
+ editorGroupHeader.tabsBackground: '#efeff2'
+ editorGroup.dropBackground: '#41433980'
+ tab.inactiveBackground: '#fafbfc'
+ tab.border: '#efeff2'
+ tab.inactiveForeground: '#ccccc7'
+ widget.shadow: '#808080'
+ progressBar.background: '#75715E'
+ badge.background: '#75715E'
+ badge.foreground: '#f8f8f2'
+ editorLineNumber.foreground: '#cccccc'
+ panelTitle.activeForeground: '#f8f8f2'
+ panelTitle.activeBorder: '#75715E'
+ panelTitle.inactiveForeground: '#75715E'
+ panel.border: '#ffffff'
+ titleBar.activeBackground: '#fafbfc'
+ statusBar.background: '#fafbfc'
+ statusBar.noFolderBackground: '#fafbfc'
+ statusBar.debuggingBackground: '#fafbfc'
+ activityBar.background: '#24292e'
+ activityBar.foreground: '#fafbfc'
+ activityBar.dropBackground: '#ffffff'
+ sideBar.background: '#fafbfc'
+ sideBarSectionHeader.background: '#F1F2F3'
+ pickerGroup.foreground: '#75715E'
+ input.background: '#ffffff'
+ inputOption.activeBorder: '#75715E'
+ focusBorder: '#fafbfc'
+ editorWidget.background: '#efeff2'
+ debugToolBar.background: '#efeff2'
+ diffEditor.insertedTextBackground: '#66852880'
+ diffEditor.removedTextBackground: '#90274A80'
+ inputValidation.errorBackground: '#90274A'
+ inputValidation.errorBorder: '#f92672'
+ inputValidation.warningBackground: '#848528'
+ inputValidation.warningBorder: '#e2e22e'
+ inputValidation.infoBackground: '#546190'
+ inputValidation.infoBorder: '#819aff'
+ editorHoverWidget.background: '#ffffff'
+ editorHoverWidget.border: '#75715E'
+ editorSuggestWidget.background: '#F3F3F3'
+ editorSuggestWidget.border: '#75715E'
+ editorGroup.border: '#ffffff'
+ peekView.border: '#75715E'
+ peekViewEditor.background: '#272822'
+ peekViewResult.background: '#efeff2'
+ peekViewTitle.background: '#efeff2'
+ peekViewResult.selectionBackground: '#ffffff'
+ peekViewResult.matchHighlightBackground: '#75715E'
+ peekViewEditor.matchHighlightBackground: '#75715E'
From f24bf5390e0309ff7839faffe8cf6dab24e21d4f Mon Sep 17 00:00:00 2001
From: Shigma <1700011071@pku.edu.cn>
Date: Wed, 10 Oct 2018 21:36:50 +0800
Subject: [PATCH 08/30] monaco in dev server
---
.gitignore | 3 +-
build/build.js | 55 +++++--
package.json | 2 +-
packages/dev-server/comp/edit.vue | 154 +++++++++++++++++-
packages/dev-server/package.json | 1 +
packages/dev-server/src/client.ts | 9 +-
packages/dev-server/src/index.html | 14 +-
packages/dev-server/src/server.ts | 4 +-
.../themes/dark.yaml} | 0
.../themes/simple.yaml} | 0
packages/renderer/src/index.js | 1 +
.../themes/{dark/index.scss => dark.scss} | 0
packages/renderer/themes/index.json | 10 ++
.../themes/{simple/index.scss => simple.scss} | 0
14 files changed, 220 insertions(+), 33 deletions(-)
rename packages/{renderer/themes/dark/monaco.yaml => dev-server/themes/dark.yaml} (100%)
rename packages/{renderer/themes/simple/monaco.yaml => dev-server/themes/simple.yaml} (100%)
rename packages/renderer/themes/{dark/index.scss => dark.scss} (100%)
create mode 100644 packages/renderer/themes/index.json
rename packages/renderer/themes/{simple/index.scss => simple.scss} (100%)
diff --git a/.gitignore b/.gitignore
index 407a7d3..1e5f855 100644
--- a/.gitignore
+++ b/.gitignore
@@ -8,4 +8,5 @@ temp
*.cache.*
packages/app/main.js
packages/app/index.html
-packages/monaco/index.css
\ No newline at end of file
+packages/monaco/index.css
+packages/dev-server/themes/*.json
\ No newline at end of file
diff --git a/build/build.js b/build/build.js
index 943fe09..ded393c 100644
--- a/build/build.js
+++ b/build/build.js
@@ -1,15 +1,18 @@
-const util = require('./util')
+const themes = require('../packages/renderer/themes')
+const { exec, resolve } = require('./util')
const { minify } = require('html-minifier')
const program = require('commander')
const webpack = require('webpack')
const sfc2js = require('sfc2js')
+const sass = require('node-sass')
+const yaml = require('js-yaml')
const fs = require('fs')
sfc2js.install(require('@sfc2js/sass'))
sfc2js.install(require('@sfc2js/clean-css'))
function mkdirIfNotExists(name) {
- fs.existsSync(util.resolve(name)) || fs.mkdirSync(util.resolve(name))
+ fs.existsSync(resolve(name)) || fs.mkdirSync(resolve(name))
}
program
@@ -31,14 +34,14 @@ const bundle = (name, options) => new Promise((resolve, reject) => {
const compiler = webpack({
target: 'web',
mode: env,
- entry: util.resolve(name, options.entry),
+ entry: resolve(name, options.entry),
resolve: {
alias: {
- '@': util.resolve(name, 'temp')
+ '@': resolve(name, 'temp')
}
},
output: {
- path: util.resolve(name, 'dist'),
+ path: resolve(name, 'dist'),
filename: options.output,
library: 'Marklet',
libraryTarget: 'umd',
@@ -69,16 +72,33 @@ Promise.resolve().then(() => {
sfc2js.transpile({
...sfc2jsOptions,
- baseDir: util.resolve('renderer'),
+ baseDir: resolve('renderer'),
outCSSFile: '../dist/marklet.min.css',
defaultScript: {
props: ['node'],
},
})
- return bundle('renderer', {
- entry: 'src/index.js',
- output: 'renderer.min.js',
+ let css = ''
+ return Promise.all(themes.map(({ key }) => new Promise((resolve, reject) => {
+ const filepath = resolve('renderer/themes', key + '.scss')
+ sass.render({
+ data: `.${key}.marklet{${fs.readFileSync(filepath).toString()}}`,
+ outputStyle: 'compressed',
+ }, (error, result) => {
+ if (error) {
+ reject(error)
+ } else {
+ css += result.css.toString()
+ resolve()
+ }
+ })
+ }))).then(() => {
+ fs.writeFileSync(resolve('renderer/dist/themes.min.css'), css)
+ return bundle('renderer', {
+ entry: 'src/index.js',
+ output: 'renderer.min.js',
+ })
})
}
}).then(() => {
@@ -86,30 +106,35 @@ Promise.resolve().then(() => {
mkdirIfNotExists('dev-server/dist')
if (program.tsc) {
- util.exec('tsc -p packages/dev-server')
+ exec('tsc -p packages/dev-server')
}
if (program.prod) {
fs.writeFileSync(
- util.resolve('dev-server/dist/index.html'),
- minify(fs.readFileSync(util.resolve('dev-server/src/index.html')).toString(), {
+ resolve('dev-server/dist/index.html'),
+ minify(fs.readFileSync(resolve('dev-server/src/index.html')).toString(), {
collapseWhitespace: true,
removeAttributeQuotes: true,
})
)
} else {
fs.copyFileSync(
- util.resolve('dev-server/src/index.html'),
- util.resolve('dev-server/dist/index.html')
+ resolve('dev-server/src/index.html'),
+ resolve('dev-server/dist/index.html')
)
}
sfc2js.transpile({
...sfc2jsOptions,
- baseDir: util.resolve('dev-server'),
+ baseDir: resolve('dev-server'),
outCSSFile: '../dist/client.min.css',
})
+ themes.forEach(({ key }) => {
+ const options = yaml.safeLoad(fs.readFileSync(resolve(`dev-server/themes/${key}.yaml`)))
+ fs.writeFileSync(resolve(`dev-server/themes/${key}.json`), JSON.stringify(options))
+ })
+
return bundle('dev-server', {
entry: 'dist/client.js',
output: 'client.min.js',
diff --git a/package.json b/package.json
index 8578516..98281a5 100644
--- a/package.json
+++ b/package.json
@@ -1,7 +1,7 @@
{
"scripts": {
"start": "npm run build && node packages/cli -m edit",
- "bootstrap": "lerna bootstrap --hoist --no-ci",
+ "bootstrap": "lerna bootstrap --no-ci",
"build": "tsc -b && node build/build -sr",
"build:prod": "tsc -b && node build/build -psr",
"build:renderer": "node build/build -r",
diff --git a/packages/dev-server/comp/edit.vue b/packages/dev-server/comp/edit.vue
index 8fe1e49..9e8aeaa 100644
--- a/packages/dev-server/comp/edit.vue
+++ b/packages/dev-server/comp/edit.vue
@@ -1,26 +1,166 @@
-
-
-
+
-
\ No newline at end of file
+
diff --git a/packages/dev-server/package.json b/packages/dev-server/package.json
index a0e9c11..755979e 100644
--- a/packages/dev-server/package.json
+++ b/packages/dev-server/package.json
@@ -23,6 +23,7 @@
"dependencies": {
"@marklet/parser": "^1.5.1",
"@marklet/renderer": "^1.3.1",
+ "monaco-editor": "^0.14.3",
"vue": "^2.5.17",
"ws": "^6.0.0"
}
diff --git a/packages/dev-server/src/client.ts b/packages/dev-server/src/client.ts
index 169cdd6..f851a7e 100644
--- a/packages/dev-server/src/client.ts
+++ b/packages/dev-server/src/client.ts
@@ -1,11 +1,9 @@
-import Vue from 'vue'
+import VueConstructor from 'vue'
import * as renderer from '@marklet/renderer'
import { DocumentLexer, LexerConfig } from '@marklet/parser'
-declare module 'vue/types/vue' {
- interface Vue {
- $eventBus: Vue
- }
+declare global {
+ export const Vue: typeof VueConstructor
}
const eventBus = new Vue()
@@ -26,7 +24,6 @@ const client = new class WatchClient {
this.url = url
this.retry = retry
this.timeout = timeout
-
this.createWebSocket()
}
diff --git a/packages/dev-server/src/index.html b/packages/dev-server/src/index.html
index acb3782..edaab62 100644
--- a/packages/dev-server/src/index.html
+++ b/packages/dev-server/src/index.html
@@ -4,12 +4,24 @@
Marklet
-
+
+
+
+
+