mirror of
https://github.com/facebook/lexical.git
synced 2025-05-17 15:18:47 +08:00
Add unstable serialization logic for node JSON parsing (#2157)
* Add unstable serialization logic for node JSON parsing * Ooops * Freeze editorState * Migrate code node * Address feedback * Address feedback * Address feedback * Address more feedback * Address more feedback * Address FlowFixMes * update types * prettier * remove import * polish types * fix types * add ut for unstable APIs * fix rebase issue * oops * wip * more nodes * types * prettier * add tests for core nodes * update codes.json * Merge global files * Rename global type defs * Update packages/lexical-link/src/index.js Co-authored-by: Gerard Rovira <zurfyx@users.noreply.github.com> * fix linter an versions * more versions Co-authored-by: acywatson <acy.watson@gmail.com> Co-authored-by: John Flockton <thegreatercurve@users.noreply.github.com> Co-authored-by: Gerard Rovira <zurfyx@users.noreply.github.com>
This commit is contained in:
@ -68,5 +68,11 @@
|
||||
"66": "createNode: node does not exist in nodeMap",
|
||||
"67": "reconcileNode: prevNode or nextNode does not exist in nodeMap",
|
||||
"68": "reconcileNode: parentDOM is null",
|
||||
"69": "Reconciliation: could not find DOM element for node key \"${key}\""
|
||||
"69": "Reconciliation: could not find DOM element for node key \"${key}\"",
|
||||
"70": "Incorrect node type received in importJSON for %s",
|
||||
"71": "LexicalNode: Node %s does not implement .exportJSON().",
|
||||
"72": "LexicalNode: Node %s is an element but .exportJSON() does not have a children array.",
|
||||
"73": "parseEditorState: type \"%s\" + not found",
|
||||
"74": "LexicalNode: Node %s does not implement .importJSON().",
|
||||
"75": "exportJSON: base method not extended"
|
||||
}
|
||||
|
@ -13,19 +13,19 @@ const traverse = require('@babel/traverse').default;
|
||||
const evalToString = require('./evalToString');
|
||||
const invertObject = require('./invertObject');
|
||||
|
||||
const plugins = [
|
||||
'classProperties',
|
||||
'jsx',
|
||||
'trailingFunctionCommas',
|
||||
'objectRestSpread',
|
||||
];
|
||||
|
||||
const babylonOptions = {
|
||||
// As a parser, babylon has its own options and we can't directly
|
||||
// import/require a babel preset. It should be kept **the same** as
|
||||
// the `babel-plugin-syntax-*` ones specified in
|
||||
// https://github.com/facebook/fbjs/blob/master/packages/babel-preset-fbjs/configure.js
|
||||
plugins: [
|
||||
'classProperties',
|
||||
'flow',
|
||||
'jsx',
|
||||
'trailingFunctionCommas',
|
||||
'objectRestSpread',
|
||||
],
|
||||
|
||||
plugins,
|
||||
sourceType: 'module',
|
||||
};
|
||||
|
||||
@ -99,7 +99,13 @@ module.exports = function (opts) {
|
||||
);
|
||||
}
|
||||
|
||||
return function extractErrors(source) {
|
||||
return function extractErrors(source, isTypeScript) {
|
||||
if (isTypeScript) {
|
||||
babylonOptions.plugins = [...plugins, 'typescript'];
|
||||
} else {
|
||||
babylonOptions.plugins = [...plugins, 'flow'];
|
||||
}
|
||||
|
||||
transform(source);
|
||||
flush();
|
||||
};
|
||||
|
Reference in New Issue
Block a user