Skip to content

Commit f384ddc

Browse files
committed
Initial
0 parents  commit f384ddc

30 files changed

+11178
-0
lines changed

.browserslistrc

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
current node
2+
last 2 versions and > 2%
3+
ie > 10

.eslintignore

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
node_modules/*
2+
docs/*
3+
docs-src/*
4+
rollup-config.js

.eslintrc.js

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
module.exports = {
2+
root: true,
3+
4+
env: {
5+
node: true,
6+
},
7+
8+
extends: [
9+
'plugin:vue/vue3-essential',
10+
'eslint:recommended',
11+
'@vue/typescript/recommended',
12+
'@vue/prettier',
13+
'@vue/prettier/@typescript-eslint',
14+
],
15+
16+
parserOptions: {
17+
ecmaVersion: 2020,
18+
},
19+
20+
rules: {
21+
'no-console': process.env.NODE_ENV === 'production' ? 'warn' : 'off',
22+
'no-debugger': process.env.NODE_ENV === 'production' ? 'warn' : 'off',
23+
},
24+
};

.gitignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
node_modules
2+
dist/*
3+
.DS_Store

.prettierrc

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
{
2+
"singleQuote": true,
3+
"bracketSpacing": false
4+
}

.vscode/settings.json

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
{
2+
"volar.tsPlugin": true
3+
}

README.md

Lines changed: 65 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,65 @@
1+
# VueEditr
2+
A simple WYSIWYG editor for Vue 3.
3+
4+
The code base is an upgrade of the vue-wysiwyg editor by chmln. The upgarde was done to support Vue 3 and was written in Typescript.
5+
6+
## Usage
7+
8+
### Install vue-editr
9+
10+
11+
## Config options
12+
13+
All keys are optional.
14+
15+
```js
16+
{
17+
// { [module]: boolean (set true to hide) }
18+
hideModules: { "bold": true },
19+
20+
// you can override icons too, if desired
21+
// just keep in mind that you may need custom styles in your application to get everything to align
22+
iconOverrides: { "bold": "<i class='your-custom-icon'></i>" },
23+
24+
// if the image option is not set, images are inserted as base64
25+
image: {
26+
uploadURL: "/api/myEndpoint",
27+
dropzoneOptions: {}
28+
},
29+
30+
// limit content height if you wish. If not set, editor size will grow with content.
31+
maxHeight: "500px",
32+
33+
// set to 'true' this will insert plain text without styling when you paste something into the editor.
34+
plainTextOnPaste: true,
35+
36+
// specify editor locale, if you don't specify this, the editor will default to english.
37+
locale: 'de'
38+
}
39+
```
40+
Available Modules:
41+
- bold
42+
- italic
43+
- underline
44+
- justifyLeft
45+
- justifyCenter
46+
- justifyRight
47+
- headings
48+
- link
49+
- code
50+
- orderedList
51+
- unorderedList
52+
- image
53+
- table
54+
- removeFormat
55+
- separator
56+
57+
Available Locales:
58+
- english (default)
59+
- hungarian
60+
- dutch
61+
- german
62+
63+
Note on the image upload API endpoint:
64+
- Image is uploaded by `multipart/form-data`
65+
- Your endpoint must respond back with a string, the URL for the image - e.g. `http://myapp.com/images/12345.jpg`

babel.config.js

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
const devPresets = ['@vue/babel-preset-app'];
2+
const buildPresets = ['@babel/preset-env', '@babel/preset-typescript'];
3+
module.exports = {
4+
presets: process.env.NODE_ENV === 'development' ? devPresets : buildPresets,
5+
};

build/rollup.config.js

Lines changed: 169 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,169 @@
1+
// rollup.config.js
2+
import fs from 'fs';
3+
import path from 'path';
4+
import vue from 'rollup-plugin-vue';
5+
import alias from '@rollup/plugin-alias';
6+
import commonjs from '@rollup/plugin-commonjs';
7+
import resolve from '@rollup/plugin-node-resolve';
8+
import replace from '@rollup/plugin-replace';
9+
import babel from '@rollup/plugin-babel';
10+
import postcss from 'rollup-plugin-postcss';
11+
import {terser} from 'rollup-plugin-terser';
12+
import minimist from 'minimist';
13+
14+
// Get browserslist config and remove ie from es build targets
15+
const esbrowserslist = fs.readFileSync('./.browserslistrc')
16+
.toString()
17+
.split('\n')
18+
.filter((entry) => entry && entry.substring(0, 2) !== 'ie');
19+
20+
const argv = minimist(process.argv.slice(2));
21+
22+
const projectRoot = path.resolve(__dirname, '..');
23+
24+
const baseConfig = {
25+
input: 'src/entry.ts',
26+
plugins: {
27+
preVue: [
28+
alias({
29+
entries: [
30+
{
31+
find: '@',
32+
replacement: `${path.resolve(projectRoot, 'src')}`,
33+
},
34+
],
35+
customResolver: resolve({
36+
extensions: ['.js', '.jsx', '.ts', '.tsx', '.vue'],
37+
}),
38+
}),
39+
],
40+
replace: {
41+
'process.env.NODE_ENV': JSON.stringify('production'),
42+
},
43+
vue: {
44+
preprocessStyles: true,
45+
},
46+
postVue: [
47+
// Process only `<style module>` blocks.
48+
postcss({
49+
modules: {
50+
generateScopedName: '[local]___[hash:base64:5]',
51+
},
52+
include: /&module=.*\.css$/,
53+
}),
54+
// Process all `<style>` blocks except `<style module>`.
55+
postcss({ include: /(?<!&module=.*)\.css$/ }),
56+
],
57+
babel: {
58+
exclude: 'node_modules/**',
59+
extensions: ['.js', '.jsx', '.ts', '.tsx', '.vue'],
60+
babelHelpers: 'bundled',
61+
},
62+
},
63+
};
64+
65+
// ESM/UMD/IIFE shared settings: externals
66+
// Refer to https://rollupjs.org/guide/en/#warning-treating-module-as-external-dependency
67+
const external = [
68+
// list external dependencies, exactly the way it is written in the import statement.
69+
// eg. 'jquery'
70+
'vue',
71+
];
72+
73+
// UMD/IIFE shared settings: output.globals
74+
// Refer to https://rollupjs.org/guide/en#output-globals for details
75+
const globals = {
76+
// Provide global variable names to replace your external imports
77+
// eg. jquery: '$'
78+
vue: 'Vue',
79+
};
80+
81+
// Customize configs for individual targets
82+
const buildFormats = [];
83+
if (!argv.format || argv.format === 'es') {
84+
const esConfig = {
85+
...baseConfig,
86+
input: 'src/entry.esm.ts',
87+
external,
88+
output: {
89+
file: 'dist/vue-editr.esm.js',
90+
format: 'esm',
91+
exports: 'named',
92+
},
93+
plugins: [
94+
replace(baseConfig.plugins.replace),
95+
...baseConfig.plugins.preVue,
96+
vue(baseConfig.plugins.vue),
97+
...baseConfig.plugins.postVue,
98+
babel({
99+
...baseConfig.plugins.babel,
100+
presets: [
101+
[
102+
'@babel/preset-env',
103+
{
104+
targets: esbrowserslist,
105+
},
106+
],
107+
],
108+
}),
109+
commonjs(),
110+
],
111+
};
112+
buildFormats.push(esConfig);
113+
}
114+
115+
if (!argv.format || argv.format === 'cjs') {
116+
const umdConfig = {
117+
...baseConfig,
118+
external,
119+
output: {
120+
compact: true,
121+
file: 'dist/vue-editr.ssr.js',
122+
format: 'cjs',
123+
name: 'VueEditr',
124+
exports: 'auto',
125+
globals,
126+
},
127+
plugins: [
128+
replace(baseConfig.plugins.replace),
129+
...baseConfig.plugins.preVue,
130+
vue(baseConfig.plugins.vue),
131+
...baseConfig.plugins.postVue,
132+
babel(baseConfig.plugins.babel),
133+
commonjs(),
134+
],
135+
};
136+
buildFormats.push(umdConfig);
137+
}
138+
139+
if (!argv.format || argv.format === 'iife') {
140+
const unpkgConfig = {
141+
...baseConfig,
142+
external,
143+
output: {
144+
compact: true,
145+
file: 'dist/vue-editr.min.js',
146+
format: 'iife',
147+
name: 'VueEditr',
148+
exports: 'auto',
149+
globals,
150+
},
151+
plugins: [
152+
replace(baseConfig.plugins.replace),
153+
...baseConfig.plugins.preVue,
154+
vue(baseConfig.plugins.vue),
155+
...baseConfig.plugins.postVue,
156+
babel(baseConfig.plugins.babel),
157+
commonjs(),
158+
terser({
159+
output: {
160+
ecma: 5,
161+
},
162+
}),
163+
],
164+
};
165+
buildFormats.push(unpkgConfig);
166+
}
167+
168+
// Export config
169+
export default buildFormats;

dev/serve.ts

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
import {createApp} from 'vue';
2+
import Dev from './serve.vue';
3+
import VueEditr from '@/entry';
4+
5+
const app = createApp(Dev);
6+
app.config.performance = true;
7+
8+
app.use(VueEditr, {
9+
hideModules: [''],
10+
iconOverrides: {
11+
bold: '<i class="mdi mdi-format-bold vue-wysiwyg-icon"></i>',
12+
italic: '<i class="mdi mdi-format-italic vue-wysiwyg-icon"></i>',
13+
underline: '<i class="mdi mdi-format-underline vue-wysiwyg-icon"></i>',
14+
orderedList: '<i class="mdi mdi-format-list-numbered vue-wysiwyg-icon"></i>',
15+
unorderedList:
16+
'<i class="mdi mdi-format-list-bulleted vue-wysiwyg-icon"></i>',
17+
removeFormat: '<i class="mdi mdi-format-clear vue-wysiwyg-icon"></i>'
18+
},
19+
plainTextOnPaste: true,
20+
locale: 'ru',
21+
});
22+
23+
app.mount('#app');

0 commit comments

Comments
 (0)