add lexical-file package (#1286)

This commit is contained in:
Acy Watson
2022-02-14 10:31:19 -08:00
committed by acywatson
parent 4c3dfe677f
commit 44e8daeae4
12 changed files with 92 additions and 27 deletions

View File

@ -32,13 +32,13 @@ module.name_mapper='^lexical/OverflowNode' -> '<PROJECT_ROOT>/packages/lexical/s
module.name_mapper='^lexical/ExtendedNodes' -> '<PROJECT_ROOT>/packages/lexical/src/nodes/extended/LexicalExtendedNodes.js'
module.name_mapper='^@lexical/list' -> '<PROJECT_ROOT>/packages/lexical-list/src/index.js'
module.name_mapper='^@lexical/file' -> '<PROJECT_ROOT>/packages/lexical-file/src/index.js'
module.name_mapper='^@lexical/helpers/selection' -> '<PROJECT_ROOT>/packages/lexical-helpers/src/LexicalSelectionHelpers.js'
module.name_mapper='^@lexical/helpers/text' -> '<PROJECT_ROOT>/packages/lexical-helpers/src/LexicalTextHelpers.js'
module.name_mapper='^@lexical/helpers/nodes' -> '<PROJECT_ROOT>/packages/lexical-helpers/src/LexicalNodeHelpers.js'
module.name_mapper='^@lexical/helpers/elements' -> '<PROJECT_ROOT>/packages/lexical-helpers/src/LexicalElementHelpers.js'
module.name_mapper='^@lexical/helpers/events' -> '<PROJECT_ROOT>/packages/lexical-helpers/src/LexicalEventHelpers.js'
module.name_mapper='^@lexical/helpers/file' -> '<PROJECT_ROOT>/packages/lexical-helpers/src/LexicalFileHelpers.js'
module.name_mapper='^@lexical/helpers/offsets' -> '<PROJECT_ROOT>/packages/lexical-helpers/src/LexicalOffsetHelpers.js'
module.name_mapper='^@lexical/helpers/root' -> '<PROJECT_ROOT>/packages/lexical-helpers/src/LexicalRootHelpers.js'

View File

@ -21,12 +21,11 @@ module.exports = {
},
moduleNameMapper: {
'^./dist/(.+)': './src/$1',
'^@lexical/file$': '<rootDir>/packages/lexical-file/src/index.js',
'^@lexical/helpers/elements$':
'<rootDir>/packages/lexical-helpers/src/LexicalElementHelpers.js',
'^@lexical/helpers/events$':
'<rootDir>/packages/lexical-helpers/src/LexicalEventHelpers.js',
'^@lexical/helpers/file$':
'<rootDir>/packages/lexical-helpers/src/LexicalFileHelpers.js',
'^@lexical/helpers/nodes$':
'<rootDir>/packages/lexical-helpers/src/LexicalNodeHelpers.js',
'^@lexical/helpers/offsets$':

17
package-lock.json generated
View File

@ -6873,6 +6873,10 @@
"node": ">= 10.14.2"
}
},
"node_modules/@lexical/file": {
"resolved": "packages/lexical-file",
"link": true
},
"node_modules/@lexical/helpers": {
"resolved": "packages/lexical-helpers",
"link": true
@ -32530,6 +32534,14 @@
"version": "0.1.8",
"license": "MIT"
},
"packages/lexical-file": {
"name": "@lexical/file",
"version": "0.1.8",
"license": "MIT",
"peerDependencies": {
"lexical": "0.1.8"
}
},
"packages/lexical-helpers": {
"name": "@lexical/helpers",
"version": "0.1.8",
@ -32552,6 +32564,7 @@
"dependencies": {
"@craco/craco": "6.1.2",
"@excalidraw/excalidraw": "latest",
"@lexical/file": "0.1.8",
"@lexical/helpers": "0.1.8",
"@lexical/list": "0.1.8",
"@lexical/react": "0.1.8",
@ -37019,6 +37032,9 @@
"chalk": "^4.0.0"
}
},
"@lexical/file": {
"version": "file:packages/lexical-file"
},
"@lexical/helpers": {
"version": "file:packages/lexical-helpers"
},
@ -45677,6 +45693,7 @@
"requires": {
"@craco/craco": "6.1.2",
"@excalidraw/excalidraw": "latest",
"@lexical/file": "0.1.8",
"@lexical/helpers": "0.1.8",
"@lexical/list": "0.1.8",
"@lexical/react": "0.1.8",

View File

@ -0,0 +1,3 @@
'use strict';
module.exports = require('./dist/LexicalFile.js');

View File

@ -0,0 +1,3 @@
# `@lexical/file`
This package contains the functionality for the file import/export feature of Lexical.

View File

@ -0,0 +1,27 @@
{
"name": "@lexical/file",
"author": {
"name": "Dominic Gannaway",
"email": "dg@domgan.com"
},
"description": "This package provides the file import/export feature for Lexical.",
"keywords": [
"lexical",
"editor",
"rich-text",
"file",
"import",
"export"
],
"license": "MIT",
"version": "0.1.8",
"main": "LexicalFile.js",
"peerDependencies": {
"lexical": "0.1.8"
},
"repository": {
"type": "git",
"url": "https://github.com/facebook/lexical",
"directory": "packages/lexical-file"
}
}

View File

@ -0,0 +1,12 @@
/**
* Copyright (c) Meta Platforms, Inc. and affiliates.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*
* @flow strict
*/
import {exportFile,importFile} from './fileImportExport';
export {exportFile,importFile};

View File

@ -10,6 +10,7 @@
"@lexical/react": "0.1.8",
"@lexical/helpers": "0.1.8",
"@lexical/list": "0.1.8",
"@lexical/file": "0.1.8",
"link-preview-generator": "1.0.7",
"@craco/craco": "6.1.2",
"@excalidraw/excalidraw": "latest",

View File

@ -16,7 +16,7 @@ import {useCallback, useEffect, useState} from 'react';
import {$createStickyNode} from '../nodes/StickyNode';
import {$log, $getRoot} from 'lexical';
import {SUPPORT_SPEECH_RECOGNITION} from './SpeechToTextPlugin';
import {importFile, exportFile} from '@lexical/helpers/file';
import {importFile, exportFile} from '@lexical/file';
const EditorPriority: CommandListenerEditorPriority = 0;

View File

@ -43,10 +43,12 @@ if (isClean) {
fs.removeSync(path.resolve('./packages/lexical-react/dist'));
fs.removeSync(path.resolve('./packages/lexical-helpers/dist'));
fs.removeSync(path.resolve('./packages/lexical-list/dist'));
fs.removeSync(path.resolve('./packages/lexical-file/dist'));
fs.removeSync(path.resolve('./packages/lexical-yjs/dist'));
}
const wwwMappings = {
'@lexical/file': 'LexicalFile',
'@lexical/list': 'LexicalList',
'@lexical/yjs': 'LexicalYjs',
lexical: 'Lexical',
@ -94,6 +96,7 @@ const externals = [
// is different to that of the OSS version).
'lexical',
'@lexical/list',
'@lexical/file',
'@lexical/yjs',
'react-dom',
'react',
@ -181,12 +184,6 @@ async function build(name, inputFile, outputFile, isProd) {
'packages/lexical-helpers/src/LexicalEventHelpers',
),
},
{
find: '@lexical/helpers/file',
replacement: path.resolve(
'packages/lexical-helpers/src/LexicalFileHelpers',
),
},
{
find: '@lexical/helpers/offsets',
replacement: path.resolve(
@ -336,6 +333,17 @@ const packages = [
outputPath: './packages/lexical-list/dist/',
sourcePath: './packages/lexical-list/src/',
},
{
modules: [
{
outputFileName: 'LexicalFile',
sourceFileName: 'index.js',
},
],
name: 'Lexical File',
outputPath: './packages/lexical-file/dist/',
sourcePath: './packages/lexical-file/src/',
},
{
modules: lexicalNodes.map((module) => ({
name: module,

View File

@ -67,9 +67,6 @@ async function prepareLexicalHelpersPackage() {
await exec(
`mv ./packages/lexical-helpers/npm/LexicalEventHelpers.js ./packages/lexical-helpers/npm/events.js`,
);
await exec(
`mv ./packages/lexical-helpers/npm/LexicalFileHelpers.js ./packages/lexical-helpers/npm/file.js`,
);
await exec(
`mv ./packages/lexical-helpers/npm/LexicalOffsetHelpers.js ./packages/lexical-helpers/npm/offsets.js`,
);
@ -122,23 +119,21 @@ async function prepareLexicalYjsPackage() {
);
}
async function prepareLexicalListPackage() {
await exec(`rm -rf ./packages/lexical-list/npm`);
await exec(`mkdir ./packages/lexical-list/npm`);
await exec(
`cp -R ./packages/lexical-list/dist/*.js ./packages/lexical-list/npm`,
);
await exec(
`cp -R ./packages/lexical-list/package.json ./packages/lexical-list/npm`,
);
await exec(`cp -R LICENSE ./packages/lexical-list/npm`);
await exec(
`cp -R ./packages/lexical-list/README.md ./packages/lexical-list/npm`,
);
async function prepareLexicalFeaturePackages() {
const packages = ['lexical-list', 'lexical-file'];
for (let i = 0; i < packages.length; i++) {
const pkg = packages[i];
await exec(`rm -rf ./packages/${pkg}/npm`);
await exec(`mkdir ./packages/${pkg}/npm`);
await exec(`cp -R ./packages/${pkg}/dist/*.js ./packages/${pkg}/npm`);
await exec(`cp -R ./packages/${pkg}/package.json ./packages/${pkg}/npm`);
await exec(`cp -R LICENSE ./packages/${pkg}/npm`);
await exec(`cp -R ./packages/${pkg}/README.md ./packages/${pkg}/npm`);
}
}
prepareLexicalCorePackage();
prepareLexicalHelpersPackage();
prepareLexicalReactPackage();
prepareLexicalYjsPackage();
prepareLexicalListPackage();
prepareLexicalFeaturePackages();