@zipify/wysiwyg 1.0.0-dev.42 → 1.0.0-dev.45

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (62) hide show
  1. package/config/vite/example.config.js +25 -0
  2. package/dist/wysiwyg.css +1 -1
  3. package/dist/wysiwyg.mjs +3143 -3046
  4. package/example/ExampleApp.vue +5 -0
  5. package/example/{example.html → index.html} +1 -0
  6. package/lib/Wysiwyg.vue +4 -5
  7. package/lib/__tests__/utils/NodeFactory.js +13 -0
  8. package/lib/components/base/__tests__/Modal.test.js +2 -3
  9. package/lib/components/base/composables/__tests__/useValidator.test.js +44 -0
  10. package/lib/components/base/composables/useValidator.js +7 -3
  11. package/lib/components/toolbar/__tests__/Toolbar.test.js +2 -3
  12. package/lib/components/toolbar/controls/StylePresetControl.vue +14 -1
  13. package/lib/components/toolbar/controls/__tests__/StylePresetControl.test.js +16 -0
  14. package/lib/components/toolbar/controls/link/LinkControl.vue +28 -25
  15. package/lib/components/toolbar/controls/link/__tests__/LinkControl.test.js +79 -0
  16. package/lib/components/toolbar/controls/link/__tests__/LinkControlHeader.test.js +42 -0
  17. package/lib/components/toolbar/controls/link/composables/__tests__/__snapshots__/useLink.test.js.snap +8 -0
  18. package/lib/components/toolbar/controls/link/composables/__tests__/useLink.test.js +114 -0
  19. package/lib/components/toolbar/controls/link/destination/LinkControlDestination.vue +2 -2
  20. package/lib/components/toolbar/controls/link/destination/LinkControlUrl.vue +2 -2
  21. package/lib/components/toolbar/controls/link/destination/__tests__/LinkControlPageBlock.test.js +36 -0
  22. package/lib/components/toolbar/controls/link/destination/__tests__/LinkControlUrl.test.js +46 -0
  23. package/lib/components/toolbar/controls/link/destination/__tests__/__snapshots__/LinkControlPageBlock.test.js.snap +9 -0
  24. package/lib/components/toolbar/controls/link/destination/__tests__/__snapshots__/LinkControlUrl.test.js.snap +17 -0
  25. package/lib/composables/useToolbar.js +11 -0
  26. package/lib/directives/__tests__/outClick.test.js +6 -0
  27. package/lib/directives/outClick.js +12 -15
  28. package/lib/enums/Alignments.js +10 -1
  29. package/lib/extensions/Alignment.js +7 -5
  30. package/lib/extensions/FontSize.js +8 -2
  31. package/lib/extensions/FontWeight.js +3 -1
  32. package/lib/extensions/LineHeight.js +30 -36
  33. package/lib/extensions/Link.js +3 -15
  34. package/lib/extensions/TextDecoration.js +18 -0
  35. package/lib/extensions/__tests__/FontSize.test.js +2 -1
  36. package/lib/extensions/__tests__/FontWeight.test.js +8 -0
  37. package/lib/extensions/__tests__/LineHeight.test.js +12 -6
  38. package/lib/extensions/__tests__/Link.test.js +102 -0
  39. package/lib/extensions/__tests__/TextDecoration.test.js +24 -0
  40. package/lib/extensions/__tests__/__snapshots__/FontWeight.test.js.snap +17 -0
  41. package/lib/extensions/__tests__/__snapshots__/Link.test.js.snap +225 -0
  42. package/lib/extensions/__tests__/__snapshots__/TextDecoration.test.js.snap +90 -0
  43. package/lib/extensions/core/plugins/PastePlugin.js +23 -14
  44. package/lib/extensions/index.js +10 -5
  45. package/lib/services/ContentNormalizer.js +55 -15
  46. package/lib/services/__tests__/ContentNormalizer.test.js +39 -4
  47. package/lib/utils/__tests__/convertAlignment.test.js +16 -0
  48. package/lib/utils/__tests__/convertFontSize.test.js +21 -0
  49. package/lib/utils/__tests__/convertLineHeight.test.js +21 -0
  50. package/lib/utils/convertAlignment.js +12 -0
  51. package/lib/utils/convertFontSize.js +8 -0
  52. package/lib/utils/convertLineHeight.js +17 -0
  53. package/lib/utils/index.js +3 -0
  54. package/package.json +3 -13
  55. package/config/webpack/example.config.js +0 -88
  56. package/config/webpack/lib.config.js +0 -43
  57. package/config/webpack/loaders/index.js +0 -6
  58. package/config/webpack/loaders/js-loader.js +0 -5
  59. package/config/webpack/loaders/style-loader.js +0 -9
  60. package/config/webpack/loaders/svg-loader.js +0 -4
  61. package/config/webpack/loaders/vue-loader.js +0 -4
  62. package/config/webpack/settings.js +0 -9
