diff --git a/.npmrc b/.npmrc index 521a9f7c077..b6c243d6f36 100644 --- a/.npmrc +++ b/.npmrc @@ -1 +1,2 @@ legacy-peer-deps=true +init-module=./scripts/npm/npm-init.js diff --git a/package-lock.json b/package-lock.json index 1dc03ce094c..5bf364b35e9 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "@lexical/monorepo", - "version": "0.14.3", + "version": "0.14.5", "lockfileVersion": 2, "requires": true, "packages": { "": { "name": "@lexical/monorepo", - "version": "0.14.3", + "version": "0.14.5", "license": "MIT", "workspaces": [ "packages/*" @@ -31132,28 +31132,28 @@ } }, "packages/lexical": { - "version": "0.14.3", + "version": "0.14.5", "license": "MIT" }, "packages/lexical-clipboard": { "name": "@lexical/clipboard", - "version": "0.14.3", + "version": "0.14.5", "license": "MIT", "dependencies": { - "@lexical/html": "0.14.3", - "@lexical/list": "0.14.3", - "@lexical/selection": "0.14.3", - "@lexical/utils": "0.14.3", - "lexical": "0.14.3" + "@lexical/html": "0.14.5", + "@lexical/list": "0.14.5", + "@lexical/selection": "0.14.5", + "@lexical/utils": "0.14.5", + "lexical": "0.14.5" } }, "packages/lexical-code": { "name": "@lexical/code", - "version": "0.14.3", + "version": "0.14.5", "license": "MIT", "dependencies": { - "@lexical/utils": "0.14.3", - "lexical": "0.14.3", + "@lexical/utils": "0.14.5", + "lexical": "0.14.5", "prismjs": "^1.27.0" }, "devDependencies": { @@ -31162,7 +31162,7 @@ }, "packages/lexical-devtools": { "name": "@lexical/devtools", - "version": "0.14.3", + "version": "0.14.5", "hasInstallScript": true, "dependencies": { "@eduardoac-skimlinks/webext-redux": "3.0.1-release-candidate", @@ -31172,12 +31172,12 @@ "zustand": "^4.5.1" }, "devDependencies": { - "@lexical/devtools-core": "0.14.3", + "@lexical/devtools-core": "0.14.5", "@rollup/plugin-babel": "^6.0.4", "@types/react": "^18.2.46", "@types/react-dom": "^18.2.18", "@vitejs/plugin-react": "^4.2.1", - "lexical": "0.14.3", + "lexical": "0.14.5", "typescript": "^5.3.3", "vite": "^5.2.2", "wxt": "^0.17.0" @@ -31185,15 +31185,15 @@ }, "packages/lexical-devtools-core": { "name": "@lexical/devtools-core", - "version": "0.14.3", + "version": "0.14.5", "license": "MIT", "dependencies": { - "@lexical/html": "0.14.3", - "@lexical/link": "0.14.3", - "@lexical/mark": "0.14.3", - "@lexical/table": "0.14.3", - "@lexical/utils": "0.14.3", - "lexical": "0.14.3" + "@lexical/html": "0.14.5", + "@lexical/link": "0.14.5", + "@lexical/mark": "0.14.5", + "@lexical/table": "0.14.5", + "@lexical/utils": "0.14.5", + "lexical": "0.14.5" }, "peerDependencies": { "react": ">=17.x", @@ -31444,144 +31444,144 @@ }, "packages/lexical-dragon": { "name": "@lexical/dragon", - "version": "0.14.3", + "version": "0.14.5", "license": "MIT", "dependencies": { - "lexical": "0.14.3" + "lexical": "0.14.5" } }, "packages/lexical-file": { "name": "@lexical/file", - "version": "0.14.3", + "version": "0.14.5", "license": "MIT", "dependencies": { - "lexical": "0.14.3" + "lexical": "0.14.5" } }, "packages/lexical-hashtag": { "name": "@lexical/hashtag", - "version": "0.14.3", + "version": "0.14.5", "license": "MIT", "dependencies": { - "@lexical/utils": "0.14.3", - "lexical": "0.14.3" + "@lexical/utils": "0.14.5", + "lexical": "0.14.5" } }, "packages/lexical-headless": { "name": "@lexical/headless", - "version": "0.14.3", + "version": "0.14.5", "license": "MIT", "dependencies": { - "lexical": "0.14.3" + "lexical": "0.14.5" } }, "packages/lexical-history": { "name": "@lexical/history", - "version": "0.14.3", + "version": "0.14.5", "license": "MIT", "dependencies": { - "@lexical/utils": "0.14.3", - "lexical": "0.14.3" + "@lexical/utils": "0.14.5", + "lexical": "0.14.5" } }, "packages/lexical-html": { "name": "@lexical/html", - "version": "0.14.3", + "version": "0.14.5", "license": "MIT", "dependencies": { - "@lexical/selection": "0.14.3", - "@lexical/utils": "0.14.3", - "lexical": "0.14.3" + "@lexical/selection": "0.14.5", + "@lexical/utils": "0.14.5", + "lexical": "0.14.5" } }, "packages/lexical-link": { "name": "@lexical/link", - "version": "0.14.3", + "version": "0.14.5", "license": "MIT", "dependencies": { - "@lexical/utils": "0.14.3", - "lexical": "0.14.3" + "@lexical/utils": "0.14.5", + "lexical": "0.14.5" } }, "packages/lexical-list": { "name": "@lexical/list", - "version": "0.14.3", + "version": "0.14.5", "license": "MIT", "dependencies": { - "@lexical/utils": "0.14.3", - "lexical": "0.14.3" + "@lexical/utils": "0.14.5", + "lexical": "0.14.5" } }, "packages/lexical-mark": { "name": "@lexical/mark", - "version": "0.14.3", + "version": "0.14.5", "license": "MIT", "dependencies": { - "@lexical/utils": "0.14.3", - "lexical": "0.14.3" + "@lexical/utils": "0.14.5", + "lexical": "0.14.5" } }, "packages/lexical-markdown": { "name": "@lexical/markdown", - "version": "0.14.3", + "version": "0.14.5", "license": "MIT", "dependencies": { - "@lexical/code": "0.14.3", - "@lexical/link": "0.14.3", - "@lexical/list": "0.14.3", - "@lexical/rich-text": "0.14.3", - "@lexical/text": "0.14.3", - "@lexical/utils": "0.14.3", - "lexical": "0.14.3" + "@lexical/code": "0.14.5", + "@lexical/link": "0.14.5", + "@lexical/list": "0.14.5", + "@lexical/rich-text": "0.14.5", + "@lexical/text": "0.14.5", + "@lexical/utils": "0.14.5", + "lexical": "0.14.5" } }, "packages/lexical-offset": { "name": "@lexical/offset", - "version": "0.14.3", + "version": "0.14.5", "license": "MIT", "dependencies": { - "lexical": "0.14.3" + "lexical": "0.14.5" } }, "packages/lexical-overflow": { "name": "@lexical/overflow", - "version": "0.14.3", + "version": "0.14.5", "license": "MIT", "dependencies": { - "lexical": "0.14.3" + "lexical": "0.14.5" } }, "packages/lexical-plain-text": { "name": "@lexical/plain-text", - "version": "0.14.3", + "version": "0.14.5", "license": "MIT", "dependencies": { - "@lexical/clipboard": "0.14.3", - "@lexical/selection": "0.14.3", - "@lexical/utils": "0.14.3", - "lexical": "0.14.3" + "@lexical/clipboard": "0.14.5", + "@lexical/selection": "0.14.5", + "@lexical/utils": "0.14.5", + "lexical": "0.14.5" } }, "packages/lexical-playground": { - "version": "0.14.3", + "version": "0.14.5", "dependencies": { "@excalidraw/excalidraw": "^0.17.0", - "@lexical/clipboard": "0.14.3", - "@lexical/code": "0.14.3", - "@lexical/file": "0.14.3", - "@lexical/hashtag": "0.14.3", - "@lexical/link": "0.14.3", - "@lexical/list": "0.14.3", - "@lexical/mark": "0.14.3", - "@lexical/overflow": "0.14.3", - "@lexical/plain-text": "0.14.3", - "@lexical/react": "0.14.3", - "@lexical/rich-text": "0.14.3", - "@lexical/selection": "0.14.3", - "@lexical/table": "0.14.3", - "@lexical/utils": "0.14.3", + "@lexical/clipboard": "0.14.5", + "@lexical/code": "0.14.5", + "@lexical/file": "0.14.5", + "@lexical/hashtag": "0.14.5", + "@lexical/link": "0.14.5", + "@lexical/list": "0.14.5", + "@lexical/mark": "0.14.5", + "@lexical/overflow": "0.14.5", + "@lexical/plain-text": "0.14.5", + "@lexical/react": "0.14.5", + "@lexical/rich-text": "0.14.5", + "@lexical/selection": "0.14.5", + "@lexical/table": "0.14.5", + "@lexical/utils": "0.14.5", "katex": "^0.15.2", - "lexical": "0.14.3", + "lexical": "0.14.5", "lodash-es": "^4.17.21", "prettier": "^2.3.2", "react": "^18.2.0", @@ -31600,27 +31600,28 @@ }, "packages/lexical-react": { "name": "@lexical/react", - "version": "0.14.3", + "version": "0.14.5", "license": "MIT", "dependencies": { - "@lexical/clipboard": "0.14.3", - "@lexical/code": "0.14.3", - "@lexical/dragon": "0.14.3", - "@lexical/hashtag": "0.14.3", - "@lexical/history": "0.14.3", - "@lexical/link": "0.14.3", - "@lexical/list": "0.14.3", - "@lexical/mark": "0.14.3", - "@lexical/markdown": "0.14.3", - "@lexical/overflow": "0.14.3", - "@lexical/plain-text": "0.14.3", - "@lexical/rich-text": "0.14.3", - "@lexical/selection": "0.14.3", - "@lexical/table": "0.14.3", - "@lexical/text": "0.14.3", - "@lexical/utils": "0.14.3", - "@lexical/yjs": "0.14.3", - "lexical": "0.14.3", + "@lexical/clipboard": "0.14.5", + "@lexical/code": "0.14.5", + "@lexical/devtools-core": "0.14.5", + "@lexical/dragon": "0.14.5", + "@lexical/hashtag": "0.14.5", + "@lexical/history": "0.14.5", + "@lexical/link": "0.14.5", + "@lexical/list": "0.14.5", + "@lexical/mark": "0.14.5", + "@lexical/markdown": "0.14.5", + "@lexical/overflow": "0.14.5", + "@lexical/plain-text": "0.14.5", + "@lexical/rich-text": "0.14.5", + "@lexical/selection": "0.14.5", + "@lexical/table": "0.14.5", + "@lexical/text": "0.14.5", + "@lexical/utils": "0.14.5", + "@lexical/yjs": "0.14.5", + "lexical": "0.14.5", "react-error-boundary": "^3.1.4" }, "peerDependencies": { @@ -31630,54 +31631,54 @@ }, "packages/lexical-rich-text": { "name": "@lexical/rich-text", - "version": "0.14.3", + "version": "0.14.5", "license": "MIT", "dependencies": { - "@lexical/clipboard": "0.14.3", - "@lexical/selection": "0.14.3", - "@lexical/utils": "0.14.3", - "lexical": "0.14.3" + "@lexical/clipboard": "0.14.5", + "@lexical/selection": "0.14.5", + "@lexical/utils": "0.14.5", + "lexical": "0.14.5" } }, "packages/lexical-selection": { "name": "@lexical/selection", - "version": "0.14.3", + "version": "0.14.5", "license": "MIT", "dependencies": { - "lexical": "0.14.3" + "lexical": "0.14.5" } }, "packages/lexical-table": { "name": "@lexical/table", - "version": "0.14.3", + "version": "0.14.5", "license": "MIT", "dependencies": { - "@lexical/utils": "0.14.3", - "lexical": "0.14.3" + "@lexical/utils": "0.14.5", + "lexical": "0.14.5" } }, "packages/lexical-text": { "name": "@lexical/text", - "version": "0.14.3", + "version": "0.14.5", "license": "MIT", "dependencies": { - "lexical": "0.14.3" + "lexical": "0.14.5" } }, "packages/lexical-utils": { "name": "@lexical/utils", - "version": "0.14.3", + "version": "0.14.5", "license": "MIT", "dependencies": { - "@lexical/list": "0.14.3", - "@lexical/selection": "0.14.3", - "@lexical/table": "0.14.3", - "lexical": "0.14.3" + "@lexical/list": "0.14.5", + "@lexical/selection": "0.14.5", + "@lexical/table": "0.14.5", + "lexical": "0.14.5" } }, "packages/lexical-website": { "name": "@lexical/website", - "version": "0.14.3", + "version": "0.14.5", "dependencies": { "@docusaurus/core": "^3.2.1", "@docusaurus/preset-classic": "^3.2.1", @@ -31703,11 +31704,11 @@ }, "packages/lexical-yjs": { "name": "@lexical/yjs", - "version": "0.14.3", + "version": "0.14.5", "license": "MIT", "dependencies": { - "@lexical/offset": "0.14.3", - "lexical": "0.14.3" + "@lexical/offset": "0.14.5", + "lexical": "0.14.5" }, "peerDependencies": { "yjs": ">=13.5.22" @@ -31740,10 +31741,10 @@ } }, "packages/shared": { - "version": "0.14.3", + "version": "0.14.5", "license": "MIT", "dependencies": { - "lexical": "0.14.3" + "lexical": "0.14.5" } } }, @@ -35122,19 +35123,19 @@ "@lexical/clipboard": { "version": "file:packages/lexical-clipboard", "requires": { - "@lexical/html": "0.14.3", - "@lexical/list": "0.14.3", - "@lexical/selection": "0.14.3", - "@lexical/utils": "0.14.3", - "lexical": "0.14.3" + "@lexical/html": "0.14.5", + "@lexical/list": "0.14.5", + "@lexical/selection": "0.14.5", + "@lexical/utils": "0.14.5", + "lexical": "0.14.5" } }, "@lexical/code": { "version": "file:packages/lexical-code", "requires": { - "@lexical/utils": "0.14.3", + "@lexical/utils": "0.14.5", "@types/prismjs": "^1.26.0", - "lexical": "0.14.3", + "lexical": "0.14.5", "prismjs": "^1.27.0" } }, @@ -35142,12 +35143,12 @@ "version": "file:packages/lexical-devtools", "requires": { "@eduardoac-skimlinks/webext-redux": "3.0.1-release-candidate", - "@lexical/devtools-core": "0.14.3", + "@lexical/devtools-core": "0.14.5", "@rollup/plugin-babel": "^6.0.4", "@types/react": "^18.2.46", "@types/react-dom": "^18.2.18", "@vitejs/plugin-react": "^4.2.1", - "lexical": "0.14.3", + "lexical": "0.14.5", "react": "^18.2.0", "react-dom": "^18.2.0", "typescript": "^5.3.3", @@ -35295,167 +35296,168 @@ "@lexical/devtools-core": { "version": "file:packages/lexical-devtools-core", "requires": { - "@lexical/html": "0.14.3", - "@lexical/link": "0.14.3", - "@lexical/mark": "0.14.3", - "@lexical/table": "0.14.3", - "@lexical/utils": "0.14.3", - "lexical": "0.14.3" + "@lexical/html": "0.14.5", + "@lexical/link": "0.14.5", + "@lexical/mark": "0.14.5", + "@lexical/table": "0.14.5", + "@lexical/utils": "0.14.5", + "lexical": "0.14.5" } }, "@lexical/dragon": { "version": "file:packages/lexical-dragon", "requires": { - "lexical": "0.14.3" + "lexical": "0.14.5" } }, "@lexical/file": { "version": "file:packages/lexical-file", "requires": { - "lexical": "0.14.3" + "lexical": "0.14.5" } }, "@lexical/hashtag": { "version": "file:packages/lexical-hashtag", "requires": { - "@lexical/utils": "0.14.3", - "lexical": "0.14.3" + "@lexical/utils": "0.14.5", + "lexical": "0.14.5" } }, "@lexical/headless": { "version": "file:packages/lexical-headless", "requires": { - "lexical": "0.14.3" + "lexical": "0.14.5" } }, "@lexical/history": { "version": "file:packages/lexical-history", "requires": { - "@lexical/utils": "0.14.3", - "lexical": "0.14.3" + "@lexical/utils": "0.14.5", + "lexical": "0.14.5" } }, "@lexical/html": { "version": "file:packages/lexical-html", "requires": { - "@lexical/selection": "0.14.3", - "@lexical/utils": "0.14.3", - "lexical": "0.14.3" + "@lexical/selection": "0.14.5", + "@lexical/utils": "0.14.5", + "lexical": "0.14.5" } }, "@lexical/link": { "version": "file:packages/lexical-link", "requires": { - "@lexical/utils": "0.14.3", - "lexical": "0.14.3" + "@lexical/utils": "0.14.5", + "lexical": "0.14.5" } }, "@lexical/list": { "version": "file:packages/lexical-list", "requires": { - "@lexical/utils": "0.14.3", - "lexical": "0.14.3" + "@lexical/utils": "0.14.5", + "lexical": "0.14.5" } }, "@lexical/mark": { "version": "file:packages/lexical-mark", "requires": { - "@lexical/utils": "0.14.3", - "lexical": "0.14.3" + "@lexical/utils": "0.14.5", + "lexical": "0.14.5" } }, "@lexical/markdown": { "version": "file:packages/lexical-markdown", "requires": { - "@lexical/code": "0.14.3", - "@lexical/link": "0.14.3", - "@lexical/list": "0.14.3", - "@lexical/rich-text": "0.14.3", - "@lexical/text": "0.14.3", - "@lexical/utils": "0.14.3", - "lexical": "0.14.3" + "@lexical/code": "0.14.5", + "@lexical/link": "0.14.5", + "@lexical/list": "0.14.5", + "@lexical/rich-text": "0.14.5", + "@lexical/text": "0.14.5", + "@lexical/utils": "0.14.5", + "lexical": "0.14.5" } }, "@lexical/offset": { "version": "file:packages/lexical-offset", "requires": { - "lexical": "0.14.3" + "lexical": "0.14.5" } }, "@lexical/overflow": { "version": "file:packages/lexical-overflow", "requires": { - "lexical": "0.14.3" + "lexical": "0.14.5" } }, "@lexical/plain-text": { "version": "file:packages/lexical-plain-text", "requires": { - "@lexical/clipboard": "0.14.3", - "@lexical/selection": "0.14.3", - "@lexical/utils": "0.14.3", - "lexical": "0.14.3" + "@lexical/clipboard": "0.14.5", + "@lexical/selection": "0.14.5", + "@lexical/utils": "0.14.5", + "lexical": "0.14.5" } }, "@lexical/react": { "version": "file:packages/lexical-react", "requires": { - "@lexical/clipboard": "0.14.3", - "@lexical/code": "0.14.3", - "@lexical/dragon": "0.14.3", - "@lexical/hashtag": "0.14.3", - "@lexical/history": "0.14.3", - "@lexical/link": "0.14.3", - "@lexical/list": "0.14.3", - "@lexical/mark": "0.14.3", - "@lexical/markdown": "0.14.3", - "@lexical/overflow": "0.14.3", - "@lexical/plain-text": "0.14.3", - "@lexical/rich-text": "0.14.3", - "@lexical/selection": "0.14.3", - "@lexical/table": "0.14.3", - "@lexical/text": "0.14.3", - "@lexical/utils": "0.14.3", - "@lexical/yjs": "0.14.3", - "lexical": "0.14.3", + "@lexical/clipboard": "0.14.5", + "@lexical/code": "0.14.5", + "@lexical/devtools-core": "0.14.5", + "@lexical/dragon": "0.14.5", + "@lexical/hashtag": "0.14.5", + "@lexical/history": "0.14.5", + "@lexical/link": "0.14.5", + "@lexical/list": "0.14.5", + "@lexical/mark": "0.14.5", + "@lexical/markdown": "0.14.5", + "@lexical/overflow": "0.14.5", + "@lexical/plain-text": "0.14.5", + "@lexical/rich-text": "0.14.5", + "@lexical/selection": "0.14.5", + "@lexical/table": "0.14.5", + "@lexical/text": "0.14.5", + "@lexical/utils": "0.14.5", + "@lexical/yjs": "0.14.5", + "lexical": "0.14.5", "react-error-boundary": "^3.1.4" } }, "@lexical/rich-text": { "version": "file:packages/lexical-rich-text", "requires": { - "@lexical/clipboard": "0.14.3", - "@lexical/selection": "0.14.3", - "@lexical/utils": "0.14.3", - "lexical": "0.14.3" + "@lexical/clipboard": "0.14.5", + "@lexical/selection": "0.14.5", + "@lexical/utils": "0.14.5", + "lexical": "0.14.5" } }, "@lexical/selection": { "version": "file:packages/lexical-selection", "requires": { - "lexical": "0.14.3" + "lexical": "0.14.5" } }, "@lexical/table": { "version": "file:packages/lexical-table", "requires": { - "@lexical/utils": "0.14.3", - "lexical": "0.14.3" + "@lexical/utils": "0.14.5", + "lexical": "0.14.5" } }, "@lexical/text": { "version": "file:packages/lexical-text", "requires": { - "lexical": "0.14.3" + "lexical": "0.14.5" } }, "@lexical/utils": { "version": "file:packages/lexical-utils", "requires": { - "@lexical/list": "0.14.3", - "@lexical/selection": "0.14.3", - "@lexical/table": "0.14.3", - "lexical": "0.14.3" + "@lexical/list": "0.14.5", + "@lexical/selection": "0.14.5", + "@lexical/table": "0.14.5", + "lexical": "0.14.5" } }, "@lexical/website": { @@ -35484,8 +35486,8 @@ "@lexical/yjs": { "version": "file:packages/lexical-yjs", "requires": { - "@lexical/offset": "0.14.3", - "lexical": "0.14.3" + "@lexical/offset": "0.14.5", + "lexical": "0.14.5" } }, "@mdx-js/mdx": { @@ -44780,24 +44782,24 @@ "version": "file:packages/lexical-playground", "requires": { "@excalidraw/excalidraw": "^0.17.0", - "@lexical/clipboard": "0.14.3", - "@lexical/code": "0.14.3", - "@lexical/file": "0.14.3", - "@lexical/hashtag": "0.14.3", - "@lexical/link": "0.14.3", - "@lexical/list": "0.14.3", - "@lexical/mark": "0.14.3", - "@lexical/overflow": "0.14.3", - "@lexical/plain-text": "0.14.3", - "@lexical/react": "0.14.3", - "@lexical/rich-text": "0.14.3", - "@lexical/selection": "0.14.3", - "@lexical/table": "0.14.3", - "@lexical/utils": "0.14.3", + "@lexical/clipboard": "0.14.5", + "@lexical/code": "0.14.5", + "@lexical/file": "0.14.5", + "@lexical/hashtag": "0.14.5", + "@lexical/link": "0.14.5", + "@lexical/list": "0.14.5", + "@lexical/mark": "0.14.5", + "@lexical/overflow": "0.14.5", + "@lexical/plain-text": "0.14.5", + "@lexical/react": "0.14.5", + "@lexical/rich-text": "0.14.5", + "@lexical/selection": "0.14.5", + "@lexical/table": "0.14.5", + "@lexical/utils": "0.14.5", "@types/lodash-es": "^4.14.182", "@vitejs/plugin-react": "^1.0.7", "katex": "^0.15.2", - "lexical": "0.14.3", + "lexical": "0.14.5", "lodash-es": "^4.17.21", "prettier": "^2.3.2", "react": "^18.2.0", @@ -50307,7 +50309,7 @@ "shared": { "version": "file:packages/shared", "requires": { - "lexical": "0.14.3" + "lexical": "0.14.5" } }, "shebang-command": { diff --git a/packages/lexical-react/flow/LexicalContextMenuPlugin.js.flow b/packages/lexical-react/flow/LexicalContextMenuPlugin.js.flow new file mode 100644 index 00000000000..27b66459534 --- /dev/null +++ b/packages/lexical-react/flow/LexicalContextMenuPlugin.js.flow @@ -0,0 +1,11 @@ +/** + * 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. + * + */ + +/** + * LexicalContextMenuPlugin + */ diff --git a/packages/lexical-react/flow/LexicalEditorRefPlugin.js.flow b/packages/lexical-react/flow/LexicalEditorRefPlugin.js.flow new file mode 100644 index 00000000000..88050067c04 --- /dev/null +++ b/packages/lexical-react/flow/LexicalEditorRefPlugin.js.flow @@ -0,0 +1,11 @@ +/** + * 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. + * + */ + +/** + * LexicalEditorRefPlugin + */ diff --git a/packages/lexical-react/flow/LexicalNodeEventPlugin.js.flow b/packages/lexical-react/flow/LexicalNodeEventPlugin.js.flow new file mode 100644 index 00000000000..a7fed0f44a0 --- /dev/null +++ b/packages/lexical-react/flow/LexicalNodeEventPlugin.js.flow @@ -0,0 +1,11 @@ +/** + * 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. + * + */ + +/** + * LexicalNodeEventPlugin + */ diff --git a/packages/lexical-website/docs/maintainers-guide.md b/packages/lexical-website/docs/maintainers-guide.md index cab6a21310b..ca3221a66b9 100644 --- a/packages/lexical-website/docs/maintainers-guide.md +++ b/packages/lexical-website/docs/maintainers-guide.md @@ -60,6 +60,123 @@ TypeScript file, not a subdirectory containing an index.ts file. The [update-packages](#npm-run-update-packages) script will ensure that the exports match the files on disk. +## Creating a new package + +The first step in creating a new package is to create the workspace, there +is a [npm-init](https://docs.npmjs.com/cli/v10/commands/npm-init) template +that will fill in some of the defaults for you based on conventions. + +The example we will use is the steps that were used to create the +`lexical-eslint-plugin`, which will be published to npm as +`@lexical/eslint-plugin`. + +### Create the workspace + +``` +npm init -w packages/lexical-eslint-plugin +``` + +This only automates the first step, creating a single file: + +
+ +`packages/lexical-eslint-plugin/package.json` + + +```json +{ + "name": "@lexical/eslint-plugin", + "description": "", + "keywords": [ + "lexical", + "editor" + ], + "version": "0.14.3", + "license": "MIT", + "repository": { + "type": "git", + "url": "git+https://github.com/facebook/lexical.git", + "directory": "packages/lexical-eslint-plugin" + }, + "main": "LexicalEslintPlugin.js", + "types": "index.d.ts", + "bugs": { + "url": "https://github.com/facebook/lexical/issues" + }, + "homepage": "https://github.com/facebook/lexical#readme" +} +``` +
+ +Some next steps for this package.json before moving on: + +- Update the description +- Add appropriate keywords + +### Create the initial source file + +``` +mkdir -p packages/lexical-eslint-plugin/src +code packages/lexical-eslint-plugin/src/index.ts +``` + +Here are some minimal examples of those files that you might start out with. +I've elided the license header, the eslint header/header fixer will help you +with that! + +
+ +`packages/lexical-eslint-plugin/src/index.ts` + + +```typescript +import {name, version} from '../package.json'; + +const plugin = { + meta: {name, version}, + rules: {}, +}; + +export default plugin; +``` +
+ +### Run update-packages to generate boilerplate docs & config + +``` +npm run update-packages +``` + +This will set up the tsconfig, flow, etc. configuration to recognize your +new module. It will also create an initial README.md using only the +description from the package.json. + + +### Create an initial unit test + +``` +mkdir -p packages/lexical-eslint-plugin/src/__tests__/unit +code packages/lexical-eslint-plugin/src/__tests__/unit/LexicalEslintPlugin.test.ts +``` + + +
+ +`packages/lexical-eslint-plugin/src/__tests__/unit/LexicalEslintPlugin.test.ts` + + +```typescript +import plugin from '@lexical/eslint-plugin'; + +describe('LexicalEslintPlugin', () => { + it('exports a plugin with meta and rules', () => { + expect(Object.keys(plugin).sort()).toMatchObject(['meta', 'rules']); + }); +}); +``` +
+ + ## Scripts for development ### npm run update-packages diff --git a/scripts/npm/npm-init.js b/scripts/npm/npm-init.js new file mode 100644 index 00000000000..44ab8d4b9fe --- /dev/null +++ b/scripts/npm/npm-init.js @@ -0,0 +1,44 @@ +/** + * 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. + * + */ +// @ts-check +// npm-init can not use strict mode because PromZard is very strange +// and does not simply require this module +/* eslint-disable strict */ +/* eslint-disable sort-keys-fix/sort-keys-fix */ + +const path = require('node:path'); +const npmToWwwName = require('../www/npmToWwwName'); +const argv = require('minimist')(process.argv.slice(2)); +const {PackageMetadata} = require('../shared/PackageMetadata'); + +const lexicalPkg = new PackageMetadata('packages/lexical/package.json'); + +// npm doesn't give us a way to discover the -w argument so +const workspace = argv.w || argv.workspace; +if ( + !Array.isArray(argv._) || + argv._.join(' ') !== 'init' || + typeof workspace !== 'string' || + !/^packages\/[^/]+$/.test(workspace) +) { + throw new Error( + 'Expecting to be called as npm init -w packages/PACKAGE_NAME', + ); +} +const pkgDirName = path.basename(workspace); + +module.exports = { + name: pkgDirName.replace(/^lexical-/, '@lexical/'), + description: '', + keywords: ['lexical', 'editor'], + version: lexicalPkg.packageJson.version, + license: lexicalPkg.packageJson.license, + repository: {...lexicalPkg.packageJson.repository, directory: workspace}, + main: `${npmToWwwName(pkgDirName)}.js`, + types: 'index.d.ts', +}; diff --git a/scripts/update-flowconfig.js b/scripts/update-flowconfig.js index 50bdbca46e8..9d2e9b872f9 100644 --- a/scripts/update-flowconfig.js +++ b/scripts/update-flowconfig.js @@ -13,9 +13,25 @@ const path = require('node:path'); const {packagesManager} = require('./shared/packagesManager'); const npmToWwwName = require('./www/npmToWwwName'); +const headerTemplate = fs.readFileSync( + path.resolve(__dirname, 'www', 'headerTemplate.js'), + 'utf8', +); + const BLOCK_REGEX = /^([\s\S]+?\n;; \[generated-start update-flowconfig\]\n)([\s\S]*?)(;; \[generated-end update-flowconfig\][\s\S]+)$/; +function flowTemplate(wwwName) { + return ( + headerTemplate.replace(/^( *\/)$/, '* @flow strict\n$1') + + ` +/** + * ${wwwName} + */` + + '\n' + ); +} + /** * @param {string} configContents * @param {string} generatedCode @@ -60,7 +76,17 @@ function updateFlowconfig(flowconfigPath = './.flowconfig') { } } else { for (const name of pkg.getExportedNpmModuleNames()) { - emit(name, resolveRelative('flow', `${npmToWwwName(name)}.js.flow`)); + const wwwName = npmToWwwName(name); + const flowFile = `${wwwName}.js.flow`; + const resolvedFlowFile = resolveRelative('flow', flowFile); + emit(name, resolveRelative('flow', flowFile)); + const flowFilePath = pkg.resolve('flow', flowFile); + if (!fs.existsSync(flowFilePath)) { + console.log( + `Creating boilerplate ${resolvedFlowFile.replace(/^[^/]+\//, '')}`, + ); + fs.writeFileSync(flowFilePath, flowTemplate(wwwName)); + } } } }