@modusoperandi/licit 0.13.22 → 0.13.24

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.
@@ -266,13 +266,25 @@ class Licit extends React.Component {
266
266
  });
267
267
 
268
268
  _defineProperty(this, "exportPDF", () => {
269
- const event = new KeyboardEvent('keydown', {
270
- ctrlKey: true,
271
- altKey: true,
272
- keyCode: 80,
273
- bubbles: false
269
+ new Promise(async (resolve, reject) => {
270
+ try {
271
+ //
272
+ if (Array.isArray(this.props.plugins)) {
273
+ this.props.plugins.forEach(plugin => {
274
+ if (plugin['key'].startsWith('exportPDF$')) {
275
+ // got the exportPDF instance.
276
+ resolve(plugin);
277
+ }
278
+ });
279
+ }
280
+ } catch (error) {
281
+ reject();
282
+ }
283
+ }).then(exportPDF => {
284
+ if (exportPDF.perform) {
285
+ exportPDF.perform(this._editorView);
286
+ }
274
287
  });
275
- this.editorView.dom.dispatchEvent(event);
276
288
  });
277
289
 
278
290
  this.initialize(_props);
@@ -662,13 +662,25 @@ class Licit extends React.Component<any, any> {
662
662
  };
663
663
 
664
664
  exportPDF = () => {
665
- const event = new KeyboardEvent('keydown', {
666
- ctrlKey: true,
667
- altKey: true,
668
- keyCode: 80,
669
- bubbles: false,
665
+ new Promise(async (resolve, reject) => {
666
+ try {
667
+ //
668
+ if (Array.isArray(this.props.plugins)) {
669
+ this.props.plugins.forEach((plugin) => {
670
+ if (plugin['key'].startsWith('exportPDF$')) {
671
+ // got the exportPDF instance.
672
+ resolve(plugin);
673
+ }
674
+ });
675
+ }
676
+ } catch (error) {
677
+ reject();
678
+ }
679
+ }).then((exportPDF) => {
680
+ if (exportPDF.perform) {
681
+ exportPDF.perform(this._editorView);
682
+ }
670
683
  });
671
- this.editorView.dom.dispatchEvent(event);
672
684
  };
673
685
  }
674
686
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@modusoperandi/licit",
3
- "version": "0.13.22",
3
+ "version": "0.13.24",
4
4
  "subversion": "1",
5
5
  "description": "Rich text editor built with React and ProseMirror",
6
6
  "main": "dist/index.js",
@@ -83,14 +83,14 @@
83
83
  "stylelint-config-standard": "^20.0.0",
84
84
  "stylelint-prettier": "^1.2.0",
85
85
  "terser-webpack-plugin": "^3.1.0",
86
- "webpack": "^4.44.2",
86
+ "webpack": "^5.74.0",
87
87
  "webpack-cli": "^4.9.1",
88
88
  "webpack-dev-server": "^4.11.1",
89
89
  "write-file-webpack-plugin": "4.5.1"
90
90
  },
91
91
  "dependencies": {
92
92
  "@modusoperandi/licit-doc-attrs-step": "^0.1.3",
93
- "@modusoperandi/licit-ui-commands": "^0.1.8",
93
+ "@modusoperandi/licit-ui-commands": "^0.1.9",
94
94
  "@wojtekmaj/enzyme-adapter-react-17": "^0.6.7",
95
95
  "body-parser": "^1.19.0",
96
96
  "browserkeymap": "2.0.2",
@@ -127,6 +127,7 @@
127
127
  "resize-observer-polyfill": "1.5.1",
128
128
  "smooth-scroll-into-view-if-needed": "1.1.28",
129
129
  "style-loader": "^1.2.1",
130
+ "url": "^0.11.0",
130
131
  "uuid": "8.2.0",
131
132
  "webfontloader": "1.6.28"
132
133
  },
@@ -662,13 +662,25 @@ class Licit extends React.Component<any, any> {
662
662
  };
663
663
 
664
664
  exportPDF = () => {
665
- const event = new KeyboardEvent('keydown', {
666
- ctrlKey: true,
667
- altKey: true,
668
- keyCode: 80,
669
- bubbles: false,
665
+ new Promise(async (resolve, reject) => {
666
+ try {
667
+ //
668
+ if (Array.isArray(this.props.plugins)) {
669
+ this.props.plugins.forEach((plugin) => {
670
+ if (plugin['key'].startsWith('exportPDF$')) {
671
+ // got the exportPDF instance.
672
+ resolve(plugin);
673
+ }
674
+ });
675
+ }
676
+ } catch (error) {
677
+ reject();
678
+ }
679
+ }).then((exportPDF) => {
680
+ if (exportPDF.perform) {
681
+ exportPDF.perform(this._editorView);
682
+ }
670
683
  });
671
- this.editorView.dom.dispatchEvent(event);
672
684
  };
673
685
  }
674
686
 
@@ -1,40 +1,43 @@
1
1
  const WebpackDevServer = require('webpack-dev-server'),
2
- webpack = require('webpack'),
3
- config = require('../webpack.config'),
4
- env = require('./env'),
5
- path = require('path'),
6
- formidable = require('formidable'),
7
- mv = require('mv'),
8
- // [FS] IRAD-1005 2020-07-07
9
- // Upgrade outdated packages.
10
- uuidv4 = require('uuid').v4,
11
- express = require('express');
2
+ webpack = require('webpack'),
3
+ config = require('../webpack.config'),
4
+ env = require('./env'),
5
+ path = require('path'),
6
+ formidable = require('formidable'),
7
+ mv = require('mv'),
8
+ // [FS] IRAD-1005 2020-07-07
9
+ // Upgrade outdated packages.
10
+ uuidv4 = require('uuid').v4,
11
+ express = require('express');
12
12
 
13
- const options = (config.chromeExtensionBoilerplate || {});
14
- const excludeEntriesToHotReload = (options.notHotReload || []);
13
+ const options = config.chromeExtensionBoilerplate || {};
14
+ const excludeEntriesToHotReload = options.notHotReload || [];
15
15
 
16
16
  for (const entryName in config.entry) {
17
17
  if (excludeEntriesToHotReload.indexOf(entryName) === -1) {
18
- config.entry[entryName] =
19
- [
20
- ('webpack-dev-server/client?http://localhost:' + env.PORT),
21
- 'webpack/hot/dev-server'
22
- ].concat(config.entry[entryName]);
18
+ config.entry[entryName] = [
19
+ 'webpack-dev-server/client?http://localhost:' + env.PORT,
20
+ 'webpack/hot/dev-server',
21
+ ].concat(config.entry[entryName]);
23
22
  }
24
23
  }
25
24
 
26
- config.plugins =
27
- [new webpack.HotModuleReplacementPlugin()].concat(config.plugins || []);
25
+ config.plugins = [new webpack.HotModuleReplacementPlugin()].concat(
26
+ config.plugins || []
27
+ );
28
28
 
29
29
  delete config.chromeExtensionBoilerplate;
30
30
 
31
31
  const compiler = webpack(config);
32
32
 
33
- const server =
34
- new WebpackDevServer(compiler, {
33
+ const server = new WebpackDevServer(
34
+ {
35
35
  hot: true,
36
- contentBase: path.join(__dirname, '../bin'),
36
+ static: path.join(__dirname, '../bin'),
37
37
  headers: { 'Access-Control-Allow-Origin': '*' },
38
- });
38
+ port: env.PORT,
39
+ },
40
+ compiler
41
+ );
39
42
 
40
- server.listen(env.PORT);
43
+ server.start();
package/webpack.config.js CHANGED
@@ -6,7 +6,6 @@ var webpack = require('webpack'),
6
6
  HtmlWebpackInlineSourcePlugin = require('html-webpack-inline-source-plugin'),
7
7
  HtmlWebpackPlugin = require('html-webpack-plugin'),
8
8
  TerserPlugin = require('terser-webpack-plugin'),
9
-
10
9
  WriteFilePlugin = require('write-file-webpack-plugin'),
11
10
  env = require('./utils/env'),
12
11
  fileSystem = require('fs'),
@@ -26,7 +25,7 @@ var options = {
26
25
  },
27
26
  output: {
28
27
  path: path.join(__dirname, 'bin'),
29
- filename: '[name].bundle.js'
28
+ filename: '[name].bundle.js',
30
29
  },
31
30
  module: {
32
31
  rules: [
@@ -35,9 +34,13 @@ var options = {
35
34
  exclude: /node_modules/,
36
35
  loader: 'babel-loader',
37
36
  options: {
38
- // https://stackoverflow.com/questions/51860043/javascript-es6-typeerror-class-constructor-client-cannot-be-invoked-without-ne
39
- // ES6 classes are supported in any recent Node version, they shouldn't be transpiled. es2015 should be excluded from Babel configuration, it's preferable to use env preset set to node target.
40
- presets: [['@babel/preset-env', { 'targets': { 'node': true } }], '@babel/preset-react', '@babel/preset-flow'],
37
+ // https://stackoverflow.com/questions/51860043/javascript-es6-typeerror-class-constructor-client-cannot-be-invoked-without-ne
38
+ // ES6 classes are supported in any recent Node version, they shouldn't be transpiled. es2015 should be excluded from Babel configuration, it's preferable to use env preset set to node target.
39
+ presets: [
40
+ ['@babel/preset-env', { targets: { node: true } }],
41
+ '@babel/preset-react',
42
+ '@babel/preset-flow',
43
+ ],
41
44
  plugins: [
42
45
  '@babel/plugin-proposal-class-properties',
43
46
  '@babel/plugin-proposal-export-default-from',
@@ -62,65 +65,74 @@ var options = {
62
65
  loader: 'file-loader',
63
66
  options: {
64
67
  name: '[name].[ext]',
65
- outputPath: 'fonts/'
66
- }
67
- }
68
- ]
68
+ outputPath: 'fonts/',
69
+ },
70
+ },
71
+ ],
69
72
  },
70
73
  {
71
74
  test: /\.css$/,
72
- use: [
73
- 'style-loader',
74
- 'css-loader',
75
- ],
75
+ use: ['style-loader', 'css-loader'],
76
76
  },
77
77
  {
78
- test: /\.(jpe?g|png|gif|svg)$/i,
79
- loader: 'file-loader'
78
+ test: /\.(jpe?g|png|gif|svg)$/i,
79
+ loader: 'file-loader',
80
80
  },
81
81
  {
82
82
  test: /\.html$/,
83
83
  loader: 'html-loader',
84
- exclude: /node_modules/
84
+ exclude: /node_modules/,
85
85
  },
86
- ]
86
+ ],
87
87
  },
