@lexical/file
Advanced tools
Comparing version 0.9.1 to 0.9.2
@@ -9,3 +9,13 @@ /** | ||
import type { LexicalEditor } from 'lexical'; | ||
/** | ||
* Takes a file and inputs its content into the editor state as an input field. | ||
* @param editor - The lexical editor. | ||
*/ | ||
export declare function importFile(editor: LexicalEditor): void; | ||
/** | ||
* Generates a .lexical file to be downloaded by the browser containing the current editor state. | ||
* @param editor - The lexical editor. | ||
* @param config - An object that optionally contains fileName and source. fileName defaults to | ||
* the current date (as a string) and source defaults to lexical. | ||
*/ | ||
export declare function exportFile(editor: LexicalEditor, config?: Readonly<{ | ||
@@ -12,0 +22,0 @@ fileName?: string; |
@@ -11,3 +11,3 @@ /** | ||
var version = "0.9.1"; | ||
var version = "0.9.2"; | ||
@@ -21,2 +21,7 @@ /** | ||
*/ | ||
/** | ||
* Takes a file and inputs its content into the editor state as an input field. | ||
* @param editor - The lexical editor. | ||
*/ | ||
function importFile(editor) { | ||
@@ -54,2 +59,8 @@ readTextFileFromSystem(text => { | ||
/** | ||
* Generates a .lexical file to be downloaded by the browser containing the current editor state. | ||
* @param editor - The lexical editor. | ||
* @param config - An object that optionally contains fileName and source. fileName defaults to | ||
* the current date (as a string) and source defaults to lexical. | ||
*/ | ||
function exportFile(editor, config = Object.freeze({})) { | ||
@@ -56,0 +67,0 @@ const now = new Date(); |
@@ -8,3 +8,3 @@ /** | ||
'use strict';var f=require("lexical");function g(a){let c=document.createElement("input");c.type="file";c.accept=".lexical";c.addEventListener("change",b=>{b=b.target;if(b.files){b=b.files[0];let d=new FileReader;d.readAsText(b,"UTF-8");d.onload=e=>{e.target&&a(e.target.result)}}});c.click()} | ||
exports.exportFile=function(a,c=Object.freeze({})){var b=new Date;a={editorState:a.getEditorState(),lastSaved:b.getTime(),source:c.source||"Lexical",version:"0.9.1"};{c=`${c.fileName||b.toISOString()}.lexical`;b=document.createElement("a");let d=document.body;null!==d&&(d.appendChild(b),b.style.display="none",a=JSON.stringify(a),a=new Blob([a],{type:"octet/stream"}),a=window.URL.createObjectURL(a),b.href=a,b.download=c,b.click(),window.URL.revokeObjectURL(a),b.remove())}}; | ||
exports.exportFile=function(a,c=Object.freeze({})){var b=new Date;a={editorState:a.getEditorState(),lastSaved:b.getTime(),source:c.source||"Lexical",version:"0.9.2"};{c=`${c.fileName||b.toISOString()}.lexical`;b=document.createElement("a");let d=document.body;null!==d&&(d.appendChild(b),b.style.display="none",a=JSON.stringify(a),a=new Blob([a],{type:"octet/stream"}),a=window.URL.createObjectURL(a),b.href=a,b.download=c,b.click(),window.URL.revokeObjectURL(a),b.remove())}}; | ||
exports.importFile=function(a){g(c=>{c=JSON.parse(c);c=a.parseEditorState(JSON.stringify(c.editorState));a.setEditorState(c);a.dispatchCommand(f.CLEAR_HISTORY_COMMAND,void 0)})} |
@@ -13,6 +13,6 @@ { | ||
"license": "MIT", | ||
"version": "0.9.1", | ||
"version": "0.9.2", | ||
"main": "LexicalFile.js", | ||
"peerDependencies": { | ||
"lexical": "0.9.1" | ||
"lexical": "0.9.2" | ||
}, | ||
@@ -19,0 +19,0 @@ "repository": { |
7553
139