Skip to content

Commit

Permalink
Merge branch 'main' into main
Browse files Browse the repository at this point in the history
  • Loading branch information
nadine-nguyen authored Aug 29, 2024
2 parents e9d66ec + 1f778da commit 5b44c80
Show file tree
Hide file tree
Showing 4 changed files with 49 additions and 8 deletions.
19 changes: 16 additions & 3 deletions packages/lexical-react/src/shared/LexicalMenu.ts
Original file line number Diff line number Diff line change
Expand Up @@ -482,6 +482,7 @@ export function useMenuAnchorRef(
setResolution: (r: MenuResolution | null) => void,
className?: string,
parent: HTMLElement = document.body,
shouldIncludePageYOffset__EXPERIMENTAL: boolean = true,
): MutableRefObject<HTMLElement> {
const [editor] = useLexicalComposerContext();
const anchorElementRef = useRef<HTMLElement>(document.createElement('div'));
Expand All @@ -495,7 +496,10 @@ export function useMenuAnchorRef(
const {left, top, width, height} = resolution.getRect();
const anchorHeight = anchorElementRef.current.offsetHeight; // use to position under anchor
containerDiv.style.top = `${
top + window.pageYOffset + anchorHeight + 3
top +
anchorHeight +
3 +
(shouldIncludePageYOffset__EXPERIMENTAL ? window.pageYOffset : 0)
}px`;
containerDiv.style.left = `${left + window.pageXOffset}px`;
containerDiv.style.height = `${height}px`;
Expand All @@ -519,7 +523,10 @@ export function useMenuAnchorRef(
top - rootElementRect.top > menuHeight + height
) {
containerDiv.style.top = `${
top - menuHeight + window.pageYOffset - height
top -
menuHeight -
height +
(shouldIncludePageYOffset__EXPERIMENTAL ? window.pageYOffset : 0)
}px`;
}
}
Expand All @@ -538,7 +545,13 @@ export function useMenuAnchorRef(
anchorElementRef.current = containerDiv;
rootElement.setAttribute('aria-controls', 'typeahead-menu');
}
}, [editor, resolution, className, parent]);
}, [
editor,
resolution,
shouldIncludePageYOffset__EXPERIMENTAL,
className,
parent,
]);

useEffect(() => {
const rootElement = editor.getRootElement();
Expand Down
1 change: 1 addition & 0 deletions packages/lexical-table/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
"main": "LexicalTable.js",
"types": "index.d.ts",
"dependencies": {
"@lexical/clipboard": "0.17.1",
"@lexical/utils": "0.17.1",
"lexical": "0.17.1"
},
Expand Down
1 change: 1 addition & 0 deletions packages/lexical-yjs/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
"types": "index.d.ts",
"dependencies": {
"@lexical/offset": "0.17.1",
"@lexical/selection": "0.17.1",
"lexical": "0.17.1"
},
"peerDependencies": {
Expand Down
36 changes: 31 additions & 5 deletions scripts/build.js
Original file line number Diff line number Diff line change
Expand Up @@ -47,13 +47,16 @@ const closureOptions = {
warning_level: 'QUIET',
};

const modulePackageMappings = Object.fromEntries(
packagesManager.getPublicPackages().flatMap((pkg) => {
const pkgName = pkg.getNpmName();
return pkg.getExportedNpmModuleNames().map((npm) => [npm, pkgName]);
}),
);

const wwwMappings = {
...Object.fromEntries(
packagesManager
.getPublicPackages()
.flatMap((pkg) =>
pkg.getExportedNpmModuleNames().map((npm) => [npm, npmToWwwName(npm)]),
),
Object.keys(modulePackageMappings).map((npm) => [npm, npmToWwwName(npm)]),
),
'prismjs/components/prism-c': 'prism-c',
'prismjs/components/prism-clike': 'prism-clike',
Expand Down Expand Up @@ -126,6 +129,7 @@ function getExtension(format) {
* @param {boolean} isProd
* @param {'cjs'|'esm'} format
* @param {string} version
* @param {import('./shared/PackageMetadata').PackageMetadata} pkg
* @returns {Promise<Array<string>>} the exports of the built module
*/
async function build(
Expand All @@ -136,10 +140,30 @@ async function build(
isProd,
format,
version,
pkg,
) {
const extensions = ['.js', '.jsx', '.ts', '.tsx'];
const inputOptions = {
external(modulePath, src) {
const modulePkgName = modulePackageMappings[modulePath];
if (
typeof modulePkgName === 'string' &&
!(
modulePkgName in pkg.packageJson.dependencies ||
modulePkgName === pkg.getNpmName()
)
) {
console.error(
`Error: ${path.relative(
'.',
src,
)} has an undeclared dependency in its import of ${modulePath}.\nAdd the following to the dependencies in ${path.relative(
'.',
pkg.resolve('package.json'),
)}: "${modulePkgName}": "${version}"`,
);
process.exit(1);
}
return (
monorepoExternalsSet.has(modulePath) ||
thirdPartyExternalsRegExp.test(modulePath)
Expand Down Expand Up @@ -422,6 +446,7 @@ async function buildAll() {
isProduction,
format,
version,
pkg,
);

if (isRelease) {
Expand All @@ -436,6 +461,7 @@ async function buildAll() {
false,
format,
version,
pkg,
);
buildForkModules(outputPath, outputFileName, format, exports);
}
Expand Down

0 comments on commit 5b44c80

Please sign in to comment.