@lexical/file
Advanced tools
Comparing version 0.2.7 to 0.2.8
@@ -12,3 +12,3 @@ /** | ||
/** | ||
* Copyright (c) Facebook, Inc. and its affiliates. | ||
* Copyright (c) Meta Platforms, Inc. and affiliates. | ||
* | ||
@@ -18,3 +18,2 @@ * This source code is licensed under the MIT license found in the | ||
* | ||
* | ||
*/ | ||
@@ -26,3 +25,3 @@ function importFile(editor) { | ||
editor.setEditorState(editorState); | ||
editor.dispatchCommand(lexical.CLEAR_HISTORY_COMMAND); | ||
editor.dispatchCommand(lexical.CLEAR_HISTORY_COMMAND, undefined); | ||
}); | ||
@@ -35,5 +34,5 @@ } | ||
input.accept = '.lexical'; | ||
input.addEventListener('change', e => { | ||
// $FlowFixMe | ||
const file = e.target.files[0]; | ||
input.addEventListener('change', event => { | ||
const target = event.target; | ||
const file = target.files[0]; | ||
const reader = new FileReader(); | ||
@@ -43,3 +42,2 @@ reader.readAsText(file, 'UTF-8'); | ||
reader.onload = readerEvent => { | ||
// $FlowFixMe | ||
const content = readerEvent.target.result; | ||
@@ -46,0 +44,0 @@ callback(content); |
@@ -9,2 +9,2 @@ /** | ||
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())}}; | ||
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)})}; | ||
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)})}; |
@@ -13,6 +13,6 @@ { | ||
"license": "MIT", | ||
"version": "0.2.7", | ||
"main": "LexicalFile.js", | ||
"version": "0.2.8", | ||
"main": "LexicalFile.ts", | ||
"peerDependencies": { | ||
"lexical": "0.2.7" | ||
"lexical": "0.2.8" | ||
}, | ||
@@ -19,0 +19,0 @@ "repository": { |
6212
104