Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Mp markdown #21

Open
wants to merge 5 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -9,3 +9,4 @@ coverage
style.js
tsconfig.json
packages/*/LICENSE
.history
11 changes: 11 additions & 0 deletions packages/mp/.babelrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
{
"plugins": [
["module-resolver", {
"root": ["./src"],
"alias": {}
}]
],
"presets": [
["env", {"loose": true, "modules": "commonjs"}]
]
}
7 changes: 7 additions & 0 deletions packages/mp/.commitlintrc.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
module.exports = {
extends: [
'@commitlint/config-conventional'
],
rules: {
}
}
1 change: 1 addition & 0 deletions packages/mp/.eslintignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
*.min.js
96 changes: 96 additions & 0 deletions packages/mp/.eslintrc.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,96 @@
module.exports = {
'extends': [
'airbnb-base',
'plugin:promise/recommended'
],
'parserOptions': {
'ecmaVersion': 9,
'ecmaFeatures': {
'jsx': false
},
'sourceType': 'module'
},
'env': {
'es6': true,
'node': true,
'jest': true
},
'plugins': [
'import',
'node',
'promise'
],
'rules': {
'arrow-parens': 'off',
'comma-dangle': [
'error',
'only-multiline'
],
'complexity': ['error', 10],
'func-names': 'off',
'global-require': 'off',
'handle-callback-err': [
'error',
'^(err|error)$'
],
'import/no-unresolved': [
'error',
{
'caseSensitive': true,
'commonjs': true,
'ignore': ['^[^.]']
}
],
'import/prefer-default-export': 'off',
'linebreak-style': 'off',
'no-catch-shadow': 'error',
'no-continue': 'off',
'no-div-regex': 'warn',
'no-else-return': 'off',
'no-param-reassign': 'off',
'no-plusplus': 'off',
'no-shadow': 'off',
'no-multi-assign': 'off',
'no-underscore-dangle': 'off',
'node/no-deprecated-api': 'error',
'node/process-exit-as-throw': 'error',
'object-curly-spacing': [
'error',
'never'
],
'operator-linebreak': [
'error',
'after',
{
'overrides': {
':': 'before',
'?': 'before'
}
}
],
'prefer-arrow-callback': 'off',
'prefer-destructuring': 'off',
'prefer-template': 'off',
'quote-props': [
1,
'as-needed',
{
'unnecessary': true
}
],
'semi': [
'error',
'never'
]
},
'globals': {
'window': true,
'document': true,
'App': true,
'Page': true,
'Component': true,
'Behavior': true,
'wx': true,
'getCurrentPages': true,
}
}
15 changes: 15 additions & 0 deletions packages/mp/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
.idea
.DS_Store

logs
*.log
npm-debug.log*
yarn-debug.log*
yarn-error.log*

miniprogram_dist
miniprogram_dev
miniprogram_npm
node_modules
coverage
.history
3 changes: 3 additions & 0 deletions packages/mp/.gitmodules
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
[submodule "src/weui-wxss"]
path = src/weui-wxss
url = http://git.code.oa.com/modules/weui-wxss.git
17 changes: 17 additions & 0 deletions packages/mp/.npmignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
.idea
.DS_Store
package-lock.json

logs
*.log
npm-debug.log*
yarn-debug.log*
yarn-error.log*

test
tools
docs
miniprogram_dev
miniprogram_npm
node_modules
coverage
8 changes: 0 additions & 8 deletions packages/mp/CHANGELOG.md

This file was deleted.

42 changes: 42 additions & 0 deletions packages/mp/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
## 开发

1. 安装依赖:

```
npm install
```

2. 执行命令:

```
npm run dev
```

默认会在包根目录下生成 miniprogram\_dev 目录,src 中的源代码会被构建并生成到 miniprogram\_dev/components 目录下。如果需要监听文件变化动态构建,则可以执行命令:

```
npm run watch
```

3. 生成的 miniprogram\_dev 目录是一个小程序项目目录,以此目录作为小程序项目目录在开发者工具中打开即可查看自定义组件被使用的效果。

## 其他命令

* 清空 miniprogram_dist 目录:

```
npm run clean
```

* 清空 miniprogam_dev 目录:

```
npm run clean-dev
```
## 子模块开发

src 下每个组件目录对应一个 npm 模块,需保证文件名均为 index.xxx,同时添加 package.json, 参考 src/video-swiper。

## 发布npm包

`npm run dist` 后生成 miniprogram_npm 目录,进入到每个子项目中执行 `npm publish --access=publish`
17 changes: 17 additions & 0 deletions packages/mp/docs/markdown.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
# markdown

markdown组件。

## 属性列表

| 属性 | 类型 | 默认值 | 必填 | 说明 |
| -------------------- | ----------- | ------- | ---- | ------------------------------------------------- |
| md | String | | 是 | 需要渲染的markdown文本 |
| highlight | Boolean | false | 否 | 代码是否高亮 |

### 注意事项
- 需要在app.json中添加"recursion-node": "components/markdown/index", 用以markdown组件自调用

### 示例代码

<mp-markdown md="{{markdown}}" highlight></mp-markdown>
28 changes: 28 additions & 0 deletions packages/mp/gulpfile.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
const gulp = require('gulp')
const clean = require('gulp-clean')

const config = require('./tools/config')
const BuildTask = require('./tools/build')
const id = require('./package.json').name

// 构建任务实例
// eslint-disable-next-line no-new
new BuildTask(id, config.entry)

// 清空生成目录和文件
gulp.task('clean', gulp.series(() => gulp.src(config.distPath, {read: false, allowEmpty: true}).pipe(clean()), done => {
if (config.isDev) {
return gulp.src(config.demoDist, {read: false, allowEmpty: true})
.pipe(clean())
}

return done()
}))
// 监听文件变化并进行开发模式构建
gulp.task('watch', gulp.series(`${id}-watch`))
// 开发模式构建
gulp.task('dev', gulp.series(`${id}-dev`))
// 生产模式构建
gulp.task('default', gulp.series(`${id}-default`))
// 构建demo
gulp.task('demo', gulp.series(`${id}-demo`))
93 changes: 72 additions & 21 deletions packages/mp/package.json
Original file line number Diff line number Diff line change
@@ -1,31 +1,82 @@
{
"name": "@bytemd/mp",
"version": "1.3.4",
"private": true,
"description": "Full-featured markdown editor and viewer",
"author": "Rongjian Zhang <pd4d10@gmail.com>",
"license": "MIT",
"version": "1.0.0",
"description": "wx miniprogram markdown viewer",
"main": "miniprogram_dist/index.js",
"scripts": {
"init": "git submodule init && git submodule update --init --remote && npm run dev",
"dev": "gulp dev --develop",
"demo": "gulp demo --develop",
"watch": "gulp watch --develop --watch",
"copy": "sh tools/copy.sh",
"build": "gulp",
"dist": "npm run build && npm run copy",
"clean-dev": "gulp clean --develop",
"clean": "gulp clean",
"test": "jest ./test/* --silent --bail",
"coverage": "jest ./test/* --coverage --bail",
"lint": "eslint \"src/**/*.js\"",
"lint-tools": "eslint \"tools/**/*.js\" --rule \"import/no-extraneous-dependencies: false\""
},
"miniprogram": "miniprogram_dist",
"jest": {
"testEnvironment": "jsdom",
"testURL": "https://jest.test",
"collectCoverageFrom": [
"src/**/*.js"
],
"moduleDirectories": [
"node_modules",
"src"
]
},
"repository": {
"type": "git",
"url": "https://github.com/bytedance/bytemd.git",
"directory": "packages/mp"
},
"main": "dist/index.cjs.js",
"module": "dist/index.esm.js",
"unpkg": "dist/index.min.js",
"jsdelivr": "dist/index.min.js",
"types": "lib/index.d.ts",
"files": [
"dist",
"lib"
],
"dependencies": {
"bytemd": "^1.3.4"
},
"publishConfig": {
"access": "public"
"author": "baozuona <bznsummer@163.com>",
"license": "MIT",
"husky": {
"hooks": {
"commit-msg": "commitlint -e $GIT_PARAMS"
}
},
"devDependencies": {
"miniprogram-api-typings": "^3.2.0"
}
"@commitlint/cli": "^8.2.0",
"@commitlint/config-conventional": "^8.2.0",
"autoprefixer": "^6.5.1",
"babel-core": "^6.26.3",
"babel-loader": "^7.1.5",
"babel-plugin-module-resolver": "^3.2.0",
"babel-preset-env": "^1.7.0",
"colors": "^1.3.1",
"eslint": "^5.14.1",
"eslint-config-airbnb-base": "13.1.0",
"eslint-loader": "^2.1.2",
"eslint-plugin-import": "^2.16.0",
"eslint-plugin-node": "^7.0.1",
"eslint-plugin-promise": "^3.8.0",
"fs-extra": "^8.1.0",
"gulp": "^4.0.0",
"gulp-clean": "^0.4.0",
"gulp-if": "^2.0.2",
"gulp-install": "^1.1.0",
"gulp-less": "^4.0.1",
"gulp-rename": "^1.4.0",
"gulp-sourcemaps": "^2.6.5",
"husky": "^4.0.0-beta.5",
"jest": "^23.5.0",
"miniprogram-api-typings": "^2.9.2",
"miniprogram-simulate": "^1.0.0",
"through2": "^2.0.3",
"ts-loader": "^5.3.3",
"tslint": "^5.13.1",
"tslint-loader": "^3.5.4",
"typescript": "^3.3.3333",
"vinyl": "^2.2.0",
"webpack": "^4.29.5",
"webpack-node-externals": "^1.7.2"
},
"dependencies": {}
}
5 changes: 5 additions & 0 deletions packages/mp/src/index.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"usingComponents": {
"markdown": "./markdown/index"
}
}
5 changes: 5 additions & 0 deletions packages/mp/src/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
// import FormValidator from './form/form-validator'

export {
// FormValidator
}
Loading