@@ -0,0 +1,12 @@
1
+ import { Alignments } from '../enums';
2
+
3
+ const MAPPING = {
4
+ start: Alignments.LEFT,
5
+ end: Alignments.RIGHT
6
+ };
7
+
8
+ export function convertAlignment(alignment) {
9
+ const mapped = MAPPING[alignment] || alignment;
10
+
11
+ return Alignments.values.includes(mapped) ? mapped : null;
12
+ }
@@ -0,0 +1,8 @@
1
+ export function convertFontSize(value, wrapperEl) {
2
+ if (!value.includes('em')) return parseInt(value);
3
+
4
+ const containerValue = window.getComputedStyle(wrapperEl).fontSize;
5
+ const size = parseFloat(value) * parseFloat(containerValue);
6
+
7
+ return Math.round(size);
8
+ }
@@ -0,0 +1,17 @@
1
+ import { convertFontSize } from './convertFontSize';
2
+
3
+ function getFontSize(sourceEl, wrapperEl) {
4
+ const source = sourceEl.firstElementChild || sourceEl;
5
+ const fontSize = source.style.fontSize;
6
+
7
+ return fontSize || window.getComputedStyle(wrapperEl).fontSize;
8
+ }
9
+
10
+ export function convertLineHeight(value, sourceEl, wrapperEl) {
11
+ if (!value.includes('px')) return value;
12
+
13
+ const rawFontSize = getFontSize(sourceEl, wrapperEl);
14
+ const fontSize = convertFontSize(rawFontSize, wrapperEl);
15
+
16
+ return (parseInt(value) / fontSize).toFixed(2);
17
+ }
@@ -3,4 +3,7 @@ export { renderInlineSetting, renderMark } from './renderInlineSetting';
3
3
  export { capitalize } from './capitalize';
4
4
  export { createKeyboardShortcut } from './createKeyboardShortcut';
5
5
  export { convertColor } from './convertColor';
6
+ export { convertLineHeight } from './convertLineHeight';
7
+ export { convertFontSize } from './convertFontSize';
8
+ export { convertAlignment } from './convertAlignment';
6
9
  export { importIcon } from './importIcon';
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@zipify/wysiwyg",
3
- "version": "1.0.0-dev.42",
3
+ "version": "1.0.0-dev.45",
4
4
  "description": "Zipify modification of TipTap text editor",
5
5
  "main": "dist/wysiwyg.mjs",
6
6
  "repository": {
@@ -15,8 +15,8 @@
15
15
  },
