├── .github └── workflows │ ├── build.yml │ └── npm-publish.yml ├── .gitignore ├── .npmignore ├── .release-it.js ├── .vscode └── settings.json ├── DEV.md ├── README-en.md ├── README.md ├── babel.config.json ├── build ├── config │ ├── common.js │ ├── dev.js │ └── prd.js └── create-rollup-config.js ├── example ├── App.vue ├── index.html ├── index.ts └── pages │ ├── Basic.vue │ ├── Simple.vue │ └── VModelHTML.vue ├── package.json ├── rollup.config.js ├── rollup.example.config.js ├── shims-vue.d.ts ├── src ├── components │ ├── Editor.vue │ └── Toolbar.vue └── index.ts ├── tsconfig.json └── yarn.lock /.github/workflows/build.yml: -------------------------------------------------------------------------------- 1 | name: build project 2 | 3 | on: 4 | push: 5 | branches: 6 | - 'main' 7 | - 'master' 8 | - 'dev' 9 | - 'feature-*' 10 | - 'fix-*' 11 | - 'hotfix-*' 12 | - 'refactor-*' 13 | 14 | jobs: 15 | build: 16 | runs-on: ubuntu-latest 17 | steps: 18 | - uses: actions/checkout@v2 19 | - uses: actions/setup-node@v1 20 | with: 21 | node-version: 14 22 | registry-url: https://registry.npmjs.org/ 23 | - run: yarn 24 | - run: yarn --version 25 | - run: node --version 26 | # - run: yarn test 27 | - run: yarn build 28 | -------------------------------------------------------------------------------- /.github/workflows/npm-publish.yml: -------------------------------------------------------------------------------- 1 | name: publish npm Package 2 | 3 | on: 4 | push: 5 | tags: 6 | - 'v*.*.*' 7 | 8 | jobs: 9 | publish-npm: 10 | runs-on: ubuntu-latest 11 | steps: 12 | - uses: actions/checkout@v2 13 | - uses: actions/setup-node@v1 14 | with: 15 | node-version: 12 16 | registry-url: https://registry.npmjs.org/ 17 | - run: yarn 18 | # - run: yarn test 19 | - run: yarn build 20 | - run: npm publish --access=public 21 | env: 22 | NODE_AUTH_TOKEN: ${{secrets.NPM_TOKEN}} 23 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | dist/ 2 | node_modules/ 3 | dist-example/ 4 | stats.html -------------------------------------------------------------------------------- /.npmignore: -------------------------------------------------------------------------------- 1 | .github/ 2 | .vscode 3 | build/ 4 | doc/ 5 | docs/ 6 | example/ 7 | __tests__/ 8 | .release-it.js 9 | index.html 10 | tsconfig.json 11 | src/ -------------------------------------------------------------------------------- /.release-it.js: -------------------------------------------------------------------------------- 1 | module.exports = { 2 | git: { 3 | tagName: 'v${version}', 4 | commitMessage: 'release: v${version}', 5 | requireCleanWorkingDir: false, 6 | requireBranch: 'main', 7 | }, 8 | hooks: { 9 | 'before:init': ['git pull origin main'], 10 | }, 11 | npm: { 12 | publish: false, 13 | }, 14 | prompt: { 15 | ghRelease: false, 16 | glRelease: false, 17 | publish: false, 18 | }, 19 | }; 20 | -------------------------------------------------------------------------------- /.vscode/settings.json: -------------------------------------------------------------------------------- 1 | { 2 | "cSpell.words": [ 3 | "rollup", 4 | "wangeditor", 5 | "wangfupeng" 6 | ] 7 | } -------------------------------------------------------------------------------- /DEV.md: -------------------------------------------------------------------------------- 1 | # 开发文档 2 | 3 | ## 目录结构 4 | 5 | ```bash 6 | ├── __test__ # 测试文件 7 | ├── build # 构建工具配置文件 8 | ├── example # dev环境下的example 9 | ├── rollup.config.js # rollup打包主入口文件 10 | ├── rollup.example.config.js # example运行配置文件 11 | └── src 12 | ├── components 13 | │ ├── Editor.vue 14 | │ └── Toolbar.vue 15 | ├── utils 16 | └── index.ts 17 | ``` 18 | 19 | ## dev 本地开发 20 | 21 | `yarn dev` 启动本地服务,使用 src/App.vue 文件 22 | 23 | `yarn test` 单元测试,使用 test 目录 24 | 25 | ## build 构建 26 | 27 | `yarn build` 构建代码,使用 src 目录。 28 | 29 | ## release 发布 30 | 31 | `yarn release` 可触发 github actions 并发布 npm 32 | -------------------------------------------------------------------------------- /README-en.md: -------------------------------------------------------------------------------- 1 | # wangEditor for Vue 2 | 3 | [](https://github.com/facebook/react/blob/main/LICENSE) [](https://www.npmjs.com/package/@wangeditor/editor-for-vue/v/next) [](https://github.com/wangeditor-team/wangEditor-for-vue/actions) 4 | 5 | [中文文档](./README.md) 6 | 7 | ## Introduction 8 | 9 | An out-of-the-box [Vue2 component](https://www.wangeditor.com/v5/for-frame.html#vue2) 10 | based on the [wangEditor 5](https://www.wangeditor.com/v5/for-frame.html#vue2) 11 | 12 | ## Installation 13 | 14 | ```shell 15 | yarn add @wangeditor/editor 16 | yarn add @wangeditor/editor-for-vue 17 | ``` 18 | 19 | ## Usage 20 | 21 | [Usage doc](https://www.wangeditor.com/en/v5/for-frame.html#vue2) 22 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # wangEditor for Vue 2 | 3 | [](https://github.com/facebook/react/blob/main/LICENSE) [](https://www.npmjs.com/package/@wangeditor/editor-for-vue/v/next) [](https://github.com/wangeditor-team/wangEditor-for-vue/actions) 4 | 5 | [English documentation](./README-en.md) 6 | 7 | ## 介绍 8 | 9 | 基于 [wangEditor](https://www.wangeditor.com/) 封装的开箱即用的 [Vue2 组件](https://www.wangeditor.com/v5/for-frame.html#vue2) 10 | 11 | ## 安装 12 | 13 | ```shell 14 | yarn add @wangeditor/editor 15 | yarn add @wangeditor/editor-for-vue 16 | ``` 17 | 18 | ## 使用 19 | 20 | 参考[文档](https://www.wangeditor.com/v5/for-frame.html#vue2) 21 | -------------------------------------------------------------------------------- /babel.config.json: -------------------------------------------------------------------------------- 1 | { 2 | "presets": [ 3 | [ 4 | "@babel/preset-env", 5 | { 6 | "modules": false, 7 | "useBuiltIns": "usage", 8 | "corejs": 3, 9 | "targets": "ie 11" 10 | } 11 | ] 12 | ], 13 | "plugins": [ 14 | [ 15 | "@babel/plugin-transform-runtime", 16 | { 17 | "absoluteRuntime": false, 18 | "corejs": 3, 19 | "helpers": true, 20 | "regenerator": true, 21 | "useESModules": false 22 | } 23 | ] 24 | ] 25 | } -------------------------------------------------------------------------------- /build/config/common.js: -------------------------------------------------------------------------------- 1 | import path from 'path'; 2 | import commonjs from '@rollup/plugin-commonjs'; 3 | import json from '@rollup/plugin-json'; 4 | import nodeResolve from '@rollup/plugin-node-resolve'; 5 | import typescript from 'rollup-plugin-typescript2'; 6 | import replace from '@rollup/plugin-replace'; 7 | import peerDepsExternal from 'rollup-plugin-peer-deps-external'; 8 | import vuePlugin from 'rollup-plugin-vue'; 9 | 10 | export const extensions = ['.js', '.jsx', '.ts', '.tsx', '.vue']; 11 | 12 | export default { 13 | input: path.resolve(__dirname, './src/index.ts'), 14 | output: { 15 | globals: { 16 | vue: 'Vue', 17 | }, 18 | }, 19 | plugins: [ 20 | peerDepsExternal(), // 打包结果不包含 package.json 的 peerDependencies 21 | json({ 22 | compact: true, 23 | indent: ' ', 24 | preferConst: true, 25 | }), 26 | typescript({ 27 | clean: true, 28 | tsconfig: path.resolve(__dirname, './tsconfig.json'), 29 | }), 30 | nodeResolve({ 31 | browser: true, // 重要 32 | extensions, 33 | }), 34 | vuePlugin({ 35 | target: 'browser', 36 | }), 37 | commonjs(), 38 | replace({ 39 | 'process.env.NODE_ENV': JSON.stringify(process.env.NODE_ENV), 40 | preventAssignment: true, 41 | }), 42 | // del({ targets: 'dist/*' }), 43 | ], 44 | }; 45 | -------------------------------------------------------------------------------- /build/config/dev.js: -------------------------------------------------------------------------------- 1 | import postcss from 'rollup-plugin-postcss' 2 | import autoprefixer from 'autoprefixer' 3 | import commonConfig from './common' 4 | 5 | const { output, input, plugins = [], external } = commonConfig 6 | 7 | export default { 8 | input, 9 | output, 10 | external, 11 | plugins: [ 12 | ...plugins, 13 | postcss({ 14 | plugins: [autoprefixer()], 15 | extract: 'css/style.css', 16 | }), 17 | ], 18 | } 19 | -------------------------------------------------------------------------------- /build/config/prd.js: -------------------------------------------------------------------------------- 1 | import babel from '@rollup/plugin-babel'; 2 | import postcss from 'rollup-plugin-postcss'; 3 | import autoprefixer from 'autoprefixer'; 4 | import cssnano from 'cssnano'; 5 | import { terser } from 'rollup-plugin-terser'; 6 | import cleanup from 'rollup-plugin-cleanup'; 7 | import commonConfig from './common'; 8 | import { extensions } from './common'; 9 | 10 | const { input, output = {}, plugins = [] } = commonConfig; 11 | 12 | const finalPlugins = [ 13 | ...plugins, 14 | // babel({ 15 | // babelHelpers: 'runtime', 16 | // exclude: 'node_modules/**', 17 | // include: 'src/**', 18 | // extensions, 19 | // }), 20 | postcss({ 21 | plugins: [ 22 | autoprefixer(), 23 | cssnano(), // 压缩 css 24 | ], 25 | extract: 'css/style.css', 26 | }), 27 | cleanup({ 28 | comments: 'none', 29 | extensions: ['.ts', '.tsx'], 30 | }), 31 | terser(), // 压缩 js 32 | ]; 33 | 34 | export default { 35 | input, 36 | output: { 37 | sourcemap: true, 38 | 39 | ...output, 40 | }, 41 | external: ['vue', '@wangeditor/editor'], 42 | plugins: finalPlugins, 43 | }; 44 | -------------------------------------------------------------------------------- /build/create-rollup-config.js: -------------------------------------------------------------------------------- 1 | /** 2 | * @description 创建 rollup 配置 3 | * @author wangfupeng 4 | */ 5 | 6 | import { merge } from 'lodash' 7 | import { visualizer } from 'rollup-plugin-visualizer' 8 | import devConf from './config/dev' 9 | import prdConf from './config/prd' 10 | 11 | // 环境变量 12 | const ENV = process.env.NODE_ENV || 'production' 13 | const IS_SIZE_STATS = ENV.indexOf('size_stats') >= 0 // 分析包体积 14 | export const IS_DEV = ENV.indexOf('development') >= 0 15 | export const IS_PRD = ENV.indexOf('production') >= 0 16 | 17 | /** 18 | * 生成单个 rollup 配置 19 | * @param {object} customConfig { input, output, plugins ... } 20 | */ 21 | export function createRollupConfig(customConfig = {}) { 22 | const { input, output = {}, plugins = [] } = customConfig 23 | 24 | let baseConfig 25 | if (IS_PRD) { 26 | baseConfig = prdConf 27 | } else { 28 | baseConfig = devConf 29 | } 30 | 31 | if (IS_SIZE_STATS) { 32 | // 分析包体积。运行之后可查看 package 下的 `stats.html` 33 | plugins.push(visualizer()) 34 | } 35 | 36 | const config = { 37 | input: input ? input : baseConfig.input, 38 | output, 39 | plugins, 40 | } 41 | 42 | const res = merge({}, baseConfig, config) 43 | return res 44 | } 45 | -------------------------------------------------------------------------------- /example/App.vue: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /example/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 |
4 | 5 | 6 | 7 |