88
88
  resolve: {
89
- alias: {}
89
+ alias: {},
90
90
  },
91
91
  plugins: [
92
92
  new webpack.ProvidePlugin({
93
93
  // jQuery (for Mathquill)
94
94
  'window.jQuery': 'jquery',
95
95
  }),
96
- // type checker
97
- ... (env.NODE_ENV === 'development') ? [new FlowWebpackPlugin({flowArgs: ['--show-all-errors']})] : [],
96
+ // type checker
97
+ ...(isDev
98
+ ? [new FlowWebpackPlugin({ flowArgs: ['--show-all-errors'] })]
99
+ : []),
98
100
  // clean the web folder
99
101
  new CleanWebpackPlugin(),
100
102
  // expose and write the allowed env vars on the compiled bundle
101
103
  new webpack.DefinePlugin({
102
- 'process.env.NODE_ENV': JSON.stringify(env.NODE_ENV)
104
+ 'process.env.NODE_ENV': JSON.stringify(env.NODE_ENV),
103
105
  }),
104
106
  new HtmlWebpackPlugin({
105
107
  template: path.join(__dirname, 'licit', 'index.html'),
106
108
  filename: 'index.html',
107
109
  chunks: ['licit'],
108
- inlineSource: isDev ? '$^' : '.(js|css)$'
110
+ inlineSource: isDev ? '$^' : '.(js|css)$',
109
111
  }),
110
- new HtmlWebpackInlineSourcePlugin(HtmlWebpackPlugin),
111
- new WriteFilePlugin()
112
- ]
112
+ ...(isDev ? [new HtmlWebpackInlineSourcePlugin(HtmlWebpackPlugin)] : []),
113
+ new WriteFilePlugin(),
114
+ ],
115
+ performance: {
116
+ assetFilter: function (assetFilename) {
117
+ return (
118
+ !assetFilename.endsWith('.eot') &&
119
+ !assetFilename.endsWith('.ttf') &&
120
+ !assetFilename.endsWith('.svg') &&
121
+ !assetFilename.endsWith('licit.bundle.js')
122
+ );
123
+ },
124
+ },
113
125
  };
114
126
 
115
- if (env.NODE_ENV === 'development') {
127
+ if (isDev) {
116
128
  options.devtool = 'source-map';
117
129
  } else {
118
- // [FS] IRAD-1005 2020-07-10
119
- // Upgrade outdated packages.
120
- options.optimization = {
130
+ // [FS] IRAD-1005 2020-07-10
131
+ // Upgrade outdated packages.
132
+ options.optimization = {
121
133
  minimize: true,
122
134
  minimizer: [new TerserPlugin()],
123
- }
135
+ };
124
136
  }
125
137
 
126
138
  module.exports = options;