@lexical/file 0.2.6 → 0.2.9

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.
@@ -9,19 +9,18 @@
9
9
  var lexical = require('lexical');
10
10
 
11
11
  /**
12
- * Copyright (c) Facebook, Inc. and its affiliates.
12
+ * Copyright (c) Meta Platforms, Inc. and affiliates.
13
13
  *
14
14
  * This source code is licensed under the MIT license found in the
15
15
  * LICENSE file in the root directory of this source tree.
16
16
  *
17
- *
18
17
  */
19
18
  function importFile(editor) {
20
19
  readTextFileFromSystem(text => {
21
20
  const json = JSON.parse(text);
22
21
  const editorState = editor.parseEditorState(JSON.stringify(json.editorState));
23
22
  editor.setEditorState(editorState);
24
- editor.dispatchCommand(lexical.CLEAR_HISTORY_COMMAND);
23
+ editor.dispatchCommand(lexical.CLEAR_HISTORY_COMMAND, undefined);
25
24
  });
26
25
  }
27
26
 
@@ -29,14 +28,13 @@ function readTextFileFromSystem(callback) {
29
28
  const input = document.createElement('input');
30
29
  input.type = 'file';
31
30
  input.accept = '.lexical';
32
- input.addEventListener('change', e => {
33
- // $FlowFixMe
34
- const file = e.target.files[0];
31
+ input.addEventListener('change', event => {
32
+ const target = event.target;
33
+ const file = target.files[0];
35
34
  const reader = new FileReader();
36
35
  reader.readAsText(file, 'UTF-8');
37
36
 
38
37
  reader.onload = readerEvent => {
39
- // $FlowFixMe
40
38
  const content = readerEvent.target.result;
41
39
  callback(content);
42
40
  };
@@ -6,4 +6,4 @@
6
6
  */
7
7
  var e=require("lexical");function f(a){const b=document.createElement("input");b.type="file";b.accept=".lexical";b.addEventListener("change",c=>{c=c.target.files[0];const d=new FileReader;d.readAsText(c,"UTF-8");d.onload=g=>{a(g.target.result)}});b.click()}
8
8
  exports.exportFile=function(a,b=Object.freeze({})){var c=new Date;a={editorState:a.getEditorState(),lastSaved:c.getTime(),source:b.source||"Lexical",version:e.VERSION};{b=`${b.fileName||c.toISOString()}.lexical`;c=document.createElement("a");const d=document.body;null!==d&&(d.appendChild(c),c.style.display="none",a=JSON.stringify(a),a=new Blob([a],{type:"octet/stream"}),a=window.URL.createObjectURL(a),c.href=a,c.download=b,c.click(),window.URL.revokeObjectURL(a),c.remove())}};
9
- exports.importFile=function(a){f(b=>{b=JSON.parse(b);b=a.parseEditorState(JSON.stringify(b.editorState));a.setEditorState(b);a.dispatchCommand(e.CLEAR_HISTORY_COMMAND)})};
9
+ exports.importFile=function(a){f(b=>{b=JSON.parse(b);b=a.parseEditorState(JSON.stringify(b.editorState));a.setEditorState(b);a.dispatchCommand(e.CLEAR_HISTORY_COMMAND,void 0)})};
package/package.json CHANGED
@@ -10,10 +10,10 @@
10
10
  "export"
11
11
  ],
12
12
  "license": "MIT",
13
- "version": "0.2.6",
13
+ "version": "0.2.9",
14
14
  "main": "LexicalFile.js",
15
15
  "peerDependencies": {
16
- "lexical": "0.2.6"
16
+ "lexical": "0.2.9"
17
17
  },
18
18
  "repository": {
19
19
  "type": "git",