@lexical/file 0.1.16 → 0.1.19

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.
package/LICENSE CHANGED
@@ -1,6 +1,6 @@
1
1
  MIT License
2
2
 
3
- Copyright (c) 2020 Dominic Gannaway
3
+ Copyright (c) Meta Platforms, Inc. and affiliates.
4
4
 
5
5
  Permission is hereby granted, free of charge, to any person obtaining a copy
6
6
  of this software and associated documentation files (the "Software"), to deal
@@ -0,0 +1,16 @@
1
+ /**
2
+ * Copyright (c) Meta Platforms, Inc. and affiliates.
3
+ *
4
+ * This source code is licensed under the MIT license found in the
5
+ * LICENSE file in the root directory of this source tree.
6
+ *
7
+ *
8
+ */
9
+
10
+ import {LexicalEditor} from 'lexical';
11
+
12
+ export function importFile(editor: LexicalEditor): void;
13
+ export function exportFile(
14
+ editor: LexicalEditor,
15
+ config?: Readonly<{fileName?: string; source?: string}>,
16
+ ): void;
@@ -21,7 +21,7 @@ function importFile(editor) {
21
21
  const json = JSON.parse(text);
22
22
  const editorState = editor.parseEditorState(JSON.stringify(json.editorState));
23
23
  editor.setEditorState(editorState);
24
- editor.execCommand('clearHistory');
24
+ editor.dispatchCommand(lexical.CLEAR_HISTORY_COMMAND);
25
25
  });
26
26
  }
27
27
 
@@ -0,0 +1,17 @@
1
+ /**
2
+ * Copyright (c) Meta Platforms, Inc. and affiliates.
3
+ *
4
+ * This source code is licensed under the MIT license found in the
5
+ * LICENSE file in the root directory of this source tree.
6
+ *
7
+ * @flow strict
8
+ *
9
+ */
10
+
11
+ import type {LexicalEditor} from 'lexical';
12
+
13
+ declare export function importFile(editor: LexicalEditor): void;
14
+ declare export function exportFile(
15
+ editor: LexicalEditor,
16
+ config?: $ReadOnly<{fileName?: string, source?: string}>,
17
+ ): void;
@@ -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.execCommand("clearHistory")})};
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)})};
package/package.json CHANGED
@@ -1,9 +1,5 @@
1
1
  {
2
2
  "name": "@lexical/file",
3
- "author": {
4
- "name": "Dominic Gannaway",
5
- "email": "dg@domgan.com"
6
- },
7
3
  "description": "This package provides the file import/export feature for Lexical.",
8
4
  "keywords": [
9
5
  "lexical",
@@ -14,10 +10,10 @@
14
10
  "export"
15
11
  ],
16
12
  "license": "MIT",
17
- "version": "0.1.16",
13
+ "version": "0.1.19",
18
14
  "main": "LexicalFile.js",
19
15
  "peerDependencies": {
20
- "lexical": "0.1.16"
16
+ "lexical": "0.1.19"
21
17
  },
22
18
  "repository": {
23
19
  "type": "git",