16
16
  "scripts": {
17
17
  "lib:build": "vite build --config ./config/vite/lib.config.js",
18
- "example:start": "NODE_ENV=development webpack serve --config ./config/webpack/example.config.js",
19
- "example:build": "NODE_ENV=production webpack --config ./config/webpack/example.config.js",
18
+ "example:start": "NODE_ENV=development vite serve --config ./config/vite/example.config.js",
19
+ "example:build": "NODE_ENV=production vite build --config ./config/vite/example.config.js",
20
20
  "test:unit": "jest .",
21
21
  "optimize-svg": "svgo --config ./config/svgo.js",
22
22
  "gzip": "gzipper compress",
@@ -51,32 +51,22 @@
51
51
  "@vue/test-utils": "^1.3.0",
52
52
  "@vue/vue2-jest": "^28.0.1",
53
53
  "babel-jest": "^28.1.3",
54
- "babel-loader": "^8.2.5",
55
- "css-loader": "^6.7.1",
56
54
  "eslint": "^8.20.0",
57
55
  "eslint-plugin-import": "^2.26.0",
58
56
  "eslint-plugin-vue": "^9.3.0",
59
57
  "gzipper": "^7.1.0",
60
- "html-webpack-plugin": "^5.5.0",
61
58
  "husky": "^8.0.1",
62
59
  "jest": "^28.1.3",
63
60
  "jest-environment-jsdom": "^28.1.3",
64
61
  "lint-staged": "^13.0.3",
65
- "mini-css-extract-plugin": "^2.6.1",
66
62
  "postcss-html": "^1.5.0",
67
63
  "release-it": "^15.1.2",
68
- "style-loader": "^3.3.1",
69
64
  "stylelint": "^14.9.1",
70
65
  "svgo": "^2.8.0",
71
66
  "vite": "^3.0.4",
72
67
  "vite-plugin-vue2": "^2.0.2",
73
68
  "vue": "^2.7.8",
74
- "vue-loader": "^15.10.0",
75
69
  "vue-template-compiler": "^2.7.8",
76
- "webpack": "^5.74.0",
77
- "webpack-bundle-analyzer": "^4.5.0",
78
- "webpack-cli": "^4.10.0",
79
- "webpack-dev-server": "^4.9.3",
80
70
  "zipify-colorpicker": "^1.0.28"
81
71
  }
82
72
  }
