@modusoperandi/licit 0.13.22 → 0.13.23

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,28 @@ 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
+ const {
274
+ ExportPDFPlugin
275
+ } = await Promise.resolve().then(() => _interopRequireWildcard(require('@modusoperandi/licit-export-pdf')));
276
+ this.props.plugins.forEach(plugin => {
277
+ if (plugin instanceof ExportPDFPlugin) {
278
+ // got the exportPDF instance.
279
+ resolve(plugin);
280
+ }
281
+ });
282
+ }
283
+ } catch (error) {
284
+ reject();
285
+ }
286
+ }).then(exportPDF => {
287
+ if (exportPDF.perform) {
288
+ exportPDF.perform(this._editorView);
289
+ }
274
290
  });
275
- this.editorView.dom.dispatchEvent(event);
276
291
  });
277
292
 
278
293
  this.initialize(_props);
@@ -662,13 +662,28 @@ 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
+ const { ExportPDFPlugin } = await import(
670
+ '@modusoperandi/licit-export-pdf'
671
+ );
672
+ this.props.plugins.forEach((plugin) => {
673
+ if (plugin instanceof ExportPDFPlugin) {
674
+ // got the exportPDF instance.
675
+ resolve(plugin);
676
+ }
677
+ });
678
+ }
679
+ } catch (error) {
680
+ reject();
681
+ }
682
+ }).then((exportPDF) => {
683
+ if (exportPDF.perform) {
684
+ exportPDF.perform(this._editorView);
685
+ }
670
686
  });
671
- this.editorView.dom.dispatchEvent(event);
672
687
  };
673
688
  }
674
689
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@modusoperandi/licit",
3
- "version": "0.13.22",
3
+ "version": "0.13.23",
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",
@@ -662,13 +662,28 @@ 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
+ const { ExportPDFPlugin } = await import(
670
+ '@modusoperandi/licit-export-pdf'
671
+ );
672
+ this.props.plugins.forEach((plugin) => {
673
+ if (plugin instanceof ExportPDFPlugin) {
674
+ // got the exportPDF instance.
675
+ resolve(plugin);
676
+ }
677
+ });
678
+ }
679
+ } catch (error) {
680
+ reject();
681
+ }
682
+ }).then((exportPDF) => {
683
+ if (exportPDF.perform) {
684
+ exportPDF.perform(this._editorView);
685
+ }
670
686
  });
671
- this.editorView.dom.dispatchEvent(event);
672
687
  };
673
688
  }
674
689
 
@@ -33,7 +33,7 @@ const compiler = webpack(config);
33
33
  const server =
34
34
  new WebpackDevServer(compiler, {
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
  });
39
39
 
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;