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 = {