@@ -1,88 +0,0 @@
1
- const path = require('path');
2
- const { DefinePlugin } = require('webpack');
3
- const HtmlWebpackPlugin = require('html-webpack-plugin');
4
- const { VueLoaderPlugin } = require('vue-loader');
5
- const MiniCssExtractPlugin = require('mini-css-extract-plugin');
6
- const { BundleAnalyzerPlugin } = require('webpack-bundle-analyzer');
7
- const { resolvePath, isDevelopment } = require('./settings');
8
- const loaders = require('./loaders');
9
-
10
- const isAnalyzerEnabled = !!process.env.ANALYZE_BUILD;
11
- const filename = isDevelopment ? '[name].js' : '[name].[contenthash].js';
12
-
13
- module.exports = {
14
- mode: isDevelopment ? 'development' : 'production',
15
- entry: resolvePath('./example/example.js'),
16
- devtool: isDevelopment ? 'eval-source-map' : false,
17
-
18
- output: {
19
- clean: true,
20
- path: resolvePath('./example/dist'),
21
- filename,
22
- chunkFilename: filename,
23
- devtoolFallbackModuleFilenameTemplate: 'webpack:///[resource-path]?[hash]',
24
- devtoolModuleFilenameTemplate: (info) => {
25
- let resPath = path.normalize(info.resourcePath);
26
- let isVue = resPath.match(/\.vue$/);
27
- let isGenerated = info.allLoaders;
28
-
29
- let generated = `webpack-generated:///${resPath}?${info.hash}`;
30
- let vuesource = `parsed:///${resPath}`;
31
-
32
- return isVue && isGenerated ? generated : vuesource;
33
- }
34
- },
35
-
36
- cache: {
37
- type: 'filesystem',
38
- cacheDirectory: resolvePath('./example/.cache')
39
- },
40
-
41
- devServer: {
42
- host: 'localhost',
43
- port: 7777,
44
- devMiddleware: { publicPath: '/' }
45
- },
46
-
47
- resolve: {
48
- extensions: ['*', '.js', '.vue', '.json']
49
- },
50
-
51
- optimization: {
52
- splitChunks: {
53
- chunks: 'all',
54
- cacheGroups: {
55
- vue: {
56
- name: 'vue',
57
- test: /[\\/]node_modules[\\/]@?vue/
58
- },
59
- tiptap: {
60
- name: 'tiptap',
61
- test: /[\\/]node_modules[\\/](@?tiptap|prosemirror)/
62
- }
63
- }
64
- }
65
- },
66
-
67
- module: {
68
- rules: [
69
- loaders.style,
70
- loaders.js,
71
- loaders.svg,
72
- loaders.vue
73
- ]
74
- },
75
-
76
- plugins: [
77
- new VueLoaderPlugin(),
78
- new MiniCssExtractPlugin(),
79
- new HtmlWebpackPlugin({
80
- title: 'ZipifyWysiwyg',
81
- template: resolvePath('./example/example.html')
82
- }),
83
- new DefinePlugin({
84
- ZW_UPDATED_AT: JSON.stringify(Date.now())
85
- }),
86
- ...(isAnalyzerEnabled ? [new BundleAnalyzerPlugin()] : [])
87
- ]
88
- };
@@ -1,43 +0,0 @@
1
- const { VueLoaderPlugin } = require('vue-loader');
2
- const MiniCssExtractPlugin = require('mini-css-extract-plugin');
3
- const { resolvePath } = require('./settings');
4
- const loaders = require('./loaders');
5
-
6
- module.exports = {
7
- mode: 'production',
8
- entry: resolvePath('./lib/index.js'),
9
-
10
- output: {
11
- clean: true,
12
- path: resolvePath('./dist'),
13
- filename: 'wysiwyg.js',
14
- library: { type: 'commonjs2' }
15
- },
16
-
17
- resolve: {
18
- extensions: ['*', '.js', '.vue', '.json']
19
- },
20
-
21
- module: {
22
- rules: [
23
- loaders.style,
24
- loaders.js,
25
- loaders.svg,
26
- loaders.vue
27
- ]
28
- },
29
-
30
- externals: {
31
- 'vue': 'commonjs2 vue',
32
- 'zipify-colorpicker': 'commonjs2 zipify-colorpicker'
33
- },
34
-
35
- experiments: {
36
- outputModule: true
37
- },
38
-
39
- plugins: [
40
- new VueLoaderPlugin(),
41
- new MiniCssExtractPlugin({ filename: 'wysiwyg.css' })
42
- ]
43
- };
@@ -1,6 +0,0 @@
1
- module.exports = {
2
- style: require('./style-loader'),
3
- svg: require('./svg-loader'),
4
- js: require('./js-loader'),
5
- vue: require('./vue-loader')
6
- };
@@ -1,5 +0,0 @@
1
- module.exports = {
2
- test: /\.js?$/,
3
- exclude: /(node_modules)/,
4
- loader: 'babel-loader'
5
- };
@@ -1,9 +0,0 @@
1
- const MiniCssExtractPlugin = require('mini-css-extract-plugin');
2
-
3
- module.exports = {
4
- test: /\.s?css$/,
5
- use: [
6
- MiniCssExtractPlugin.loader,
7
- 'css-loader'
8
- ]
9
- };
@@ -1,4 +0,0 @@
1
- module.exports = {
2
- test: /\.svg$/,
3
- type: 'asset/source'
4
- };
@@ -1,4 +0,0 @@
1
- module.exports = {
2
- test: /\.vue$/,
3
- use: { loader: 'vue-loader' }
4
- };
@@ -1,9 +0,0 @@
1
- const path = require('path');
2
-
3
- const root = path.resolve(__dirname, '../..');
4
-
5
- module.exports = {
6
- root,
7
- resolvePath: (...parts) => path.resolve(root, ...parts),
8
- isDevelopment: process.env.NODE_ENV === 'development'
9
- };