diff --git a/.github/workflows/claude-code-review.yml b/.github/workflows/claude-code-review.yml index b5e8cfd4..2d30d4e0 100644 --- a/.github/workflows/claude-code-review.yml +++ b/.github/workflows/claude-code-review.yml @@ -1,44 +1,43 @@ name: Claude Code Review on: - pull_request: - types: [opened, synchronize, ready_for_review, reopened] - # Optional: Only run on specific file changes - # paths: - # - "src/**/*.ts" - # - "src/**/*.tsx" - # - "src/**/*.js" - # - "src/**/*.jsx" + pull_request: + types: [opened, synchronize, ready_for_review, reopened] + # Optional: Only run on specific file changes + # paths: + # - "src/**/*.ts" + # - "src/**/*.tsx" + # - "src/**/*.js" + # - "src/**/*.jsx" jobs: - claude-review: - # Optional: Filter by PR author - # if: | - # github.event.pull_request.user.login == 'external-contributor' || - # github.event.pull_request.user.login == 'new-developer' || - # github.event.pull_request.author_association == 'FIRST_TIME_CONTRIBUTOR' + claude-review: + # Optional: Filter by PR author + # if: | + # github.event.pull_request.user.login == 'external-contributor' || + # github.event.pull_request.user.login == 'new-developer' || + # github.event.pull_request.author_association == 'FIRST_TIME_CONTRIBUTOR' - runs-on: ubuntu-latest - permissions: - contents: read - pull-requests: read - issues: read - id-token: write + runs-on: ubuntu-latest + permissions: + contents: read + pull-requests: read + issues: read + id-token: write - steps: - - name: Checkout repository - uses: actions/checkout@v4 - with: - fetch-depth: 1 - - - name: Run Claude Code Review - id: claude-review - uses: anthropics/claude-code-action@v1 - with: - claude_code_oauth_token: ${{ secrets.CLAUDE_CODE_OAUTH_TOKEN }} - plugin_marketplaces: 'https://github.com/anthropics/claude-code.git' - plugins: 'code-review@claude-code-plugins' - prompt: '/code-review:code-review ${{ github.repository }}/pull/${{ github.event.pull_request.number }}' - # See https://github.com/anthropics/claude-code-action/blob/main/docs/usage.md - # or https://code.claude.com/docs/en/cli-reference for available options + steps: + - name: Checkout repository + uses: actions/checkout@v4 + with: + fetch-depth: 1 + - name: Run Claude Code Review + id: claude-review + uses: anthropics/claude-code-action@v1 + with: + claude_code_oauth_token: ${{ secrets.CLAUDE_CODE_OAUTH_TOKEN }} + plugin_marketplaces: 'https://github.com/anthropics/claude-code.git' + plugins: 'code-review@claude-code-plugins' + prompt: '/code-review:code-review ${{ github.repository }}/pull/${{ github.event.pull_request.number }}' + # See https://github.com/anthropics/claude-code-action/blob/main/docs/usage.md + # or https://code.claude.com/docs/en/cli-reference for available options diff --git a/.github/workflows/claude.yml b/.github/workflows/claude.yml index d300267f..c0520ec6 100644 --- a/.github/workflows/claude.yml +++ b/.github/workflows/claude.yml @@ -1,50 +1,49 @@ name: Claude Code on: - issue_comment: - types: [created] - pull_request_review_comment: - types: [created] - issues: - types: [opened, assigned] - pull_request_review: - types: [submitted] + issue_comment: + types: [created] + pull_request_review_comment: + types: [created] + issues: + types: [opened, assigned] + pull_request_review: + types: [submitted] jobs: - claude: - if: | - (github.event_name == 'issue_comment' && contains(github.event.comment.body, '@claude')) || - (github.event_name == 'pull_request_review_comment' && contains(github.event.comment.body, '@claude')) || - (github.event_name == 'pull_request_review' && contains(github.event.review.body, '@claude')) || - (github.event_name == 'issues' && (contains(github.event.issue.body, '@claude') || contains(github.event.issue.title, '@claude'))) - runs-on: ubuntu-latest - permissions: - contents: read - pull-requests: read - issues: read - id-token: write - actions: read # Required for Claude to read CI results on PRs - steps: - - name: Checkout repository - uses: actions/checkout@v4 - with: - fetch-depth: 1 + claude: + if: | + (github.event_name == 'issue_comment' && contains(github.event.comment.body, '@claude')) || + (github.event_name == 'pull_request_review_comment' && contains(github.event.comment.body, '@claude')) || + (github.event_name == 'pull_request_review' && contains(github.event.review.body, '@claude')) || + (github.event_name == 'issues' && (contains(github.event.issue.body, '@claude') || contains(github.event.issue.title, '@claude'))) + runs-on: ubuntu-latest + permissions: + contents: read + pull-requests: read + issues: read + id-token: write + actions: read # Required for Claude to read CI results on PRs + steps: + - name: Checkout repository + uses: actions/checkout@v4 + with: + fetch-depth: 1 - - name: Run Claude Code - id: claude - uses: anthropics/claude-code-action@v1 - with: - claude_code_oauth_token: ${{ secrets.CLAUDE_CODE_OAUTH_TOKEN }} + - name: Run Claude Code + id: claude + uses: anthropics/claude-code-action@v1 + with: + claude_code_oauth_token: ${{ secrets.CLAUDE_CODE_OAUTH_TOKEN }} - # This is an optional setting that allows Claude to read CI results on PRs - additional_permissions: | - actions: read + # This is an optional setting that allows Claude to read CI results on PRs + additional_permissions: | + actions: read - # Optional: Give a custom prompt to Claude. If this is not specified, Claude will perform the instructions specified in the comment that tagged it. - # prompt: 'Update the pull request description to include a summary of changes.' - - # Optional: Add claude_args to customize behavior and configuration - # See https://github.com/anthropics/claude-code-action/blob/main/docs/usage.md - # or https://code.claude.com/docs/en/cli-reference for available options - # claude_args: '--allowed-tools Bash(gh pr:*)' + # Optional: Give a custom prompt to Claude. If this is not specified, Claude will perform the instructions specified in the comment that tagged it. + # prompt: 'Update the pull request description to include a summary of changes.' + # Optional: Add claude_args to customize behavior and configuration + # See https://github.com/anthropics/claude-code-action/blob/main/docs/usage.md + # or https://code.claude.com/docs/en/cli-reference for available options + # claude_args: '--allowed-tools Bash(gh pr:*)' diff --git a/.github/workflows/publish-public-build.yml b/.github/workflows/publish-public-build.yml index daef2f54..f9d0c109 100644 --- a/.github/workflows/publish-public-build.yml +++ b/.github/workflows/publish-public-build.yml @@ -1,56 +1,56 @@ name: Publish Public Build on: - push: - branches: - - master + push: + branches: + - master jobs: - publish-build: - runs-on: ubuntu-latest - - steps: - - uses: actions/checkout@v4 - - - uses: actions/setup-node@v4 - with: - node-version: '18' - - # Build the library - - name: Install and Build - run: | - npm ci - npm run build - - # Push to public mirror repo - - name: Push Build to Public Mirror - env: - FORCE_UI_TOKEN: ${{ secrets.FORCE_UI_TOKEN }} - run: | - # Clone public mirror repo - git clone https://x-access-token:${{ secrets.FORCE_UI_TOKEN }}@github.com/brainstormforce/bsf-admin-ui.git build-repo - - cd build-repo - - # Clear old dist - rm -rf dist - - # Copy new build - cp -r ../dist ./ - - # Update version in package.json - VERSION=$(node -p "require('../package.json').version") - node -e " - const pkg = require('./package.json'); - pkg.version = process.argv[1]; - require('fs').writeFileSync('package.json', JSON.stringify(pkg, null, 2)); - " "$VERSION" - - # Commit and tag - git config user.name github-actions - git config user.email github-actions@github.com - git add dist package.json - git commit -m "Release v$VERSION - build artifacts only" - git tag v$VERSION - git push origin master - git push origin v$VERSION + publish-build: + runs-on: ubuntu-latest + + steps: + - uses: actions/checkout@v4 + + - uses: actions/setup-node@v4 + with: + node-version: '18' + + # Build the library + - name: Install and Build + run: | + npm ci + npm run build + + # Push to public mirror repo + - name: Push Build to Public Mirror + env: + FORCE_UI_TOKEN: ${{ secrets.FORCE_UI_TOKEN }} + run: | + # Clone public mirror repo + git clone https://x-access-token:${{ secrets.FORCE_UI_TOKEN }}@github.com/brainstormforce/bsf-admin-ui.git build-repo + + cd build-repo + + # Clear old dist + rm -rf dist + + # Copy new build + cp -r ../dist ./ + + # Update version in package.json + VERSION=$(node -p "require('../package.json').version") + node -e " + const pkg = require('./package.json'); + pkg.version = process.argv[1]; + require('fs').writeFileSync('package.json', JSON.stringify(pkg, null, 2)); + " "$VERSION" + + # Commit and tag + git config user.name github-actions + git config user.email github-actions@github.com + git add dist package.json + git commit -m "Release v$VERSION - build artifacts only" + git tag v$VERSION + git push origin master + git push origin v$VERSION diff --git a/.github/workflows/publish.yml b/.github/workflows/publish.yml index e287f670..90d8f344 100644 --- a/.github/workflows/publish.yml +++ b/.github/workflows/publish.yml @@ -1,28 +1,28 @@ name: Publish Package on: - push: - branches: - - master + push: + branches: + - master jobs: - publish: - runs-on: ubuntu-latest - permissions: - contents: read - packages: write - steps: - - uses: actions/checkout@v4 + publish: + runs-on: ubuntu-latest + permissions: + contents: read + packages: write + steps: + - uses: actions/checkout@v4 - - uses: actions/setup-node@v4 - with: - node-version: '18' - registry-url: 'https://npm.pkg.github.com' - scope: '@brainstormforce' + - uses: actions/setup-node@v4 + with: + node-version: '18' + registry-url: 'https://npm.pkg.github.com' + scope: '@brainstormforce' - - run: npm ci - - run: npm run build + - run: npm ci + - run: npm run build - - run: npm publish - env: - NODE_AUTH_TOKEN: ${{ secrets.GITHUB_TOKEN }} + - run: npm publish + env: + NODE_AUTH_TOKEN: ${{ secrets.GITHUB_TOKEN }} diff --git a/.storybook/main.ts b/.storybook/main.ts index d6e28d58..70bd54e6 100644 --- a/.storybook/main.ts +++ b/.storybook/main.ts @@ -1,5 +1,5 @@ // This file has been automatically migrated to valid ESM format by Storybook. -import { fileURLToPath } from "node:url"; +import { fileURLToPath } from 'node:url'; import type { StorybookConfig } from '@storybook/react-vite'; import path, { dirname } from 'path'; @@ -10,14 +10,14 @@ const __dirname = dirname(__filename); const config: StorybookConfig = { stories: ['../src/**/*.mdx', '../src/**/*.stories.@(js|jsx|mjs|ts|tsx)'], addons: [ - '@storybook/addon-onboarding', - '@storybook/addon-links', - '@chromatic-com/storybook', - '@storybook/addon-a11y', - '@storybook/addon-docs', - '@storybook/addon-mcp', - '@storybook/addon-vitest' - ], + '@storybook/addon-onboarding', + '@storybook/addon-links', + '@chromatic-com/storybook', + '@storybook/addon-a11y', + '@storybook/addon-docs', + '@storybook/addon-mcp', + '@storybook/addon-vitest', + ], framework: { name: '@storybook/react-vite', options: { diff --git a/README.md b/README.md index a06c1cc6..469feb66 100644 --- a/README.md +++ b/README.md @@ -14,7 +14,7 @@ Using Force UI as a dependency in package.json - ```json "dependencies": { - "@bsf/force-ui": "git+https://github.com/brainstormforce/force-ui#1.7.11" + "@bsf/force-ui": "git+https://github.com/brainstormforce/force-ui#1.7.12" } ``` @@ -28,7 +28,7 @@ npm install Or you can directly run the following command to install the package - ```bash -npm i -S @bsf/force-ui@git+https://github.com/brainstormforce/force-ui.git#1.7.11 +npm i -S @bsf/force-ui@git+https://github.com/brainstormforce/force-ui.git#1.7.12 ```
@@ -307,7 +307,7 @@ export default function Example() { Force UI provides an MCP server that gives AI assistants accurate component usage context correct props, patterns, and examples. So you get reliable implementations without guesswork. ```bash -npx mcp-add --type http --url "https://brainstormforce.github.io/force-ui/mcp" --scope project # use `global` instead of `project` for making it accessible globally +npx mcp-add --type http --url "https://forceui.brainstormforce.com/mcp" --scope project # use `global` instead of `project` for making it accessible globally ``` When prompted, use the following configuration: diff --git a/changelog.txt b/changelog.txt index 279c4b11..72c5b99a 100644 --- a/changelog.txt +++ b/changelog.txt @@ -1,3 +1,11 @@ +Version 1.7.12 - 10th June, 2026 +- Improvement: Atom - Textarea: Added `autoResize`, `minHeight`, and `maxHeight` props. When `autoResize` is enabled, the textarea height auto-adjusts to fit its content and stops growing at `maxHeight` (default 160px), at which point it becomes scrollable. `minHeight` and `maxHeight` apply as CSS constraints regardless of `autoResize`. +- Improvement: Organism - Line Chart: Added `seriesLabels` prop to map data keys to custom display names in the tooltip, useful for translated labels. Falls back to the data key when no label is provided. +- Improvement: Atom - DatePicker: Added opt-in `enableTimeSelection` prop that renders time inputs below the calendar grid for `single` and `range` selection types (ignored for `multiple`). The chosen time is merged into the selected dates and carried in the `onDateSelect`/`onApply` payloads. +- Fix: Organism - Editor Input: Added Shadow DOM support for the mention suggestions menu. +- Fix: Molecule - Accordion: Collapsed content children are unmounted again to prevent heavy panel content from rendering up front and re-rendering on every keystroke; the ARIA region element stays in the DOM so `aria-controls` and `aria-labelledby` still resolve. +- Fix: Organism - Editor Input: The mention typeahead anchor is now created lazily and appended to the DOM only when the menu opens, eliminating per-mount style recalculations and typing lag on pages with many editors. + Version 1.7.11 - 8th April, 2026 - New: Added Storybook MCP compatibility support for smoother integration with MCP-based tooling and workflows. - Improvement: Atom - Alert: Added `role="alert"` and improved focus-visible ring on the close button. diff --git a/component-data.json b/component-data.json deleted file mode 100644 index a703da1e..00000000 --- a/component-data.json +++ /dev/null @@ -1,3069 +0,0 @@ -{ - "components": { - "Accordion": { - "props": { - "className": { - "type": "string", - "required": false, - "description": "Custom class names for additional styling" - }, - "disabled": { - "type": "boolean", - "required": false, - "description": "Disables the component" - }, - "children": { - "type": "ReactNode", - "required": true, - "description": "Children components" - }, - "type": { - "type": "'simple' | 'separator' | 'boxed'", - "required": false, - "description": "Accordion type (same as parent)" - }, - "defaultValue": { - "type": "string | string[]", - "required": false, - "description": "Initial active item(s)" - }, - "autoClose": { - "type": "boolean", - "required": false, - "description": "Automatically close other items when one is opened" - }, - "isOpen": { - "type": "boolean", - "required": false, - "description": "Determines if the content is open" - }, - "onToggle": { - "type": "() => void", - "required": false, - "description": "Callback for toggling item state" - }, - "value": { - "type": "string", - "required": false, - "description": "The value associated with the accordion item" - }, - "onClick": { - "type": "() => void", - "required": false, - "description": "OnClick handler for the accordion trigger. This works only when collapsible is set to `false`." - }, - "iconType": { - "type": "'arrow' | 'plus-minus' | 'none'", - "required": false, - "description": "Type of icon to display" - }, - "tag": { - "type": "ElementType", - "required": false, - "description": "Element to render trigger as" - }, - "collapsible": { - "type": "boolean", - "required": false, - "description": "Specifies whether the accordion item can be collapsed." - } - }, - "subComponents": { - "Item": { - "props": { - "isOpen": { - "type": "boolean", - "required": false, - "description": "Determines if the item is open" - }, - "onToggle": { - "type": "() => void", - "required": false, - "description": "Callback to toggle the item's state" - }, - "type": { - "type": "'simple' | 'separator' | 'boxed'", - "required": false, - "description": "Accordion type (same as parent)" - }, - "value": { - "type": "string", - "required": false, - "description": "The value associated with the accordion item" - } - } - }, - "Trigger": { - "props": { - "onClick": { - "type": "() => void", - "required": false, - "description": "OnClick handler for the accordion trigger. This works only when collapsible is set to `false`." - }, - "onToggle": { - "type": "() => void", - "required": false, - "description": "Callback for toggling item state" - }, - "isOpen": { - "type": "boolean", - "required": false, - "description": "Indicates if the item is open" - }, - "iconType": { - "type": "'arrow' | 'plus-minus' | 'none'", - "required": false, - "description": "Type of icon to display" - }, - "tag": { - "type": "ElementType", - "required": false, - "description": "Element to render trigger as" - }, - "type": { - "type": "'simple' | 'separator' | 'boxed'", - "required": false, - "description": "Accordion type (same as parent)" - }, - "collapsible": { - "type": "boolean", - "required": false, - "description": "Specifies whether the accordion item can be collapsed." - } - } - }, - "Content": { - "props": { - "isOpen": { - "type": "boolean", - "required": false, - "description": "Determines if the content is open" - }, - "type": { - "type": "'simple' | 'separator' | 'boxed'", - "required": false, - "description": "Accordion type (same as parent)" - } - } - } - } - }, - "Alert": { - "props": { - "variant": { - "type": "'neutral' | 'info' | 'warning' | 'error' | 'success'", - "required": false, - "description": "Defines the style variant of the alert." - }, - "theme": { - "type": "'light' | 'dark'", - "required": false, - "description": "Defines the theme of the alert." - }, - "design": { - "type": "'inline' | 'stack'", - "required": false, - "description": "Defines the design of the alert." - }, - "title": { - "type": "React.ReactNode", - "required": false, - "description": "Defines the title of the alert." - }, - "content": { - "type": "React.ReactNode", - "required": false, - "description": "Defines the content of the alert." - }, - "className": { - "type": "string", - "required": false, - "description": "Defines the extra classes." - }, - "onClose": { - "type": "() => void", - "required": false, - "description": "Callback function for close event." - }, - "icon": { - "type": "React.ReactElement | null", - "required": false, - "description": "Custom Icon for the alert." - }, - "action": { - "type": "{", - "required": false, - "description": "Defines the action of the alert." - }, - "label": { - "type": "string", - "required": true, - "description": "" - }, - "onClick": { - "type": "( close: () => void ) => void", - "required": true, - "description": "" - }, - "type": { - "type": "'link' | 'button'", - "required": true, - "description": "" - } - }, - "subComponents": {} - }, - "AreaChart": { - "props": { - "data": { - "type": "DataItem[]", - "required": true, - "description": "An array of objects representing the source data for the chart." - }, - "dataKeys": { - "type": "string[]", - "required": true, - "description": "An array of strings representing the keys to access data in each data object. Used for identifying different data series." - }, - "colors": { - "type": "Color[]", - "required": false, - "description": "An array of color strings that determine the colors for each data series in the chart." - }, - "variant": { - "type": "'solid' | 'gradient'", - "required": false, - "description": "Defines the variant of Area Chart." - }, - "showXAxis": { - "type": "boolean", - "required": false, - "description": "Whether to render the `` component for the x-axis." - }, - "showYAxis": { - "type": "boolean", - "required": false, - "description": "Whether to render the `` component for the y-axis." - }, - "showTooltip": { - "type": "boolean", - "required": false, - "description": "Toggle the visibility of the tooltip on hover, displaying detailed information for each data point." - }, - "tooltipIndicator": { - "type": "'dot' | 'line' | 'dashed'", - "required": false, - "description": "The tooltip indicator. It can be `dot`, `line` or `dashed`." - }, - "tooltipLabelKey": { - "type": "string", - "required": false, - "description": "An array of objects representing the source data for the chart." - }, - "showLegend": { - "type": "boolean", - "required": false, - "description": "Whether to render the `` component to identify data series." - }, - "showCartesianGrid": { - "type": "boolean", - "required": false, - "description": "Whether to display the ``, adding horizontal and vertical grid lines." - }, - "xAxisTickFormatter": { - "type": "( value: string ) => string", - "required": false, - "description": "A function used to format the ticks on the x-axis, e.g., for formatting dates or numbers." - }, - "tickFormatter": { - "type": "( value: string ) => string", - "required": false, - "description": " A function used to format the ticks on the x-axis, e.g., for formatting dates or numbers. @deprecated Use `xAxisTickFormatter` instead. " - }, - "yAxisTickFormatter": { - "type": "( value: number ) => string", - "required": false, - "description": "A function used to format the ticks on the y-axis, e.g., for converting 1000 to 1K." - }, - "xAxisDataKey": { - "type": "string", - "required": false, - "description": "The key in the data objects representing values for the x-axis. This is used to access the x-axis values from each data entry." - }, - "yAxisDataKey": { - "type": "string", - "required": false, - "description": "The key in the data objects representing values for the y-axis. This is used to access the y-axis values from each data entry." - }, - "xAxisFontSize": { - "type": "'sm' | 'md' | 'lg'", - "required": false, - "description": "Font size for the labels on the x-axis." - }, - "xAxisFontColor": { - "type": "string", - "required": false, - "description": "Font color for the labels on the x-axis." - }, - "chartWidth": { - "type": "number", - "required": false, - "description": "Width of the chart container." - }, - "chartHeight": { - "type": "number", - "required": false, - "description": "Height of the chart container." - }, - "areaChartWrapperProps": { - "type": "Omit<", - "required": false, - "description": " Area chart Wrapper props to apply additional props to the wrapper component. Ex. `margin`, or `onClick` etc. @see https://recharts.org/en-US/api/AreaChart " - }, - "noDataComponent": { - "type": "ReactNode", - "required": false, - "description": " Custom component to display when no data is available. If not provided, a default \"No data available\" message will be displayed. " - } - }, - "subComponents": {} - }, - "Avatar": { - "props": { - "variant": { - "type": "'white' | 'gray' | 'primary' | 'primary-light' | 'dark'", - "required": false, - "description": "Defines the style variant of the avatar." - }, - "size": { - "type": "'xxs' | 'xs' | 'sm' | 'md' | 'lg'", - "required": false, - "description": "Defines the size of the avatar." - }, - "border": { - "type": "'none' | 'subtle' | 'ring'", - "required": false, - "description": "Defines the border of the avatar." - }, - "url": { - "type": "string", - "required": false, - "description": "The URL of the Avatar image" - }, - "children": { - "type": "ReactNode", - "required": false, - "description": "Defines the children of the avatar." - }, - "className": { - "type": "string", - "required": false, - "description": "Defines the extra classes" - }, - "src": { - "type": "string", - "required": false, - "description": "The URL of the Avatar image." - }, - "alt": { - "type": "string", - "required": false, - "description": "Alt text for the avatar image." - } - }, - "subComponents": {} - }, - "Badge": { - "props": { - "label": { - "type": "ReactNode", - "required": false, - "description": " Defines the Label of the badge. " - }, - "size": { - "type": "'xxs' | 'xs' | 'sm' | 'md' | 'lg'", - "required": false, - "description": " Defines the size of the badge. " - }, - "className": { - "type": "string", - "required": false, - "description": " Defines the extra classes " - }, - "type": { - "type": "'pill' | 'rounded'", - "required": false, - "description": " Defines the type of the badge. " - }, - "variant": { - "type": "'neutral' | 'red' | 'yellow' | 'green' | 'blue' | 'inverse'", - "required": false, - "description": " Defines the style variant of the badge. " - }, - "icon": { - "type": "ReactNode", - "required": false, - "description": " Custom Icon for the badge. " - }, - "disableHover": { - "type": "boolean", - "required": false, - "description": " Disable hover effect. @default false " - }, - "disabled": { - "type": "boolean", - "required": false, - "description": " Defines if the badge is disabled. " - }, - "onClose": { - "type": "( event: React.MouseEvent ) => void", - "required": false, - "description": " Callback function for close event " - }, - "closable": { - "type": "boolean", - "required": false, - "description": " Defines if the badge is closable. " - }, - "onMouseDown": { - "type": "() => void", - "required": false, - "description": " Callback function for mouse down event. " - } - }, - "subComponents": {} - }, - "BarChart": { - "props": { - "data": { - "type": "DataItem[]", - "required": true, - "description": "An array of objects representing the source data for the chart." - }, - "dataKeys": { - "type": "string[]", - "required": true, - "description": "An array of strings representing the keys to access data in each data object. Used for identifying different data series." - }, - "colors": { - "type": "Color[]", - "required": false, - "description": "An array of color strings that determine the colors for each data series in the chart." - }, - "layout": { - "type": "'horizontal' | 'vertical'", - "required": false, - "description": "Defines the layout of Bar Chart. if you want to check how layout `vertical` works, then you need to clear the xAxisDataKey value and set showCartesianGrid to false." - }, - "stacked": { - "type": "boolean", - "required": false, - "description": "Defines are the chart bars are stacked." - }, - "showXAxis": { - "type": "boolean", - "required": false, - "description": "Whether to render the `` component for the x-axis." - }, - "showYAxis": { - "type": "boolean", - "required": false, - "description": "Whether to render the `` component for the y-axis." - }, - "showTooltip": { - "type": "boolean", - "required": false, - "description": "Toggle the visibility of the tooltip on hover, displaying detailed information for each data point." - }, - "tooltipIndicator": { - "type": "'dot' | 'line' | 'dashed'", - "required": false, - "description": "The tooltip indicator. It can be `dot`, `line` or `dashed`." - } - }, - "subComponents": {} - }, - "Breadcrumb": { - "props": { - "children": { - "type": "ReactNode", - "required": true, - "description": "Defines the children of the breadcrumb." - }, - "size": { - "type": "'sm' | 'md'", - "required": false, - "description": "Defines the size of the breadcrumb." - }, - "href": { - "type": "string", - "required": true, - "description": "Defines the href of the link." - }, - "className": { - "type": "string", - "required": false, - "description": "Defines the class name of the link." - }, - "as": { - "type": "ElementType", - "required": false, - "description": "Defines the element type of the link." - }, - "type": { - "type": "'arrow' | 'slash'", - "required": true, - "description": " Defines the type of separator. Available options: - arrow - slash " - } - }, - "subComponents": { - "List": { - "props": {} - }, - "Item": { - "props": {} - }, - "Link": { - "props": { - "href": { - "type": "string", - "required": true, - "description": "Defines the href of the link." - }, - "className": { - "type": "string", - "required": false, - "description": "Defines the class name of the link." - }, - "as": { - "type": "ElementType", - "required": false, - "description": "Defines the element type of the link." - } - } - }, - "Separator": { - "props": { - "type": { - "type": "'arrow' | 'slash'", - "required": true, - "description": " Defines the type of separator. Available options: - arrow - slash " - } - } - }, - "Ellipsis": { - "props": {} - }, - "Page": { - "props": {} - } - } - }, - "Button": { - "props": { - "variant": { - "type": "'primary' | 'secondary' | 'outline' | 'ghost' | 'link'", - "required": false, - "description": " Defines the style variant of the button. " - }, - "size": { - "type": "'xs' | 'sm' | 'md' | 'lg'", - "required": false, - "description": " Defines the size of the button. " - }, - "type": { - "type": "'button' | 'submit' | 'reset'", - "required": false, - "description": " Defines the type of the button. " - }, - "tag": { - "type": "ElementType", - "required": false, - "description": " Defines the tag of the button. " - }, - "className": { - "type": "string", - "required": false, - "description": " The class name of the button " - }, - "children": { - "type": "ReactNode", - "required": false, - "description": " The children of the button " - }, - "disabled": { - "type": "boolean", - "required": false, - "description": " Defines if the button is disabled. " - }, - "destructive": { - "type": "boolean", - "required": false, - "description": " Defines if the button is destructive. " - }, - "icon": { - "type": "ReactNode", - "required": false, - "description": " Custom Icon for the button. " - }, - "iconPosition": { - "type": "'left' | 'right'", - "required": false, - "description": " Defines the position of the icon. " - }, - "loading": { - "type": "boolean", - "required": false, - "description": " Defines if the button is loading. " - }, - "onClick": { - "type": "( event: React.MouseEvent ) => void", - "required": false, - "description": "On click event." - } - }, - "subComponents": {} - }, - "ButtonGroup": { - "props": { - "className": { - "type": "string", - "required": false, - "description": "Additional class names for styling." - }, - "children": { - "type": "ReactNode", - "required": true, - "description": "Child elements, typically Button components." - }, - "activeItem": { - "type": "string | null", - "required": false, - "description": "Active item slug in the group." - }, - "onChange": { - "type": "( value: ButtonValue ) => void", - "required": false, - "description": "Callback when the active item changes." - }, - "size": { - "type": "'xs' | 'sm' | 'md'", - "required": false, - "description": "Size of the buttons in the group." - }, - "iconPosition": { - "type": "'left' | 'right'", - "required": false, - "description": "Position of the icon inside the button." - }, - "slug": { - "type": "string", - "required": true, - "description": "Unique slug identifying the button." - }, - "text": { - "type": "string", - "required": true, - "description": "Text content of the button." - }, - "icon": { - "type": "ReactElement", - "required": false, - "description": "Icon displayed inside the button." - }, - "disabled": { - "type": "boolean", - "required": false, - "description": "Marks the button as disabled." - }, - "isFirstChild": { - "type": "boolean", - "required": false, - "description": "Indicates if the button is the first child in the group." - }, - "isLastChild": { - "type": "boolean", - "required": false, - "description": "Indicates if the button is the last child in the group." - } - }, - "subComponents": {} - }, - "Checkbox": { - "props": {}, - "subComponents": {} - }, - "Container": { - "props": { - "containerType": { - "type": "TContainerType", - "required": false, - "description": "Defines the type of the container (default: 'flex')." - }, - "cols": { - "type": "TCols", - "required": true, - "description": "" - }, - "className": { - "type": "string", - "required": false, - "description": "Defines any additional CSS classes for the container." - }, - "children": { - "type": "ReactNode", - "required": false, - "description": "Defines the children of the container." - } - }, - "subComponents": { - "Item": { - "props": { - "containerType": { - "type": "TContainerType", - "required": true, - "description": "" - }, - "cols": { - "type": "TCols", - "required": true, - "description": "" - } - } - } - } - }, - "Dialog": { - "props": { - "className": { - "type": "string", - "required": false, - "description": "Additional class name for the dialog close button." - }, - "style": { - "type": "React.CSSProperties", - "required": false, - "description": "Additional inline styles." - }, - "open": { - "type": "boolean", - "required": false, - "description": "Control the dialog open state. If not provided, the dialog will be controlled internally." - }, - "setOpen": { - "type": "( open: boolean ) => void", - "required": false, - "description": "Control the dialog open state. If not provided, the dialog will be controlled internally." - }, - "children": { - "type": "ReactNode | ( ( props: { close: () => void", - "required": false, - "description": "Children of the dialog footer." - }, - "id": { - "type": "string", - "required": false, - "description": "Id of the dialog portal where the element will be rendered. If not provided, the dialog will be rendered in the body." - }, - "root": { - "type": "HTMLElement", - "required": false, - "description": "Root element of the dialog portal. If not provided, the dialog will be rendered in the body." - }, - "as": { - "type": "ElementType", - "required": false, - "description": "Additional class name for the dialog close button." - }, - "onClick": { - "type": "() => void", - "required": false, - "description": "On click event for the close button." - } - }, - "subComponents": { - "Panel": { - "props": { - "children": { - "type": "ReactNode | ( ( param: { close: () => void", - "required": true, - "description": "Children of the dialog panel." - } - } - }, - "Portal": { - "props": { - "children": { - "type": "ReactNode", - "required": true, - "description": "Children of the dialog portal." - }, - "id": { - "type": "string", - "required": false, - "description": "Id of the dialog portal where the element will be rendered. If not provided, the dialog will be rendered in the body." - }, - "root": { - "type": "HTMLElement", - "required": false, - "description": "Root element of the dialog portal. If not provided, the dialog will be rendered in the body." - } - } - }, - "Title": { - "props": {} - }, - "Description": { - "props": {} - }, - "CloseButton": { - "props": { - "children": { - "type": "ReactNode", - "required": false, - "description": "Children of the dialog close button." - }, - "as": { - "type": "ElementType", - "required": false, - "description": "Additional class name for the dialog close button." - }, - "className": { - "type": "string", - "required": false, - "description": "Additional class name for the dialog close button." - }, - "onClick": { - "type": "() => void", - "required": false, - "description": "On click event for the close button." - } - } - }, - "Header": { - "props": { - "children": { - "type": "ReactNode", - "required": true, - "description": "Children of the dialog header." - } - } - }, - "Body": { - "props": { - "children": { - "type": "ReactNode", - "required": true, - "description": "Children of the dialog body." - } - } - }, - "Footer": { - "props": { - "children": { - "type": "ReactNode | ( ( props: { close: () => void", - "required": false, - "description": "Children of the dialog footer." - } - } - }, - "Backdrop": { - "props": {} - } - } - }, - "Drawer": { - "props": { - "open": { - "type": "boolean", - "required": false, - "description": "Open state of the drawer. Optional for uncontrolled component." - }, - "setOpen": { - "type": "( open: boolean ) => void", - "required": false, - "description": "Set open state of the drawer. Optional for uncontrolled component." - }, - "children": { - "type": "ReactNode", - "required": true, - "description": "Drawer content." - }, - "trigger": { - "type": "ReactNode | ( ( props: { onClick: () => void", - "required": false, - "description": "Trigger element to open the drawer. Required for uncontrolled component." - } - }, - "subComponents": { - "Panel": { - "props": { - "children": { - "type": "ReactNode | ( ( props: { close: () => void", - "required": true, - "description": "Drawer content." - } - } - }, - "Header": { - "props": { - "children": { - "type": "ReactNode", - "required": true, - "description": "Header content." - }, - "className": { - "type": "string", - "required": false, - "description": "Additional class names." - } - } - }, - "Title": { - "props": { - "children": { - "type": "ReactNode", - "required": true, - "description": "Title content." - }, - "as": { - "type": "ElementType", - "required": false, - "description": "HTML element to render." - }, - "className": { - "type": "string", - "required": false, - "description": "Additional class names." - } - } - }, - "Description": { - "props": { - "as": { - "type": "ElementType", - "required": false, - "description": "Description tag." - }, - "children": { - "type": "ReactNode", - "required": true, - "description": "Description content." - }, - "className": { - "type": "string", - "required": false, - "description": "Additional class names." - } - } - }, - "Body": { - "props": { - "children": { - "type": "ReactNode", - "required": true, - "description": "Body content." - }, - "className": { - "type": "string", - "required": false, - "description": "Additional class names." - } - } - }, - "CloseButton": { - "props": { - "className": { - "type": "string", - "required": false, - "description": "Additional class names." - }, - "onClick": { - "type": "() => void", - "required": true, - "description": "Click handler." - }, - "children": { - "type": "ReactNode | ( ( { close", - "required": false, - "description": "Button content." - } - } - }, - "Footer": { - "props": { - "children": { - "type": "ReactNode | ( ( { close", - "required": true, - "description": "Footer content." - } - } - }, - "Backdrop": { - "props": { - "className": { - "type": "string", - "required": false, - "description": "Additional class names." - } - } - }, - "Portal": { - "props": {} - } - } - }, - "DropdownMenu": { - "props": {}, - "subComponents": { - "Trigger": { - "props": {} - }, - "Content": { - "props": {} - }, - "List": { - "props": {} - }, - "Item": { - "props": {} - }, - "Separator": { - "props": {} - }, - "Portal": { - "props": {} - }, - "ContentWrapper": { - "props": {} - } - } - }, - "Dropzone": { - "props": { - "onFileUpload": { - "type": "( file: File ) => void", - "required": false, - "description": "Callback function when a file is uploaded" - }, - "inlineIcon": { - "type": "boolean", - "required": false, - "description": "Determines if the icon should be inline" - }, - "label": { - "type": "string", - "required": false, - "description": "Label for the dropzone" - }, - "helpText": { - "type": "string", - "required": false, - "description": "Help text for the dropzone" - }, - "size": { - "type": "'sm' | 'md' | 'lg'", - "required": false, - "description": "Size variant of the dropzone" - }, - "disabled": { - "type": "boolean", - "required": false, - "description": "Indicates if the component is disabled" - }, - "error": { - "type": "boolean", - "required": false, - "description": "Indicates if the component is in error state" - }, - "errorText": { - "type": "string", - "required": false, - "description": "Error text to display" - }, - "className": { - "type": "string", - "required": false, - "description": "Custom class name for the dropzone" - }, - "wrapperClassName": { - "type": "string", - "required": false, - "description": "Custom class name for the wrapper" - } - }, - "subComponents": {} - }, - "EditorInput": { - "props": { - "defaultValue": { - "type": "string", - "required": false, - "description": "Default value for the editor input field." - }, - "placeholder": { - "type": "string", - "required": false, - "description": "Placeholder text for the editor input field." - }, - "size": { - "type": "keyof typeof editorInputClassNames", - "required": false, - "description": "Defines the sizes of the editor input." - }, - "autoFocus": { - "type": "boolean", - "required": false, - "description": "Defines if the editor input is focused automatically." - }, - "options": { - "type": "T[]", - "required": true, - "description": "Array of options to be displayed in the editor input. Each option should be an object or string." - }, - "trigger": { - "type": "string", - "required": false, - "description": "The trigger to be used to show the mention options." - }, - "menuComponent": { - "type": "TMenuComponent", - "required": false, - "description": "The component to be used for the mention menu." - }, - "menuItemComponent": { - "type": "TMenuItemComponent", - "required": false, - "description": "The component to be used for the mention menu items." - }, - "className": { - "type": "string", - "required": false, - "description": "Additional class names to be added to the editor input." - }, - "wrapperClassName": { - "type": "string", - "required": false, - "description": "Additional class names to be added to the editor input wrapper." - }, - "disabled": { - "type": "boolean", - "required": false, - "description": "Defines if the editor input is disabled." - }, - "autoSpaceAfterMention": { - "type": "boolean", - "required": false, - "description": "Defines if the editor input should add a space after selecting a mention/tag option." - }, - "style": { - "type": "React.CSSProperties", - "required": false, - "description": " Override the default styles of the editor input. This prop allows you to apply custom styles using a React.CSSProperties object. Note that the editor utilizes inline styles, so to effectively override existing styles, you must provide the desired styles through this `style` prop. " - }, - "maxLength": { - "type": "number", - "required": false, - "description": "Defines the maximum character limit of the editor input." - } - }, - "subComponents": {} - }, - "FilePreview": { - "props": { - "file": { - "type": "FilePreviewFile", - "required": true, - "description": "The file to display. It can be a File object or an object with name, url, type, and size properties." - }, - "onRemove": { - "type": "( selectedFile: FilePreviewFile ) => void", - "required": true, - "description": "Function called when the file is removed. The parameter is the selected file object, which can be a File object or an object with name, url, type, and size properties or null." - }, - "disabled": { - "type": "boolean", - "required": false, - "description": "Indicates whether the file preview is disabled." - }, - "size": { - "type": "'sm' | 'md' | 'lg'", - "required": false, - "description": "The size of the file preview." - }, - "error": { - "type": "boolean", - "required": false, - "description": "Indicates whether the file preview has an error." - } - }, - "subComponents": {} - }, - "HamburgerMenu": { - "props": { - "className": { - "type": "string", - "required": false, - "description": " Additional class name for styling. " - }, - "children": { - "type": "ReactNode", - "required": false, - "description": " Children elements. " - }, - "tag": { - "type": "T", - "required": false, - "description": " The tag or component to render the option as. " - }, - "active": { - "type": "boolean", - "required": false, - "description": " Whether the option is active. " - }, - "icon": { - "type": "React.ReactElement", - "required": false, - "description": " Icon component to display. " - }, - "iconPosition": { - "type": "'left' | 'right'", - "required": false, - "description": " Position of the icon. " - }, - "variants": { - "type": "{", - "required": true, - "description": "" - } - }, - "subComponents": { - "Options": { - "props": { - "children": { - "type": "React.ReactNode", - "required": true, - "description": " The children to render in the menu options. " - }, - "className": { - "type": "string", - "required": false, - "description": " The class name to apply to the menu options container. " - } - } - }, - "Option": { - "props": { - "tag": { - "type": "T", - "required": false, - "description": " The tag or component to render the option as. " - }, - "active": { - "type": "boolean", - "required": false, - "description": " Whether the option is active. " - }, - "icon": { - "type": "React.ReactElement", - "required": false, - "description": " Icon component to display. " - }, - "iconPosition": { - "type": "'left' | 'right'", - "required": false, - "description": " Position of the icon. " - }, - "className": { - "type": "string", - "required": false, - "description": " Additional class name for styling. " - }, - "children": { - "type": "ReactNode", - "required": false, - "description": " Children elements. " - } - } - }, - "Toggle": { - "props": { - "className": { - "type": "string", - "required": false, - "description": " The class name to apply to the hamburger menu toggle button. " - } - } - } - } - }, - "Input": { - "props": { - "id": { - "type": "string", - "required": false, - "description": "Unique identifier for the input element." - }, - "type": { - "type": "'text' | 'password' | 'email' | 'file'", - "required": false, - "description": "Specifies the type of the input element (e.g., text, file)." - }, - "defaultValue": { - "type": "string", - "required": false, - "description": "Initial value of the input element." - }, - "value": { - "type": "string", - "required": false, - "description": "Controlled value of the input element." - }, - "size": { - "type": "'sm' | 'md' | 'lg'", - "required": false, - "description": "Defines the size of the input (e.g., 'sm', 'md', 'lg')." - }, - "className": { - "type": "string", - "required": false, - "description": "Additional custom classes for styling." - }, - "disabled": { - "type": "boolean", - "required": false, - "description": "Disables the input element when true." - }, - "onChange": { - "type": "( value: string | FileList | null ) => void", - "required": false, - "description": "Function called when the input value changes." - }, - "error": { - "type": "boolean", - "required": false, - "description": "Indicates whether the input has an error state." - }, - "onError": { - "type": "() => void", - "required": false, - "description": "Function called when the input encounters an error." - }, - "prefix": { - "type": "ReactNode", - "required": false, - "description": "React node displayed as a prefix inside the input." - }, - "suffix": { - "type": "ReactNode", - "required": false, - "description": "React node displayed as a suffix inside the input." - }, - "label": { - "type": "string", - "required": false, - "description": "Label displayed above the input field." - }, - "placeholder": { - "type": "string", - "required": false, - "description": "Placeholder text for the input field." - }, - "required": { - "type": "boolean", - "required": false, - "description": "Indicates whether the input is required." - } - }, - "subComponents": {} - }, - "Label": { - "props": { - "children": { - "type": "ReactNode", - "required": true, - "description": "The content of the label." - }, - "tag": { - "type": "string | ElementType", - "required": false, - "description": "Defines the HTML tag to use for the label." - }, - "size": { - "type": "'xs' | 'sm' | 'md'", - "required": false, - "description": "Defines the size of the label." - }, - "className": { - "type": "string", - "required": false, - "description": "Defines the extra classes." - }, - "variant": { - "type": "'neutral' | 'help' | 'error' | 'disabled'", - "required": false, - "description": "Defines the style variant of the label." - }, - "required": { - "type": "boolean", - "required": false, - "description": "Defines if the label is required." - } - }, - "subComponents": {} - }, - "LineChart": { - "props": { - "data": { - "type": "DataItem[]", - "required": true, - "description": "An array of objects representing the source data for the chart." - }, - "dataKeys": { - "type": "string[]", - "required": true, - "description": "An array of strings representing the keys to access data in each data object. Used for identifying different data series." - }, - "colors": { - "type": "Color[]", - "required": false, - "description": "An array of color objects that determine the stroke colors for each data series in the chart." - }, - "showXAxis": { - "type": "boolean", - "required": false, - "description": "Whether to render the `` component for the x-axis." - }, - "showYAxis": { - "type": "boolean", - "required": false, - "description": "Whether to render the `` component for the y-axis." - }, - "showTooltip": { - "type": "boolean", - "required": false, - "description": "Toggle the visibility of the tooltip on hover, displaying detailed information for each data point." - }, - "tooltipIndicator": { - "type": "'dot' | 'line' | 'dashed'", - "required": false, - "description": "The tooltip indicator. It can be `dot`, `line`, or `dashed`." - }, - "tooltipLabelKey": { - "type": "string", - "required": false, - "description": "The key to use for the tooltip label." - }, - "showCartesianGrid": { - "type": "boolean", - "required": false, - "description": "Whether to display the ``, adding horizontal and vertical grid lines." - }, - "xAxisTickFormatter": { - "type": "( value: string ) => string", - "required": false, - "description": "A function used to format the ticks on the x-axis, e.g., for formatting dates or numbers." - }, - "tickFormatter": { - "type": "( value: string ) => string", - "required": false, - "description": " A function used to format the ticks on the x-axis, e.g., for formatting dates or numbers. @deprecated Use `xAxisTickFormatter` instead. " - }, - "yAxisTickFormatter": { - "type": "( value: number ) => string", - "required": false, - "description": "A function used to format the ticks on the y-axis, e.g., for converting 1000 to 1K." - }, - "xAxisDataKey": { - "type": "string", - "required": false, - "description": "The key in the data objects representing values for the x-axis." - }, - "yAxisDataKey": { - "type": "string", - "required": false, - "description": "The key in the data objects representing values for the y-axis." - }, - "xAxisFontSize": { - "type": "'sm' | 'md' | 'lg'", - "required": false, - "description": "Font size for the labels on the x-axis." - }, - "xAxisFontColor": { - "type": "string", - "required": false, - "description": "Font color for the labels on the x-axis." - }, - "yAxisFontColor": { - "type": "string | string[]", - "required": false, - "description": " Font color for the labels on the y-axis. When biaxial is true, you can provide an array of two colors [leftAxisColor, rightAxisColor]. If a single color is provided, it will be used for both axes. " - }, - "chartWidth": { - "type": "number | string", - "required": false, - "description": "Width of the chart container." - }, - "chartHeight": { - "type": "number | string", - "required": false, - "description": "Height of the chart container." - }, - "withDots": { - "type": "boolean", - "required": false, - "description": "Determines whether dots are shown on each data point." - }, - "lineChartWrapperProps": { - "type": "Omit<", - "required": false, - "description": " Line chart Wrapper props to apply additional props to the wrapper component. Ex. `margin`, or `onClick` etc. @see https://recharts.org/en-US/api/LineChart " - }, - "strokeDasharray": { - "type": "string", - "required": false, - "description": " The stroke dasharray for the Cartesian grid. @default '3 3' @see https://recharts.org/en-US/api/CartesianGrid " - }, - "gridColor": { - "type": "string", - "required": false, - "description": " The color of the Cartesian grid lines. @default '#E5E7EB' " - }, - "biaxial": { - "type": "boolean", - "required": false, - "description": " Biaxial chart. " - }, - "noDataComponent": { - "type": "ReactNode", - "required": false, - "description": " Custom component to display when no data is available. If not provided, a default \"No data available\" message will be displayed. " - } - }, - "subComponents": {} - }, - "Loader": { - "props": { - "variant": { - "type": "'primary' | 'secondary'", - "required": false, - "description": "Defines the variant of the loader. Options are 'primary' or 'secondary'." - }, - "size": { - "type": "'sm' | 'md' | 'lg' | 'xl'", - "required": false, - "description": "Defines the size of the loader. Options are 'sm', 'md', 'lg', or 'xl'." - }, - "icon": { - "type": "ReactNode", - "required": false, - "description": "Optional icon to display instead of the default loader icon." - }, - "className": { - "type": "string", - "required": false, - "description": "Additional custom classes for styling." - } - }, - "subComponents": {} - }, - "Pagination": { - "props": { - "children": { - "type": "ReactNode", - "required": false, - "description": "Defines the children of the pagination component." - }, - "className": { - "type": "string", - "required": false, - "description": "Additional CSS classes." - }, - "size": { - "type": "PaginationSize", - "required": false, - "description": "Defines the size of pagination items." - }, - "disabled": { - "type": "boolean", - "required": false, - "description": "Disables the button." - }, - "isActive": { - "type": "boolean", - "required": false, - "description": "Marks the button as active." - }, - "onClick": { - "type": "React.MouseEventHandler", - "required": false, - "description": "Optional click handler for the button." - }, - "tag": { - "type": "'a' | 'button'", - "required": false, - "description": "The HTML tag to be rendered for the pagination button." - } - }, - "subComponents": { - "Content": { - "props": {} - }, - "Item": { - "props": { - "isActive": { - "type": "boolean", - "required": false, - "description": "Marks the pagination item as active." - } - } - }, - "Previous": { - "props": {} - }, - "Next": { - "props": {} - }, - "Ellipsis": { - "props": {} - } - } - }, - "PieChart": { - "props": { - "data": { - "type": "DataItem[]", - "required": true, - "description": "An array of objects representing the source data for the chart." - }, - "dataKey": { - "type": "string", - "required": true, - "description": "A string which representing the key to access data in each data object. Used for identifying different data series." - }, - "type": { - "type": "'simple' | 'donut'", - "required": false, - "description": "Type of pie chart. It can be `simple` or `donut`" - }, - "showTooltip": { - "type": "boolean", - "required": false, - "description": "Toggle the visibility of the tooltip on hover, displaying detailed information for each data point." - }, - "tooltipIndicator": { - "type": "'dot' | 'line' | 'dashed'", - "required": false, - "description": "The tooltip indicator. It can be `dot`, `line`, or `dashed`." - }, - "tooltipLabelKey": { - "type": "string", - "required": false, - "description": "The key to use for the tooltip label." - }, - "label": { - "type": "boolean", - "required": false, - "description": "When is true it show the label inside `donut` pie chart" - }, - "labelName": { - "type": "string", - "required": false, - "description": "Label name which will be displayed inside donut pie chart." - }, - "labelNameColor": { - "type": "string", - "required": false, - "description": "Label name color which will be displayed inside donut pie chart." - }, - "labelValue": { - "type": "number | string", - "required": false, - "description": "Label value which will be displayed inside donut pie chart." - }, - "showLegend": { - "type": "boolean", - "required": false, - "description": "Whether to render the `` component to identify data series." - }, - "chartWidth": { - "type": "number", - "required": false, - "description": "Width of the chart container." - }, - "pieOuterRadius": { - "type": "number", - "required": false, - "description": "Outer radius of the pie chart." - }, - "pieInnerRadius": { - "type": "number", - "required": false, - "description": "Inner radius of the pie chart." - } - }, - "subComponents": {} - }, - "ProgressBar": { - "props": { - "progress": { - "type": "number", - "required": false, - "description": "Current progress value (0 to 100)." - }, - "speed": { - "type": "number", - "required": false, - "description": "Speed of the progress transition in milliseconds." - }, - "className": { - "type": "string", - "required": false, - "description": "Additional custom classes for styling." - } - }, - "subComponents": {} - }, - "ProgressSteps": { - "props": { - "children": { - "type": "ReactNode", - "required": true, - "description": "Defines the children of the progress steps." - }, - "className": { - "type": "string", - "required": false, - "description": "Defines the class name for the component." - }, - "variant": { - "type": "'dot' | 'number' | 'icon'", - "required": false, - "description": "Specifies the variant style: 'dot', 'number', or 'icon'." - }, - "size": { - "type": "'sm' | 'md' | 'lg'", - "required": true, - "description": "Defines the size of the step: 'sm', 'md', or 'lg'." - }, - "type": { - "type": "'inline' | 'stack'", - "required": false, - "description": "Defines the layout type: 'inline' or 'stack'." - }, - "currentStep": { - "type": "number", - "required": false, - "description": "Defines the current step number. `-1` keeps all steps completed." - }, - "lineClassName": { - "type": "string", - "required": false, - "description": "Additional class names for the connecting line." - }, - "completedVariant": { - "type": "CompletedVariant", - "required": false, - "description": "How to display completed steps" - }, - "completedIcon": { - "type": "ReactNode", - "required": false, - "description": "Custom icon for completed steps" - }, - "labelText": { - "type": "string", - "required": false, - "description": "Text label for the step." - }, - "icon": { - "type": "ReactNode", - "required": false, - "description": "Custom icon for the step." - }, - "isCurrent": { - "type": "boolean", - "required": false, - "description": "Indicates if this step is currently active." - }, - "isCompleted": { - "type": "boolean", - "required": false, - "description": "Indicates if this step has been completed." - }, - "sizeClasses": { - "type": "StepSizeClasses", - "required": false, - "description": "Size-specific CSS classes for the step." - }, - "isLast": { - "type": "boolean", - "required": false, - "description": "Indicates if this step is the last in the sequence." - }, - "index": { - "type": "number", - "required": false, - "description": "The index of the step in the sequence." - } - }, - "subComponents": { - "Step": { - "props": { - "variant": { - "type": "'dot' | 'number' | 'icon'", - "required": false, - "description": "Specifies the variant style: 'dot', 'number', or 'icon'." - }, - "size": { - "type": "'sm' | 'md' | 'lg'", - "required": true, - "description": "Defines the size of the step: 'sm', 'md', or 'lg'." - }, - "type": { - "type": "'inline' | 'stack'", - "required": false, - "description": "Defines the layout type: 'inline' or 'stack'." - }, - "currentStep": { - "type": "number", - "required": false, - "description": "Defines the current step number. `-1` keeps all steps completed." - }, - "lineClassName": { - "type": "string", - "required": false, - "description": "Additional class names for the connecting line." - }, - "completedVariant": { - "type": "CompletedVariant", - "required": false, - "description": "How to display completed steps" - }, - "completedIcon": { - "type": "ReactNode", - "required": false, - "description": "Custom icon for completed steps" - }, - "labelText": { - "type": "string", - "required": false, - "description": "Text label for the step." - }, - "icon": { - "type": "ReactNode", - "required": false, - "description": "Custom icon for the step." - }, - "isCurrent": { - "type": "boolean", - "required": false, - "description": "Indicates if this step is currently active." - }, - "isCompleted": { - "type": "boolean", - "required": false, - "description": "Indicates if this step has been completed." - }, - "sizeClasses": { - "type": "StepSizeClasses", - "required": false, - "description": "Size-specific CSS classes for the step." - }, - "isLast": { - "type": "boolean", - "required": false, - "description": "Indicates if this step is the last in the sequence." - }, - "index": { - "type": "number", - "required": false, - "description": "The index of the step in the sequence." - } - } - } - } - }, - "RadioButton": { - "props": { - "className": { - "type": "string", - "required": false, - "description": "Custom class names for additional styling" - }, - "as": { - "type": "ElementType", - "required": false, - "description": "HTML element or React component to render the element as" - }, - "children": { - "type": "ReactNode", - "required": true, - "description": "" - }, - "disabled": { - "type": "boolean", - "required": false, - "description": "" - }, - "name": { - "type": "string", - "required": false, - "description": "Name used for form submission" - }, - "style": { - "type": "'simple' | 'tile'", - "required": false, - "description": "Style of the radio button group: 'simple' or 'tile'" - }, - "size": { - "type": "'sm' | 'md'", - "required": false, - "description": "Size of the radio buttons: 'sm' or 'md'" - }, - "value": { - "type": "string | string[]", - "required": false, - "description": "Controlled value of the group" - }, - "defaultValue": { - "type": "string | string[]", - "required": false, - "description": "Default value if the group is uncontrolled" - }, - "by": { - "type": "string", - "required": false, - "description": "Attribute to compare selected values, typically 'id'" - }, - "onChange": { - "type": "( value: string | string[] ) => void", - "required": false, - "description": "Handler invoked on value change" - }, - "disableGroup": { - "type": "boolean", - "required": false, - "description": "Disables all radio buttons in the group" - }, - "vertical": { - "type": "boolean", - "required": false, - "description": "Arranges the radio buttons vertically" - }, - "columns": { - "type": "number", - "required": false, - "description": "Number of columns for arranging the buttons" - }, - "multiSelection": { - "type": "boolean", - "required": false, - "description": "Enables multi-selection mode" - }, - "gapClassName": { - "type": "string", - "required": false, - "description": "Gap between radio buttons" - }, - "id": { - "type": "string", - "required": false, - "description": "Unique identifier for the radio button" - } - }, - "subComponents": { - "Group": { - "props": { - "name": { - "type": "string", - "required": false, - "description": "Name used for form submission" - }, - "style": { - "type": "'simple' | 'tile'", - "required": false, - "description": "Style of the radio button group: 'simple' or 'tile'" - }, - "size": { - "type": "'sm' | 'md'", - "required": false, - "description": "Size of the radio buttons: 'sm' or 'md'" - }, - "value": { - "type": "string | string[]", - "required": false, - "description": "Controlled value of the group" - }, - "defaultValue": { - "type": "string | string[]", - "required": false, - "description": "Default value if the group is uncontrolled" - }, - "by": { - "type": "string", - "required": false, - "description": "Attribute to compare selected values, typically 'id'" - }, - "onChange": { - "type": "( value: string | string[] ) => void", - "required": false, - "description": "Handler invoked on value change" - }, - "disableGroup": { - "type": "boolean", - "required": false, - "description": "Disables all radio buttons in the group" - }, - "vertical": { - "type": "boolean", - "required": false, - "description": "Arranges the radio buttons vertically" - }, - "columns": { - "type": "number", - "required": false, - "description": "Number of columns for arranging the buttons" - }, - "multiSelection": { - "type": "boolean", - "required": false, - "description": "Enables multi-selection mode" - }, - "gapClassName": { - "type": "string", - "required": false, - "description": "Gap between radio buttons" - }, - "id": { - "type": "string", - "required": false, - "description": "" - }, - "children": { - "type": "ReactNode", - "required": true, - "description": "" - }, - "disabled": { - "type": "boolean", - "required": false, - "description": "" - } - } - }, - "Button": { - "props": { - "className": { - "type": "string", - "required": false, - "description": "Custom class names for additional styling" - }, - "as": { - "type": "ElementType", - "required": false, - "description": "HTML element or React component to render the element as" - }, - "children": { - "type": "ReactNode", - "required": true, - "description": "" - }, - "disabled": { - "type": "boolean", - "required": false, - "description": "" - }, - "name": { - "type": "string", - "required": false, - "description": "Name used for form submission" - }, - "style": { - "type": "'simple' | 'tile'", - "required": false, - "description": "Style of the radio button group: 'simple' or 'tile'" - }, - "size": { - "type": "'sm' | 'md'", - "required": false, - "description": "" - }, - "value": { - "type": "string", - "required": true, - "description": "" - }, - "defaultValue": { - "type": "string | string[]", - "required": false, - "description": "Default value if the group is uncontrolled" - }, - "by": { - "type": "string", - "required": false, - "description": "Attribute to compare selected values, typically 'id'" - }, - "onChange": { - "type": "( value: string | string[] ) => void", - "required": false, - "description": "Handler invoked on value change" - }, - "disableGroup": { - "type": "boolean", - "required": false, - "description": "Disables all radio buttons in the group" - }, - "vertical": { - "type": "boolean", - "required": false, - "description": "Arranges the radio buttons vertically" - }, - "columns": { - "type": "number", - "required": false, - "description": "Number of columns for arranging the buttons" - }, - "multiSelection": { - "type": "boolean", - "required": false, - "description": "Enables multi-selection mode" - }, - "gapClassName": { - "type": "string", - "required": false, - "description": "Gap between radio buttons" - }, - "id": { - "type": "string", - "required": false, - "description": "Unique identifier for the radio button" - }, - "label": { - "type": "{ heading: string; description?: string", - "required": false, - "description": "Label content for the radio button" - } - } - } - } - }, - "Select": { - "props": { - "id": { - "type": "string", - "required": false, - "description": " Root element ID where the `Select.Options` will be rendered. If not provided Select.Options will be rendered in the body. " - }, - "size": { - "type": "SelectSizes", - "required": false, - "description": "Defines the size of the Select Component." - }, - "by": { - "type": "string", - "required": false, - "description": "When the value is an object, a key is required to compare the selected value. The default value is `id`." - }, - "children": { - "type": "MultiTypeChildren", - "required": false, - "description": "Expects the `Select.Button` children of the Select Component." - }, - "combobox": { - "type": "boolean", - "required": false, - "description": "Combobox mode." - }, - "disabled": { - "type": "boolean", - "required": false, - "description": "Disables the Select Component." - }, - "multiple": { - "type": "boolean", - "required": false, - "description": "Multi select mode." - }, - "value": { - "type": "SelectOptionValue", - "required": true, - "description": "Value of the option." - }, - "onChange": { - "type": "SelectOnChange", - "required": true, - "description": "onChange event to be triggered when the value of the Select Component changes." - }, - "defaultValue": { - "type": "SelectOptionValue | SelectOptionValue[]", - "required": false, - "description": "Defines the default value of the Select Component." - }, - "searchPlaceholder": { - "type": "string", - "required": false, - "description": "Placeholder text for search box." - }, - "searchFn": { - "type": "( keyword: string ) => Promise", - "required": false, - "description": "Function to fetch options. If provided, the search functionality will be handled outside of the select component." - }, - "debounceDelay": { - "type": "number", - "required": false, - "description": "Delay in milliseconds for debounced search. If the searchFn is provided, the debounceDelay will be used to debounce the search." - }, - "root": { - "type": "HTMLElement", - "required": false, - "description": " Root element where the `Select.Options` will be rendered. If not provided Select.Options will be rendered in the body. " - }, - "icon": { - "type": "ReactNode | null", - "required": false, - "description": "Option Icon to show at the right of the option trigger/button. By default it will show chevron down icon." - }, - "placeholder": { - "type": "string", - "required": false, - "description": "Placeholder text when no option is selected." - }, - "optionIcon": { - "type": "ReactNode | null", - "required": false, - "description": "Icon to show in the selected option badge (Multi-select mode only). By default it won't show unknown icon." - }, - "render": { - "type": "( selected: SelectOptionValue ) => ReactNode | string", - "required": false, - "description": " Render function to display the selected option (Must use for multi-select mode). For multi-select mode, the selected option will be displayed as a badge but the render function will be used to display the selected options. For single-select mode, the render function will be used to display the selected option. " - }, - "label": { - "type": "string", - "required": false, - "description": "Label for the Select component." - }, - "className": { - "type": "string", - "required": false, - "description": "Additional class name for the Select Button." - }, - "selected": { - "type": "boolean", - "required": false, - "description": "Selected state of the option." - } - }, - "subComponents": { - "Portal": { - "props": { - "children": { - "type": "ReactNode", - "required": false, - "description": "Expects the `Select.Options` children of the Select.Portal Component." - }, - "root": { - "type": "HTMLElement", - "required": false, - "description": " Root element where the `Select.Options` will be rendered. If not provided Select.Options will be rendered in the body. " - }, - "id": { - "type": "string", - "required": false, - "description": " Root element ID where the `Select.Options` will be rendered. If not provided Select.Options will be rendered in the body. " - } - } - }, - "Button": { - "props": { - "children": { - "type": "MultiTypeChildren", - "required": false, - "description": "Expects the `Select.Button` children of the Select Component." - }, - "icon": { - "type": "ReactNode | null", - "required": false, - "description": "Option Icon to show at the right of the option trigger/button. By default it will show chevron down icon." - }, - "placeholder": { - "type": "string", - "required": false, - "description": "Placeholder text when no option is selected." - }, - "optionIcon": { - "type": "ReactNode | null", - "required": false, - "description": "Icon to show in the selected option badge (Multi-select mode only). By default it won't show unknown icon." - }, - "render": { - "type": "( selected: SelectOptionValue ) => ReactNode | string", - "required": false, - "description": " Render function to display the selected option (Must use for multi-select mode). For multi-select mode, the selected option will be displayed as a badge but the render function will be used to display the selected options. For single-select mode, the render function will be used to display the selected option. " - }, - "label": { - "type": "string", - "required": false, - "description": "Label for the Select component." - }, - "className": { - "type": "string", - "required": false, - "description": "Additional class name for the Select Button." - } - } - }, - "Options": { - "props": { - "children": { - "type": "React.ReactNode", - "required": true, - "description": "Expects the `Select.Option` or `Select.OptionGroup` children" - }, - "className": { - "type": "string", - "required": false, - "description": "Additional class name for the Select Options wrapper." - } - } - }, - "Option": { - "props": { - "value": { - "type": "SelectOptionValue", - "required": true, - "description": "Value of the option." - }, - "selected": { - "type": "boolean", - "required": false, - "description": "Selected state of the option." - }, - "children": { - "type": "ReactNode", - "required": false, - "description": "Expects the `Select.Option` children of the Select Component." - }, - "className": { - "type": "string", - "required": false, - "description": "Additional class name for the Select Option." - }, - "label": { - "type": "string", - "required": true, - "description": "Label for the option group" - } - } - }, - "OptionGroup": { - "props": { - "label": { - "type": "string", - "required": true, - "description": "Label for the option group" - }, - "children": { - "type": "ReactNode", - "required": true, - "description": "Children options" - }, - "className": { - "type": "string", - "required": false, - "description": "Additional class name for the option group" - } - } - } - } - }, - "Sidebar": { - "props": { - "isCollapsed": { - "type": "boolean", - "required": true, - "description": "" - }, - "setIsCollapsed": { - "type": "React.Dispatch>", - "required": true, - "description": "" - }, - "collapsible": { - "type": "boolean", - "required": false, - "description": "Determines if the Sidebar can be collapsed or not. If true, a collapse button is shown." - }, - "children": { - "type": "ReactNode", - "required": true, - "description": "Content to render inside the Sidebar. Typically includes Sidebar.Header, Sidebar.Body, and Sidebar.Footer components." - }, - "className": { - "type": "string", - "required": false, - "description": "Optional custom CSS classes for styling the Sidebar item." - }, - "onCollapseChange": { - "type": "( isCollapsed: boolean ) => void", - "required": false, - "description": "Callback function triggered when the Sidebar collapse state changes." - }, - "borderOn": { - "type": "boolean", - "required": false, - "description": "Controls whether a border should appear on the right of the Sidebar." - }, - "collapsed": { - "type": "boolean", - "required": false, - "description": "Set the sidebar collapse state. This is useful when collapsible is false and you want to use the sidebar as collapsed by default." - } - }, - "subComponents": { - "Header": { - "props": {} - }, - "Body": { - "props": {} - }, - "Footer": { - "props": {} - }, - "Item": { - "props": { - "className": { - "type": "string", - "required": false, - "description": "Optional custom CSS classes for styling the Sidebar item." - }, - "onClick": { - "type": "() => void; // Add this line", - "required": false, - "description": "Click event handler" - } - } - } - } - }, - "Skeleton": { - "props": { - "variant": { - "type": "'rectangular' | 'circular'", - "required": false, - "description": "Defines the style variant of the skeleton." - }, - "className": { - "type": "string", - "required": false, - "description": "Allows you to pass custom classes to control the size and styles." - } - }, - "subComponents": {} - }, - "Switch": { - "props": { - "id": { - "type": "string", - "required": false, - "description": "Unique identifier for the switch component." - }, - "onChange": { - "type": "( checked: boolean ) => void", - "required": false, - "description": "Callback function triggered when the switch value changes." - }, - "value": { - "type": "boolean", - "required": false, - "description": "Controlled value of the switch (checked or unchecked)." - }, - "defaultValue": { - "type": "boolean", - "required": false, - "description": "Initial value of the switch (checked or unchecked) when used as an uncontrolled component." - }, - "size": { - "type": "'xs' | 'sm' | 'md'", - "required": false, - "description": " Defines the size of the switch (e.g., 'xs', 'sm', 'md'). @default 'sm' " - }, - "disabled": { - "type": "boolean", - "required": false, - "description": "Disables the switch if true." - }, - "label": { - "type": "{", - "required": false, - "description": "Defines the label for the switch, can include heading and description." - }, - "heading": { - "type": "string", - "required": false, - "description": "Heading for the label." - }, - "description": { - "type": "string", - "required": false, - "description": "Description for the label." - } - }, - "subComponents": {} - }, - "Table": { - "props": { - "children": { - "type": "ReactNode", - "required": false, - "description": " Child components to render within the table footer. " - }, - "className": { - "type": "string", - "required": false, - "description": " Class name to apply to the component. " - }, - "checkboxSelection": { - "type": "boolean", - "required": false, - "description": " Whether to show checkboxes for row selection. " - }, - "selected": { - "type": "boolean", - "required": false, - "description": " Whether any of the rows are selected. " - }, - "indeterminate": { - "type": "boolean", - "required": false, - "description": " Whether the checkbox is indeterminate. " - }, - "disabled": { - "type": "boolean", - "required": false, - "description": " Whether the checkbox is disabled. " - }, - "onChangeSelection": { - "type": "( checked: boolean ) => void", - "required": false, - "description": " On checkbox change for bulk selection/deselection. @default undefined " - }, - "value": { - "type": "T | undefined", - "required": false, - "description": " value of the row. " - } - }, - "subComponents": { - "Head": { - "props": { - "children": { - "type": "ReactNode", - "required": false, - "description": " Child components to render within the table head. " - }, - "selected": { - "type": "boolean", - "required": false, - "description": " Whether any of the rows are selected. " - }, - "indeterminate": { - "type": "boolean", - "required": false, - "description": " Whether the checkbox is indeterminate. " - }, - "disabled": { - "type": "boolean", - "required": false, - "description": " Whether the checkbox is disabled. " - }, - "onChangeSelection": { - "type": "( checked: boolean ) => void", - "required": false, - "description": " On checkbox change for bulk selection/deselection. @default undefined " - } - } - }, - "HeadCell": { - "props": { - "children": { - "type": "ReactNode", - "required": false, - "description": " Content to display in the header cell. " - } - } - }, - "Body": { - "props": { - "children": { - "type": "ReactNode", - "required": false, - "description": " Child components to render within the table body. " - } - } - }, - "Row": { - "props": { - "children": { - "type": "ReactNode", - "required": false, - "description": " Child components to render within the table row. " - }, - "value": { - "type": "T | undefined", - "required": false, - "description": " value of the row. " - }, - "selected": { - "type": "boolean", - "required": false, - "description": " Whether the row is selected. " - }, - "onChangeSelection": { - "type": "( checked: boolean, value: T ) => void", - "required": false, - "description": " On checkbox selection change. " - }, - "disabled": { - "type": "boolean", - "required": false, - "description": " Whether the row is disabled. " - } - } - }, - "Cell": { - "props": { - "children": { - "type": "ReactNode", - "required": false, - "description": " Content to display in the table cell. " - } - } - }, - "Footer": { - "props": { - "children": { - "type": "ReactNode", - "required": false, - "description": " Child components to render within the table footer. " - } - } - } - } - }, - "Tabs": { - "props": { - "activeItem": { - "type": "string | null", - "required": true, - "description": "The active tab value to identify active tab." - }, - "onChange": { - "type": "( {", - "required": false, - "description": "Callback when the active item changes." - }, - "slug": { - "type": "string", - "required": true, - "description": "Unique identifier for the tab panel that is used for the tab." - }, - "text": { - "type": "string", - "required": true, - "description": "Text to display in the tab." - }, - "icon": { - "type": "ReactNode", - "required": false, - "description": "Icon to display in the tab." - }, - "className": { - "type": "string", - "required": false, - "description": "Additional class names for styling." - }, - "disabled": { - "type": "boolean", - "required": false, - "description": "Disables the tab." - }, - "badge": { - "type": "ReactNode", - "required": false, - "description": "Badge to display in the tab." - }, - "children": { - "type": "ReactNode", - "required": true, - "description": "Content to display in the tab panel." - } - }, - "subComponents": { - "Group": { - "props": { - "activeItem": { - "type": "string | null", - "required": false, - "description": "Controls the active tab." - }, - "onChange": { - "type": "( {", - "required": false, - "description": "Callback when the active item changes." - } - } - }, - "Tab": { - "props": { - "slug": { - "type": "string", - "required": true, - "description": "Unique identifier for the tab." - }, - "text": { - "type": "string", - "required": true, - "description": "Text to display in the tab." - }, - "icon": { - "type": "ReactNode", - "required": false, - "description": "Icon to display in the tab." - }, - "className": { - "type": "string", - "required": false, - "description": "Additional class names for styling." - }, - "disabled": { - "type": "boolean", - "required": false, - "description": "Disables the tab." - }, - "badge": { - "type": "ReactNode", - "required": false, - "description": "Badge to display in the tab." - }, - "activeItem": { - "type": "string | null", - "required": true, - "description": "The active tab value to identify active tab." - }, - "onChange": { - "type": "( {", - "required": false, - "description": "Callback when the active item changes." - }, - "children": { - "type": "ReactNode", - "required": true, - "description": "Content to display in the tab panel." - } - } - }, - "Panel": { - "props": { - "slug": { - "type": "string", - "required": true, - "description": "Unique identifier for the tab panel that is used for the tab." - }, - "children": { - "type": "ReactNode", - "required": true, - "description": "Content to display in the tab panel." - } - } - } - } - }, - "Text": { - "props": { - "as": { - "type": "C", - "required": false, - "description": " The element to render the text as. @default 'p' " - }, - "ref": { - "type": "PolymorphicRef", - "required": false, - "description": "" - }, - "children": { - "type": "ReactNode", - "required": true, - "description": " The content of the text. " - }, - "weight": { - "type": "keyof typeof fontWeightClassNames", - "required": false, - "description": " The font weight of the text. " - }, - "size": { - "type": "keyof typeof fontSizeClassNames", - "required": false, - "description": " The font size of the text. " - }, - "lineHeight": { - "type": "keyof typeof lineHeightClassNames", - "required": false, - "description": " The line height of the text. " - }, - "letterSpacing": { - "type": "keyof typeof letterSpacingClassNames", - "required": false, - "description": " The letter spacing of the text. " - }, - "color": { - "type": "keyof typeof fontColorClassNames", - "required": false, - "description": " The font color of the text. " - }, - "className": { - "type": "string", - "required": false, - "description": " Additional class names to apply " - } - }, - "subComponents": {} - }, - "Title": { - "props": { - "title": { - "type": "string", - "required": false, - "description": "The main title text to render." - }, - "description": { - "type": "string", - "required": false, - "description": "Optional description text to display below the title." - }, - "icon": { - "type": "ReactNode", - "required": false, - "description": "Icon element to display alongside the title." - }, - "iconPosition": { - "type": "'left' | 'right'", - "required": false, - "description": "Determines the position of the icon relative to the title." - }, - "tag": { - "type": "'h1' | 'h2' | 'h3' | 'h4' | 'h5' | 'h6'", - "required": false, - "description": "HTML tag to use for the title (e.g., h1, h2, h3)." - }, - "size": { - "type": "'xs' | 'sm' | 'md' | 'lg'", - "required": false, - "description": "Size variant of the title (affects both title and description styles) - xs, sm, md, lg." - }, - "className": { - "type": "string", - "required": false, - "description": "Additional class names to apply to the root element." - } - }, - "subComponents": {} - }, - "Toaster": { - "props": { - "position": { - "type": "'top-right' | 'top-left' | 'bottom-right' | 'bottom-left'", - "required": false, - "description": "Defines the position of the toaster." - }, - "design": { - "type": "'stack' | 'inline'", - "required": false, - "description": "Defines the design of the toast." - }, - "theme": { - "type": "'light' | 'dark'", - "required": false, - "description": "Defines the theme of the toast." - }, - "className": { - "type": "string", - "required": false, - "description": "Additional classes to be added to the toaster." - }, - "autoDismiss": { - "type": "boolean", - "required": false, - "description": "Defines if the toast should be auto dismissed or not." - }, - "dismissAfter": { - "type": "number", - "required": false, - "description": "Time in milliseconds after which the toast will be dismissed." - }, - "toastItem": { - "type": "ToastType", - "required": true, - "description": "The toast item." - }, - "title": { - "type": "string | React.ReactElement", - "required": false, - "description": "The title of the toast." - }, - "content": { - "type": "string | React.ReactElement", - "required": false, - "description": "The content of the toast." - }, - "icon": { - "type": "React.ReactElement", - "required": false, - "description": "The icon for the toast." - }, - "variant": { - "type": "ToastType['type']", - "required": false, - "description": "The variant of the toast." - }, - "removeToast": { - "type": "( id: number ) => void", - "required": false, - "description": "Function to remove the toast." - } - }, - "subComponents": {} - }, - "Tooltip": { - "props": { - "variant": { - "type": "'light' | 'dark'", - "required": false, - "description": "Defines the visual variant of the tooltip." - }, - "title": { - "type": "string", - "required": false, - "description": "The title displayed at the top of the tooltip." - }, - "content": { - "type": "ReactNode", - "required": false, - "description": "The main content to be displayed within the tooltip." - }, - "arrow": { - "type": "boolean", - "required": false, - "description": "Indicates whether to show an arrow pointing to the target element." - }, - "open": { - "type": "boolean", - "required": false, - "description": "Controls the visibility of the tooltip in a controlled manner." - }, - "setOpen": { - "type": "( isOpen: boolean ) => void", - "required": false, - "description": "Function to set the visibility state of the tooltip." - }, - "children": { - "type": "ReactNode", - "required": true, - "description": "The child element to which the tooltip is attached." - }, - "className": { - "type": "string", - "required": false, - "description": "Additional CSS classes to apply to the tooltip for custom styling." - }, - "tooltipPortalRoot": { - "type": "HTMLElement | null", - "required": false, - "description": "The root element where the tooltip will be rendered." - }, - "tooltipPortalId": { - "type": "string", - "required": false, - "description": "The ID of the tooltip portal." - }, - "strategy": { - "type": "'fixed' | 'absolute'", - "required": false, - "description": "Specifies the positioning strategy for the tooltip." - }, - "offset": { - "type": "number", - "required": false, - "description": "Offset distance (in pixels) from the target element to the tooltip." - }, - "triggers": { - "type": "( 'click' | 'hover' | 'focus' )[]", - "required": false, - "description": "Events that trigger the tooltip." - }, - "interactive": { - "type": "boolean", - "required": false, - "description": "Indicates whether the tooltip content is interactive. Keeps the tooltip open while the user interacts with its content." - }, - "boundary": { - "type": "'viewport' | 'clippingAncestors' | HTMLElement | null", - "required": false, - "description": "Defines the boundary for positioning the tooltip, accepting 'viewport', 'clippingAncestors', or an HTML element reference." - } - }, - "subComponents": {} - }, - "Topbar": { - "props": { - "children": { - "type": "ReactNode", - "required": false, - "description": "Children to be rendered inside the Topbar." - }, - "className": { - "type": "string", - "required": false, - "description": "Additional classes to be added to the Topbar." - }, - "gap": { - "type": "'0' | 'xxs' | 'xs' | 'sm' | 'md' | 'lg' | 'xl' | '2xl'", - "required": false, - "description": "Defines the gap between items." - }, - "align": { - "type": "'left' | 'center' | 'right'", - "required": false, - "description": "Defines how the content inside the Middle section is aligned." - } - }, - "subComponents": { - "Left": { - "props": {} - }, - "Middle": { - "props": { - "align": { - "type": "'left' | 'center' | 'right'", - "required": false, - "description": "Defines how the content inside the Middle section is aligned." - } - } - }, - "Right": { - "props": {} - }, - "Item": { - "props": {} - } - } - } - }, - "metadata": { - "totalComponents": 38, - "extractedAt": "2025-06-05T10:11:20.250Z", - "componentsWithSubcomponents": 15 - } -} \ No newline at end of file diff --git a/package-lock.json b/package-lock.json index 26a8f150..7a7decba 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,24 +1,27 @@ { "name": "@bsf/force-ui", - "version": "1.7.11", + "version": "1.7.12", "lockfileVersion": 3, "requires": true, "packages": { "": { "name": "@bsf/force-ui", - "version": "1.7.11", + "version": "1.7.12", + "hasInstallScript": true, "license": "ISC", "dependencies": { "@emotion/is-prop-valid": "^1.3.0", "@floating-ui/react": "^0.26.28", - "@lexical/react": "^0.31.2", - "@lexical/selection": "^0.31.2", - "@lexical/utils": "^0.31.2", + "@lexical/clipboard": "0.38.2", + "@lexical/react": "0.38.2", + "@lexical/selection": "0.38.2", + "@lexical/table": "0.38.2", + "@lexical/utils": "0.38.2", "clsx": "^2.1.1", "date-fns": "^4.1.0", "deepmerge": "^4.3.1", "framer-motion": "^12.34.3", - "lexical": "^0.31.2", + "lexical": "0.38.2", "lucide-react": "^0.417.0", "nanoid": "^5.0.7", "react-day-picker": "^9.1.3", @@ -68,6 +71,7 @@ "gulp-cli": "^3.0.0", "gulp-replace": "^1.1.4", "inquirer": "^12.4.1", + "patch-package": "^8.0.1", "playwright": "^1.58.2", "postcss": "^8.4.39", "prettier": "^3.2.5", @@ -2826,22 +2830,22 @@ } }, "node_modules/@floating-ui/core": { - "version": "1.7.4", - "resolved": "https://registry.npmjs.org/@floating-ui/core/-/core-1.7.4.tgz", - "integrity": "sha512-C3HlIdsBxszvm5McXlB8PeOEWfBhcGBTZGkGlWc2U0KFY5IwG5OQEuQ8rq52DZmcHDlPLd+YFBK+cZcytwIFWg==", + "version": "1.7.5", + "resolved": "https://registry.npmjs.org/@floating-ui/core/-/core-1.7.5.tgz", + "integrity": "sha512-1Ih4WTWyw0+lKyFMcBHGbb5U5FtuHJuujoyyr5zTaWS5EYMeT6Jb2AuDeftsCsEuchO+mM2ij5+q9crhydzLhQ==", "license": "MIT", "dependencies": { - "@floating-ui/utils": "^0.2.10" + "@floating-ui/utils": "^0.2.11" } }, "node_modules/@floating-ui/dom": { - "version": "1.7.5", - "resolved": "https://registry.npmjs.org/@floating-ui/dom/-/dom-1.7.5.tgz", - "integrity": "sha512-N0bD2kIPInNHUHehXhMke1rBGs1dwqvC9O9KYMyyjK7iXt7GAhnro7UlcuYcGdS/yYOlq0MAVgrow8IbWJwyqg==", + "version": "1.7.6", + "resolved": "https://registry.npmjs.org/@floating-ui/dom/-/dom-1.7.6.tgz", + "integrity": "sha512-9gZSAI5XM36880PPMm//9dfiEngYoC6Am2izES1FF406YFsjvyBMmeJ2g4SAju3xWwtuynNRFL2s9hgxpLI5SQ==", "license": "MIT", "dependencies": { - "@floating-ui/core": "^1.7.4", - "@floating-ui/utils": "^0.2.10" + "@floating-ui/core": "^1.7.5", + "@floating-ui/utils": "^0.2.11" } }, "node_modules/@floating-ui/react": { @@ -2860,12 +2864,12 @@ } }, "node_modules/@floating-ui/react-dom": { - "version": "2.1.7", - "resolved": "https://registry.npmjs.org/@floating-ui/react-dom/-/react-dom-2.1.7.tgz", - "integrity": "sha512-0tLRojf/1Go2JgEVm+3Frg9A3IW8bJgKgdO0BN5RkF//ufuz2joZM63Npau2ff3J6lUVYgDSNzNkR+aH3IVfjg==", + "version": "2.1.8", + "resolved": "https://registry.npmjs.org/@floating-ui/react-dom/-/react-dom-2.1.8.tgz", + "integrity": "sha512-cC52bHwM/n/CxS87FH0yWdngEZrjdtLW/qVruo68qg+prK7ZQ4YGdut2GyDVpoGeAYe/h899rVeOVm6Oi40k2A==", "license": "MIT", "dependencies": { - "@floating-ui/dom": "^1.7.5" + "@floating-ui/dom": "^1.7.6" }, "peerDependencies": { "react": ">=16.8.0", @@ -2873,9 +2877,9 @@ } }, "node_modules/@floating-ui/utils": { - "version": "0.2.10", - "resolved": "https://registry.npmjs.org/@floating-ui/utils/-/utils-0.2.10.tgz", - "integrity": "sha512-aGTxbpbg8/b5JfU1HXSrbH3wXZuLPJcNEcZQFMxLs3oSzgtVu6nFPkbbGGUvBcUjKV2YyB9Wxxabo+HEH9tcRQ==", + "version": "0.2.11", + "resolved": "https://registry.npmjs.org/@floating-ui/utils/-/utils-0.2.11.tgz", + "integrity": "sha512-RiB/yIh78pcIxl6lLMG0CgBXAZ2Y0eVHqMPYugu+9U0AeT6YBeiJpf7lbdJNIugFP5SIjwNRgo4DhR1Qxi26Gg==", "license": "MIT" }, "node_modules/@gulpjs/messages": { @@ -4060,41 +4064,41 @@ "license": "MIT" }, "node_modules/@lexical/clipboard": { - "version": "0.31.2", - "resolved": "https://registry.npmjs.org/@lexical/clipboard/-/clipboard-0.31.2.tgz", - "integrity": "sha512-cedna5jXfNzbmGl0nLOiLoQoE42i3NfCU6wtugO/auWTLbv1/gD9g0egLg2lAUod+BApaCgdTU4tV2bqww2GWQ==", + "version": "0.38.2", + "resolved": "https://registry.npmjs.org/@lexical/clipboard/-/clipboard-0.38.2.tgz", + "integrity": "sha512-dDShUplCu8/o6BB9ousr3uFZ9bltR+HtleF/Tl8FXFNPpZ4AXhbLKUoJuucRuIr+zqT7RxEv/3M6pk/HEoE6NQ==", "license": "MIT", "dependencies": { - "@lexical/html": "0.31.2", - "@lexical/list": "0.31.2", - "@lexical/selection": "0.31.2", - "@lexical/utils": "0.31.2", - "lexical": "0.31.2" + "@lexical/html": "0.38.2", + "@lexical/list": "0.38.2", + "@lexical/selection": "0.38.2", + "@lexical/utils": "0.38.2", + "lexical": "0.38.2" } }, "node_modules/@lexical/code": { - "version": "0.31.2", - "resolved": "https://registry.npmjs.org/@lexical/code/-/code-0.31.2.tgz", - "integrity": "sha512-pix3n43zJzzkOgiUV0aTkWL4syItiHrP7YkdenkXgauVMAqZq3IvmK1hSQYKeDsVw/3N8mU26oRp0g5kPDV1rA==", + "version": "0.38.2", + "resolved": "https://registry.npmjs.org/@lexical/code/-/code-0.38.2.tgz", + "integrity": "sha512-wpqgbmPsfi/+8SYP0zI2kml09fGPRhzO5litR9DIbbSGvcbawMbRNcKLO81DaTbsJRnBJiQvbBBBJAwZKRqgBw==", "license": "MIT", "dependencies": { - "@lexical/utils": "0.31.2", - "lexical": "0.31.2", + "@lexical/utils": "0.38.2", + "lexical": "0.38.2", "prismjs": "^1.30.0" } }, "node_modules/@lexical/devtools-core": { - "version": "0.31.2", - "resolved": "https://registry.npmjs.org/@lexical/devtools-core/-/devtools-core-0.31.2.tgz", - "integrity": "sha512-Ae5jJzeo6+3DVEWj9n6h+Vz8R4eL+Z7egGHOAwSa3E65PVp8WNlAoM+Z0rNNpvmbFglWD7d9pSPHcK/G5B7Bfw==", + "version": "0.38.2", + "resolved": "https://registry.npmjs.org/@lexical/devtools-core/-/devtools-core-0.38.2.tgz", + "integrity": "sha512-hlN0q7taHNzG47xKynQLCAFEPOL8l6IP79C2M18/FE1+htqNP35q4rWhYhsptGlKo4me4PtiME7mskvr7T4yqA==", "license": "MIT", "dependencies": { - "@lexical/html": "0.31.2", - "@lexical/link": "0.31.2", - "@lexical/mark": "0.31.2", - "@lexical/table": "0.31.2", - "@lexical/utils": "0.31.2", - "lexical": "0.31.2" + "@lexical/html": "0.38.2", + "@lexical/link": "0.38.2", + "@lexical/mark": "0.38.2", + "@lexical/table": "0.38.2", + "@lexical/utils": "0.38.2", + "lexical": "0.38.2" }, "peerDependencies": { "react": ">=17.x", @@ -4102,212 +4106,248 @@ } }, "node_modules/@lexical/dragon": { - "version": "0.31.2", - "resolved": "https://registry.npmjs.org/@lexical/dragon/-/dragon-0.31.2.tgz", - "integrity": "sha512-exFqbyyLyfZmmKQgjB4sJOYHV5DQYIPw0orvxpGMeaVCOgfP0RvB21QLHyazmGlnVNcahscHYieZmLJdpwHYMQ==", + "version": "0.38.2", + "resolved": "https://registry.npmjs.org/@lexical/dragon/-/dragon-0.38.2.tgz", + "integrity": "sha512-riOhgo+l4oN50RnLGhcqeUokVlMZRc+NDrxRNs2lyKSUdC4vAhAmAVUHDqYPyb4K4ZSw4ebZ3j8hI2zO4O3BbA==", "license": "MIT", "dependencies": { - "lexical": "0.31.2" + "@lexical/extension": "0.38.2", + "lexical": "0.38.2" + } + }, + "node_modules/@lexical/extension": { + "version": "0.38.2", + "resolved": "https://registry.npmjs.org/@lexical/extension/-/extension-0.38.2.tgz", + "integrity": "sha512-qbUNxEVjAC0kxp7hEMTzktj0/51SyJoIJWK6Gm790b4yNBq82fEPkksfuLkRg9VQUteD0RT1Nkjy8pho8nNamw==", + "license": "MIT", + "dependencies": { + "@lexical/utils": "0.38.2", + "@preact/signals-core": "^1.11.0", + "lexical": "0.38.2" } }, "node_modules/@lexical/hashtag": { - "version": "0.31.2", - "resolved": "https://registry.npmjs.org/@lexical/hashtag/-/hashtag-0.31.2.tgz", - "integrity": "sha512-/sa8bsCq2CKmdpvN/l2B8K/sJrsmd4pAafFG4JWB7JXjPxJyDe80WbSaQfBPdrhvqdLY8l05GeWM17SsEV1sMw==", + "version": "0.38.2", + "resolved": "https://registry.npmjs.org/@lexical/hashtag/-/hashtag-0.38.2.tgz", + "integrity": "sha512-jNI4Pv+plth39bjOeeQegMypkjDmoMWBMZtV0lCynBpkkPFlfMnyL9uzW/IxkZnX8LXWSw5mbWk07nqOUNTCrA==", "license": "MIT", "dependencies": { - "@lexical/utils": "0.31.2", - "lexical": "0.31.2" + "@lexical/text": "0.38.2", + "@lexical/utils": "0.38.2", + "lexical": "0.38.2" } }, "node_modules/@lexical/history": { - "version": "0.31.2", - "resolved": "https://registry.npmjs.org/@lexical/history/-/history-0.31.2.tgz", - "integrity": "sha512-q3Ykv3oi711XmuFdg7LuppLImyedgpLD5KekXLXRVyOGOTvvaNfb2YQfRjFBalxl3umj2QHYR22Zkamx8zfFXw==", + "version": "0.38.2", + "resolved": "https://registry.npmjs.org/@lexical/history/-/history-0.38.2.tgz", + "integrity": "sha512-QWPwoVDMe/oJ0+TFhy78TDi7TWU/8bcDRFUNk1nWgbq7+2m+5MMoj90LmOFwakQHnCVovgba2qj+atZrab1dsQ==", "license": "MIT", "dependencies": { - "@lexical/utils": "0.31.2", - "lexical": "0.31.2" + "@lexical/extension": "0.38.2", + "@lexical/utils": "0.38.2", + "lexical": "0.38.2" } }, "node_modules/@lexical/html": { - "version": "0.31.2", - "resolved": "https://registry.npmjs.org/@lexical/html/-/html-0.31.2.tgz", - "integrity": "sha512-92Oi9daBDNCaionS9ENnXkC+jzzz5WdFTHxTkPqcGaJZE/jF0rAe6LQo6356O/yr9dYK/KIsE8V79AJHqQKJhg==", + "version": "0.38.2", + "resolved": "https://registry.npmjs.org/@lexical/html/-/html-0.38.2.tgz", + "integrity": "sha512-pC5AV+07bmHistRwgG3NJzBMlIzSdxYO6rJU4eBNzyR4becdiLsI4iuv+aY7PhfSv+SCs7QJ9oc4i5caq48Pkg==", "license": "MIT", "dependencies": { - "@lexical/selection": "0.31.2", - "@lexical/utils": "0.31.2", - "lexical": "0.31.2" + "@lexical/selection": "0.38.2", + "@lexical/utils": "0.38.2", + "lexical": "0.38.2" } }, "node_modules/@lexical/link": { - "version": "0.31.2", - "resolved": "https://registry.npmjs.org/@lexical/link/-/link-0.31.2.tgz", - "integrity": "sha512-sLtpW+cuFdVq1V6vlEFUEC1BRHyHBxEdCrxwTP7T0CreJDKrUrBD2oBafb/4AiOPhM7CHAwW88pbuY5KvWOovw==", + "version": "0.38.2", + "resolved": "https://registry.npmjs.org/@lexical/link/-/link-0.38.2.tgz", + "integrity": "sha512-UOKTyYqrdCR9+7GmH6ZVqJTmqYefKGMUHMGljyGks+OjOGZAQs78S1QgcPEqltDy+SSdPSYK7wAo6gjxZfEq9g==", "license": "MIT", "dependencies": { - "@lexical/utils": "0.31.2", - "lexical": "0.31.2" + "@lexical/extension": "0.38.2", + "@lexical/utils": "0.38.2", + "lexical": "0.38.2" } }, "node_modules/@lexical/list": { - "version": "0.31.2", - "resolved": "https://registry.npmjs.org/@lexical/list/-/list-0.31.2.tgz", - "integrity": "sha512-NbdpxSttk/MmYCSovsxiQwS2h3h2U/Kg3WwNfW9vgpvdZE+qmg6jqpzUFVe51/i+GF2WU0uRPG0J5StMGhtYlg==", + "version": "0.38.2", + "resolved": "https://registry.npmjs.org/@lexical/list/-/list-0.38.2.tgz", + "integrity": "sha512-OQm9TzatlMrDZGxMxbozZEHzMJhKxAbH1TOnOGyFfzpfjbnFK2y8oLeVsfQZfZRmiqQS4Qc/rpFnRP2Ax5dsbA==", "license": "MIT", "dependencies": { - "@lexical/selection": "0.31.2", - "@lexical/utils": "0.31.2", - "lexical": "0.31.2" + "@lexical/extension": "0.38.2", + "@lexical/selection": "0.38.2", + "@lexical/utils": "0.38.2", + "lexical": "0.38.2" } }, "node_modules/@lexical/mark": { - "version": "0.31.2", - "resolved": "https://registry.npmjs.org/@lexical/mark/-/mark-0.31.2.tgz", - "integrity": "sha512-orzsqWaejgdUhSHXRFogF0HNzRWKf2HD7DgiGxKF7LrjVLl4j14+zA8UWX9d4qNwIbRPdfQkYfeOSPwbYx3iRw==", + "version": "0.38.2", + "resolved": "https://registry.npmjs.org/@lexical/mark/-/mark-0.38.2.tgz", + "integrity": "sha512-U+8KGwc3cP5DxSs15HfkP2YZJDs5wMbWQAwpGqep9bKphgxUgjPViKhdi+PxIt2QEzk7WcoZWUsK1d2ty/vSmg==", "license": "MIT", "dependencies": { - "@lexical/utils": "0.31.2", - "lexical": "0.31.2" + "@lexical/utils": "0.38.2", + "lexical": "0.38.2" } }, "node_modules/@lexical/markdown": { - "version": "0.31.2", - "resolved": "https://registry.npmjs.org/@lexical/markdown/-/markdown-0.31.2.tgz", - "integrity": "sha512-2gWo7HiMONTor3whJo1237LZz769eVVRT8kGUgBq/p5QyFsb131NUYSxCperKdDaO43k+4ZQspPHyQJjoyOxHg==", + "version": "0.38.2", + "resolved": "https://registry.npmjs.org/@lexical/markdown/-/markdown-0.38.2.tgz", + "integrity": "sha512-ykQJ9KUpCs1+Ak6ZhQMP6Slai4/CxfLEGg/rSHNVGbcd7OaH/ICtZN5jOmIe9ExfXMWy1o8PyMu+oAM3+AWFgA==", "license": "MIT", "dependencies": { - "@lexical/code": "0.31.2", - "@lexical/link": "0.31.2", - "@lexical/list": "0.31.2", - "@lexical/rich-text": "0.31.2", - "@lexical/text": "0.31.2", - "@lexical/utils": "0.31.2", - "lexical": "0.31.2" + "@lexical/code": "0.38.2", + "@lexical/link": "0.38.2", + "@lexical/list": "0.38.2", + "@lexical/rich-text": "0.38.2", + "@lexical/text": "0.38.2", + "@lexical/utils": "0.38.2", + "lexical": "0.38.2" } }, "node_modules/@lexical/offset": { - "version": "0.31.2", - "resolved": "https://registry.npmjs.org/@lexical/offset/-/offset-0.31.2.tgz", - "integrity": "sha512-f8bNvys2jNgnjQWoUd6us7KBXdB7AhKqgWqso7nGeoB1CWGTkd88Qxm8A9uX/muPK0cb6fed4X7wN2xuRDWpyQ==", + "version": "0.38.2", + "resolved": "https://registry.npmjs.org/@lexical/offset/-/offset-0.38.2.tgz", + "integrity": "sha512-uDky2palcY+gE6WTv6q2umm2ioTUnVqcaWlEcchP6A310rI08n6rbpmkaLSIh3mT2GJQN2QcN2x0ct5BQmKIpA==", "license": "MIT", "dependencies": { - "lexical": "0.31.2" + "lexical": "0.38.2" } }, "node_modules/@lexical/overflow": { - "version": "0.31.2", - "resolved": "https://registry.npmjs.org/@lexical/overflow/-/overflow-0.31.2.tgz", - "integrity": "sha512-l5jbPglBX8CiXZ7F+okTcfdOwfAgf1JIa8BJhkQrtRP/fEiY3NnCehBYfp/Iyd9uBZDWlVlp1+UsqFFtEeT3Yg==", + "version": "0.38.2", + "resolved": "https://registry.npmjs.org/@lexical/overflow/-/overflow-0.38.2.tgz", + "integrity": "sha512-f6vkTf+YZF0EuKvUK3goh4jrnF+Z0koiNMO+7rhSMLooc5IlD/4XXix4ZLiIktUWq4BhO84b82qtrO+6oPUxtw==", "license": "MIT", "dependencies": { - "lexical": "0.31.2" + "lexical": "0.38.2" } }, "node_modules/@lexical/plain-text": { - "version": "0.31.2", - "resolved": "https://registry.npmjs.org/@lexical/plain-text/-/plain-text-0.31.2.tgz", - "integrity": "sha512-CMKuWPUCyDZ8ET10YZM7RxDyIB2UiHJ7mEwqEKl86OS9XOhWtp0qUQUonyeAy4f9yfuMTA7fQ2iLlEmAaeVu+g==", + "version": "0.38.2", + "resolved": "https://registry.npmjs.org/@lexical/plain-text/-/plain-text-0.38.2.tgz", + "integrity": "sha512-xRYNHJJFCbaQgr0uErW8Im2Phv1nWHIT4VSoAlBYqLuVGZBD4p61dqheBwqXWlGGJFk+MY5C5URLiMicgpol7A==", "license": "MIT", "dependencies": { - "@lexical/clipboard": "0.31.2", - "@lexical/selection": "0.31.2", - "@lexical/utils": "0.31.2", - "lexical": "0.31.2" + "@lexical/clipboard": "0.38.2", + "@lexical/dragon": "0.38.2", + "@lexical/selection": "0.38.2", + "@lexical/utils": "0.38.2", + "lexical": "0.38.2" } }, "node_modules/@lexical/react": { - "version": "0.31.2", - "resolved": "https://registry.npmjs.org/@lexical/react/-/react-0.31.2.tgz", - "integrity": "sha512-A/Ub9Ub5vx9EE0WEhVeE3t/SMVecnaPGeN37Q5LMPXiGgQCsMKEYtjHKvAjjAXSk8YD1lGTd/k4LOjyl8Y9ZyA==", - "license": "MIT", - "dependencies": { - "@lexical/devtools-core": "0.31.2", - "@lexical/dragon": "0.31.2", - "@lexical/hashtag": "0.31.2", - "@lexical/history": "0.31.2", - "@lexical/link": "0.31.2", - "@lexical/list": "0.31.2", - "@lexical/mark": "0.31.2", - "@lexical/markdown": "0.31.2", - "@lexical/overflow": "0.31.2", - "@lexical/plain-text": "0.31.2", - "@lexical/rich-text": "0.31.2", - "@lexical/table": "0.31.2", - "@lexical/text": "0.31.2", - "@lexical/utils": "0.31.2", - "@lexical/yjs": "0.31.2", - "lexical": "0.31.2", - "react-error-boundary": "^3.1.4" + "version": "0.38.2", + "resolved": "https://registry.npmjs.org/@lexical/react/-/react-0.38.2.tgz", + "integrity": "sha512-M3z3MkWyw3Msg4Hojr5TnO4TzL71NVPVNGoavESjdgJbTdv1ezcQqjE4feq+qs7H9jytZeuK8wsEOJfSPmNd8w==", + "license": "MIT", + "dependencies": { + "@floating-ui/react": "^0.27.16", + "@lexical/devtools-core": "0.38.2", + "@lexical/dragon": "0.38.2", + "@lexical/extension": "0.38.2", + "@lexical/hashtag": "0.38.2", + "@lexical/history": "0.38.2", + "@lexical/link": "0.38.2", + "@lexical/list": "0.38.2", + "@lexical/mark": "0.38.2", + "@lexical/markdown": "0.38.2", + "@lexical/overflow": "0.38.2", + "@lexical/plain-text": "0.38.2", + "@lexical/rich-text": "0.38.2", + "@lexical/table": "0.38.2", + "@lexical/text": "0.38.2", + "@lexical/utils": "0.38.2", + "@lexical/yjs": "0.38.2", + "lexical": "0.38.2", + "react-error-boundary": "^6.0.0" }, "peerDependencies": { "react": ">=17.x", "react-dom": ">=17.x" } }, + "node_modules/@lexical/react/node_modules/@floating-ui/react": { + "version": "0.27.19", + "resolved": "https://registry.npmjs.org/@floating-ui/react/-/react-0.27.19.tgz", + "integrity": "sha512-31B8h5mm8YxotlE7/AU/PhNAl8eWxAmjL/v2QOxroDNkTFLk3Uu82u63N3b6TXa4EGJeeZLVcd/9AlNlVqzeog==", + "license": "MIT", + "dependencies": { + "@floating-ui/react-dom": "^2.1.8", + "@floating-ui/utils": "^0.2.11", + "tabbable": "^6.0.0" + }, + "peerDependencies": { + "react": ">=17.0.0", + "react-dom": ">=17.0.0" + } + }, "node_modules/@lexical/rich-text": { - "version": "0.31.2", - "resolved": "https://registry.npmjs.org/@lexical/rich-text/-/rich-text-0.31.2.tgz", - "integrity": "sha512-iBkqY0CvTKbwk3T+a4wtI6/OjhM/CdxXvha6b88Gb9d5tYj5k7cT5SznYF1sXPmwtqpXg9TWkBN2Puqv3LPvsg==", + "version": "0.38.2", + "resolved": "https://registry.npmjs.org/@lexical/rich-text/-/rich-text-0.38.2.tgz", + "integrity": "sha512-eFjeOT7YnDZYpty7Zlwlct0UxUSaYu53uLYG+Prs3NoKzsfEK7e7nYsy/BbQFfk5HoM1pYuYxFR2iIX62+YHGw==", "license": "MIT", "dependencies": { - "@lexical/clipboard": "0.31.2", - "@lexical/selection": "0.31.2", - "@lexical/utils": "0.31.2", - "lexical": "0.31.2" + "@lexical/clipboard": "0.38.2", + "@lexical/dragon": "0.38.2", + "@lexical/selection": "0.38.2", + "@lexical/utils": "0.38.2", + "lexical": "0.38.2" } }, "node_modules/@lexical/selection": { - "version": "0.31.2", - "resolved": "https://registry.npmjs.org/@lexical/selection/-/selection-0.31.2.tgz", - "integrity": "sha512-8hwNgAVWob09y8/Z2QKknw0z6vFcfjsQfHkyDwXwXUeTcJFjlAokrXrc65PRuufI4TaFDQHnXQpP5GcOYROE6Q==", + "version": "0.38.2", + "resolved": "https://registry.npmjs.org/@lexical/selection/-/selection-0.38.2.tgz", + "integrity": "sha512-eMFiWlBH6bEX9U9sMJ6PXPxVXTrihQfFeiIlWLuTpEIDF2HRz7Uo1KFRC/yN6q0DQaj7d9NZYA6Mei5DoQuz5w==", "license": "MIT", "dependencies": { - "lexical": "0.31.2" + "lexical": "0.38.2" } }, "node_modules/@lexical/table": { - "version": "0.31.2", - "resolved": "https://registry.npmjs.org/@lexical/table/-/table-0.31.2.tgz", - "integrity": "sha512-S4W6DdkDCYP32qL6QD4jyksEatyfapRBc4sqoRove83fQEWnFhJ1iBheiG3hSm3YDbDmLclZxcE2CuSIZ6bd0Q==", + "version": "0.38.2", + "resolved": "https://registry.npmjs.org/@lexical/table/-/table-0.38.2.tgz", + "integrity": "sha512-uu0i7yz0nbClmHOO5ZFsinRJE6vQnFz2YPblYHAlNigiBedhqMwSv5bedrzDq8nTTHwych3mC63tcyKIrM+I1g==", "license": "MIT", "dependencies": { - "@lexical/clipboard": "0.31.2", - "@lexical/utils": "0.31.2", - "lexical": "0.31.2" + "@lexical/clipboard": "0.38.2", + "@lexical/extension": "0.38.2", + "@lexical/utils": "0.38.2", + "lexical": "0.38.2" } }, "node_modules/@lexical/text": { - "version": "0.31.2", - "resolved": "https://registry.npmjs.org/@lexical/text/-/text-0.31.2.tgz", - "integrity": "sha512-+rGRAqE4uKdJf25e4stqDImhBh5RgVmxMJf00OyQdwq1P2M+/xF3NddqRpoACHyMyHhuR1wOSONSnYbMqMtc6w==", + "version": "0.38.2", + "resolved": "https://registry.npmjs.org/@lexical/text/-/text-0.38.2.tgz", + "integrity": "sha512-+juZxUugtC4T37aE3P0l4I9tsWbogDUnTI/mgYk4Ht9g+gLJnhQkzSA8chIyfTxbj5i0A8yWrUUSw+/xA7lKUQ==", "license": "MIT", "dependencies": { - "lexical": "0.31.2" + "lexical": "0.38.2" } }, "node_modules/@lexical/utils": { - "version": "0.31.2", - "resolved": "https://registry.npmjs.org/@lexical/utils/-/utils-0.31.2.tgz", - "integrity": "sha512-vtPzZuJt134cz+oiHAPSIHT3hGt/9Gtug/Cf8OftqJeg3/7P6dKiTdAvAql3q4QxHlCAup4Ed87Ec8PYsICGGg==", + "version": "0.38.2", + "resolved": "https://registry.npmjs.org/@lexical/utils/-/utils-0.38.2.tgz", + "integrity": "sha512-y+3rw15r4oAWIEXicUdNjfk8018dbKl7dWHqGHVEtqzAYefnEYdfD2FJ5KOTXfeoYfxi8yOW7FvzS4NZDi8Bfw==", "license": "MIT", "dependencies": { - "@lexical/list": "0.31.2", - "@lexical/selection": "0.31.2", - "@lexical/table": "0.31.2", - "lexical": "0.31.2" + "@lexical/list": "0.38.2", + "@lexical/selection": "0.38.2", + "@lexical/table": "0.38.2", + "lexical": "0.38.2" } }, "node_modules/@lexical/yjs": { - "version": "0.31.2", - "resolved": "https://registry.npmjs.org/@lexical/yjs/-/yjs-0.31.2.tgz", - "integrity": "sha512-H1OV+NFGTmHqr+0BFkxo4bDBsdw1WmSwCzIoMVU1uA4levH7tLay/xBV/67ghh+5InSwGR6gcJeFdbL86URuOw==", + "version": "0.38.2", + "resolved": "https://registry.npmjs.org/@lexical/yjs/-/yjs-0.38.2.tgz", + "integrity": "sha512-fg6ZHNrVQmy1AAxaTs8HrFbeNTJCaCoEDPi6pqypHQU3QVfqr4nq0L0EcHU/TRlR1CeduEPvZZIjUUxWTZ0u8g==", "license": "MIT", "dependencies": { - "@lexical/offset": "0.31.2", - "@lexical/selection": "0.31.2", - "lexical": "0.31.2" + "@lexical/offset": "0.38.2", + "@lexical/selection": "0.38.2", + "lexical": "0.38.2" }, "peerDependencies": { "yjs": ">=13.5.22" @@ -4624,6 +4664,16 @@ "dev": true, "license": "MIT" }, + "node_modules/@preact/signals-core": { + "version": "1.14.2", + "resolved": "https://registry.npmjs.org/@preact/signals-core/-/signals-core-1.14.2.tgz", + "integrity": "sha512-RZHdBj9ZF4n40Rp4jS052EHHjBWf96P9oNdXPfhQTovCuWY9iQn3Gq+gOTJSgBO9A/JBuPfMOWsSX/lIU9Pc/A==", + "license": "MIT", + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/preact" + } + }, "node_modules/@rolldown/binding-android-arm64": { "version": "1.0.0-rc.11", "resolved": "https://registry.npmjs.org/@rolldown/binding-android-arm64/-/binding-android-arm64-1.0.0-rc.11.tgz", @@ -8440,6 +8490,13 @@ "npm": ">=8.19.2" } }, + "node_modules/@yarnpkg/lockfile": { + "version": "1.1.0", + "resolved": "https://registry.npmjs.org/@yarnpkg/lockfile/-/lockfile-1.1.0.tgz", + "integrity": "sha512-GpSwvyXOcOOlV70vbnzjj4fW5xW/FdUF6nQEt1ENy7m4ZCczi1+/buVUPAqmGfqznsORNFzUMjctTIp8a9tuCQ==", + "dev": true, + "license": "BSD-2-Clause" + }, "node_modules/acorn": { "version": "8.16.0", "resolved": "https://registry.npmjs.org/acorn/-/acorn-8.16.0.tgz", @@ -12279,6 +12336,16 @@ "url": "https://github.com/sponsors/sindresorhus" } }, + "node_modules/find-yarn-workspace-root": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/find-yarn-workspace-root/-/find-yarn-workspace-root-2.0.0.tgz", + "integrity": "sha512-1IMnbjt4KzsQfnhnzNd8wUEgXZ44IzZaZmnLYx7D5FZlaHt2gW20Cri8Q+E/t5tIj4+epTBub+2Zxu/vNILzqQ==", + "dev": true, + "license": "Apache-2.0", + "dependencies": { + "micromatch": "^4.0.2" + } + }, "node_modules/findup-sync": { "version": "5.0.0", "resolved": "https://registry.npmjs.org/findup-sync/-/findup-sync-5.0.0.tgz", @@ -15755,6 +15822,26 @@ "dev": true, "license": "MIT" }, + "node_modules/json-stable-stringify": { + "version": "1.3.0", + "resolved": "https://registry.npmjs.org/json-stable-stringify/-/json-stable-stringify-1.3.0.tgz", + "integrity": "sha512-qtYiSSFlwot9XHtF9bD9c7rwKjr+RecWT//ZnPvSmEjpV5mmPOCN4j8UjY5hbjNkOwZ/jQv3J6R1/pL7RwgMsg==", + "dev": true, + "license": "MIT", + "dependencies": { + "call-bind": "^1.0.8", + "call-bound": "^1.0.4", + "isarray": "^2.0.5", + "jsonify": "^0.0.1", + "object-keys": "^1.1.1" + }, + "engines": { + "node": ">= 0.4" + }, + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, "node_modules/json-stable-stringify-without-jsonify": { "version": "1.0.1", "resolved": "https://registry.npmjs.org/json-stable-stringify-without-jsonify/-/json-stable-stringify-without-jsonify-1.0.1.tgz", @@ -15795,6 +15882,16 @@ "graceful-fs": "^4.1.6" } }, + "node_modules/jsonify": { + "version": "0.0.1", + "resolved": "https://registry.npmjs.org/jsonify/-/jsonify-0.0.1.tgz", + "integrity": "sha512-2/Ki0GcmuqSrgFyelQq9M05y7PS0mEwuIzrf3f1fPqkVDVRvZrPZtVSMHxdgo8Aq0sxAOb/cr2aqqA3LeWHVPg==", + "dev": true, + "license": "Public Domain", + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, "node_modules/jsx-ast-utils": { "version": "3.3.5", "resolved": "https://registry.npmjs.org/jsx-ast-utils/-/jsx-ast-utils-3.3.5.tgz", @@ -15862,6 +15959,16 @@ "node": ">=0.10.0" } }, + "node_modules/klaw-sync": { + "version": "6.0.0", + "resolved": "https://registry.npmjs.org/klaw-sync/-/klaw-sync-6.0.0.tgz", + "integrity": "sha512-nIeuVSzdCCs6TDPTqI8w1Yre34sSq7AkZ4B3sfOBbI2CgVSB4Du4aLQijFU2+lhAFCwt9+42Hel6lQNIv6AntQ==", + "dev": true, + "license": "MIT", + "dependencies": { + "graceful-fs": "^4.1.11" + } + }, "node_modules/kleur": { "version": "3.0.3", "resolved": "https://registry.npmjs.org/kleur/-/kleur-3.0.3.tgz", @@ -15951,9 +16058,9 @@ } }, "node_modules/lexical": { - "version": "0.31.2", - "resolved": "https://registry.npmjs.org/lexical/-/lexical-0.31.2.tgz", - "integrity": "sha512-1GRqzl/QAdtzqOoYXVfMFOkyiSQKIIPcazsgIs+WvsLL8UIcwP16WWeKUtamJgyvS84GN/tuMJsd1Iv+Qzw9WA==", + "version": "0.38.2", + "resolved": "https://registry.npmjs.org/lexical/-/lexical-0.38.2.tgz", + "integrity": "sha512-JJmfsG3c4gwBHzUGffbV7ifMNkKAWMCnYE3xJl87gty7hjyV5f3xq7eqTjP5HFYvO4XpjJvvWO2/djHp5S10tw==", "license": "MIT" }, "node_modules/lib0": { @@ -17590,6 +17697,152 @@ "tslib": "^2.0.3" } }, + "node_modules/patch-package": { + "version": "8.0.1", + "resolved": "https://registry.npmjs.org/patch-package/-/patch-package-8.0.1.tgz", + "integrity": "sha512-VsKRIA8f5uqHQ7NGhwIna6Bx6D9s/1iXlA1hthBVBEbkq+t4kXD0HHt+rJhf/Z+Ci0F/HCB2hvn0qLdLG+Qxlw==", + "dev": true, + "license": "MIT", + "dependencies": { + "@yarnpkg/lockfile": "^1.1.0", + "chalk": "^4.1.2", + "ci-info": "^3.7.0", + "cross-spawn": "^7.0.3", + "find-yarn-workspace-root": "^2.0.0", + "fs-extra": "^10.0.0", + "json-stable-stringify": "^1.0.2", + "klaw-sync": "^6.0.0", + "minimist": "^1.2.6", + "open": "^7.4.2", + "semver": "^7.5.3", + "slash": "^2.0.0", + "tmp": "^0.2.4", + "yaml": "^2.2.2" + }, + "bin": { + "patch-package": "index.js" + }, + "engines": { + "node": ">=14", + "npm": ">5" + } + }, + "node_modules/patch-package/node_modules/ci-info": { + "version": "3.9.0", + "resolved": "https://registry.npmjs.org/ci-info/-/ci-info-3.9.0.tgz", + "integrity": "sha512-NIxF55hv4nSqQswkAeiOi1r83xy8JldOFDTWiug55KBu9Jnblncd2U6ViHmYgHf01TPZS77NJBhBMKdWj9HQMQ==", + "dev": true, + "funding": [ + { + "type": "github", + "url": "https://github.com/sponsors/sibiraj-s" + } + ], + "license": "MIT", + "engines": { + "node": ">=8" + } + }, + "node_modules/patch-package/node_modules/fs-extra": { + "version": "10.1.0", + "resolved": "https://registry.npmjs.org/fs-extra/-/fs-extra-10.1.0.tgz", + "integrity": "sha512-oRXApq54ETRj4eMiFzGnHWGy+zo5raudjuxN0b8H7s/RU2oW0Wvsx9O0ACRN/kRq9E8Vu/ReskGB5o3ji+FzHQ==", + "dev": true, + "license": "MIT", + "dependencies": { + "graceful-fs": "^4.2.0", + "jsonfile": "^6.0.1", + "universalify": "^2.0.0" + }, + "engines": { + "node": ">=12" + } + }, + "node_modules/patch-package/node_modules/is-docker": { + "version": "2.2.1", + "resolved": "https://registry.npmjs.org/is-docker/-/is-docker-2.2.1.tgz", + "integrity": "sha512-F+i2BKsFrH66iaUFc0woD8sLy8getkwTwtOBjvs56Cx4CgJDeKQeqfz8wAYiSb8JOprWhHH5p77PbmYCvvUuXQ==", + "dev": true, + "license": "MIT", + "bin": { + "is-docker": "cli.js" + }, + "engines": { + "node": ">=8" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } + }, + "node_modules/patch-package/node_modules/is-wsl": { + "version": "2.2.0", + "resolved": "https://registry.npmjs.org/is-wsl/-/is-wsl-2.2.0.tgz", + "integrity": "sha512-fKzAra0rGJUUBwGBgNkHZuToZcn+TtXHpeCgmkMJMMYx1sQDYaCSyjJBSCa2nH1DGm7s3n1oBnohoVTBaN7Lww==", + "dev": true, + "license": "MIT", + "dependencies": { + "is-docker": "^2.0.0" + }, + "engines": { + "node": ">=8" + } + }, + "node_modules/patch-package/node_modules/open": { + "version": "7.4.2", + "resolved": "https://registry.npmjs.org/open/-/open-7.4.2.tgz", + "integrity": "sha512-MVHddDVweXZF3awtlAS+6pgKLlm/JgxZ90+/NBurBoQctVOOB/zDdVjcyPzQ+0laDGbsWgrRkflI65sQeOgT9Q==", + "dev": true, + "license": "MIT", + "dependencies": { + "is-docker": "^2.0.0", + "is-wsl": "^2.1.1" + }, + "engines": { + "node": ">=8" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } + }, + "node_modules/patch-package/node_modules/semver": { + "version": "7.8.3", + "resolved": "https://registry.npmjs.org/semver/-/semver-7.8.3.tgz", + "integrity": "sha512-wnilbGyMxzbY7dNOl7jpKbLSjcfeweJWU5j4+u5qW+6/wuGD9KzIGOyZnQVSBM9E7DtWaaH3CyHkppYrKYoxwg==", + "dev": true, + "license": "ISC", + "bin": { + "semver": "bin/semver.js" + }, + "engines": { + "node": ">=10" + } + }, + "node_modules/patch-package/node_modules/slash": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/slash/-/slash-2.0.0.tgz", + "integrity": "sha512-ZYKh3Wh2z1PpEXWr0MpSBZ0V6mZHAQfYevttO11c51CaWjGTaadiKZ+wVt1PbMlDV5qhMFslpZCemhwOK7C89A==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=6" + } + }, + "node_modules/patch-package/node_modules/yaml": { + "version": "2.9.0", + "resolved": "https://registry.npmjs.org/yaml/-/yaml-2.9.0.tgz", + "integrity": "sha512-2AvhNX3mb8zd6Zy7INTtSpl1F15HW6Wnqj0srWlkKLcpYl/gMIMJiyuGq2KeI2YFxUPjdlB+3Lc10seMLtL4cA==", + "dev": true, + "license": "ISC", + "bin": { + "yaml": "bin.mjs" + }, + "engines": { + "node": ">= 14.6" + }, + "funding": { + "url": "https://github.com/sponsors/eemeli" + } + }, "node_modules/path-browserify": { "version": "1.0.1", "resolved": "https://registry.npmjs.org/path-browserify/-/path-browserify-1.0.1.tgz", @@ -18404,19 +18657,12 @@ } }, "node_modules/react-error-boundary": { - "version": "3.1.4", - "resolved": "https://registry.npmjs.org/react-error-boundary/-/react-error-boundary-3.1.4.tgz", - "integrity": "sha512-uM9uPzZJTF6wRQORmSrvOIgt4lJ9MC1sNgEOj2XGsDTRE4kmpWxg7ENK9EWNKJRMAOY9z0MuF4yIfl6gp4sotA==", + "version": "6.1.2", + "resolved": "https://registry.npmjs.org/react-error-boundary/-/react-error-boundary-6.1.2.tgz", + "integrity": "sha512-3DpCr5HVdZ0caUjYE/kIHBEJN0mNP3ZCgf16c48uJ5TbWjorKVp+YG8W3XqlJ7vJAVNw6wNIImyPXmFydwmyng==", "license": "MIT", - "dependencies": { - "@babel/runtime": "^7.12.5" - }, - "engines": { - "node": ">=10", - "npm": ">=6" - }, "peerDependencies": { - "react": ">=16.13.1" + "react": "^18.0.0 || ^19.0.0" } }, "node_modules/react-is": { @@ -21115,6 +21361,16 @@ "valibot": "^1.1.0" } }, + "node_modules/tmp": { + "version": "0.2.7", + "resolved": "https://registry.npmjs.org/tmp/-/tmp-0.2.7.tgz", + "integrity": "sha512-e0votIpp4Uo2AJYSzVHV6xCcawuiez3DzqDAbrTc3YxBkplN6e+dM13ZeIcZnDg/QpSuU2zfZ3rzwY8ukEnaXw==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=14.14" + } + }, "node_modules/tmpl": { "version": "1.0.5", "resolved": "https://registry.npmjs.org/tmpl/-/tmpl-1.0.5.tgz", @@ -23060,9 +23316,9 @@ } }, "node_modules/yjs": { - "version": "13.6.30", - "resolved": "https://registry.npmjs.org/yjs/-/yjs-13.6.30.tgz", - "integrity": "sha512-vv/9h42eCMC81ZHDFswuu/MKzkl/vyq1BhaNGfHyOonwlG4CJbQF4oiBBJPvfdeCt/PlVDWh7Nov9D34YY09uQ==", + "version": "13.6.31", + "resolved": "https://registry.npmjs.org/yjs/-/yjs-13.6.31.tgz", + "integrity": "sha512-Eq+5BRfbeGyqGVrTJL3bEcr8gKkxPuyuoHmAwpk52fDb8kOVMrfVSTRPd6yiGgX5Fskb96qCRjzjbRjrL4YEnw==", "license": "MIT", "peer": true, "dependencies": { diff --git a/package.json b/package.json index 1d635b95..9416187f 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@bsf/force-ui", - "version": "1.7.11", + "version": "1.7.12", "description": "Library of components for the BSF project", "main": "./dist/force-ui.cjs.js", "module": "./dist/force-ui.es.js", @@ -42,7 +42,8 @@ "build-storybook": "storybook build", "chromatic": "npx chromatic --project-token $CHROMATIC_PROJECT_TOKEN", "package": "sh bin/build.sh", - "release": "npm run build && npm run package " + "release": "npm run build && npm run package ", + "postinstall": "patch-package" }, "repository": { "type": "git", @@ -64,14 +65,16 @@ "dependencies": { "@emotion/is-prop-valid": "^1.3.0", "@floating-ui/react": "^0.26.28", - "@lexical/react": "^0.31.2", - "@lexical/selection": "^0.31.2", - "@lexical/utils": "^0.31.2", + "@lexical/clipboard": "0.38.2", + "@lexical/react": "0.38.2", + "@lexical/selection": "0.38.2", + "@lexical/table": "0.38.2", + "@lexical/utils": "0.38.2", "clsx": "^2.1.1", "date-fns": "^4.1.0", "deepmerge": "^4.3.1", "framer-motion": "^12.34.3", - "lexical": "^0.31.2", + "lexical": "0.38.2", "lucide-react": "^0.417.0", "nanoid": "^5.0.7", "react-day-picker": "^9.1.3", @@ -101,6 +104,8 @@ "@types/react-dom": "^18.3.0", "@typescript-eslint/eslint-plugin": "^8.11.0", "@vitejs/plugin-react": "^4.3.2", + "@vitest/browser-playwright": "^4.1.1", + "@vitest/coverage-v8": "^4.1.1", "@wordpress/eslint-plugin": "^20.3.0", "@wordpress/prettier-config": "^4.4.0", "@wordpress/stylelint-config": "^23.2.0", @@ -119,6 +124,8 @@ "gulp-cli": "^3.0.0", "gulp-replace": "^1.1.4", "inquirer": "^12.4.1", + "patch-package": "^8.0.1", + "playwright": "^1.58.2", "postcss": "^8.4.39", "prettier": "^3.2.5", "rollup-preserve-directives": "^1.1.2", @@ -130,10 +137,7 @@ "typescript-eslint": "^8.7.0", "vite": "^5.4.21", "vite-plugin-dts": "^4.2.3", - "vitest": "^4.1.1", - "playwright": "^1.58.2", - "@vitest/browser-playwright": "^4.1.1", - "@vitest/coverage-v8": "^4.1.1" + "vitest": "^4.1.1" }, "browserslist": [ "last 1 version", diff --git a/patches/@lexical+clipboard+0.38.2.patch b/patches/@lexical+clipboard+0.38.2.patch new file mode 100644 index 00000000..6e404826 --- /dev/null +++ b/patches/@lexical+clipboard+0.38.2.patch @@ -0,0 +1,79 @@ +diff --git a/node_modules/@lexical/clipboard/LexicalClipboard.dev.js b/node_modules/@lexical/clipboard/LexicalClipboard.dev.js +index f9f95b7..67d8c01 100644 +--- a/node_modules/@lexical/clipboard/LexicalClipboard.dev.js ++++ b/node_modules/@lexical/clipboard/LexicalClipboard.dev.js +@@ -341,9 +341,9 @@ async function copyToClipboard(editor, event, data) { + }); + } + const rootElement = editor.getRootElement(); +- const editorWindow = editor._window || window; ++ const editorWindow = lexical.getWindow(editor); + const windowDocument = editorWindow.document; +- const domSelection = lexical.getDOMSelection(editorWindow); ++ const domSelection = lexical.getDOMSelectionForEditor(editor); + if (rootElement === null || domSelection === null) { + return false; + } +@@ -384,7 +384,7 @@ async function copyToClipboard(editor, event, data) { + // TODO shouldn't pass editor (pass namespace directly) + function $copyToClipboardEvent(editor, event, data) { + if (data === undefined) { +- const domSelection = lexical.getDOMSelection(editor._window); ++ const domSelection = lexical.getDOMSelectionForEditor(editor); + const selection = lexical.$getSelection(); + if (!selection || selection.isCollapsed()) { + return false; +diff --git a/node_modules/@lexical/clipboard/LexicalClipboard.dev.mjs b/node_modules/@lexical/clipboard/LexicalClipboard.dev.mjs +index 4977d85..af61100 100644 +--- a/node_modules/@lexical/clipboard/LexicalClipboard.dev.mjs ++++ b/node_modules/@lexical/clipboard/LexicalClipboard.dev.mjs +@@ -9,7 +9,7 @@ + import { $generateHtmlFromNodes, $generateNodesFromDOM } from '@lexical/html'; + import { $addNodeStyle, $sliceSelectedTextNodeContent } from '@lexical/selection'; + import { objectKlassEquals } from '@lexical/utils'; +-import { $getSelection, $isRangeSelection, $createTabNode, SELECTION_INSERT_CLIPBOARD_NODES_COMMAND, $caretFromPoint, $isTextPointCaret, $getCaretRange, $getChildCaret, $getRoot, $isTextNode, $isElementNode, $parseSerializedNode, getDOMSelection, COPY_COMMAND, COMMAND_PRIORITY_CRITICAL, isSelectionWithinEditor, $getEditor } from 'lexical'; ++import { $getSelection, $isRangeSelection, $createTabNode, SELECTION_INSERT_CLIPBOARD_NODES_COMMAND, $caretFromPoint, $isTextPointCaret, $getCaretRange, $getChildCaret, $getRoot, $isTextNode, $isElementNode, $parseSerializedNode, getWindow, getDOMSelectionForEditor, COPY_COMMAND, COMMAND_PRIORITY_CRITICAL, isSelectionWithinEditor, $getEditor } from 'lexical'; + + /** + * Copyright (c) Meta Platforms, Inc. and affiliates. +@@ -339,9 +339,9 @@ async function copyToClipboard(editor, event, data) { + }); + } + const rootElement = editor.getRootElement(); +- const editorWindow = editor._window || window; ++ const editorWindow = getWindow(editor); + const windowDocument = editorWindow.document; +- const domSelection = getDOMSelection(editorWindow); ++ const domSelection = getDOMSelectionForEditor(editor); + if (rootElement === null || domSelection === null) { + return false; + } +@@ -382,7 +382,7 @@ async function copyToClipboard(editor, event, data) { + // TODO shouldn't pass editor (pass namespace directly) + function $copyToClipboardEvent(editor, event, data) { + if (data === undefined) { +- const domSelection = getDOMSelection(editor._window); ++ const domSelection = getDOMSelectionForEditor(editor); + const selection = $getSelection(); + if (!selection || selection.isCollapsed()) { + return false; +diff --git a/node_modules/@lexical/clipboard/LexicalClipboard.prod.js b/node_modules/@lexical/clipboard/LexicalClipboard.prod.js +index df656d8..0865d78 100644 +--- a/node_modules/@lexical/clipboard/LexicalClipboard.prod.js ++++ b/node_modules/@lexical/clipboard/LexicalClipboard.prod.js +@@ -6,4 +6,4 @@ + * + */ + +-"use strict";var e=require("@lexical/html"),t=require("@lexical/selection"),n=require("@lexical/utils"),o=require("lexical");function r(e,...t){const n=new URL("https://lexical.dev/docs/error"),o=new URLSearchParams;o.append("code",e);for(const e of t)o.append("v",e);throw n.search=o.toString(),Error(`Minified Lexical error #${e}; visit ${n.toString()} for the full message or use the non-minified dev environment for full errors and additional helpful warnings.`)}function i(t,n=o.$getSelection()){return null==n&&r(166),o.$isRangeSelection(n)&&n.isCollapsed()||0===n.getNodes().length?"":e.$generateHtmlFromNodes(t,n)}function l(e,t=o.$getSelection()){return null==t&&r(166),o.$isRangeSelection(t)&&t.isCollapsed()||0===t.getNodes().length?null:JSON.stringify(c(e,t))}function s(e,t,n){e.dispatchCommand(o.SELECTION_INSERT_CLIPBOARD_NODES_COMMAND,{nodes:t,selection:n})||(n.insertNodes(t),function(e){if(o.$isRangeSelection(e)&&e.isCollapsed()){const t=e.anchor;let n=null;const r=o.$caretFromPoint(t,"previous");if(r)if(o.$isTextPointCaret(r))n=r.origin;else{const e=o.$getCaretRange(r,o.$getChildCaret(o.$getRoot(),"next").getFlipped());for(const t of e){if(o.$isTextNode(t.origin)){n=t.origin;break}if(o.$isElementNode(t.origin)&&!t.origin.isInline())break}}if(n&&o.$isTextNode(n)){const t=n.getFormat(),o=n.getStyle();e.format===t&&e.style===o||(e.format=t,e.style=o,e.dirty=!0)}}}(n))}function a(e,n,i,l=[]){let s=null===n||i.isSelected(n);const c=o.$isElementNode(i)&&i.excludeFromCopy("html");let d=i;null!==n&&o.$isTextNode(d)&&(d=t.$sliceSelectedTextNodeContent(n,d,"clone"));const u=o.$isElementNode(d)?d.getChildren():[],f=function(e){const t=e.exportJSON(),n=e.constructor;if(t.type!==n.getType()&&r(58,n.name),o.$isElementNode(e)){const e=t.children;Array.isArray(e)||r(59,n.name)}return t}(d);o.$isTextNode(d)&&0===d.getTextContentSize()&&(s=!1);for(let t=0;te}).createHTML(e)}return e}(l),"text/html");return s(r,e.$generateNodesFromDOM(r,t),n)}catch(e){console.error(e)}const c=a||t.getData("text/uri-list");if(null!=c)if(o.$isRangeSelection(n)){const e=c.split(/(\r?\n|\t)/);""===e[e.length-1]&&e.pop();for(let t=0;t{e.update(()=>{n(f(e,t,r))})});const i=e.getRootElement(),l=e._window||window,s=l.document,a=o.getDOMSelection(l);if(null===i||null===a)return!1;const c=s.createElement("span");c.style.cssText="position: fixed; top: -1000px;",c.append(s.createTextNode("#")),i.append(c);const d=new Range;return d.setStart(c,0),d.setEnd(c,1),a.removeAllRanges(),a.addRange(d),new Promise((t,i)=>{const a=e.registerCommand(o.COPY_COMMAND,o=>(n.objectKlassEquals(o,ClipboardEvent)&&(a(),null!==u&&(l.clearTimeout(u),u=null),t(f(e,o,r))),!0),o.COMMAND_PRIORITY_CRITICAL);u=l.setTimeout(()=>{a(),u=null,t(!1)},50),s.execCommand("copy"),c.remove()})},exports.setLexicalClipboardDataTransfer=x; ++"use strict";var e=require("@lexical/html"),t=require("@lexical/selection"),n=require("@lexical/utils"),o=require("lexical");function r(e,...t){const n=new URL("https://lexical.dev/docs/error"),o=new URLSearchParams;o.append("code",e);for(const e of t)o.append("v",e);throw n.search=o.toString(),Error(`Minified Lexical error #${e}; visit ${n.toString()} for the full message or use the non-minified dev environment for full errors and additional helpful warnings.`)}function i(t,n=o.$getSelection()){return null==n&&r(166),o.$isRangeSelection(n)&&n.isCollapsed()||0===n.getNodes().length?"":e.$generateHtmlFromNodes(t,n)}function l(e,t=o.$getSelection()){return null==t&&r(166),o.$isRangeSelection(t)&&t.isCollapsed()||0===t.getNodes().length?null:JSON.stringify(c(e,t))}function s(e,t,n){e.dispatchCommand(o.SELECTION_INSERT_CLIPBOARD_NODES_COMMAND,{nodes:t,selection:n})||(n.insertNodes(t),function(e){if(o.$isRangeSelection(e)&&e.isCollapsed()){const t=e.anchor;let n=null;const r=o.$caretFromPoint(t,"previous");if(r)if(o.$isTextPointCaret(r))n=r.origin;else{const e=o.$getCaretRange(r,o.$getChildCaret(o.$getRoot(),"next").getFlipped());for(const t of e){if(o.$isTextNode(t.origin)){n=t.origin;break}if(o.$isElementNode(t.origin)&&!t.origin.isInline())break}}if(n&&o.$isTextNode(n)){const t=n.getFormat(),o=n.getStyle();e.format===t&&e.style===o||(e.format=t,e.style=o,e.dirty=!0)}}}(n))}function a(e,n,i,l=[]){let s=null===n||i.isSelected(n);const c=o.$isElementNode(i)&&i.excludeFromCopy("html");let d=i;null!==n&&o.$isTextNode(d)&&(d=t.$sliceSelectedTextNodeContent(n,d,"clone"));const u=o.$isElementNode(d)?d.getChildren():[],f=function(e){const t=e.exportJSON(),n=e.constructor;if(t.type!==n.getType()&&r(58,n.name),o.$isElementNode(e)){const e=t.children;Array.isArray(e)||r(59,n.name)}return t}(d);o.$isTextNode(d)&&0===d.getTextContentSize()&&(s=!1);for(let t=0;te}).createHTML(e)}return e}(l),"text/html");return s(r,e.$generateNodesFromDOM(r,t),n)}catch(e){console.error(e)}const c=a||t.getData("text/uri-list");if(null!=c)if(o.$isRangeSelection(n)){const e=c.split(/(\r?\n|\t)/);""===e[e.length-1]&&e.pop();for(let t=0;t{e.update(()=>{n(f(e,t,r))})});const i=e.getRootElement(),l=o.getWindow(e),s=l.document,a=o.getDOMSelectionForEditor(e);if(null===i||null===a)return!1;const c=s.createElement("span");c.style.cssText="position: fixed; top: -1000px;",c.append(s.createTextNode("#")),i.append(c);const d=new Range;return d.setStart(c,0),d.setEnd(c,1),a.removeAllRanges(),a.addRange(d),new Promise((t,i)=>{const a=e.registerCommand(o.COPY_COMMAND,o=>(n.objectKlassEquals(o,ClipboardEvent)&&(a(),null!==u&&(l.clearTimeout(u),u=null),t(f(e,o,r))),!0),o.COMMAND_PRIORITY_CRITICAL);u=l.setTimeout(()=>{a(),u=null,t(!1)},50),s.execCommand("copy"),c.remove()})},exports.setLexicalClipboardDataTransfer=x; +diff --git a/node_modules/@lexical/clipboard/LexicalClipboard.prod.mjs b/node_modules/@lexical/clipboard/LexicalClipboard.prod.mjs +index 0151ee9..9010373 100644 +--- a/node_modules/@lexical/clipboard/LexicalClipboard.prod.mjs ++++ b/node_modules/@lexical/clipboard/LexicalClipboard.prod.mjs +@@ -6,4 +6,4 @@ + * + */ + +-import{$generateHtmlFromNodes as t,$generateNodesFromDOM as e}from"@lexical/html";import{$addNodeStyle as n,$sliceSelectedTextNodeContent as o}from"@lexical/selection";import{objectKlassEquals as r}from"@lexical/utils";import{$getSelection as i,$isRangeSelection as l,$createTabNode as s,SELECTION_INSERT_CLIPBOARD_NODES_COMMAND as c,$caretFromPoint as a,$isTextPointCaret as u,$getCaretRange as f,$getChildCaret as d,$getRoot as p,$isTextNode as g,$isElementNode as m,$parseSerializedNode as h,getDOMSelection as x,COPY_COMMAND as y,COMMAND_PRIORITY_CRITICAL as w,isSelectionWithinEditor as T,$getEditor as C}from"lexical";function v(t,...e){const n=new URL("https://lexical.dev/docs/error"),o=new URLSearchParams;o.append("code",t);for(const t of e)o.append("v",t);throw n.search=o.toString(),Error(`Minified Lexical error #${t}; visit ${n.toString()} for the full message or use the non-minified dev environment for full errors and additional helpful warnings.`)}function D(e,n=i()){return null==n&&v(166),l(n)&&n.isCollapsed()||0===n.getNodes().length?"":t(e,n)}function S(t,e=i()){return null==e&&v(166),l(e)&&e.isCollapsed()||0===e.getNodes().length?null:JSON.stringify(E(t,e))}function N(t,e){const n=t.getData("text/plain")||t.getData("text/uri-list");null!=n&&e.insertRawText(n)}function R(t,n,o){const r=t.getData("application/x-lexical-editor");if(r)try{const t=JSON.parse(r);if(t.namespace===o._config.namespace&&Array.isArray(t.nodes)){return A(o,L(t.nodes),n)}}catch(t){console.error(t)}const c=t.getData("text/html"),a=t.getData("text/plain");if(c&&a!==c)try{const t=(new DOMParser).parseFromString(function(t){if(window.trustedTypes&&window.trustedTypes.createPolicy){return window.trustedTypes.createPolicy("lexical",{createHTML:t=>t}).createHTML(t)}return t}(c),"text/html");return A(o,e(o,t),n)}catch(t){console.error(t)}const u=a||t.getData("text/uri-list");if(null!=u)if(l(n)){const t=u.split(/(\r?\n|\t)/);""===t[t.length-1]&&t.pop();for(let e=0;e{t.update(()=>{o(M(t,e,n))})});const o=t.getRootElement(),i=t._window||window,l=i.document,s=x(i);if(null===o||null===s)return!1;const c=l.createElement("span");c.style.cssText="position: fixed; top: -1000px;",c.append(l.createTextNode("#")),o.append(c);const a=new Range;return a.setStart(c,0),a.setEnd(c,1),s.removeAllRanges(),s.addRange(a),new Promise((e,o)=>{const s=t.registerCommand(y,o=>(r(o,ClipboardEvent)&&(s(),null!==b&&(i.clearTimeout(b),b=null),e(M(t,o,n))),!0),w);b=i.setTimeout(()=>{s(),b=null,e(!1)},50),l.execCommand("copy"),c.remove()})}function M(t,e,n){if(void 0===n){const e=x(t._window),o=i();if(!o||o.isCollapsed())return!1;if(!e)return!1;const r=e.anchorNode,l=e.focusNode;if(null!==r&&null!==l&&!T(t,r,l))return!1;n=_(o)}e.preventDefault();const o=e.clipboardData;return null!==o&&(J(o,n),!0)}const O=[["text/html",D],["application/x-lexical-editor",S]];function _(t=i()){const e={"text/plain":t?t.getTextContent():""};if(t){const n=C();for(const[o,r]of O){const i=r(n,t);null!==i&&(e[o]=i)}}return e}function J(t,e){for(const[n]of O)void 0===e[n]&&t.setData(n,"");for(const n in e){const o=e[n];void 0!==o&&t.setData(n,o)}}export{E as $generateJSONFromSelectedNodes,L as $generateNodesFromSerializedNodes,_ as $getClipboardDataFromSelection,D as $getHtmlContent,S as $getLexicalContent,N as $insertDataTransferForPlainText,R as $insertDataTransferForRichText,A as $insertGeneratedNodes,F as copyToClipboard,J as setLexicalClipboardDataTransfer}; ++import{$generateHtmlFromNodes as t,$generateNodesFromDOM as e}from"@lexical/html";import{$addNodeStyle as n,$sliceSelectedTextNodeContent as o}from"@lexical/selection";import{objectKlassEquals as r}from"@lexical/utils";import{$getSelection as i,$isRangeSelection as l,$createTabNode as s,SELECTION_INSERT_CLIPBOARD_NODES_COMMAND as c,$caretFromPoint as a,$isTextPointCaret as u,$getCaretRange as f,$getChildCaret as d,$getRoot as p,$isTextNode as g,$isElementNode as m,$parseSerializedNode as h,getWindow as x,getDOMSelectionForEditor as y,COPY_COMMAND as w,COMMAND_PRIORITY_CRITICAL as T,isSelectionWithinEditor as C,$getEditor as v}from"lexical";function D(t,...e){const n=new URL("https://lexical.dev/docs/error"),o=new URLSearchParams;o.append("code",t);for(const t of e)o.append("v",t);throw n.search=o.toString(),Error(`Minified Lexical error #${t}; visit ${n.toString()} for the full message or use the non-minified dev environment for full errors and additional helpful warnings.`)}function S(e,n=i()){return null==n&&D(166),l(n)&&n.isCollapsed()||0===n.getNodes().length?"":t(e,n)}function N(t,e=i()){return null==e&&D(166),l(e)&&e.isCollapsed()||0===e.getNodes().length?null:JSON.stringify(L(t,e))}function R(t,e){const n=t.getData("text/plain")||t.getData("text/uri-list");null!=n&&e.insertRawText(n)}function A(t,n,o){const r=t.getData("application/x-lexical-editor");if(r)try{const t=JSON.parse(r);if(t.namespace===o._config.namespace&&Array.isArray(t.nodes)){return P(o,b(t.nodes),n)}}catch(t){console.error(t)}const c=t.getData("text/html"),a=t.getData("text/plain");if(c&&a!==c)try{const t=(new DOMParser).parseFromString(function(t){if(window.trustedTypes&&window.trustedTypes.createPolicy){return window.trustedTypes.createPolicy("lexical",{createHTML:t=>t}).createHTML(t)}return t}(c),"text/html");return P(o,e(o,t),n)}catch(t){console.error(t)}const u=a||t.getData("text/uri-list");if(null!=u)if(l(n)){const t=u.split(/(\r?\n|\t)/);""===t[t.length-1]&&t.pop();for(let e=0;e{t.update(()=>{o(O(t,e,n))})});const o=t.getRootElement(),i=x(t),l=i.document,s=y(t);if(null===o||null===s)return!1;const c=l.createElement("span");c.style.cssText="position: fixed; top: -1000px;",c.append(l.createTextNode("#")),o.append(c);const a=new Range;return a.setStart(c,0),a.setEnd(c,1),s.removeAllRanges(),s.addRange(a),new Promise((e,o)=>{const s=t.registerCommand(w,o=>(r(o,ClipboardEvent)&&(s(),null!==F&&(i.clearTimeout(F),F=null),e(O(t,o,n))),!0),T);F=i.setTimeout(()=>{s(),F=null,e(!1)},50),l.execCommand("copy"),c.remove()})}function O(t,e,n){if(void 0===n){const e=y(t),o=i();if(!o||o.isCollapsed())return!1;if(!e)return!1;const r=e.anchorNode,l=e.focusNode;if(null!==r&&null!==l&&!C(t,r,l))return!1;n=k(o)}e.preventDefault();const o=e.clipboardData;return null!==o&&(H(o,n),!0)}const J=[["text/html",S],["application/x-lexical-editor",N]];function k(t=i()){const e={"text/plain":t?t.getTextContent():""};if(t){const n=v();for(const[o,r]of J){const i=r(n,t);null!==i&&(e[o]=i)}}return e}function H(t,e){for(const[n]of J)void 0===e[n]&&t.setData(n,"");for(const n in e){const o=e[n];void 0!==o&&t.setData(n,o)}}export{L as $generateJSONFromSelectedNodes,b as $generateNodesFromSerializedNodes,k as $getClipboardDataFromSelection,S as $getHtmlContent,N as $getLexicalContent,R as $insertDataTransferForPlainText,A as $insertDataTransferForRichText,P as $insertGeneratedNodes,M as copyToClipboard,H as setLexicalClipboardDataTransfer}; diff --git a/patches/@lexical+react+0.38.2.patch b/patches/@lexical+react+0.38.2.patch new file mode 100644 index 00000000..af96e1f1 --- /dev/null +++ b/patches/@lexical+react+0.38.2.patch @@ -0,0 +1,2146 @@ +diff --git a/node_modules/@lexical/react/LexicalAutoEmbedPlugin.d.ts b/node_modules/@lexical/react/LexicalAutoEmbedPlugin.d.ts +index 1abdfa6..4cb519d 100644 +--- a/node_modules/@lexical/react/LexicalAutoEmbedPlugin.d.ts ++++ b/node_modules/@lexical/react/LexicalAutoEmbedPlugin.d.ts +@@ -7,7 +7,7 @@ + */ + import type { CommandListenerPriority, LexicalNode } from 'lexical'; + import type { JSX } from 'react'; +-import { MenuOption, MenuRenderFn } from '@lexical/react/LexicalNodeMenuPlugin'; ++import { MenuOption } from '@lexical/react/LexicalNodeMenuPlugin'; + import { LexicalCommand, LexicalEditor } from 'lexical'; + export type EmbedMatchResult = { + url: string; +@@ -32,8 +32,7 @@ type LexicalAutoEmbedPluginProps = { + embedConfigs: Array; + onOpenEmbedModalForConfig: (embedConfig: TEmbedConfig) => void; + getMenuOptions: (activeEmbedConfig: TEmbedConfig, embedFn: () => void, dismissFn: () => void) => Array; +- menuRenderFn: MenuRenderFn; + menuCommandPriority?: CommandListenerPriority; + }; +-export declare function LexicalAutoEmbedPlugin({ embedConfigs, onOpenEmbedModalForConfig, getMenuOptions, menuRenderFn, menuCommandPriority, }: LexicalAutoEmbedPluginProps): JSX.Element | null; ++export declare function LexicalAutoEmbedPlugin({ embedConfigs, onOpenEmbedModalForConfig, getMenuOptions, menuCommandPriority, }: LexicalAutoEmbedPluginProps): JSX.Element | null; + export {}; +diff --git a/node_modules/@lexical/react/LexicalAutoEmbedPlugin.dev.js b/node_modules/@lexical/react/LexicalAutoEmbedPlugin.dev.js +index ef822a0..31b7b6c 100644 +--- a/node_modules/@lexical/react/LexicalAutoEmbedPlugin.dev.js ++++ b/node_modules/@lexical/react/LexicalAutoEmbedPlugin.dev.js +@@ -39,7 +39,6 @@ function LexicalAutoEmbedPlugin({ + embedConfigs, + onOpenEmbedModalForConfig, + getMenuOptions, +- menuRenderFn, + menuCommandPriority = lexical.COMMAND_PRIORITY_LOW + }) { + const [editor] = LexicalComposerContext.useLexicalComposerContext(); +@@ -135,7 +134,6 @@ function LexicalAutoEmbedPlugin({ + onClose: reset, + onSelectOption: onSelectOption, + options: options, +- menuRenderFn: menuRenderFn, + commandPriority: menuCommandPriority + }) : null; + } +diff --git a/node_modules/@lexical/react/LexicalAutoEmbedPlugin.dev.mjs b/node_modules/@lexical/react/LexicalAutoEmbedPlugin.dev.mjs +index 745e0d6..18d4ed8 100644 +--- a/node_modules/@lexical/react/LexicalAutoEmbedPlugin.dev.mjs ++++ b/node_modules/@lexical/react/LexicalAutoEmbedPlugin.dev.mjs +@@ -37,7 +37,6 @@ function LexicalAutoEmbedPlugin({ + embedConfigs, + onOpenEmbedModalForConfig, + getMenuOptions, +- menuRenderFn, + menuCommandPriority = COMMAND_PRIORITY_LOW + }) { + const [editor] = useLexicalComposerContext(); +@@ -133,7 +132,6 @@ function LexicalAutoEmbedPlugin({ + onClose: reset, + onSelectOption: onSelectOption, + options: options, +- menuRenderFn: menuRenderFn, + commandPriority: menuCommandPriority + }) : null; + } +diff --git a/node_modules/@lexical/react/LexicalAutoEmbedPlugin.js.flow b/node_modules/@lexical/react/LexicalAutoEmbedPlugin.js.flow +index b30259d..d44fe47 100644 +--- a/node_modules/@lexical/react/LexicalAutoEmbedPlugin.js.flow ++++ b/node_modules/@lexical/react/LexicalAutoEmbedPlugin.js.flow +@@ -13,7 +13,6 @@ import {MenuOption} from '@lexical/react/LexicalTypeaheadMenuPlugin'; + import type {LexicalCommand, LexicalEditor, NodeKey, TextNode} from 'lexical'; + import * as React from 'react'; + import {createCommand} from 'lexical'; +-import type {MenuRenderFn} from './LexicalTypeaheadMenuPlugin'; + + export type EmbedMatchResult = { + url: string, +@@ -43,7 +42,6 @@ type LexicalAutoEmbedPluginProps = { + embedFn: () => void, + dismissFn: () => void, + ) => Array, +- menuRenderFn: MenuRenderFn, + }; + + declare export class AutoEmbedOption extends MenuOption { +diff --git a/node_modules/@lexical/react/LexicalAutoEmbedPlugin.prod.js b/node_modules/@lexical/react/LexicalAutoEmbedPlugin.prod.js +index c410388..5f91054 100644 +--- a/node_modules/@lexical/react/LexicalAutoEmbedPlugin.prod.js ++++ b/node_modules/@lexical/react/LexicalAutoEmbedPlugin.prod.js +@@ -6,4 +6,4 @@ + * + */ + +-"use strict";var e=require("@lexical/link"),t=require("@lexical/react/LexicalComposerContext"),n=require("@lexical/react/LexicalNodeMenuPlugin"),o=require("@lexical/utils"),i=require("lexical"),l=require("react"),r=require("react/jsx-runtime");const s=i.createCommand("INSERT_EMBED_COMMAND");class u extends n.MenuOption{title;onSelect;constructor(e,t){super(e),this.title=e,this.onSelect=t.onSelect.bind(this)}}exports.AutoEmbedOption=u,exports.INSERT_EMBED_COMMAND=s,exports.LexicalAutoEmbedPlugin=function({embedConfigs:u,onOpenEmbedModalForConfig:a,getMenuOptions:c,menuRenderFn:d,menuCommandPriority:m=i.COMMAND_PRIORITY_LOW}){const[p]=t.useLexicalComposerContext(),[x,C]=l.useState(null),[f,M]=l.useState(null),g=l.useCallback(()=>{C(null),M(null)},[]),E=l.useCallback(async t=>{const n=p.getEditorState().read(function(){const n=i.$getNodeByKey(t);if(e.$isLinkNode(n))return n.getURL()});if(void 0!==n)for(const e of u){null!=await Promise.resolve(e.parseUrl(n))&&(M(e),C(t))}},[p,u]);l.useEffect(()=>o.mergeRegister(...[e.LinkNode,e.AutoLinkNode].map(e=>p.registerMutationListener(e,(...e)=>((e,{updateTags:t,dirtyLeaves:n})=>{for(const[o,l]of e)"created"===l&&t.has(i.PASTE_TAG)&&n.size<=3?E(o):o===x&&g()})(...e),{skipInitialization:!0}))),[E,p,u,x,g]),l.useEffect(()=>p.registerCommand(s,e=>{const t=u.find(({type:t})=>t===e);return!!t&&(a(t),!0)},i.COMMAND_PRIORITY_EDITOR),[p,u,a]);const N=l.useCallback(async function(){if(null!=f&&null!=x){const t=p.getEditorState().read(()=>{const t=i.$getNodeByKey(x);return e.$isLinkNode(t)?t:null});if(e.$isLinkNode(t)){const e=await Promise.resolve(f.parseUrl(t.__url));null!=e&&p.update(()=>{i.$getSelection()||t.selectEnd(),f.insertNode(p,e),t.isAttached()&&t.remove()})}}},[f,p,x]),L=l.useMemo(()=>null!=f&&null!=x?c(f,N,g):[],[f,N,c,x,g]),A=l.useCallback((e,t,n)=>{p.update(()=>{e.onSelect(t),n()})},[p]);return null!=x?r.jsx(n.LexicalNodeMenuPlugin,{nodeKey:x,onClose:g,onSelectOption:A,options:L,menuRenderFn:d,commandPriority:m}):null},exports.URL_MATCHER=/((https?:\/\/(www\.)?)|(www\.))[-a-zA-Z0-9@:%._+~#=]{1,256}\.[a-zA-Z0-9()]{1,6}\b([-a-zA-Z0-9()@:%_+.~#?&//=]*)/; ++"use strict";var e=require("@lexical/link"),t=require("@lexical/react/LexicalComposerContext"),n=require("@lexical/react/LexicalNodeMenuPlugin"),o=require("@lexical/utils"),i=require("lexical"),l=require("react"),r=require("react/jsx-runtime");const s=i.createCommand("INSERT_EMBED_COMMAND");class a extends n.MenuOption{title;onSelect;constructor(e,t){super(e),this.title=e,this.onSelect=t.onSelect.bind(this)}}exports.AutoEmbedOption=a,exports.INSERT_EMBED_COMMAND=s,exports.LexicalAutoEmbedPlugin=function({embedConfigs:a,onOpenEmbedModalForConfig:u,getMenuOptions:c,menuCommandPriority:d=i.COMMAND_PRIORITY_LOW}){const[m]=t.useLexicalComposerContext(),[p,x]=l.useState(null),[C,f]=l.useState(null),M=l.useCallback(()=>{x(null),f(null)},[]),g=l.useCallback(async t=>{const n=m.getEditorState().read(function(){const n=i.$getNodeByKey(t);if(e.$isLinkNode(n))return n.getURL()});if(void 0!==n)for(const e of a){null!=await Promise.resolve(e.parseUrl(n))&&(f(e),x(t))}},[m,a]);l.useEffect(()=>o.mergeRegister(...[e.LinkNode,e.AutoLinkNode].map(e=>m.registerMutationListener(e,(...e)=>((e,{updateTags:t,dirtyLeaves:n})=>{for(const[o,l]of e)"created"===l&&t.has(i.PASTE_TAG)&&n.size<=3?g(o):o===p&&M()})(...e),{skipInitialization:!0}))),[g,m,a,p,M]),l.useEffect(()=>m.registerCommand(s,e=>{const t=a.find(({type:t})=>t===e);return!!t&&(u(t),!0)},i.COMMAND_PRIORITY_EDITOR),[m,a,u]);const E=l.useCallback(async function(){if(null!=C&&null!=p){const t=m.getEditorState().read(()=>{const t=i.$getNodeByKey(p);return e.$isLinkNode(t)?t:null});if(e.$isLinkNode(t)){const e=await Promise.resolve(C.parseUrl(t.__url));null!=e&&m.update(()=>{i.$getSelection()||t.selectEnd(),C.insertNode(m,e),t.isAttached()&&t.remove()})}}},[C,m,p]),N=l.useMemo(()=>null!=C&&null!=p?c(C,E,M):[],[C,E,c,p,M]),L=l.useCallback((e,t,n)=>{m.update(()=>{e.onSelect(t),n()})},[m]);return null!=p?r.jsx(n.LexicalNodeMenuPlugin,{nodeKey:p,onClose:M,onSelectOption:L,options:N,commandPriority:d}):null},exports.URL_MATCHER=/((https?:\/\/(www\.)?)|(www\.))[-a-zA-Z0-9@:%._+~#=]{1,256}\.[a-zA-Z0-9()]{1,6}\b([-a-zA-Z0-9()@:%_+.~#?&//=]*)/; +diff --git a/node_modules/@lexical/react/LexicalAutoEmbedPlugin.prod.mjs b/node_modules/@lexical/react/LexicalAutoEmbedPlugin.prod.mjs +index bbb95b1..f9c8a22 100644 +--- a/node_modules/@lexical/react/LexicalAutoEmbedPlugin.prod.mjs ++++ b/node_modules/@lexical/react/LexicalAutoEmbedPlugin.prod.mjs +@@ -6,4 +6,4 @@ + * + */ + +-import{$isLinkNode as e,LinkNode as t,AutoLinkNode as n}from"@lexical/link";import{useLexicalComposerContext as o}from"@lexical/react/LexicalComposerContext";import{MenuOption as r,LexicalNodeMenuPlugin as i}from"@lexical/react/LexicalNodeMenuPlugin";import{mergeRegister as l}from"@lexical/utils";import{createCommand as s,$getNodeByKey as a,COMMAND_PRIORITY_EDITOR as c,$getSelection as u,COMMAND_PRIORITY_LOW as m,PASTE_TAG as d}from"lexical";import{useState as p,useCallback as f,useEffect as x,useMemo as g}from"react";import{jsx as w}from"react/jsx-runtime";const C=/((https?:\/\/(www\.)?)|(www\.))[-a-zA-Z0-9@:%._+~#=]{1,256}\.[a-zA-Z0-9()]{1,6}\b([-a-zA-Z0-9()@:%_+.~#?&//=]*)/,S=s("INSERT_EMBED_COMMAND");class y extends r{title;onSelect;constructor(e,t){super(e),this.title=e,this.onSelect=t.onSelect.bind(this)}}function E({embedConfigs:r,onOpenEmbedModalForConfig:s,getMenuOptions:C,menuRenderFn:y,menuCommandPriority:E=m}){const[M]=o(),[h,_]=p(null),[v,z]=p(null),A=f(()=>{_(null),z(null)},[]),L=f(async t=>{const n=M.getEditorState().read(function(){const n=a(t);if(e(n))return n.getURL()});if(void 0!==n)for(const e of r){null!=await Promise.resolve(e.parseUrl(n))&&(z(e),_(t))}},[M,r]);x(()=>l(...[t,n].map(e=>M.registerMutationListener(e,(...e)=>((e,{updateTags:t,dirtyLeaves:n})=>{for(const[o,r]of e)"created"===r&&t.has(d)&&n.size<=3?L(o):o===h&&A()})(...e),{skipInitialization:!0}))),[L,M,r,h,A]),x(()=>M.registerCommand(S,e=>{const t=r.find(({type:t})=>t===e);return!!t&&(s(t),!0)},c),[M,r,s]);const P=f(async function(){if(null!=v&&null!=h){const t=M.getEditorState().read(()=>{const t=a(h);return e(t)?t:null});if(e(t)){const e=await Promise.resolve(v.parseUrl(t.__url));null!=e&&M.update(()=>{u()||t.selectEnd(),v.insertNode(M,e),t.isAttached()&&t.remove()})}}},[v,M,h]),b=g(()=>null!=v&&null!=h?C(v,P,A):[],[v,P,C,h,A]),N=f((e,t,n)=>{M.update(()=>{e.onSelect(t),n()})},[M]);return null!=h?w(i,{nodeKey:h,onClose:A,onSelectOption:N,options:b,menuRenderFn:y,commandPriority:E}):null}export{y as AutoEmbedOption,S as INSERT_EMBED_COMMAND,E as LexicalAutoEmbedPlugin,C as URL_MATCHER}; ++import{$isLinkNode as t,LinkNode as e,AutoLinkNode as o}from"@lexical/link";import{useLexicalComposerContext as n}from"@lexical/react/LexicalComposerContext";import{MenuOption as i,LexicalNodeMenuPlugin as r}from"@lexical/react/LexicalNodeMenuPlugin";import{mergeRegister as l}from"@lexical/utils";import{createCommand as s,$getNodeByKey as a,COMMAND_PRIORITY_EDITOR as c,$getSelection as u,COMMAND_PRIORITY_LOW as m,PASTE_TAG as d}from"lexical";import{useState as p,useCallback as f,useEffect as x,useMemo as g}from"react";import{jsx as w}from"react/jsx-runtime";const C=/((https?:\/\/(www\.)?)|(www\.))[-a-zA-Z0-9@:%._+~#=]{1,256}\.[a-zA-Z0-9()]{1,6}\b([-a-zA-Z0-9()@:%_+.~#?&//=]*)/,S=s("INSERT_EMBED_COMMAND");class y extends i{title;onSelect;constructor(t,e){super(t),this.title=t,this.onSelect=e.onSelect.bind(this)}}function E({embedConfigs:i,onOpenEmbedModalForConfig:s,getMenuOptions:C,menuCommandPriority:y=m}){const[E]=n(),[M,h]=p(null),[_,v]=p(null),z=f(()=>{h(null),v(null)},[]),A=f(async e=>{const o=E.getEditorState().read(function(){const o=a(e);if(t(o))return o.getURL()});if(void 0!==o)for(const t of i){null!=await Promise.resolve(t.parseUrl(o))&&(v(t),h(e))}},[E,i]);x(()=>l(...[e,o].map(t=>E.registerMutationListener(t,(...t)=>((t,{updateTags:e,dirtyLeaves:o})=>{for(const[n,i]of t)"created"===i&&e.has(d)&&o.size<=3?A(n):n===M&&z()})(...t),{skipInitialization:!0}))),[A,E,i,M,z]),x(()=>E.registerCommand(S,t=>{const e=i.find(({type:e})=>e===t);return!!e&&(s(e),!0)},c),[E,i,s]);const L=f(async function(){if(null!=_&&null!=M){const e=E.getEditorState().read(()=>{const e=a(M);return t(e)?e:null});if(t(e)){const t=await Promise.resolve(_.parseUrl(e.__url));null!=t&&E.update(()=>{u()||e.selectEnd(),_.insertNode(E,t),e.isAttached()&&e.remove()})}}},[_,E,M]),P=g(()=>null!=_&&null!=M?C(_,L,z):[],[_,L,C,M,z]),b=f((t,e,o)=>{E.update(()=>{t.onSelect(e),o()})},[E]);return null!=M?w(r,{nodeKey:M,onClose:z,onSelectOption:b,options:P,commandPriority:y}):null}export{y as AutoEmbedOption,S as INSERT_EMBED_COMMAND,E as LexicalAutoEmbedPlugin,C as URL_MATCHER}; +diff --git a/node_modules/@lexical/react/LexicalContextMenuPlugin.d.ts b/node_modules/@lexical/react/LexicalContextMenuPlugin.d.ts +deleted file mode 100644 +index 5958fef..0000000 +--- a/node_modules/@lexical/react/LexicalContextMenuPlugin.d.ts ++++ /dev/null +@@ -1,36 +0,0 @@ +-/** +- * 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. +- * +- */ +-import type { MenuRenderFn, MenuResolution } from './shared/LexicalMenu'; +-import type { JSX } from 'react'; +-import { CommandListenerPriority, LexicalNode } from 'lexical'; +-import { ReactPortal, RefObject } from 'react'; +-import { MenuOption } from './shared/LexicalMenu'; +-export type ContextMenuRenderFn = (anchorElementRef: RefObject, itemProps: { +- selectedIndex: number | null; +- selectOptionAndCleanUp: (option: TOption) => void; +- setHighlightedIndex: (index: number) => void; +- options: Array; +-}, menuProps: { +- setMenuRef: (element: HTMLElement | null) => void; +-}) => ReactPortal | JSX.Element | null; +-export type LexicalContextMenuPluginProps = { +- onSelectOption: (option: TOption, textNodeContainingQuery: LexicalNode | null, closeMenu: () => void, matchingString: string) => void; +- options: Array; +- onClose?: () => void; +- onWillOpen?: (event: MouseEvent) => void; +- onOpen?: (resolution: MenuResolution) => void; +- menuRenderFn: ContextMenuRenderFn; +- anchorClassName?: string; +- commandPriority?: CommandListenerPriority; +- parent?: HTMLElement; +-}; +-/** +- * @deprecated Use LexicalNodeContextMenuPlugin instead. +- */ +-export declare function LexicalContextMenuPlugin({ options, onWillOpen, onClose, onOpen, onSelectOption, menuRenderFn: contextMenuRenderFn, anchorClassName, commandPriority, parent, }: LexicalContextMenuPluginProps): JSX.Element | null; +-export { MenuOption, MenuRenderFn, MenuResolution }; +diff --git a/node_modules/@lexical/react/LexicalContextMenuPlugin.dev.js b/node_modules/@lexical/react/LexicalContextMenuPlugin.dev.js +deleted file mode 100644 +index 1afd361..0000000 +--- a/node_modules/@lexical/react/LexicalContextMenuPlugin.dev.js ++++ /dev/null +@@ -1,524 +0,0 @@ +-/** +- * 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. +- * +- */ +- +-'use strict'; +- +-var LexicalComposerContext = require('@lexical/react/LexicalComposerContext'); +-var utils = require('@lexical/utils'); +-var lexical = require('lexical'); +-var React = require('react'); +-var jsxRuntime = require('react/jsx-runtime'); +- +-function _interopNamespaceDefault(e) { +- var n = Object.create(null); +- if (e) { +- for (var k in e) { +- n[k] = e[k]; +- } +- } +- n.default = e; +- return n; +-} +- +-var React__namespace = /*#__PURE__*/_interopNamespaceDefault(React); +- +-/** +- * 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. +- * +- */ +- +-const CAN_USE_DOM = typeof window !== 'undefined' && typeof window.document !== 'undefined' && typeof window.document.createElement !== 'undefined'; +- +-/** +- * 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. +- * +- */ +- +- +-// This workaround is no longer necessary in React 19, +-// but we currently support React >=17.x +-// https://github.com/facebook/react/pull/26395 +-const useLayoutEffectImpl = CAN_USE_DOM ? React.useLayoutEffect : React.useEffect; +- +-/** +- * 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. +- * +- */ +- +-class MenuOption { +- key; +- ref; +- constructor(key) { +- this.key = key; +- this.ref = { +- current: null +- }; +- this.setRefElement = this.setRefElement.bind(this); +- } +- setRefElement(element) { +- this.ref = { +- current: element +- }; +- } +-} +-const scrollIntoViewIfNeeded = target => { +- const typeaheadContainerNode = document.getElementById('typeahead-menu'); +- if (!typeaheadContainerNode) { +- return; +- } +- const typeaheadRect = typeaheadContainerNode.getBoundingClientRect(); +- if (typeaheadRect.top + typeaheadRect.height > window.innerHeight) { +- typeaheadContainerNode.scrollIntoView({ +- block: 'center' +- }); +- } +- if (typeaheadRect.top < 0) { +- typeaheadContainerNode.scrollIntoView({ +- block: 'center' +- }); +- } +- target.scrollIntoView({ +- block: 'nearest' +- }); +-}; +- +-/** +- * Walk backwards along user input and forward through entity title to try +- * and replace more of the user's text with entity. +- */ +-function getFullMatchOffset(documentText, entryText, offset) { +- let triggerOffset = offset; +- for (let i = triggerOffset; i <= entryText.length; i++) { +- if (documentText.slice(-i) === entryText.substring(0, i)) { +- triggerOffset = i; +- } +- } +- return triggerOffset; +-} +- +-/** +- * Split Lexical TextNode and return a new TextNode only containing matched text. +- * Common use cases include: removing the node, replacing with a new node. +- */ +-function $splitNodeContainingQuery(match) { +- const selection = lexical.$getSelection(); +- if (!lexical.$isRangeSelection(selection) || !selection.isCollapsed()) { +- return null; +- } +- const anchor = selection.anchor; +- if (anchor.type !== 'text') { +- return null; +- } +- const anchorNode = anchor.getNode(); +- if (!anchorNode.isSimpleText()) { +- return null; +- } +- const selectionOffset = anchor.offset; +- const textContent = anchorNode.getTextContent().slice(0, selectionOffset); +- const characterOffset = match.replaceableString.length; +- const queryOffset = getFullMatchOffset(textContent, match.matchingString, characterOffset); +- const startOffset = selectionOffset - queryOffset; +- if (startOffset < 0) { +- return null; +- } +- let newNode; +- if (startOffset === 0) { +- [newNode] = anchorNode.splitText(selectionOffset); +- } else { +- [, newNode] = anchorNode.splitText(startOffset, selectionOffset); +- } +- return newNode; +-} +- +-// Got from https://stackoverflow.com/a/42543908/2013580 +-function getScrollParent(element, includeHidden) { +- let style = getComputedStyle(element); +- const excludeStaticParent = style.position === 'absolute'; +- const overflowRegex = /(auto|scroll)/; +- if (style.position === 'fixed') { +- return document.body; +- } +- for (let parent = element; parent = parent.parentElement;) { +- style = getComputedStyle(parent); +- if (excludeStaticParent && style.position === 'static') { +- continue; +- } +- if (overflowRegex.test(style.overflow + style.overflowY + style.overflowX)) { +- return parent; +- } +- } +- return document.body; +-} +-function isTriggerVisibleInNearestScrollContainer(targetElement, containerElement) { +- const tRect = targetElement.getBoundingClientRect(); +- const cRect = containerElement.getBoundingClientRect(); +- const VISIBILITY_MARGIN_PX = 6; +- return tRect.top >= cRect.top - VISIBILITY_MARGIN_PX && tRect.top <= cRect.bottom + VISIBILITY_MARGIN_PX; +-} +- +-// Reposition the menu on scroll, window resize, and element resize. +-function useDynamicPositioning(resolution, targetElement, onReposition, onVisibilityChange) { +- const [editor] = LexicalComposerContext.useLexicalComposerContext(); +- React.useEffect(() => { +- if (targetElement != null && resolution != null) { +- const rootElement = editor.getRootElement(); +- const rootScrollParent = rootElement != null ? getScrollParent(rootElement) : document.body; +- let ticking = false; +- let previousIsInView = isTriggerVisibleInNearestScrollContainer(targetElement, rootScrollParent); +- const handleScroll = function () { +- if (!ticking) { +- window.requestAnimationFrame(function () { +- onReposition(); +- ticking = false; +- }); +- ticking = true; +- } +- const isInView = isTriggerVisibleInNearestScrollContainer(targetElement, rootScrollParent); +- if (isInView !== previousIsInView) { +- previousIsInView = isInView; +- if (onVisibilityChange != null) { +- onVisibilityChange(isInView); +- } +- } +- }; +- const resizeObserver = new ResizeObserver(onReposition); +- window.addEventListener('resize', onReposition); +- document.addEventListener('scroll', handleScroll, { +- capture: true, +- passive: true +- }); +- resizeObserver.observe(targetElement); +- return () => { +- resizeObserver.unobserve(targetElement); +- window.removeEventListener('resize', onReposition); +- document.removeEventListener('scroll', handleScroll, true); +- }; +- } +- }, [targetElement, editor, onVisibilityChange, onReposition, resolution]); +-} +-const SCROLL_TYPEAHEAD_OPTION_INTO_VIEW_COMMAND = lexical.createCommand('SCROLL_TYPEAHEAD_OPTION_INTO_VIEW_COMMAND'); +-function LexicalMenu({ +- close, +- editor, +- anchorElementRef, +- resolution, +- options, +- menuRenderFn, +- onSelectOption, +- shouldSplitNodeWithQuery = false, +- commandPriority = lexical.COMMAND_PRIORITY_LOW, +- preselectFirstItem = true +-}) { +- const [rawSelectedIndex, setHighlightedIndex] = React.useState(null); +- // Clamp highlighted index if options list shrinks +- const selectedIndex = rawSelectedIndex !== null ? Math.min(options.length - 1, rawSelectedIndex) : null; +- const matchingString = resolution.match && resolution.match.matchingString; +- React.useEffect(() => { +- if (preselectFirstItem) { +- setHighlightedIndex(0); +- } +- }, [matchingString, preselectFirstItem]); +- const selectOptionAndCleanUp = React.useCallback(selectedEntry => { +- editor.update(() => { +- const textNodeContainingQuery = resolution.match != null && shouldSplitNodeWithQuery ? $splitNodeContainingQuery(resolution.match) : null; +- onSelectOption(selectedEntry, textNodeContainingQuery, close, resolution.match ? resolution.match.matchingString : ''); +- }); +- }, [editor, shouldSplitNodeWithQuery, resolution.match, onSelectOption, close]); +- const updateSelectedIndex = React.useCallback(index => { +- const rootElem = editor.getRootElement(); +- if (rootElem !== null) { +- rootElem.setAttribute('aria-activedescendant', 'typeahead-item-' + index); +- setHighlightedIndex(index); +- } +- }, [editor]); +- React.useEffect(() => { +- return () => { +- const rootElem = editor.getRootElement(); +- if (rootElem !== null) { +- rootElem.removeAttribute('aria-activedescendant'); +- } +- }; +- }, [editor]); +- useLayoutEffectImpl(() => { +- if (options === null) { +- setHighlightedIndex(null); +- } else if (selectedIndex === null && preselectFirstItem) { +- updateSelectedIndex(0); +- } +- }, [options, selectedIndex, updateSelectedIndex, preselectFirstItem]); +- React.useEffect(() => { +- return utils.mergeRegister(editor.registerCommand(SCROLL_TYPEAHEAD_OPTION_INTO_VIEW_COMMAND, ({ +- option +- }) => { +- if (option.ref && option.ref.current != null) { +- scrollIntoViewIfNeeded(option.ref.current); +- return true; +- } +- return false; +- }, commandPriority)); +- }, [editor, updateSelectedIndex, commandPriority]); +- React.useEffect(() => { +- return utils.mergeRegister(editor.registerCommand(lexical.KEY_ARROW_DOWN_COMMAND, payload => { +- const event = payload; +- if (options !== null && options.length) { +- const newSelectedIndex = selectedIndex === null ? 0 : selectedIndex !== options.length - 1 ? selectedIndex + 1 : 0; +- updateSelectedIndex(newSelectedIndex); +- const option = options[newSelectedIndex]; +- if (!option) { +- updateSelectedIndex(-1); +- event.preventDefault(); +- event.stopImmediatePropagation(); +- return true; +- } +- if (option.ref && option.ref.current) { +- editor.dispatchCommand(SCROLL_TYPEAHEAD_OPTION_INTO_VIEW_COMMAND, { +- index: newSelectedIndex, +- option +- }); +- } +- event.preventDefault(); +- event.stopImmediatePropagation(); +- } +- return true; +- }, commandPriority), editor.registerCommand(lexical.KEY_ARROW_UP_COMMAND, payload => { +- const event = payload; +- if (options !== null && options.length) { +- const newSelectedIndex = selectedIndex === null ? options.length - 1 : selectedIndex !== 0 ? selectedIndex - 1 : options.length - 1; +- updateSelectedIndex(newSelectedIndex); +- const option = options[newSelectedIndex]; +- if (!option) { +- updateSelectedIndex(-1); +- event.preventDefault(); +- event.stopImmediatePropagation(); +- return true; +- } +- if (option.ref && option.ref.current) { +- scrollIntoViewIfNeeded(option.ref.current); +- } +- event.preventDefault(); +- event.stopImmediatePropagation(); +- } +- return true; +- }, commandPriority), editor.registerCommand(lexical.KEY_ESCAPE_COMMAND, payload => { +- const event = payload; +- event.preventDefault(); +- event.stopImmediatePropagation(); +- close(); +- return true; +- }, commandPriority), editor.registerCommand(lexical.KEY_TAB_COMMAND, payload => { +- const event = payload; +- if (options === null || selectedIndex === null || options[selectedIndex] == null) { +- return false; +- } +- event.preventDefault(); +- event.stopImmediatePropagation(); +- selectOptionAndCleanUp(options[selectedIndex]); +- return true; +- }, commandPriority), editor.registerCommand(lexical.KEY_ENTER_COMMAND, event => { +- if (options === null || selectedIndex === null || options[selectedIndex] == null) { +- return false; +- } +- if (event !== null) { +- event.preventDefault(); +- event.stopImmediatePropagation(); +- } +- selectOptionAndCleanUp(options[selectedIndex]); +- return true; +- }, commandPriority)); +- }, [selectOptionAndCleanUp, close, editor, options, selectedIndex, updateSelectedIndex, commandPriority]); +- const listItemProps = React.useMemo(() => ({ +- options, +- selectOptionAndCleanUp, +- selectedIndex, +- setHighlightedIndex +- }), [selectOptionAndCleanUp, selectedIndex, options]); +- return menuRenderFn(anchorElementRef, listItemProps, resolution.match ? resolution.match.matchingString : ''); +-} +-function setContainerDivAttributes(containerDiv, className) { +- if (className != null) { +- containerDiv.className = className; +- } +- containerDiv.setAttribute('aria-label', 'Typeahead menu'); +- containerDiv.setAttribute('role', 'listbox'); +- containerDiv.style.display = 'block'; +- containerDiv.style.position = 'absolute'; +-} +-function useMenuAnchorRef(resolution, setResolution, className, parent = CAN_USE_DOM ? document.body : undefined, shouldIncludePageYOffset__EXPERIMENTAL = true) { +- const [editor] = LexicalComposerContext.useLexicalComposerContext(); +- const initialAnchorElement = CAN_USE_DOM ? document.createElement('div') : null; +- const anchorElementRef = React.useRef(initialAnchorElement); +- const positionMenu = React.useCallback(() => { +- if (anchorElementRef.current === null || parent === undefined) { +- return; +- } +- anchorElementRef.current.style.top = anchorElementRef.current.style.bottom; +- const rootElement = editor.getRootElement(); +- const containerDiv = anchorElementRef.current; +- const menuEle = containerDiv.firstChild; +- if (rootElement !== null && resolution !== null) { +- const { +- left, +- top, +- width, +- height +- } = resolution.getRect(); +- const anchorHeight = anchorElementRef.current.offsetHeight; // use to position under anchor +- containerDiv.style.top = `${top + anchorHeight + 3 + (shouldIncludePageYOffset__EXPERIMENTAL ? window.pageYOffset : 0)}px`; +- containerDiv.style.left = `${left + window.pageXOffset}px`; +- containerDiv.style.height = `${height}px`; +- containerDiv.style.width = `${width}px`; +- if (menuEle !== null) { +- menuEle.style.top = `${top}`; +- const menuRect = menuEle.getBoundingClientRect(); +- const menuHeight = menuRect.height; +- const menuWidth = menuRect.width; +- const rootElementRect = rootElement.getBoundingClientRect(); +- if (left + menuWidth > rootElementRect.right) { +- containerDiv.style.left = `${rootElementRect.right - menuWidth + window.pageXOffset}px`; +- } +- if ((top + menuHeight > window.innerHeight || top + menuHeight > rootElementRect.bottom) && top - rootElementRect.top > menuHeight + height) { +- containerDiv.style.top = `${top - menuHeight - height + (shouldIncludePageYOffset__EXPERIMENTAL ? window.pageYOffset : 0)}px`; +- } +- } +- if (!containerDiv.isConnected) { +- setContainerDivAttributes(containerDiv, className); +- parent.append(containerDiv); +- } +- containerDiv.setAttribute('id', 'typeahead-menu'); +- rootElement.setAttribute('aria-controls', 'typeahead-menu'); +- } +- }, [editor, resolution, shouldIncludePageYOffset__EXPERIMENTAL, className, parent]); +- React.useEffect(() => { +- const rootElement = editor.getRootElement(); +- if (resolution !== null) { +- positionMenu(); +- } +- return () => { +- if (rootElement !== null) { +- rootElement.removeAttribute('aria-controls'); +- } +- // eslint-disable-next-line react-hooks/exhaustive-deps +- const containerDiv = anchorElementRef.current; +- if (containerDiv !== null && containerDiv.isConnected) { +- containerDiv.remove(); +- containerDiv.removeAttribute('id'); +- } +- }; +- }, [editor, positionMenu, resolution]); +- const onVisibilityChange = React.useCallback(isInView => { +- if (resolution !== null) { +- if (!isInView) { +- setResolution(null); +- } +- } +- }, [resolution, setResolution]); +- useDynamicPositioning(resolution, anchorElementRef.current, positionMenu, onVisibilityChange); +- +- // Append the context for the menu immediately +- if (initialAnchorElement != null && initialAnchorElement === anchorElementRef.current) { +- setContainerDivAttributes(initialAnchorElement, className); +- if (parent != null) { +- parent.append(initialAnchorElement); +- } +- } +- return anchorElementRef; +-} +- +-/** +- * 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. +- * +- */ +- +-const PRE_PORTAL_DIV_SIZE = 1; +- +-/** +- * @deprecated Use LexicalNodeContextMenuPlugin instead. +- */ +-function LexicalContextMenuPlugin({ +- options, +- onWillOpen, +- onClose, +- onOpen, +- onSelectOption, +- menuRenderFn: contextMenuRenderFn, +- anchorClassName, +- commandPriority = lexical.COMMAND_PRIORITY_LOW, +- parent +-}) { +- const [editor] = LexicalComposerContext.useLexicalComposerContext(); +- const [resolution, setResolution] = React.useState(null); +- const menuRef = React__namespace.useRef(null); +- const anchorElementRef = useMenuAnchorRef(resolution, setResolution, anchorClassName, parent); +- const closeNodeMenu = React.useCallback(() => { +- setResolution(null); +- if (onClose != null && resolution !== null) { +- onClose(); +- } +- }, [onClose, resolution]); +- const openNodeMenu = React.useCallback(res => { +- setResolution(res); +- if (onOpen != null && resolution === null) { +- onOpen(res); +- } +- }, [onOpen, resolution]); +- const handleContextMenu = React.useCallback(event => { +- event.preventDefault(); +- if (onWillOpen != null) { +- onWillOpen(event); +- } +- const zoom = utils.calculateZoomLevel(event.target); +- openNodeMenu({ +- getRect: () => new DOMRect(event.clientX / zoom, event.clientY / zoom, PRE_PORTAL_DIV_SIZE, PRE_PORTAL_DIV_SIZE) +- }); +- }, [openNodeMenu, onWillOpen]); +- const handleClick = React.useCallback(event => { +- if (resolution !== null && menuRef.current != null && event.target != null && lexical.isDOMNode(event.target) && !menuRef.current.contains(event.target)) { +- closeNodeMenu(); +- } +- }, [closeNodeMenu, resolution]); +- React.useEffect(() => { +- const editorElement = editor.getRootElement(); +- if (editorElement) { +- editorElement.addEventListener('contextmenu', handleContextMenu); +- return () => editorElement.removeEventListener('contextmenu', handleContextMenu); +- } +- }, [editor, handleContextMenu]); +- React.useEffect(() => { +- document.addEventListener('click', handleClick); +- return () => document.removeEventListener('click', handleClick); +- }, [editor, handleClick]); +- return anchorElementRef.current === null || resolution === null || editor === null ? null : /*#__PURE__*/jsxRuntime.jsx(LexicalMenu, { +- close: closeNodeMenu, +- resolution: resolution, +- editor: editor, +- anchorElementRef: anchorElementRef, +- options: options, +- menuRenderFn: (anchorRef, itemProps) => contextMenuRenderFn(anchorRef, itemProps, { +- setMenuRef: ref => { +- menuRef.current = ref; +- } +- }), +- onSelectOption: onSelectOption, +- commandPriority: commandPriority +- }); +-} +- +-exports.LexicalContextMenuPlugin = LexicalContextMenuPlugin; +-exports.MenuOption = MenuOption; +diff --git a/node_modules/@lexical/react/LexicalContextMenuPlugin.dev.mjs b/node_modules/@lexical/react/LexicalContextMenuPlugin.dev.mjs +deleted file mode 100644 +index 3214b3a..0000000 +--- a/node_modules/@lexical/react/LexicalContextMenuPlugin.dev.mjs ++++ /dev/null +@@ -1,509 +0,0 @@ +-/** +- * 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. +- * +- */ +- +-import { useLexicalComposerContext } from '@lexical/react/LexicalComposerContext'; +-import { mergeRegister, calculateZoomLevel } from '@lexical/utils'; +-import { createCommand, COMMAND_PRIORITY_LOW, KEY_ARROW_DOWN_COMMAND, KEY_ARROW_UP_COMMAND, KEY_ESCAPE_COMMAND, KEY_TAB_COMMAND, KEY_ENTER_COMMAND, $getSelection, $isRangeSelection, isDOMNode } from 'lexical'; +-import * as React from 'react'; +-import { useLayoutEffect, useEffect, useRef, useCallback, useState, useMemo } from 'react'; +-import { jsx } from 'react/jsx-runtime'; +- +-/** +- * 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. +- * +- */ +- +-const CAN_USE_DOM = typeof window !== 'undefined' && typeof window.document !== 'undefined' && typeof window.document.createElement !== 'undefined'; +- +-/** +- * 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. +- * +- */ +- +- +-// This workaround is no longer necessary in React 19, +-// but we currently support React >=17.x +-// https://github.com/facebook/react/pull/26395 +-const useLayoutEffectImpl = CAN_USE_DOM ? useLayoutEffect : useEffect; +- +-/** +- * 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. +- * +- */ +- +-class MenuOption { +- key; +- ref; +- constructor(key) { +- this.key = key; +- this.ref = { +- current: null +- }; +- this.setRefElement = this.setRefElement.bind(this); +- } +- setRefElement(element) { +- this.ref = { +- current: element +- }; +- } +-} +-const scrollIntoViewIfNeeded = target => { +- const typeaheadContainerNode = document.getElementById('typeahead-menu'); +- if (!typeaheadContainerNode) { +- return; +- } +- const typeaheadRect = typeaheadContainerNode.getBoundingClientRect(); +- if (typeaheadRect.top + typeaheadRect.height > window.innerHeight) { +- typeaheadContainerNode.scrollIntoView({ +- block: 'center' +- }); +- } +- if (typeaheadRect.top < 0) { +- typeaheadContainerNode.scrollIntoView({ +- block: 'center' +- }); +- } +- target.scrollIntoView({ +- block: 'nearest' +- }); +-}; +- +-/** +- * Walk backwards along user input and forward through entity title to try +- * and replace more of the user's text with entity. +- */ +-function getFullMatchOffset(documentText, entryText, offset) { +- let triggerOffset = offset; +- for (let i = triggerOffset; i <= entryText.length; i++) { +- if (documentText.slice(-i) === entryText.substring(0, i)) { +- triggerOffset = i; +- } +- } +- return triggerOffset; +-} +- +-/** +- * Split Lexical TextNode and return a new TextNode only containing matched text. +- * Common use cases include: removing the node, replacing with a new node. +- */ +-function $splitNodeContainingQuery(match) { +- const selection = $getSelection(); +- if (!$isRangeSelection(selection) || !selection.isCollapsed()) { +- return null; +- } +- const anchor = selection.anchor; +- if (anchor.type !== 'text') { +- return null; +- } +- const anchorNode = anchor.getNode(); +- if (!anchorNode.isSimpleText()) { +- return null; +- } +- const selectionOffset = anchor.offset; +- const textContent = anchorNode.getTextContent().slice(0, selectionOffset); +- const characterOffset = match.replaceableString.length; +- const queryOffset = getFullMatchOffset(textContent, match.matchingString, characterOffset); +- const startOffset = selectionOffset - queryOffset; +- if (startOffset < 0) { +- return null; +- } +- let newNode; +- if (startOffset === 0) { +- [newNode] = anchorNode.splitText(selectionOffset); +- } else { +- [, newNode] = anchorNode.splitText(startOffset, selectionOffset); +- } +- return newNode; +-} +- +-// Got from https://stackoverflow.com/a/42543908/2013580 +-function getScrollParent(element, includeHidden) { +- let style = getComputedStyle(element); +- const excludeStaticParent = style.position === 'absolute'; +- const overflowRegex = /(auto|scroll)/; +- if (style.position === 'fixed') { +- return document.body; +- } +- for (let parent = element; parent = parent.parentElement;) { +- style = getComputedStyle(parent); +- if (excludeStaticParent && style.position === 'static') { +- continue; +- } +- if (overflowRegex.test(style.overflow + style.overflowY + style.overflowX)) { +- return parent; +- } +- } +- return document.body; +-} +-function isTriggerVisibleInNearestScrollContainer(targetElement, containerElement) { +- const tRect = targetElement.getBoundingClientRect(); +- const cRect = containerElement.getBoundingClientRect(); +- const VISIBILITY_MARGIN_PX = 6; +- return tRect.top >= cRect.top - VISIBILITY_MARGIN_PX && tRect.top <= cRect.bottom + VISIBILITY_MARGIN_PX; +-} +- +-// Reposition the menu on scroll, window resize, and element resize. +-function useDynamicPositioning(resolution, targetElement, onReposition, onVisibilityChange) { +- const [editor] = useLexicalComposerContext(); +- useEffect(() => { +- if (targetElement != null && resolution != null) { +- const rootElement = editor.getRootElement(); +- const rootScrollParent = rootElement != null ? getScrollParent(rootElement) : document.body; +- let ticking = false; +- let previousIsInView = isTriggerVisibleInNearestScrollContainer(targetElement, rootScrollParent); +- const handleScroll = function () { +- if (!ticking) { +- window.requestAnimationFrame(function () { +- onReposition(); +- ticking = false; +- }); +- ticking = true; +- } +- const isInView = isTriggerVisibleInNearestScrollContainer(targetElement, rootScrollParent); +- if (isInView !== previousIsInView) { +- previousIsInView = isInView; +- if (onVisibilityChange != null) { +- onVisibilityChange(isInView); +- } +- } +- }; +- const resizeObserver = new ResizeObserver(onReposition); +- window.addEventListener('resize', onReposition); +- document.addEventListener('scroll', handleScroll, { +- capture: true, +- passive: true +- }); +- resizeObserver.observe(targetElement); +- return () => { +- resizeObserver.unobserve(targetElement); +- window.removeEventListener('resize', onReposition); +- document.removeEventListener('scroll', handleScroll, true); +- }; +- } +- }, [targetElement, editor, onVisibilityChange, onReposition, resolution]); +-} +-const SCROLL_TYPEAHEAD_OPTION_INTO_VIEW_COMMAND = createCommand('SCROLL_TYPEAHEAD_OPTION_INTO_VIEW_COMMAND'); +-function LexicalMenu({ +- close, +- editor, +- anchorElementRef, +- resolution, +- options, +- menuRenderFn, +- onSelectOption, +- shouldSplitNodeWithQuery = false, +- commandPriority = COMMAND_PRIORITY_LOW, +- preselectFirstItem = true +-}) { +- const [rawSelectedIndex, setHighlightedIndex] = useState(null); +- // Clamp highlighted index if options list shrinks +- const selectedIndex = rawSelectedIndex !== null ? Math.min(options.length - 1, rawSelectedIndex) : null; +- const matchingString = resolution.match && resolution.match.matchingString; +- useEffect(() => { +- if (preselectFirstItem) { +- setHighlightedIndex(0); +- } +- }, [matchingString, preselectFirstItem]); +- const selectOptionAndCleanUp = useCallback(selectedEntry => { +- editor.update(() => { +- const textNodeContainingQuery = resolution.match != null && shouldSplitNodeWithQuery ? $splitNodeContainingQuery(resolution.match) : null; +- onSelectOption(selectedEntry, textNodeContainingQuery, close, resolution.match ? resolution.match.matchingString : ''); +- }); +- }, [editor, shouldSplitNodeWithQuery, resolution.match, onSelectOption, close]); +- const updateSelectedIndex = useCallback(index => { +- const rootElem = editor.getRootElement(); +- if (rootElem !== null) { +- rootElem.setAttribute('aria-activedescendant', 'typeahead-item-' + index); +- setHighlightedIndex(index); +- } +- }, [editor]); +- useEffect(() => { +- return () => { +- const rootElem = editor.getRootElement(); +- if (rootElem !== null) { +- rootElem.removeAttribute('aria-activedescendant'); +- } +- }; +- }, [editor]); +- useLayoutEffectImpl(() => { +- if (options === null) { +- setHighlightedIndex(null); +- } else if (selectedIndex === null && preselectFirstItem) { +- updateSelectedIndex(0); +- } +- }, [options, selectedIndex, updateSelectedIndex, preselectFirstItem]); +- useEffect(() => { +- return mergeRegister(editor.registerCommand(SCROLL_TYPEAHEAD_OPTION_INTO_VIEW_COMMAND, ({ +- option +- }) => { +- if (option.ref && option.ref.current != null) { +- scrollIntoViewIfNeeded(option.ref.current); +- return true; +- } +- return false; +- }, commandPriority)); +- }, [editor, updateSelectedIndex, commandPriority]); +- useEffect(() => { +- return mergeRegister(editor.registerCommand(KEY_ARROW_DOWN_COMMAND, payload => { +- const event = payload; +- if (options !== null && options.length) { +- const newSelectedIndex = selectedIndex === null ? 0 : selectedIndex !== options.length - 1 ? selectedIndex + 1 : 0; +- updateSelectedIndex(newSelectedIndex); +- const option = options[newSelectedIndex]; +- if (!option) { +- updateSelectedIndex(-1); +- event.preventDefault(); +- event.stopImmediatePropagation(); +- return true; +- } +- if (option.ref && option.ref.current) { +- editor.dispatchCommand(SCROLL_TYPEAHEAD_OPTION_INTO_VIEW_COMMAND, { +- index: newSelectedIndex, +- option +- }); +- } +- event.preventDefault(); +- event.stopImmediatePropagation(); +- } +- return true; +- }, commandPriority), editor.registerCommand(KEY_ARROW_UP_COMMAND, payload => { +- const event = payload; +- if (options !== null && options.length) { +- const newSelectedIndex = selectedIndex === null ? options.length - 1 : selectedIndex !== 0 ? selectedIndex - 1 : options.length - 1; +- updateSelectedIndex(newSelectedIndex); +- const option = options[newSelectedIndex]; +- if (!option) { +- updateSelectedIndex(-1); +- event.preventDefault(); +- event.stopImmediatePropagation(); +- return true; +- } +- if (option.ref && option.ref.current) { +- scrollIntoViewIfNeeded(option.ref.current); +- } +- event.preventDefault(); +- event.stopImmediatePropagation(); +- } +- return true; +- }, commandPriority), editor.registerCommand(KEY_ESCAPE_COMMAND, payload => { +- const event = payload; +- event.preventDefault(); +- event.stopImmediatePropagation(); +- close(); +- return true; +- }, commandPriority), editor.registerCommand(KEY_TAB_COMMAND, payload => { +- const event = payload; +- if (options === null || selectedIndex === null || options[selectedIndex] == null) { +- return false; +- } +- event.preventDefault(); +- event.stopImmediatePropagation(); +- selectOptionAndCleanUp(options[selectedIndex]); +- return true; +- }, commandPriority), editor.registerCommand(KEY_ENTER_COMMAND, event => { +- if (options === null || selectedIndex === null || options[selectedIndex] == null) { +- return false; +- } +- if (event !== null) { +- event.preventDefault(); +- event.stopImmediatePropagation(); +- } +- selectOptionAndCleanUp(options[selectedIndex]); +- return true; +- }, commandPriority)); +- }, [selectOptionAndCleanUp, close, editor, options, selectedIndex, updateSelectedIndex, commandPriority]); +- const listItemProps = useMemo(() => ({ +- options, +- selectOptionAndCleanUp, +- selectedIndex, +- setHighlightedIndex +- }), [selectOptionAndCleanUp, selectedIndex, options]); +- return menuRenderFn(anchorElementRef, listItemProps, resolution.match ? resolution.match.matchingString : ''); +-} +-function setContainerDivAttributes(containerDiv, className) { +- if (className != null) { +- containerDiv.className = className; +- } +- containerDiv.setAttribute('aria-label', 'Typeahead menu'); +- containerDiv.setAttribute('role', 'listbox'); +- containerDiv.style.display = 'block'; +- containerDiv.style.position = 'absolute'; +-} +-function useMenuAnchorRef(resolution, setResolution, className, parent = CAN_USE_DOM ? document.body : undefined, shouldIncludePageYOffset__EXPERIMENTAL = true) { +- const [editor] = useLexicalComposerContext(); +- const initialAnchorElement = CAN_USE_DOM ? document.createElement('div') : null; +- const anchorElementRef = useRef(initialAnchorElement); +- const positionMenu = useCallback(() => { +- if (anchorElementRef.current === null || parent === undefined) { +- return; +- } +- anchorElementRef.current.style.top = anchorElementRef.current.style.bottom; +- const rootElement = editor.getRootElement(); +- const containerDiv = anchorElementRef.current; +- const menuEle = containerDiv.firstChild; +- if (rootElement !== null && resolution !== null) { +- const { +- left, +- top, +- width, +- height +- } = resolution.getRect(); +- const anchorHeight = anchorElementRef.current.offsetHeight; // use to position under anchor +- containerDiv.style.top = `${top + anchorHeight + 3 + (shouldIncludePageYOffset__EXPERIMENTAL ? window.pageYOffset : 0)}px`; +- containerDiv.style.left = `${left + window.pageXOffset}px`; +- containerDiv.style.height = `${height}px`; +- containerDiv.style.width = `${width}px`; +- if (menuEle !== null) { +- menuEle.style.top = `${top}`; +- const menuRect = menuEle.getBoundingClientRect(); +- const menuHeight = menuRect.height; +- const menuWidth = menuRect.width; +- const rootElementRect = rootElement.getBoundingClientRect(); +- if (left + menuWidth > rootElementRect.right) { +- containerDiv.style.left = `${rootElementRect.right - menuWidth + window.pageXOffset}px`; +- } +- if ((top + menuHeight > window.innerHeight || top + menuHeight > rootElementRect.bottom) && top - rootElementRect.top > menuHeight + height) { +- containerDiv.style.top = `${top - menuHeight - height + (shouldIncludePageYOffset__EXPERIMENTAL ? window.pageYOffset : 0)}px`; +- } +- } +- if (!containerDiv.isConnected) { +- setContainerDivAttributes(containerDiv, className); +- parent.append(containerDiv); +- } +- containerDiv.setAttribute('id', 'typeahead-menu'); +- rootElement.setAttribute('aria-controls', 'typeahead-menu'); +- } +- }, [editor, resolution, shouldIncludePageYOffset__EXPERIMENTAL, className, parent]); +- useEffect(() => { +- const rootElement = editor.getRootElement(); +- if (resolution !== null) { +- positionMenu(); +- } +- return () => { +- if (rootElement !== null) { +- rootElement.removeAttribute('aria-controls'); +- } +- // eslint-disable-next-line react-hooks/exhaustive-deps +- const containerDiv = anchorElementRef.current; +- if (containerDiv !== null && containerDiv.isConnected) { +- containerDiv.remove(); +- containerDiv.removeAttribute('id'); +- } +- }; +- }, [editor, positionMenu, resolution]); +- const onVisibilityChange = useCallback(isInView => { +- if (resolution !== null) { +- if (!isInView) { +- setResolution(null); +- } +- } +- }, [resolution, setResolution]); +- useDynamicPositioning(resolution, anchorElementRef.current, positionMenu, onVisibilityChange); +- +- // Append the context for the menu immediately +- if (initialAnchorElement != null && initialAnchorElement === anchorElementRef.current) { +- setContainerDivAttributes(initialAnchorElement, className); +- if (parent != null) { +- parent.append(initialAnchorElement); +- } +- } +- return anchorElementRef; +-} +- +-/** +- * 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. +- * +- */ +- +-const PRE_PORTAL_DIV_SIZE = 1; +- +-/** +- * @deprecated Use LexicalNodeContextMenuPlugin instead. +- */ +-function LexicalContextMenuPlugin({ +- options, +- onWillOpen, +- onClose, +- onOpen, +- onSelectOption, +- menuRenderFn: contextMenuRenderFn, +- anchorClassName, +- commandPriority = COMMAND_PRIORITY_LOW, +- parent +-}) { +- const [editor] = useLexicalComposerContext(); +- const [resolution, setResolution] = useState(null); +- const menuRef = React.useRef(null); +- const anchorElementRef = useMenuAnchorRef(resolution, setResolution, anchorClassName, parent); +- const closeNodeMenu = useCallback(() => { +- setResolution(null); +- if (onClose != null && resolution !== null) { +- onClose(); +- } +- }, [onClose, resolution]); +- const openNodeMenu = useCallback(res => { +- setResolution(res); +- if (onOpen != null && resolution === null) { +- onOpen(res); +- } +- }, [onOpen, resolution]); +- const handleContextMenu = useCallback(event => { +- event.preventDefault(); +- if (onWillOpen != null) { +- onWillOpen(event); +- } +- const zoom = calculateZoomLevel(event.target); +- openNodeMenu({ +- getRect: () => new DOMRect(event.clientX / zoom, event.clientY / zoom, PRE_PORTAL_DIV_SIZE, PRE_PORTAL_DIV_SIZE) +- }); +- }, [openNodeMenu, onWillOpen]); +- const handleClick = useCallback(event => { +- if (resolution !== null && menuRef.current != null && event.target != null && isDOMNode(event.target) && !menuRef.current.contains(event.target)) { +- closeNodeMenu(); +- } +- }, [closeNodeMenu, resolution]); +- useEffect(() => { +- const editorElement = editor.getRootElement(); +- if (editorElement) { +- editorElement.addEventListener('contextmenu', handleContextMenu); +- return () => editorElement.removeEventListener('contextmenu', handleContextMenu); +- } +- }, [editor, handleContextMenu]); +- useEffect(() => { +- document.addEventListener('click', handleClick); +- return () => document.removeEventListener('click', handleClick); +- }, [editor, handleClick]); +- return anchorElementRef.current === null || resolution === null || editor === null ? null : /*#__PURE__*/jsx(LexicalMenu, { +- close: closeNodeMenu, +- resolution: resolution, +- editor: editor, +- anchorElementRef: anchorElementRef, +- options: options, +- menuRenderFn: (anchorRef, itemProps) => contextMenuRenderFn(anchorRef, itemProps, { +- setMenuRef: ref => { +- menuRef.current = ref; +- } +- }), +- onSelectOption: onSelectOption, +- commandPriority: commandPriority +- }); +-} +- +-export { LexicalContextMenuPlugin, MenuOption }; +diff --git a/node_modules/@lexical/react/LexicalContextMenuPlugin.js b/node_modules/@lexical/react/LexicalContextMenuPlugin.js +deleted file mode 100644 +index b3f6da5..0000000 +--- a/node_modules/@lexical/react/LexicalContextMenuPlugin.js ++++ /dev/null +@@ -1,11 +0,0 @@ +-/** +- * 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. +- * +- */ +- +-'use strict' +-const LexicalContextMenuPlugin = process.env.NODE_ENV !== 'production' ? require('./LexicalContextMenuPlugin.dev.js') : require('./LexicalContextMenuPlugin.prod.js'); +-module.exports = LexicalContextMenuPlugin; +\ No newline at end of file +diff --git a/node_modules/@lexical/react/LexicalContextMenuPlugin.mjs b/node_modules/@lexical/react/LexicalContextMenuPlugin.mjs +deleted file mode 100644 +index bff384c..0000000 +--- a/node_modules/@lexical/react/LexicalContextMenuPlugin.mjs ++++ /dev/null +@@ -1,13 +0,0 @@ +-/** +- * 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. +- * +- */ +- +-import * as modDev from './LexicalContextMenuPlugin.dev.mjs'; +-import * as modProd from './LexicalContextMenuPlugin.prod.mjs'; +-const mod = process.env.NODE_ENV !== 'production' ? modDev : modProd; +-export const LexicalContextMenuPlugin = mod.LexicalContextMenuPlugin; +-export const MenuOption = mod.MenuOption; +\ No newline at end of file +diff --git a/node_modules/@lexical/react/LexicalContextMenuPlugin.node.mjs b/node_modules/@lexical/react/LexicalContextMenuPlugin.node.mjs +deleted file mode 100644 +index 89b8196..0000000 +--- a/node_modules/@lexical/react/LexicalContextMenuPlugin.node.mjs ++++ /dev/null +@@ -1,11 +0,0 @@ +-/** +- * 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. +- * +- */ +- +-const mod = await (process.env.NODE_ENV !== 'production' ? import('./LexicalContextMenuPlugin.dev.mjs') : import('./LexicalContextMenuPlugin.prod.mjs')); +-export const LexicalContextMenuPlugin = mod.LexicalContextMenuPlugin; +-export const MenuOption = mod.MenuOption; +\ No newline at end of file +diff --git a/node_modules/@lexical/react/LexicalContextMenuPlugin.prod.js b/node_modules/@lexical/react/LexicalContextMenuPlugin.prod.js +deleted file mode 100644 +index c713b15..0000000 +--- a/node_modules/@lexical/react/LexicalContextMenuPlugin.prod.js ++++ /dev/null +@@ -1,9 +0,0 @@ +-/** +- * 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. +- * +- */ +- +-"use strict";var e=require("@lexical/react/LexicalComposerContext"),t=require("@lexical/utils"),n=require("lexical"),o=require("react"),l=require("react/jsx-runtime");function r(e){var t=Object.create(null);if(e)for(var n in e)t[n]=e[n];return t.default=e,t}var i=r(o);const u="undefined"!=typeof window&&void 0!==window.document&&void 0!==window.document.createElement,s=u?o.useLayoutEffect:o.useEffect;const c=e=>{const t=document.getElementById("typeahead-menu");if(!t)return;const n=t.getBoundingClientRect();n.top+n.height>window.innerHeight&&t.scrollIntoView({block:"center"}),n.top<0&&t.scrollIntoView({block:"center"}),e.scrollIntoView({block:"nearest"})};function a(e,t){const n=e.getBoundingClientRect(),o=t.getBoundingClientRect();return n.top>=o.top-6&&n.top<=o.bottom+6}function m(t,n,l,r){const[i]=e.useLexicalComposerContext();o.useEffect(()=>{if(null!=n&&null!=t){const e=i.getRootElement(),t=null!=e?function(e){let t=getComputedStyle(e);const n="absolute"===t.position,o=/(auto|scroll)/;if("fixed"===t.position)return document.body;for(let l=e;l=l.parentElement;)if(t=getComputedStyle(l),(!n||"static"!==t.position)&&o.test(t.overflow+t.overflowY+t.overflowX))return l;return document.body}(e):document.body;let o=!1,u=a(n,t);const s=function(){o||(window.requestAnimationFrame(function(){l(),o=!1}),o=!0);const e=a(n,t);e!==u&&(u=e,null!=r&&r(e))},c=new ResizeObserver(l);return window.addEventListener("resize",l),document.addEventListener("scroll",s,{capture:!0,passive:!0}),c.observe(n),()=>{c.unobserve(n),window.removeEventListener("resize",l),document.removeEventListener("scroll",s,!0)}}},[n,i,r,l,t])}const d=n.createCommand("SCROLL_TYPEAHEAD_OPTION_INTO_VIEW_COMMAND");function f({close:e,editor:l,anchorElementRef:r,resolution:i,options:u,menuRenderFn:a,onSelectOption:m,shouldSplitNodeWithQuery:f=!1,commandPriority:p=n.COMMAND_PRIORITY_LOW,preselectFirstItem:g=!0}){const[h,C]=o.useState(null),E=null!==h?Math.min(u.length-1,h):null,v=i.match&&i.match.matchingString;o.useEffect(()=>{g&&C(0)},[v,g]);const R=o.useCallback(t=>{l.update(()=>{const o=null!=i.match&&f?function(e){const t=n.$getSelection();if(!n.$isRangeSelection(t)||!t.isCollapsed())return null;const o=t.anchor;if("text"!==o.type)return null;const l=o.getNode();if(!l.isSimpleText())return null;const r=o.offset,i=l.getTextContent().slice(0,r),u=e.replaceableString.length,s=r-function(e,t,n){let o=n;for(let n=o;n<=t.length;n++)e.slice(-n)===t.substring(0,n)&&(o=n);return o}(i,e.matchingString,u);if(s<0)return null;let c;return 0===s?[c]=l.splitText(r):[,c]=l.splitText(s,r),c}(i.match):null;m(t,o,e,i.match?i.match.matchingString:"")})},[l,f,i.match,m,e]),b=o.useCallback(e=>{const t=l.getRootElement();null!==t&&(t.setAttribute("aria-activedescendant","typeahead-item-"+e),C(e))},[l]);o.useEffect(()=>()=>{const e=l.getRootElement();null!==e&&e.removeAttribute("aria-activedescendant")},[l]),s(()=>{null===u?C(null):null===E&&g&&b(0)},[u,E,b,g]),o.useEffect(()=>t.mergeRegister(l.registerCommand(d,({option:e})=>!(!e.ref||null==e.ref.current)&&(c(e.ref.current),!0),p)),[l,b,p]),o.useEffect(()=>t.mergeRegister(l.registerCommand(n.KEY_ARROW_DOWN_COMMAND,e=>{const t=e;if(null!==u&&u.length){const e=null===E?0:E!==u.length-1?E+1:0;b(e);const n=u[e];if(!n)return b(-1),t.preventDefault(),t.stopImmediatePropagation(),!0;n.ref&&n.ref.current&&l.dispatchCommand(d,{index:e,option:n}),t.preventDefault(),t.stopImmediatePropagation()}return!0},p),l.registerCommand(n.KEY_ARROW_UP_COMMAND,e=>{const t=e;if(null!==u&&u.length){const e=null===E?u.length-1:0!==E?E-1:u.length-1;b(e);const n=u[e];if(!n)return b(-1),t.preventDefault(),t.stopImmediatePropagation(),!0;n.ref&&n.ref.current&&c(n.ref.current),t.preventDefault(),t.stopImmediatePropagation()}return!0},p),l.registerCommand(n.KEY_ESCAPE_COMMAND,t=>{const n=t;return n.preventDefault(),n.stopImmediatePropagation(),e(),!0},p),l.registerCommand(n.KEY_TAB_COMMAND,e=>{const t=e;return null!==u&&null!==E&&null!=u[E]&&(t.preventDefault(),t.stopImmediatePropagation(),R(u[E]),!0)},p),l.registerCommand(n.KEY_ENTER_COMMAND,e=>null!==u&&null!==E&&null!=u[E]&&(null!==e&&(e.preventDefault(),e.stopImmediatePropagation()),R(u[E]),!0),p)),[R,e,l,u,E,b,p]);return a(r,o.useMemo(()=>({options:u,selectOptionAndCleanUp:R,selectedIndex:E,setHighlightedIndex:C}),[R,E,u]),i.match?i.match.matchingString:"")}function p(e,t){null!=t&&(e.className=t),e.setAttribute("aria-label","Typeahead menu"),e.setAttribute("role","listbox"),e.style.display="block",e.style.position="absolute"}exports.LexicalContextMenuPlugin=function({options:r,onWillOpen:s,onClose:c,onOpen:a,onSelectOption:d,menuRenderFn:g,anchorClassName:h,commandPriority:C=n.COMMAND_PRIORITY_LOW,parent:E}){const[v]=e.useLexicalComposerContext(),[R,b]=o.useState(null),w=i.useRef(null),x=function(t,n,l,r=(u?document.body:void 0),i=!0){const[s]=e.useLexicalComposerContext(),c=u?document.createElement("div"):null,a=o.useRef(c),d=o.useCallback(()=>{if(null===a.current||void 0===r)return;a.current.style.top=a.current.style.bottom;const e=s.getRootElement(),n=a.current,o=n.firstChild;if(null!==e&&null!==t){const{left:u,top:s,width:c,height:m}=t.getRect(),d=a.current.offsetHeight;if(n.style.top=`${s+d+3+(i?window.pageYOffset:0)}px`,n.style.left=`${u+window.pageXOffset}px`,n.style.height=`${m}px`,n.style.width=`${c}px`,null!==o){o.style.top=`${s}`;const t=o.getBoundingClientRect(),l=t.height,r=t.width,c=e.getBoundingClientRect();u+r>c.right&&(n.style.left=`${c.right-r+window.pageXOffset}px`),(s+l>window.innerHeight||s+l>c.bottom)&&s-c.top>l+m&&(n.style.top=`${s-l-m+(i?window.pageYOffset:0)}px`)}n.isConnected||(p(n,l),r.append(n)),n.setAttribute("id","typeahead-menu"),e.setAttribute("aria-controls","typeahead-menu")}},[s,t,i,l,r]);o.useEffect(()=>{const e=s.getRootElement();return null!==t&&d(),()=>{null!==e&&e.removeAttribute("aria-controls");const t=a.current;null!==t&&t.isConnected&&(t.remove(),t.removeAttribute("id"))}},[s,d,t]);const f=o.useCallback(e=>{null!==t&&(e||n(null))},[t,n]);return m(t,a.current,d,f),null!=c&&c===a.current&&(p(c,l),null!=r&&r.append(c)),a}(R,b,h,E),O=o.useCallback(()=>{b(null),null!=c&&null!==R&&c()},[c,R]),y=o.useCallback(e=>{b(e),null!=a&&null===R&&a(e)},[a,R]),A=o.useCallback(e=>{e.preventDefault(),null!=s&&s(e);const n=t.calculateZoomLevel(e.target);y({getRect:()=>new DOMRect(e.clientX/n,e.clientY/n,1,1)})},[y,s]),M=o.useCallback(e=>{null!==R&&null!=w.current&&null!=e.target&&n.isDOMNode(e.target)&&!w.current.contains(e.target)&&O()},[O,R]);return o.useEffect(()=>{const e=v.getRootElement();if(e)return e.addEventListener("contextmenu",A),()=>e.removeEventListener("contextmenu",A)},[v,A]),o.useEffect(()=>(document.addEventListener("click",M),()=>document.removeEventListener("click",M)),[v,M]),null===x.current||null===R||null===v?null:l.jsx(f,{close:O,resolution:R,editor:v,anchorElementRef:x,options:r,menuRenderFn:(e,t)=>g(e,t,{setMenuRef:e=>{w.current=e}}),onSelectOption:d,commandPriority:C})},exports.MenuOption=class{key;ref;constructor(e){this.key=e,this.ref={current:null},this.setRefElement=this.setRefElement.bind(this)}setRefElement(e){this.ref={current:e}}}; +diff --git a/node_modules/@lexical/react/LexicalContextMenuPlugin.prod.mjs b/node_modules/@lexical/react/LexicalContextMenuPlugin.prod.mjs +deleted file mode 100644 +index 7d26d16..0000000 +--- a/node_modules/@lexical/react/LexicalContextMenuPlugin.prod.mjs ++++ /dev/null +@@ -1,9 +0,0 @@ +-/** +- * 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. +- * +- */ +- +-import{useLexicalComposerContext as t}from"@lexical/react/LexicalComposerContext";import{mergeRegister as e,calculateZoomLevel as n}from"@lexical/utils";import{createCommand as o,COMMAND_PRIORITY_LOW as l,KEY_ARROW_DOWN_COMMAND as r,KEY_ARROW_UP_COMMAND as i,KEY_ESCAPE_COMMAND as u,KEY_TAB_COMMAND as c,KEY_ENTER_COMMAND as s,$getSelection as a,$isRangeSelection as m,isDOMNode as d}from"lexical";import*as p from"react";import{useLayoutEffect as f,useEffect as g,useRef as h,useCallback as v,useState as w,useMemo as y}from"react";import{jsx as b}from"react/jsx-runtime";const C="undefined"!=typeof window&&void 0!==window.document&&void 0!==window.document.createElement,E=C?f:g;class R{key;ref;constructor(t){this.key=t,this.ref={current:null},this.setRefElement=this.setRefElement.bind(this)}setRefElement(t){this.ref={current:t}}}const x=t=>{const e=document.getElementById("typeahead-menu");if(!e)return;const n=e.getBoundingClientRect();n.top+n.height>window.innerHeight&&e.scrollIntoView({block:"center"}),n.top<0&&e.scrollIntoView({block:"center"}),t.scrollIntoView({block:"nearest"})};function I(t,e){const n=t.getBoundingClientRect(),o=e.getBoundingClientRect();return n.top>=o.top-6&&n.top<=o.bottom+6}function O(e,n,o,l){const[r]=t();g(()=>{if(null!=n&&null!=e){const t=r.getRootElement(),e=null!=t?function(t){let e=getComputedStyle(t);const n="absolute"===e.position,o=/(auto|scroll)/;if("fixed"===e.position)return document.body;for(let l=t;l=l.parentElement;)if(e=getComputedStyle(l),(!n||"static"!==e.position)&&o.test(e.overflow+e.overflowY+e.overflowX))return l;return document.body}(t):document.body;let i=!1,u=I(n,e);const c=function(){i||(window.requestAnimationFrame(function(){o(),i=!1}),i=!0);const t=I(n,e);t!==u&&(u=t,null!=l&&l(t))},s=new ResizeObserver(o);return window.addEventListener("resize",o),document.addEventListener("scroll",c,{capture:!0,passive:!0}),s.observe(n),()=>{s.unobserve(n),window.removeEventListener("resize",o),document.removeEventListener("scroll",c,!0)}}},[n,r,l,o,e])}const A=o("SCROLL_TYPEAHEAD_OPTION_INTO_VIEW_COMMAND");function S({close:t,editor:n,anchorElementRef:o,resolution:d,options:p,menuRenderFn:f,onSelectOption:h,shouldSplitNodeWithQuery:b=!1,commandPriority:C=l,preselectFirstItem:R=!0}){const[I,O]=w(null),S=null!==I?Math.min(p.length-1,I):null,P=d.match&&d.match.matchingString;g(()=>{R&&O(0)},[P,R]);const D=v(e=>{n.update(()=>{const n=null!=d.match&&b?function(t){const e=a();if(!m(e)||!e.isCollapsed())return null;const n=e.anchor;if("text"!==n.type)return null;const o=n.getNode();if(!o.isSimpleText())return null;const l=n.offset,r=o.getTextContent().slice(0,l),i=t.replaceableString.length,u=l-function(t,e,n){let o=n;for(let n=o;n<=e.length;n++)t.slice(-n)===e.substring(0,n)&&(o=n);return o}(r,t.matchingString,i);if(u<0)return null;let c;return 0===u?[c]=o.splitText(l):[,c]=o.splitText(u,l),c}(d.match):null;h(e,n,t,d.match?d.match.matchingString:"")})},[n,b,d.match,h,t]),L=v(t=>{const e=n.getRootElement();null!==e&&(e.setAttribute("aria-activedescendant","typeahead-item-"+t),O(t))},[n]);g(()=>()=>{const t=n.getRootElement();null!==t&&t.removeAttribute("aria-activedescendant")},[n]),E(()=>{null===p?O(null):null===S&&R&&L(0)},[p,S,L,R]),g(()=>e(n.registerCommand(A,({option:t})=>!(!t.ref||null==t.ref.current)&&(x(t.ref.current),!0),C)),[n,L,C]),g(()=>e(n.registerCommand(r,t=>{const e=t;if(null!==p&&p.length){const t=null===S?0:S!==p.length-1?S+1:0;L(t);const o=p[t];if(!o)return L(-1),e.preventDefault(),e.stopImmediatePropagation(),!0;o.ref&&o.ref.current&&n.dispatchCommand(A,{index:t,option:o}),e.preventDefault(),e.stopImmediatePropagation()}return!0},C),n.registerCommand(i,t=>{const e=t;if(null!==p&&p.length){const t=null===S?p.length-1:0!==S?S-1:p.length-1;L(t);const n=p[t];if(!n)return L(-1),e.preventDefault(),e.stopImmediatePropagation(),!0;n.ref&&n.ref.current&&x(n.ref.current),e.preventDefault(),e.stopImmediatePropagation()}return!0},C),n.registerCommand(u,e=>{const n=e;return n.preventDefault(),n.stopImmediatePropagation(),t(),!0},C),n.registerCommand(c,t=>{const e=t;return null!==p&&null!==S&&null!=p[S]&&(e.preventDefault(),e.stopImmediatePropagation(),D(p[S]),!0)},C),n.registerCommand(s,t=>null!==p&&null!==S&&null!=p[S]&&(null!==t&&(t.preventDefault(),t.stopImmediatePropagation()),D(p[S]),!0),C)),[D,t,n,p,S,L,C]);return f(o,y(()=>({options:p,selectOptionAndCleanUp:D,selectedIndex:S,setHighlightedIndex:O}),[D,S,p]),d.match?d.match.matchingString:"")}function P(t,e){null!=e&&(t.className=e),t.setAttribute("aria-label","Typeahead menu"),t.setAttribute("role","listbox"),t.style.display="block",t.style.position="absolute"}function D({options:e,onWillOpen:o,onClose:r,onOpen:i,onSelectOption:u,menuRenderFn:c,anchorClassName:s,commandPriority:a=l,parent:m}){const[f]=t(),[y,E]=w(null),R=p.useRef(null),x=function(e,n,o,l=(C?document.body:void 0),r=!0){const[i]=t(),u=C?document.createElement("div"):null,c=h(u),s=v(()=>{if(null===c.current||void 0===l)return;c.current.style.top=c.current.style.bottom;const t=i.getRootElement(),n=c.current,u=n.firstChild;if(null!==t&&null!==e){const{left:i,top:s,width:a,height:m}=e.getRect(),d=c.current.offsetHeight;if(n.style.top=`${s+d+3+(r?window.pageYOffset:0)}px`,n.style.left=`${i+window.pageXOffset}px`,n.style.height=`${m}px`,n.style.width=`${a}px`,null!==u){u.style.top=`${s}`;const e=u.getBoundingClientRect(),o=e.height,l=e.width,c=t.getBoundingClientRect();i+l>c.right&&(n.style.left=`${c.right-l+window.pageXOffset}px`),(s+o>window.innerHeight||s+o>c.bottom)&&s-c.top>o+m&&(n.style.top=`${s-o-m+(r?window.pageYOffset:0)}px`)}n.isConnected||(P(n,o),l.append(n)),n.setAttribute("id","typeahead-menu"),t.setAttribute("aria-controls","typeahead-menu")}},[i,e,r,o,l]);g(()=>{const t=i.getRootElement();return null!==e&&s(),()=>{null!==t&&t.removeAttribute("aria-controls");const e=c.current;null!==e&&e.isConnected&&(e.remove(),e.removeAttribute("id"))}},[i,s,e]);const a=v(t=>{null!==e&&(t||n(null))},[e,n]);return O(e,c.current,s,a),null!=u&&u===c.current&&(P(u,o),null!=l&&l.append(u)),c}(y,E,s,m),I=v(()=>{E(null),null!=r&&null!==y&&r()},[r,y]),A=v(t=>{E(t),null!=i&&null===y&&i(t)},[i,y]),D=v(t=>{t.preventDefault(),null!=o&&o(t);const e=n(t.target);A({getRect:()=>new DOMRect(t.clientX/e,t.clientY/e,1,1)})},[A,o]),L=v(t=>{null!==y&&null!=R.current&&null!=t.target&&d(t.target)&&!R.current.contains(t.target)&&I()},[I,y]);return g(()=>{const t=f.getRootElement();if(t)return t.addEventListener("contextmenu",D),()=>t.removeEventListener("contextmenu",D)},[f,D]),g(()=>(document.addEventListener("click",L),()=>document.removeEventListener("click",L)),[f,L]),null===x.current||null===y||null===f?null:b(S,{close:I,resolution:y,editor:f,anchorElementRef:x,options:e,menuRenderFn:(t,e)=>c(t,e,{setMenuRef:t=>{R.current=t}}),onSelectOption:u,commandPriority:a})}export{D as LexicalContextMenuPlugin,R as MenuOption}; +diff --git a/node_modules/@lexical/react/LexicalNodeMenuPlugin.d.ts b/node_modules/@lexical/react/LexicalNodeMenuPlugin.d.ts +index 651b7d7..8ad7623 100644 +--- a/node_modules/@lexical/react/LexicalNodeMenuPlugin.d.ts ++++ b/node_modules/@lexical/react/LexicalNodeMenuPlugin.d.ts +@@ -5,7 +5,7 @@ + * LICENSE file in the root directory of this source tree. + * + */ +-import type { MenuRenderFn, MenuResolution } from './shared/LexicalMenu'; ++import type { MenuResolution } from './shared/LexicalMenu'; + import type { JSX } from 'react'; + import { CommandListenerPriority, NodeKey, TextNode } from 'lexical'; + import { MenuOption } from './shared/LexicalMenu'; +@@ -15,10 +15,9 @@ export type NodeMenuPluginProps = { + nodeKey: NodeKey | null; + onClose?: () => void; + onOpen?: (resolution: MenuResolution) => void; +- menuRenderFn: MenuRenderFn; + anchorClassName?: string; + commandPriority?: CommandListenerPriority; + parent?: HTMLElement; + }; +-export declare function LexicalNodeMenuPlugin({ options, nodeKey, onClose, onOpen, onSelectOption, menuRenderFn, anchorClassName, commandPriority, parent, }: NodeMenuPluginProps): JSX.Element | null; +-export { MenuOption, MenuRenderFn, MenuResolution }; ++export declare function LexicalNodeMenuPlugin({ options, nodeKey, onClose, onOpen, onSelectOption, anchorClassName, commandPriority, parent, }: NodeMenuPluginProps): JSX.Element | null; ++export { MenuOption, MenuResolution }; +diff --git a/node_modules/@lexical/react/LexicalNodeMenuPlugin.dev.js b/node_modules/@lexical/react/LexicalNodeMenuPlugin.dev.js +index cc367e3..5615c93 100644 +--- a/node_modules/@lexical/react/LexicalNodeMenuPlugin.dev.js ++++ b/node_modules/@lexical/react/LexicalNodeMenuPlugin.dev.js +@@ -12,6 +12,7 @@ var LexicalComposerContext = require('@lexical/react/LexicalComposerContext'); + var lexical = require('lexical'); + var React = require('react'); + var utils = require('@lexical/utils'); ++var ReactDOM = require('react-dom'); + var jsxRuntime = require('react/jsx-runtime'); + + /** +@@ -70,6 +71,8 @@ const useLayoutEffectImpl = CAN_USE_DOM ? React.useLayoutEffect : React.useEffec + class MenuOption { + key; + ref; ++ icon; ++ title; + constructor(key) { + this.key = key; + this.ref = { +@@ -219,13 +222,38 @@ function useDynamicPositioning(resolution, targetElement, onReposition, onVisibi + }, [targetElement, editor, onVisibilityChange, onReposition, resolution]); + } + const SCROLL_TYPEAHEAD_OPTION_INTO_VIEW_COMMAND = lexical.createCommand('SCROLL_TYPEAHEAD_OPTION_INTO_VIEW_COMMAND'); ++function MenuItem({ ++ index, ++ isSelected, ++ onClick, ++ onMouseEnter, ++ option ++}) { ++ let className = 'item'; ++ if (isSelected) { ++ className += ' selected'; ++ } ++ return /*#__PURE__*/jsxRuntime.jsxs("li", { ++ tabIndex: -1, ++ className: className, ++ ref: option.setRefElement, ++ role: "option", ++ "aria-selected": isSelected, ++ id: 'typeahead-item-' + index, ++ onMouseEnter: onMouseEnter, ++ onClick: onClick, ++ children: [option.icon, /*#__PURE__*/jsxRuntime.jsx("span", { ++ className: "text", ++ children: option.title ++ })] ++ }, option.key); ++} + function LexicalMenu({ + close, + editor, + anchorElementRef, + resolution, + options, +- menuRenderFn, + onSelectOption, + shouldSplitNodeWithQuery = false, + commandPriority = lexical.COMMAND_PRIORITY_LOW, +@@ -253,6 +281,25 @@ function LexicalMenu({ + setHighlightedIndex(index); + } + }, [editor]); ++ const menuRenderFn = React.useCallback(() => { ++ return anchorElementRef.current && options.length ? /*#__PURE__*/ReactDOM.createPortal(/*#__PURE__*/jsxRuntime.jsx("div", { ++ className: "typeahead-popover mentions-menu", ++ children: /*#__PURE__*/jsxRuntime.jsx("ul", { ++ children: options.map((option, i) => /*#__PURE__*/jsxRuntime.jsx(MenuItem, { ++ index: i, ++ isSelected: selectedIndex === i, ++ onClick: () => { ++ setHighlightedIndex(i); ++ selectOptionAndCleanUp(option); ++ }, ++ onMouseEnter: () => { ++ setHighlightedIndex(i); ++ }, ++ option: option ++ }, option.key)) ++ }) ++ }), anchorElementRef.current) : null; ++ }, [anchorElementRef, options, selectedIndex, selectOptionAndCleanUp, setHighlightedIndex]); + React.useEffect(() => { + return () => { + const rootElem = editor.getRootElement(); +@@ -348,13 +395,7 @@ function LexicalMenu({ + return true; + }, commandPriority)); + }, [selectOptionAndCleanUp, close, editor, options, selectedIndex, updateSelectedIndex, commandPriority]); +- const listItemProps = React.useMemo(() => ({ +- options, +- selectOptionAndCleanUp, +- selectedIndex, +- setHighlightedIndex +- }), [selectOptionAndCleanUp, selectedIndex, options]); +- return menuRenderFn(anchorElementRef, listItemProps, resolution.match ? resolution.match.matchingString : ''); ++ return menuRenderFn(); + } + function setContainerDivAttributes(containerDiv, className) { + if (className != null) { +@@ -460,7 +501,6 @@ function LexicalNodeMenuPlugin({ + onClose, + onOpen, + onSelectOption, +- menuRenderFn, + anchorClassName, + commandPriority = lexical.COMMAND_PRIORITY_LOW, + parent +@@ -517,7 +557,6 @@ function LexicalNodeMenuPlugin({ + editor: editor, + anchorElementRef: anchorElementRef, + options: options, +- menuRenderFn: menuRenderFn, + onSelectOption: onSelectOption, + commandPriority: commandPriority + }); +diff --git a/node_modules/@lexical/react/LexicalNodeMenuPlugin.dev.mjs b/node_modules/@lexical/react/LexicalNodeMenuPlugin.dev.mjs +index 5355ecb..283f88c 100644 +--- a/node_modules/@lexical/react/LexicalNodeMenuPlugin.dev.mjs ++++ b/node_modules/@lexical/react/LexicalNodeMenuPlugin.dev.mjs +@@ -8,9 +8,10 @@ + + import { useLexicalComposerContext } from '@lexical/react/LexicalComposerContext'; + import { createCommand, COMMAND_PRIORITY_LOW, KEY_ARROW_DOWN_COMMAND, KEY_ARROW_UP_COMMAND, KEY_ESCAPE_COMMAND, KEY_TAB_COMMAND, KEY_ENTER_COMMAND, $getSelection, $isRangeSelection, $getNodeByKey } from 'lexical'; +-import React, { useLayoutEffect, useEffect, useRef, useCallback, useState, useMemo } from 'react'; ++import React, { useLayoutEffect, useEffect, useRef, useCallback, useState } from 'react'; + import { mergeRegister } from '@lexical/utils'; +-import { jsx } from 'react/jsx-runtime'; ++import ReactDOM from 'react-dom'; ++import { jsx, jsxs } from 'react/jsx-runtime'; + + /** + * Copyright (c) Meta Platforms, Inc. and affiliates. +@@ -68,6 +69,8 @@ const useLayoutEffectImpl = CAN_USE_DOM ? useLayoutEffect : useEffect; + class MenuOption { + key; + ref; ++ icon; ++ title; + constructor(key) { + this.key = key; + this.ref = { +@@ -217,13 +220,38 @@ function useDynamicPositioning(resolution, targetElement, onReposition, onVisibi + }, [targetElement, editor, onVisibilityChange, onReposition, resolution]); + } + const SCROLL_TYPEAHEAD_OPTION_INTO_VIEW_COMMAND = createCommand('SCROLL_TYPEAHEAD_OPTION_INTO_VIEW_COMMAND'); ++function MenuItem({ ++ index, ++ isSelected, ++ onClick, ++ onMouseEnter, ++ option ++}) { ++ let className = 'item'; ++ if (isSelected) { ++ className += ' selected'; ++ } ++ return /*#__PURE__*/jsxs("li", { ++ tabIndex: -1, ++ className: className, ++ ref: option.setRefElement, ++ role: "option", ++ "aria-selected": isSelected, ++ id: 'typeahead-item-' + index, ++ onMouseEnter: onMouseEnter, ++ onClick: onClick, ++ children: [option.icon, /*#__PURE__*/jsx("span", { ++ className: "text", ++ children: option.title ++ })] ++ }, option.key); ++} + function LexicalMenu({ + close, + editor, + anchorElementRef, + resolution, + options, +- menuRenderFn, + onSelectOption, + shouldSplitNodeWithQuery = false, + commandPriority = COMMAND_PRIORITY_LOW, +@@ -251,6 +279,25 @@ function LexicalMenu({ + setHighlightedIndex(index); + } + }, [editor]); ++ const menuRenderFn = useCallback(() => { ++ return anchorElementRef.current && options.length ? /*#__PURE__*/ReactDOM.createPortal(/*#__PURE__*/jsx("div", { ++ className: "typeahead-popover mentions-menu", ++ children: /*#__PURE__*/jsx("ul", { ++ children: options.map((option, i) => /*#__PURE__*/jsx(MenuItem, { ++ index: i, ++ isSelected: selectedIndex === i, ++ onClick: () => { ++ setHighlightedIndex(i); ++ selectOptionAndCleanUp(option); ++ }, ++ onMouseEnter: () => { ++ setHighlightedIndex(i); ++ }, ++ option: option ++ }, option.key)) ++ }) ++ }), anchorElementRef.current) : null; ++ }, [anchorElementRef, options, selectedIndex, selectOptionAndCleanUp, setHighlightedIndex]); + useEffect(() => { + return () => { + const rootElem = editor.getRootElement(); +@@ -346,13 +393,7 @@ function LexicalMenu({ + return true; + }, commandPriority)); + }, [selectOptionAndCleanUp, close, editor, options, selectedIndex, updateSelectedIndex, commandPriority]); +- const listItemProps = useMemo(() => ({ +- options, +- selectOptionAndCleanUp, +- selectedIndex, +- setHighlightedIndex +- }), [selectOptionAndCleanUp, selectedIndex, options]); +- return menuRenderFn(anchorElementRef, listItemProps, resolution.match ? resolution.match.matchingString : ''); ++ return menuRenderFn(); + } + function setContainerDivAttributes(containerDiv, className) { + if (className != null) { +@@ -458,7 +499,6 @@ function LexicalNodeMenuPlugin({ + onClose, + onOpen, + onSelectOption, +- menuRenderFn, + anchorClassName, + commandPriority = COMMAND_PRIORITY_LOW, + parent +@@ -515,7 +555,6 @@ function LexicalNodeMenuPlugin({ + editor: editor, + anchorElementRef: anchorElementRef, + options: options, +- menuRenderFn: menuRenderFn, + onSelectOption: onSelectOption, + commandPriority: commandPriority + }); +diff --git a/node_modules/@lexical/react/LexicalNodeMenuPlugin.js.flow b/node_modules/@lexical/react/LexicalNodeMenuPlugin.js.flow +index 8376c18..716a9ec 100644 +--- a/node_modules/@lexical/react/LexicalNodeMenuPlugin.js.flow ++++ b/node_modules/@lexical/react/LexicalNodeMenuPlugin.js.flow +@@ -28,17 +28,6 @@ declare export class MenuOption { + setRefElement(element: HTMLElement | null): void; + } + +-export type MenuRenderFn = ( +- anchorElementRef: {current: HTMLElement | null}, +- itemProps: { +- selectedIndex: number | null, +- selectOptionAndCleanUp: (option: TOption) => void, +- setHighlightedIndex: (index: number) => void, +- options: Array, +- }, +- matchingString: string, +-) => React.Portal | React.MixedElement | null; +- + export type TriggerFn = ( + text: string, + editor: LexicalEditor, +@@ -55,7 +44,6 @@ type NodeMenuPluginProps = { + nodeKey: NodeKey | null, + onClose?: () => void, + onOpen?: (resolution: MenuResolution) => void, +- menuRenderFn: MenuRenderFn, + anchorClassName?: string, + }; + +diff --git a/node_modules/@lexical/react/LexicalNodeMenuPlugin.prod.js b/node_modules/@lexical/react/LexicalNodeMenuPlugin.prod.js +index bf399f1..5b79d2f 100644 +--- a/node_modules/@lexical/react/LexicalNodeMenuPlugin.prod.js ++++ b/node_modules/@lexical/react/LexicalNodeMenuPlugin.prod.js +@@ -6,4 +6,4 @@ + * + */ + +-"use strict";var e=require("@lexical/react/LexicalComposerContext"),t=require("lexical"),n=require("react"),o=require("@lexical/utils"),l=require("react/jsx-runtime");const r="startTransition";const i="undefined"!=typeof window&&void 0!==window.document&&void 0!==window.document.createElement,u=i?n.useLayoutEffect:n.useEffect;const s=e=>{const t=document.getElementById("typeahead-menu");if(!t)return;const n=t.getBoundingClientRect();n.top+n.height>window.innerHeight&&t.scrollIntoView({block:"center"}),n.top<0&&t.scrollIntoView({block:"center"}),e.scrollIntoView({block:"nearest"})};function c(e,t){const n=e.getBoundingClientRect(),o=t.getBoundingClientRect();return n.top>=o.top-6&&n.top<=o.bottom+6}function a(t,o,l,r){const[i]=e.useLexicalComposerContext();n.useEffect(()=>{if(null!=o&&null!=t){const e=i.getRootElement(),t=null!=e?function(e){let t=getComputedStyle(e);const n="absolute"===t.position,o=/(auto|scroll)/;if("fixed"===t.position)return document.body;for(let l=e;l=l.parentElement;)if(t=getComputedStyle(l),(!n||"static"!==t.position)&&o.test(t.overflow+t.overflowY+t.overflowX))return l;return document.body}(e):document.body;let n=!1,u=c(o,t);const s=function(){n||(window.requestAnimationFrame(function(){l(),n=!1}),n=!0);const e=c(o,t);e!==u&&(u=e,null!=r&&r(e))},a=new ResizeObserver(l);return window.addEventListener("resize",l),document.addEventListener("scroll",s,{capture:!0,passive:!0}),a.observe(o),()=>{a.unobserve(o),window.removeEventListener("resize",l),document.removeEventListener("scroll",s,!0)}}},[o,i,r,l,t])}const d=t.createCommand("SCROLL_TYPEAHEAD_OPTION_INTO_VIEW_COMMAND");function m({close:e,editor:l,anchorElementRef:r,resolution:i,options:c,menuRenderFn:a,onSelectOption:m,shouldSplitNodeWithQuery:f=!1,commandPriority:p=t.COMMAND_PRIORITY_LOW,preselectFirstItem:g=!0}){const[h,C]=n.useState(null),E=null!==h?Math.min(c.length-1,h):null,y=i.match&&i.match.matchingString;n.useEffect(()=>{g&&C(0)},[y,g]);const b=n.useCallback(n=>{l.update(()=>{const o=null!=i.match&&f?function(e){const n=t.$getSelection();if(!t.$isRangeSelection(n)||!n.isCollapsed())return null;const o=n.anchor;if("text"!==o.type)return null;const l=o.getNode();if(!l.isSimpleText())return null;const r=o.offset,i=l.getTextContent().slice(0,r),u=e.replaceableString.length,s=r-function(e,t,n){let o=n;for(let n=o;n<=t.length;n++)e.slice(-n)===t.substring(0,n)&&(o=n);return o}(i,e.matchingString,u);if(s<0)return null;let c;return 0===s?[c]=l.splitText(r):[,c]=l.splitText(s,r),c}(i.match):null;m(n,o,e,i.match?i.match.matchingString:"")})},[l,f,i.match,m,e]),R=n.useCallback(e=>{const t=l.getRootElement();null!==t&&(t.setAttribute("aria-activedescendant","typeahead-item-"+e),C(e))},[l]);n.useEffect(()=>()=>{const e=l.getRootElement();null!==e&&e.removeAttribute("aria-activedescendant")},[l]),u(()=>{null===c?C(null):null===E&&g&&R(0)},[c,E,R,g]),n.useEffect(()=>o.mergeRegister(l.registerCommand(d,({option:e})=>!(!e.ref||null==e.ref.current)&&(s(e.ref.current),!0),p)),[l,R,p]),n.useEffect(()=>o.mergeRegister(l.registerCommand(t.KEY_ARROW_DOWN_COMMAND,e=>{const t=e;if(null!==c&&c.length){const e=null===E?0:E!==c.length-1?E+1:0;R(e);const n=c[e];if(!n)return R(-1),t.preventDefault(),t.stopImmediatePropagation(),!0;n.ref&&n.ref.current&&l.dispatchCommand(d,{index:e,option:n}),t.preventDefault(),t.stopImmediatePropagation()}return!0},p),l.registerCommand(t.KEY_ARROW_UP_COMMAND,e=>{const t=e;if(null!==c&&c.length){const e=null===E?c.length-1:0!==E?E-1:c.length-1;R(e);const n=c[e];if(!n)return R(-1),t.preventDefault(),t.stopImmediatePropagation(),!0;n.ref&&n.ref.current&&s(n.ref.current),t.preventDefault(),t.stopImmediatePropagation()}return!0},p),l.registerCommand(t.KEY_ESCAPE_COMMAND,t=>{const n=t;return n.preventDefault(),n.stopImmediatePropagation(),e(),!0},p),l.registerCommand(t.KEY_TAB_COMMAND,e=>{const t=e;return null!==c&&null!==E&&null!=c[E]&&(t.preventDefault(),t.stopImmediatePropagation(),b(c[E]),!0)},p),l.registerCommand(t.KEY_ENTER_COMMAND,e=>null!==c&&null!==E&&null!=c[E]&&(null!==e&&(e.preventDefault(),e.stopImmediatePropagation()),b(c[E]),!0),p)),[b,e,l,c,E,R,p]);return a(r,n.useMemo(()=>({options:c,selectOptionAndCleanUp:b,selectedIndex:E,setHighlightedIndex:C}),[b,E,c]),i.match?i.match.matchingString:"")}function f(e,t){null!=t&&(e.className=t),e.setAttribute("aria-label","Typeahead menu"),e.setAttribute("role","listbox"),e.style.display="block",e.style.position="absolute"}exports.LexicalNodeMenuPlugin=function({options:o,nodeKey:u,onClose:s,onOpen:c,onSelectOption:d,menuRenderFn:p,anchorClassName:g,commandPriority:h=t.COMMAND_PRIORITY_LOW,parent:C}){const[E]=e.useLexicalComposerContext(),[y,b]=n.useState(null),R=function(t,o,l,r=(i?document.body:void 0),u=!0){const[s]=e.useLexicalComposerContext(),c=i?document.createElement("div"):null,d=n.useRef(c),m=n.useCallback(()=>{if(null===d.current||void 0===r)return;d.current.style.top=d.current.style.bottom;const e=s.getRootElement(),n=d.current,o=n.firstChild;if(null!==e&&null!==t){const{left:i,top:s,width:c,height:a}=t.getRect(),m=d.current.offsetHeight;if(n.style.top=`${s+m+3+(u?window.pageYOffset:0)}px`,n.style.left=`${i+window.pageXOffset}px`,n.style.height=`${a}px`,n.style.width=`${c}px`,null!==o){o.style.top=`${s}`;const t=o.getBoundingClientRect(),l=t.height,r=t.width,c=e.getBoundingClientRect();i+r>c.right&&(n.style.left=`${c.right-r+window.pageXOffset}px`),(s+l>window.innerHeight||s+l>c.bottom)&&s-c.top>l+a&&(n.style.top=`${s-l-a+(u?window.pageYOffset:0)}px`)}n.isConnected||(f(n,l),r.append(n)),n.setAttribute("id","typeahead-menu"),e.setAttribute("aria-controls","typeahead-menu")}},[s,t,u,l,r]);n.useEffect(()=>{const e=s.getRootElement();return null!==t&&m(),()=>{null!==e&&e.removeAttribute("aria-controls");const t=d.current;null!==t&&t.isConnected&&(t.remove(),t.removeAttribute("id"))}},[s,m,t]);const p=n.useCallback(e=>{null!==t&&(e||o(null))},[t,o]);return a(t,d.current,m,p),null!=c&&c===d.current&&(f(c,l),null!=r&&r.append(c)),d}(y,b,g,C),w=n.useCallback(()=>{b(null),null!=s&&null!==y&&s()},[s,y]),v=n.useCallback(e=>{b(e),null!=c&&null===y&&c(e)},[c,y]),x=n.useCallback(()=>{u?E.update(()=>{const e=t.$getNodeByKey(u),o=E.getElementByKey(u);var l;null!=e&&null!=o&&null==y&&(l=()=>v({getRect:()=>o.getBoundingClientRect()}),r in n?n[r](l):l())}):null==u&&null!=y&&w()},[w,E,u,v,y]);return n.useEffect(()=>{x()},[x,u]),n.useEffect(()=>{if(null!=u)return E.registerUpdateListener(({dirtyElements:e})=>{e.get(u)&&x()})},[E,x,u]),null===R.current||null===y||null===E?null:l.jsx(m,{close:w,resolution:y,editor:E,anchorElementRef:R,options:o,menuRenderFn:p,onSelectOption:d,commandPriority:h})},exports.MenuOption=class{key;ref;constructor(e){this.key=e,this.ref={current:null},this.setRefElement=this.setRefElement.bind(this)}setRefElement(e){this.ref={current:e}}}; ++"use strict";var e=require("@lexical/react/LexicalComposerContext"),t=require("lexical"),n=require("react"),l=require("@lexical/utils"),o=require("react-dom"),r=require("react/jsx-runtime");const i="startTransition";const s="undefined"!=typeof window&&void 0!==window.document&&void 0!==window.document.createElement,u=s?n.useLayoutEffect:n.useEffect;const c=e=>{const t=document.getElementById("typeahead-menu");if(!t)return;const n=t.getBoundingClientRect();n.top+n.height>window.innerHeight&&t.scrollIntoView({block:"center"}),n.top<0&&t.scrollIntoView({block:"center"}),e.scrollIntoView({block:"nearest"})};function a(e,t){const n=e.getBoundingClientRect(),l=t.getBoundingClientRect();return n.top>=l.top-6&&n.top<=l.bottom+6}function d(t,l,o,r){const[i]=e.useLexicalComposerContext();n.useEffect(()=>{if(null!=l&&null!=t){const e=i.getRootElement(),t=null!=e?function(e){let t=getComputedStyle(e);const n="absolute"===t.position,l=/(auto|scroll)/;if("fixed"===t.position)return document.body;for(let o=e;o=o.parentElement;)if(t=getComputedStyle(o),(!n||"static"!==t.position)&&l.test(t.overflow+t.overflowY+t.overflowX))return o;return document.body}(e):document.body;let n=!1,s=a(l,t);const u=function(){n||(window.requestAnimationFrame(function(){o(),n=!1}),n=!0);const e=a(l,t);e!==s&&(s=e,null!=r&&r(e))},c=new ResizeObserver(o);return window.addEventListener("resize",o),document.addEventListener("scroll",u,{capture:!0,passive:!0}),c.observe(l),()=>{c.unobserve(l),window.removeEventListener("resize",o),document.removeEventListener("scroll",u,!0)}}},[l,i,r,o,t])}const m=t.createCommand("SCROLL_TYPEAHEAD_OPTION_INTO_VIEW_COMMAND");function p({index:e,isSelected:t,onClick:n,onMouseEnter:l,option:o}){let i="item";return t&&(i+=" selected"),r.jsxs("li",{tabIndex:-1,className:i,ref:o.setRefElement,role:"option","aria-selected":t,id:"typeahead-item-"+e,onMouseEnter:l,onClick:n,children:[o.icon,r.jsx("span",{className:"text",children:o.title})]},o.key)}function f({close:e,editor:i,anchorElementRef:s,resolution:a,options:d,onSelectOption:f,shouldSplitNodeWithQuery:g=!1,commandPriority:h=t.COMMAND_PRIORITY_LOW,preselectFirstItem:C=!0}){const[E,y]=n.useState(null),x=null!==E?Math.min(d.length-1,E):null,b=a.match&&a.match.matchingString;n.useEffect(()=>{C&&y(0)},[b,C]);const v=n.useCallback(n=>{i.update(()=>{const l=null!=a.match&&g?function(e){const n=t.$getSelection();if(!t.$isRangeSelection(n)||!n.isCollapsed())return null;const l=n.anchor;if("text"!==l.type)return null;const o=l.getNode();if(!o.isSimpleText())return null;const r=l.offset,i=o.getTextContent().slice(0,r),s=e.replaceableString.length,u=r-function(e,t,n){let l=n;for(let n=l;n<=t.length;n++)e.slice(-n)===t.substring(0,n)&&(l=n);return l}(i,e.matchingString,s);if(u<0)return null;let c;return 0===u?[c]=o.splitText(r):[,c]=o.splitText(u,r),c}(a.match):null;f(n,l,e,a.match?a.match.matchingString:"")})},[i,g,a.match,f,e]),w=n.useCallback(e=>{const t=i.getRootElement();null!==t&&(t.setAttribute("aria-activedescendant","typeahead-item-"+e),y(e))},[i]),R=n.useCallback(()=>s.current&&d.length?o.createPortal(r.jsx("div",{className:"typeahead-popover mentions-menu",children:r.jsx("ul",{children:d.map((e,t)=>r.jsx(p,{index:t,isSelected:x===t,onClick:()=>{y(t),v(e)},onMouseEnter:()=>{y(t)},option:e},e.key))})}),s.current):null,[s,d,x,v,y]);return n.useEffect(()=>()=>{const e=i.getRootElement();null!==e&&e.removeAttribute("aria-activedescendant")},[i]),u(()=>{null===d?y(null):null===x&&C&&w(0)},[d,x,w,C]),n.useEffect(()=>l.mergeRegister(i.registerCommand(m,({option:e})=>!(!e.ref||null==e.ref.current)&&(c(e.ref.current),!0),h)),[i,w,h]),n.useEffect(()=>l.mergeRegister(i.registerCommand(t.KEY_ARROW_DOWN_COMMAND,e=>{const t=e;if(null!==d&&d.length){const e=null===x?0:x!==d.length-1?x+1:0;w(e);const n=d[e];if(!n)return w(-1),t.preventDefault(),t.stopImmediatePropagation(),!0;n.ref&&n.ref.current&&i.dispatchCommand(m,{index:e,option:n}),t.preventDefault(),t.stopImmediatePropagation()}return!0},h),i.registerCommand(t.KEY_ARROW_UP_COMMAND,e=>{const t=e;if(null!==d&&d.length){const e=null===x?d.length-1:0!==x?x-1:d.length-1;w(e);const n=d[e];if(!n)return w(-1),t.preventDefault(),t.stopImmediatePropagation(),!0;n.ref&&n.ref.current&&c(n.ref.current),t.preventDefault(),t.stopImmediatePropagation()}return!0},h),i.registerCommand(t.KEY_ESCAPE_COMMAND,t=>{const n=t;return n.preventDefault(),n.stopImmediatePropagation(),e(),!0},h),i.registerCommand(t.KEY_TAB_COMMAND,e=>{const t=e;return null!==d&&null!==x&&null!=d[x]&&(t.preventDefault(),t.stopImmediatePropagation(),v(d[x]),!0)},h),i.registerCommand(t.KEY_ENTER_COMMAND,e=>null!==d&&null!==x&&null!=d[x]&&(null!==e&&(e.preventDefault(),e.stopImmediatePropagation()),v(d[x]),!0),h)),[v,e,i,d,x,w,h]),R()}function g(e,t){null!=t&&(e.className=t),e.setAttribute("aria-label","Typeahead menu"),e.setAttribute("role","listbox"),e.style.display="block",e.style.position="absolute"}exports.LexicalNodeMenuPlugin=function({options:l,nodeKey:o,onClose:u,onOpen:c,onSelectOption:a,anchorClassName:m,commandPriority:p=t.COMMAND_PRIORITY_LOW,parent:h}){const[C]=e.useLexicalComposerContext(),[E,y]=n.useState(null),x=function(t,l,o,r=(s?document.body:void 0),i=!0){const[u]=e.useLexicalComposerContext(),c=s?document.createElement("div"):null,a=n.useRef(c),m=n.useCallback(()=>{if(null===a.current||void 0===r)return;a.current.style.top=a.current.style.bottom;const e=u.getRootElement(),n=a.current,l=n.firstChild;if(null!==e&&null!==t){const{left:s,top:u,width:c,height:d}=t.getRect(),m=a.current.offsetHeight;if(n.style.top=`${u+m+3+(i?window.pageYOffset:0)}px`,n.style.left=`${s+window.pageXOffset}px`,n.style.height=`${d}px`,n.style.width=`${c}px`,null!==l){l.style.top=`${u}`;const t=l.getBoundingClientRect(),o=t.height,r=t.width,c=e.getBoundingClientRect();s+r>c.right&&(n.style.left=`${c.right-r+window.pageXOffset}px`),(u+o>window.innerHeight||u+o>c.bottom)&&u-c.top>o+d&&(n.style.top=`${u-o-d+(i?window.pageYOffset:0)}px`)}n.isConnected||(g(n,o),r.append(n)),n.setAttribute("id","typeahead-menu"),e.setAttribute("aria-controls","typeahead-menu")}},[u,t,i,o,r]);n.useEffect(()=>{const e=u.getRootElement();return null!==t&&m(),()=>{null!==e&&e.removeAttribute("aria-controls");const t=a.current;null!==t&&t.isConnected&&(t.remove(),t.removeAttribute("id"))}},[u,m,t]);const p=n.useCallback(e=>{null!==t&&(e||l(null))},[t,l]);return d(t,a.current,m,p),null!=c&&c===a.current&&(g(c,o),null!=r&&r.append(c)),a}(E,y,m,h),b=n.useCallback(()=>{y(null),null!=u&&null!==E&&u()},[u,E]),v=n.useCallback(e=>{y(e),null!=c&&null===E&&c(e)},[c,E]),w=n.useCallback(()=>{o?C.update(()=>{const e=t.$getNodeByKey(o),l=C.getElementByKey(o);var r;null!=e&&null!=l&&null==E&&(r=()=>v({getRect:()=>l.getBoundingClientRect()}),i in n?n[i](r):r())}):null==o&&null!=E&&b()},[b,C,o,v,E]);return n.useEffect(()=>{w()},[w,o]),n.useEffect(()=>{if(null!=o)return C.registerUpdateListener(({dirtyElements:e})=>{e.get(o)&&w()})},[C,w,o]),null===x.current||null===E||null===C?null:r.jsx(f,{close:b,resolution:E,editor:C,anchorElementRef:x,options:l,onSelectOption:a,commandPriority:p})},exports.MenuOption=class{key;ref;icon;title;constructor(e){this.key=e,this.ref={current:null},this.setRefElement=this.setRefElement.bind(this)}setRefElement(e){this.ref={current:e}}}; +diff --git a/node_modules/@lexical/react/LexicalNodeMenuPlugin.prod.mjs b/node_modules/@lexical/react/LexicalNodeMenuPlugin.prod.mjs +index edcacbe..e1589d5 100644 +--- a/node_modules/@lexical/react/LexicalNodeMenuPlugin.prod.mjs ++++ b/node_modules/@lexical/react/LexicalNodeMenuPlugin.prod.mjs +@@ -6,4 +6,4 @@ + * + */ + +-import{useLexicalComposerContext as t}from"@lexical/react/LexicalComposerContext";import{createCommand as e,COMMAND_PRIORITY_LOW as n,KEY_ARROW_DOWN_COMMAND as o,KEY_ARROW_UP_COMMAND as l,KEY_ESCAPE_COMMAND as r,KEY_TAB_COMMAND as i,KEY_ENTER_COMMAND as u,$getSelection as s,$isRangeSelection as c,$getNodeByKey as a}from"lexical";import m,{useLayoutEffect as d,useEffect as p,useRef as f,useCallback as g,useState as h,useMemo as y}from"react";import{mergeRegister as w}from"@lexical/utils";import{jsx as v}from"react/jsx-runtime";const b="startTransition";const C="undefined"!=typeof window&&void 0!==window.document&&void 0!==window.document.createElement,x=C?d:p;class E{key;ref;constructor(t){this.key=t,this.ref={current:null},this.setRefElement=this.setRefElement.bind(this)}setRefElement(t){this.ref={current:t}}}const R=t=>{const e=document.getElementById("typeahead-menu");if(!e)return;const n=e.getBoundingClientRect();n.top+n.height>window.innerHeight&&e.scrollIntoView({block:"center"}),n.top<0&&e.scrollIntoView({block:"center"}),t.scrollIntoView({block:"nearest"})};function I(t,e){const n=t.getBoundingClientRect(),o=e.getBoundingClientRect();return n.top>=o.top-6&&n.top<=o.bottom+6}function O(e,n,o,l){const[r]=t();p(()=>{if(null!=n&&null!=e){const t=r.getRootElement(),e=null!=t?function(t){let e=getComputedStyle(t);const n="absolute"===e.position,o=/(auto|scroll)/;if("fixed"===e.position)return document.body;for(let l=t;l=l.parentElement;)if(e=getComputedStyle(l),(!n||"static"!==e.position)&&o.test(e.overflow+e.overflowY+e.overflowX))return l;return document.body}(t):document.body;let i=!1,u=I(n,e);const s=function(){i||(window.requestAnimationFrame(function(){o(),i=!1}),i=!0);const t=I(n,e);t!==u&&(u=t,null!=l&&l(t))},c=new ResizeObserver(o);return window.addEventListener("resize",o),document.addEventListener("scroll",s,{capture:!0,passive:!0}),c.observe(n),()=>{c.unobserve(n),window.removeEventListener("resize",o),document.removeEventListener("scroll",s,!0)}}},[n,r,l,o,e])}const A=e("SCROLL_TYPEAHEAD_OPTION_INTO_VIEW_COMMAND");function S({close:t,editor:e,anchorElementRef:a,resolution:m,options:d,menuRenderFn:f,onSelectOption:v,shouldSplitNodeWithQuery:b=!1,commandPriority:C=n,preselectFirstItem:E=!0}){const[I,O]=h(null),S=null!==I?Math.min(d.length-1,I):null,P=m.match&&m.match.matchingString;p(()=>{E&&O(0)},[P,E]);const D=g(n=>{e.update(()=>{const e=null!=m.match&&b?function(t){const e=s();if(!c(e)||!e.isCollapsed())return null;const n=e.anchor;if("text"!==n.type)return null;const o=n.getNode();if(!o.isSimpleText())return null;const l=n.offset,r=o.getTextContent().slice(0,l),i=t.replaceableString.length,u=l-function(t,e,n){let o=n;for(let n=o;n<=e.length;n++)t.slice(-n)===e.substring(0,n)&&(o=n);return o}(r,t.matchingString,i);if(u<0)return null;let a;return 0===u?[a]=o.splitText(l):[,a]=o.splitText(u,l),a}(m.match):null;v(n,e,t,m.match?m.match.matchingString:"")})},[e,b,m.match,v,t]),T=g(t=>{const n=e.getRootElement();null!==n&&(n.setAttribute("aria-activedescendant","typeahead-item-"+t),O(t))},[e]);p(()=>()=>{const t=e.getRootElement();null!==t&&t.removeAttribute("aria-activedescendant")},[e]),x(()=>{null===d?O(null):null===S&&E&&T(0)},[d,S,T,E]),p(()=>w(e.registerCommand(A,({option:t})=>!(!t.ref||null==t.ref.current)&&(R(t.ref.current),!0),C)),[e,T,C]),p(()=>w(e.registerCommand(o,t=>{const n=t;if(null!==d&&d.length){const t=null===S?0:S!==d.length-1?S+1:0;T(t);const o=d[t];if(!o)return T(-1),n.preventDefault(),n.stopImmediatePropagation(),!0;o.ref&&o.ref.current&&e.dispatchCommand(A,{index:t,option:o}),n.preventDefault(),n.stopImmediatePropagation()}return!0},C),e.registerCommand(l,t=>{const e=t;if(null!==d&&d.length){const t=null===S?d.length-1:0!==S?S-1:d.length-1;T(t);const n=d[t];if(!n)return T(-1),e.preventDefault(),e.stopImmediatePropagation(),!0;n.ref&&n.ref.current&&R(n.ref.current),e.preventDefault(),e.stopImmediatePropagation()}return!0},C),e.registerCommand(r,e=>{const n=e;return n.preventDefault(),n.stopImmediatePropagation(),t(),!0},C),e.registerCommand(i,t=>{const e=t;return null!==d&&null!==S&&null!=d[S]&&(e.preventDefault(),e.stopImmediatePropagation(),D(d[S]),!0)},C),e.registerCommand(u,t=>null!==d&&null!==S&&null!=d[S]&&(null!==t&&(t.preventDefault(),t.stopImmediatePropagation()),D(d[S]),!0),C)),[D,t,e,d,S,T,C]);return f(a,y(()=>({options:d,selectOptionAndCleanUp:D,selectedIndex:S,setHighlightedIndex:O}),[D,S,d]),m.match?m.match.matchingString:"")}function P(t,e){null!=e&&(t.className=e),t.setAttribute("aria-label","Typeahead menu"),t.setAttribute("role","listbox"),t.style.display="block",t.style.position="absolute"}function D({options:e,nodeKey:o,onClose:l,onOpen:r,onSelectOption:i,menuRenderFn:u,anchorClassName:s,commandPriority:c=n,parent:d}){const[y]=t(),[w,x]=h(null),E=function(e,n,o,l=(C?document.body:void 0),r=!0){const[i]=t(),u=C?document.createElement("div"):null,s=f(u),c=g(()=>{if(null===s.current||void 0===l)return;s.current.style.top=s.current.style.bottom;const t=i.getRootElement(),n=s.current,u=n.firstChild;if(null!==t&&null!==e){const{left:i,top:c,width:a,height:m}=e.getRect(),d=s.current.offsetHeight;if(n.style.top=`${c+d+3+(r?window.pageYOffset:0)}px`,n.style.left=`${i+window.pageXOffset}px`,n.style.height=`${m}px`,n.style.width=`${a}px`,null!==u){u.style.top=`${c}`;const e=u.getBoundingClientRect(),o=e.height,l=e.width,s=t.getBoundingClientRect();i+l>s.right&&(n.style.left=`${s.right-l+window.pageXOffset}px`),(c+o>window.innerHeight||c+o>s.bottom)&&c-s.top>o+m&&(n.style.top=`${c-o-m+(r?window.pageYOffset:0)}px`)}n.isConnected||(P(n,o),l.append(n)),n.setAttribute("id","typeahead-menu"),t.setAttribute("aria-controls","typeahead-menu")}},[i,e,r,o,l]);p(()=>{const t=i.getRootElement();return null!==e&&c(),()=>{null!==t&&t.removeAttribute("aria-controls");const e=s.current;null!==e&&e.isConnected&&(e.remove(),e.removeAttribute("id"))}},[i,c,e]);const a=g(t=>{null!==e&&(t||n(null))},[e,n]);return O(e,s.current,c,a),null!=u&&u===s.current&&(P(u,o),null!=l&&l.append(u)),s}(w,x,s,d),R=g(()=>{x(null),null!=l&&null!==w&&l()},[l,w]),I=g(t=>{x(t),null!=r&&null===w&&r(t)},[r,w]),A=g(()=>{o?y.update(()=>{const t=a(o),e=y.getElementByKey(o);var n;null!=t&&null!=e&&null==w&&(n=()=>I({getRect:()=>e.getBoundingClientRect()}),b in m?m[b](n):n())}):null==o&&null!=w&&R()},[R,y,o,I,w]);return p(()=>{A()},[A,o]),p(()=>{if(null!=o)return y.registerUpdateListener(({dirtyElements:t})=>{t.get(o)&&A()})},[y,A,o]),null===E.current||null===w||null===y?null:v(S,{close:R,resolution:w,editor:y,anchorElementRef:E,options:e,menuRenderFn:u,onSelectOption:i,commandPriority:c})}export{D as LexicalNodeMenuPlugin,E as MenuOption}; ++import{useLexicalComposerContext as e}from"@lexical/react/LexicalComposerContext";import{createCommand as t,COMMAND_PRIORITY_LOW as n,KEY_ARROW_DOWN_COMMAND as o,KEY_ARROW_UP_COMMAND as l,KEY_ESCAPE_COMMAND as r,KEY_TAB_COMMAND as i,KEY_ENTER_COMMAND as u,$getSelection as s,$isRangeSelection as c,$getNodeByKey as a}from"lexical";import m,{useLayoutEffect as d,useEffect as p,useRef as f,useCallback as g,useState as h}from"react";import{mergeRegister as y}from"@lexical/utils";import v from"react-dom";import{jsx as w,jsxs as b}from"react/jsx-runtime";const C="startTransition";const E="undefined"!=typeof window&&void 0!==window.document&&void 0!==window.document.createElement,x=E?d:p;class R{key;ref;icon;title;constructor(e){this.key=e,this.ref={current:null},this.setRefElement=this.setRefElement.bind(this)}setRefElement(e){this.ref={current:e}}}const I=e=>{const t=document.getElementById("typeahead-menu");if(!t)return;const n=t.getBoundingClientRect();n.top+n.height>window.innerHeight&&t.scrollIntoView({block:"center"}),n.top<0&&t.scrollIntoView({block:"center"}),e.scrollIntoView({block:"nearest"})};function O(e,t){const n=e.getBoundingClientRect(),o=t.getBoundingClientRect();return n.top>=o.top-6&&n.top<=o.bottom+6}function S(t,n,o,l){const[r]=e();p(()=>{if(null!=n&&null!=t){const e=r.getRootElement(),t=null!=e?function(e){let t=getComputedStyle(e);const n="absolute"===t.position,o=/(auto|scroll)/;if("fixed"===t.position)return document.body;for(let l=e;l=l.parentElement;)if(t=getComputedStyle(l),(!n||"static"!==t.position)&&o.test(t.overflow+t.overflowY+t.overflowX))return l;return document.body}(e):document.body;let i=!1,u=O(n,t);const s=function(){i||(window.requestAnimationFrame(function(){o(),i=!1}),i=!0);const e=O(n,t);e!==u&&(u=e,null!=l&&l(e))},c=new ResizeObserver(o);return window.addEventListener("resize",o),document.addEventListener("scroll",s,{capture:!0,passive:!0}),c.observe(n),()=>{c.unobserve(n),window.removeEventListener("resize",o),document.removeEventListener("scroll",s,!0)}}},[n,r,l,o,t])}const P=t("SCROLL_TYPEAHEAD_OPTION_INTO_VIEW_COMMAND");function A({index:e,isSelected:t,onClick:n,onMouseEnter:o,option:l}){let r="item";return t&&(r+=" selected"),b("li",{tabIndex:-1,className:r,ref:l.setRefElement,role:"option","aria-selected":t,id:"typeahead-item-"+e,onMouseEnter:o,onClick:n,children:[l.icon,w("span",{className:"text",children:l.title})]},l.key)}function k({close:e,editor:t,anchorElementRef:a,resolution:m,options:d,onSelectOption:f,shouldSplitNodeWithQuery:b=!1,commandPriority:C=n,preselectFirstItem:E=!0}){const[R,O]=h(null),S=null!==R?Math.min(d.length-1,R):null,k=m.match&&m.match.matchingString;p(()=>{E&&O(0)},[k,E]);const N=g(n=>{t.update(()=>{const t=null!=m.match&&b?function(e){const t=s();if(!c(t)||!t.isCollapsed())return null;const n=t.anchor;if("text"!==n.type)return null;const o=n.getNode();if(!o.isSimpleText())return null;const l=n.offset,r=o.getTextContent().slice(0,l),i=e.replaceableString.length,u=l-function(e,t,n){let o=n;for(let n=o;n<=t.length;n++)e.slice(-n)===t.substring(0,n)&&(o=n);return o}(r,e.matchingString,i);if(u<0)return null;let a;return 0===u?[a]=o.splitText(l):[,a]=o.splitText(u,l),a}(m.match):null;f(n,t,e,m.match?m.match.matchingString:"")})},[t,b,m.match,f,e]),D=g(e=>{const n=t.getRootElement();null!==n&&(n.setAttribute("aria-activedescendant","typeahead-item-"+e),O(e))},[t]),T=g(()=>a.current&&d.length?v.createPortal(w("div",{className:"typeahead-popover mentions-menu",children:w("ul",{children:d.map((e,t)=>w(A,{index:t,isSelected:S===t,onClick:()=>{O(t),N(e)},onMouseEnter:()=>{O(t)},option:e},e.key))})}),a.current):null,[a,d,S,N,O]);return p(()=>()=>{const e=t.getRootElement();null!==e&&e.removeAttribute("aria-activedescendant")},[t]),x(()=>{null===d?O(null):null===S&&E&&D(0)},[d,S,D,E]),p(()=>y(t.registerCommand(P,({option:e})=>!(!e.ref||null==e.ref.current)&&(I(e.ref.current),!0),C)),[t,D,C]),p(()=>y(t.registerCommand(o,e=>{const n=e;if(null!==d&&d.length){const e=null===S?0:S!==d.length-1?S+1:0;D(e);const o=d[e];if(!o)return D(-1),n.preventDefault(),n.stopImmediatePropagation(),!0;o.ref&&o.ref.current&&t.dispatchCommand(P,{index:e,option:o}),n.preventDefault(),n.stopImmediatePropagation()}return!0},C),t.registerCommand(l,e=>{const t=e;if(null!==d&&d.length){const e=null===S?d.length-1:0!==S?S-1:d.length-1;D(e);const n=d[e];if(!n)return D(-1),t.preventDefault(),t.stopImmediatePropagation(),!0;n.ref&&n.ref.current&&I(n.ref.current),t.preventDefault(),t.stopImmediatePropagation()}return!0},C),t.registerCommand(r,t=>{const n=t;return n.preventDefault(),n.stopImmediatePropagation(),e(),!0},C),t.registerCommand(i,e=>{const t=e;return null!==d&&null!==S&&null!=d[S]&&(t.preventDefault(),t.stopImmediatePropagation(),N(d[S]),!0)},C),t.registerCommand(u,e=>null!==d&&null!==S&&null!=d[S]&&(null!==e&&(e.preventDefault(),e.stopImmediatePropagation()),N(d[S]),!0),C)),[N,e,t,d,S,D,C]),T()}function N(e,t){null!=t&&(e.className=t),e.setAttribute("aria-label","Typeahead menu"),e.setAttribute("role","listbox"),e.style.display="block",e.style.position="absolute"}function D({options:t,nodeKey:o,onClose:l,onOpen:r,onSelectOption:i,anchorClassName:u,commandPriority:s=n,parent:c}){const[d]=e(),[y,v]=h(null),b=function(t,n,o,l=(E?document.body:void 0),r=!0){const[i]=e(),u=E?document.createElement("div"):null,s=f(u),c=g(()=>{if(null===s.current||void 0===l)return;s.current.style.top=s.current.style.bottom;const e=i.getRootElement(),n=s.current,u=n.firstChild;if(null!==e&&null!==t){const{left:i,top:c,width:a,height:m}=t.getRect(),d=s.current.offsetHeight;if(n.style.top=`${c+d+3+(r?window.pageYOffset:0)}px`,n.style.left=`${i+window.pageXOffset}px`,n.style.height=`${m}px`,n.style.width=`${a}px`,null!==u){u.style.top=`${c}`;const t=u.getBoundingClientRect(),o=t.height,l=t.width,s=e.getBoundingClientRect();i+l>s.right&&(n.style.left=`${s.right-l+window.pageXOffset}px`),(c+o>window.innerHeight||c+o>s.bottom)&&c-s.top>o+m&&(n.style.top=`${c-o-m+(r?window.pageYOffset:0)}px`)}n.isConnected||(N(n,o),l.append(n)),n.setAttribute("id","typeahead-menu"),e.setAttribute("aria-controls","typeahead-menu")}},[i,t,r,o,l]);p(()=>{const e=i.getRootElement();return null!==t&&c(),()=>{null!==e&&e.removeAttribute("aria-controls");const t=s.current;null!==t&&t.isConnected&&(t.remove(),t.removeAttribute("id"))}},[i,c,t]);const a=g(e=>{null!==t&&(e||n(null))},[t,n]);return S(t,s.current,c,a),null!=u&&u===s.current&&(N(u,o),null!=l&&l.append(u)),s}(y,v,u,c),x=g(()=>{v(null),null!=l&&null!==y&&l()},[l,y]),R=g(e=>{v(e),null!=r&&null===y&&r(e)},[r,y]),I=g(()=>{o?d.update(()=>{const e=a(o),t=d.getElementByKey(o);var n;null!=e&&null!=t&&null==y&&(n=()=>R({getRect:()=>t.getBoundingClientRect()}),C in m?m[C](n):n())}):null==o&&null!=y&&x()},[x,d,o,R,y]);return p(()=>{I()},[I,o]),p(()=>{if(null!=o)return d.registerUpdateListener(({dirtyElements:e})=>{e.get(o)&&I()})},[d,I,o]),null===b.current||null===y||null===d?null:w(k,{close:x,resolution:y,editor:d,anchorElementRef:b,options:t,onSelectOption:i,commandPriority:s})}export{D as LexicalNodeMenuPlugin,R as MenuOption}; +diff --git a/node_modules/@lexical/react/LexicalTablePlugin.d.ts b/node_modules/@lexical/react/LexicalTablePlugin.d.ts +index 78fed1a..d3ddb2c 100644 +--- a/node_modules/@lexical/react/LexicalTablePlugin.d.ts ++++ b/node_modules/@lexical/react/LexicalTablePlugin.d.ts +@@ -24,6 +24,12 @@ export interface TablePluginProps { + * When `true` (default `false`), tables will be wrapped in a `
` to enable horizontal scrolling + */ + hasHorizontalScroll?: boolean; ++ /** ++ * When `true` (default `false`), nested tables will be allowed. ++ * ++ * @experimental Nested tables are not officially supported. ++ */ ++ hasNestedTables?: boolean; + } + /** + * A plugin to enable all of the features of Lexical's TableNode. +@@ -31,4 +37,4 @@ export interface TablePluginProps { + * @param props - See type for documentation + * @returns An element to render in your LexicalComposer + */ +-export declare function TablePlugin({ hasCellMerge, hasCellBackgroundColor, hasTabHandler, hasHorizontalScroll, }: TablePluginProps): JSX.Element | null; ++export declare function TablePlugin({ hasCellMerge, hasCellBackgroundColor, hasTabHandler, hasHorizontalScroll, hasNestedTables, }: TablePluginProps): JSX.Element | null; +diff --git a/node_modules/@lexical/react/LexicalTablePlugin.dev.js b/node_modules/@lexical/react/LexicalTablePlugin.dev.js +index ee13d80..6cb3a73 100644 +--- a/node_modules/@lexical/react/LexicalTablePlugin.dev.js ++++ b/node_modules/@lexical/react/LexicalTablePlugin.dev.js +@@ -8,6 +8,7 @@ + + 'use strict'; + ++var extension = require('@lexical/extension'); + var LexicalComposerContext = require('@lexical/react/LexicalComposerContext'); + var table = require('@lexical/table'); + var react = require('react'); +@@ -30,7 +31,8 @@ function TablePlugin({ + hasCellMerge = true, + hasCellBackgroundColor = true, + hasTabHandler = true, +- hasHorizontalScroll = false ++ hasHorizontalScroll = false, ++ hasNestedTables = false + }) { + const [editor] = LexicalComposerContext.useLexicalComposerContext(); + react.useEffect(() => { +@@ -42,7 +44,13 @@ function TablePlugin({ + editor.registerNodeTransform(table.TableNode, () => {})(); + } + }, [editor, hasHorizontalScroll]); +- react.useEffect(() => table.registerTablePlugin(editor), [editor]); ++ const hasNestedTablesSignal = react.useMemo(() => extension.signal(false), []); ++ if (hasNestedTablesSignal.peek() !== hasNestedTables) { ++ hasNestedTablesSignal.value = hasNestedTables; ++ } ++ react.useEffect(() => table.registerTablePlugin(editor, { ++ hasNestedTables: hasNestedTablesSignal ++ }), [editor, hasNestedTablesSignal]); + react.useEffect(() => table.registerTableSelectionObserver(editor, hasTabHandler), [editor, hasTabHandler]); + + // Unmerge cells when the feature isn't enabled +diff --git a/node_modules/@lexical/react/LexicalTablePlugin.dev.mjs b/node_modules/@lexical/react/LexicalTablePlugin.dev.mjs +index 8217ccb..95ab1c0 100644 +--- a/node_modules/@lexical/react/LexicalTablePlugin.dev.mjs ++++ b/node_modules/@lexical/react/LexicalTablePlugin.dev.mjs +@@ -6,9 +6,10 @@ + * + */ + ++import { signal } from '@lexical/extension'; + import { useLexicalComposerContext } from '@lexical/react/LexicalComposerContext'; + import { $isScrollableTablesActive, setScrollableTablesActive, TableNode, registerTablePlugin, registerTableSelectionObserver, registerTableCellUnmergeTransform, TableCellNode } from '@lexical/table'; +-import { useEffect } from 'react'; ++import { useEffect, useMemo } from 'react'; + + /** + * Copyright (c) Meta Platforms, Inc. and affiliates. +@@ -28,7 +29,8 @@ function TablePlugin({ + hasCellMerge = true, + hasCellBackgroundColor = true, + hasTabHandler = true, +- hasHorizontalScroll = false ++ hasHorizontalScroll = false, ++ hasNestedTables = false + }) { + const [editor] = useLexicalComposerContext(); + useEffect(() => { +@@ -40,7 +42,13 @@ function TablePlugin({ + editor.registerNodeTransform(TableNode, () => {})(); + } + }, [editor, hasHorizontalScroll]); +- useEffect(() => registerTablePlugin(editor), [editor]); ++ const hasNestedTablesSignal = useMemo(() => signal(false), []); ++ if (hasNestedTablesSignal.peek() !== hasNestedTables) { ++ hasNestedTablesSignal.value = hasNestedTables; ++ } ++ useEffect(() => registerTablePlugin(editor, { ++ hasNestedTables: hasNestedTablesSignal ++ }), [editor, hasNestedTablesSignal]); + useEffect(() => registerTableSelectionObserver(editor, hasTabHandler), [editor, hasTabHandler]); + + // Unmerge cells when the feature isn't enabled +diff --git a/node_modules/@lexical/react/LexicalTablePlugin.prod.js b/node_modules/@lexical/react/LexicalTablePlugin.prod.js +index 3b68b89..ea31fbd 100644 +--- a/node_modules/@lexical/react/LexicalTablePlugin.prod.js ++++ b/node_modules/@lexical/react/LexicalTablePlugin.prod.js +@@ -6,4 +6,4 @@ + * + */ + +-"use strict";var e=require("@lexical/react/LexicalComposerContext"),r=require("@lexical/table"),l=require("react");exports.TablePlugin=function({hasCellMerge:t=!0,hasCellBackgroundColor:a=!0,hasTabHandler:o=!0,hasHorizontalScroll:s=!1}){const[c]=e.useLexicalComposerContext();return l.useEffect(()=>{r.$isScrollableTablesActive(c)!==s&&(r.setScrollableTablesActive(c,s),c.registerNodeTransform(r.TableNode,()=>{})())},[c,s]),l.useEffect(()=>r.registerTablePlugin(c),[c]),l.useEffect(()=>r.registerTableSelectionObserver(c,o),[c,o]),l.useEffect(()=>{if(!t)return r.registerTableCellUnmergeTransform(c)},[c,t]),l.useEffect(()=>{if(!a)return c.registerNodeTransform(r.TableCellNode,e=>{null!==e.getBackgroundColor()&&e.setBackgroundColor(null)})},[c,a,t]),null}; ++"use strict";var e=require("@lexical/extension"),r=require("@lexical/react/LexicalComposerContext"),l=require("@lexical/table"),s=require("react");exports.TablePlugin=function({hasCellMerge:a=!0,hasCellBackgroundColor:t=!0,hasTabHandler:o=!0,hasHorizontalScroll:i=!1,hasNestedTables:n=!1}){const[c]=r.useLexicalComposerContext();s.useEffect(()=>{l.$isScrollableTablesActive(c)!==i&&(l.setScrollableTablesActive(c,i),c.registerNodeTransform(l.TableNode,()=>{})())},[c,i]);const u=s.useMemo(()=>e.signal(!1),[]);return u.peek()!==n&&(u.value=n),s.useEffect(()=>l.registerTablePlugin(c,{hasNestedTables:u}),[c,u]),s.useEffect(()=>l.registerTableSelectionObserver(c,o),[c,o]),s.useEffect(()=>{if(!a)return l.registerTableCellUnmergeTransform(c)},[c,a]),s.useEffect(()=>{if(!t)return c.registerNodeTransform(l.TableCellNode,e=>{null!==e.getBackgroundColor()&&e.setBackgroundColor(null)})},[c,t,a]),null}; +diff --git a/node_modules/@lexical/react/LexicalTablePlugin.prod.mjs b/node_modules/@lexical/react/LexicalTablePlugin.prod.mjs +index 9b12bce..c3cb971 100644 +--- a/node_modules/@lexical/react/LexicalTablePlugin.prod.mjs ++++ b/node_modules/@lexical/react/LexicalTablePlugin.prod.mjs +@@ -6,4 +6,4 @@ + * + */ + +-import{useLexicalComposerContext as r}from"@lexical/react/LexicalComposerContext";import{$isScrollableTablesActive as o,setScrollableTablesActive as e,TableNode as l,registerTablePlugin as t,registerTableSelectionObserver as a,registerTableCellUnmergeTransform as n,TableCellNode as i}from"@lexical/table";import{useEffect as c}from"react";function s({hasCellMerge:s=!0,hasCellBackgroundColor:u=!0,hasTabHandler:m=!0,hasHorizontalScroll:f=!1}){const[g]=r();return c(()=>{o(g)!==f&&(e(g,f),g.registerNodeTransform(l,()=>{})())},[g,f]),c(()=>t(g),[g]),c(()=>a(g,m),[g,m]),c(()=>{if(!s)return n(g)},[g,s]),c(()=>{if(!u)return g.registerNodeTransform(i,r=>{null!==r.getBackgroundColor()&&r.setBackgroundColor(null)})},[g,u,s]),null}export{s as TablePlugin}; ++import{signal as e}from"@lexical/extension";import{useLexicalComposerContext as r}from"@lexical/react/LexicalComposerContext";import{$isScrollableTablesActive as o,setScrollableTablesActive as l,TableNode as a,registerTablePlugin as t,registerTableSelectionObserver as n,registerTableCellUnmergeTransform as s,TableCellNode as i}from"@lexical/table";import{useEffect as c,useMemo as m}from"react";function u({hasCellMerge:u=!0,hasCellBackgroundColor:f=!0,hasTabHandler:d=!0,hasHorizontalScroll:g=!1,hasNestedTables:p=!1}){const[x]=r();c(()=>{o(x)!==g&&(l(x,g),x.registerNodeTransform(a,()=>{})())},[x,g]);const C=m(()=>e(!1),[]);return C.peek()!==p&&(C.value=p),c(()=>t(x,{hasNestedTables:C}),[x,C]),c(()=>n(x,d),[x,d]),c(()=>{if(!u)return s(x)},[x,u]),c(()=>{if(!f)return x.registerNodeTransform(i,e=>{null!==e.getBackgroundColor()&&e.setBackgroundColor(null)})},[x,f,u]),null}export{u as TablePlugin}; +diff --git a/node_modules/@lexical/react/LexicalTypeaheadMenuPlugin.d.ts b/node_modules/@lexical/react/LexicalTypeaheadMenuPlugin.d.ts +index 31eb4db..03ca321 100644 +--- a/node_modules/@lexical/react/LexicalTypeaheadMenuPlugin.d.ts ++++ b/node_modules/@lexical/react/LexicalTypeaheadMenuPlugin.d.ts +@@ -5,7 +5,7 @@ + * LICENSE file in the root directory of this source tree. + * + */ +-import type { MenuRenderFn, MenuResolution, MenuTextMatch, TriggerFn } from './shared/LexicalMenu'; ++import type { MenuResolution, MenuTextMatch, TriggerFn } from './shared/LexicalMenu'; + import type { JSX } from 'react'; + import { CommandListenerPriority, LexicalCommand, TextNode } from 'lexical'; + import { MenuOption } from './shared/LexicalMenu'; +@@ -26,7 +26,6 @@ export type TypeaheadMenuPluginProps = { + onQueryChange: (matchingString: string | null) => void; + onSelectOption: (option: TOption, textNodeContainingQuery: TextNode | null, closeMenu: () => void, matchingString: string) => void; + options: Array; +- menuRenderFn: MenuRenderFn; + triggerFn: TriggerFn; + onOpen?: (resolution: MenuResolution) => void; + onClose?: () => void; +@@ -36,5 +35,5 @@ export type TypeaheadMenuPluginProps = { + preselectFirstItem?: boolean; + ignoreEntityBoundary?: boolean; + }; +-export declare function LexicalTypeaheadMenuPlugin({ options, onQueryChange, onSelectOption, onOpen, onClose, menuRenderFn, triggerFn, anchorClassName, commandPriority, parent, preselectFirstItem, ignoreEntityBoundary, }: TypeaheadMenuPluginProps): JSX.Element | null; +-export { MenuOption, MenuRenderFn, MenuResolution, MenuTextMatch, TriggerFn }; ++export declare function LexicalTypeaheadMenuPlugin({ options, onQueryChange, onSelectOption, onOpen, onClose, triggerFn, anchorClassName, commandPriority, parent, preselectFirstItem, ignoreEntityBoundary, }: TypeaheadMenuPluginProps): JSX.Element | null; ++export { MenuOption, MenuResolution, MenuTextMatch, TriggerFn }; +diff --git a/node_modules/@lexical/react/LexicalTypeaheadMenuPlugin.dev.js b/node_modules/@lexical/react/LexicalTypeaheadMenuPlugin.dev.js +index 0611c30..bf6046f 100644 +--- a/node_modules/@lexical/react/LexicalTypeaheadMenuPlugin.dev.js ++++ b/node_modules/@lexical/react/LexicalTypeaheadMenuPlugin.dev.js +@@ -12,6 +12,7 @@ var LexicalComposerContext = require('@lexical/react/LexicalComposerContext'); + var lexical = require('lexical'); + var React = require('react'); + var utils = require('@lexical/utils'); ++var ReactDOM = require('react-dom'); + var jsxRuntime = require('react/jsx-runtime'); + + /** +@@ -70,6 +71,8 @@ const useLayoutEffectImpl = CAN_USE_DOM ? React.useLayoutEffect : React.useEffec + class MenuOption { + key; + ref; ++ icon; ++ title; + constructor(key) { + this.key = key; + this.ref = { +@@ -219,13 +222,38 @@ function useDynamicPositioning(resolution, targetElement, onReposition, onVisibi + }, [targetElement, editor, onVisibilityChange, onReposition, resolution]); + } + const SCROLL_TYPEAHEAD_OPTION_INTO_VIEW_COMMAND$1 = lexical.createCommand('SCROLL_TYPEAHEAD_OPTION_INTO_VIEW_COMMAND'); ++function MenuItem({ ++ index, ++ isSelected, ++ onClick, ++ onMouseEnter, ++ option ++}) { ++ let className = 'item'; ++ if (isSelected) { ++ className += ' selected'; ++ } ++ return /*#__PURE__*/jsxRuntime.jsxs("li", { ++ tabIndex: -1, ++ className: className, ++ ref: option.setRefElement, ++ role: "option", ++ "aria-selected": isSelected, ++ id: 'typeahead-item-' + index, ++ onMouseEnter: onMouseEnter, ++ onClick: onClick, ++ children: [option.icon, /*#__PURE__*/jsxRuntime.jsx("span", { ++ className: "text", ++ children: option.title ++ })] ++ }, option.key); ++} + function LexicalMenu({ + close, + editor, + anchorElementRef, + resolution, + options, +- menuRenderFn, + onSelectOption, + shouldSplitNodeWithQuery = false, + commandPriority = lexical.COMMAND_PRIORITY_LOW, +@@ -253,6 +281,25 @@ function LexicalMenu({ + setHighlightedIndex(index); + } + }, [editor]); ++ const menuRenderFn = React.useCallback(() => { ++ return anchorElementRef.current && options.length ? /*#__PURE__*/ReactDOM.createPortal(/*#__PURE__*/jsxRuntime.jsx("div", { ++ className: "typeahead-popover mentions-menu", ++ children: /*#__PURE__*/jsxRuntime.jsx("ul", { ++ children: options.map((option, i) => /*#__PURE__*/jsxRuntime.jsx(MenuItem, { ++ index: i, ++ isSelected: selectedIndex === i, ++ onClick: () => { ++ setHighlightedIndex(i); ++ selectOptionAndCleanUp(option); ++ }, ++ onMouseEnter: () => { ++ setHighlightedIndex(i); ++ }, ++ option: option ++ }, option.key)) ++ }) ++ }), anchorElementRef.current) : null; ++ }, [anchorElementRef, options, selectedIndex, selectOptionAndCleanUp, setHighlightedIndex]); + React.useEffect(() => { + return () => { + const rootElem = editor.getRootElement(); +@@ -348,13 +395,7 @@ function LexicalMenu({ + return true; + }, commandPriority)); + }, [selectOptionAndCleanUp, close, editor, options, selectedIndex, updateSelectedIndex, commandPriority]); +- const listItemProps = React.useMemo(() => ({ +- options, +- selectOptionAndCleanUp, +- selectedIndex, +- setHighlightedIndex +- }), [selectOptionAndCleanUp, selectedIndex, options]); +- return menuRenderFn(anchorElementRef, listItemProps, resolution.match ? resolution.match.matchingString : ''); ++ return menuRenderFn(); + } + function setContainerDivAttributes(containerDiv, className) { + if (className != null) { +@@ -467,8 +508,8 @@ function getTextUpToAnchor(selection) { + const anchorOffset = anchor.offset; + return anchorNode.getTextContent().slice(0, anchorOffset); + } +-function tryToPositionRange(leadOffset, range, editorWindow) { +- const domSelection = lexical.getDOMSelection(editorWindow); ++function tryToPositionRange(leadOffset, range, editor) { ++ const domSelection = lexical.getDOMSelectionForEditor(editor); + if (domSelection === null || !domSelection.isCollapsed) { + return false; + } +@@ -564,7 +605,6 @@ function LexicalTypeaheadMenuPlugin({ + onSelectOption, + onOpen, + onClose, +- menuRenderFn, + triggerFn, + anchorClassName, + commandPriority = lexical.COMMAND_PRIORITY_LOW, +@@ -595,6 +635,9 @@ function LexicalTypeaheadMenuPlugin({ + closeTypeahead(); + return; + } ++ if (editor.isComposing()) { ++ return; ++ } + const editorWindow = editor._window || window; + const range = editorWindow.document.createRange(); + const selection = lexical.$getSelection(); +@@ -606,7 +649,7 @@ function LexicalTypeaheadMenuPlugin({ + const match = triggerFn(text, editor); + onQueryChange(match ? match.matchingString : null); + if (match !== null && (ignoreEntityBoundary || !isSelectionOnEntityBoundary(editor, match.leadOffset))) { +- const isRangePositioned = tryToPositionRange(match.leadOffset, range, editorWindow); ++ const isRangePositioned = tryToPositionRange(match.leadOffset, range, editor); + if (isRangePositioned !== null) { + startTransition(() => openTypeahead({ + getRect: () => range.getBoundingClientRect(), +@@ -634,7 +677,6 @@ function LexicalTypeaheadMenuPlugin({ + editor: editor, + anchorElementRef: anchorElementRef, + options: options, +- menuRenderFn: menuRenderFn, + shouldSplitNodeWithQuery: true, + onSelectOption: onSelectOption, + commandPriority: commandPriority, +diff --git a/node_modules/@lexical/react/LexicalTypeaheadMenuPlugin.dev.mjs b/node_modules/@lexical/react/LexicalTypeaheadMenuPlugin.dev.mjs +index df6ae52..8cffbc1 100644 +--- a/node_modules/@lexical/react/LexicalTypeaheadMenuPlugin.dev.mjs ++++ b/node_modules/@lexical/react/LexicalTypeaheadMenuPlugin.dev.mjs +@@ -7,10 +7,11 @@ + */ + + import { useLexicalComposerContext } from '@lexical/react/LexicalComposerContext'; +-import { createCommand, COMMAND_PRIORITY_LOW, KEY_ARROW_DOWN_COMMAND, KEY_ARROW_UP_COMMAND, KEY_ESCAPE_COMMAND, KEY_TAB_COMMAND, KEY_ENTER_COMMAND, $getSelection, $isRangeSelection, $isTextNode, getDOMSelection } from 'lexical'; +-import React, { useLayoutEffect, useEffect, useRef, useCallback, useState, useMemo } from 'react'; ++import { createCommand, COMMAND_PRIORITY_LOW, KEY_ARROW_DOWN_COMMAND, KEY_ARROW_UP_COMMAND, KEY_ESCAPE_COMMAND, KEY_TAB_COMMAND, KEY_ENTER_COMMAND, $getSelection, $isRangeSelection, $isTextNode, getDOMSelectionForEditor } from 'lexical'; ++import React, { useLayoutEffect, useEffect, useRef, useCallback, useState } from 'react'; + import { mergeRegister } from '@lexical/utils'; +-import { jsx } from 'react/jsx-runtime'; ++import ReactDOM from 'react-dom'; ++import { jsx, jsxs } from 'react/jsx-runtime'; + + /** + * Copyright (c) Meta Platforms, Inc. and affiliates. +@@ -68,6 +69,8 @@ const useLayoutEffectImpl = CAN_USE_DOM ? useLayoutEffect : useEffect; + class MenuOption { + key; + ref; ++ icon; ++ title; + constructor(key) { + this.key = key; + this.ref = { +@@ -217,13 +220,38 @@ function useDynamicPositioning(resolution, targetElement, onReposition, onVisibi + }, [targetElement, editor, onVisibilityChange, onReposition, resolution]); + } + const SCROLL_TYPEAHEAD_OPTION_INTO_VIEW_COMMAND$1 = createCommand('SCROLL_TYPEAHEAD_OPTION_INTO_VIEW_COMMAND'); ++function MenuItem({ ++ index, ++ isSelected, ++ onClick, ++ onMouseEnter, ++ option ++}) { ++ let className = 'item'; ++ if (isSelected) { ++ className += ' selected'; ++ } ++ return /*#__PURE__*/jsxs("li", { ++ tabIndex: -1, ++ className: className, ++ ref: option.setRefElement, ++ role: "option", ++ "aria-selected": isSelected, ++ id: 'typeahead-item-' + index, ++ onMouseEnter: onMouseEnter, ++ onClick: onClick, ++ children: [option.icon, /*#__PURE__*/jsx("span", { ++ className: "text", ++ children: option.title ++ })] ++ }, option.key); ++} + function LexicalMenu({ + close, + editor, + anchorElementRef, + resolution, + options, +- menuRenderFn, + onSelectOption, + shouldSplitNodeWithQuery = false, + commandPriority = COMMAND_PRIORITY_LOW, +@@ -251,6 +279,25 @@ function LexicalMenu({ + setHighlightedIndex(index); + } + }, [editor]); ++ const menuRenderFn = useCallback(() => { ++ return anchorElementRef.current && options.length ? /*#__PURE__*/ReactDOM.createPortal(/*#__PURE__*/jsx("div", { ++ className: "typeahead-popover mentions-menu", ++ children: /*#__PURE__*/jsx("ul", { ++ children: options.map((option, i) => /*#__PURE__*/jsx(MenuItem, { ++ index: i, ++ isSelected: selectedIndex === i, ++ onClick: () => { ++ setHighlightedIndex(i); ++ selectOptionAndCleanUp(option); ++ }, ++ onMouseEnter: () => { ++ setHighlightedIndex(i); ++ }, ++ option: option ++ }, option.key)) ++ }) ++ }), anchorElementRef.current) : null; ++ }, [anchorElementRef, options, selectedIndex, selectOptionAndCleanUp, setHighlightedIndex]); + useEffect(() => { + return () => { + const rootElem = editor.getRootElement(); +@@ -346,13 +393,7 @@ function LexicalMenu({ + return true; + }, commandPriority)); + }, [selectOptionAndCleanUp, close, editor, options, selectedIndex, updateSelectedIndex, commandPriority]); +- const listItemProps = useMemo(() => ({ +- options, +- selectOptionAndCleanUp, +- selectedIndex, +- setHighlightedIndex +- }), [selectOptionAndCleanUp, selectedIndex, options]); +- return menuRenderFn(anchorElementRef, listItemProps, resolution.match ? resolution.match.matchingString : ''); ++ return menuRenderFn(); + } + function setContainerDivAttributes(containerDiv, className) { + if (className != null) { +@@ -465,8 +506,8 @@ function getTextUpToAnchor(selection) { + const anchorOffset = anchor.offset; + return anchorNode.getTextContent().slice(0, anchorOffset); + } +-function tryToPositionRange(leadOffset, range, editorWindow) { +- const domSelection = getDOMSelection(editorWindow); ++function tryToPositionRange(leadOffset, range, editor) { ++ const domSelection = getDOMSelectionForEditor(editor); + if (domSelection === null || !domSelection.isCollapsed) { + return false; + } +@@ -562,7 +603,6 @@ function LexicalTypeaheadMenuPlugin({ + onSelectOption, + onOpen, + onClose, +- menuRenderFn, + triggerFn, + anchorClassName, + commandPriority = COMMAND_PRIORITY_LOW, +@@ -593,6 +633,9 @@ function LexicalTypeaheadMenuPlugin({ + closeTypeahead(); + return; + } ++ if (editor.isComposing()) { ++ return; ++ } + const editorWindow = editor._window || window; + const range = editorWindow.document.createRange(); + const selection = $getSelection(); +@@ -604,7 +647,7 @@ function LexicalTypeaheadMenuPlugin({ + const match = triggerFn(text, editor); + onQueryChange(match ? match.matchingString : null); + if (match !== null && (ignoreEntityBoundary || !isSelectionOnEntityBoundary(editor, match.leadOffset))) { +- const isRangePositioned = tryToPositionRange(match.leadOffset, range, editorWindow); ++ const isRangePositioned = tryToPositionRange(match.leadOffset, range, editor); + if (isRangePositioned !== null) { + startTransition(() => openTypeahead({ + getRect: () => range.getBoundingClientRect(), +@@ -632,7 +675,6 @@ function LexicalTypeaheadMenuPlugin({ + editor: editor, + anchorElementRef: anchorElementRef, + options: options, +- menuRenderFn: menuRenderFn, + shouldSplitNodeWithQuery: true, + onSelectOption: onSelectOption, + commandPriority: commandPriority, +diff --git a/node_modules/@lexical/react/LexicalTypeaheadMenuPlugin.js.flow b/node_modules/@lexical/react/LexicalTypeaheadMenuPlugin.js.flow +index 82c3883..3e4b7d2 100644 +--- a/node_modules/@lexical/react/LexicalTypeaheadMenuPlugin.js.flow ++++ b/node_modules/@lexical/react/LexicalTypeaheadMenuPlugin.js.flow +@@ -36,17 +36,6 @@ declare export var SCROLL_TYPEAHEAD_OPTION_INTO_VIEW_COMMAND: LexicalCommand<{ + option: MenuOption, + }>; + +-export type MenuRenderFn = ( +- anchorElementRef: {current: HTMLElement | null}, +- itemProps: { +- selectedIndex: number | null, +- selectOptionAndCleanUp: (option: TOption) => void, +- setHighlightedIndex: (index: number) => void, +- options: Array, +- }, +- matchingString: string, +-) => React.Portal | React.MixedElement | null; +- + declare export function getScrollParent( + element: HTMLElement, + includeHidden: boolean, +@@ -66,7 +55,6 @@ export type TypeaheadMenuPluginProps = { + matchingString: string, + ) => void, + options: Array, +- menuRenderFn: MenuRenderFn, + triggerFn: TriggerFn, + onOpen?: (resolution: MenuResolution) => void, + onClose?: () => void, +diff --git a/node_modules/@lexical/react/LexicalTypeaheadMenuPlugin.prod.js b/node_modules/@lexical/react/LexicalTypeaheadMenuPlugin.prod.js +index 7dc6b12..af9dc7e 100644 +--- a/node_modules/@lexical/react/LexicalTypeaheadMenuPlugin.prod.js ++++ b/node_modules/@lexical/react/LexicalTypeaheadMenuPlugin.prod.js +@@ -6,4 +6,4 @@ + * + */ + +-"use strict";var e=require("@lexical/react/LexicalComposerContext"),t=require("lexical"),n=require("react"),o=require("@lexical/utils"),r=require("react/jsx-runtime");const l="startTransition";const i="undefined"!=typeof window&&void 0!==window.document&&void 0!==window.document.createElement,s=i?n.useLayoutEffect:n.useEffect;const u=e=>{const t=document.getElementById("typeahead-menu");if(!t)return;const n=t.getBoundingClientRect();n.top+n.height>window.innerHeight&&t.scrollIntoView({block:"center"}),n.top<0&&t.scrollIntoView({block:"center"}),e.scrollIntoView({block:"nearest"})};function c(e,t){const n=e.getBoundingClientRect(),o=t.getBoundingClientRect();return n.top>=o.top-6&&n.top<=o.bottom+6}function a(t,o,r,l){const[i]=e.useLexicalComposerContext();n.useEffect(()=>{if(null!=o&&null!=t){const e=i.getRootElement(),t=null!=e?function(e){let t=getComputedStyle(e);const n="absolute"===t.position,o=/(auto|scroll)/;if("fixed"===t.position)return document.body;for(let r=e;r=r.parentElement;)if(t=getComputedStyle(r),(!n||"static"!==t.position)&&o.test(t.overflow+t.overflowY+t.overflowX))return r;return document.body}(e):document.body;let n=!1,s=c(o,t);const u=function(){n||(window.requestAnimationFrame(function(){r(),n=!1}),n=!0);const e=c(o,t);e!==s&&(s=e,null!=l&&l(e))},a=new ResizeObserver(r);return window.addEventListener("resize",r),document.addEventListener("scroll",u,{capture:!0,passive:!0}),a.observe(o),()=>{a.unobserve(o),window.removeEventListener("resize",r),document.removeEventListener("scroll",u,!0)}}},[o,i,l,r,t])}const d=t.createCommand("SCROLL_TYPEAHEAD_OPTION_INTO_VIEW_COMMAND");function f({close:e,editor:r,anchorElementRef:l,resolution:i,options:c,menuRenderFn:a,onSelectOption:f,shouldSplitNodeWithQuery:m=!1,commandPriority:p=t.COMMAND_PRIORITY_LOW,preselectFirstItem:g=!0}){const[h,C]=n.useState(null),E=null!==h?Math.min(c.length-1,h):null,x=i.match&&i.match.matchingString;n.useEffect(()=>{g&&C(0)},[x,g]);const y=n.useCallback(n=>{r.update(()=>{const o=null!=i.match&&m?function(e){const n=t.$getSelection();if(!t.$isRangeSelection(n)||!n.isCollapsed())return null;const o=n.anchor;if("text"!==o.type)return null;const r=o.getNode();if(!r.isSimpleText())return null;const l=o.offset,i=r.getTextContent().slice(0,l),s=e.replaceableString.length,u=l-function(e,t,n){let o=n;for(let n=o;n<=t.length;n++)e.slice(-n)===t.substring(0,n)&&(o=n);return o}(i,e.matchingString,s);if(u<0)return null;let c;return 0===u?[c]=r.splitText(l):[,c]=r.splitText(u,l),c}(i.match):null;f(n,o,e,i.match?i.match.matchingString:"")})},[r,m,i.match,f,e]),O=n.useCallback(e=>{const t=r.getRootElement();null!==t&&(t.setAttribute("aria-activedescendant","typeahead-item-"+e),C(e))},[r]);n.useEffect(()=>()=>{const e=r.getRootElement();null!==e&&e.removeAttribute("aria-activedescendant")},[r]),s(()=>{null===c?C(null):null===E&&g&&O(0)},[c,E,O,g]),n.useEffect(()=>o.mergeRegister(r.registerCommand(d,({option:e})=>!(!e.ref||null==e.ref.current)&&(u(e.ref.current),!0),p)),[r,O,p]),n.useEffect(()=>o.mergeRegister(r.registerCommand(t.KEY_ARROW_DOWN_COMMAND,e=>{const t=e;if(null!==c&&c.length){const e=null===E?0:E!==c.length-1?E+1:0;O(e);const n=c[e];if(!n)return O(-1),t.preventDefault(),t.stopImmediatePropagation(),!0;n.ref&&n.ref.current&&r.dispatchCommand(d,{index:e,option:n}),t.preventDefault(),t.stopImmediatePropagation()}return!0},p),r.registerCommand(t.KEY_ARROW_UP_COMMAND,e=>{const t=e;if(null!==c&&c.length){const e=null===E?c.length-1:0!==E?E-1:c.length-1;O(e);const n=c[e];if(!n)return O(-1),t.preventDefault(),t.stopImmediatePropagation(),!0;n.ref&&n.ref.current&&u(n.ref.current),t.preventDefault(),t.stopImmediatePropagation()}return!0},p),r.registerCommand(t.KEY_ESCAPE_COMMAND,t=>{const n=t;return n.preventDefault(),n.stopImmediatePropagation(),e(),!0},p),r.registerCommand(t.KEY_TAB_COMMAND,e=>{const t=e;return null!==c&&null!==E&&null!=c[E]&&(t.preventDefault(),t.stopImmediatePropagation(),y(c[E]),!0)},p),r.registerCommand(t.KEY_ENTER_COMMAND,e=>null!==c&&null!==E&&null!=c[E]&&(null!==e&&(e.preventDefault(),e.stopImmediatePropagation()),y(c[E]),!0),p)),[y,e,r,c,E,O,p]);return a(l,n.useMemo(()=>({options:c,selectOptionAndCleanUp:y,selectedIndex:E,setHighlightedIndex:C}),[y,E,c]),i.match?i.match.matchingString:"")}function m(e,t){null!=t&&(e.className=t),e.setAttribute("aria-label","Typeahead menu"),e.setAttribute("role","listbox"),e.style.display="block",e.style.position="absolute"}const p="\\.,\\+\\*\\?\\$\\@\\|#{}\\(\\)\\^\\-\\[\\]\\\\/!%'\"~=<>_:;";const g=t.createCommand("SCROLL_TYPEAHEAD_OPTION_INTO_VIEW_COMMAND");exports.LexicalTypeaheadMenuPlugin=function({options:o,onQueryChange:s,onSelectOption:u,onOpen:c,onClose:d,menuRenderFn:p,triggerFn:g,anchorClassName:h,commandPriority:C=t.COMMAND_PRIORITY_LOW,parent:E,preselectFirstItem:x=!0,ignoreEntityBoundary:y=!1}){const[O]=e.useLexicalComposerContext(),[b,w]=n.useState(null),R=function(t,o,r,l=(i?document.body:void 0),s=!0){const[u]=e.useLexicalComposerContext(),c=i?document.createElement("div"):null,d=n.useRef(c),f=n.useCallback(()=>{if(null===d.current||void 0===l)return;d.current.style.top=d.current.style.bottom;const e=u.getRootElement(),n=d.current,o=n.firstChild;if(null!==e&&null!==t){const{left:i,top:u,width:c,height:a}=t.getRect(),f=d.current.offsetHeight;if(n.style.top=`${u+f+3+(s?window.pageYOffset:0)}px`,n.style.left=`${i+window.pageXOffset}px`,n.style.height=`${a}px`,n.style.width=`${c}px`,null!==o){o.style.top=`${u}`;const t=o.getBoundingClientRect(),r=t.height,l=t.width,c=e.getBoundingClientRect();i+l>c.right&&(n.style.left=`${c.right-l+window.pageXOffset}px`),(u+r>window.innerHeight||u+r>c.bottom)&&u-c.top>r+a&&(n.style.top=`${u-r-a+(s?window.pageYOffset:0)}px`)}n.isConnected||(m(n,r),l.append(n)),n.setAttribute("id","typeahead-menu"),e.setAttribute("aria-controls","typeahead-menu")}},[u,t,s,r,l]);n.useEffect(()=>{const e=u.getRootElement();return null!==t&&f(),()=>{null!==e&&e.removeAttribute("aria-controls");const t=d.current;null!==t&&t.isConnected&&(t.remove(),t.removeAttribute("id"))}},[u,f,t]);const p=n.useCallback(e=>{null!==t&&(e||o(null))},[t,o]);return a(t,d.current,f,p),null!=c&&c===d.current&&(m(c,r),null!=l&&l.append(c)),d}(b,w,h,E),v=n.useCallback(()=>{w(null),null!=d&&null!==b&&d()},[d,b]),S=n.useCallback(e=>{w(e),null!=c&&null===b&&c(e)},[c,b]);return n.useEffect(()=>{const e=O.registerUpdateListener(()=>{O.getEditorState().read(()=>{if(!O.isEditable())return void v();const e=O._window||window,o=e.document.createRange(),r=t.$getSelection(),i=function(e){let n=null;return e.getEditorState().read(()=>{const e=t.$getSelection();t.$isRangeSelection(e)&&(n=function(e){const t=e.anchor;if("text"!==t.type)return null;const n=t.getNode();if(!n.isSimpleText())return null;const o=t.offset;return n.getTextContent().slice(0,o)}(e))}),n}(O);if(!t.$isRangeSelection(r)||!r.isCollapsed()||null===i||null===o)return void v();const u=g(i,O);if(s(u?u.matchingString:null),null!==u&&(y||!function(e,n){return 0===n&&e.getEditorState().read(()=>{const e=t.$getSelection();if(t.$isRangeSelection(e)){const n=e.anchor.getNode().getPreviousSibling();return t.$isTextNode(n)&&n.isTextEntity()}return!1})}(O,u.leadOffset))){const r=function(e,n,o){const r=t.getDOMSelection(o);if(null===r||!r.isCollapsed)return!1;const l=r.anchorNode,i=e,s=r.anchorOffset;if(null==l||null==s)return!1;try{n.setStart(l,i),n.setEnd(l,s)}catch(e){return!1}return!0}(u.leadOffset,o,e);if(null!==r)return c=()=>S({getRect:()=>o.getBoundingClientRect(),match:u}),void(l in n?n[l](c):c())}var c;v()})});return()=>{e()}},[O,g,s,b,v,S,y]),n.useEffect(()=>O.registerEditableListener(e=>{e||v()}),[O,v]),null===b||null===O||null===R.current?null:r.jsx(f,{close:v,resolution:b,editor:O,anchorElementRef:R,options:o,menuRenderFn:p,shouldSplitNodeWithQuery:!0,onSelectOption:u,commandPriority:C,preselectFirstItem:x})},exports.MenuOption=class{key;ref;constructor(e){this.key=e,this.ref={current:null},this.setRefElement=this.setRefElement.bind(this)}setRefElement(e){this.ref={current:e}}},exports.PUNCTUATION=p,exports.SCROLL_TYPEAHEAD_OPTION_INTO_VIEW_COMMAND=g,exports.getScrollParent=function(e,t){let n=getComputedStyle(e);const o="absolute"===n.position,r=t?/(auto|scroll|hidden)/:/(auto|scroll)/;if("fixed"===n.position)return document.body;for(let t=e;t=t.parentElement;)if(n=getComputedStyle(t),(!o||"static"!==n.position)&&r.test(n.overflow+n.overflowY+n.overflowX))return t;return document.body},exports.useBasicTypeaheadTriggerMatch=function(e,{minLength:t=1,maxLength:o=75,punctuation:r=p,allowWhitespace:l=!1}){return n.useCallback(n=>{const i=new RegExp("(^|\\s|\\()(["+e+"]((?:"+("[^"+e+r+(l?"":"\\s")+"]")+"){0,"+o+"}))$").exec(n);if(null!==i){const e=i[1],n=i[3];if(n.length>=t)return{leadOffset:i.index+e.length,matchingString:n,replaceableString:i[2]}}return null},[l,e,r,o,t])},exports.useDynamicPositioning=a; ++"use strict";var e=require("@lexical/react/LexicalComposerContext"),t=require("lexical"),n=require("react"),o=require("@lexical/utils"),r=require("react-dom"),l=require("react/jsx-runtime");const i="startTransition";const s="undefined"!=typeof window&&void 0!==window.document&&void 0!==window.document.createElement,u=s?n.useLayoutEffect:n.useEffect;const c=e=>{const t=document.getElementById("typeahead-menu");if(!t)return;const n=t.getBoundingClientRect();n.top+n.height>window.innerHeight&&t.scrollIntoView({block:"center"}),n.top<0&&t.scrollIntoView({block:"center"}),e.scrollIntoView({block:"nearest"})};function a(e,t){const n=e.getBoundingClientRect(),o=t.getBoundingClientRect();return n.top>=o.top-6&&n.top<=o.bottom+6}function d(t,o,r,l){const[i]=e.useLexicalComposerContext();n.useEffect(()=>{if(null!=o&&null!=t){const e=i.getRootElement(),t=null!=e?function(e){let t=getComputedStyle(e);const n="absolute"===t.position,o=/(auto|scroll)/;if("fixed"===t.position)return document.body;for(let r=e;r=r.parentElement;)if(t=getComputedStyle(r),(!n||"static"!==t.position)&&o.test(t.overflow+t.overflowY+t.overflowX))return r;return document.body}(e):document.body;let n=!1,s=a(o,t);const u=function(){n||(window.requestAnimationFrame(function(){r(),n=!1}),n=!0);const e=a(o,t);e!==s&&(s=e,null!=l&&l(e))},c=new ResizeObserver(r);return window.addEventListener("resize",r),document.addEventListener("scroll",u,{capture:!0,passive:!0}),c.observe(o),()=>{c.unobserve(o),window.removeEventListener("resize",r),document.removeEventListener("scroll",u,!0)}}},[o,i,l,r,t])}const f=t.createCommand("SCROLL_TYPEAHEAD_OPTION_INTO_VIEW_COMMAND");function m({index:e,isSelected:t,onClick:n,onMouseEnter:o,option:r}){let i="item";return t&&(i+=" selected"),l.jsxs("li",{tabIndex:-1,className:i,ref:r.setRefElement,role:"option","aria-selected":t,id:"typeahead-item-"+e,onMouseEnter:o,onClick:n,children:[r.icon,l.jsx("span",{className:"text",children:r.title})]},r.key)}function p({close:e,editor:i,anchorElementRef:s,resolution:a,options:d,onSelectOption:p,shouldSplitNodeWithQuery:g=!1,commandPriority:h=t.COMMAND_PRIORITY_LOW,preselectFirstItem:C=!0}){const[E,x]=n.useState(null),y=null!==E?Math.min(d.length-1,E):null,b=a.match&&a.match.matchingString;n.useEffect(()=>{C&&x(0)},[b,C]);const O=n.useCallback(n=>{i.update(()=>{const o=null!=a.match&&g?function(e){const n=t.$getSelection();if(!t.$isRangeSelection(n)||!n.isCollapsed())return null;const o=n.anchor;if("text"!==o.type)return null;const r=o.getNode();if(!r.isSimpleText())return null;const l=o.offset,i=r.getTextContent().slice(0,l),s=e.replaceableString.length,u=l-function(e,t,n){let o=n;for(let n=o;n<=t.length;n++)e.slice(-n)===t.substring(0,n)&&(o=n);return o}(i,e.matchingString,s);if(u<0)return null;let c;return 0===u?[c]=r.splitText(l):[,c]=r.splitText(u,l),c}(a.match):null;p(n,o,e,a.match?a.match.matchingString:"")})},[i,g,a.match,p,e]),w=n.useCallback(e=>{const t=i.getRootElement();null!==t&&(t.setAttribute("aria-activedescendant","typeahead-item-"+e),x(e))},[i]),v=n.useCallback(()=>s.current&&d.length?r.createPortal(l.jsx("div",{className:"typeahead-popover mentions-menu",children:l.jsx("ul",{children:d.map((e,t)=>l.jsx(m,{index:t,isSelected:y===t,onClick:()=>{x(t),O(e)},onMouseEnter:()=>{x(t)},option:e},e.key))})}),s.current):null,[s,d,y,O,x]);return n.useEffect(()=>()=>{const e=i.getRootElement();null!==e&&e.removeAttribute("aria-activedescendant")},[i]),u(()=>{null===d?x(null):null===y&&C&&w(0)},[d,y,w,C]),n.useEffect(()=>o.mergeRegister(i.registerCommand(f,({option:e})=>!(!e.ref||null==e.ref.current)&&(c(e.ref.current),!0),h)),[i,w,h]),n.useEffect(()=>o.mergeRegister(i.registerCommand(t.KEY_ARROW_DOWN_COMMAND,e=>{const t=e;if(null!==d&&d.length){const e=null===y?0:y!==d.length-1?y+1:0;w(e);const n=d[e];if(!n)return w(-1),t.preventDefault(),t.stopImmediatePropagation(),!0;n.ref&&n.ref.current&&i.dispatchCommand(f,{index:e,option:n}),t.preventDefault(),t.stopImmediatePropagation()}return!0},h),i.registerCommand(t.KEY_ARROW_UP_COMMAND,e=>{const t=e;if(null!==d&&d.length){const e=null===y?d.length-1:0!==y?y-1:d.length-1;w(e);const n=d[e];if(!n)return w(-1),t.preventDefault(),t.stopImmediatePropagation(),!0;n.ref&&n.ref.current&&c(n.ref.current),t.preventDefault(),t.stopImmediatePropagation()}return!0},h),i.registerCommand(t.KEY_ESCAPE_COMMAND,t=>{const n=t;return n.preventDefault(),n.stopImmediatePropagation(),e(),!0},h),i.registerCommand(t.KEY_TAB_COMMAND,e=>{const t=e;return null!==d&&null!==y&&null!=d[y]&&(t.preventDefault(),t.stopImmediatePropagation(),O(d[y]),!0)},h),i.registerCommand(t.KEY_ENTER_COMMAND,e=>null!==d&&null!==y&&null!=d[y]&&(null!==e&&(e.preventDefault(),e.stopImmediatePropagation()),O(d[y]),!0),h)),[O,e,i,d,y,w,h]),v()}function g(e,t){null!=t&&(e.className=t),e.setAttribute("aria-label","Typeahead menu"),e.setAttribute("role","listbox"),e.style.display="block",e.style.position="absolute"}const h="\\.,\\+\\*\\?\\$\\@\\|#{}\\(\\)\\^\\-\\[\\]\\\\/!%'\"~=<>_:;";const C=t.createCommand("SCROLL_TYPEAHEAD_OPTION_INTO_VIEW_COMMAND");exports.LexicalTypeaheadMenuPlugin=function({options:o,onQueryChange:r,onSelectOption:u,onOpen:c,onClose:a,triggerFn:f,anchorClassName:m,commandPriority:h=t.COMMAND_PRIORITY_LOW,parent:C,preselectFirstItem:E=!0,ignoreEntityBoundary:x=!1}){const[y]=e.useLexicalComposerContext(),[b,O]=n.useState(null),w=function(t,o,r,l=(s?document.body:void 0),i=!0){const[u]=e.useLexicalComposerContext(),c=s?document.createElement("div"):null,a=n.useRef(c),f=n.useCallback(()=>{if(null===a.current||void 0===l)return;a.current.style.top=a.current.style.bottom;const e=u.getRootElement(),n=a.current,o=n.firstChild;if(null!==e&&null!==t){const{left:s,top:u,width:c,height:d}=t.getRect(),f=a.current.offsetHeight;if(n.style.top=`${u+f+3+(i?window.pageYOffset:0)}px`,n.style.left=`${s+window.pageXOffset}px`,n.style.height=`${d}px`,n.style.width=`${c}px`,null!==o){o.style.top=`${u}`;const t=o.getBoundingClientRect(),r=t.height,l=t.width,c=e.getBoundingClientRect();s+l>c.right&&(n.style.left=`${c.right-l+window.pageXOffset}px`),(u+r>window.innerHeight||u+r>c.bottom)&&u-c.top>r+d&&(n.style.top=`${u-r-d+(i?window.pageYOffset:0)}px`)}n.isConnected||(g(n,r),l.append(n)),n.setAttribute("id","typeahead-menu"),e.setAttribute("aria-controls","typeahead-menu")}},[u,t,i,r,l]);n.useEffect(()=>{const e=u.getRootElement();return null!==t&&f(),()=>{null!==e&&e.removeAttribute("aria-controls");const t=a.current;null!==t&&t.isConnected&&(t.remove(),t.removeAttribute("id"))}},[u,f,t]);const m=n.useCallback(e=>{null!==t&&(e||o(null))},[t,o]);return d(t,a.current,f,m),null!=c&&c===a.current&&(g(c,r),null!=l&&l.append(c)),a}(b,O,m,C),v=n.useCallback(()=>{O(null),null!=a&&null!==b&&a()},[a,b]),R=n.useCallback(e=>{O(e),null!=c&&null===b&&c(e)},[c,b]);return n.useEffect(()=>{const e=y.registerUpdateListener(()=>{y.getEditorState().read(()=>{if(!y.isEditable())return void v();if(y.isComposing())return;const e=(y._window||window).document.createRange(),o=t.$getSelection(),l=function(e){let n=null;return e.getEditorState().read(()=>{const e=t.$getSelection();t.$isRangeSelection(e)&&(n=function(e){const t=e.anchor;if("text"!==t.type)return null;const n=t.getNode();if(!n.isSimpleText())return null;const o=t.offset;return n.getTextContent().slice(0,o)}(e))}),n}(y);if(!t.$isRangeSelection(o)||!o.isCollapsed()||null===l||null===e)return void v();const s=f(l,y);if(r(s?s.matchingString:null),null!==s&&(x||!function(e,n){return 0===n&&e.getEditorState().read(()=>{const e=t.$getSelection();if(t.$isRangeSelection(e)){const n=e.anchor.getNode().getPreviousSibling();return t.$isTextNode(n)&&n.isTextEntity()}return!1})}(y,s.leadOffset))){const o=function(e,n,o){const r=t.getDOMSelectionForEditor(o);if(null===r||!r.isCollapsed)return!1;const l=r.anchorNode,i=e,s=r.anchorOffset;if(null==l||null==s)return!1;try{n.setStart(l,i),n.setEnd(l,s)}catch(e){return!1}return!0}(s.leadOffset,e,y);if(null!==o)return u=()=>R({getRect:()=>e.getBoundingClientRect(),match:s}),void(i in n?n[i](u):u())}var u;v()})});return()=>{e()}},[y,f,r,b,v,R,x]),n.useEffect(()=>y.registerEditableListener(e=>{e||v()}),[y,v]),null===b||null===y||null===w.current?null:l.jsx(p,{close:v,resolution:b,editor:y,anchorElementRef:w,options:o,shouldSplitNodeWithQuery:!0,onSelectOption:u,commandPriority:h,preselectFirstItem:E})},exports.MenuOption=class{key;ref;icon;title;constructor(e){this.key=e,this.ref={current:null},this.setRefElement=this.setRefElement.bind(this)}setRefElement(e){this.ref={current:e}}},exports.PUNCTUATION=h,exports.SCROLL_TYPEAHEAD_OPTION_INTO_VIEW_COMMAND=C,exports.getScrollParent=function(e,t){let n=getComputedStyle(e);const o="absolute"===n.position,r=t?/(auto|scroll|hidden)/:/(auto|scroll)/;if("fixed"===n.position)return document.body;for(let t=e;t=t.parentElement;)if(n=getComputedStyle(t),(!o||"static"!==n.position)&&r.test(n.overflow+n.overflowY+n.overflowX))return t;return document.body},exports.useBasicTypeaheadTriggerMatch=function(e,{minLength:t=1,maxLength:o=75,punctuation:r=h,allowWhitespace:l=!1}){return n.useCallback(n=>{const i=new RegExp("(^|\\s|\\()(["+e+"]((?:"+("[^"+e+r+(l?"":"\\s")+"]")+"){0,"+o+"}))$").exec(n);if(null!==i){const e=i[1],n=i[3];if(n.length>=t)return{leadOffset:i.index+e.length,matchingString:n,replaceableString:i[2]}}return null},[l,e,r,o,t])},exports.useDynamicPositioning=d; +diff --git a/node_modules/@lexical/react/LexicalTypeaheadMenuPlugin.prod.mjs b/node_modules/@lexical/react/LexicalTypeaheadMenuPlugin.prod.mjs +index 35303d3..f9c281f 100644 +--- a/node_modules/@lexical/react/LexicalTypeaheadMenuPlugin.prod.mjs ++++ b/node_modules/@lexical/react/LexicalTypeaheadMenuPlugin.prod.mjs +@@ -6,4 +6,4 @@ + * + */ + +-import{useLexicalComposerContext as t}from"@lexical/react/LexicalComposerContext";import{createCommand as e,COMMAND_PRIORITY_LOW as n,KEY_ARROW_DOWN_COMMAND as o,KEY_ARROW_UP_COMMAND as r,KEY_ESCAPE_COMMAND as l,KEY_TAB_COMMAND as i,KEY_ENTER_COMMAND as u,$getSelection as s,$isRangeSelection as c,$isTextNode as a,getDOMSelection as d}from"lexical";import m,{useLayoutEffect as f,useEffect as p,useRef as g,useCallback as h,useState as w,useMemo as y}from"react";import{mergeRegister as v}from"@lexical/utils";import{jsx as b}from"react/jsx-runtime";const C="startTransition";const E="undefined"!=typeof window&&void 0!==window.document&&void 0!==window.document.createElement,x=E?f:p;class R{key;ref;constructor(t){this.key=t,this.ref={current:null},this.setRefElement=this.setRefElement.bind(this)}setRefElement(t){this.ref={current:t}}}const S=t=>{const e=document.getElementById("typeahead-menu");if(!e)return;const n=e.getBoundingClientRect();n.top+n.height>window.innerHeight&&e.scrollIntoView({block:"center"}),n.top<0&&e.scrollIntoView({block:"center"}),t.scrollIntoView({block:"nearest"})};function O(t,e){const n=t.getBoundingClientRect(),o=e.getBoundingClientRect();return n.top>=o.top-6&&n.top<=o.bottom+6}function I(e,n,o,r){const[l]=t();p(()=>{if(null!=n&&null!=e){const t=l.getRootElement(),e=null!=t?function(t){let e=getComputedStyle(t);const n="absolute"===e.position,o=/(auto|scroll)/;if("fixed"===e.position)return document.body;for(let r=t;r=r.parentElement;)if(e=getComputedStyle(r),(!n||"static"!==e.position)&&o.test(e.overflow+e.overflowY+e.overflowX))return r;return document.body}(t):document.body;let i=!1,u=O(n,e);const s=function(){i||(window.requestAnimationFrame(function(){o(),i=!1}),i=!0);const t=O(n,e);t!==u&&(u=t,null!=r&&r(t))},c=new ResizeObserver(o);return window.addEventListener("resize",o),document.addEventListener("scroll",s,{capture:!0,passive:!0}),c.observe(n),()=>{c.unobserve(n),window.removeEventListener("resize",o),document.removeEventListener("scroll",s,!0)}}},[n,l,r,o,e])}const A=e("SCROLL_TYPEAHEAD_OPTION_INTO_VIEW_COMMAND");function P({close:t,editor:e,anchorElementRef:a,resolution:d,options:m,menuRenderFn:f,onSelectOption:g,shouldSplitNodeWithQuery:b=!1,commandPriority:C=n,preselectFirstItem:E=!0}){const[R,O]=w(null),I=null!==R?Math.min(m.length-1,R):null,P=d.match&&d.match.matchingString;p(()=>{E&&O(0)},[P,E]);const T=h(n=>{e.update(()=>{const e=null!=d.match&&b?function(t){const e=s();if(!c(e)||!e.isCollapsed())return null;const n=e.anchor;if("text"!==n.type)return null;const o=n.getNode();if(!o.isSimpleText())return null;const r=n.offset,l=o.getTextContent().slice(0,r),i=t.replaceableString.length,u=r-function(t,e,n){let o=n;for(let n=o;n<=e.length;n++)t.slice(-n)===e.substring(0,n)&&(o=n);return o}(l,t.matchingString,i);if(u<0)return null;let a;return 0===u?[a]=o.splitText(r):[,a]=o.splitText(u,r),a}(d.match):null;g(n,e,t,d.match?d.match.matchingString:"")})},[e,b,d.match,g,t]),N=h(t=>{const n=e.getRootElement();null!==n&&(n.setAttribute("aria-activedescendant","typeahead-item-"+t),O(t))},[e]);p(()=>()=>{const t=e.getRootElement();null!==t&&t.removeAttribute("aria-activedescendant")},[e]),x(()=>{null===m?O(null):null===I&&E&&N(0)},[m,I,N,E]),p(()=>v(e.registerCommand(A,({option:t})=>!(!t.ref||null==t.ref.current)&&(S(t.ref.current),!0),C)),[e,N,C]),p(()=>v(e.registerCommand(o,t=>{const n=t;if(null!==m&&m.length){const t=null===I?0:I!==m.length-1?I+1:0;N(t);const o=m[t];if(!o)return N(-1),n.preventDefault(),n.stopImmediatePropagation(),!0;o.ref&&o.ref.current&&e.dispatchCommand(A,{index:t,option:o}),n.preventDefault(),n.stopImmediatePropagation()}return!0},C),e.registerCommand(r,t=>{const e=t;if(null!==m&&m.length){const t=null===I?m.length-1:0!==I?I-1:m.length-1;N(t);const n=m[t];if(!n)return N(-1),e.preventDefault(),e.stopImmediatePropagation(),!0;n.ref&&n.ref.current&&S(n.ref.current),e.preventDefault(),e.stopImmediatePropagation()}return!0},C),e.registerCommand(l,e=>{const n=e;return n.preventDefault(),n.stopImmediatePropagation(),t(),!0},C),e.registerCommand(i,t=>{const e=t;return null!==m&&null!==I&&null!=m[I]&&(e.preventDefault(),e.stopImmediatePropagation(),T(m[I]),!0)},C),e.registerCommand(u,t=>null!==m&&null!==I&&null!=m[I]&&(null!==t&&(t.preventDefault(),t.stopImmediatePropagation()),T(m[I]),!0),C)),[T,t,e,m,I,N,C]);return f(a,y(()=>({options:m,selectOptionAndCleanUp:T,selectedIndex:I,setHighlightedIndex:O}),[T,I,m]),d.match?d.match.matchingString:"")}function T(t,e){null!=e&&(t.className=e),t.setAttribute("aria-label","Typeahead menu"),t.setAttribute("role","listbox"),t.style.display="block",t.style.position="absolute"}const N="\\.,\\+\\*\\?\\$\\@\\|#{}\\(\\)\\^\\-\\[\\]\\\\/!%'\"~=<>_:;";function L(t,e){let n=getComputedStyle(t);const o="absolute"===n.position,r=e?/(auto|scroll|hidden)/:/(auto|scroll)/;if("fixed"===n.position)return document.body;for(let e=t;e=e.parentElement;)if(n=getComputedStyle(e),(!o||"static"!==n.position)&&r.test(n.overflow+n.overflowY+n.overflowX))return e;return document.body}const _=e("SCROLL_TYPEAHEAD_OPTION_INTO_VIEW_COMMAND");function D(t,{minLength:e=1,maxLength:n=75,punctuation:o=N,allowWhitespace:r=!1}){return h(l=>{const i=new RegExp("(^|\\s|\\()(["+t+"]((?:"+("[^"+t+o+(r?"":"\\s")+"]")+"){0,"+n+"}))$").exec(l);if(null!==i){const t=i[1],n=i[3];if(n.length>=e)return{leadOffset:i.index+t.length,matchingString:n,replaceableString:i[2]}}return null},[r,t,o,n,e])}function $({options:e,onQueryChange:o,onSelectOption:r,onOpen:l,onClose:i,menuRenderFn:u,triggerFn:f,anchorClassName:y,commandPriority:v=n,parent:x,preselectFirstItem:R=!0,ignoreEntityBoundary:S=!1}){const[O]=t(),[A,N]=w(null),L=function(e,n,o,r=(E?document.body:void 0),l=!0){const[i]=t(),u=E?document.createElement("div"):null,s=g(u),c=h(()=>{if(null===s.current||void 0===r)return;s.current.style.top=s.current.style.bottom;const t=i.getRootElement(),n=s.current,u=n.firstChild;if(null!==t&&null!==e){const{left:i,top:c,width:a,height:d}=e.getRect(),m=s.current.offsetHeight;if(n.style.top=`${c+m+3+(l?window.pageYOffset:0)}px`,n.style.left=`${i+window.pageXOffset}px`,n.style.height=`${d}px`,n.style.width=`${a}px`,null!==u){u.style.top=`${c}`;const e=u.getBoundingClientRect(),o=e.height,r=e.width,s=t.getBoundingClientRect();i+r>s.right&&(n.style.left=`${s.right-r+window.pageXOffset}px`),(c+o>window.innerHeight||c+o>s.bottom)&&c-s.top>o+d&&(n.style.top=`${c-o-d+(l?window.pageYOffset:0)}px`)}n.isConnected||(T(n,o),r.append(n)),n.setAttribute("id","typeahead-menu"),t.setAttribute("aria-controls","typeahead-menu")}},[i,e,l,o,r]);p(()=>{const t=i.getRootElement();return null!==e&&c(),()=>{null!==t&&t.removeAttribute("aria-controls");const e=s.current;null!==e&&e.isConnected&&(e.remove(),e.removeAttribute("id"))}},[i,c,e]);const a=h(t=>{null!==e&&(t||n(null))},[e,n]);return I(e,s.current,c,a),null!=u&&u===s.current&&(T(u,o),null!=r&&r.append(u)),s}(A,N,y,x),_=h(()=>{N(null),null!=i&&null!==A&&i()},[i,A]),D=h(t=>{N(t),null!=l&&null===A&&l(t)},[l,A]);return p(()=>{const t=O.registerUpdateListener(()=>{O.getEditorState().read(()=>{if(!O.isEditable())return void _();const t=O._window||window,e=t.document.createRange(),n=s(),r=function(t){let e=null;return t.getEditorState().read(()=>{const t=s();c(t)&&(e=function(t){const e=t.anchor;if("text"!==e.type)return null;const n=e.getNode();if(!n.isSimpleText())return null;const o=e.offset;return n.getTextContent().slice(0,o)}(t))}),e}(O);if(!c(n)||!n.isCollapsed()||null===r||null===e)return void _();const l=f(r,O);if(o(l?l.matchingString:null),null!==l&&(S||!function(t,e){return 0===e&&t.getEditorState().read(()=>{const t=s();if(c(t)){const e=t.anchor.getNode().getPreviousSibling();return a(e)&&e.isTextEntity()}return!1})}(O,l.leadOffset))){const n=function(t,e,n){const o=d(n);if(null===o||!o.isCollapsed)return!1;const r=o.anchorNode,l=t,i=o.anchorOffset;if(null==r||null==i)return!1;try{e.setStart(r,l),e.setEnd(r,i)}catch(t){return!1}return!0}(l.leadOffset,e,t);if(null!==n)return i=()=>D({getRect:()=>e.getBoundingClientRect(),match:l}),void(C in m?m[C](i):i())}var i;_()})});return()=>{t()}},[O,f,o,A,_,D,S]),p(()=>O.registerEditableListener(t=>{t||_()}),[O,_]),null===A||null===O||null===L.current?null:b(P,{close:_,resolution:A,editor:O,anchorElementRef:L,options:e,menuRenderFn:u,shouldSplitNodeWithQuery:!0,onSelectOption:r,commandPriority:v,preselectFirstItem:R})}export{$ as LexicalTypeaheadMenuPlugin,R as MenuOption,N as PUNCTUATION,_ as SCROLL_TYPEAHEAD_OPTION_INTO_VIEW_COMMAND,L as getScrollParent,D as useBasicTypeaheadTriggerMatch,I as useDynamicPositioning}; ++import{useLexicalComposerContext as t}from"@lexical/react/LexicalComposerContext";import{createCommand as e,COMMAND_PRIORITY_LOW as n,KEY_ARROW_DOWN_COMMAND as o,KEY_ARROW_UP_COMMAND as r,KEY_ESCAPE_COMMAND as l,KEY_TAB_COMMAND as i,KEY_ENTER_COMMAND as u,$getSelection as s,$isRangeSelection as c,$isTextNode as a,getDOMSelectionForEditor as d}from"lexical";import m,{useLayoutEffect as p,useEffect as f,useRef as g,useCallback as h,useState as y}from"react";import{mergeRegister as w}from"@lexical/utils";import v from"react-dom";import{jsx as C,jsxs as E}from"react/jsx-runtime";const b="startTransition";const x="undefined"!=typeof window&&void 0!==window.document&&void 0!==window.document.createElement,S=x?p:f;class R{key;ref;icon;title;constructor(t){this.key=t,this.ref={current:null},this.setRefElement=this.setRefElement.bind(this)}setRefElement(t){this.ref={current:t}}}const O=t=>{const e=document.getElementById("typeahead-menu");if(!e)return;const n=e.getBoundingClientRect();n.top+n.height>window.innerHeight&&e.scrollIntoView({block:"center"}),n.top<0&&e.scrollIntoView({block:"center"}),t.scrollIntoView({block:"nearest"})};function I(t,e){const n=t.getBoundingClientRect(),o=e.getBoundingClientRect();return n.top>=o.top-6&&n.top<=o.bottom+6}function N(e,n,o,r){const[l]=t();f(()=>{if(null!=n&&null!=e){const t=l.getRootElement(),e=null!=t?function(t){let e=getComputedStyle(t);const n="absolute"===e.position,o=/(auto|scroll)/;if("fixed"===e.position)return document.body;for(let r=t;r=r.parentElement;)if(e=getComputedStyle(r),(!n||"static"!==e.position)&&o.test(e.overflow+e.overflowY+e.overflowX))return r;return document.body}(t):document.body;let i=!1,u=I(n,e);const s=function(){i||(window.requestAnimationFrame(function(){o(),i=!1}),i=!0);const t=I(n,e);t!==u&&(u=t,null!=r&&r(t))},c=new ResizeObserver(o);return window.addEventListener("resize",o),document.addEventListener("scroll",s,{capture:!0,passive:!0}),c.observe(n),()=>{c.unobserve(n),window.removeEventListener("resize",o),document.removeEventListener("scroll",s,!0)}}},[n,l,r,o,e])}const P=e("SCROLL_TYPEAHEAD_OPTION_INTO_VIEW_COMMAND");function A({index:t,isSelected:e,onClick:n,onMouseEnter:o,option:r}){let l="item";return e&&(l+=" selected"),E("li",{tabIndex:-1,className:l,ref:r.setRefElement,role:"option","aria-selected":e,id:"typeahead-item-"+t,onMouseEnter:o,onClick:n,children:[r.icon,C("span",{className:"text",children:r.title})]},r.key)}function T({close:t,editor:e,anchorElementRef:a,resolution:d,options:m,onSelectOption:p,shouldSplitNodeWithQuery:g=!1,commandPriority:E=n,preselectFirstItem:b=!0}){const[x,R]=y(null),I=null!==x?Math.min(m.length-1,x):null,N=d.match&&d.match.matchingString;f(()=>{b&&R(0)},[N,b]);const T=h(n=>{e.update(()=>{const e=null!=d.match&&g?function(t){const e=s();if(!c(e)||!e.isCollapsed())return null;const n=e.anchor;if("text"!==n.type)return null;const o=n.getNode();if(!o.isSimpleText())return null;const r=n.offset,l=o.getTextContent().slice(0,r),i=t.replaceableString.length,u=r-function(t,e,n){let o=n;for(let n=o;n<=e.length;n++)t.slice(-n)===e.substring(0,n)&&(o=n);return o}(l,t.matchingString,i);if(u<0)return null;let a;return 0===u?[a]=o.splitText(r):[,a]=o.splitText(u,r),a}(d.match):null;p(n,e,t,d.match?d.match.matchingString:"")})},[e,g,d.match,p,t]),L=h(t=>{const n=e.getRootElement();null!==n&&(n.setAttribute("aria-activedescendant","typeahead-item-"+t),R(t))},[e]),_=h(()=>a.current&&m.length?v.createPortal(C("div",{className:"typeahead-popover mentions-menu",children:C("ul",{children:m.map((t,e)=>C(A,{index:e,isSelected:I===e,onClick:()=>{R(e),T(t)},onMouseEnter:()=>{R(e)},option:t},t.key))})}),a.current):null,[a,m,I,T,R]);return f(()=>()=>{const t=e.getRootElement();null!==t&&t.removeAttribute("aria-activedescendant")},[e]),S(()=>{null===m?R(null):null===I&&b&&L(0)},[m,I,L,b]),f(()=>w(e.registerCommand(P,({option:t})=>!(!t.ref||null==t.ref.current)&&(O(t.ref.current),!0),E)),[e,L,E]),f(()=>w(e.registerCommand(o,t=>{const n=t;if(null!==m&&m.length){const t=null===I?0:I!==m.length-1?I+1:0;L(t);const o=m[t];if(!o)return L(-1),n.preventDefault(),n.stopImmediatePropagation(),!0;o.ref&&o.ref.current&&e.dispatchCommand(P,{index:t,option:o}),n.preventDefault(),n.stopImmediatePropagation()}return!0},E),e.registerCommand(r,t=>{const e=t;if(null!==m&&m.length){const t=null===I?m.length-1:0!==I?I-1:m.length-1;L(t);const n=m[t];if(!n)return L(-1),e.preventDefault(),e.stopImmediatePropagation(),!0;n.ref&&n.ref.current&&O(n.ref.current),e.preventDefault(),e.stopImmediatePropagation()}return!0},E),e.registerCommand(l,e=>{const n=e;return n.preventDefault(),n.stopImmediatePropagation(),t(),!0},E),e.registerCommand(i,t=>{const e=t;return null!==m&&null!==I&&null!=m[I]&&(e.preventDefault(),e.stopImmediatePropagation(),T(m[I]),!0)},E),e.registerCommand(u,t=>null!==m&&null!==I&&null!=m[I]&&(null!==t&&(t.preventDefault(),t.stopImmediatePropagation()),T(m[I]),!0),E)),[T,t,e,m,I,L,E]),_()}function L(t,e){null!=e&&(t.className=e),t.setAttribute("aria-label","Typeahead menu"),t.setAttribute("role","listbox"),t.style.display="block",t.style.position="absolute"}const _="\\.,\\+\\*\\?\\$\\@\\|#{}\\(\\)\\^\\-\\[\\]\\\\/!%'\"~=<>_:;";function k(t,e){let n=getComputedStyle(t);const o="absolute"===n.position,r=e?/(auto|scroll|hidden)/:/(auto|scroll)/;if("fixed"===n.position)return document.body;for(let e=t;e=e.parentElement;)if(n=getComputedStyle(e),(!o||"static"!==n.position)&&r.test(n.overflow+n.overflowY+n.overflowX))return e;return document.body}const D=e("SCROLL_TYPEAHEAD_OPTION_INTO_VIEW_COMMAND");function $(t,{minLength:e=1,maxLength:n=75,punctuation:o=_,allowWhitespace:r=!1}){return h(l=>{const i=new RegExp("(^|\\s|\\()(["+t+"]((?:"+("[^"+t+o+(r?"":"\\s")+"]")+"){0,"+n+"}))$").exec(l);if(null!==i){const t=i[1],n=i[3];if(n.length>=e)return{leadOffset:i.index+t.length,matchingString:n,replaceableString:i[2]}}return null},[r,t,o,n,e])}function B({options:e,onQueryChange:o,onSelectOption:r,onOpen:l,onClose:i,triggerFn:u,anchorClassName:p,commandPriority:w=n,parent:v,preselectFirstItem:E=!0,ignoreEntityBoundary:S=!1}){const[R]=t(),[O,I]=y(null),P=function(e,n,o,r=(x?document.body:void 0),l=!0){const[i]=t(),u=x?document.createElement("div"):null,s=g(u),c=h(()=>{if(null===s.current||void 0===r)return;s.current.style.top=s.current.style.bottom;const t=i.getRootElement(),n=s.current,u=n.firstChild;if(null!==t&&null!==e){const{left:i,top:c,width:a,height:d}=e.getRect(),m=s.current.offsetHeight;if(n.style.top=`${c+m+3+(l?window.pageYOffset:0)}px`,n.style.left=`${i+window.pageXOffset}px`,n.style.height=`${d}px`,n.style.width=`${a}px`,null!==u){u.style.top=`${c}`;const e=u.getBoundingClientRect(),o=e.height,r=e.width,s=t.getBoundingClientRect();i+r>s.right&&(n.style.left=`${s.right-r+window.pageXOffset}px`),(c+o>window.innerHeight||c+o>s.bottom)&&c-s.top>o+d&&(n.style.top=`${c-o-d+(l?window.pageYOffset:0)}px`)}n.isConnected||(L(n,o),r.append(n)),n.setAttribute("id","typeahead-menu"),t.setAttribute("aria-controls","typeahead-menu")}},[i,e,l,o,r]);f(()=>{const t=i.getRootElement();return null!==e&&c(),()=>{null!==t&&t.removeAttribute("aria-controls");const e=s.current;null!==e&&e.isConnected&&(e.remove(),e.removeAttribute("id"))}},[i,c,e]);const a=h(t=>{null!==e&&(t||n(null))},[e,n]);return N(e,s.current,c,a),null!=u&&u===s.current&&(L(u,o),null!=r&&r.append(u)),s}(O,I,p,v),A=h(()=>{I(null),null!=i&&null!==O&&i()},[i,O]),_=h(t=>{I(t),null!=l&&null===O&&l(t)},[l,O]);return f(()=>{const t=R.registerUpdateListener(()=>{R.getEditorState().read(()=>{if(!R.isEditable())return void A();if(R.isComposing())return;const t=(R._window||window).document.createRange(),e=s(),n=function(t){let e=null;return t.getEditorState().read(()=>{const t=s();c(t)&&(e=function(t){const e=t.anchor;if("text"!==e.type)return null;const n=e.getNode();if(!n.isSimpleText())return null;const o=e.offset;return n.getTextContent().slice(0,o)}(t))}),e}(R);if(!c(e)||!e.isCollapsed()||null===n||null===t)return void A();const r=u(n,R);if(o(r?r.matchingString:null),null!==r&&(S||!function(t,e){return 0===e&&t.getEditorState().read(()=>{const t=s();if(c(t)){const e=t.anchor.getNode().getPreviousSibling();return a(e)&&e.isTextEntity()}return!1})}(R,r.leadOffset))){const e=function(t,e,n){const o=d(n);if(null===o||!o.isCollapsed)return!1;const r=o.anchorNode,l=t,i=o.anchorOffset;if(null==r||null==i)return!1;try{e.setStart(r,l),e.setEnd(r,i)}catch(t){return!1}return!0}(r.leadOffset,t,R);if(null!==e)return l=()=>_({getRect:()=>t.getBoundingClientRect(),match:r}),void(b in m?m[b](l):l())}var l;A()})});return()=>{t()}},[R,u,o,O,A,_,S]),f(()=>R.registerEditableListener(t=>{t||A()}),[R,A]),null===O||null===R||null===P.current?null:C(T,{close:A,resolution:O,editor:R,anchorElementRef:P,options:e,shouldSplitNodeWithQuery:!0,onSelectOption:r,commandPriority:w,preselectFirstItem:E})}export{B as LexicalTypeaheadMenuPlugin,R as MenuOption,_ as PUNCTUATION,D as SCROLL_TYPEAHEAD_OPTION_INTO_VIEW_COMMAND,k as getScrollParent,$ as useBasicTypeaheadTriggerMatch,N as useDynamicPositioning}; +diff --git a/node_modules/@lexical/react/shared/LexicalMenu.d.ts b/node_modules/@lexical/react/shared/LexicalMenu.d.ts +index 9773e10..2638679 100644 +--- a/node_modules/@lexical/react/shared/LexicalMenu.d.ts ++++ b/node_modules/@lexical/react/shared/LexicalMenu.d.ts +@@ -7,7 +7,7 @@ + */ + import type { JSX } from 'react'; + import { CommandListenerPriority, LexicalCommand, LexicalEditor, TextNode } from 'lexical'; +-import { ReactPortal, RefObject } from 'react'; ++import { RefObject } from 'react'; + export type MenuTextMatch = { + leadOffset: number; + matchingString: string; +@@ -17,33 +17,27 @@ export type MenuResolution = { + match?: MenuTextMatch; + getRect: () => DOMRect; + }; +-export declare const PUNCTUATION = "\\.,\\+\\*\\?\\$\\@\\|#{}\\(\\)\\^\\-\\[\\]\\\\/!%'\"~=<>_:;"; + export declare class MenuOption { + key: string; + ref?: RefObject; ++ icon?: JSX.Element; ++ title?: JSX.Element | string | null; + constructor(key: string); + setRefElement(element: HTMLElement | null): void; + } +-export type MenuRenderFn = (anchorElementRef: RefObject, itemProps: { +- selectedIndex: number | null; +- selectOptionAndCleanUp: (option: TOption) => void; +- setHighlightedIndex: (index: number) => void; +- options: Array; +-}, matchingString: string | null) => ReactPortal | JSX.Element | null; + export declare function getScrollParent(element: HTMLElement, includeHidden: boolean): HTMLElement | HTMLBodyElement; + export declare function useDynamicPositioning(resolution: MenuResolution | null, targetElement: HTMLElement | null, onReposition: () => void, onVisibilityChange?: (isInView: boolean) => void): void; + export declare const SCROLL_TYPEAHEAD_OPTION_INTO_VIEW_COMMAND: LexicalCommand<{ + index: number; + option: MenuOption; + }>; +-export declare function LexicalMenu({ close, editor, anchorElementRef, resolution, options, menuRenderFn, onSelectOption, shouldSplitNodeWithQuery, commandPriority, preselectFirstItem, }: { ++export declare function LexicalMenu({ close, editor, anchorElementRef, resolution, options, onSelectOption, shouldSplitNodeWithQuery, commandPriority, preselectFirstItem, }: { + close: () => void; + editor: LexicalEditor; + anchorElementRef: RefObject; + resolution: MenuResolution; + options: Array; + shouldSplitNodeWithQuery?: boolean; +- menuRenderFn: MenuRenderFn; + onSelectOption: (option: TOption, textNodeContainingQuery: TextNode | null, closeMenu: () => void, matchingString: string) => void; + commandPriority?: CommandListenerPriority; + preselectFirstItem?: boolean; diff --git a/patches/@lexical+selection+0.38.2.patch b/patches/@lexical+selection+0.38.2.patch new file mode 100644 index 00000000..dab97c03 --- /dev/null +++ b/patches/@lexical+selection+0.38.2.patch @@ -0,0 +1,59 @@ +diff --git a/node_modules/@lexical/selection/LexicalSelection.dev.js b/node_modules/@lexical/selection/LexicalSelection.dev.js +index b1bbd7a..dede56f 100644 +--- a/node_modules/@lexical/selection/LexicalSelection.dev.js ++++ b/node_modules/@lexical/selection/LexicalSelection.dev.js +@@ -71,7 +71,9 @@ function getDOMIndexWithinParent(node) { + function createDOMRange(editor, anchorNode, _anchorOffset, focusNode, _focusOffset) { + const anchorKey = anchorNode.getKey(); + const focusKey = focusNode.getKey(); +- const range = document.createRange(); ++ const rootElement = editor.getRootElement(); ++ const doc = lexical.getDocumentFromElement(rootElement); ++ const range = doc.createRange(); + let anchorDOM = editor.getElementByKey(anchorKey); + let focusDOM = editor.getElementByKey(focusKey); + let anchorOffset = _anchorOffset; +diff --git a/node_modules/@lexical/selection/LexicalSelection.dev.mjs b/node_modules/@lexical/selection/LexicalSelection.dev.mjs +index 026af3e..7928fe6 100644 +--- a/node_modules/@lexical/selection/LexicalSelection.dev.mjs ++++ b/node_modules/@lexical/selection/LexicalSelection.dev.mjs +@@ -6,7 +6,7 @@ + * + */ + +-import { $isTextNode, $getEditor, $isRootNode, $isElementNode, $getNodeByKey, $getPreviousSelection, $createTextNode, $isRangeSelection, $getSelection, $caretRangeFromSelection, $isTokenOrSegmented, $getCharacterOffsets, $cloneWithPropertiesEphemeral, $createRangeSelection, $findMatchingParent, INTERNAL_$isBlock, $setSelection, $caretFromPoint, $isExtendableTextPointCaret, $extendCaretToRange, $isChildCaret, $isDecoratorNode, $isRootOrShadowRoot, $hasAncestor, $isLeafNode } from 'lexical'; ++import { getDocumentFromElement, $isTextNode, $getEditor, $isRootNode, $isElementNode, $getNodeByKey, $getPreviousSelection, $createTextNode, $isRangeSelection, $getSelection, $caretRangeFromSelection, $isTokenOrSegmented, $getCharacterOffsets, $cloneWithPropertiesEphemeral, $createRangeSelection, $findMatchingParent, INTERNAL_$isBlock, $setSelection, $caretFromPoint, $isExtendableTextPointCaret, $extendCaretToRange, $isChildCaret, $isDecoratorNode, $isRootOrShadowRoot, $hasAncestor, $isLeafNode } from 'lexical'; + export { $cloneWithProperties, $selectAll } from 'lexical'; + + /** +@@ -70,7 +70,9 @@ function getDOMIndexWithinParent(node) { + function createDOMRange(editor, anchorNode, _anchorOffset, focusNode, _focusOffset) { + const anchorKey = anchorNode.getKey(); + const focusKey = focusNode.getKey(); +- const range = document.createRange(); ++ const rootElement = editor.getRootElement(); ++ const doc = getDocumentFromElement(rootElement); ++ const range = doc.createRange(); + let anchorDOM = editor.getElementByKey(anchorKey); + let focusDOM = editor.getElementByKey(focusKey); + let anchorOffset = _anchorOffset; +diff --git a/node_modules/@lexical/selection/LexicalSelection.prod.js b/node_modules/@lexical/selection/LexicalSelection.prod.js +index 235e0ae..1260896 100644 +--- a/node_modules/@lexical/selection/LexicalSelection.prod.js ++++ b/node_modules/@lexical/selection/LexicalSelection.prod.js +@@ -6,4 +6,4 @@ + * + */ + +-"use strict";var e=require("lexical");function t(e,...t){const n=new URL("https://lexical.dev/docs/error"),o=new URLSearchParams;o.append("code",e);for(const e of t)o.append("v",e);throw n.search=o.toString(),Error(`Minified Lexical error #${e}; visit ${n.toString()} for the full message or use the non-minified dev environment for full errors and additional helpful warnings.`)}const n=new Map;function o(e){let t=e;for(;null!=t;){if(t.nodeType===Node.TEXT_NODE)return t;t=t.firstChild}return null}function s(e){const t=e.parentNode;if(null==t)throw new Error("Should never happen");return[t,Array.from(t.childNodes).indexOf(e)]}function r(e){const t={};if(!e)return t;const n=e.split(";");for(const e of n)if(""!==e){const[n,o]=e.split(/:([^]+)/);n&&o&&(t[n.trim()]=o.trim())}return t}function l(e){let t=n.get(e);return void 0===t&&(t=r(e),n.set(e,t)),t}function i(e){let t="";for(const n in e)n&&(t+=`${n}: ${e[n]};`);return t}function c(t){const n=e.$getEditor().getElementByKey(t.getKey());if(null===n)return null;const o=n.ownerDocument.defaultView;return null===o?null:o.getComputedStyle(n)}function f(t){return c(e.$isRootNode(t)?t:t.getParentOrThrow())}function a(t,n,o){let s=n.getNode(),r=o;if(e.$isElementNode(s)){const e=s.getDescendantByIndex(n.offset);null!==e&&(s=e)}for(;r>0&&null!==s;){if(e.$isElementNode(s)){const e=s.getLastDescendant();null!==e&&(s=e)}let o=s.getPreviousSibling(),l=0;if(null===o){let e=s.getParentOrThrow(),t=e.getPreviousSibling();for(;null===t;){if(e=e.getParent(),null===e){o=null;break}t=e.getPreviousSibling()}null!==e&&(l=e.isInline()?0:2,o=t)}let i=s.getTextContent();""===i&&e.$isElementNode(s)&&!s.isInline()&&(i="\n\n");const c=i.length;if(!e.$isTextNode(s)||r>=c){const t=s.getParent();s.remove(),null==t||0!==t.getChildrenSize()||e.$isRootNode(t)||t.remove(),r-=c+l,s=o}else{const o=s.getKey(),l=t.getEditorState().read(()=>{const t=e.$getNodeByKey(o);return e.$isTextNode(t)&&t.isSimpleText()?t.getTextContent():null}),f=c-r,a=i.slice(0,f);if(null!==l&&l!==i){const t=e.$getPreviousSelection();let n=s;if(s.isSimpleText())s.setTextContent(l);else{const t=e.$createTextNode(l);s.replace(t),n=t}if(e.$isRangeSelection(t)&&t.isCollapsed()){const e=t.anchor.offset;n.select(e,e)}}else if(s.isSimpleText()){const e=n.key===o;let t=n.offset;t("function"==typeof n?e[t]=n(r[t],o):null===n?delete e[t]:e[t]=n,e),{...r}),f=i(c);e.$isRangeSelection(o)||e.$isTextNode(o)?o.setStyle(f):o.setTextStyle(f),n.set(f,c)}function u(t){const n=e.$getSelection();if(!n)return;const o=new Map,s=e=>o.get(e.getKey())||[0,e.getTextContentSize()];if(e.$isRangeSelection(n))for(const t of e.$caretRangeFromSelection(n).getTextSlices())t&&o.set(t.caret.origin.getKey(),t.getSliceIndices());const r=n.getNodes();for(const n of r){if(!e.$isTextNode(n)||!n.canHaveFormat())continue;const[o,r]=s(n);if(r!==o)if(e.$isTokenOrSegmented(n)||0===o&&r===n.getTextContentSize())t(n);else{t(n.splitText(o,r)[0===o?0:1])}}e.$isRangeSelection(n)&&"text"===n.anchor.type&&"text"===n.focus.type&&n.anchor.key===n.focus.key&&g(n)}function g(e){if(e.isBackward()){const{anchor:t,focus:n}=e,{key:o,offset:s,type:r}=t;t.set(n.key,n.offset,n.type),n.set(o,s,r)}}function p(e,t){const n=e.getFormatType(),o=e.getIndent();n!==t.getFormatType()&&t.setFormat(n),o!==t.getIndent()&&t.setIndent(o)}function $(e){return e.getNode().isAttached()}function h(t){let n=t;for(;null!==n&&!e.$isRootOrShadowRoot(n);){const e=n.getLatest(),t=n.getParent();0===e.getChildrenSize()&&n.remove(!0),n=t}}function y(n,o,s,r,l=null){if(0===o.length)return;const i=o[0],c=new Map,f=[];let a=e.$isElementNode(i)?i:i.getParentOrThrow();a.isInline()&&(a=a.getParentOrThrow());let d=!1;for(;null!==a;){const t=a.getPreviousSibling();if(null!==t){a=t,d=!0;break}if(a=a.getParentOrThrow(),e.$isRootOrShadowRoot(a))break}const u=new Set;for(let t=0;t{n.append(t),g.add(t.getKey()),e.$isElementNode(t)&&t.getChildrenKeys().forEach(e=>g.add(e))}),h(l)}}else if(u.has(s.getKey())){e.$isElementNode(s)||t(179);const n=r();n.setFormat(s.getFormatType()),n.setIndent(s.getIndent()),f.push(n),s.remove(!0)}}if(null!==l)for(let e=0;e=0;e--){const t=f[e];a.insertAfter(t)}else{const t=a.getFirstChild();if(e.$isElementNode(t)&&(a=t),null===t)if(l)a.append(l);else for(let e=0;e=0;e--){const t=f[e];a.insertAfter(t),p=t}const y=e.$getPreviousSelection();e.$isRangeSelection(y)&&$(y.anchor)&&$(y.focus)?e.$setSelection(y.clone()):null!==p?p.selectEnd():n.dirty=!0}function m(e){const t=S(e);return null!==t&&"vertical-rl"===t.writingMode}function S(t){const n=t.anchor.getNode();return e.$isElementNode(n)?c(n):f(n)}function x(e,t,n,o){e.modify(t?"extend":"move",n,o)}function N(e){const t=S(e);return null!==t&&"rtl"===t.direction}function T(e,t,n){const o=l(e.getStyle());return null!==o&&o[t]||n}const E=a;exports.$cloneWithProperties=e.$cloneWithProperties,exports.$selectAll=e.$selectAll,exports.$addNodeStyle=function(e){const t=e.getStyle(),o=r(t);n.set(t,o)},exports.$copyBlockFormatIndent=p,exports.$ensureForwardRangeSelection=g,exports.$forEachSelectedTextNode=u,exports.$getComputedStyleForElement=c,exports.$getComputedStyleForParent=f,exports.$getSelectionStyleValueForProperty=function(t,n,o=""){let s=null;const r=t.getNodes(),i=t.anchor,c=t.focus,f=t.isBackward(),a=f?c.offset:i.offset,d=f?c.getNode():i.getNode();if(e.$isRangeSelection(t)&&t.isCollapsed()&&""!==t.style){const e=l(t.style);if(null!==e&&n in e)return e[n]}for(let t=0;t{d(e,n)})},exports.$setBlocksType=function(t,n,o=p){if(null===t)return;const s=t.getStartEndPoints(),r=new Map;let l=null;if(s){const[t,n]=s;l=e.$createRangeSelection(),l.anchor.set(t.key,t.offset,t.type),l.focus.set(n.key,n.offset,n.type);const o=e.$findMatchingParent(t.getNode(),e.INTERNAL_$isBlock),i=e.$findMatchingParent(n.getNode(),e.INTERNAL_$isBlock);e.$isElementNode(o)&&r.set(o.getKey(),o),e.$isElementNode(i)&&r.set(i.getKey(),i)}for(const n of t.getNodes())if(e.$isElementNode(n)&&e.INTERNAL_$isBlock(n))r.set(n.getKey(),n);else if(null===s){const t=e.$findMatchingParent(n,e.INTERNAL_$isBlock);e.$isElementNode(t)&&r.set(t.getKey(),t)}for(const[e,t]of r){const s=n();o(t,s),t.replace(s,!0),l&&(e===l.anchor.key&&l.anchor.set(s.getKey(),l.anchor.offset,l.anchor.type),e===l.focus.key&&l.focus.set(s.getKey(),l.focus.offset,l.focus.type))}l&&t.is(e.$getSelection())&&e.$setSelection(l)},exports.$shouldOverrideDefaultCharacterSelection=function(t,n){let o=m(t)?!n:n;N(t)&&(o=!o);const s=e.$caretFromPoint(t.focus,o?"previous":"next");if(e.$isExtendableTextPointCaret(s))return!1;for(const t of e.$extendCaretToRange(s)){if(e.$isChildCaret(t))return!t.origin.isInline();if(!e.$isElementNode(t.origin)){if(e.$isDecoratorNode(t.origin))return!0;break}}return!1},exports.$sliceSelectedTextNodeContent=function(t,n,o="self"){const s=t.getStartEndPoints();if(n.isSelected(t)&&!e.$isTokenOrSegmented(n)&&null!==s){const[r,l]=s,i=t.isBackward(),c=r.getNode(),f=l.getNode(),a=n.is(c),d=n.is(f);if(a||d){const[s,r]=e.$getCharacterOffsets(t),l=c.is(f),a=n.is(i?f:c),d=n.is(i?c:f);let u,g=0;if(l)g=s>r?r:s,u=s>r?s:r;else if(a){g=i?r:s,u=void 0}else if(d){g=0,u=i?s:r}const p=n.__text.slice(g,u);p!==n.__text&&("clone"===o&&(n=e.$cloneWithPropertiesEphemeral(n)),n.__text=p)}}return n},exports.$trimTextContentFromAnchor=a,exports.$wrapNodes=function(t,n,o=null){const s=t.getStartEndPoints(),r=s?s[0]:null,l=t.getNodes(),i=l.length;if(null!==r&&(0===i||1===i&&"element"===r.type&&0===r.getNode().getChildrenSize())){const e="text"===r.type?r.getNode().getParentOrThrow():r.getNode(),t=e.getChildren();let s=n();return s.setFormat(e.getFormatType()),s.setIndent(e.getIndent()),t.forEach(e=>s.append(e)),o&&(s=o.append(s)),void e.replace(s)}let c=null,f=[];for(let s=0;s{const n=e.top-t.top;return Math.abs(n)<=3?e.left-t.left:n});for(let e=0;et.top&&i.left+i.width>t.left,s=t.width+r===o.width;n||s?(l.splice(e--,1),c--):i=t}return l},exports.getCSSFromStyleObject=i,exports.getStyleObjectFromCSS=l,exports.trimTextContentFromAnchor=E; ++"use strict";var e=require("lexical");function t(e,...t){const n=new URL("https://lexical.dev/docs/error"),o=new URLSearchParams;o.append("code",e);for(const e of t)o.append("v",e);throw n.search=o.toString(),Error(`Minified Lexical error #${e}; visit ${n.toString()} for the full message or use the non-minified dev environment for full errors and additional helpful warnings.`)}const n=new Map;function o(e){let t=e;for(;null!=t;){if(t.nodeType===Node.TEXT_NODE)return t;t=t.firstChild}return null}function s(e){const t=e.parentNode;if(null==t)throw new Error("Should never happen");return[t,Array.from(t.childNodes).indexOf(e)]}function r(e){const t={};if(!e)return t;const n=e.split(";");for(const e of n)if(""!==e){const[n,o]=e.split(/:([^]+)/);n&&o&&(t[n.trim()]=o.trim())}return t}function l(e){let t=n.get(e);return void 0===t&&(t=r(e),n.set(e,t)),t}function i(e){let t="";for(const n in e)n&&(t+=`${n}: ${e[n]};`);return t}function c(t){const n=e.$getEditor().getElementByKey(t.getKey());if(null===n)return null;const o=n.ownerDocument.defaultView;return null===o?null:o.getComputedStyle(n)}function f(t){return c(e.$isRootNode(t)?t:t.getParentOrThrow())}function a(t,n,o){let s=n.getNode(),r=o;if(e.$isElementNode(s)){const e=s.getDescendantByIndex(n.offset);null!==e&&(s=e)}for(;r>0&&null!==s;){if(e.$isElementNode(s)){const e=s.getLastDescendant();null!==e&&(s=e)}let o=s.getPreviousSibling(),l=0;if(null===o){let e=s.getParentOrThrow(),t=e.getPreviousSibling();for(;null===t;){if(e=e.getParent(),null===e){o=null;break}t=e.getPreviousSibling()}null!==e&&(l=e.isInline()?0:2,o=t)}let i=s.getTextContent();""===i&&e.$isElementNode(s)&&!s.isInline()&&(i="\n\n");const c=i.length;if(!e.$isTextNode(s)||r>=c){const t=s.getParent();s.remove(),null==t||0!==t.getChildrenSize()||e.$isRootNode(t)||t.remove(),r-=c+l,s=o}else{const o=s.getKey(),l=t.getEditorState().read(()=>{const t=e.$getNodeByKey(o);return e.$isTextNode(t)&&t.isSimpleText()?t.getTextContent():null}),f=c-r,a=i.slice(0,f);if(null!==l&&l!==i){const t=e.$getPreviousSelection();let n=s;if(s.isSimpleText())s.setTextContent(l);else{const t=e.$createTextNode(l);s.replace(t),n=t}if(e.$isRangeSelection(t)&&t.isCollapsed()){const e=t.anchor.offset;n.select(e,e)}}else if(s.isSimpleText()){const e=n.key===o;let t=n.offset;t("function"==typeof n?e[t]=n(r[t],o):null===n?delete e[t]:e[t]=n,e),{...r}),f=i(c);e.$isRangeSelection(o)||e.$isTextNode(o)?o.setStyle(f):o.setTextStyle(f),n.set(f,c)}function u(t){const n=e.$getSelection();if(!n)return;const o=new Map,s=e=>o.get(e.getKey())||[0,e.getTextContentSize()];if(e.$isRangeSelection(n))for(const t of e.$caretRangeFromSelection(n).getTextSlices())t&&o.set(t.caret.origin.getKey(),t.getSliceIndices());const r=n.getNodes();for(const n of r){if(!e.$isTextNode(n)||!n.canHaveFormat())continue;const[o,r]=s(n);if(r!==o)if(e.$isTokenOrSegmented(n)||0===o&&r===n.getTextContentSize())t(n);else{t(n.splitText(o,r)[0===o?0:1])}}e.$isRangeSelection(n)&&"text"===n.anchor.type&&"text"===n.focus.type&&n.anchor.key===n.focus.key&&g(n)}function g(e){if(e.isBackward()){const{anchor:t,focus:n}=e,{key:o,offset:s,type:r}=t;t.set(n.key,n.offset,n.type),n.set(o,s,r)}}function p(e,t){const n=e.getFormatType(),o=e.getIndent();n!==t.getFormatType()&&t.setFormat(n),o!==t.getIndent()&&t.setIndent(o)}function $(e){return e.getNode().isAttached()}function h(t){let n=t;for(;null!==n&&!e.$isRootOrShadowRoot(n);){const e=n.getLatest(),t=n.getParent();0===e.getChildrenSize()&&n.remove(!0),n=t}}function m(n,o,s,r,l=null){if(0===o.length)return;const i=o[0],c=new Map,f=[];let a=e.$isElementNode(i)?i:i.getParentOrThrow();a.isInline()&&(a=a.getParentOrThrow());let d=!1;for(;null!==a;){const t=a.getPreviousSibling();if(null!==t){a=t,d=!0;break}if(a=a.getParentOrThrow(),e.$isRootOrShadowRoot(a))break}const u=new Set;for(let t=0;t{n.append(t),g.add(t.getKey()),e.$isElementNode(t)&&t.getChildrenKeys().forEach(e=>g.add(e))}),h(l)}}else if(u.has(s.getKey())){e.$isElementNode(s)||t(179);const n=r();n.setFormat(s.getFormatType()),n.setIndent(s.getIndent()),f.push(n),s.remove(!0)}}if(null!==l)for(let e=0;e=0;e--){const t=f[e];a.insertAfter(t)}else{const t=a.getFirstChild();if(e.$isElementNode(t)&&(a=t),null===t)if(l)a.append(l);else for(let e=0;e=0;e--){const t=f[e];a.insertAfter(t),p=t}const m=e.$getPreviousSelection();e.$isRangeSelection(m)&&$(m.anchor)&&$(m.focus)?e.$setSelection(m.clone()):null!==p?p.selectEnd():n.dirty=!0}function y(e){const t=S(e);return null!==t&&"vertical-rl"===t.writingMode}function S(t){const n=t.anchor.getNode();return e.$isElementNode(n)?c(n):f(n)}function x(e,t,n,o){e.modify(t?"extend":"move",n,o)}function N(e){const t=S(e);return null!==t&&"rtl"===t.direction}function T(e,t,n){const o=l(e.getStyle());return null!==o&&o[t]||n}const E=a;exports.$cloneWithProperties=e.$cloneWithProperties,exports.$selectAll=e.$selectAll,exports.$addNodeStyle=function(e){const t=e.getStyle(),o=r(t);n.set(t,o)},exports.$copyBlockFormatIndent=p,exports.$ensureForwardRangeSelection=g,exports.$forEachSelectedTextNode=u,exports.$getComputedStyleForElement=c,exports.$getComputedStyleForParent=f,exports.$getSelectionStyleValueForProperty=function(t,n,o=""){let s=null;const r=t.getNodes(),i=t.anchor,c=t.focus,f=t.isBackward(),a=f?c.offset:i.offset,d=f?c.getNode():i.getNode();if(e.$isRangeSelection(t)&&t.isCollapsed()&&""!==t.style){const e=l(t.style);if(null!==e&&n in e)return e[n]}for(let t=0;t{d(e,n)})},exports.$setBlocksType=function(t,n,o=p){if(null===t)return;const s=t.getStartEndPoints(),r=new Map;let l=null;if(s){const[t,n]=s;l=e.$createRangeSelection(),l.anchor.set(t.key,t.offset,t.type),l.focus.set(n.key,n.offset,n.type);const o=e.$findMatchingParent(t.getNode(),e.INTERNAL_$isBlock),i=e.$findMatchingParent(n.getNode(),e.INTERNAL_$isBlock);e.$isElementNode(o)&&r.set(o.getKey(),o),e.$isElementNode(i)&&r.set(i.getKey(),i)}for(const n of t.getNodes())if(e.$isElementNode(n)&&e.INTERNAL_$isBlock(n))r.set(n.getKey(),n);else if(null===s){const t=e.$findMatchingParent(n,e.INTERNAL_$isBlock);e.$isElementNode(t)&&r.set(t.getKey(),t)}for(const[e,t]of r){const s=n();o(t,s),t.replace(s,!0),l&&(e===l.anchor.key&&l.anchor.set(s.getKey(),l.anchor.offset,l.anchor.type),e===l.focus.key&&l.focus.set(s.getKey(),l.focus.offset,l.focus.type))}l&&t.is(e.$getSelection())&&e.$setSelection(l)},exports.$shouldOverrideDefaultCharacterSelection=function(t,n){let o=y(t)?!n:n;N(t)&&(o=!o);const s=e.$caretFromPoint(t.focus,o?"previous":"next");if(e.$isExtendableTextPointCaret(s))return!1;for(const t of e.$extendCaretToRange(s)){if(e.$isChildCaret(t))return!t.origin.isInline();if(!e.$isElementNode(t.origin)){if(e.$isDecoratorNode(t.origin))return!0;break}}return!1},exports.$sliceSelectedTextNodeContent=function(t,n,o="self"){const s=t.getStartEndPoints();if(n.isSelected(t)&&!e.$isTokenOrSegmented(n)&&null!==s){const[r,l]=s,i=t.isBackward(),c=r.getNode(),f=l.getNode(),a=n.is(c),d=n.is(f);if(a||d){const[s,r]=e.$getCharacterOffsets(t),l=c.is(f),a=n.is(i?f:c),d=n.is(i?c:f);let u,g=0;if(l)g=s>r?r:s,u=s>r?s:r;else if(a){g=i?r:s,u=void 0}else if(d){g=0,u=i?s:r}const p=n.__text.slice(g,u);p!==n.__text&&("clone"===o&&(n=e.$cloneWithPropertiesEphemeral(n)),n.__text=p)}}return n},exports.$trimTextContentFromAnchor=a,exports.$wrapNodes=function(t,n,o=null){const s=t.getStartEndPoints(),r=s?s[0]:null,l=t.getNodes(),i=l.length;if(null!==r&&(0===i||1===i&&"element"===r.type&&0===r.getNode().getChildrenSize())){const e="text"===r.type?r.getNode().getParentOrThrow():r.getNode(),t=e.getChildren();let s=n();return s.setFormat(e.getFormatType()),s.setIndent(e.getIndent()),t.forEach(e=>s.append(e)),o&&(s=o.append(s)),void e.replace(s)}let c=null,f=[];for(let s=0;s{const n=e.top-t.top;return Math.abs(n)<=3?e.left-t.left:n});for(let e=0;et.top&&i.left+i.width>t.left,s=t.width+r===o.width;n||s?(l.splice(e--,1),c--):i=t}return l},exports.getCSSFromStyleObject=i,exports.getStyleObjectFromCSS=l,exports.trimTextContentFromAnchor=E; +diff --git a/node_modules/@lexical/selection/LexicalSelection.prod.mjs b/node_modules/@lexical/selection/LexicalSelection.prod.mjs +index 36fe4a7..c4b94cc 100644 +--- a/node_modules/@lexical/selection/LexicalSelection.prod.mjs ++++ b/node_modules/@lexical/selection/LexicalSelection.prod.mjs +@@ -6,4 +6,4 @@ + * + */ + +-import{$isTextNode as e,$getEditor as t,$isRootNode as n,$isElementNode as o,$getNodeByKey as l,$getPreviousSelection as r,$createTextNode as s,$isRangeSelection as i,$getSelection as c,$caretRangeFromSelection as f,$isTokenOrSegmented as u,$getCharacterOffsets as g,$cloneWithPropertiesEphemeral as a,$createRangeSelection as d,$findMatchingParent as p,INTERNAL_$isBlock as h,$setSelection as y,$caretFromPoint as m,$isExtendableTextPointCaret as S,$extendCaretToRange as x,$isChildCaret as T,$isDecoratorNode as w,$isRootOrShadowRoot as v,$hasAncestor as N,$isLeafNode as C}from"lexical";export{$cloneWithProperties,$selectAll}from"lexical";function K(e,...t){const n=new URL("https://lexical.dev/docs/error"),o=new URLSearchParams;o.append("code",e);for(const e of t)o.append("v",e);throw n.search=o.toString(),Error(`Minified Lexical error #${e}; visit ${n.toString()} for the full message or use the non-minified dev environment for full errors and additional helpful warnings.`)}const P=new Map;function E(e){let t=e;for(;null!=t;){if(t.nodeType===Node.TEXT_NODE)return t;t=t.firstChild}return null}function k(e){const t=e.parentNode;if(null==t)throw new Error("Should never happen");return[t,Array.from(t.childNodes).indexOf(e)]}function I(t,n,o,l,r){const s=n.getKey(),i=l.getKey(),c=document.createRange();let f=t.getElementByKey(s),u=t.getElementByKey(i),g=o,a=r;if(e(n)&&(f=E(f)),e(l)&&(u=E(u)),void 0===n||void 0===l||null===f||null===u)return null;"BR"===f.nodeName&&([f,g]=k(f)),"BR"===u.nodeName&&([u,a]=k(u));const d=f.firstChild;f===u&&null!=d&&"BR"===d.nodeName&&0===g&&0===a&&(a=1);try{c.setStart(f,g),c.setEnd(u,a)}catch(e){return null}return!c.collapsed||g===a&&s===i||(c.setStart(u,a),c.setEnd(f,g)),c}function B(e,t){const n=e.getRootElement();if(null===n)return[];const o=n.getBoundingClientRect(),l=getComputedStyle(n),r=parseFloat(l.paddingLeft)+parseFloat(l.paddingRight),s=Array.from(t.getClientRects());let i,c=s.length;s.sort((e,t)=>{const n=e.top-t.top;return Math.abs(n)<=3?e.left-t.left:n});for(let e=0;et.top&&i.left+i.width>t.left,l=t.width+r===o.width;n||l?(s.splice(e--,1),c--):i=t}return s}function F(e){const t={};if(!e)return t;const n=e.split(";");for(const e of n)if(""!==e){const[n,o]=e.split(/:([^]+)/);n&&o&&(t[n.trim()]=o.trim())}return t}function b(e){let t=P.get(e);return void 0===t&&(t=F(e),P.set(e,t)),t}function R(e){let t="";for(const n in e)n&&(t+=`${n}: ${e[n]};`);return t}function O(e){const n=t().getElementByKey(e.getKey());if(null===n)return null;const o=n.ownerDocument.defaultView;return null===o?null:o.getComputedStyle(n)}function z(e){return O(n(e)?e:e.getParentOrThrow())}function A(e){const t=z(e);return null!==t&&"rtl"===t.direction}function M(e,t,n="self"){const o=e.getStartEndPoints();if(t.isSelected(e)&&!u(t)&&null!==o){const[l,r]=o,s=e.isBackward(),i=l.getNode(),c=r.getNode(),f=t.is(i),u=t.is(c);if(f||u){const[o,l]=g(e),r=i.is(c),f=t.is(s?c:i),u=t.is(s?i:c);let d,p=0;if(r)p=o>l?l:o,d=o>l?o:l;else if(f){p=s?l:o,d=void 0}else if(u){p=0,d=s?o:l}const h=t.__text.slice(p,d);h!==t.__text&&("clone"===n&&(t=a(t)),t.__text=h)}}return t}function _(e){if("text"===e.type)return e.offset===e.getNode().getTextContentSize();const t=e.getNode();return o(t)||K(177),e.offset===t.getChildrenSize()}function L(t,c,f){let u=c.getNode(),g=f;if(o(u)){const e=u.getDescendantByIndex(c.offset);null!==e&&(u=e)}for(;g>0&&null!==u;){if(o(u)){const e=u.getLastDescendant();null!==e&&(u=e)}let f=u.getPreviousSibling(),a=0;if(null===f){let e=u.getParentOrThrow(),t=e.getPreviousSibling();for(;null===t;){if(e=e.getParent(),null===e){f=null;break}t=e.getPreviousSibling()}null!==e&&(a=e.isInline()?0:2,f=t)}let d=u.getTextContent();""===d&&o(u)&&!u.isInline()&&(d="\n\n");const p=d.length;if(!e(u)||g>=p){const e=u.getParent();u.remove(),null==e||0!==e.getChildrenSize()||n(e)||e.remove(),g-=p+a,u=f}else{const n=u.getKey(),o=t.getEditorState().read(()=>{const t=l(n);return e(t)&&t.isSimpleText()?t.getTextContent():null}),f=p-g,a=d.slice(0,f);if(null!==o&&o!==d){const e=r();let t=u;if(u.isSimpleText())u.setTextContent(o);else{const e=s(o);u.replace(e),t=e}if(i(e)&&e.isCollapsed()){const n=e.anchor.offset;t.select(n,n)}}else if(u.isSimpleText()){const e=c.key===n;let t=c.offset;t("function"==typeof o?e[n]=o(l[n],t):null===o?delete e[n]:e[n]=o,e),{...l}),s=R(r);i(t)||e(t)?t.setStyle(s):t.setTextStyle(s),P.set(s,r)}function U(e,t){if(i(e)&&e.isCollapsed()){D(e,t);const n=e.anchor.getNode();o(n)&&n.isEmpty()&&D(n,t)}j(e=>{D(e,t)})}function j(t){const n=c();if(!n)return;const o=new Map,l=e=>o.get(e.getKey())||[0,e.getTextContentSize()];if(i(n))for(const e of f(n).getTextSlices())e&&o.set(e.caret.origin.getKey(),e.getSliceIndices());const r=n.getNodes();for(const n of r){if(!e(n)||!n.canHaveFormat())continue;const[o,r]=l(n);if(r!==o)if(u(n)||0===o&&r===n.getTextContentSize())t(n);else{t(n.splitText(o,r)[0===o?0:1])}}i(n)&&"text"===n.anchor.type&&"text"===n.focus.type&&n.anchor.key===n.focus.key&&H(n)}function H(e){if(e.isBackward()){const{anchor:t,focus:n}=e,{key:o,offset:l,type:r}=t;t.set(n.key,n.offset,n.type),n.set(o,l,r)}}function V(e,t){const n=e.getFormatType(),o=e.getIndent();n!==t.getFormatType()&&t.setFormat(n),o!==t.getIndent()&&t.setIndent(o)}function W(e,t,n=V){if(null===e)return;const l=e.getStartEndPoints(),r=new Map;let s=null;if(l){const[e,t]=l;s=d(),s.anchor.set(e.key,e.offset,e.type),s.focus.set(t.key,t.offset,t.type);const n=p(e.getNode(),h),i=p(t.getNode(),h);o(n)&&r.set(n.getKey(),n),o(i)&&r.set(i.getKey(),i)}for(const t of e.getNodes())if(o(t)&&h(t))r.set(t.getKey(),t);else if(null===l){const e=p(t,h);o(e)&&r.set(e.getKey(),e)}for(const[e,o]of r){const l=t();n(o,l),o.replace(l,!0),s&&(e===s.anchor.key&&s.anchor.set(l.getKey(),s.anchor.offset,s.anchor.type),e===s.focus.key&&s.focus.set(l.getKey(),s.focus.offset,s.focus.type))}s&&e.is(c())&&y(s)}function X(e){return e.getNode().isAttached()}function q(e){let t=e;for(;null!==t&&!v(t);){const e=t.getLatest(),n=t.getParent();0===e.getChildrenSize()&&t.remove(!0),t=n}}function G(e,t,n=null){const o=e.getStartEndPoints(),l=o?o[0]:null,r=e.getNodes(),s=r.length;if(null!==l&&(0===s||1===s&&"element"===l.type&&0===l.getNode().getChildrenSize())){const e="text"===l.type?l.getNode().getParentOrThrow():l.getNode(),o=e.getChildren();let r=t();return r.setFormat(e.getFormatType()),r.setIndent(e.getIndent()),o.forEach(e=>r.append(e)),n&&(r=n.append(r)),void e.replace(r)}let i=null,c=[];for(let o=0;o{t.append(e),p.add(e.getKey()),o(e)&&e.getChildrenKeys().forEach(e=>p.add(e))}),q(r)}}else if(d.has(n.getKey())){o(n)||K(179);const e=l();e.setFormat(n.getFormatType()),e.setIndent(n.getIndent()),u.push(e),n.remove(!0)}}if(null!==s)for(let e=0;e=0;e--){const t=u[e];g.insertAfter(t)}else{const e=g.getFirstChild();if(o(e)&&(g=e),null===e)if(s)g.append(s);else for(let e=0;e=0;e--){const t=u[e];g.insertAfter(t),h=t}const m=r();i(m)&&X(m.anchor)&&X(m.focus)?y(m.clone()):null!==h?h.selectEnd():e.dirty=!0}function Q(e){const t=Y(e);return null!==t&&"vertical-rl"===t.writingMode}function Y(e){const t=e.anchor.getNode();return o(t)?O(t):z(t)}function Z(e,t){let n=Q(e)?!t:t;te(e)&&(n=!n);const l=m(e.focus,n?"previous":"next");if(S(l))return!1;for(const e of x(l)){if(T(e))return!e.origin.isInline();if(!o(e.origin)){if(w(e.origin))return!0;break}}return!1}function ee(e,t,n,o){e.modify(t?"extend":"move",n,o)}function te(e){const t=Y(e);return null!==t&&"rtl"===t.direction}function ne(e,t,n){const o=te(e);let l;l=Q(e)||o?!n:n,ee(e,t,l,"character")}function oe(e,t,n){const o=b(e.getStyle());return null!==o&&o[t]||n}function le(t,n,o=""){let l=null;const r=t.getNodes(),s=t.anchor,c=t.focus,f=t.isBackward(),u=f?c.offset:s.offset,g=f?c.getNode():s.getNode();if(i(t)&&t.isCollapsed()&&""!==t.style){const e=b(t.style);if(null!==e&&n in e)return e[n]}for(let t=0;t{const n=e.top-t.top;return Math.abs(n)<=3?e.left-t.left:n});for(let e=0;et.top&&i.left+i.width>t.left,l=t.width+r===o.width;n||l?(s.splice(e--,1),c--):i=t}return s}function b(e){const t={};if(!e)return t;const n=e.split(";");for(const e of n)if(""!==e){const[n,o]=e.split(/:([^]+)/);n&&o&&(t[n.trim()]=o.trim())}return t}function R(e){let t=P.get(e);return void 0===t&&(t=b(e),P.set(e,t)),t}function O(e){let t="";for(const n in e)n&&(t+=`${n}: ${e[n]};`);return t}function z(e){const t=n().getElementByKey(e.getKey());if(null===t)return null;const o=t.ownerDocument.defaultView;return null===o?null:o.getComputedStyle(t)}function A(e){return z(o(e)?e:e.getParentOrThrow())}function M(e){const t=A(e);return null!==t&&"rtl"===t.direction}function _(e,t,n="self"){const o=e.getStartEndPoints();if(t.isSelected(e)&&!g(t)&&null!==o){const[l,r]=o,s=e.isBackward(),i=l.getNode(),c=r.getNode(),f=t.is(i),u=t.is(c);if(f||u){const[o,l]=a(e),r=i.is(c),f=t.is(s?c:i),u=t.is(s?i:c);let g,p=0;if(r)p=o>l?l:o,g=o>l?o:l;else if(f){p=s?l:o,g=void 0}else if(u){p=0,g=s?o:l}const h=t.__text.slice(p,g);h!==t.__text&&("clone"===n&&(t=d(t)),t.__text=h)}}return t}function L(e){if("text"===e.type)return e.offset===e.getNode().getTextContentSize();const t=e.getNode();return l(t)||E(177),e.offset===t.getChildrenSize()}function $(e,n,f){let u=n.getNode(),g=f;if(l(u)){const e=u.getDescendantByIndex(n.offset);null!==e&&(u=e)}for(;g>0&&null!==u;){if(l(u)){const e=u.getLastDescendant();null!==e&&(u=e)}let f=u.getPreviousSibling(),a=0;if(null===f){let e=u.getParentOrThrow(),t=e.getPreviousSibling();for(;null===t;){if(e=e.getParent(),null===e){f=null;break}t=e.getPreviousSibling()}null!==e&&(a=e.isInline()?0:2,f=t)}let d=u.getTextContent();""===d&&l(u)&&!u.isInline()&&(d="\n\n");const p=d.length;if(!t(u)||g>=p){const e=u.getParent();u.remove(),null==e||0!==e.getChildrenSize()||o(e)||e.remove(),g-=p+a,u=f}else{const o=u.getKey(),l=e.getEditorState().read(()=>{const e=r(o);return t(e)&&e.isSimpleText()?e.getTextContent():null}),f=p-g,a=d.slice(0,f);if(null!==l&&l!==d){const e=s();let t=u;if(u.isSimpleText())u.setTextContent(l);else{const e=i(l);u.replace(e),t=e}if(c(e)&&e.isCollapsed()){const n=e.anchor.offset;t.select(n,n)}}else if(u.isSimpleText()){const e=n.key===o;let t=n.offset;t("function"==typeof l?t[n]=l(o[n],e):null===l?delete t[n]:t[n]=l,t),{...o}),s=O(r);c(e)||t(e)?e.setStyle(s):e.setTextStyle(s),P.set(s,r)}function j(e,t){if(c(e)&&e.isCollapsed()){U(e,t);const n=e.anchor.getNode();l(n)&&n.isEmpty()&&U(n,t)}H(e=>{U(e,t)})}function H(e){const n=f();if(!n)return;const o=new Map,l=e=>o.get(e.getKey())||[0,e.getTextContentSize()];if(c(n))for(const e of u(n).getTextSlices())e&&o.set(e.caret.origin.getKey(),e.getSliceIndices());const r=n.getNodes();for(const n of r){if(!t(n)||!n.canHaveFormat())continue;const[o,r]=l(n);if(r!==o)if(g(n)||0===o&&r===n.getTextContentSize())e(n);else{e(n.splitText(o,r)[0===o?0:1])}}c(n)&&"text"===n.anchor.type&&"text"===n.focus.type&&n.anchor.key===n.focus.key&&V(n)}function V(e){if(e.isBackward()){const{anchor:t,focus:n}=e,{key:o,offset:l,type:r}=t;t.set(n.key,n.offset,n.type),n.set(o,l,r)}}function W(e,t){const n=e.getFormatType(),o=e.getIndent();n!==t.getFormatType()&&t.setFormat(n),o!==t.getIndent()&&t.setIndent(o)}function X(e,t,n=W){if(null===e)return;const o=e.getStartEndPoints(),r=new Map;let s=null;if(o){const[e,t]=o;s=p(),s.anchor.set(e.key,e.offset,e.type),s.focus.set(t.key,t.offset,t.type);const n=h(e.getNode(),y),i=h(t.getNode(),y);l(n)&&r.set(n.getKey(),n),l(i)&&r.set(i.getKey(),i)}for(const t of e.getNodes())if(l(t)&&y(t))r.set(t.getKey(),t);else if(null===o){const e=h(t,y);l(e)&&r.set(e.getKey(),e)}for(const[e,o]of r){const l=t();n(o,l),o.replace(l,!0),s&&(e===s.anchor.key&&s.anchor.set(l.getKey(),s.anchor.offset,s.anchor.type),e===s.focus.key&&s.focus.set(l.getKey(),s.focus.offset,s.focus.type))}s&&e.is(f())&&m(s)}function q(e){return e.getNode().isAttached()}function G(e){let t=e;for(;null!==t&&!N(t);){const e=t.getLatest(),n=t.getParent();0===e.getChildrenSize()&&t.remove(!0),t=n}}function J(e,t,n=null){const o=e.getStartEndPoints(),l=o?o[0]:null,r=e.getNodes(),s=r.length;if(null!==l&&(0===s||1===s&&"element"===l.type&&0===l.getNode().getChildrenSize())){const e="text"===l.type?l.getNode().getParentOrThrow():l.getNode(),o=e.getChildren();let r=t();return r.setFormat(e.getFormatType()),r.setIndent(e.getIndent()),o.forEach(e=>r.append(e)),n&&(r=n.append(r)),void e.replace(r)}let i=null,c=[];for(let o=0;o{t.append(e),p.add(e.getKey()),l(e)&&e.getChildrenKeys().forEach(e=>p.add(e))}),G(r)}}else if(d.has(n.getKey())){l(n)||E(179);const e=o();e.setFormat(n.getFormatType()),e.setIndent(n.getIndent()),u.push(e),n.remove(!0)}}if(null!==r)for(let e=0;e=0;e--){const t=u[e];g.insertAfter(t)}else{const e=g.getFirstChild();if(l(e)&&(g=e),null===e)if(r)g.append(r);else for(let e=0;e=0;e--){const t=u[e];g.insertAfter(t),h=t}const y=s();c(y)&&q(y.anchor)&&q(y.focus)?m(y.clone()):null!==h?h.selectEnd():e.dirty=!0}function Y(e){const t=Z(e);return null!==t&&"vertical-rl"===t.writingMode}function Z(e){const t=e.anchor.getNode();return l(t)?z(t):A(t)}function ee(e,t){let n=Y(e)?!t:t;ne(e)&&(n=!n);const o=S(e.focus,n?"previous":"next");if(x(o))return!1;for(const e of T(o)){if(w(e))return!e.origin.isInline();if(!l(e.origin)){if(v(e.origin))return!0;break}}return!1}function te(e,t,n,o){e.modify(t?"extend":"move",n,o)}function ne(e){const t=Z(e);return null!==t&&"rtl"===t.direction}function oe(e,t,n){const o=ne(e);let l;l=Y(e)||o?!n:n,te(e,t,l,"character")}function le(e,t,n){const o=R(e.getStyle());return null!==o&&o[t]||n}function re(e,n,o=""){let l=null;const r=e.getNodes(),s=e.anchor,i=e.focus,f=e.isBackward(),u=f?i.offset:s.offset,g=f?i.getNode():s.getNode();if(c(e)&&e.isCollapsed()&&""!==e.style){const t=R(e.style);if(null!==t&&n in t)return t[n]}for(let e=0;e 0) { ++ // Repeat the last column width. ++ const fillWidth = colWidths[colWidths.length - 1]; ++ newColWidths = [...colWidths, ...Array(columnCount - colWidths.length).fill(fillWidth)]; ++ } ++ node.setColWidths(newColWidths); ++ } + } + function $tableClickCommand(event) { + if (event.detail < 3 || !lexical.isDOMNode(event.target)) { +@@ -4173,17 +4186,22 @@ function registerTableSelectionObserver(editor, hasTabHandler = true) { + * @param editor The editor + * @returns An unregister callback + */ +-function registerTablePlugin(editor) { ++function registerTablePlugin(editor, options) { + if (!editor.hasNodes([TableNode])) { + { + formatDevErrorMessage(`TablePlugin: TableNode is not registered on editor`); + } + } +- return utils.mergeRegister(editor.registerCommand(INSERT_TABLE_COMMAND, $insertTableCommandListener, lexical.COMMAND_PRIORITY_EDITOR), editor.registerCommand(lexical.SELECTION_INSERT_CLIPBOARD_NODES_COMMAND, ({ ++ const { ++ hasNestedTables = extension.signal(false) ++ } = options ?? {}; ++ return utils.mergeRegister(editor.registerCommand(INSERT_TABLE_COMMAND, payload => { ++ return $insertTable(payload, hasNestedTables.peek()); ++ }, lexical.COMMAND_PRIORITY_EDITOR), editor.registerCommand(lexical.SELECTION_INSERT_CLIPBOARD_NODES_COMMAND, ({ + nodes, + selection + }, dispatchEditor) => { +- if (editor !== dispatchEditor || !lexical.$isRangeSelection(selection)) { ++ if (hasNestedTables.peek() || editor !== dispatchEditor || !lexical.$isRangeSelection(selection)) { + return false; + } + const isInsideTableCell = $findTableNode(selection.anchor.getNode()) !== null; +@@ -4211,12 +4229,16 @@ const TableExtension = lexical.defineExtension({ + hasCellBackgroundColor: true, + hasCellMerge: true, + hasHorizontalScroll: true, ++ hasNestedTables: false, + hasTabHandler: true + }), + name: '@lexical/table/Table', +- nodes: [TableNode, TableRowNode, TableCellNode], ++ nodes: () => [TableNode, TableRowNode, TableCellNode], + register(editor, config, state) { + const stores = state.getOutput(); ++ const { ++ hasNestedTables ++ } = stores; + return utils.mergeRegister(extension.effect(() => { + const hasHorizontalScroll = stores.hasHorizontalScroll.value; + const hadHorizontalScroll = $isScrollableTablesActive(editor); +@@ -4226,7 +4248,9 @@ const TableExtension = lexical.defineExtension({ + // TableNodes as dirty. The handler is immediately unregistered. + editor.registerNodeTransform(TableNode, () => {})(); + } +- }), registerTablePlugin(editor), extension.effect(() => registerTableSelectionObserver(editor, stores.hasTabHandler.value)), extension.effect(() => stores.hasCellMerge.value ? undefined : registerTableCellUnmergeTransform(editor)), extension.effect(() => stores.hasCellBackgroundColor.value ? undefined : editor.registerNodeTransform(TableCellNode, node => { ++ }), registerTablePlugin(editor, { ++ hasNestedTables ++ }), extension.effect(() => registerTableSelectionObserver(editor, stores.hasTabHandler.value)), extension.effect(() => stores.hasCellMerge.value ? undefined : registerTableCellUnmergeTransform(editor)), extension.effect(() => stores.hasCellBackgroundColor.value ? undefined : editor.registerNodeTransform(TableCellNode, node => { + if (node.getBackgroundColor() !== null) { + node.setBackgroundColor(null); + } +diff --git a/node_modules/@lexical/table/LexicalTable.dev.mjs b/node_modules/@lexical/table/LexicalTable.dev.mjs +index 8e92a12..a68e504 100644 +--- a/node_modules/@lexical/table/LexicalTable.dev.mjs ++++ b/node_modules/@lexical/table/LexicalTable.dev.mjs +@@ -7,8 +7,8 @@ + */ + + import { addClassNamesToElement, $descendantsMatching, $findMatchingParent, removeClassNamesFromElement, objectKlassEquals, isHTMLElement as isHTMLElement$1, $insertFirst as $insertFirst$1, mergeRegister, $insertNodeToNearestRoot, $unwrapAndFilterDescendants } from '@lexical/utils'; +-import { ElementNode, isHTMLElement, $isInlineElementOrDecoratorNode, $isTextNode, $isLineBreakNode, $createParagraphNode, $applyNodeReplacement, createCommand, $createTextNode, $getSelection, $isRangeSelection, $isParagraphNode, $createPoint, $getNodeByKey, $isElementNode, $normalizeSelection__EXPERIMENTAL, isCurrentlyReadOnlyMode, TEXT_TYPE_TO_FORMAT, $getEditor, $setSelection, SELECTION_CHANGE_COMMAND, getDOMSelection, $createRangeSelection, $isRootNode, INSERT_PARAGRAPH_COMMAND, KEY_ARROW_DOWN_COMMAND, KEY_ARROW_UP_COMMAND, KEY_ARROW_LEFT_COMMAND, KEY_ARROW_RIGHT_COMMAND, COMMAND_PRIORITY_HIGH, KEY_ESCAPE_COMMAND, DELETE_WORD_COMMAND, DELETE_LINE_COMMAND, DELETE_CHARACTER_COMMAND, KEY_BACKSPACE_COMMAND, KEY_DELETE_COMMAND, CUT_COMMAND, FORMAT_TEXT_COMMAND, FORMAT_ELEMENT_COMMAND, CONTROLLED_TEXT_INSERTION_COMMAND, KEY_TAB_COMMAND, FOCUS_COMMAND, SELECTION_INSERT_CLIPBOARD_NODES_COMMAND, $getPreviousSelection, $getNearestNodeFromDOMNode, $createRangeSelectionFromDom, isDOMNode, $isRootOrShadowRoot, $caretFromPoint, $isExtendableTextPointCaret, $extendCaretToRange, $isSiblingCaret, $getSiblingCaret, $setPointFromCaret, $normalizeCaret, $isChildCaret, $getChildCaret, $getAdjacentChildCaret, setDOMUnmanaged, COMMAND_PRIORITY_EDITOR, CLICK_COMMAND, defineExtension, safeCast } from 'lexical'; +-import { effect, namedSignals } from '@lexical/extension'; ++import { ElementNode, isHTMLElement, $isInlineElementOrDecoratorNode, $isTextNode, $isLineBreakNode, $createParagraphNode, $applyNodeReplacement, createCommand, $createTextNode, $getSelection, $isRangeSelection, $isParagraphNode, $createPoint, $getNodeByKey, $isElementNode, $normalizeSelection__EXPERIMENTAL, isCurrentlyReadOnlyMode, TEXT_TYPE_TO_FORMAT, $getEditor, $setSelection, SELECTION_CHANGE_COMMAND, getDOMSelectionForEditor, $createRangeSelection, $isRootNode, INSERT_PARAGRAPH_COMMAND, KEY_ARROW_DOWN_COMMAND, KEY_ARROW_UP_COMMAND, KEY_ARROW_LEFT_COMMAND, KEY_ARROW_RIGHT_COMMAND, COMMAND_PRIORITY_HIGH, KEY_ESCAPE_COMMAND, DELETE_WORD_COMMAND, DELETE_LINE_COMMAND, DELETE_CHARACTER_COMMAND, KEY_BACKSPACE_COMMAND, KEY_DELETE_COMMAND, CUT_COMMAND, FORMAT_TEXT_COMMAND, FORMAT_ELEMENT_COMMAND, CONTROLLED_TEXT_INSERTION_COMMAND, KEY_TAB_COMMAND, FOCUS_COMMAND, SELECTION_INSERT_CLIPBOARD_NODES_COMMAND, $getPreviousSelection, $getNearestNodeFromDOMNode, $createRangeSelectionFromDom, isDOMNode, $isRootOrShadowRoot, $caretFromPoint, $isExtendableTextPointCaret, $extendCaretToRange, $isSiblingCaret, $getSiblingCaret, $setPointFromCaret, $normalizeCaret, $isChildCaret, $getChildCaret, $getAdjacentChildCaret, setDOMUnmanaged, COMMAND_PRIORITY_EDITOR, CLICK_COMMAND, defineExtension, safeCast } from 'lexical'; ++import { signal, effect, namedSignals } from '@lexical/extension'; + import { copyToClipboard, $getClipboardDataFromSelection } from '@lexical/clipboard'; + + /** +@@ -1987,7 +1987,7 @@ class TableObserver { + /** @internal */ + updateDOMSelection() { + if (this.anchorCell !== null && this.focusCell !== null) { +- const domSelection = getDOMSelection(this.editor._window); ++ const domSelection = getDOMSelectionForEditor(this.editor); + // We are not using a native selection for tables, and if we + // set one then the reconciler will undo it. + // TODO - it would make sense to have one so that native +@@ -2726,7 +2726,7 @@ function applyTableHandlers(tableNode, element, editor, hasTabHandler) { + } + } else if (selection && $isTableSelection(selection) && selection.is(prevSelection) && selection.tableKey === tableNode.getKey()) { + // if selection goes outside of the table we need to change it to Range selection +- const domSelection = getDOMSelection(editorWindow); ++ const domSelection = getDOMSelectionForEditor(editor); + if (domSelection && domSelection.anchorNode && domSelection.focusNode) { + const focusNode = $getNearestNodeFromDOMNode(domSelection.focusNode); + const isFocusOutside = focusNode && !tableNode.isParentOf(focusNode); +@@ -3388,7 +3388,7 @@ function $handleArrowKey(editor, event, direction, tableNode, tableObserver) { + if (anchor.type === 'element') { + edgeSelectionRect = anchorDOM.getBoundingClientRect(); + } else { +- const domSelection = getDOMSelection(getEditorWindow(editor)); ++ const domSelection = getDOMSelectionForEditor(editor); + if (domSelection === null || domSelection.rangeCount === 0) { + return false; + } +@@ -3480,7 +3480,7 @@ function $getTableEdgeCursorPosition(editor, selection, tableNode) { + } + + // TODO: Add support for nested tables +- const domSelection = getDOMSelection(getEditorWindow(editor)); ++ const domSelection = getDOMSelectionForEditor(editor); + if (!domSelection) { + return undefined; + } +@@ -3971,18 +3971,18 @@ function $isTableNode(node) { + return node instanceof TableNode; + } + +-function $insertTableCommandListener({ ++function $insertTable({ + rows, + columns, + includeHeaders +-}) { ++}, hasNestedTables) { + const selection = $getSelection() || $getPreviousSelection(); + if (!selection || !$isRangeSelection(selection)) { + return false; + } + + // Prevent nested tables by checking if we're already inside a table +- if ($findTableNode(selection.anchor.getNode())) { ++ if (!hasNestedTables && $findTableNode(selection.anchor.getNode())) { + return false; + } + const tableNode = $createTableNodeWithDimensions(Number(rows), Number(columns), includeHeaders); +@@ -4039,6 +4039,19 @@ function $tableTransform(node) { + rowNode.append(newCell); + } + } ++ const colWidths = node.getColWidths(); ++ const columnCount = node.getColumnCount(); ++ if (colWidths && colWidths.length !== columnCount) { ++ let newColWidths = undefined; ++ if (columnCount < colWidths.length) { ++ newColWidths = colWidths.slice(0, columnCount); ++ } else if (colWidths.length > 0) { ++ // Repeat the last column width. ++ const fillWidth = colWidths[colWidths.length - 1]; ++ newColWidths = [...colWidths, ...Array(columnCount - colWidths.length).fill(fillWidth)]; ++ } ++ node.setColWidths(newColWidths); ++ } + } + function $tableClickCommand(event) { + if (event.detail < 3 || !isDOMNode(event.target)) { +@@ -4171,17 +4184,22 @@ function registerTableSelectionObserver(editor, hasTabHandler = true) { + * @param editor The editor + * @returns An unregister callback + */ +-function registerTablePlugin(editor) { ++function registerTablePlugin(editor, options) { + if (!editor.hasNodes([TableNode])) { + { + formatDevErrorMessage(`TablePlugin: TableNode is not registered on editor`); + } + } +- return mergeRegister(editor.registerCommand(INSERT_TABLE_COMMAND, $insertTableCommandListener, COMMAND_PRIORITY_EDITOR), editor.registerCommand(SELECTION_INSERT_CLIPBOARD_NODES_COMMAND, ({ ++ const { ++ hasNestedTables = signal(false) ++ } = options ?? {}; ++ return mergeRegister(editor.registerCommand(INSERT_TABLE_COMMAND, payload => { ++ return $insertTable(payload, hasNestedTables.peek()); ++ }, COMMAND_PRIORITY_EDITOR), editor.registerCommand(SELECTION_INSERT_CLIPBOARD_NODES_COMMAND, ({ + nodes, + selection + }, dispatchEditor) => { +- if (editor !== dispatchEditor || !$isRangeSelection(selection)) { ++ if (hasNestedTables.peek() || editor !== dispatchEditor || !$isRangeSelection(selection)) { + return false; + } + const isInsideTableCell = $findTableNode(selection.anchor.getNode()) !== null; +@@ -4209,12 +4227,16 @@ const TableExtension = defineExtension({ + hasCellBackgroundColor: true, + hasCellMerge: true, + hasHorizontalScroll: true, ++ hasNestedTables: false, + hasTabHandler: true + }), + name: '@lexical/table/Table', +- nodes: [TableNode, TableRowNode, TableCellNode], ++ nodes: () => [TableNode, TableRowNode, TableCellNode], + register(editor, config, state) { + const stores = state.getOutput(); ++ const { ++ hasNestedTables ++ } = stores; + return mergeRegister(effect(() => { + const hasHorizontalScroll = stores.hasHorizontalScroll.value; + const hadHorizontalScroll = $isScrollableTablesActive(editor); +@@ -4224,7 +4246,9 @@ const TableExtension = defineExtension({ + // TableNodes as dirty. The handler is immediately unregistered. + editor.registerNodeTransform(TableNode, () => {})(); + } +- }), registerTablePlugin(editor), effect(() => registerTableSelectionObserver(editor, stores.hasTabHandler.value)), effect(() => stores.hasCellMerge.value ? undefined : registerTableCellUnmergeTransform(editor)), effect(() => stores.hasCellBackgroundColor.value ? undefined : editor.registerNodeTransform(TableCellNode, node => { ++ }), registerTablePlugin(editor, { ++ hasNestedTables ++ }), effect(() => registerTableSelectionObserver(editor, stores.hasTabHandler.value)), effect(() => stores.hasCellMerge.value ? undefined : registerTableCellUnmergeTransform(editor)), effect(() => stores.hasCellBackgroundColor.value ? undefined : editor.registerNodeTransform(TableCellNode, node => { + if (node.getBackgroundColor() !== null) { + node.setBackgroundColor(null); + } +diff --git a/node_modules/@lexical/table/LexicalTable.prod.js b/node_modules/@lexical/table/LexicalTable.prod.js +index 2c95550..71c56a1 100644 +--- a/node_modules/@lexical/table/LexicalTable.prod.js ++++ b/node_modules/@lexical/table/LexicalTable.prod.js +@@ -6,4 +6,4 @@ + * + */ + +-"use strict";var e=require("@lexical/utils"),t=require("lexical"),n=require("@lexical/extension"),o=require("@lexical/clipboard");const r=/^(\d+(?:\.\d+)?)px$/,l={BOTH:3,COLUMN:2,NO_STATUS:0,ROW:1};class s extends t.ElementNode{__colSpan;__rowSpan;__headerState;__width;__backgroundColor;__verticalAlign;static getType(){return"tablecell"}static clone(e){return new s(e.__headerState,e.__colSpan,e.__width,e.__key)}afterCloneFrom(e){super.afterCloneFrom(e),this.__rowSpan=e.__rowSpan,this.__backgroundColor=e.__backgroundColor,this.__verticalAlign=e.__verticalAlign}static importDOM(){return{td:e=>({conversion:a,priority:0}),th:e=>({conversion:a,priority:0})}}static importJSON(e){return c().updateFromJSON(e)}updateFromJSON(e){return super.updateFromJSON(e).setHeaderStyles(e.headerState).setColSpan(e.colSpan||1).setRowSpan(e.rowSpan||1).setWidth(e.width||void 0).setBackgroundColor(e.backgroundColor||null).setVerticalAlign(e.verticalAlign||void 0)}constructor(e=l.NO_STATUS,t=1,n,o){super(o),this.__colSpan=t,this.__rowSpan=1,this.__headerState=e,this.__width=n,this.__backgroundColor=null,this.__verticalAlign=void 0}createDOM(t){const n=document.createElement(this.getTag());return this.__width&&(n.style.width=`${this.__width}px`),this.__colSpan>1&&(n.colSpan=this.__colSpan),this.__rowSpan>1&&(n.rowSpan=this.__rowSpan),null!==this.__backgroundColor&&(n.style.backgroundColor=this.__backgroundColor),i(this.__verticalAlign)&&(n.style.verticalAlign=this.__verticalAlign),e.addClassNamesToElement(n,t.theme.tableCell,this.hasHeader()&&t.theme.tableCellHeader),n}exportDOM(e){const n=super.exportDOM(e);if(t.isHTMLElement(n.element)){const e=n.element;e.setAttribute("data-temporary-table-cell-lexical-key",this.getKey()),e.style.border="1px solid black",this.__colSpan>1&&(e.colSpan=this.__colSpan),this.__rowSpan>1&&(e.rowSpan=this.__rowSpan),e.style.width=`${this.getWidth()||75}px`,e.style.verticalAlign=this.getVerticalAlign()||"top",e.style.textAlign="start",null===this.__backgroundColor&&this.hasHeader()&&(e.style.backgroundColor="#f2f3f5")}return n}exportJSON(){return{...super.exportJSON(),...i(this.__verticalAlign)&&{verticalAlign:this.__verticalAlign},backgroundColor:this.getBackgroundColor(),colSpan:this.__colSpan,headerState:this.__headerState,rowSpan:this.__rowSpan,width:this.getWidth()}}getColSpan(){return this.getLatest().__colSpan}setColSpan(e){const t=this.getWritable();return t.__colSpan=e,t}getRowSpan(){return this.getLatest().__rowSpan}setRowSpan(e){const t=this.getWritable();return t.__rowSpan=e,t}getTag(){return this.hasHeader()?"th":"td"}setHeaderStyles(e,t=l.BOTH){const n=this.getWritable();return n.__headerState=e&t|n.__headerState&~t,n}getHeaderStyles(){return this.getLatest().__headerState}setWidth(e){const t=this.getWritable();return t.__width=e,t}getWidth(){return this.getLatest().__width}getBackgroundColor(){return this.getLatest().__backgroundColor}setBackgroundColor(e){const t=this.getWritable();return t.__backgroundColor=e,t}getVerticalAlign(){return this.getLatest().__verticalAlign}setVerticalAlign(e){const t=this.getWritable();return t.__verticalAlign=e||void 0,t}toggleHeaderStyle(e){const t=this.getWritable();return(t.__headerState&e)===e?t.__headerState-=e:t.__headerState+=e,t}hasHeaderState(e){return(this.getHeaderStyles()&e)===e}hasHeader(){return this.getLatest().__headerState!==l.NO_STATUS}updateDOM(e){return e.__headerState!==this.__headerState||e.__width!==this.__width||e.__colSpan!==this.__colSpan||e.__rowSpan!==this.__rowSpan||e.__backgroundColor!==this.__backgroundColor||e.__verticalAlign!==this.__verticalAlign}isShadowRoot(){return!0}collapseAtStart(){return!0}canBeEmpty(){return!1}canIndent(){return!1}}function i(e){return"middle"===e||"bottom"===e}function a(e){const n=e,o=e.nodeName.toLowerCase();let s;r.test(n.style.width)&&(s=parseFloat(n.style.width));const a=c("th"===o?l.ROW:l.NO_STATUS,n.colSpan,s);a.__rowSpan=n.rowSpan;const u=n.style.backgroundColor;""!==u&&(a.__backgroundColor=u);const d=n.style.verticalAlign;i(d)&&(a.__verticalAlign=d);const h=n.style,g=(h&&h.textDecoration||"").split(" "),f="700"===h.fontWeight||"bold"===h.fontWeight,m=g.includes("line-through"),p="italic"===h.fontStyle,C=g.includes("underline");return{after:e=>{const n=[];let o=null;const r=()=>{if(o){const e=o.getFirstChild();t.$isLineBreakNode(e)&&1===o.getChildrenSize()&&e.remove()}};for(const l of e)t.$isInlineElementOrDecoratorNode(l)||t.$isTextNode(l)||t.$isLineBreakNode(l)?(t.$isTextNode(l)&&(f&&l.toggleFormat("bold"),m&&l.toggleFormat("strikethrough"),p&&l.toggleFormat("italic"),C&&l.toggleFormat("underline")),o?o.append(l):(o=t.$createParagraphNode().append(l),n.push(o))):(n.push(l),r(),o=null);return r(),0===n.length&&n.push(t.$createParagraphNode()),n},node:a}}function c(e=l.NO_STATUS,n=1,o){return t.$applyNodeReplacement(new s(e,n,o))}function u(e){return e instanceof s}const d=t.createCommand("INSERT_TABLE_COMMAND");function h(e,...t){const n=new URL("https://lexical.dev/docs/error"),o=new URLSearchParams;o.append("code",e);for(const e of t)o.append("v",e);throw n.search=o.toString(),Error(`Minified Lexical error #${e}; visit ${n.toString()} for the full message or use the non-minified dev environment for full errors and additional helpful warnings.`)}class g extends t.ElementNode{__height;static getType(){return"tablerow"}static clone(e){return new g(e.__height,e.__key)}static importDOM(){return{tr:e=>({conversion:f,priority:0})}}static importJSON(e){return m().updateFromJSON(e)}updateFromJSON(e){return super.updateFromJSON(e).setHeight(e.height)}constructor(e,t){super(t),this.__height=e}exportJSON(){const e=this.getHeight();return{...super.exportJSON(),...void 0===e?void 0:{height:e}}}createDOM(t){const n=document.createElement("tr");return this.__height&&(n.style.height=`${this.__height}px`),e.addClassNamesToElement(n,t.theme.tableRow),n}extractWithChild(e,t,n){return"html"===n}isShadowRoot(){return!0}setHeight(e){const t=this.getWritable();return t.__height=e,t}getHeight(){return this.getLatest().__height}updateDOM(e){return e.__height!==this.__height}canBeEmpty(){return!1}canIndent(){return!1}}function f(t){const n=t;let o;return r.test(n.style.height)&&(o=parseFloat(n.style.height)),{after:t=>e.$descendantsMatching(t,u),node:m(o)}}function m(e){return t.$applyNodeReplacement(new g(e))}function p(e){return e instanceof g}const C="undefined"!=typeof window&&void 0!==window.document&&void 0!==window.document.createElement,_=C&&"documentMode"in document?document.documentMode:null,S=C&&/^(?!.*Seamonkey)(?=.*Firefox).*/i.test(navigator.userAgent);function N(e,n,o=!0){const r=Le();for(let s=0;sp(e));if(p(n))return n;throw new Error("Expected table cell to be inside of table row.")}function b(t){const n=e.$findMatchingParent(t,e=>We(e));if(We(n))return n;throw new Error("Expected table cell to be inside of table.")}function T(e,t){const n=b(e),{x:o,y:r}=n.getCordsFromCellNode(e,t);return{above:n.getCellNodeFromCords(o,r-1,t),below:n.getCellNodeFromCords(o,r+1,t),left:n.getCellNodeFromCords(o-1,r,t),right:n.getCellNodeFromCords(o+1,r,t)}}C&&"InputEvent"in window&&!_&&new window.InputEvent("input");const y=(e,t)=>e===l.BOTH||e===t?t:l.NO_STATUS;function $(e=!0){const n=t.$getSelection();t.$isRangeSelection(n)||X(n)||h(188);const o=n.anchor.getNode(),r=n.focus.getNode(),[l]=B(o),[s,,i]=B(r),[,a,c]=L(i,s,l),{startRow:u}=c,{startRow:d}=a;return e?M(u+l.__rowSpan>d+s.__rowSpan?l:s,!0):M(dd+s.__colSpan?l:s,!0):O(d1;){if(s-=r.__colSpan,!(s>=0)){C.append(m(o));continue e}{const{cell:e,startRow:o}=t[s];n=e,l=o}}n.insertAfter(m(o))}else r.setColSpan(r.__colSpan+1)}null!==f&&o&&D(f);const _=r.getColWidths();if(_){const e=[..._],t=d<0?0:d,n=e[t];e.splice(t,0,n),r.setColWidths(e)}return f}function A(){const e=t.$getSelection();t.$isRangeSelection(e)||X(e)||h(188);const[n,o]=e.isBackward()?[e.focus.getNode(),e.anchor.getNode()]:[e.anchor.getNode(),e.focus.getNode()],[r,,l]=B(n),[s]=B(o),[i,a,c]=L(l,r,s),{startRow:u}=a,{startRow:d}=c,g=d+s.__rowSpan-1;if(i.length===g-u+1)return void l.remove();const f=i[0].length,m=i[g+1],C=l.getChildAtIndex(g+1);for(let e=g;e>=u;e--){for(let t=f-1;t>=0;t--){const{cell:n,startRow:o,startColumn:r}=i[e][t];if(r===t){if(og){const e=Math.max(o,u),t=Math.min(n.__rowSpan+o-1,g),r=e<=t?t-e+1:0;n.setRowSpan(n.__rowSpan-r)}if(o>=u&&o+n.__rowSpan-1>g&&e===g){null===C&&h(122);let o=null;for(let n=0;n1&&(n+=r.__colSpan-1)}null===o?K(C,n):o.insertAfter(n)}}}const t=l.getChildAtIndex(e);p(t)||h(206,String(e)),t.remove()}if(void 0!==m){const{cell:e}=m[0];D(e)}else{const e=i[u-1],{cell:t}=e[0];D(t)}}const v=A;function F(){const e=t.$getSelection();t.$isRangeSelection(e)||X(e)||h(188);const n=e.anchor.getNode(),o=e.focus.getNode(),[r,,l]=B(n),[s]=B(o),[i,a,c]=L(l,r,s),{startColumn:u}=a,{startRow:d,startColumn:g}=c,f=Math.min(u,g),m=Math.max(u+r.__colSpan-1,g+s.__colSpan-1),p=m-f+1;if(i[0].length===m-f+1)return l.selectPrevious(),void l.remove();const C=i.length;for(let e=0;em){if(t===m){const e=m-o+1;n.setColSpan(n.__colSpan-e)}}else n.remove()}const _=i[d],S=u>g?_[u+r.__colSpan]:_[g+s.__colSpan];if(void 0!==S){const{cell:e}=S;D(e)}else{const e=ge.is(n.cell))){a.add(t);const e=n.startRow,o=n.startColumn,c=n.cell.__rowSpan||1,u=n.cell.__colSpan||1;r=Math.min(r,e),l=Math.max(l,e+c-1),s=Math.min(s,o),i=Math.max(i,o+u-1)}}if(r===1/0||s===1/0)return null;const c=l-r+1,u=i-s+1,d=o[r][s];if(!d.cell)return null;const h=d.cell;h.setColSpan(u),h.setRowSpan(c);const g=new Set([h.getKey()]);for(let e=r;e<=l;e++)for(let t=s;t<=i;t++){const n=o[e][t];if(!n.cell)continue;const r=n.cell,l=r.getKey();if(!g.has(l)){g.add(l);k(r)||h.append(...r.getChildren()),r.remove()}}return 0===h.getChildrenSize()&&h.append(t.$createParagraphNode()),h}function k(e){if(1!==e.getChildrenSize())return!1;const n=e.getFirstChildOrThrow();return!(!t.$isParagraphNode(n)||!n.isEmpty())}function H(e){const[n,o,r]=B(e),s=n.__colSpan,i=n.__rowSpan;if(1===s&&1===i)return;const[a,u]=L(r,n,n),{startColumn:d,startRow:g}=u,f=n.__headerState&l.COLUMN,m=Array.from({length:s},(e,t)=>{let n=f;for(let e=0;0!==n&&e{let n=C;for(let e=0;0!==n&&e1){for(let e=1;e1){let e;for(let n=1;n1&&(e+=n.__colSpan-1)}if(null===i)for(let o=s-1;o>=0;o--)K(e,c(m[o]|_[n]).append(t.$createParagraphNode()));else for(let e=s-1;e>=0;e--)i.insertAfter(c(m[e]|_[n]).append(t.$createParagraphNode()))}n.setRowSpan(1)}}function L(e,t,n){const[o,r,l]=W(e,t,n);return null===r&&h(207),null===l&&h(208),[o,r,l]}function W(e,t,n){const o=[];let r=null,l=null;function s(e){let t=o[e];return void 0===t&&(o[e]=t=[]),t}const i=e.getChildren();for(let e=0;e=i.length);t++){const n=s(e+t);for(let e=0;e=r,h=a.startRow<=i&&u>=l;if(d&&h){const e=Math.min(r,a.startColumn),t=Math.max(s,c),n=Math.min(l,a.startRow),d=Math.max(i,u);e===r&&t===s&&n===l&&d===i||(r=e,s=t,l=n,i=d,o=!0)}}}while(o);return{maxColumn:s,maxRow:i,minColumn:r,minRow:l}}function Y(e){const[t,,n]=B(e),o=n.getChildren(),r=o.length,l=o[0].getChildren().length,s=new Array(r);for(let e=0;e{const o=t[n].getNode(),r=e.$findMatchingParent(o,u);u(r)||h(238,n,o.getKey(),o.getType());const l=r.getParent();p(l)||h(239,n);const s=l.getParent();return We(s)||h(240,n),[o,r,l,s]});return l.is(c)||h(241),{anchorCell:o,anchorNode:n,anchorRow:r,anchorTable:l,focusCell:i,focusNode:s,focusRow:a,focusTable:c}}class G{tableKey;anchor;focus;_cachedNodes;dirty;constructor(e,t,n){this.anchor=t,this.focus=n,t._selection=this,n._selection=this,this._cachedNodes=null,this.dirty=!1,this.tableKey=e}getStartEndPoints(){return[this.anchor,this.focus]}isValid(){if("root"===this.tableKey||"root"===this.anchor.key||"element"!==this.anchor.type||"root"===this.focus.key||"element"!==this.focus.type)return!1;const e=t.$getNodeByKey(this.tableKey),n=t.$getNodeByKey(this.anchor.key),o=t.$getNodeByKey(this.focus.key);return null!==e&&null!==n&&null!==o}isBackward(){return this.focus.isBefore(this.anchor)}getCachedNodes(){return this._cachedNodes}setCachedNodes(e){this._cachedNodes=e}is(e){return X(e)&&this.tableKey===e.tableKey&&this.anchor.is(e.anchor)&&this.focus.is(e.focus)}set(e,t,n){this.dirty=this.dirty||e!==this.tableKey||t!==this.anchor.key||n!==this.focus.key,this.tableKey=e,this.anchor.key=t,this.focus.key=n,this._cachedNodes=null}clone(){return new G(this.tableKey,t.$createPoint(this.anchor.key,this.anchor.offset,this.anchor.type),t.$createPoint(this.focus.key,this.focus.offset,this.focus.type))}isCollapsed(){return!1}extract(){return this.getNodes()}insertRawText(e){}insertText(){}hasFormat(e){let n=0;this.getNodes().filter(u).forEach(e=>{const o=e.getFirstChild();t.$isParagraphNode(o)&&(n|=o.getTextFormat())});const o=t.TEXT_TYPE_TO_FORMAT[e];return 0!==(n&o)}insertNodes(e){const n=this.focus.getNode();t.$isElementNode(n)||h(151);t.$normalizeSelection__EXPERIMENTAL(n.select(0,n.getChildrenSize())).insertNodes(e)}getShape(){const{anchorCell:e,focusCell:t}=U(this),n=Y(e);null===n&&h(153);const o=Y(t);null===o&&h(155);const r=Math.min(n.columnIndex,o.columnIndex),l=Math.max(n.columnIndex+n.colSpan-1,o.columnIndex+o.colSpan-1),s=Math.min(n.rowIndex,o.rowIndex),i=Math.max(n.rowIndex+n.rowSpan-1,o.rowIndex+o.rowSpan-1);return{fromX:Math.min(r,l),fromY:Math.min(s,i),toX:Math.max(r,l),toY:Math.max(s,i)}}getNodes(){if(!this.isValid())return[];const e=this._cachedNodes;if(null!==e)return e;const{anchorTable:n,anchorCell:o,focusCell:r}=U(this),l=r.getParents()[1];if(l!==n){if(n.isParentOf(r)){const e=l.getParent();null==e&&h(159),this.set(this.tableKey,r.getKey(),e.getKey())}else{const e=n.getParent();null==e&&h(158),this.set(this.tableKey,e.getKey(),r.getKey())}return this.getNodes()}const[s,i,a]=L(n,o,r),{minColumn:c,maxColumn:u,minRow:d,maxRow:g}=z(s,i,a),f=new Map([[n.getKey(),n]]);let m=null;for(let e=d;e<=g;e++)for(let t=c;t<=u;t++){const{cell:n}=s[e][t],o=n.getParent();p(o)||h(160),o!==m&&(f.set(o.getKey(),o),m=o),f.has(n.getKey())||j(n,e=>{f.set(e.getKey(),e)})}const C=Array.from(f.values());return t.isCurrentlyReadOnlyMode()||(this._cachedNodes=C),C}getTextContent(){const e=this.getNodes().filter(e=>u(e));let t="";for(let n=0;n0;e=o.at(-1)){const r=e.pop();void 0===r?o.pop():!1!==n(r)&&t.$isElementNode(r)&&o.push(r.getChildren())}}function V(e,n=t.$getEditor()){const o=t.$getNodeByKey(e);We(o)||h(231,e);const r=te(o,n.getElementByKey(e));return null===r&&h(232,e),{tableElement:r,tableNode:o}}class Q{focusX;focusY;listenersToRemove;table;isHighlightingCells;anchorX;anchorY;tableNodeKey;anchorCell;focusCell;anchorCellNodeKey;focusCellNodeKey;editor;tableSelection;hasHijackedSelectionStyles;isSelecting;pointerType;shouldCheckSelection;abortController;listenerOptions;nextFocus;constructor(e,t){this.isHighlightingCells=!1,this.anchorX=-1,this.anchorY=-1,this.focusX=-1,this.focusY=-1,this.listenersToRemove=new Set,this.tableNodeKey=t,this.editor=e,this.table={columns:0,domRows:[],rows:0},this.tableSelection=null,this.anchorCellNodeKey=null,this.focusCellNodeKey=null,this.anchorCell=null,this.focusCell=null,this.hasHijackedSelectionStyles=!1,this.isSelecting=!1,this.pointerType=null,this.shouldCheckSelection=!1,this.abortController=new AbortController,this.listenerOptions={signal:this.abortController.signal},this.nextFocus=null,this.trackTable()}getTable(){return this.table}removeListeners(){this.abortController.abort("removeListeners"),Array.from(this.listenersToRemove).forEach(e=>e()),this.listenersToRemove.clear()}$lookup(){return V(this.tableNodeKey,this.editor)}trackTable(){const e=new MutationObserver(e=>{this.editor.getEditorState().read(()=>{let t=!1;for(let n=0;n{const{tableNode:t,tableElement:n}=this.$lookup();this.table=de(t,n),e.observe(n,{attributes:!0,childList:!0,subtree:!0})},{editor:this.editor})}$clearHighlight(){const e=this.editor;this.isHighlightingCells=!1,this.anchorX=-1,this.anchorY=-1,this.focusX=-1,this.focusY=-1,this.tableSelection=null,this.anchorCellNodeKey=null,this.focusCellNodeKey=null,this.anchorCell=null,this.focusCell=null,this.hasHijackedSelectionStyles=!1,this.$enableHighlightStyle();const{tableNode:n,tableElement:o}=this.$lookup();he(e,de(n,o),null),null!==t.$getSelection()&&(t.$setSelection(null),e.dispatchCommand(t.SELECTION_CHANGE_COMMAND,void 0))}$enableHighlightStyle(){const t=this.editor,{tableElement:n}=this.$lookup();e.removeClassNamesFromElement(n,t._config.theme.tableSelection),n.classList.remove("disable-selection"),this.hasHijackedSelectionStyles=!1}$disableHighlightStyle(){const{tableElement:t}=this.$lookup();e.addClassNamesToElement(t,this.editor._config.theme.tableSelection),this.hasHijackedSelectionStyles=!0}$updateTableTableSelection(e){if(null!==e){e.tableKey!==this.tableNodeKey&&h(233,e.tableKey,this.tableNodeKey);const t=this.editor;this.tableSelection=e,this.isHighlightingCells=!0,this.$disableHighlightStyle(),this.updateDOMSelection(),he(t,this.table,this.tableSelection)}else this.$clearHighlight()}setShouldCheckSelection(){this.shouldCheckSelection=!0}getAndClearShouldCheckSelection(){return!!this.shouldCheckSelection&&(this.shouldCheckSelection=!1,!0)}setNextFocus(e){this.nextFocus=e}getAndClearNextFocus(){const{nextFocus:e}=this;return null!==e&&(this.nextFocus=null),e}updateDOMSelection(){if(null!==this.anchorCell&&null!==this.focusCell){const e=t.getDOMSelection(this.editor._window);e&&e.rangeCount>0&&e.removeAllRanges()}}$setFocusCellForSelection(e,n=!1){const o=this.editor,{tableNode:r}=this.$lookup(),l=e.x,s=e.y;if(this.focusCell=e,this.isHighlightingCells||this.anchorX===l&&this.anchorY===s&&!n){if(l===this.focusX&&s===this.focusY)return!1}else this.isHighlightingCells=!0,this.$disableHighlightStyle();if(this.focusX=l,this.focusY=s,this.isHighlightingCells){const n=ve(r,e.elem);if(null!=this.tableSelection&&null!=this.anchorCellNodeKey&&null!==n)return this.focusCellNodeKey=n.getKey(),this.tableSelection=q(r,this.$getAnchorTableCellOrThrow(),n),t.$setSelection(this.tableSelection),o.dispatchCommand(t.SELECTION_CHANGE_COMMAND,void 0),he(o,this.table,this.tableSelection),!0}return!1}$getAnchorTableCell(){return this.anchorCellNodeKey?t.$getNodeByKey(this.anchorCellNodeKey):null}$getAnchorTableCellOrThrow(){const e=this.$getAnchorTableCell();return null===e&&h(234),e}$getFocusTableCell(){return this.focusCellNodeKey?t.$getNodeByKey(this.focusCellNodeKey):null}$getFocusTableCellOrThrow(){const e=this.$getFocusTableCell();return null===e&&h(235),e}$setAnchorCellForSelection(e){this.isHighlightingCells=!1,this.anchorCell=e,this.anchorX=e.x,this.anchorY=e.y;const{tableNode:t}=this.$lookup(),n=ve(t,e.elem);if(null!==n){const e=n.getKey();this.tableSelection=null!=this.tableSelection?this.tableSelection.clone():J(),this.anchorCellNodeKey=e}}$formatCells(e){const n=t.$getSelection();X(n)||h(236);const o=t.$createRangeSelection(),r=o.anchor,l=o.focus,s=n.getNodes().filter(u);s.length>0||h(237);const i=s[0].getFirstChild(),a=t.$isParagraphNode(i)?i.getFormatFlags(e,null):null;s.forEach(t=>{r.set(t.getKey(),0,"element"),l.set(t.getKey(),t.getChildrenSize(),"element"),o.formatText(e,a)}),t.$setSelection(n),this.editor.dispatchCommand(t.SELECTION_CHANGE_COMMAND,void 0)}$clearText(){const{editor:e}=this,n=t.$getNodeByKey(this.tableNodeKey);if(!We(n))throw new Error("Expected TableNode.");const o=t.$getSelection();X(o)||h(253);const r=o.getNodes().filter(u),l=n.getFirstChild(),s=n.getLastChild();if(r.length>0&&null!==l&&null!==s&&p(l)&&p(s)&&r[0]===l.getFirstChild()&&r[r.length-1]===s.getLastChild()){n.selectPrevious();const o=n.getParent();return n.remove(),void(t.$isRootNode(o)&&o.isEmpty()&&e.dispatchCommand(t.INSERT_PARAGRAPH_COMMAND,void 0))}r.forEach(e=>{if(t.$isElementNode(e)){const n=t.$createParagraphNode(),o=t.$createTextNode();n.append(o),e.append(n),e.getChildren().forEach(e=>{e!==n&&e.remove()})}}),he(e,this.table,null),t.$setSelection(null),e.dispatchCommand(t.SELECTION_CHANGE_COMMAND,void 0)}}const Z="__lexicalTableSelection";function ee(e){return t.isHTMLElement(e)&&"TABLE"===e.nodeName}function te(e,t){if(!t)return t;const n=ee(t)?t:e.getDOMSlot(t).element;return"TABLE"!==n.nodeName&&h(245,t.nodeName),n}function ne(e){return e._window}function oe(e,t){for(let n=t,o=null;null!==n;n=n.getParent()){if(e.is(n))return o;u(n)&&(o=n)}return null}const re=[[t.KEY_ARROW_DOWN_COMMAND,"down"],[t.KEY_ARROW_UP_COMMAND,"up"],[t.KEY_ARROW_LEFT_COMMAND,"backward"],[t.KEY_ARROW_RIGHT_COMMAND,"forward"]],le=[t.DELETE_WORD_COMMAND,t.DELETE_LINE_COMMAND,t.DELETE_CHARACTER_COMMAND],se=[t.KEY_BACKSPACE_COMMAND,t.KEY_DELETE_COMMAND];function ie(n,r,l,s){const i=l.getRootElement(),a=ne(l);null!==i&&null!==a||h(246);const c=new Q(l,n.getKey()),d=te(n,r);!function(e,t){null!==ae(e)&&h(205);e[Z]=t}(d,c),c.listenersToRemove.add(()=>function(e,t){ae(e)===t&&delete e[Z]}(d,c));const g=e=>{if(c.pointerType=e.pointerType,0!==e.button||!t.isDOMNode(e.target)||!a)return;const o=ce(e.target);null!==o&&l.update(()=>{const r=t.$getPreviousSelection();if(S&&e.shiftKey&&Ne(r,n)&&(t.$isRangeSelection(r)||X(r))){const t=r.anchor.getNode(),l=oe(n,r.anchor.getNode());if(l)c.$setAnchorCellForSelection(Ae(c,l)),c.$setFocusCellForSelection(o),xe(e);else{(n.isBefore(t)?n.selectStart():n.selectEnd()).anchor.set(r.anchor.key,r.anchor.offset,r.anchor.type)}}else"touch"!==e.pointerType&&c.$setAnchorCellForSelection(o)}),(()=>{if(c.isSelecting)return;const e=()=>{c.isSelecting=!1,a.removeEventListener("pointerup",e),a.removeEventListener("pointermove",n)},n=o=>{if(1&~o.buttons&&c.isSelecting)return c.isSelecting=!1,a.removeEventListener("pointerup",e),void a.removeEventListener("pointermove",n);if(!t.isDOMNode(o.target))return;let r=null;const s=!(S||d.contains(o.target));if(s)r=ue(d,o.target);else for(const e of document.elementsFromPoint(o.clientX,o.clientY))if(r=ue(d,e),r)break;!r||null!==c.focusCell&&r.elem===c.focusCell.elem||(c.setNextFocus({focusCell:r,override:s}),l.dispatchCommand(t.SELECTION_CHANGE_COMMAND,void 0))};c.isSelecting=!0,a.addEventListener("pointerup",e,c.listenerOptions),a.addEventListener("pointermove",n,c.listenerOptions)})()};d.addEventListener("pointerdown",g,c.listenerOptions),c.listenersToRemove.add(()=>{d.removeEventListener("pointerdown",g)});const f=e=>{if(e.detail>=3&&t.isDOMNode(e.target)){null!==ce(e.target)&&e.preventDefault()}};d.addEventListener("mousedown",f,c.listenerOptions),c.listenersToRemove.add(()=>{d.removeEventListener("mousedown",f)});const m=e=>{const n=e.target;0===e.button&&t.isDOMNode(n)&&l.update(()=>{const e=t.$getSelection();X(e)&&e.tableKey===c.tableNodeKey&&i.contains(n)&&c.$clearHighlight()})};a.addEventListener("pointerdown",m,c.listenerOptions),c.listenersToRemove.add(()=>{a.removeEventListener("pointerdown",m)});for(const[e,o]of re)c.listenersToRemove.add(l.registerCommand(e,e=>Me(l,e,o,n,c),t.COMMAND_PRIORITY_HIGH));c.listenersToRemove.add(l.registerCommand(t.KEY_ESCAPE_COMMAND,e=>{const o=t.$getSelection();if(X(o)){const t=oe(n,o.focus.getNode());if(null!==t)return xe(e),t.selectEnd(),!0}return!1},t.COMMAND_PRIORITY_HIGH));const C=o=>()=>{const r=t.$getSelection();if(!Ne(r,n))return!1;if(X(r))return c.$clearText(),!0;if(t.$isRangeSelection(r)){if(!u(oe(n,r.anchor.getNode())))return!1;const l=r.anchor.getNode(),s=r.focus.getNode(),i=n.isParentOf(l),a=n.isParentOf(s);if(i&&!a||a&&!i)return c.$clearText(),!0;const d=e.$findMatchingParent(r.anchor.getNode(),e=>t.$isElementNode(e)),h=d&&e.$findMatchingParent(d,e=>t.$isElementNode(e)&&u(e.getParent()));if(!t.$isElementNode(h)||!t.$isElementNode(d))return!1;if(o===t.DELETE_LINE_COMMAND&&null===h.getPreviousSibling())return!0}return!1};for(const e of le)c.listenersToRemove.add(l.registerCommand(e,C(e),t.COMMAND_PRIORITY_HIGH));const _=e=>{const o=t.$getSelection();if(!X(o)&&!t.$isRangeSelection(o))return!1;const r=n.isParentOf(o.anchor.getNode());if(r!==n.isParentOf(o.focus.getNode())){const e=r?"anchor":"focus",t=r?"focus":"anchor",{key:l,offset:s,type:i}=o[t];return n[o[e].isBefore(o[t])?"selectPrevious":"selectNext"]()[t].set(l,s,i),!1}return!!Ne(o,n)&&(!!X(o)&&(e&&(e.preventDefault(),e.stopPropagation()),c.$clearText(),!0))};for(const e of se)c.listenersToRemove.add(l.registerCommand(e,_,t.COMMAND_PRIORITY_HIGH));return c.listenersToRemove.add(l.registerCommand(t.CUT_COMMAND,n=>{const r=t.$getSelection();if(r){if(!X(r)&&!t.$isRangeSelection(r))return!1;o.copyToClipboard(l,e.objectKlassEquals(n,ClipboardEvent)?n:null,o.$getClipboardDataFromSelection(r));const s=_(n);return t.$isRangeSelection(r)?(r.removeText(),!0):s}return!1},t.COMMAND_PRIORITY_HIGH)),c.listenersToRemove.add(l.registerCommand(t.FORMAT_TEXT_COMMAND,o=>{const r=t.$getSelection();if(!Ne(r,n))return!1;if(X(r))return c.$formatCells(o),!0;if(t.$isRangeSelection(r)){const t=e.$findMatchingParent(r.anchor.getNode(),e=>u(e));if(!u(t))return!1}return!1},t.COMMAND_PRIORITY_HIGH)),c.listenersToRemove.add(l.registerCommand(t.FORMAT_ELEMENT_COMMAND,e=>{const o=t.$getSelection();if(!X(o)||!Ne(o,n))return!1;const r=o.anchor.getNode(),l=o.focus.getNode();if(!u(r)||!u(l))return!1;if(function(e,t){if(X(e)){const n=e.anchor.getNode(),o=e.focus.getNode();if(t&&n&&o){const[e]=L(t,n,o);return n.getKey()===e[0][0].cell.getKey()&&o.getKey()===e[e.length-1].at(-1).cell.getKey()}}return!1}(o,n))return n.setFormat(e),!0;const[s,i,a]=L(n,r,l),c=Math.max(i.startRow+i.cell.__rowSpan-1,a.startRow+a.cell.__rowSpan-1),d=Math.max(i.startColumn+i.cell.__colSpan-1,a.startColumn+a.cell.__colSpan-1),h=Math.min(i.startRow,a.startRow),g=Math.min(i.startColumn,a.startColumn),f=new Set;for(let n=h;n<=c;n++)for(let o=g;o<=d;o++){const r=s[n][o].cell;if(f.has(r))continue;f.add(r),r.setFormat(e);const l=r.getChildren();for(let n=0;n{const r=t.$getSelection();if(!Ne(r,n))return!1;if(X(r))return c.$clearHighlight(),!1;if(t.$isRangeSelection(r)){const s=e.$findMatchingParent(r.anchor.getNode(),e=>u(e));if(!u(s))return!1;if("string"==typeof o){const e=Oe(l,r,n);if(e)return Ee(e,n,[t.$createTextNode(o)]),!0}}return!1},t.COMMAND_PRIORITY_HIGH)),s&&c.listenersToRemove.add(l.registerCommand(t.KEY_TAB_COMMAND,o=>{const r=t.$getSelection();if(!t.$isRangeSelection(r)||!r.isCollapsed()||!Ne(r,n))return!1;const l=ye(r.anchor.getNode());return!(null===l||!n.is($e(l)))&&(xe(o),function(n,o){const r="next"===o?"getNextSibling":"getPreviousSibling",l="next"===o?"getFirstChild":"getLastChild",s=n[r]();if(t.$isElementNode(s))return s.selectEnd();const i=e.$findMatchingParent(n,p);null===i&&h(247);for(let e=i[r]();p(e);e=e[r]()){const n=e[l]();if(t.$isElementNode(n))return n.selectEnd()}const a=e.$findMatchingParent(i,We);null===a&&h(248);"next"===o?a.selectNext():a.selectPrevious()}(l,o.shiftKey?"previous":"next"),!0)},t.COMMAND_PRIORITY_HIGH)),c.listenersToRemove.add(l.registerCommand(t.FOCUS_COMMAND,e=>n.isSelected(),t.COMMAND_PRIORITY_HIGH)),c.listenersToRemove.add(l.registerCommand(t.SELECTION_INSERT_CLIPBOARD_NODES_COMMAND,(n,o)=>{if(l!==o)return!1;const{nodes:r,selection:s}=n,i=s.getStartEndPoints(),a=X(s),c=t.$isRangeSelection(s)&&null!==e.$findMatchingParent(s.anchor.getNode(),e=>u(e))&&null!==e.$findMatchingParent(s.focus.getNode(),e=>u(e))||a;if(1!==r.length||!We(r[0])||!c||null===i)return!1;const[d,h]=i,[g,f,m]=B(d),C=e.$findMatchingParent(h.getNode(),e=>u(e));if(!(u(g)&&u(C)&&p(f)&&We(m)))return!1;const _=r[0],[S,N,w]=L(m,g,C),[b]=W(_,null,null),T=S.length,y=T>0?S[0].length:0;let $=N.startRow,R=N.startColumn,x=b.length,E=x>0?b[0].length:0;if(a){const e=z(S,N,w),t=e.maxRow-e.minRow+1,n=e.maxColumn-e.minColumn+1;$=e.minRow,R=e.minColumn,x=Math.min(x,t),E=Math.min(E,n)}let A=!1;const v=Math.min(T,$+x)-1,F=Math.min(y,R+E)-1,P=new Set;for(let e=$;e<=v;e++)for(let t=R;t<=F;t++){const n=S[e][t];P.has(n.cell.getKey())||(1===n.cell.__rowSpan&&1===n.cell.__colSpan||(H(n.cell),P.add(n.cell.getKey()),A=!0))}let[D]=W(m.getWritable(),null,null);const K=x-T+$;for(let e=0;e{if(t.$isTextNode(e)){t.$createParagraphNode().append(e),i.append(e)}else i.append(e)}),a.forEach(e=>e.remove())}if(a&&A){const[e]=W(m.getWritable(),null,null);e[N.startRow][N.startColumn].cell.selectEnd()}return!0},t.COMMAND_PRIORITY_HIGH)),c.listenersToRemove.add(l.registerCommand(t.SELECTION_CHANGE_COMMAND,()=>{const o=t.$getSelection(),r=t.$getPreviousSelection(),s=c.getAndClearNextFocus();if(null!==s){const{focusCell:e}=s;if(X(o)&&o.tableKey===c.tableNodeKey)return(e.x!==c.focusX||e.y!==c.focusY)&&(c.$setFocusCellForSelection(e),!0);if(e!==c.anchorCell&&Ne(o,n))return c.$setFocusCellForSelection(e),!0}if(c.getAndClearShouldCheckSelection()&&t.$isRangeSelection(r)&&t.$isRangeSelection(o)&&o.isCollapsed()){const t=o.anchor.getNode(),r=n.getFirstChild(),l=ye(t);if(null!==l&&p(r)){const t=r.getFirstChild();if(u(t)&&n.is(e.$findMatchingParent(l,e=>e.is(n)||e.is(t))))return t.selectStart(),!0}}if(t.$isRangeSelection(o)){const{anchor:e,focus:s}=o,i=e.getNode(),a=s.getNode(),u=ye(i),d=ye(a),h=!(!u||!n.is($e(u))),g=!(!d||!n.is($e(d))),f=h!==g,m=h&&g,p=o.isBackward();if(f){const e=o.clone();if(g){const[t]=L(n,d,d),o=t[0][0].cell,r=t[t.length-1].at(-1).cell;e.focus.set(p?o.getKey():r.getKey(),p?o.getChildrenSize():r.getChildrenSize(),"element")}else if(h){const[t]=L(n,u,u),o=t[0][0].cell,r=t[t.length-1].at(-1).cell;e.anchor.set(p?r.getKey():o.getKey(),p?r.getChildrenSize():0,"element")}t.$setSelection(e),fe(l,c)}else if(m&&(u.is(d)||(c.$setAnchorCellForSelection(Ae(c,u)),c.$setFocusCellForSelection(Ae(c,d),!0)),"touch"===c.pointerType&&c.isSelecting&&o.isCollapsed()&&t.$isRangeSelection(r)&&r.isCollapsed())){const e=ye(r.anchor.getNode());e&&!e.is(d)&&(c.$setAnchorCellForSelection(Ae(c,e)),c.$setFocusCellForSelection(Ae(c,d),!0),c.pointerType=null)}}else if(o&&X(o)&&o.is(r)&&o.tableKey===n.getKey()){const e=t.getDOMSelection(a);if(e&&e.anchorNode&&e.focusNode){const r=t.$getNearestNodeFromDOMNode(e.focusNode),s=r&&!n.isParentOf(r),i=t.$getNearestNodeFromDOMNode(e.anchorNode),a=i&&n.isParentOf(i);if(s&&a&&e.rangeCount>0){const r=t.$createRangeSelectionFromDom(e,l);r&&(r.anchor.set(n.getKey(),o.isBackward()?n.getChildrenSize():0,"element"),e.removeAllRanges(),t.$setSelection(r))}}}return o&&!o.is(r)&&(X(o)||X(r))&&c.tableSelection&&!c.tableSelection.is(r)?(X(o)&&o.tableKey===c.tableNodeKey?c.$updateTableTableSelection(o):!X(o)&&X(r)&&r.tableKey===c.tableNodeKey&&c.$updateTableTableSelection(null),!1):(c.hasHijackedSelectionStyles&&!n.isSelected()?function(e,t){t.$enableHighlightStyle(),ge(t.table,t=>{const n=t.elem;t.highlighted=!1,Te(e,t),n.getAttribute("style")||n.removeAttribute("style")})}(l,c):!c.hasHijackedSelectionStyles&&n.isSelected()&&fe(l,c),!1)},t.COMMAND_PRIORITY_HIGH)),c.listenersToRemove.add(l.registerCommand(t.INSERT_PARAGRAPH_COMMAND,()=>{const e=t.$getSelection();if(!t.$isRangeSelection(e)||!e.isCollapsed()||!Ne(e,n))return!1;const o=Oe(l,e,n);return!!o&&(Ee(o,n),!0)},t.COMMAND_PRIORITY_HIGH)),c}function ae(e){return e[Z]||null}function ce(e){let t=e;for(;null!=t;){const e=t.nodeName;if("TD"===e||"TH"===e){const e=t._cell;return void 0===e?null:e}t=t.parentNode}return null}function ue(e,t){if(!e.contains(t))return null;let n=null;for(let o=t;null!=o;o=o.parentNode){if(o===e)return n;const t=o.nodeName;"TD"!==t&&"TH"!==t||(n=o._cell||null)}return null}function de(e,t){const n=[],o={columns:0,domRows:n,rows:0};let r=te(e,t).querySelector("tr"),l=0,s=0;for(n.length=0;null!=r;){const e=r.nodeName;if("TD"===e||"TH"===e){const e={elem:r,hasBackgroundColor:""!==r.style.backgroundColor,highlighted:!1,x:l,y:s};r._cell=e;let t=n[s];void 0===t&&(t=n[s]=[]),t[l]=e}else{const e=r.firstChild;if(null!=e){r=e;continue}}const t=r.nextSibling;if(null!=t){l++,r=t;continue}const o=r.parentNode;if(null!=o){const e=o.nextSibling;if(null==e)break;s++,l=0,r=e}}return o.columns=l+1,o.rows=s+1,o}function he(e,t,n){const o=new Set(n?n.getNodes():[]);ge(t,(t,n)=>{const r=t.elem;o.has(n)?(t.highlighted=!0,be(e,t)):(t.highlighted=!1,Te(e,t),r.getAttribute("style")||r.removeAttribute("style"))})}function ge(e,n){const{domRows:o}=e;for(let e=0;e{t.highlighted=!0,be(e,t)})}const me=(e,t,n,o,r)=>{const l="forward"===r;switch(r){case"backward":case"forward":return n!==(l?e.table.columns-1:0)?we(t.getCellNodeFromCordsOrThrow(n+(l?1:-1),o,e.table),l):o!==(l?e.table.rows-1:0)?we(t.getCellNodeFromCordsOrThrow(l?0:e.table.columns-1,o+(l?1:-1),e.table),l):l?t.selectNext():t.selectPrevious(),!0;case"up":return 0!==o?we(t.getCellNodeFromCordsOrThrow(n,o-1,e.table),!1):t.selectPrevious(),!0;case"down":return o!==e.table.rows-1?we(t.getCellNodeFromCordsOrThrow(n,o+1,e.table),!0):t.selectNext(),!0;default:return!1}};function pe(e,t){let n,o;if(t.startColumn===e.minColumn)n="minColumn";else{if(t.startColumn+t.cell.__colSpan-1!==e.maxColumn)return null;n="maxColumn"}if(t.startRow===e.minRow)o="minRow";else{if(t.startRow+t.cell.__rowSpan-1!==e.maxRow)return null;o="maxRow"}return[n,o]}function Ce([e,t]){return["minColumn"===e?"maxColumn":"minColumn","minRow"===t?"maxRow":"minRow"]}function _e(e,t,[n,o]){const r=t[o],l=e[r];void 0===l&&h(250,o,String(r));const s=t[n],i=l[s];return void 0===i&&h(250,n,String(s)),i}function Se(e,t,n,o,r){const l=z(t,n,o),s=function(e,t){const{minColumn:n,maxColumn:o,minRow:r,maxRow:l}=t;let s=1,i=1,a=1,c=1;const u=e[r],d=e[l];for(let e=n;e<=o;e++)s=Math.max(s,u[e].cell.__rowSpan),c=Math.max(c,d[e].cell.__rowSpan);for(let t=r;t<=l;t++)i=Math.max(i,e[t][n].cell.__colSpan),a=Math.max(a,e[t][o].cell.__colSpan);return{bottomSpan:c,leftSpan:i,rightSpan:a,topSpan:s}}(t,l),{topSpan:i,leftSpan:a,bottomSpan:c,rightSpan:u}=s,d=function(e,t){const n=pe(e,t);return null===n&&h(249,t.cell.getKey()),n}(l,n),[g,f]=Ce(d);let m=l[g],p=l[f];"forward"===r?m+="maxColumn"===g?1:a:"backward"===r?m-="minColumn"===g?1:u:"down"===r?p+="maxRow"===f?1:i:"up"===r&&(p-="minRow"===f?1:c);const C=t[p];if(void 0===C)return!1;const _=C[m];if(void 0===_)return!1;const[S,N]=function(e,t,n){const o=z(e,t,n),r=pe(o,t);if(r)return[_e(e,o,r),_e(e,o,Ce(r))];const l=pe(o,n);if(l)return[_e(e,o,Ce(l)),_e(e,o,l)];const s=["minColumn","minRow"];return[_e(e,o,s),_e(e,o,Ce(s))]}(t,n,_),w=Ae(e,S.cell),b=Ae(e,N.cell);return e.$setAnchorCellForSelection(w),e.$setFocusCellForSelection(b,!0),!0}function Ne(e,n){if(t.$isRangeSelection(e)||X(e)){const t=n.isParentOf(e.anchor.getNode()),o=n.isParentOf(e.focus.getNode());return t&&o}return!1}function we(e,t){t?e.selectStart():e.selectEnd()}function be(n,o){const r=o.elem,l=n._config.theme;u(t.$getNearestNodeFromDOMNode(r))||h(131),e.addClassNamesToElement(r,l.tableCellSelected)}function Te(n,o){const r=o.elem;u(t.$getNearestNodeFromDOMNode(r))||h(131);const l=n._config.theme;e.removeClassNamesFromElement(r,l.tableCellSelected)}function ye(t){const n=e.$findMatchingParent(t,u);return u(n)?n:null}function $e(t){const n=e.$findMatchingParent(t,We);return We(n)?n:null}function Re(n,o,r,l,s,i,a){const c=t.$caretFromPoint(r.focus,s?"previous":"next");if(t.$isExtendableTextPointCaret(c))return!1;let d=c;for(const e of t.$extendCaretToRange(c).iterNodeCarets("shadowRoot")){if(!t.$isSiblingCaret(e)||!t.$isElementNode(e.origin))return!1;d=e}const h=d.getParentAtCaret();if(!u(h))return!1;const g=h,f=function(e){for(const n of t.$extendCaretToRange(e).iterNodeCarets("root")){const{origin:o}=n;if(u(o)){if(t.$isChildCaret(n))return t.$getChildCaret(o,e.direction)}else if(!p(o))break}return null}(t.$getSiblingCaret(g,d.direction)),m=e.$findMatchingParent(g,We);if(!m||!m.is(i))return!1;const C=n.getElementByKey(g.getKey()),_=ce(C);if(!C||!_)return!1;const S=ke(n,m);if(a.table=S,f)if("extend"===l){const e=ce(n.getElementByKey(f.origin.getKey()));if(!e)return!1;a.$setAnchorCellForSelection(_),a.$setFocusCellForSelection(e,!0)}else{const e=t.$normalizeCaret(f);t.$setPointFromCaret(r.anchor,e),t.$setPointFromCaret(r.focus,e)}else if("extend"===l)a.$setAnchorCellForSelection(_),a.$setFocusCellForSelection(_,!0);else{const e=function(e){const n=t.$getAdjacentChildCaret(e);return t.$isChildCaret(n)?t.$normalizeCaret(n):e}(t.$getSiblingCaret(m,c.direction));t.$setPointFromCaret(r.anchor,e),t.$setPointFromCaret(r.focus,e)}return xe(o),!0}function Me(n,o,r,l,s){if(("up"===r||"down"===r)&&function(e){const t=e.getRootElement();if(!t)return!1;return t.hasAttribute("aria-controls")&&"typeahead-menu"===t.getAttribute("aria-controls")}(n))return!1;const i=t.$getSelection();if(!Ne(i,l)){if(t.$isRangeSelection(i)){if("backward"===r){if(i.focus.offset>0)return!1;const e=function(e){for(let n=e,o=e;null!==o;n=o,o=o.getParent())if(t.$isElementNode(o)){if(o!==n&&o.getFirstChild()!==n)return null;if(!o.isInline())return o}return null}(i.focus.getNode());if(!e)return!1;const n=e.getPreviousSibling();return!!We(n)&&(xe(o),o.shiftKey?i.focus.set(n.getParentOrThrow().getKey(),n.getIndexWithinParent(),"element"):n.selectEnd(),!0)}if(o.shiftKey&&("up"===r||"down"===r)){const n=i.focus.getNode();if(!i.isCollapsed()&&("up"===r&&!i.isBackward()||"down"===r&&i.isBackward())){let s=e.$findMatchingParent(n,e=>We(e));if(u(s)&&(s=e.$findMatchingParent(s,We)),s!==l)return!1;if(!s)return!1;const a="down"===r?s.getNextSibling():s.getPreviousSibling();if(!a)return!1;let c=0;"up"===r&&t.$isElementNode(a)&&(c=a.getChildrenSize());let d=a;if("up"===r&&t.$isElementNode(a)){const e=a.getLastChild();d=e||a,c=t.$isTextNode(d)?d.getTextContentSize():0}const h=i.clone();return h.focus.set(d.getKey(),c,t.$isTextNode(d)?"text":"element"),t.$setSelection(h),xe(o),!0}if(t.$isRootOrShadowRoot(n)){const e="up"===r?i.getNodes()[i.getNodes().length-1]:i.getNodes()[0];if(e){if(null!==oe(l,e)){const e=l.getFirstDescendant(),t=l.getLastDescendant();if(!e||!t)return!1;const[n]=B(e),[o]=B(t),r=l.getCordsFromCellNode(n,s.table),i=l.getCordsFromCellNode(o,s.table),a=l.getDOMCellFromCordsOrThrow(r.x,r.y,s.table),c=l.getDOMCellFromCordsOrThrow(i.x,i.y,s.table);return s.$setAnchorCellForSelection(a),s.$setFocusCellForSelection(c,!0),!0}}return!1}{let l=e.$findMatchingParent(n,e=>t.$isElementNode(e)&&!e.isInline());if(u(l)&&(l=e.$findMatchingParent(l,We)),!l)return!1;const a="down"===r?l.getNextSibling():l.getPreviousSibling();if(We(a)&&s.tableNodeKey===a.getKey()){const e=a.getFirstDescendant(),n=a.getLastDescendant();if(!e||!n)return!1;const[l]=B(e),[s]=B(n),c=i.clone();return c.focus.set(("up"===r?l:s).getKey(),"up"===r?0:s.getChildrenSize(),"element"),xe(o),t.$setSelection(c),!0}}}}return"down"===r&&De(n)&&s.setShouldCheckSelection(),!1}if(t.$isRangeSelection(i)){if("backward"===r||"forward"===r){return Re(n,o,i,o.shiftKey?"extend":"move","backward"===r,l,s)}if(i.isCollapsed()){const{anchor:a,focus:c}=i,d=e.$findMatchingParent(a.getNode(),u),h=e.$findMatchingParent(c.getNode(),u);if(!u(d)||!d.is(h))return!1;const g=$e(d);if(g!==l&&null!=g){const e=te(g,n.getElementByKey(g.getKey()));if(null!=e)return s.table=de(g,e),Me(n,o,r,g,s)}const f=n.getElementByKey(d.__key),m=n.getElementByKey(a.key);if(null==m||null==f)return!1;let p;if("element"===a.type)p=m.getBoundingClientRect();else{const e=t.getDOMSelection(ne(n));if(null===e||0===e.rangeCount)return!1;p=e.getRangeAt(0).getBoundingClientRect()}const C="up"===r?d.getFirstChild():d.getLastChild();if(null==C)return!1;const _=n.getElementByKey(C.__key);if(null==_)return!1;const S=_.getBoundingClientRect();if("up"===r?S.top>p.top-p.height:p.bottom+p.height>S.bottom){xe(o);const e=l.getCordsFromCellNode(d,s.table);if(!o.shiftKey)return me(s,l,e.x,e.y,r);{const t=l.getDOMCellFromCordsOrThrow(e.x,e.y,s.table);s.$setAnchorCellForSelection(t),s.$setFocusCellForSelection(t,!0)}return!0}}}else if(X(i)){const{anchor:t,focus:a}=i,c=e.$findMatchingParent(t.getNode(),u),d=e.$findMatchingParent(a.getNode(),u),[g]=i.getNodes();We(g)||h(251);const f=te(g,n.getElementByKey(g.getKey()));if(!u(c)||!u(d)||!We(g)||null==f)return!1;s.$updateTableTableSelection(i);const m=de(g,f),p=l.getCordsFromCellNode(c,m),C=l.getDOMCellFromCordsOrThrow(p.x,p.y,m);if(s.$setAnchorCellForSelection(C),xe(o),o.shiftKey){const[e,t,n]=L(l,c,d);return Se(s,e,t,n,r)}return d.selectEnd(),!0}return!1}function xe(e){e.preventDefault(),e.stopImmediatePropagation(),e.stopPropagation()}function Ee(e,n,o){const r=t.$createParagraphNode();"first"===e?n.insertBefore(r):n.insertAfter(r),r.append(...o||[]),r.selectEnd()}function Oe(n,o,r){const l=r.getParent();if(!l)return;const s=t.getDOMSelection(ne(n));if(!s)return;const i=s.anchorNode,a=n.getElementByKey(l.getKey()),c=te(r,n.getElementByKey(r.getKey()));if(!i||!a||!c||!a.contains(i)||c.contains(i))return;const d=e.$findMatchingParent(o.anchor.getNode(),e=>u(e));if(!d)return;const h=e.$findMatchingParent(d,e=>We(e));if(!We(h)||!h.is(r))return;const[g,f]=L(r,d,d),m=g[0][0],p=g[g.length-1][g[0].length-1],{startRow:C,startColumn:_}=f,S=C===m.startRow&&_===m.startColumn,N=C===p.startRow&&_===p.startColumn;return S?"first":N?"last":void 0}function Ae(e,t){const{tableNode:n}=e.$lookup(),o=n.getCordsFromCellNode(t,e.table);return n.getDOMCellFromCordsOrThrow(o.x,o.y,e.table)}function ve(e,n,o){return oe(e,t.$getNearestNodeFromDOMNode(n,o))}function Fe(t,n,o){if(!n.theme.tableAlignment)return;const r=[],l=[];for(const e of["center","right"]){const t=n.theme.tableAlignment[e];t&&(e===o?l:r).push(t)}e.removeClassNamesFromElement(t,...r),e.addClassNamesToElement(t,...l)}const Pe=new WeakSet;function De(e=t.$getEditor()){return Pe.has(e)}function Ke(e,t){t?Pe.add(e):Pe.delete(e)}class Ie extends t.ElementNode{__rowStriping;__frozenColumnCount;__frozenRowCount;__colWidths;static getType(){return"table"}getColWidths(){return this.getLatest().__colWidths}setColWidths(e){const t=this.getWritable();return t.__colWidths=e,t}static clone(e){return new Ie(e.__key)}afterCloneFrom(e){super.afterCloneFrom(e),this.__colWidths=e.__colWidths,this.__rowStriping=e.__rowStriping,this.__frozenColumnCount=e.__frozenColumnCount,this.__frozenRowCount=e.__frozenRowCount}static importDOM(){return{table:e=>({conversion:He,priority:1})}}static importJSON(e){return Le().updateFromJSON(e)}updateFromJSON(e){return super.updateFromJSON(e).setRowStriping(e.rowStriping||!1).setFrozenColumns(e.frozenColumnCount||0).setFrozenRows(e.frozenRowCount||0).setColWidths(e.colWidths)}constructor(e){super(e),this.__rowStriping=!1,this.__frozenColumnCount=0,this.__frozenRowCount=0,this.__colWidths=void 0}exportJSON(){return{...super.exportJSON(),colWidths:this.getColWidths(),frozenColumnCount:this.__frozenColumnCount?this.__frozenColumnCount:void 0,frozenRowCount:this.__frozenRowCount?this.__frozenRowCount:void 0,rowStriping:this.__rowStriping?this.__rowStriping:void 0}}extractWithChild(e,t,n){return"html"===n}getDOMSlot(e){const t=ee(e)?e:e.querySelector("table");return ee(t)||h(229),super.getDOMSlot(e).withElement(t).withAfter(t.querySelector("colgroup"))}createDOM(n,o){const r=document.createElement("table");this.__style&&(r.style.cssText=this.__style);const l=document.createElement("colgroup");if(r.appendChild(l),t.setDOMUnmanaged(l),e.addClassNamesToElement(r,n.theme.table),this.updateTableElement(null,r,n),De(o)){const t=document.createElement("div"),o=n.theme.tableScrollableWrapper;return o?e.addClassNamesToElement(t,o):t.style.cssText="overflow-x: auto;",t.appendChild(r),this.updateTableWrapper(null,t,r,n),t}return r}updateTableWrapper(t,n,o,r){this.__frozenColumnCount!==(t?t.__frozenColumnCount:0)&&function(t,n,o,r){r>0?(e.addClassNamesToElement(t,o.theme.tableFrozenColumn),n.setAttribute("data-lexical-frozen-column","true")):(e.removeClassNamesFromElement(t,o.theme.tableFrozenColumn),n.removeAttribute("data-lexical-frozen-column"))}(n,o,r,this.__frozenColumnCount),this.__frozenRowCount!==(t?t.__frozenRowCount:0)&&function(t,n,o,r){r>0?(e.addClassNamesToElement(t,o.theme.tableFrozenRow),n.setAttribute("data-lexical-frozen-row","true")):(e.removeClassNamesFromElement(t,o.theme.tableFrozenRow),n.removeAttribute("data-lexical-frozen-row"))}(n,o,r,this.__frozenRowCount)}updateTableElement(t,n,o){this.__style!==(t?t.__style:"")&&(n.style.cssText=this.__style),this.__rowStriping!==(!!t&&t.__rowStriping)&&function(t,n,o){o?(e.addClassNamesToElement(t,n.theme.tableRowStriping),t.setAttribute("data-lexical-row-striping","true")):(e.removeClassNamesFromElement(t,n.theme.tableRowStriping),t.removeAttribute("data-lexical-row-striping"))}(n,o,this.__rowStriping),function(e,t,n,o){const r=e.querySelector("colgroup");if(!r)return;const l=[];for(let e=0;e{if(n.after&&(o=n.after(o)),!ee(o)&&e.isHTMLElement(o)&&(o=o.querySelector("table")),!ee(o))return null;Fe(o,t._config,this.getFormatType());const[r]=W(this,null,null),l=new Map;for(const e of r)for(const t of e){const e=t.cell.getKey();l.has(e)||l.set(e,{colSpan:t.cell.getColSpan(),startColumn:t.startColumn})}const s=new Set;for(const e of o.querySelectorAll(":scope > tr > [data-temporary-table-cell-lexical-key]")){const t=e.getAttribute("data-temporary-table-cell-lexical-key");if(t){const n=l.get(t);if(e.removeAttribute("data-temporary-table-cell-lexical-key"),n){l.delete(t);for(let e=0;e colgroup");if(i){const e=Array.from(o.querySelectorAll(":scope > colgroup > col")).filter((e,t)=>s.has(t));i.replaceChildren(...e)}const a=o.querySelectorAll(":scope > tr");if(a.length>0){const e=document.createElement("tbody");for(const t of a)e.appendChild(t);o.append(e)}return o},element:!ee(o)&&e.isHTMLElement(o)?o.querySelector("table"):o}}canBeEmpty(){return!1}isShadowRoot(){return!0}getCordsFromCellNode(e,t){const{rows:n,domRows:o}=t;for(let t=0;t{u(e)&&(t+=e.getColSpan())}),t}}function ke(e,t){const n=e.getElementByKey(t.getKey());return null===n&&h(230),de(t,n)}function He(t){const n=Le();t.hasAttribute("data-lexical-row-striping")&&n.setRowStriping(!0),t.hasAttribute("data-lexical-frozen-column")&&n.setFrozenColumns(1),t.hasAttribute("data-lexical-frozen-row")&&n.setFrozenRows(1);const o=t.querySelector(":scope > colgroup");if(o){let e=[];for(const t of o.querySelectorAll(":scope > col")){let n=t.style.width||"";if(!r.test(n)&&(n=t.getAttribute("width")||"",!/^\d+$/.test(n))){e=void 0;break}e.push(parseFloat(n))}e&&n.setColWidths(e)}return{after:t=>e.$descendantsMatching(t,p),node:n}}function Le(){return t.$applyNodeReplacement(new Ie)}function We(e){return e instanceof Ie}function Be({rows:n,columns:o,includeHeaders:r}){const l=t.$getSelection()||t.$getPreviousSelection();if(!l||!t.$isRangeSelection(l))return!1;if($e(l.anchor.getNode()))return!1;const s=N(Number(n),Number(o),r);e.$insertNodeToNearestRoot(s);const i=s.getFirstDescendant();return t.$isTextNode(i)&&i.select(),!0}function ze(e){p(e.getParent())?e.isEmpty()&&e.append(t.$createParagraphNode()):e.remove()}function Ye(t){We(t.getParent())?e.$unwrapAndFilterDescendants(t,u):t.remove()}function Ue(n){e.$unwrapAndFilterDescendants(n,p);const[o]=W(n,null,null),r=o.reduce((e,t)=>Math.max(e,t.length),0),l=n.getChildren();for(let e=0;et?1+e:e,0);if(s!==r)for(let e=s;et.$isElementNode(e)&&!e.isInline());if(null===r)return!1;return!!u(r.getParent())&&(r.select(0),!0)}function Xe(t){return t.registerNodeTransform(s,t=>{if(t.getColSpan()>1||t.getRowSpan()>1){const[,,n]=B(t),[o]=L(n,t,t),r=o.length,l=o[0].length;let s=n.getFirstChild();p(s)||h(175);const i=[];for(let t=0;t1||a.getRowSpan()>1){u(a)||h(176);const t=c(a.__headerState);null!==n?n.insertAfter(t):e.$insertFirst(s,t)}}}for(const e of i)e.setColSpan(1),e.setRowSpan(1)}})}function Je(e,t=!0){const n=new Map,o=(o,r,l)=>{const s=te(o,l),i=ie(o,s,e,t);n.set(r,[i,s])},r=e.registerMutationListener(Ie,t=>{e.getEditorState().read(()=>{for(const[e,r]of t){const t=n.get(e);if("created"===r||"updated"===r){const{tableNode:r,tableElement:l}=V(e);void 0===t?o(r,e,l):l!==t[1]&&(t[0].removeListeners(),n.delete(e),o(r,e,l))}else"destroyed"===r&&void 0!==t&&(t[0].removeListeners(),n.delete(e))}},{editor:e})},{skipInitialization:!1});return()=>{r();for(const[,[e]]of n)e.removeListeners()}}function qe(n){return n.hasNodes([Ie])||h(255),e.mergeRegister(n.registerCommand(d,Be,t.COMMAND_PRIORITY_EDITOR),n.registerCommand(t.SELECTION_INSERT_CLIPBOARD_NODES_COMMAND,({nodes:e,selection:o},r)=>{if(n!==r||!t.$isRangeSelection(o))return!1;return null!==$e(o.anchor.getNode())&&e.some(We)},t.COMMAND_PRIORITY_EDITOR),n.registerCommand(t.CLICK_COMMAND,Ge,t.COMMAND_PRIORITY_EDITOR),n.registerNodeTransform(Ie,Ue),n.registerNodeTransform(g,Ye),n.registerNodeTransform(s,ze))}const je=t.defineExtension({build:(e,t,o)=>n.namedSignals(t),config:t.safeCast({hasCellBackgroundColor:!0,hasCellMerge:!0,hasHorizontalScroll:!0,hasTabHandler:!0}),name:"@lexical/table/Table",nodes:[Ie,g,s],register(t,o,r){const l=r.getOutput();return e.mergeRegister(n.effect(()=>{const e=l.hasHorizontalScroll.value;De(t)!==e&&(Ke(t,e),t.registerNodeTransform(Ie,()=>{})())}),qe(t),n.effect(()=>Je(t,l.hasTabHandler.value)),n.effect(()=>l.hasCellMerge.value?void 0:Xe(t)),n.effect(()=>l.hasCellBackgroundColor.value?void 0:t.registerNodeTransform(s,e=>{null!==e.getBackgroundColor()&&e.setBackgroundColor(null)})))}});exports.$computeTableMap=L,exports.$computeTableMapSkipCellCheck=W,exports.$createTableCellNode=c,exports.$createTableNode=Le,exports.$createTableNodeWithDimensions=N,exports.$createTableRowNode=m,exports.$createTableSelection=J,exports.$createTableSelectionFrom=q,exports.$deleteTableColumn=function(e,t){const n=e.getChildren();for(let e=0;e=e.length||t<0)throw new Error("Table column target index out of range");e[t].remove()}}return e},exports.$deleteTableColumnAtSelection=F,exports.$deleteTableColumn__EXPERIMENTAL=P,exports.$deleteTableRowAtSelection=A,exports.$deleteTableRow__EXPERIMENTAL=v,exports.$findCellNode=ye,exports.$findTableNode=$e,exports.$getElementForTableNode=ke,exports.$getNodeTriplet=B,exports.$getTableAndElementByKey=V,exports.$getTableCellNodeFromLexicalNode=function(t){const n=e.$findMatchingParent(t,e=>u(e));return u(n)?n:null},exports.$getTableCellNodeRect=Y,exports.$getTableColumnIndexFromTableCellNode=function(e){return w(e).getChildren().findIndex(t=>t.is(e))},exports.$getTableNodeFromLexicalNodeOrThrow=b,exports.$getTableRowIndexFromTableCellNode=function(e){const t=w(e);return b(t).getChildren().findIndex(e=>e.is(t))},exports.$getTableRowNodeFromTableCellNodeOrThrow=w,exports.$insertTableColumn=function(e,n,o=!0,r,s){const i=e.getChildren(),a=[];for(let e=0;e=e.length||n<0)throw new Error("Table column target index out of range");const r=e[n];u(r)||h(12);const{left:i,right:d}=T(r,s);let g=l.NO_STATUS;(i&&i.hasHeaderState(l.ROW)||d&&d.hasHeaderState(l.ROW))&&(g|=l.ROW);const f=c(g);f.append(t.$createParagraphNode()),a.push({newTableCell:f,targetCell:r})}}return a.forEach(({newTableCell:e,targetCell:t})=>{o?t.insertAfter(e):t.insertBefore(e)}),e},exports.$insertTableColumnAtSelection=x,exports.$insertTableColumn__EXPERIMENTAL=E,exports.$insertTableRow=function(e,n,o=!0,r,s){const i=e.getChildren();if(n>=i.length||n<0)throw new Error("Table row target index out of range");const a=i[n];if(!p(a))throw new Error("Row before insertion index does not exist.");for(let e=0;e=n.length||t<0)throw new Error("Expected table cell to be inside of table row.");return n[t].remove(),e},exports.$unmergeCell=function(){const n=t.$getSelection();t.$isRangeSelection(n)||X(n)||h(188);const o=n.anchor.getNode(),r=e.$findMatchingParent(o,u);return u(r)||h(148),H(r)},exports.INSERT_TABLE_COMMAND=d,exports.TableCellHeaderStates=l,exports.TableCellNode=s,exports.TableExtension=je,exports.TableNode=Ie,exports.TableObserver=Q,exports.TableRowNode=g,exports.applyTableHandlers=ie,exports.getDOMCellFromTarget=ce,exports.getTableElement=te,exports.getTableObserverFromTableElement=ae,exports.registerTableCellUnmergeTransform=Xe,exports.registerTablePlugin=qe,exports.registerTableSelectionObserver=Je,exports.setScrollableTablesActive=Ke; ++"use strict";var e=require("@lexical/utils"),t=require("lexical"),n=require("@lexical/extension"),o=require("@lexical/clipboard");const r=/^(\d+(?:\.\d+)?)px$/,l={BOTH:3,COLUMN:2,NO_STATUS:0,ROW:1};class s extends t.ElementNode{__colSpan;__rowSpan;__headerState;__width;__backgroundColor;__verticalAlign;static getType(){return"tablecell"}static clone(e){return new s(e.__headerState,e.__colSpan,e.__width,e.__key)}afterCloneFrom(e){super.afterCloneFrom(e),this.__rowSpan=e.__rowSpan,this.__backgroundColor=e.__backgroundColor,this.__verticalAlign=e.__verticalAlign}static importDOM(){return{td:e=>({conversion:a,priority:0}),th:e=>({conversion:a,priority:0})}}static importJSON(e){return c().updateFromJSON(e)}updateFromJSON(e){return super.updateFromJSON(e).setHeaderStyles(e.headerState).setColSpan(e.colSpan||1).setRowSpan(e.rowSpan||1).setWidth(e.width||void 0).setBackgroundColor(e.backgroundColor||null).setVerticalAlign(e.verticalAlign||void 0)}constructor(e=l.NO_STATUS,t=1,n,o){super(o),this.__colSpan=t,this.__rowSpan=1,this.__headerState=e,this.__width=n,this.__backgroundColor=null,this.__verticalAlign=void 0}createDOM(t){const n=document.createElement(this.getTag());return this.__width&&(n.style.width=`${this.__width}px`),this.__colSpan>1&&(n.colSpan=this.__colSpan),this.__rowSpan>1&&(n.rowSpan=this.__rowSpan),null!==this.__backgroundColor&&(n.style.backgroundColor=this.__backgroundColor),i(this.__verticalAlign)&&(n.style.verticalAlign=this.__verticalAlign),e.addClassNamesToElement(n,t.theme.tableCell,this.hasHeader()&&t.theme.tableCellHeader),n}exportDOM(e){const n=super.exportDOM(e);if(t.isHTMLElement(n.element)){const e=n.element;e.setAttribute("data-temporary-table-cell-lexical-key",this.getKey()),e.style.border="1px solid black",this.__colSpan>1&&(e.colSpan=this.__colSpan),this.__rowSpan>1&&(e.rowSpan=this.__rowSpan),e.style.width=`${this.getWidth()||75}px`,e.style.verticalAlign=this.getVerticalAlign()||"top",e.style.textAlign="start",null===this.__backgroundColor&&this.hasHeader()&&(e.style.backgroundColor="#f2f3f5")}return n}exportJSON(){return{...super.exportJSON(),...i(this.__verticalAlign)&&{verticalAlign:this.__verticalAlign},backgroundColor:this.getBackgroundColor(),colSpan:this.__colSpan,headerState:this.__headerState,rowSpan:this.__rowSpan,width:this.getWidth()}}getColSpan(){return this.getLatest().__colSpan}setColSpan(e){const t=this.getWritable();return t.__colSpan=e,t}getRowSpan(){return this.getLatest().__rowSpan}setRowSpan(e){const t=this.getWritable();return t.__rowSpan=e,t}getTag(){return this.hasHeader()?"th":"td"}setHeaderStyles(e,t=l.BOTH){const n=this.getWritable();return n.__headerState=e&t|n.__headerState&~t,n}getHeaderStyles(){return this.getLatest().__headerState}setWidth(e){const t=this.getWritable();return t.__width=e,t}getWidth(){return this.getLatest().__width}getBackgroundColor(){return this.getLatest().__backgroundColor}setBackgroundColor(e){const t=this.getWritable();return t.__backgroundColor=e,t}getVerticalAlign(){return this.getLatest().__verticalAlign}setVerticalAlign(e){const t=this.getWritable();return t.__verticalAlign=e||void 0,t}toggleHeaderStyle(e){const t=this.getWritable();return(t.__headerState&e)===e?t.__headerState-=e:t.__headerState+=e,t}hasHeaderState(e){return(this.getHeaderStyles()&e)===e}hasHeader(){return this.getLatest().__headerState!==l.NO_STATUS}updateDOM(e){return e.__headerState!==this.__headerState||e.__width!==this.__width||e.__colSpan!==this.__colSpan||e.__rowSpan!==this.__rowSpan||e.__backgroundColor!==this.__backgroundColor||e.__verticalAlign!==this.__verticalAlign}isShadowRoot(){return!0}collapseAtStart(){return!0}canBeEmpty(){return!1}canIndent(){return!1}}function i(e){return"middle"===e||"bottom"===e}function a(e){const n=e,o=e.nodeName.toLowerCase();let s;r.test(n.style.width)&&(s=parseFloat(n.style.width));const a=c("th"===o?l.ROW:l.NO_STATUS,n.colSpan,s);a.__rowSpan=n.rowSpan;const u=n.style.backgroundColor;""!==u&&(a.__backgroundColor=u);const d=n.style.verticalAlign;i(d)&&(a.__verticalAlign=d);const h=n.style,g=(h&&h.textDecoration||"").split(" "),f="700"===h.fontWeight||"bold"===h.fontWeight,m=g.includes("line-through"),C="italic"===h.fontStyle,p=g.includes("underline");return{after:e=>{const n=[];let o=null;const r=()=>{if(o){const e=o.getFirstChild();t.$isLineBreakNode(e)&&1===o.getChildrenSize()&&e.remove()}};for(const l of e)t.$isInlineElementOrDecoratorNode(l)||t.$isTextNode(l)||t.$isLineBreakNode(l)?(t.$isTextNode(l)&&(f&&l.toggleFormat("bold"),m&&l.toggleFormat("strikethrough"),C&&l.toggleFormat("italic"),p&&l.toggleFormat("underline")),o?o.append(l):(o=t.$createParagraphNode().append(l),n.push(o))):(n.push(l),r(),o=null);return r(),0===n.length&&n.push(t.$createParagraphNode()),n},node:a}}function c(e=l.NO_STATUS,n=1,o){return t.$applyNodeReplacement(new s(e,n,o))}function u(e){return e instanceof s}const d=t.createCommand("INSERT_TABLE_COMMAND");function h(e,...t){const n=new URL("https://lexical.dev/docs/error"),o=new URLSearchParams;o.append("code",e);for(const e of t)o.append("v",e);throw n.search=o.toString(),Error(`Minified Lexical error #${e}; visit ${n.toString()} for the full message or use the non-minified dev environment for full errors and additional helpful warnings.`)}class g extends t.ElementNode{__height;static getType(){return"tablerow"}static clone(e){return new g(e.__height,e.__key)}static importDOM(){return{tr:e=>({conversion:f,priority:0})}}static importJSON(e){return m().updateFromJSON(e)}updateFromJSON(e){return super.updateFromJSON(e).setHeight(e.height)}constructor(e,t){super(t),this.__height=e}exportJSON(){const e=this.getHeight();return{...super.exportJSON(),...void 0===e?void 0:{height:e}}}createDOM(t){const n=document.createElement("tr");return this.__height&&(n.style.height=`${this.__height}px`),e.addClassNamesToElement(n,t.theme.tableRow),n}extractWithChild(e,t,n){return"html"===n}isShadowRoot(){return!0}setHeight(e){const t=this.getWritable();return t.__height=e,t}getHeight(){return this.getLatest().__height}updateDOM(e){return e.__height!==this.__height}canBeEmpty(){return!1}canIndent(){return!1}}function f(t){const n=t;let o;return r.test(n.style.height)&&(o=parseFloat(n.style.height)),{after:t=>e.$descendantsMatching(t,u),node:m(o)}}function m(e){return t.$applyNodeReplacement(new g(e))}function C(e){return e instanceof g}const p="undefined"!=typeof window&&void 0!==window.document&&void 0!==window.document.createElement,_=p&&"documentMode"in document?document.documentMode:null,S=p&&/^(?!.*Seamonkey)(?=.*Firefox).*/i.test(navigator.userAgent);function N(e,n,o=!0){const r=He();for(let s=0;sC(e));if(C(n))return n;throw new Error("Expected table cell to be inside of table row.")}function w(t){const n=e.$findMatchingParent(t,e=>Le(e));if(Le(n))return n;throw new Error("Expected table cell to be inside of table.")}function T(e,t){const n=w(e),{x:o,y:r}=n.getCordsFromCellNode(e,t);return{above:n.getCellNodeFromCords(o,r-1,t),below:n.getCellNodeFromCords(o,r+1,t),left:n.getCellNodeFromCords(o-1,r,t),right:n.getCellNodeFromCords(o+1,r,t)}}p&&"InputEvent"in window&&!_&&new window.InputEvent("input");const y=(e,t)=>e===l.BOTH||e===t?t:l.NO_STATUS;function $(e=!0){const n=t.$getSelection();t.$isRangeSelection(n)||X(n)||h(188);const o=n.anchor.getNode(),r=n.focus.getNode(),[l]=B(o),[s,,i]=B(r),[,a,c]=L(i,s,l),{startRow:u}=c,{startRow:d}=a;return e?M(u+l.__rowSpan>d+s.__rowSpan?l:s,!0):M(dd+s.__colSpan?l:s,!0):O(d1;){if(s-=r.__colSpan,!(s>=0)){p.append(m(o));continue e}{const{cell:e,startRow:o}=t[s];n=e,l=o}}n.insertAfter(m(o))}else r.setColSpan(r.__colSpan+1)}null!==f&&o&&D(f);const _=r.getColWidths();if(_){const e=[..._],t=d<0?0:d,n=e[t];e.splice(t,0,n),r.setColWidths(e)}return f}function A(){const e=t.$getSelection();t.$isRangeSelection(e)||X(e)||h(188);const[n,o]=e.isBackward()?[e.focus.getNode(),e.anchor.getNode()]:[e.anchor.getNode(),e.focus.getNode()],[r,,l]=B(n),[s]=B(o),[i,a,c]=L(l,r,s),{startRow:u}=a,{startRow:d}=c,g=d+s.__rowSpan-1;if(i.length===g-u+1)return void l.remove();const f=i[0].length,m=i[g+1],p=l.getChildAtIndex(g+1);for(let e=g;e>=u;e--){for(let t=f-1;t>=0;t--){const{cell:n,startRow:o,startColumn:r}=i[e][t];if(r===t){if(og){const e=Math.max(o,u),t=Math.min(n.__rowSpan+o-1,g),r=e<=t?t-e+1:0;n.setRowSpan(n.__rowSpan-r)}if(o>=u&&o+n.__rowSpan-1>g&&e===g){null===p&&h(122);let o=null;for(let n=0;n1&&(n+=r.__colSpan-1)}null===o?K(p,n):o.insertAfter(n)}}}const t=l.getChildAtIndex(e);C(t)||h(206,String(e)),t.remove()}if(void 0!==m){const{cell:e}=m[0];D(e)}else{const e=i[u-1],{cell:t}=e[0];D(t)}}const v=A;function F(){const e=t.$getSelection();t.$isRangeSelection(e)||X(e)||h(188);const n=e.anchor.getNode(),o=e.focus.getNode(),[r,,l]=B(n),[s]=B(o),[i,a,c]=L(l,r,s),{startColumn:u}=a,{startRow:d,startColumn:g}=c,f=Math.min(u,g),m=Math.max(u+r.__colSpan-1,g+s.__colSpan-1),C=m-f+1;if(i[0].length===m-f+1)return l.selectPrevious(),void l.remove();const p=i.length;for(let e=0;em){if(t===m){const e=m-o+1;n.setColSpan(n.__colSpan-e)}}else n.remove()}const _=i[d],S=u>g?_[u+r.__colSpan]:_[g+s.__colSpan];if(void 0!==S){const{cell:e}=S;D(e)}else{const e=ge.is(n.cell))){a.add(t);const e=n.startRow,o=n.startColumn,c=n.cell.__rowSpan||1,u=n.cell.__colSpan||1;r=Math.min(r,e),l=Math.max(l,e+c-1),s=Math.min(s,o),i=Math.max(i,o+u-1)}}if(r===1/0||s===1/0)return null;const c=l-r+1,u=i-s+1,d=o[r][s];if(!d.cell)return null;const h=d.cell;h.setColSpan(u),h.setRowSpan(c);const g=new Set([h.getKey()]);for(let e=r;e<=l;e++)for(let t=s;t<=i;t++){const n=o[e][t];if(!n.cell)continue;const r=n.cell,l=r.getKey();if(!g.has(l)){g.add(l);k(r)||h.append(...r.getChildren()),r.remove()}}return 0===h.getChildrenSize()&&h.append(t.$createParagraphNode()),h}function k(e){if(1!==e.getChildrenSize())return!1;const n=e.getFirstChildOrThrow();return!(!t.$isParagraphNode(n)||!n.isEmpty())}function H(e){const[n,o,r]=B(e),s=n.__colSpan,i=n.__rowSpan;if(1===s&&1===i)return;const[a,u]=L(r,n,n),{startColumn:d,startRow:g}=u,f=n.__headerState&l.COLUMN,m=Array.from({length:s},(e,t)=>{let n=f;for(let e=0;0!==n&&e{let n=p;for(let e=0;0!==n&&e1){for(let e=1;e1){let e;for(let n=1;n1&&(e+=n.__colSpan-1)}if(null===i)for(let o=s-1;o>=0;o--)K(e,c(m[o]|_[n]).append(t.$createParagraphNode()));else for(let e=s-1;e>=0;e--)i.insertAfter(c(m[e]|_[n]).append(t.$createParagraphNode()))}n.setRowSpan(1)}}function L(e,t,n){const[o,r,l]=W(e,t,n);return null===r&&h(207),null===l&&h(208),[o,r,l]}function W(e,t,n){const o=[];let r=null,l=null;function s(e){let t=o[e];return void 0===t&&(o[e]=t=[]),t}const i=e.getChildren();for(let e=0;e=i.length);t++){const n=s(e+t);for(let e=0;e=r,h=a.startRow<=i&&u>=l;if(d&&h){const e=Math.min(r,a.startColumn),t=Math.max(s,c),n=Math.min(l,a.startRow),d=Math.max(i,u);e===r&&t===s&&n===l&&d===i||(r=e,s=t,l=n,i=d,o=!0)}}}while(o);return{maxColumn:s,maxRow:i,minColumn:r,minRow:l}}function Y(e){const[t,,n]=B(e),o=n.getChildren(),r=o.length,l=o[0].getChildren().length,s=new Array(r);for(let e=0;e{const o=t[n].getNode(),r=e.$findMatchingParent(o,u);u(r)||h(238,n,o.getKey(),o.getType());const l=r.getParent();C(l)||h(239,n);const s=l.getParent();return Le(s)||h(240,n),[o,r,l,s]});return l.is(c)||h(241),{anchorCell:o,anchorNode:n,anchorRow:r,anchorTable:l,focusCell:i,focusNode:s,focusRow:a,focusTable:c}}class G{tableKey;anchor;focus;_cachedNodes;dirty;constructor(e,t,n){this.anchor=t,this.focus=n,t._selection=this,n._selection=this,this._cachedNodes=null,this.dirty=!1,this.tableKey=e}getStartEndPoints(){return[this.anchor,this.focus]}isValid(){if("root"===this.tableKey||"root"===this.anchor.key||"element"!==this.anchor.type||"root"===this.focus.key||"element"!==this.focus.type)return!1;const e=t.$getNodeByKey(this.tableKey),n=t.$getNodeByKey(this.anchor.key),o=t.$getNodeByKey(this.focus.key);return null!==e&&null!==n&&null!==o}isBackward(){return this.focus.isBefore(this.anchor)}getCachedNodes(){return this._cachedNodes}setCachedNodes(e){this._cachedNodes=e}is(e){return X(e)&&this.tableKey===e.tableKey&&this.anchor.is(e.anchor)&&this.focus.is(e.focus)}set(e,t,n){this.dirty=this.dirty||e!==this.tableKey||t!==this.anchor.key||n!==this.focus.key,this.tableKey=e,this.anchor.key=t,this.focus.key=n,this._cachedNodes=null}clone(){return new G(this.tableKey,t.$createPoint(this.anchor.key,this.anchor.offset,this.anchor.type),t.$createPoint(this.focus.key,this.focus.offset,this.focus.type))}isCollapsed(){return!1}extract(){return this.getNodes()}insertRawText(e){}insertText(){}hasFormat(e){let n=0;this.getNodes().filter(u).forEach(e=>{const o=e.getFirstChild();t.$isParagraphNode(o)&&(n|=o.getTextFormat())});const o=t.TEXT_TYPE_TO_FORMAT[e];return 0!==(n&o)}insertNodes(e){const n=this.focus.getNode();t.$isElementNode(n)||h(151);t.$normalizeSelection__EXPERIMENTAL(n.select(0,n.getChildrenSize())).insertNodes(e)}getShape(){const{anchorCell:e,focusCell:t}=U(this),n=Y(e);null===n&&h(153);const o=Y(t);null===o&&h(155);const r=Math.min(n.columnIndex,o.columnIndex),l=Math.max(n.columnIndex+n.colSpan-1,o.columnIndex+o.colSpan-1),s=Math.min(n.rowIndex,o.rowIndex),i=Math.max(n.rowIndex+n.rowSpan-1,o.rowIndex+o.rowSpan-1);return{fromX:Math.min(r,l),fromY:Math.min(s,i),toX:Math.max(r,l),toY:Math.max(s,i)}}getNodes(){if(!this.isValid())return[];const e=this._cachedNodes;if(null!==e)return e;const{anchorTable:n,anchorCell:o,focusCell:r}=U(this),l=r.getParents()[1];if(l!==n){if(n.isParentOf(r)){const e=l.getParent();null==e&&h(159),this.set(this.tableKey,r.getKey(),e.getKey())}else{const e=n.getParent();null==e&&h(158),this.set(this.tableKey,e.getKey(),r.getKey())}return this.getNodes()}const[s,i,a]=L(n,o,r),{minColumn:c,maxColumn:u,minRow:d,maxRow:g}=z(s,i,a),f=new Map([[n.getKey(),n]]);let m=null;for(let e=d;e<=g;e++)for(let t=c;t<=u;t++){const{cell:n}=s[e][t],o=n.getParent();C(o)||h(160),o!==m&&(f.set(o.getKey(),o),m=o),f.has(n.getKey())||j(n,e=>{f.set(e.getKey(),e)})}const p=Array.from(f.values());return t.isCurrentlyReadOnlyMode()||(this._cachedNodes=p),p}getTextContent(){const e=this.getNodes().filter(e=>u(e));let t="";for(let n=0;n0;e=o.at(-1)){const r=e.pop();void 0===r?o.pop():!1!==n(r)&&t.$isElementNode(r)&&o.push(r.getChildren())}}function V(e,n=t.$getEditor()){const o=t.$getNodeByKey(e);Le(o)||h(231,e);const r=te(o,n.getElementByKey(e));return null===r&&h(232,e),{tableElement:r,tableNode:o}}class Q{focusX;focusY;listenersToRemove;table;isHighlightingCells;anchorX;anchorY;tableNodeKey;anchorCell;focusCell;anchorCellNodeKey;focusCellNodeKey;editor;tableSelection;hasHijackedSelectionStyles;isSelecting;pointerType;shouldCheckSelection;abortController;listenerOptions;nextFocus;constructor(e,t){this.isHighlightingCells=!1,this.anchorX=-1,this.anchorY=-1,this.focusX=-1,this.focusY=-1,this.listenersToRemove=new Set,this.tableNodeKey=t,this.editor=e,this.table={columns:0,domRows:[],rows:0},this.tableSelection=null,this.anchorCellNodeKey=null,this.focusCellNodeKey=null,this.anchorCell=null,this.focusCell=null,this.hasHijackedSelectionStyles=!1,this.isSelecting=!1,this.pointerType=null,this.shouldCheckSelection=!1,this.abortController=new AbortController,this.listenerOptions={signal:this.abortController.signal},this.nextFocus=null,this.trackTable()}getTable(){return this.table}removeListeners(){this.abortController.abort("removeListeners"),Array.from(this.listenersToRemove).forEach(e=>e()),this.listenersToRemove.clear()}$lookup(){return V(this.tableNodeKey,this.editor)}trackTable(){const e=new MutationObserver(e=>{this.editor.getEditorState().read(()=>{let t=!1;for(let n=0;n{const{tableNode:t,tableElement:n}=this.$lookup();this.table=ue(t,n),e.observe(n,{attributes:!0,childList:!0,subtree:!0})},{editor:this.editor})}$clearHighlight(){const e=this.editor;this.isHighlightingCells=!1,this.anchorX=-1,this.anchorY=-1,this.focusX=-1,this.focusY=-1,this.tableSelection=null,this.anchorCellNodeKey=null,this.focusCellNodeKey=null,this.anchorCell=null,this.focusCell=null,this.hasHijackedSelectionStyles=!1,this.$enableHighlightStyle();const{tableNode:n,tableElement:o}=this.$lookup();de(e,ue(n,o),null),null!==t.$getSelection()&&(t.$setSelection(null),e.dispatchCommand(t.SELECTION_CHANGE_COMMAND,void 0))}$enableHighlightStyle(){const t=this.editor,{tableElement:n}=this.$lookup();e.removeClassNamesFromElement(n,t._config.theme.tableSelection),n.classList.remove("disable-selection"),this.hasHijackedSelectionStyles=!1}$disableHighlightStyle(){const{tableElement:t}=this.$lookup();e.addClassNamesToElement(t,this.editor._config.theme.tableSelection),this.hasHijackedSelectionStyles=!0}$updateTableTableSelection(e){if(null!==e){e.tableKey!==this.tableNodeKey&&h(233,e.tableKey,this.tableNodeKey);const t=this.editor;this.tableSelection=e,this.isHighlightingCells=!0,this.$disableHighlightStyle(),this.updateDOMSelection(),de(t,this.table,this.tableSelection)}else this.$clearHighlight()}setShouldCheckSelection(){this.shouldCheckSelection=!0}getAndClearShouldCheckSelection(){return!!this.shouldCheckSelection&&(this.shouldCheckSelection=!1,!0)}setNextFocus(e){this.nextFocus=e}getAndClearNextFocus(){const{nextFocus:e}=this;return null!==e&&(this.nextFocus=null),e}updateDOMSelection(){if(null!==this.anchorCell&&null!==this.focusCell){const e=t.getDOMSelectionForEditor(this.editor);e&&e.rangeCount>0&&e.removeAllRanges()}}$setFocusCellForSelection(e,n=!1){const o=this.editor,{tableNode:r}=this.$lookup(),l=e.x,s=e.y;if(this.focusCell=e,this.isHighlightingCells||this.anchorX===l&&this.anchorY===s&&!n){if(l===this.focusX&&s===this.focusY)return!1}else this.isHighlightingCells=!0,this.$disableHighlightStyle();if(this.focusX=l,this.focusY=s,this.isHighlightingCells){const n=Ae(r,e.elem);if(null!=this.tableSelection&&null!=this.anchorCellNodeKey&&null!==n)return this.focusCellNodeKey=n.getKey(),this.tableSelection=q(r,this.$getAnchorTableCellOrThrow(),n),t.$setSelection(this.tableSelection),o.dispatchCommand(t.SELECTION_CHANGE_COMMAND,void 0),de(o,this.table,this.tableSelection),!0}return!1}$getAnchorTableCell(){return this.anchorCellNodeKey?t.$getNodeByKey(this.anchorCellNodeKey):null}$getAnchorTableCellOrThrow(){const e=this.$getAnchorTableCell();return null===e&&h(234),e}$getFocusTableCell(){return this.focusCellNodeKey?t.$getNodeByKey(this.focusCellNodeKey):null}$getFocusTableCellOrThrow(){const e=this.$getFocusTableCell();return null===e&&h(235),e}$setAnchorCellForSelection(e){this.isHighlightingCells=!1,this.anchorCell=e,this.anchorX=e.x,this.anchorY=e.y;const{tableNode:t}=this.$lookup(),n=Ae(t,e.elem);if(null!==n){const e=n.getKey();this.tableSelection=null!=this.tableSelection?this.tableSelection.clone():J(),this.anchorCellNodeKey=e}}$formatCells(e){const n=t.$getSelection();X(n)||h(236);const o=t.$createRangeSelection(),r=o.anchor,l=o.focus,s=n.getNodes().filter(u);s.length>0||h(237);const i=s[0].getFirstChild(),a=t.$isParagraphNode(i)?i.getFormatFlags(e,null):null;s.forEach(t=>{r.set(t.getKey(),0,"element"),l.set(t.getKey(),t.getChildrenSize(),"element"),o.formatText(e,a)}),t.$setSelection(n),this.editor.dispatchCommand(t.SELECTION_CHANGE_COMMAND,void 0)}$clearText(){const{editor:e}=this,n=t.$getNodeByKey(this.tableNodeKey);if(!Le(n))throw new Error("Expected TableNode.");const o=t.$getSelection();X(o)||h(253);const r=o.getNodes().filter(u),l=n.getFirstChild(),s=n.getLastChild();if(r.length>0&&null!==l&&null!==s&&C(l)&&C(s)&&r[0]===l.getFirstChild()&&r[r.length-1]===s.getLastChild()){n.selectPrevious();const o=n.getParent();return n.remove(),void(t.$isRootNode(o)&&o.isEmpty()&&e.dispatchCommand(t.INSERT_PARAGRAPH_COMMAND,void 0))}r.forEach(e=>{if(t.$isElementNode(e)){const n=t.$createParagraphNode(),o=t.$createTextNode();n.append(o),e.append(n),e.getChildren().forEach(e=>{e!==n&&e.remove()})}}),de(e,this.table,null),t.$setSelection(null),e.dispatchCommand(t.SELECTION_CHANGE_COMMAND,void 0)}}const Z="__lexicalTableSelection";function ee(e){return t.isHTMLElement(e)&&"TABLE"===e.nodeName}function te(e,t){if(!t)return t;const n=ee(t)?t:e.getDOMSlot(t).element;return"TABLE"!==n.nodeName&&h(245,t.nodeName),n}function ne(e,t){for(let n=t,o=null;null!==n;n=n.getParent()){if(e.is(n))return o;u(n)&&(o=n)}return null}const oe=[[t.KEY_ARROW_DOWN_COMMAND,"down"],[t.KEY_ARROW_UP_COMMAND,"up"],[t.KEY_ARROW_LEFT_COMMAND,"backward"],[t.KEY_ARROW_RIGHT_COMMAND,"forward"]],re=[t.DELETE_WORD_COMMAND,t.DELETE_LINE_COMMAND,t.DELETE_CHARACTER_COMMAND],le=[t.KEY_BACKSPACE_COMMAND,t.KEY_DELETE_COMMAND];function se(n,r,l,s){const i=l.getRootElement(),a=function(e){return e._window}(l);null!==i&&null!==a||h(246);const c=new Q(l,n.getKey()),d=te(n,r);!function(e,t){null!==ie(e)&&h(205);e[Z]=t}(d,c),c.listenersToRemove.add(()=>function(e,t){ie(e)===t&&delete e[Z]}(d,c));const g=e=>{if(c.pointerType=e.pointerType,0!==e.button||!t.isDOMNode(e.target)||!a)return;const o=ae(e.target);null!==o&&l.update(()=>{const r=t.$getPreviousSelection();if(S&&e.shiftKey&&Se(r,n)&&(t.$isRangeSelection(r)||X(r))){const t=r.anchor.getNode(),l=ne(n,r.anchor.getNode());if(l)c.$setAnchorCellForSelection(Oe(c,l)),c.$setFocusCellForSelection(o),Me(e);else{(n.isBefore(t)?n.selectStart():n.selectEnd()).anchor.set(r.anchor.key,r.anchor.offset,r.anchor.type)}}else"touch"!==e.pointerType&&c.$setAnchorCellForSelection(o)}),(()=>{if(c.isSelecting)return;const e=()=>{c.isSelecting=!1,a.removeEventListener("pointerup",e),a.removeEventListener("pointermove",n)},n=o=>{if(1&~o.buttons&&c.isSelecting)return c.isSelecting=!1,a.removeEventListener("pointerup",e),void a.removeEventListener("pointermove",n);if(!t.isDOMNode(o.target))return;let r=null;const s=!(S||d.contains(o.target));if(s)r=ce(d,o.target);else for(const e of document.elementsFromPoint(o.clientX,o.clientY))if(r=ce(d,e),r)break;!r||null!==c.focusCell&&r.elem===c.focusCell.elem||(c.setNextFocus({focusCell:r,override:s}),l.dispatchCommand(t.SELECTION_CHANGE_COMMAND,void 0))};c.isSelecting=!0,a.addEventListener("pointerup",e,c.listenerOptions),a.addEventListener("pointermove",n,c.listenerOptions)})()};d.addEventListener("pointerdown",g,c.listenerOptions),c.listenersToRemove.add(()=>{d.removeEventListener("pointerdown",g)});const f=e=>{if(e.detail>=3&&t.isDOMNode(e.target)){null!==ae(e.target)&&e.preventDefault()}};d.addEventListener("mousedown",f,c.listenerOptions),c.listenersToRemove.add(()=>{d.removeEventListener("mousedown",f)});const m=e=>{const n=e.target;0===e.button&&t.isDOMNode(n)&&l.update(()=>{const e=t.$getSelection();X(e)&&e.tableKey===c.tableNodeKey&&i.contains(n)&&c.$clearHighlight()})};a.addEventListener("pointerdown",m,c.listenerOptions),c.listenersToRemove.add(()=>{a.removeEventListener("pointerdown",m)});for(const[e,o]of oe)c.listenersToRemove.add(l.registerCommand(e,e=>Re(l,e,o,n,c),t.COMMAND_PRIORITY_HIGH));c.listenersToRemove.add(l.registerCommand(t.KEY_ESCAPE_COMMAND,e=>{const o=t.$getSelection();if(X(o)){const t=ne(n,o.focus.getNode());if(null!==t)return Me(e),t.selectEnd(),!0}return!1},t.COMMAND_PRIORITY_HIGH));const p=o=>()=>{const r=t.$getSelection();if(!Se(r,n))return!1;if(X(r))return c.$clearText(),!0;if(t.$isRangeSelection(r)){if(!u(ne(n,r.anchor.getNode())))return!1;const l=r.anchor.getNode(),s=r.focus.getNode(),i=n.isParentOf(l),a=n.isParentOf(s);if(i&&!a||a&&!i)return c.$clearText(),!0;const d=e.$findMatchingParent(r.anchor.getNode(),e=>t.$isElementNode(e)),h=d&&e.$findMatchingParent(d,e=>t.$isElementNode(e)&&u(e.getParent()));if(!t.$isElementNode(h)||!t.$isElementNode(d))return!1;if(o===t.DELETE_LINE_COMMAND&&null===h.getPreviousSibling())return!0}return!1};for(const e of re)c.listenersToRemove.add(l.registerCommand(e,p(e),t.COMMAND_PRIORITY_HIGH));const _=e=>{const o=t.$getSelection();if(!X(o)&&!t.$isRangeSelection(o))return!1;const r=n.isParentOf(o.anchor.getNode());if(r!==n.isParentOf(o.focus.getNode())){const e=r?"anchor":"focus",t=r?"focus":"anchor",{key:l,offset:s,type:i}=o[t];return n[o[e].isBefore(o[t])?"selectPrevious":"selectNext"]()[t].set(l,s,i),!1}return!!Se(o,n)&&(!!X(o)&&(e&&(e.preventDefault(),e.stopPropagation()),c.$clearText(),!0))};for(const e of le)c.listenersToRemove.add(l.registerCommand(e,_,t.COMMAND_PRIORITY_HIGH));return c.listenersToRemove.add(l.registerCommand(t.CUT_COMMAND,n=>{const r=t.$getSelection();if(r){if(!X(r)&&!t.$isRangeSelection(r))return!1;o.copyToClipboard(l,e.objectKlassEquals(n,ClipboardEvent)?n:null,o.$getClipboardDataFromSelection(r));const s=_(n);return t.$isRangeSelection(r)?(r.removeText(),!0):s}return!1},t.COMMAND_PRIORITY_HIGH)),c.listenersToRemove.add(l.registerCommand(t.FORMAT_TEXT_COMMAND,o=>{const r=t.$getSelection();if(!Se(r,n))return!1;if(X(r))return c.$formatCells(o),!0;if(t.$isRangeSelection(r)){const t=e.$findMatchingParent(r.anchor.getNode(),e=>u(e));if(!u(t))return!1}return!1},t.COMMAND_PRIORITY_HIGH)),c.listenersToRemove.add(l.registerCommand(t.FORMAT_ELEMENT_COMMAND,e=>{const o=t.$getSelection();if(!X(o)||!Se(o,n))return!1;const r=o.anchor.getNode(),l=o.focus.getNode();if(!u(r)||!u(l))return!1;if(function(e,t){if(X(e)){const n=e.anchor.getNode(),o=e.focus.getNode();if(t&&n&&o){const[e]=L(t,n,o);return n.getKey()===e[0][0].cell.getKey()&&o.getKey()===e[e.length-1].at(-1).cell.getKey()}}return!1}(o,n))return n.setFormat(e),!0;const[s,i,a]=L(n,r,l),c=Math.max(i.startRow+i.cell.__rowSpan-1,a.startRow+a.cell.__rowSpan-1),d=Math.max(i.startColumn+i.cell.__colSpan-1,a.startColumn+a.cell.__colSpan-1),h=Math.min(i.startRow,a.startRow),g=Math.min(i.startColumn,a.startColumn),f=new Set;for(let n=h;n<=c;n++)for(let o=g;o<=d;o++){const r=s[n][o].cell;if(f.has(r))continue;f.add(r),r.setFormat(e);const l=r.getChildren();for(let n=0;n{const r=t.$getSelection();if(!Se(r,n))return!1;if(X(r))return c.$clearHighlight(),!1;if(t.$isRangeSelection(r)){const s=e.$findMatchingParent(r.anchor.getNode(),e=>u(e));if(!u(s))return!1;if("string"==typeof o){const e=Ee(l,r,n);if(e)return xe(e,n,[t.$createTextNode(o)]),!0}}return!1},t.COMMAND_PRIORITY_HIGH)),s&&c.listenersToRemove.add(l.registerCommand(t.KEY_TAB_COMMAND,o=>{const r=t.$getSelection();if(!t.$isRangeSelection(r)||!r.isCollapsed()||!Se(r,n))return!1;const l=Te(r.anchor.getNode());return!(null===l||!n.is(ye(l)))&&(Me(o),function(n,o){const r="next"===o?"getNextSibling":"getPreviousSibling",l="next"===o?"getFirstChild":"getLastChild",s=n[r]();if(t.$isElementNode(s))return s.selectEnd();const i=e.$findMatchingParent(n,C);null===i&&h(247);for(let e=i[r]();C(e);e=e[r]()){const n=e[l]();if(t.$isElementNode(n))return n.selectEnd()}const a=e.$findMatchingParent(i,Le);null===a&&h(248);"next"===o?a.selectNext():a.selectPrevious()}(l,o.shiftKey?"previous":"next"),!0)},t.COMMAND_PRIORITY_HIGH)),c.listenersToRemove.add(l.registerCommand(t.FOCUS_COMMAND,e=>n.isSelected(),t.COMMAND_PRIORITY_HIGH)),c.listenersToRemove.add(l.registerCommand(t.SELECTION_INSERT_CLIPBOARD_NODES_COMMAND,(n,o)=>{if(l!==o)return!1;const{nodes:r,selection:s}=n,i=s.getStartEndPoints(),a=X(s),c=t.$isRangeSelection(s)&&null!==e.$findMatchingParent(s.anchor.getNode(),e=>u(e))&&null!==e.$findMatchingParent(s.focus.getNode(),e=>u(e))||a;if(1!==r.length||!Le(r[0])||!c||null===i)return!1;const[d,h]=i,[g,f,m]=B(d),p=e.$findMatchingParent(h.getNode(),e=>u(e));if(!(u(g)&&u(p)&&C(f)&&Le(m)))return!1;const _=r[0],[S,N,b]=L(m,g,p),[w]=W(_,null,null),T=S.length,y=T>0?S[0].length:0;let $=N.startRow,R=N.startColumn,x=w.length,E=x>0?w[0].length:0;if(a){const e=z(S,N,b),t=e.maxRow-e.minRow+1,n=e.maxColumn-e.minColumn+1;$=e.minRow,R=e.minColumn,x=Math.min(x,t),E=Math.min(E,n)}let A=!1;const v=Math.min(T,$+x)-1,F=Math.min(y,R+E)-1,P=new Set;for(let e=$;e<=v;e++)for(let t=R;t<=F;t++){const n=S[e][t];P.has(n.cell.getKey())||(1===n.cell.__rowSpan&&1===n.cell.__colSpan||(H(n.cell),P.add(n.cell.getKey()),A=!0))}let[D]=W(m.getWritable(),null,null);const K=x-T+$;for(let e=0;e{if(t.$isTextNode(e)){t.$createParagraphNode().append(e),i.append(e)}else i.append(e)}),a.forEach(e=>e.remove())}if(a&&A){const[e]=W(m.getWritable(),null,null);e[N.startRow][N.startColumn].cell.selectEnd()}return!0},t.COMMAND_PRIORITY_HIGH)),c.listenersToRemove.add(l.registerCommand(t.SELECTION_CHANGE_COMMAND,()=>{const o=t.$getSelection(),r=t.$getPreviousSelection(),s=c.getAndClearNextFocus();if(null!==s){const{focusCell:e}=s;if(X(o)&&o.tableKey===c.tableNodeKey)return(e.x!==c.focusX||e.y!==c.focusY)&&(c.$setFocusCellForSelection(e),!0);if(e!==c.anchorCell&&Se(o,n))return c.$setFocusCellForSelection(e),!0}if(c.getAndClearShouldCheckSelection()&&t.$isRangeSelection(r)&&t.$isRangeSelection(o)&&o.isCollapsed()){const t=o.anchor.getNode(),r=n.getFirstChild(),l=Te(t);if(null!==l&&C(r)){const t=r.getFirstChild();if(u(t)&&n.is(e.$findMatchingParent(l,e=>e.is(n)||e.is(t))))return t.selectStart(),!0}}if(t.$isRangeSelection(o)){const{anchor:e,focus:s}=o,i=e.getNode(),a=s.getNode(),u=Te(i),d=Te(a),h=!(!u||!n.is(ye(u))),g=!(!d||!n.is(ye(d))),f=h!==g,m=h&&g,C=o.isBackward();if(f){const e=o.clone();if(g){const[t]=L(n,d,d),o=t[0][0].cell,r=t[t.length-1].at(-1).cell;e.focus.set(C?o.getKey():r.getKey(),C?o.getChildrenSize():r.getChildrenSize(),"element")}else if(h){const[t]=L(n,u,u),o=t[0][0].cell,r=t[t.length-1].at(-1).cell;e.anchor.set(C?r.getKey():o.getKey(),C?r.getChildrenSize():0,"element")}t.$setSelection(e),ge(l,c)}else if(m&&(u.is(d)||(c.$setAnchorCellForSelection(Oe(c,u)),c.$setFocusCellForSelection(Oe(c,d),!0)),"touch"===c.pointerType&&c.isSelecting&&o.isCollapsed()&&t.$isRangeSelection(r)&&r.isCollapsed())){const e=Te(r.anchor.getNode());e&&!e.is(d)&&(c.$setAnchorCellForSelection(Oe(c,e)),c.$setFocusCellForSelection(Oe(c,d),!0),c.pointerType=null)}}else if(o&&X(o)&&o.is(r)&&o.tableKey===n.getKey()){const e=t.getDOMSelectionForEditor(l);if(e&&e.anchorNode&&e.focusNode){const r=t.$getNearestNodeFromDOMNode(e.focusNode),s=r&&!n.isParentOf(r),i=t.$getNearestNodeFromDOMNode(e.anchorNode),a=i&&n.isParentOf(i);if(s&&a&&e.rangeCount>0){const r=t.$createRangeSelectionFromDom(e,l);r&&(r.anchor.set(n.getKey(),o.isBackward()?n.getChildrenSize():0,"element"),e.removeAllRanges(),t.$setSelection(r))}}}return o&&!o.is(r)&&(X(o)||X(r))&&c.tableSelection&&!c.tableSelection.is(r)?(X(o)&&o.tableKey===c.tableNodeKey?c.$updateTableTableSelection(o):!X(o)&&X(r)&&r.tableKey===c.tableNodeKey&&c.$updateTableTableSelection(null),!1):(c.hasHijackedSelectionStyles&&!n.isSelected()?function(e,t){t.$enableHighlightStyle(),he(t.table,t=>{const n=t.elem;t.highlighted=!1,we(e,t),n.getAttribute("style")||n.removeAttribute("style")})}(l,c):!c.hasHijackedSelectionStyles&&n.isSelected()&&ge(l,c),!1)},t.COMMAND_PRIORITY_HIGH)),c.listenersToRemove.add(l.registerCommand(t.INSERT_PARAGRAPH_COMMAND,()=>{const e=t.$getSelection();if(!t.$isRangeSelection(e)||!e.isCollapsed()||!Se(e,n))return!1;const o=Ee(l,e,n);return!!o&&(xe(o,n),!0)},t.COMMAND_PRIORITY_HIGH)),c}function ie(e){return e[Z]||null}function ae(e){let t=e;for(;null!=t;){const e=t.nodeName;if("TD"===e||"TH"===e){const e=t._cell;return void 0===e?null:e}t=t.parentNode}return null}function ce(e,t){if(!e.contains(t))return null;let n=null;for(let o=t;null!=o;o=o.parentNode){if(o===e)return n;const t=o.nodeName;"TD"!==t&&"TH"!==t||(n=o._cell||null)}return null}function ue(e,t){const n=[],o={columns:0,domRows:n,rows:0};let r=te(e,t).querySelector("tr"),l=0,s=0;for(n.length=0;null!=r;){const e=r.nodeName;if("TD"===e||"TH"===e){const e={elem:r,hasBackgroundColor:""!==r.style.backgroundColor,highlighted:!1,x:l,y:s};r._cell=e;let t=n[s];void 0===t&&(t=n[s]=[]),t[l]=e}else{const e=r.firstChild;if(null!=e){r=e;continue}}const t=r.nextSibling;if(null!=t){l++,r=t;continue}const o=r.parentNode;if(null!=o){const e=o.nextSibling;if(null==e)break;s++,l=0,r=e}}return o.columns=l+1,o.rows=s+1,o}function de(e,t,n){const o=new Set(n?n.getNodes():[]);he(t,(t,n)=>{const r=t.elem;o.has(n)?(t.highlighted=!0,be(e,t)):(t.highlighted=!1,we(e,t),r.getAttribute("style")||r.removeAttribute("style"))})}function he(e,n){const{domRows:o}=e;for(let e=0;e{t.highlighted=!0,be(e,t)})}const fe=(e,t,n,o,r)=>{const l="forward"===r;switch(r){case"backward":case"forward":return n!==(l?e.table.columns-1:0)?Ne(t.getCellNodeFromCordsOrThrow(n+(l?1:-1),o,e.table),l):o!==(l?e.table.rows-1:0)?Ne(t.getCellNodeFromCordsOrThrow(l?0:e.table.columns-1,o+(l?1:-1),e.table),l):l?t.selectNext():t.selectPrevious(),!0;case"up":return 0!==o?Ne(t.getCellNodeFromCordsOrThrow(n,o-1,e.table),!1):t.selectPrevious(),!0;case"down":return o!==e.table.rows-1?Ne(t.getCellNodeFromCordsOrThrow(n,o+1,e.table),!0):t.selectNext(),!0;default:return!1}};function me(e,t){let n,o;if(t.startColumn===e.minColumn)n="minColumn";else{if(t.startColumn+t.cell.__colSpan-1!==e.maxColumn)return null;n="maxColumn"}if(t.startRow===e.minRow)o="minRow";else{if(t.startRow+t.cell.__rowSpan-1!==e.maxRow)return null;o="maxRow"}return[n,o]}function Ce([e,t]){return["minColumn"===e?"maxColumn":"minColumn","minRow"===t?"maxRow":"minRow"]}function pe(e,t,[n,o]){const r=t[o],l=e[r];void 0===l&&h(250,o,String(r));const s=t[n],i=l[s];return void 0===i&&h(250,n,String(s)),i}function _e(e,t,n,o,r){const l=z(t,n,o),s=function(e,t){const{minColumn:n,maxColumn:o,minRow:r,maxRow:l}=t;let s=1,i=1,a=1,c=1;const u=e[r],d=e[l];for(let e=n;e<=o;e++)s=Math.max(s,u[e].cell.__rowSpan),c=Math.max(c,d[e].cell.__rowSpan);for(let t=r;t<=l;t++)i=Math.max(i,e[t][n].cell.__colSpan),a=Math.max(a,e[t][o].cell.__colSpan);return{bottomSpan:c,leftSpan:i,rightSpan:a,topSpan:s}}(t,l),{topSpan:i,leftSpan:a,bottomSpan:c,rightSpan:u}=s,d=function(e,t){const n=me(e,t);return null===n&&h(249,t.cell.getKey()),n}(l,n),[g,f]=Ce(d);let m=l[g],C=l[f];"forward"===r?m+="maxColumn"===g?1:a:"backward"===r?m-="minColumn"===g?1:u:"down"===r?C+="maxRow"===f?1:i:"up"===r&&(C-="minRow"===f?1:c);const p=t[C];if(void 0===p)return!1;const _=p[m];if(void 0===_)return!1;const[S,N]=function(e,t,n){const o=z(e,t,n),r=me(o,t);if(r)return[pe(e,o,r),pe(e,o,Ce(r))];const l=me(o,n);if(l)return[pe(e,o,Ce(l)),pe(e,o,l)];const s=["minColumn","minRow"];return[pe(e,o,s),pe(e,o,Ce(s))]}(t,n,_),b=Oe(e,S.cell),w=Oe(e,N.cell);return e.$setAnchorCellForSelection(b),e.$setFocusCellForSelection(w,!0),!0}function Se(e,n){if(t.$isRangeSelection(e)||X(e)){const t=n.isParentOf(e.anchor.getNode()),o=n.isParentOf(e.focus.getNode());return t&&o}return!1}function Ne(e,t){t?e.selectStart():e.selectEnd()}function be(n,o){const r=o.elem,l=n._config.theme;u(t.$getNearestNodeFromDOMNode(r))||h(131),e.addClassNamesToElement(r,l.tableCellSelected)}function we(n,o){const r=o.elem;u(t.$getNearestNodeFromDOMNode(r))||h(131);const l=n._config.theme;e.removeClassNamesFromElement(r,l.tableCellSelected)}function Te(t){const n=e.$findMatchingParent(t,u);return u(n)?n:null}function ye(t){const n=e.$findMatchingParent(t,Le);return Le(n)?n:null}function $e(n,o,r,l,s,i,a){const c=t.$caretFromPoint(r.focus,s?"previous":"next");if(t.$isExtendableTextPointCaret(c))return!1;let d=c;for(const e of t.$extendCaretToRange(c).iterNodeCarets("shadowRoot")){if(!t.$isSiblingCaret(e)||!t.$isElementNode(e.origin))return!1;d=e}const h=d.getParentAtCaret();if(!u(h))return!1;const g=h,f=function(e){for(const n of t.$extendCaretToRange(e).iterNodeCarets("root")){const{origin:o}=n;if(u(o)){if(t.$isChildCaret(n))return t.$getChildCaret(o,e.direction)}else if(!C(o))break}return null}(t.$getSiblingCaret(g,d.direction)),m=e.$findMatchingParent(g,Le);if(!m||!m.is(i))return!1;const p=n.getElementByKey(g.getKey()),_=ae(p);if(!p||!_)return!1;const S=Ie(n,m);if(a.table=S,f)if("extend"===l){const e=ae(n.getElementByKey(f.origin.getKey()));if(!e)return!1;a.$setAnchorCellForSelection(_),a.$setFocusCellForSelection(e,!0)}else{const e=t.$normalizeCaret(f);t.$setPointFromCaret(r.anchor,e),t.$setPointFromCaret(r.focus,e)}else if("extend"===l)a.$setAnchorCellForSelection(_),a.$setFocusCellForSelection(_,!0);else{const e=function(e){const n=t.$getAdjacentChildCaret(e);return t.$isChildCaret(n)?t.$normalizeCaret(n):e}(t.$getSiblingCaret(m,c.direction));t.$setPointFromCaret(r.anchor,e),t.$setPointFromCaret(r.focus,e)}return Me(o),!0}function Re(n,o,r,l,s){if(("up"===r||"down"===r)&&function(e){const t=e.getRootElement();if(!t)return!1;return t.hasAttribute("aria-controls")&&"typeahead-menu"===t.getAttribute("aria-controls")}(n))return!1;const i=t.$getSelection();if(!Se(i,l)){if(t.$isRangeSelection(i)){if("backward"===r){if(i.focus.offset>0)return!1;const e=function(e){for(let n=e,o=e;null!==o;n=o,o=o.getParent())if(t.$isElementNode(o)){if(o!==n&&o.getFirstChild()!==n)return null;if(!o.isInline())return o}return null}(i.focus.getNode());if(!e)return!1;const n=e.getPreviousSibling();return!!Le(n)&&(Me(o),o.shiftKey?i.focus.set(n.getParentOrThrow().getKey(),n.getIndexWithinParent(),"element"):n.selectEnd(),!0)}if(o.shiftKey&&("up"===r||"down"===r)){const n=i.focus.getNode();if(!i.isCollapsed()&&("up"===r&&!i.isBackward()||"down"===r&&i.isBackward())){let s=e.$findMatchingParent(n,e=>Le(e));if(u(s)&&(s=e.$findMatchingParent(s,Le)),s!==l)return!1;if(!s)return!1;const a="down"===r?s.getNextSibling():s.getPreviousSibling();if(!a)return!1;let c=0;"up"===r&&t.$isElementNode(a)&&(c=a.getChildrenSize());let d=a;if("up"===r&&t.$isElementNode(a)){const e=a.getLastChild();d=e||a,c=t.$isTextNode(d)?d.getTextContentSize():0}const h=i.clone();return h.focus.set(d.getKey(),c,t.$isTextNode(d)?"text":"element"),t.$setSelection(h),Me(o),!0}if(t.$isRootOrShadowRoot(n)){const e="up"===r?i.getNodes()[i.getNodes().length-1]:i.getNodes()[0];if(e){if(null!==ne(l,e)){const e=l.getFirstDescendant(),t=l.getLastDescendant();if(!e||!t)return!1;const[n]=B(e),[o]=B(t),r=l.getCordsFromCellNode(n,s.table),i=l.getCordsFromCellNode(o,s.table),a=l.getDOMCellFromCordsOrThrow(r.x,r.y,s.table),c=l.getDOMCellFromCordsOrThrow(i.x,i.y,s.table);return s.$setAnchorCellForSelection(a),s.$setFocusCellForSelection(c,!0),!0}}return!1}{let l=e.$findMatchingParent(n,e=>t.$isElementNode(e)&&!e.isInline());if(u(l)&&(l=e.$findMatchingParent(l,Le)),!l)return!1;const a="down"===r?l.getNextSibling():l.getPreviousSibling();if(Le(a)&&s.tableNodeKey===a.getKey()){const e=a.getFirstDescendant(),n=a.getLastDescendant();if(!e||!n)return!1;const[l]=B(e),[s]=B(n),c=i.clone();return c.focus.set(("up"===r?l:s).getKey(),"up"===r?0:s.getChildrenSize(),"element"),Me(o),t.$setSelection(c),!0}}}}return"down"===r&&Pe(n)&&s.setShouldCheckSelection(),!1}if(t.$isRangeSelection(i)){if("backward"===r||"forward"===r){return $e(n,o,i,o.shiftKey?"extend":"move","backward"===r,l,s)}if(i.isCollapsed()){const{anchor:a,focus:c}=i,d=e.$findMatchingParent(a.getNode(),u),h=e.$findMatchingParent(c.getNode(),u);if(!u(d)||!d.is(h))return!1;const g=ye(d);if(g!==l&&null!=g){const e=te(g,n.getElementByKey(g.getKey()));if(null!=e)return s.table=ue(g,e),Re(n,o,r,g,s)}const f=n.getElementByKey(d.__key),m=n.getElementByKey(a.key);if(null==m||null==f)return!1;let C;if("element"===a.type)C=m.getBoundingClientRect();else{const e=t.getDOMSelectionForEditor(n);if(null===e||0===e.rangeCount)return!1;C=e.getRangeAt(0).getBoundingClientRect()}const p="up"===r?d.getFirstChild():d.getLastChild();if(null==p)return!1;const _=n.getElementByKey(p.__key);if(null==_)return!1;const S=_.getBoundingClientRect();if("up"===r?S.top>C.top-C.height:C.bottom+C.height>S.bottom){Me(o);const e=l.getCordsFromCellNode(d,s.table);if(!o.shiftKey)return fe(s,l,e.x,e.y,r);{const t=l.getDOMCellFromCordsOrThrow(e.x,e.y,s.table);s.$setAnchorCellForSelection(t),s.$setFocusCellForSelection(t,!0)}return!0}}}else if(X(i)){const{anchor:t,focus:a}=i,c=e.$findMatchingParent(t.getNode(),u),d=e.$findMatchingParent(a.getNode(),u),[g]=i.getNodes();Le(g)||h(251);const f=te(g,n.getElementByKey(g.getKey()));if(!u(c)||!u(d)||!Le(g)||null==f)return!1;s.$updateTableTableSelection(i);const m=ue(g,f),C=l.getCordsFromCellNode(c,m),p=l.getDOMCellFromCordsOrThrow(C.x,C.y,m);if(s.$setAnchorCellForSelection(p),Me(o),o.shiftKey){const[e,t,n]=L(l,c,d);return _e(s,e,t,n,r)}return d.selectEnd(),!0}return!1}function Me(e){e.preventDefault(),e.stopImmediatePropagation(),e.stopPropagation()}function xe(e,n,o){const r=t.$createParagraphNode();"first"===e?n.insertBefore(r):n.insertAfter(r),r.append(...o||[]),r.selectEnd()}function Ee(n,o,r){const l=r.getParent();if(!l)return;const s=t.getDOMSelectionForEditor(n);if(!s)return;const i=s.anchorNode,a=n.getElementByKey(l.getKey()),c=te(r,n.getElementByKey(r.getKey()));if(!i||!a||!c||!a.contains(i)||c.contains(i))return;const d=e.$findMatchingParent(o.anchor.getNode(),e=>u(e));if(!d)return;const h=e.$findMatchingParent(d,e=>Le(e));if(!Le(h)||!h.is(r))return;const[g,f]=L(r,d,d),m=g[0][0],C=g[g.length-1][g[0].length-1],{startRow:p,startColumn:_}=f,S=p===m.startRow&&_===m.startColumn,N=p===C.startRow&&_===C.startColumn;return S?"first":N?"last":void 0}function Oe(e,t){const{tableNode:n}=e.$lookup(),o=n.getCordsFromCellNode(t,e.table);return n.getDOMCellFromCordsOrThrow(o.x,o.y,e.table)}function Ae(e,n,o){return ne(e,t.$getNearestNodeFromDOMNode(n,o))}function ve(t,n,o){if(!n.theme.tableAlignment)return;const r=[],l=[];for(const e of["center","right"]){const t=n.theme.tableAlignment[e];t&&(e===o?l:r).push(t)}e.removeClassNamesFromElement(t,...r),e.addClassNamesToElement(t,...l)}const Fe=new WeakSet;function Pe(e=t.$getEditor()){return Fe.has(e)}function De(e,t){t?Fe.add(e):Fe.delete(e)}class Ke extends t.ElementNode{__rowStriping;__frozenColumnCount;__frozenRowCount;__colWidths;static getType(){return"table"}getColWidths(){return this.getLatest().__colWidths}setColWidths(e){const t=this.getWritable();return t.__colWidths=e,t}static clone(e){return new Ke(e.__key)}afterCloneFrom(e){super.afterCloneFrom(e),this.__colWidths=e.__colWidths,this.__rowStriping=e.__rowStriping,this.__frozenColumnCount=e.__frozenColumnCount,this.__frozenRowCount=e.__frozenRowCount}static importDOM(){return{table:e=>({conversion:ke,priority:1})}}static importJSON(e){return He().updateFromJSON(e)}updateFromJSON(e){return super.updateFromJSON(e).setRowStriping(e.rowStriping||!1).setFrozenColumns(e.frozenColumnCount||0).setFrozenRows(e.frozenRowCount||0).setColWidths(e.colWidths)}constructor(e){super(e),this.__rowStriping=!1,this.__frozenColumnCount=0,this.__frozenRowCount=0,this.__colWidths=void 0}exportJSON(){return{...super.exportJSON(),colWidths:this.getColWidths(),frozenColumnCount:this.__frozenColumnCount?this.__frozenColumnCount:void 0,frozenRowCount:this.__frozenRowCount?this.__frozenRowCount:void 0,rowStriping:this.__rowStriping?this.__rowStriping:void 0}}extractWithChild(e,t,n){return"html"===n}getDOMSlot(e){const t=ee(e)?e:e.querySelector("table");return ee(t)||h(229),super.getDOMSlot(e).withElement(t).withAfter(t.querySelector("colgroup"))}createDOM(n,o){const r=document.createElement("table");this.__style&&(r.style.cssText=this.__style);const l=document.createElement("colgroup");if(r.appendChild(l),t.setDOMUnmanaged(l),e.addClassNamesToElement(r,n.theme.table),this.updateTableElement(null,r,n),Pe(o)){const t=document.createElement("div"),o=n.theme.tableScrollableWrapper;return o?e.addClassNamesToElement(t,o):t.style.cssText="overflow-x: auto;",t.appendChild(r),this.updateTableWrapper(null,t,r,n),t}return r}updateTableWrapper(t,n,o,r){this.__frozenColumnCount!==(t?t.__frozenColumnCount:0)&&function(t,n,o,r){r>0?(e.addClassNamesToElement(t,o.theme.tableFrozenColumn),n.setAttribute("data-lexical-frozen-column","true")):(e.removeClassNamesFromElement(t,o.theme.tableFrozenColumn),n.removeAttribute("data-lexical-frozen-column"))}(n,o,r,this.__frozenColumnCount),this.__frozenRowCount!==(t?t.__frozenRowCount:0)&&function(t,n,o,r){r>0?(e.addClassNamesToElement(t,o.theme.tableFrozenRow),n.setAttribute("data-lexical-frozen-row","true")):(e.removeClassNamesFromElement(t,o.theme.tableFrozenRow),n.removeAttribute("data-lexical-frozen-row"))}(n,o,r,this.__frozenRowCount)}updateTableElement(t,n,o){this.__style!==(t?t.__style:"")&&(n.style.cssText=this.__style),this.__rowStriping!==(!!t&&t.__rowStriping)&&function(t,n,o){o?(e.addClassNamesToElement(t,n.theme.tableRowStriping),t.setAttribute("data-lexical-row-striping","true")):(e.removeClassNamesFromElement(t,n.theme.tableRowStriping),t.removeAttribute("data-lexical-row-striping"))}(n,o,this.__rowStriping),function(e,t,n,o){const r=e.querySelector("colgroup");if(!r)return;const l=[];for(let e=0;e{if(n.after&&(o=n.after(o)),!ee(o)&&e.isHTMLElement(o)&&(o=o.querySelector("table")),!ee(o))return null;ve(o,t._config,this.getFormatType());const[r]=W(this,null,null),l=new Map;for(const e of r)for(const t of e){const e=t.cell.getKey();l.has(e)||l.set(e,{colSpan:t.cell.getColSpan(),startColumn:t.startColumn})}const s=new Set;for(const e of o.querySelectorAll(":scope > tr > [data-temporary-table-cell-lexical-key]")){const t=e.getAttribute("data-temporary-table-cell-lexical-key");if(t){const n=l.get(t);if(e.removeAttribute("data-temporary-table-cell-lexical-key"),n){l.delete(t);for(let e=0;e colgroup");if(i){const e=Array.from(o.querySelectorAll(":scope > colgroup > col")).filter((e,t)=>s.has(t));i.replaceChildren(...e)}const a=o.querySelectorAll(":scope > tr");if(a.length>0){const e=document.createElement("tbody");for(const t of a)e.appendChild(t);o.append(e)}return o},element:!ee(o)&&e.isHTMLElement(o)?o.querySelector("table"):o}}canBeEmpty(){return!1}isShadowRoot(){return!0}getCordsFromCellNode(e,t){const{rows:n,domRows:o}=t;for(let t=0;t{u(e)&&(t+=e.getColSpan())}),t}}function Ie(e,t){const n=e.getElementByKey(t.getKey());return null===n&&h(230),ue(t,n)}function ke(t){const n=He();t.hasAttribute("data-lexical-row-striping")&&n.setRowStriping(!0),t.hasAttribute("data-lexical-frozen-column")&&n.setFrozenColumns(1),t.hasAttribute("data-lexical-frozen-row")&&n.setFrozenRows(1);const o=t.querySelector(":scope > colgroup");if(o){let e=[];for(const t of o.querySelectorAll(":scope > col")){let n=t.style.width||"";if(!r.test(n)&&(n=t.getAttribute("width")||"",!/^\d+$/.test(n))){e=void 0;break}e.push(parseFloat(n))}e&&n.setColWidths(e)}return{after:t=>e.$descendantsMatching(t,C),node:n}}function He(){return t.$applyNodeReplacement(new Ke)}function Le(e){return e instanceof Ke}function We(e){C(e.getParent())?e.isEmpty()&&e.append(t.$createParagraphNode()):e.remove()}function Be(t){Le(t.getParent())?e.$unwrapAndFilterDescendants(t,u):t.remove()}function ze(n){e.$unwrapAndFilterDescendants(n,C);const[o]=W(n,null,null),r=o.reduce((e,t)=>Math.max(e,t.length),0),l=n.getChildren();for(let e=0;et?1+e:e,0);if(s!==r)for(let e=s;e0){const t=s[s.length-1];e=[...s,...Array(i-s.length).fill(t)]}n.setColWidths(e)}}function Ye(n){if(n.detail<3||!t.isDOMNode(n.target))return!1;const o=t.$getNearestNodeFromDOMNode(n.target);if(null===o)return!1;const r=e.$findMatchingParent(o,e=>t.$isElementNode(e)&&!e.isInline());if(null===r)return!1;return!!u(r.getParent())&&(r.select(0),!0)}function Ue(t){return t.registerNodeTransform(s,t=>{if(t.getColSpan()>1||t.getRowSpan()>1){const[,,n]=B(t),[o]=L(n,t,t),r=o.length,l=o[0].length;let s=n.getFirstChild();C(s)||h(175);const i=[];for(let t=0;t1||a.getRowSpan()>1){u(a)||h(176);const t=c(a.__headerState);null!==n?n.insertAfter(t):e.$insertFirst(s,t)}}}for(const e of i)e.setColSpan(1),e.setRowSpan(1)}})}function Ge(e,t=!0){const n=new Map,o=(o,r,l)=>{const s=te(o,l),i=se(o,s,e,t);n.set(r,[i,s])},r=e.registerMutationListener(Ke,t=>{e.getEditorState().read(()=>{for(const[e,r]of t){const t=n.get(e);if("created"===r||"updated"===r){const{tableNode:r,tableElement:l}=V(e);void 0===t?o(r,e,l):l!==t[1]&&(t[0].removeListeners(),n.delete(e),o(r,e,l))}else"destroyed"===r&&void 0!==t&&(t[0].removeListeners(),n.delete(e))}},{editor:e})},{skipInitialization:!1});return()=>{r();for(const[,[e]]of n)e.removeListeners()}}function Xe(o,r){o.hasNodes([Ke])||h(255);const{hasNestedTables:l=n.signal(!1)}=r??{};return e.mergeRegister(o.registerCommand(d,n=>function({rows:n,columns:o,includeHeaders:r},l){const s=t.$getSelection()||t.$getPreviousSelection();if(!s||!t.$isRangeSelection(s))return!1;if(!l&&ye(s.anchor.getNode()))return!1;const i=N(Number(n),Number(o),r);e.$insertNodeToNearestRoot(i);const a=i.getFirstDescendant();return t.$isTextNode(a)&&a.select(),!0}(n,l.peek()),t.COMMAND_PRIORITY_EDITOR),o.registerCommand(t.SELECTION_INSERT_CLIPBOARD_NODES_COMMAND,({nodes:e,selection:n},r)=>{if(l.peek()||o!==r||!t.$isRangeSelection(n))return!1;return null!==ye(n.anchor.getNode())&&e.some(Le)},t.COMMAND_PRIORITY_EDITOR),o.registerCommand(t.CLICK_COMMAND,Ye,t.COMMAND_PRIORITY_EDITOR),o.registerNodeTransform(Ke,ze),o.registerNodeTransform(g,Be),o.registerNodeTransform(s,We))}const Je=t.defineExtension({build:(e,t,o)=>n.namedSignals(t),config:t.safeCast({hasCellBackgroundColor:!0,hasCellMerge:!0,hasHorizontalScroll:!0,hasNestedTables:!1,hasTabHandler:!0}),name:"@lexical/table/Table",nodes:()=>[Ke,g,s],register(t,o,r){const l=r.getOutput(),{hasNestedTables:i}=l;return e.mergeRegister(n.effect(()=>{const e=l.hasHorizontalScroll.value;Pe(t)!==e&&(De(t,e),t.registerNodeTransform(Ke,()=>{})())}),Xe(t,{hasNestedTables:i}),n.effect(()=>Ge(t,l.hasTabHandler.value)),n.effect(()=>l.hasCellMerge.value?void 0:Ue(t)),n.effect(()=>l.hasCellBackgroundColor.value?void 0:t.registerNodeTransform(s,e=>{null!==e.getBackgroundColor()&&e.setBackgroundColor(null)})))}});exports.$computeTableMap=L,exports.$computeTableMapSkipCellCheck=W,exports.$createTableCellNode=c,exports.$createTableNode=He,exports.$createTableNodeWithDimensions=N,exports.$createTableRowNode=m,exports.$createTableSelection=J,exports.$createTableSelectionFrom=q,exports.$deleteTableColumn=function(e,t){const n=e.getChildren();for(let e=0;e=e.length||t<0)throw new Error("Table column target index out of range");e[t].remove()}}return e},exports.$deleteTableColumnAtSelection=F,exports.$deleteTableColumn__EXPERIMENTAL=P,exports.$deleteTableRowAtSelection=A,exports.$deleteTableRow__EXPERIMENTAL=v,exports.$findCellNode=Te,exports.$findTableNode=ye,exports.$getElementForTableNode=Ie,exports.$getNodeTriplet=B,exports.$getTableAndElementByKey=V,exports.$getTableCellNodeFromLexicalNode=function(t){const n=e.$findMatchingParent(t,e=>u(e));return u(n)?n:null},exports.$getTableCellNodeRect=Y,exports.$getTableColumnIndexFromTableCellNode=function(e){return b(e).getChildren().findIndex(t=>t.is(e))},exports.$getTableNodeFromLexicalNodeOrThrow=w,exports.$getTableRowIndexFromTableCellNode=function(e){const t=b(e);return w(t).getChildren().findIndex(e=>e.is(t))},exports.$getTableRowNodeFromTableCellNodeOrThrow=b,exports.$insertTableColumn=function(e,n,o=!0,r,s){const i=e.getChildren(),a=[];for(let e=0;e=e.length||n<0)throw new Error("Table column target index out of range");const r=e[n];u(r)||h(12);const{left:i,right:d}=T(r,s);let g=l.NO_STATUS;(i&&i.hasHeaderState(l.ROW)||d&&d.hasHeaderState(l.ROW))&&(g|=l.ROW);const f=c(g);f.append(t.$createParagraphNode()),a.push({newTableCell:f,targetCell:r})}}return a.forEach(({newTableCell:e,targetCell:t})=>{o?t.insertAfter(e):t.insertBefore(e)}),e},exports.$insertTableColumnAtSelection=x,exports.$insertTableColumn__EXPERIMENTAL=E,exports.$insertTableRow=function(e,n,o=!0,r,s){const i=e.getChildren();if(n>=i.length||n<0)throw new Error("Table row target index out of range");const a=i[n];if(!C(a))throw new Error("Row before insertion index does not exist.");for(let e=0;e=n.length||t<0)throw new Error("Expected table cell to be inside of table row.");return n[t].remove(),e},exports.$unmergeCell=function(){const n=t.$getSelection();t.$isRangeSelection(n)||X(n)||h(188);const o=n.anchor.getNode(),r=e.$findMatchingParent(o,u);return u(r)||h(148),H(r)},exports.INSERT_TABLE_COMMAND=d,exports.TableCellHeaderStates=l,exports.TableCellNode=s,exports.TableExtension=Je,exports.TableNode=Ke,exports.TableObserver=Q,exports.TableRowNode=g,exports.applyTableHandlers=se,exports.getDOMCellFromTarget=ae,exports.getTableElement=te,exports.getTableObserverFromTableElement=ie,exports.registerTableCellUnmergeTransform=Ue,exports.registerTablePlugin=Xe,exports.registerTableSelectionObserver=Ge,exports.setScrollableTablesActive=De; +diff --git a/node_modules/@lexical/table/LexicalTable.prod.mjs b/node_modules/@lexical/table/LexicalTable.prod.mjs +index 53dc3be..4d0b816 100644 +--- a/node_modules/@lexical/table/LexicalTable.prod.mjs ++++ b/node_modules/@lexical/table/LexicalTable.prod.mjs +@@ -6,4 +6,4 @@ + * + */ + +-import{addClassNamesToElement as e,$descendantsMatching as t,$findMatchingParent as n,removeClassNamesFromElement as o,objectKlassEquals as r,isHTMLElement as l,$insertFirst as s,mergeRegister as i,$insertNodeToNearestRoot as c,$unwrapAndFilterDescendants as a}from"@lexical/utils";import{ElementNode as u,isHTMLElement as h,$isInlineElementOrDecoratorNode as d,$isTextNode as f,$isLineBreakNode as g,$createParagraphNode as m,$applyNodeReplacement as p,createCommand as C,$createTextNode as _,$getSelection as S,$isRangeSelection as w,$isParagraphNode as b,$createPoint as y,$getNodeByKey as N,$isElementNode as v,$normalizeSelection__EXPERIMENTAL as x,isCurrentlyReadOnlyMode as T,TEXT_TYPE_TO_FORMAT as R,$getEditor as F,$setSelection as O,SELECTION_CHANGE_COMMAND as A,getDOMSelection as K,$createRangeSelection as E,$isRootNode as k,INSERT_PARAGRAPH_COMMAND as M,KEY_ARROW_DOWN_COMMAND as $,KEY_ARROW_UP_COMMAND as z,KEY_ARROW_LEFT_COMMAND as W,KEY_ARROW_RIGHT_COMMAND as H,COMMAND_PRIORITY_HIGH as L,KEY_ESCAPE_COMMAND as B,DELETE_WORD_COMMAND as P,DELETE_LINE_COMMAND as D,DELETE_CHARACTER_COMMAND as I,KEY_BACKSPACE_COMMAND as U,KEY_DELETE_COMMAND as J,CUT_COMMAND as Y,FORMAT_TEXT_COMMAND as X,FORMAT_ELEMENT_COMMAND as q,CONTROLLED_TEXT_INSERTION_COMMAND as j,KEY_TAB_COMMAND as V,FOCUS_COMMAND as G,SELECTION_INSERT_CLIPBOARD_NODES_COMMAND as Q,$getPreviousSelection as Z,$getNearestNodeFromDOMNode as ee,$createRangeSelectionFromDom as te,isDOMNode as ne,$isRootOrShadowRoot as oe,$caretFromPoint as re,$isExtendableTextPointCaret as le,$extendCaretToRange as se,$isSiblingCaret as ie,$getSiblingCaret as ce,$setPointFromCaret as ae,$normalizeCaret as ue,$isChildCaret as he,$getChildCaret as de,$getAdjacentChildCaret as fe,setDOMUnmanaged as ge,COMMAND_PRIORITY_EDITOR as me,CLICK_COMMAND as pe,defineExtension as Ce,safeCast as _e}from"lexical";import{effect as Se,namedSignals as we}from"@lexical/extension";import{copyToClipboard as be,$getClipboardDataFromSelection as ye}from"@lexical/clipboard";const Ne=/^(\d+(?:\.\d+)?)px$/,ve={BOTH:3,COLUMN:2,NO_STATUS:0,ROW:1};class xe extends u{__colSpan;__rowSpan;__headerState;__width;__backgroundColor;__verticalAlign;static getType(){return"tablecell"}static clone(e){return new xe(e.__headerState,e.__colSpan,e.__width,e.__key)}afterCloneFrom(e){super.afterCloneFrom(e),this.__rowSpan=e.__rowSpan,this.__backgroundColor=e.__backgroundColor,this.__verticalAlign=e.__verticalAlign}static importDOM(){return{td:e=>({conversion:Re,priority:0}),th:e=>({conversion:Re,priority:0})}}static importJSON(e){return Fe().updateFromJSON(e)}updateFromJSON(e){return super.updateFromJSON(e).setHeaderStyles(e.headerState).setColSpan(e.colSpan||1).setRowSpan(e.rowSpan||1).setWidth(e.width||void 0).setBackgroundColor(e.backgroundColor||null).setVerticalAlign(e.verticalAlign||void 0)}constructor(e=ve.NO_STATUS,t=1,n,o){super(o),this.__colSpan=t,this.__rowSpan=1,this.__headerState=e,this.__width=n,this.__backgroundColor=null,this.__verticalAlign=void 0}createDOM(t){const n=document.createElement(this.getTag());return this.__width&&(n.style.width=`${this.__width}px`),this.__colSpan>1&&(n.colSpan=this.__colSpan),this.__rowSpan>1&&(n.rowSpan=this.__rowSpan),null!==this.__backgroundColor&&(n.style.backgroundColor=this.__backgroundColor),Te(this.__verticalAlign)&&(n.style.verticalAlign=this.__verticalAlign),e(n,t.theme.tableCell,this.hasHeader()&&t.theme.tableCellHeader),n}exportDOM(e){const t=super.exportDOM(e);if(h(t.element)){const e=t.element;e.setAttribute("data-temporary-table-cell-lexical-key",this.getKey()),e.style.border="1px solid black",this.__colSpan>1&&(e.colSpan=this.__colSpan),this.__rowSpan>1&&(e.rowSpan=this.__rowSpan),e.style.width=`${this.getWidth()||75}px`,e.style.verticalAlign=this.getVerticalAlign()||"top",e.style.textAlign="start",null===this.__backgroundColor&&this.hasHeader()&&(e.style.backgroundColor="#f2f3f5")}return t}exportJSON(){return{...super.exportJSON(),...Te(this.__verticalAlign)&&{verticalAlign:this.__verticalAlign},backgroundColor:this.getBackgroundColor(),colSpan:this.__colSpan,headerState:this.__headerState,rowSpan:this.__rowSpan,width:this.getWidth()}}getColSpan(){return this.getLatest().__colSpan}setColSpan(e){const t=this.getWritable();return t.__colSpan=e,t}getRowSpan(){return this.getLatest().__rowSpan}setRowSpan(e){const t=this.getWritable();return t.__rowSpan=e,t}getTag(){return this.hasHeader()?"th":"td"}setHeaderStyles(e,t=ve.BOTH){const n=this.getWritable();return n.__headerState=e&t|n.__headerState&~t,n}getHeaderStyles(){return this.getLatest().__headerState}setWidth(e){const t=this.getWritable();return t.__width=e,t}getWidth(){return this.getLatest().__width}getBackgroundColor(){return this.getLatest().__backgroundColor}setBackgroundColor(e){const t=this.getWritable();return t.__backgroundColor=e,t}getVerticalAlign(){return this.getLatest().__verticalAlign}setVerticalAlign(e){const t=this.getWritable();return t.__verticalAlign=e||void 0,t}toggleHeaderStyle(e){const t=this.getWritable();return(t.__headerState&e)===e?t.__headerState-=e:t.__headerState+=e,t}hasHeaderState(e){return(this.getHeaderStyles()&e)===e}hasHeader(){return this.getLatest().__headerState!==ve.NO_STATUS}updateDOM(e){return e.__headerState!==this.__headerState||e.__width!==this.__width||e.__colSpan!==this.__colSpan||e.__rowSpan!==this.__rowSpan||e.__backgroundColor!==this.__backgroundColor||e.__verticalAlign!==this.__verticalAlign}isShadowRoot(){return!0}collapseAtStart(){return!0}canBeEmpty(){return!1}canIndent(){return!1}}function Te(e){return"middle"===e||"bottom"===e}function Re(e){const t=e,n=e.nodeName.toLowerCase();let o;Ne.test(t.style.width)&&(o=parseFloat(t.style.width));const r=Fe("th"===n?ve.ROW:ve.NO_STATUS,t.colSpan,o);r.__rowSpan=t.rowSpan;const l=t.style.backgroundColor;""!==l&&(r.__backgroundColor=l);const s=t.style.verticalAlign;Te(s)&&(r.__verticalAlign=s);const i=t.style,c=(i&&i.textDecoration||"").split(" "),a="700"===i.fontWeight||"bold"===i.fontWeight,u=c.includes("line-through"),h="italic"===i.fontStyle,p=c.includes("underline");return{after:e=>{const t=[];let n=null;const o=()=>{if(n){const e=n.getFirstChild();g(e)&&1===n.getChildrenSize()&&e.remove()}};for(const r of e)d(r)||f(r)||g(r)?(f(r)&&(a&&r.toggleFormat("bold"),u&&r.toggleFormat("strikethrough"),h&&r.toggleFormat("italic"),p&&r.toggleFormat("underline")),n?n.append(r):(n=m().append(r),t.push(n))):(t.push(r),o(),n=null);return o(),0===t.length&&t.push(m()),t},node:r}}function Fe(e=ve.NO_STATUS,t=1,n){return p(new xe(e,t,n))}function Oe(e){return e instanceof xe}const Ae=C("INSERT_TABLE_COMMAND");function Ke(e,...t){const n=new URL("https://lexical.dev/docs/error"),o=new URLSearchParams;o.append("code",e);for(const e of t)o.append("v",e);throw n.search=o.toString(),Error(`Minified Lexical error #${e}; visit ${n.toString()} for the full message or use the non-minified dev environment for full errors and additional helpful warnings.`)}class Ee extends u{__height;static getType(){return"tablerow"}static clone(e){return new Ee(e.__height,e.__key)}static importDOM(){return{tr:e=>({conversion:ke,priority:0})}}static importJSON(e){return Me().updateFromJSON(e)}updateFromJSON(e){return super.updateFromJSON(e).setHeight(e.height)}constructor(e,t){super(t),this.__height=e}exportJSON(){const e=this.getHeight();return{...super.exportJSON(),...void 0===e?void 0:{height:e}}}createDOM(t){const n=document.createElement("tr");return this.__height&&(n.style.height=`${this.__height}px`),e(n,t.theme.tableRow),n}extractWithChild(e,t,n){return"html"===n}isShadowRoot(){return!0}setHeight(e){const t=this.getWritable();return t.__height=e,t}getHeight(){return this.getLatest().__height}updateDOM(e){return e.__height!==this.__height}canBeEmpty(){return!1}canIndent(){return!1}}function ke(e){const n=e;let o;return Ne.test(n.style.height)&&(o=parseFloat(n.style.height)),{after:e=>t(e,Oe),node:Me(o)}}function Me(e){return p(new Ee(e))}function $e(e){return e instanceof Ee}const ze="undefined"!=typeof window&&void 0!==window.document&&void 0!==window.document.createElement,We=ze&&"documentMode"in document?document.documentMode:null,He=ze&&/^(?!.*Seamonkey)(?=.*Firefox).*/i.test(navigator.userAgent);function Le(e,t,n=!0){const o=gn();for(let r=0;rOe(e));return Oe(t)?t:null}function Pe(e){const t=n(e,e=>$e(e));if($e(t))return t;throw new Error("Expected table cell to be inside of table row.")}function De(e){const t=n(e,e=>mn(e));if(mn(t))return t;throw new Error("Expected table cell to be inside of table.")}function Ie(e){const t=Pe(e);return De(t).getChildren().findIndex(e=>e.is(t))}function Ue(e){return Pe(e).getChildren().findIndex(t=>t.is(e))}function Je(e,t){const n=De(e),{x:o,y:r}=n.getCordsFromCellNode(e,t);return{above:n.getCellNodeFromCords(o,r-1,t),below:n.getCellNodeFromCords(o,r+1,t),left:n.getCellNodeFromCords(o-1,r,t),right:n.getCellNodeFromCords(o+1,r,t)}}function Ye(e,t){const n=e.getChildren();if(t>=n.length||t<0)throw new Error("Expected table cell to be inside of table row.");return n[t].remove(),e}function Xe(e,t,n=!0,o,r){const l=e.getChildren();if(t>=l.length||t<0)throw new Error("Table row target index out of range");const s=l[t];if(!$e(s))throw new Error("Row before insertion index does not exist.");for(let e=0;ee===ve.BOTH||e===t?t:ve.NO_STATUS;function je(e=!0){const t=S();w(t)||wt(t)||Ke(188);const n=t.anchor.getNode(),o=t.focus.getNode(),[r]=mt(n),[l,,s]=mt(o),[,i,c]=ft(s,l,r),{startRow:a}=c,{startRow:u}=i;return e?Ge(a+r.__rowSpan>u+l.__rowSpan?r:l,!0):Ge(u=e.length||t<0)throw new Error("Table column target index out of range");const o=e[t];Oe(o)||Ke(12);const{left:l,right:i}=Je(o,r);let c=ve.NO_STATUS;(l&&l.hasHeaderState(ve.ROW)||i&&i.hasHeaderState(ve.ROW))&&(c|=ve.ROW);const a=Fe(c);a.append(m()),s.push({newTableCell:a,targetCell:o})}}return s.forEach(({newTableCell:e,targetCell:t})=>{n?t.insertAfter(e):t.insertBefore(e)}),e}function Ze(e=!0){const t=S();w(t)||wt(t)||Ke(188);const n=t.anchor.getNode(),o=t.focus.getNode(),[r]=mt(n),[l,,s]=mt(o),[,i,c]=ft(s,l,r),{startColumn:a}=c,{startColumn:u}=i;return e?tt(a+r.__colSpan>u+l.__colSpan?r:l,!0):tt(u1;){if(s-=l.__colSpan,!(s>=0)){d.append(h(o));continue e}{const{cell:e,startRow:o}=t[s];n=e,r=o}}n.insertAfter(h(o))}else l.setColSpan(l.__colSpan+1)}null!==u&&n&&it(u);const f=o.getColWidths();if(f){const e=[...f],t=c<0?0:c,n=e[t];e.splice(t,0,n),o.setColWidths(e)}return u}function nt(e,t){const n=e.getChildren();for(let e=0;e=e.length||t<0)throw new Error("Table column target index out of range");e[t].remove()}}return e}function ot(){const e=S();w(e)||wt(e)||Ke(188);const[t,n]=e.isBackward()?[e.focus.getNode(),e.anchor.getNode()]:[e.anchor.getNode(),e.focus.getNode()],[o,,r]=mt(t),[l]=mt(n),[s,i,c]=ft(r,o,l),{startRow:a}=i,{startRow:u}=c,h=u+l.__rowSpan-1;if(s.length===h-a+1)return void r.remove();const d=s[0].length,f=s[h+1],g=r.getChildAtIndex(h+1);for(let e=h;e>=a;e--){for(let t=d-1;t>=0;t--){const{cell:n,startRow:o,startColumn:r}=s[e][t];if(r===t){if(oh){const e=Math.max(o,a),t=Math.min(n.__rowSpan+o-1,h),r=e<=t?t-e+1:0;n.setRowSpan(n.__rowSpan-r)}if(o>=a&&o+n.__rowSpan-1>h&&e===h){null===g&&Ke(122);let o=null;for(let n=0;n1&&(n+=r.__colSpan-1)}null===o?ct(g,n):o.insertAfter(n)}}}const t=r.getChildAtIndex(e);$e(t)||Ke(206,String(e)),t.remove()}if(void 0!==f){const{cell:e}=f[0];it(e)}else{const e=s[a-1],{cell:t}=e[0];it(t)}}const rt=ot;function lt(){const e=S();w(e)||wt(e)||Ke(188);const t=e.anchor.getNode(),n=e.focus.getNode(),[o,,r]=mt(t),[l]=mt(n),[s,i,c]=ft(r,o,l),{startColumn:a}=i,{startRow:u,startColumn:h}=c,d=Math.min(a,h),f=Math.max(a+o.__colSpan-1,h+l.__colSpan-1),g=f-d+1;if(s[0].length===f-d+1)return r.selectPrevious(),void r.remove();const m=s.length;for(let e=0;ef){if(t===f){const e=f-o+1;n.setColSpan(n.__colSpan-e)}}else n.remove()}const p=s[u],C=a>h?p[a+o.__colSpan]:p[h+l.__colSpan];if(void 0!==C){const{cell:e}=C;it(e)}else{const e=he.is(n.cell))){i.add(t);const e=n.startRow,c=n.startColumn,a=n.cell.__rowSpan||1,u=n.cell.__colSpan||1;o=Math.min(o,e),r=Math.max(r,e+a-1),l=Math.min(l,c),s=Math.max(s,c+u-1)}}if(o===1/0||l===1/0)return null;const c=r-o+1,a=s-l+1,u=n[o][l];if(!u.cell)return null;const h=u.cell;h.setColSpan(a),h.setRowSpan(c);const d=new Set([h.getKey()]);for(let e=o;e<=r;e++)for(let t=l;t<=s;t++){const o=n[e][t];if(!o.cell)continue;const r=o.cell,l=r.getKey();if(!d.has(l)){d.add(l);ut(r)||h.append(...r.getChildren()),r.remove()}}return 0===h.getChildrenSize()&&h.append(m()),h}function ut(e){if(1!==e.getChildrenSize())return!1;const t=e.getFirstChildOrThrow();return!(!b(t)||!t.isEmpty())}function ht(){const e=S();w(e)||wt(e)||Ke(188);const t=e.anchor.getNode(),o=n(t,Oe);return Oe(o)||Ke(148),dt(o)}function dt(e){const[t,n,o]=mt(e),r=t.__colSpan,l=t.__rowSpan;if(1===r&&1===l)return;const[s,i]=ft(o,t,t),{startColumn:c,startRow:a}=i,u=t.__headerState&ve.COLUMN,h=Array.from({length:r},(e,t)=>{let n=u;for(let e=0;0!==n&&e{let n=d;for(let e=0;0!==n&&e1){for(let e=1;e1){let e;for(let t=1;t1&&(e+=n.__colSpan-1)}if(null===i)for(let n=r-1;n>=0;n--)ct(e,Fe(h[n]|f[t]).append(m()));else for(let e=r-1;e>=0;e--)i.insertAfter(Fe(h[e]|f[t]).append(m()))}t.setRowSpan(1)}}function ft(e,t,n){const[o,r,l]=gt(e,t,n);return null===r&&Ke(207),null===l&&Ke(208),[o,r,l]}function gt(e,t,n){const o=[];let r=null,l=null;function s(e){let t=o[e];return void 0===t&&(o[e]=t=[]),t}const i=e.getChildren();for(let e=0;e=i.length);t++){const n=s(e+t);for(let e=0;e=r,d=c.startRow<=i&&u>=l;if(h&&d){const e=Math.min(r,c.startColumn),t=Math.max(s,a),n=Math.min(l,c.startRow),h=Math.max(i,u);e===r&&t===s&&n===l&&h===i||(r=e,s=t,l=n,i=h,o=!0)}}}while(o);return{maxColumn:s,maxRow:i,minColumn:r,minRow:l}}function Ct(e){const[t,,n]=mt(e),o=n.getChildren(),r=o.length,l=o[0].getChildren().length,s=new Array(r);for(let e=0;e{const o=e[t].getNode(),r=n(o,Oe);Oe(r)||Ke(238,t,o.getKey(),o.getType());const l=r.getParent();$e(l)||Ke(239,t);const s=l.getParent();return mn(s)||Ke(240,t),[o,r,l,s]});return l.is(a)||Ke(241),{anchorCell:o,anchorNode:t,anchorRow:r,anchorTable:l,focusCell:i,focusNode:s,focusRow:c,focusTable:a}}class St{tableKey;anchor;focus;_cachedNodes;dirty;constructor(e,t,n){this.anchor=t,this.focus=n,t._selection=this,n._selection=this,this._cachedNodes=null,this.dirty=!1,this.tableKey=e}getStartEndPoints(){return[this.anchor,this.focus]}isValid(){if("root"===this.tableKey||"root"===this.anchor.key||"element"!==this.anchor.type||"root"===this.focus.key||"element"!==this.focus.type)return!1;const e=N(this.tableKey),t=N(this.anchor.key),n=N(this.focus.key);return null!==e&&null!==t&&null!==n}isBackward(){return this.focus.isBefore(this.anchor)}getCachedNodes(){return this._cachedNodes}setCachedNodes(e){this._cachedNodes=e}is(e){return wt(e)&&this.tableKey===e.tableKey&&this.anchor.is(e.anchor)&&this.focus.is(e.focus)}set(e,t,n){this.dirty=this.dirty||e!==this.tableKey||t!==this.anchor.key||n!==this.focus.key,this.tableKey=e,this.anchor.key=t,this.focus.key=n,this._cachedNodes=null}clone(){return new St(this.tableKey,y(this.anchor.key,this.anchor.offset,this.anchor.type),y(this.focus.key,this.focus.offset,this.focus.type))}isCollapsed(){return!1}extract(){return this.getNodes()}insertRawText(e){}insertText(){}hasFormat(e){let t=0;this.getNodes().filter(Oe).forEach(e=>{const n=e.getFirstChild();b(n)&&(t|=n.getTextFormat())});const n=R[e];return 0!==(t&n)}insertNodes(e){const t=this.focus.getNode();v(t)||Ke(151);x(t.select(0,t.getChildrenSize())).insertNodes(e)}getShape(){const{anchorCell:e,focusCell:t}=_t(this),n=Ct(e);null===n&&Ke(153);const o=Ct(t);null===o&&Ke(155);const r=Math.min(n.columnIndex,o.columnIndex),l=Math.max(n.columnIndex+n.colSpan-1,o.columnIndex+o.colSpan-1),s=Math.min(n.rowIndex,o.rowIndex),i=Math.max(n.rowIndex+n.rowSpan-1,o.rowIndex+o.rowSpan-1);return{fromX:Math.min(r,l),fromY:Math.min(s,i),toX:Math.max(r,l),toY:Math.max(s,i)}}getNodes(){if(!this.isValid())return[];const e=this._cachedNodes;if(null!==e)return e;const{anchorTable:t,anchorCell:n,focusCell:o}=_t(this),r=o.getParents()[1];if(r!==t){if(t.isParentOf(o)){const e=r.getParent();null==e&&Ke(159),this.set(this.tableKey,o.getKey(),e.getKey())}else{const e=t.getParent();null==e&&Ke(158),this.set(this.tableKey,e.getKey(),o.getKey())}return this.getNodes()}const[l,s,i]=ft(t,n,o),{minColumn:c,maxColumn:a,minRow:u,maxRow:h}=pt(l,s,i),d=new Map([[t.getKey(),t]]);let f=null;for(let e=u;e<=h;e++)for(let t=c;t<=a;t++){const{cell:n}=l[e][t],o=n.getParent();$e(o)||Ke(160),o!==f&&(d.set(o.getKey(),o),f=o),d.has(n.getKey())||Nt(n,e=>{d.set(e.getKey(),e)})}const g=Array.from(d.values());return T()||(this._cachedNodes=g),g}getTextContent(){const e=this.getNodes().filter(e=>Oe(e));let t="";for(let n=0;n0;e=n.at(-1)){const o=e.pop();void 0===o?n.pop():!1!==t(o)&&v(o)&&n.push(o.getChildren())}}function vt(e,t=F()){const n=N(e);mn(n)||Ke(231,e);const o=Ft(n,t.getElementByKey(e));return null===o&&Ke(232,e),{tableElement:o,tableNode:n}}class xt{focusX;focusY;listenersToRemove;table;isHighlightingCells;anchorX;anchorY;tableNodeKey;anchorCell;focusCell;anchorCellNodeKey;focusCellNodeKey;editor;tableSelection;hasHijackedSelectionStyles;isSelecting;pointerType;shouldCheckSelection;abortController;listenerOptions;nextFocus;constructor(e,t){this.isHighlightingCells=!1,this.anchorX=-1,this.anchorY=-1,this.focusX=-1,this.focusY=-1,this.listenersToRemove=new Set,this.tableNodeKey=t,this.editor=e,this.table={columns:0,domRows:[],rows:0},this.tableSelection=null,this.anchorCellNodeKey=null,this.focusCellNodeKey=null,this.anchorCell=null,this.focusCell=null,this.hasHijackedSelectionStyles=!1,this.isSelecting=!1,this.pointerType=null,this.shouldCheckSelection=!1,this.abortController=new AbortController,this.listenerOptions={signal:this.abortController.signal},this.nextFocus=null,this.trackTable()}getTable(){return this.table}removeListeners(){this.abortController.abort("removeListeners"),Array.from(this.listenersToRemove).forEach(e=>e()),this.listenersToRemove.clear()}$lookup(){return vt(this.tableNodeKey,this.editor)}trackTable(){const e=new MutationObserver(e=>{this.editor.getEditorState().read(()=>{let t=!1;for(let n=0;n{const{tableNode:t,tableElement:n}=this.$lookup();this.table=Ht(t,n),e.observe(n,{attributes:!0,childList:!0,subtree:!0})},{editor:this.editor})}$clearHighlight(){const e=this.editor;this.isHighlightingCells=!1,this.anchorX=-1,this.anchorY=-1,this.focusX=-1,this.focusY=-1,this.tableSelection=null,this.anchorCellNodeKey=null,this.focusCellNodeKey=null,this.anchorCell=null,this.focusCell=null,this.hasHijackedSelectionStyles=!1,this.$enableHighlightStyle();const{tableNode:t,tableElement:n}=this.$lookup();Lt(e,Ht(t,n),null),null!==S()&&(O(null),e.dispatchCommand(A,void 0))}$enableHighlightStyle(){const e=this.editor,{tableElement:t}=this.$lookup();o(t,e._config.theme.tableSelection),t.classList.remove("disable-selection"),this.hasHijackedSelectionStyles=!1}$disableHighlightStyle(){const{tableElement:t}=this.$lookup();e(t,this.editor._config.theme.tableSelection),this.hasHijackedSelectionStyles=!0}$updateTableTableSelection(e){if(null!==e){e.tableKey!==this.tableNodeKey&&Ke(233,e.tableKey,this.tableNodeKey);const t=this.editor;this.tableSelection=e,this.isHighlightingCells=!0,this.$disableHighlightStyle(),this.updateDOMSelection(),Lt(t,this.table,this.tableSelection)}else this.$clearHighlight()}setShouldCheckSelection(){this.shouldCheckSelection=!0}getAndClearShouldCheckSelection(){return!!this.shouldCheckSelection&&(this.shouldCheckSelection=!1,!0)}setNextFocus(e){this.nextFocus=e}getAndClearNextFocus(){const{nextFocus:e}=this;return null!==e&&(this.nextFocus=null),e}updateDOMSelection(){if(null!==this.anchorCell&&null!==this.focusCell){const e=K(this.editor._window);e&&e.rangeCount>0&&e.removeAllRanges()}}$setFocusCellForSelection(e,t=!1){const n=this.editor,{tableNode:o}=this.$lookup(),r=e.x,l=e.y;if(this.focusCell=e,this.isHighlightingCells||this.anchorX===r&&this.anchorY===l&&!t){if(r===this.focusX&&l===this.focusY)return!1}else this.isHighlightingCells=!0,this.$disableHighlightStyle();if(this.focusX=r,this.focusY=l,this.isHighlightingCells){const t=ln(o,e.elem);if(null!=this.tableSelection&&null!=this.anchorCellNodeKey&&null!==t)return this.focusCellNodeKey=t.getKey(),this.tableSelection=yt(o,this.$getAnchorTableCellOrThrow(),t),O(this.tableSelection),n.dispatchCommand(A,void 0),Lt(n,this.table,this.tableSelection),!0}return!1}$getAnchorTableCell(){return this.anchorCellNodeKey?N(this.anchorCellNodeKey):null}$getAnchorTableCellOrThrow(){const e=this.$getAnchorTableCell();return null===e&&Ke(234),e}$getFocusTableCell(){return this.focusCellNodeKey?N(this.focusCellNodeKey):null}$getFocusTableCellOrThrow(){const e=this.$getFocusTableCell();return null===e&&Ke(235),e}$setAnchorCellForSelection(e){this.isHighlightingCells=!1,this.anchorCell=e,this.anchorX=e.x,this.anchorY=e.y;const{tableNode:t}=this.$lookup(),n=ln(t,e.elem);if(null!==n){const e=n.getKey();this.tableSelection=null!=this.tableSelection?this.tableSelection.clone():bt(),this.anchorCellNodeKey=e}}$formatCells(e){const t=S();wt(t)||Ke(236);const n=E(),o=n.anchor,r=n.focus,l=t.getNodes().filter(Oe);l.length>0||Ke(237);const s=l[0].getFirstChild(),i=b(s)?s.getFormatFlags(e,null):null;l.forEach(t=>{o.set(t.getKey(),0,"element"),r.set(t.getKey(),t.getChildrenSize(),"element"),n.formatText(e,i)}),O(t),this.editor.dispatchCommand(A,void 0)}$clearText(){const{editor:e}=this,t=N(this.tableNodeKey);if(!mn(t))throw new Error("Expected TableNode.");const n=S();wt(n)||Ke(253);const o=n.getNodes().filter(Oe),r=t.getFirstChild(),l=t.getLastChild();if(o.length>0&&null!==r&&null!==l&&$e(r)&&$e(l)&&o[0]===r.getFirstChild()&&o[o.length-1]===l.getLastChild()){t.selectPrevious();const n=t.getParent();return t.remove(),void(k(n)&&n.isEmpty()&&e.dispatchCommand(M,void 0))}o.forEach(e=>{if(v(e)){const t=m(),n=_();t.append(n),e.append(t),e.getChildren().forEach(e=>{e!==t&&e.remove()})}}),Lt(e,this.table,null),O(null),e.dispatchCommand(A,void 0)}}const Tt="__lexicalTableSelection";function Rt(e){return h(e)&&"TABLE"===e.nodeName}function Ft(e,t){if(!t)return t;const n=Rt(t)?t:e.getDOMSlot(t).element;return"TABLE"!==n.nodeName&&Ke(245,t.nodeName),n}function Ot(e){return e._window}function At(e,t){for(let n=t,o=null;null!==n;n=n.getParent()){if(e.is(n))return o;Oe(n)&&(o=n)}return null}const Kt=[[$,"down"],[z,"up"],[W,"backward"],[H,"forward"]],Et=[P,D,I],kt=[U,J];function Mt(e,t,o,l){const s=o.getRootElement(),i=Ot(o);null!==s&&null!==i||Ke(246);const c=new xt(o,e.getKey()),a=Ft(e,t);!function(e,t){null!==$t(e)&&Ke(205);e[Tt]=t}(a,c),c.listenersToRemove.add(()=>function(e,t){$t(e)===t&&delete e[Tt]}(a,c));const u=t=>{if(c.pointerType=t.pointerType,0!==t.button||!ne(t.target)||!i)return;const n=zt(t.target);null!==n&&o.update(()=>{const o=Z();if(He&&t.shiftKey&&Xt(o,e)&&(w(o)||wt(o))){const r=o.anchor.getNode(),l=At(e,o.anchor.getNode());if(l)c.$setAnchorCellForSelection(rn(c,l)),c.$setFocusCellForSelection(n),tn(t);else{(e.isBefore(r)?e.selectStart():e.selectEnd()).anchor.set(o.anchor.key,o.anchor.offset,o.anchor.type)}}else"touch"!==t.pointerType&&c.$setAnchorCellForSelection(n)}),(()=>{if(c.isSelecting)return;const e=()=>{c.isSelecting=!1,i.removeEventListener("pointerup",e),i.removeEventListener("pointermove",t)},t=n=>{if(1&~n.buttons&&c.isSelecting)return c.isSelecting=!1,i.removeEventListener("pointerup",e),void i.removeEventListener("pointermove",t);if(!ne(n.target))return;let r=null;const l=!(He||a.contains(n.target));if(l)r=Wt(a,n.target);else for(const e of document.elementsFromPoint(n.clientX,n.clientY))if(r=Wt(a,e),r)break;!r||null!==c.focusCell&&r.elem===c.focusCell.elem||(c.setNextFocus({focusCell:r,override:l}),o.dispatchCommand(A,void 0))};c.isSelecting=!0,i.addEventListener("pointerup",e,c.listenerOptions),i.addEventListener("pointermove",t,c.listenerOptions)})()};a.addEventListener("pointerdown",u,c.listenerOptions),c.listenersToRemove.add(()=>{a.removeEventListener("pointerdown",u)});const h=e=>{if(e.detail>=3&&ne(e.target)){null!==zt(e.target)&&e.preventDefault()}};a.addEventListener("mousedown",h,c.listenerOptions),c.listenersToRemove.add(()=>{a.removeEventListener("mousedown",h)});const d=e=>{const t=e.target;0===e.button&&ne(t)&&o.update(()=>{const e=S();wt(e)&&e.tableKey===c.tableNodeKey&&s.contains(t)&&c.$clearHighlight()})};i.addEventListener("pointerdown",d,c.listenerOptions),c.listenersToRemove.add(()=>{i.removeEventListener("pointerdown",d)});for(const[t,n]of Kt)c.listenersToRemove.add(o.registerCommand(t,t=>en(o,t,n,e,c),L));c.listenersToRemove.add(o.registerCommand(B,t=>{const n=S();if(wt(n)){const o=At(e,n.focus.getNode());if(null!==o)return tn(t),o.selectEnd(),!0}return!1},L));const g=t=>()=>{const o=S();if(!Xt(o,e))return!1;if(wt(o))return c.$clearText(),!0;if(w(o)){if(!Oe(At(e,o.anchor.getNode())))return!1;const r=o.anchor.getNode(),l=o.focus.getNode(),s=e.isParentOf(r),i=e.isParentOf(l);if(s&&!i||i&&!s)return c.$clearText(),!0;const a=n(o.anchor.getNode(),e=>v(e)),u=a&&n(a,e=>v(e)&&Oe(e.getParent()));if(!v(u)||!v(a))return!1;if(t===D&&null===u.getPreviousSibling())return!0}return!1};for(const e of Et)c.listenersToRemove.add(o.registerCommand(e,g(e),L));const p=t=>{const n=S();if(!wt(n)&&!w(n))return!1;const o=e.isParentOf(n.anchor.getNode());if(o!==e.isParentOf(n.focus.getNode())){const t=o?"anchor":"focus",r=o?"focus":"anchor",{key:l,offset:s,type:i}=n[r];return e[n[t].isBefore(n[r])?"selectPrevious":"selectNext"]()[r].set(l,s,i),!1}return!!Xt(n,e)&&(!!wt(n)&&(t&&(t.preventDefault(),t.stopPropagation()),c.$clearText(),!0))};for(const e of kt)c.listenersToRemove.add(o.registerCommand(e,p,L));return c.listenersToRemove.add(o.registerCommand(Y,e=>{const t=S();if(t){if(!wt(t)&&!w(t))return!1;be(o,r(e,ClipboardEvent)?e:null,ye(t));const n=p(e);return w(t)?(t.removeText(),!0):n}return!1},L)),c.listenersToRemove.add(o.registerCommand(X,t=>{const o=S();if(!Xt(o,e))return!1;if(wt(o))return c.$formatCells(t),!0;if(w(o)){const e=n(o.anchor.getNode(),e=>Oe(e));if(!Oe(e))return!1}return!1},L)),c.listenersToRemove.add(o.registerCommand(q,t=>{const n=S();if(!wt(n)||!Xt(n,e))return!1;const o=n.anchor.getNode(),r=n.focus.getNode();if(!Oe(o)||!Oe(r))return!1;if(function(e,t){if(wt(e)){const n=e.anchor.getNode(),o=e.focus.getNode();if(t&&n&&o){const[e]=ft(t,n,o);return n.getKey()===e[0][0].cell.getKey()&&o.getKey()===e[e.length-1].at(-1).cell.getKey()}}return!1}(n,e))return e.setFormat(t),!0;const[l,s,i]=ft(e,o,r),c=Math.max(s.startRow+s.cell.__rowSpan-1,i.startRow+i.cell.__rowSpan-1),a=Math.max(s.startColumn+s.cell.__colSpan-1,i.startColumn+i.cell.__colSpan-1),u=Math.min(s.startRow,i.startRow),h=Math.min(s.startColumn,i.startColumn),d=new Set;for(let e=u;e<=c;e++)for(let n=h;n<=a;n++){const o=l[e][n].cell;if(d.has(o))continue;d.add(o),o.setFormat(t);const r=o.getChildren();for(let e=0;e{const r=S();if(!Xt(r,e))return!1;if(wt(r))return c.$clearHighlight(),!1;if(w(r)){const l=n(r.anchor.getNode(),e=>Oe(e));if(!Oe(l))return!1;if("string"==typeof t){const n=on(o,r,e);if(n)return nn(n,e,[_(t)]),!0}}return!1},L)),l&&c.listenersToRemove.add(o.registerCommand(V,t=>{const o=S();if(!w(o)||!o.isCollapsed()||!Xt(o,e))return!1;const r=Gt(o.anchor.getNode());return!(null===r||!e.is(Qt(r)))&&(tn(t),function(e,t){const o="next"===t?"getNextSibling":"getPreviousSibling",r="next"===t?"getFirstChild":"getLastChild",l=e[o]();if(v(l))return l.selectEnd();const s=n(e,$e);null===s&&Ke(247);for(let e=s[o]();$e(e);e=e[o]()){const t=e[r]();if(v(t))return t.selectEnd()}const i=n(s,mn);null===i&&Ke(248);"next"===t?i.selectNext():i.selectPrevious()}(r,t.shiftKey?"previous":"next"),!0)},L)),c.listenersToRemove.add(o.registerCommand(G,t=>e.isSelected(),L)),c.listenersToRemove.add(o.registerCommand(Q,(e,t)=>{if(o!==t)return!1;const{nodes:r,selection:l}=e,s=l.getStartEndPoints(),i=wt(l),c=w(l)&&null!==n(l.anchor.getNode(),e=>Oe(e))&&null!==n(l.focus.getNode(),e=>Oe(e))||i;if(1!==r.length||!mn(r[0])||!c||null===s)return!1;const[a,u]=s,[h,d,g]=mt(a),p=n(u.getNode(),e=>Oe(e));if(!(Oe(h)&&Oe(p)&&$e(d)&&mn(g)))return!1;const C=r[0],[_,S,b]=ft(g,h,p),[y]=gt(C,null,null),N=_.length,v=N>0?_[0].length:0;let x=S.startRow,T=S.startColumn,R=y.length,F=R>0?y[0].length:0;if(i){const e=pt(_,S,b),t=e.maxRow-e.minRow+1,n=e.maxColumn-e.minColumn+1;x=e.minRow,T=e.minColumn,R=Math.min(R,t),F=Math.min(F,n)}let O=!1;const A=Math.min(N,x+R)-1,K=Math.min(v,T+F)-1,E=new Set;for(let e=x;e<=A;e++)for(let t=T;t<=K;t++){const n=_[e][t];E.has(n.cell.getKey())||(1===n.cell.__rowSpan&&1===n.cell.__colSpan||(dt(n.cell),E.add(n.cell.getKey()),O=!0))}let[k]=gt(g.getWritable(),null,null);const M=R-N+x;for(let e=0;e{if(f(e)){m().append(e),s.append(e)}else s.append(e)}),i.forEach(e=>e.remove())}if(i&&O){const[e]=gt(g.getWritable(),null,null);e[S.startRow][S.startColumn].cell.selectEnd()}return!0},L)),c.listenersToRemove.add(o.registerCommand(A,()=>{const t=S(),r=Z(),l=c.getAndClearNextFocus();if(null!==l){const{focusCell:n}=l;if(wt(t)&&t.tableKey===c.tableNodeKey)return(n.x!==c.focusX||n.y!==c.focusY)&&(c.$setFocusCellForSelection(n),!0);if(n!==c.anchorCell&&Xt(t,e))return c.$setFocusCellForSelection(n),!0}if(c.getAndClearShouldCheckSelection()&&w(r)&&w(t)&&t.isCollapsed()){const o=t.anchor.getNode(),r=e.getFirstChild(),l=Gt(o);if(null!==l&&$e(r)){const t=r.getFirstChild();if(Oe(t)&&e.is(n(l,n=>n.is(e)||n.is(t))))return t.selectStart(),!0}}if(w(t)){const{anchor:n,focus:l}=t,s=n.getNode(),i=l.getNode(),a=Gt(s),u=Gt(i),h=!(!a||!e.is(Qt(a))),d=!(!u||!e.is(Qt(u))),f=h!==d,g=h&&d,m=t.isBackward();if(f){const n=t.clone();if(d){const[t]=ft(e,u,u),o=t[0][0].cell,r=t[t.length-1].at(-1).cell;n.focus.set(m?o.getKey():r.getKey(),m?o.getChildrenSize():r.getChildrenSize(),"element")}else if(h){const[t]=ft(e,a,a),o=t[0][0].cell,r=t[t.length-1].at(-1).cell;n.anchor.set(m?r.getKey():o.getKey(),m?r.getChildrenSize():0,"element")}O(n),Pt(o,c)}else if(g&&(a.is(u)||(c.$setAnchorCellForSelection(rn(c,a)),c.$setFocusCellForSelection(rn(c,u),!0)),"touch"===c.pointerType&&c.isSelecting&&t.isCollapsed()&&w(r)&&r.isCollapsed())){const e=Gt(r.anchor.getNode());e&&!e.is(u)&&(c.$setAnchorCellForSelection(rn(c,e)),c.$setFocusCellForSelection(rn(c,u),!0),c.pointerType=null)}}else if(t&&wt(t)&&t.is(r)&&t.tableKey===e.getKey()){const n=K(i);if(n&&n.anchorNode&&n.focusNode){const r=ee(n.focusNode),l=r&&!e.isParentOf(r),s=ee(n.anchorNode),i=s&&e.isParentOf(s);if(l&&i&&n.rangeCount>0){const r=te(n,o);r&&(r.anchor.set(e.getKey(),t.isBackward()?e.getChildrenSize():0,"element"),n.removeAllRanges(),O(r))}}}return t&&!t.is(r)&&(wt(t)||wt(r))&&c.tableSelection&&!c.tableSelection.is(r)?(wt(t)&&t.tableKey===c.tableNodeKey?c.$updateTableTableSelection(t):!wt(t)&&wt(r)&&r.tableKey===c.tableNodeKey&&c.$updateTableTableSelection(null),!1):(c.hasHijackedSelectionStyles&&!e.isSelected()?function(e,t){t.$enableHighlightStyle(),Bt(t.table,t=>{const n=t.elem;t.highlighted=!1,Vt(e,t),n.getAttribute("style")||n.removeAttribute("style")})}(o,c):!c.hasHijackedSelectionStyles&&e.isSelected()&&Pt(o,c),!1)},L)),c.listenersToRemove.add(o.registerCommand(M,()=>{const t=S();if(!w(t)||!t.isCollapsed()||!Xt(t,e))return!1;const n=on(o,t,e);return!!n&&(nn(n,e),!0)},L)),c}function $t(e){return e[Tt]||null}function zt(e){let t=e;for(;null!=t;){const e=t.nodeName;if("TD"===e||"TH"===e){const e=t._cell;return void 0===e?null:e}t=t.parentNode}return null}function Wt(e,t){if(!e.contains(t))return null;let n=null;for(let o=t;null!=o;o=o.parentNode){if(o===e)return n;const t=o.nodeName;"TD"!==t&&"TH"!==t||(n=o._cell||null)}return null}function Ht(e,t){const n=[],o={columns:0,domRows:n,rows:0};let r=Ft(e,t).querySelector("tr"),l=0,s=0;for(n.length=0;null!=r;){const e=r.nodeName;if("TD"===e||"TH"===e){const e={elem:r,hasBackgroundColor:""!==r.style.backgroundColor,highlighted:!1,x:l,y:s};r._cell=e;let t=n[s];void 0===t&&(t=n[s]=[]),t[l]=e}else{const e=r.firstChild;if(null!=e){r=e;continue}}const t=r.nextSibling;if(null!=t){l++,r=t;continue}const o=r.parentNode;if(null!=o){const e=o.nextSibling;if(null==e)break;s++,l=0,r=e}}return o.columns=l+1,o.rows=s+1,o}function Lt(e,t,n){const o=new Set(n?n.getNodes():[]);Bt(t,(t,n)=>{const r=t.elem;o.has(n)?(t.highlighted=!0,jt(e,t)):(t.highlighted=!1,Vt(e,t),r.getAttribute("style")||r.removeAttribute("style"))})}function Bt(e,t){const{domRows:n}=e;for(let e=0;e{t.highlighted=!0,jt(e,t)})}const Dt=(e,t,n,o,r)=>{const l="forward"===r;switch(r){case"backward":case"forward":return n!==(l?e.table.columns-1:0)?qt(t.getCellNodeFromCordsOrThrow(n+(l?1:-1),o,e.table),l):o!==(l?e.table.rows-1:0)?qt(t.getCellNodeFromCordsOrThrow(l?0:e.table.columns-1,o+(l?1:-1),e.table),l):l?t.selectNext():t.selectPrevious(),!0;case"up":return 0!==o?qt(t.getCellNodeFromCordsOrThrow(n,o-1,e.table),!1):t.selectPrevious(),!0;case"down":return o!==e.table.rows-1?qt(t.getCellNodeFromCordsOrThrow(n,o+1,e.table),!0):t.selectNext(),!0;default:return!1}};function It(e,t){let n,o;if(t.startColumn===e.minColumn)n="minColumn";else{if(t.startColumn+t.cell.__colSpan-1!==e.maxColumn)return null;n="maxColumn"}if(t.startRow===e.minRow)o="minRow";else{if(t.startRow+t.cell.__rowSpan-1!==e.maxRow)return null;o="maxRow"}return[n,o]}function Ut([e,t]){return["minColumn"===e?"maxColumn":"minColumn","minRow"===t?"maxRow":"minRow"]}function Jt(e,t,[n,o]){const r=t[o],l=e[r];void 0===l&&Ke(250,o,String(r));const s=t[n],i=l[s];return void 0===i&&Ke(250,n,String(s)),i}function Yt(e,t,n,o,r){const l=pt(t,n,o),s=function(e,t){const{minColumn:n,maxColumn:o,minRow:r,maxRow:l}=t;let s=1,i=1,c=1,a=1;const u=e[r],h=e[l];for(let e=n;e<=o;e++)s=Math.max(s,u[e].cell.__rowSpan),a=Math.max(a,h[e].cell.__rowSpan);for(let t=r;t<=l;t++)i=Math.max(i,e[t][n].cell.__colSpan),c=Math.max(c,e[t][o].cell.__colSpan);return{bottomSpan:a,leftSpan:i,rightSpan:c,topSpan:s}}(t,l),{topSpan:i,leftSpan:c,bottomSpan:a,rightSpan:u}=s,h=function(e,t){const n=It(e,t);return null===n&&Ke(249,t.cell.getKey()),n}(l,n),[d,f]=Ut(h);let g=l[d],m=l[f];"forward"===r?g+="maxColumn"===d?1:c:"backward"===r?g-="minColumn"===d?1:u:"down"===r?m+="maxRow"===f?1:i:"up"===r&&(m-="minRow"===f?1:a);const p=t[m];if(void 0===p)return!1;const C=p[g];if(void 0===C)return!1;const[_,S]=function(e,t,n){const o=pt(e,t,n),r=It(o,t);if(r)return[Jt(e,o,r),Jt(e,o,Ut(r))];const l=It(o,n);if(l)return[Jt(e,o,Ut(l)),Jt(e,o,l)];const s=["minColumn","minRow"];return[Jt(e,o,s),Jt(e,o,Ut(s))]}(t,n,C),w=rn(e,_.cell),b=rn(e,S.cell);return e.$setAnchorCellForSelection(w),e.$setFocusCellForSelection(b,!0),!0}function Xt(e,t){if(w(e)||wt(e)){const n=t.isParentOf(e.anchor.getNode()),o=t.isParentOf(e.focus.getNode());return n&&o}return!1}function qt(e,t){t?e.selectStart():e.selectEnd()}function jt(t,n){const o=n.elem,r=t._config.theme;Oe(ee(o))||Ke(131),e(o,r.tableCellSelected)}function Vt(e,t){const n=t.elem;Oe(ee(n))||Ke(131);const r=e._config.theme;o(n,r.tableCellSelected)}function Gt(e){const t=n(e,Oe);return Oe(t)?t:null}function Qt(e){const t=n(e,mn);return mn(t)?t:null}function Zt(e,t,o,r,l,s,i){const c=re(o.focus,l?"previous":"next");if(le(c))return!1;let a=c;for(const e of se(c).iterNodeCarets("shadowRoot")){if(!ie(e)||!v(e.origin))return!1;a=e}const u=a.getParentAtCaret();if(!Oe(u))return!1;const h=u,d=function(e){for(const t of se(e).iterNodeCarets("root")){const{origin:n}=t;if(Oe(n)){if(he(t))return de(n,e.direction)}else if(!$e(n))break}return null}(ce(h,a.direction)),f=n(h,mn);if(!f||!f.is(s))return!1;const g=e.getElementByKey(h.getKey()),m=zt(g);if(!g||!m)return!1;const p=dn(e,f);if(i.table=p,d)if("extend"===r){const t=zt(e.getElementByKey(d.origin.getKey()));if(!t)return!1;i.$setAnchorCellForSelection(m),i.$setFocusCellForSelection(t,!0)}else{const e=ue(d);ae(o.anchor,e),ae(o.focus,e)}else if("extend"===r)i.$setAnchorCellForSelection(m),i.$setFocusCellForSelection(m,!0);else{const e=function(e){const t=fe(e);return he(t)?ue(t):e}(ce(f,c.direction));ae(o.anchor,e),ae(o.focus,e)}return tn(t),!0}function en(e,t,o,r,l){if(("up"===o||"down"===o)&&function(e){const t=e.getRootElement();if(!t)return!1;return t.hasAttribute("aria-controls")&&"typeahead-menu"===t.getAttribute("aria-controls")}(e))return!1;const s=S();if(!Xt(s,r)){if(w(s)){if("backward"===o){if(s.focus.offset>0)return!1;const e=function(e){for(let t=e,n=e;null!==n;t=n,n=n.getParent())if(v(n)){if(n!==t&&n.getFirstChild()!==t)return null;if(!n.isInline())return n}return null}(s.focus.getNode());if(!e)return!1;const n=e.getPreviousSibling();return!!mn(n)&&(tn(t),t.shiftKey?s.focus.set(n.getParentOrThrow().getKey(),n.getIndexWithinParent(),"element"):n.selectEnd(),!0)}if(t.shiftKey&&("up"===o||"down"===o)){const e=s.focus.getNode();if(!s.isCollapsed()&&("up"===o&&!s.isBackward()||"down"===o&&s.isBackward())){let l=n(e,e=>mn(e));if(Oe(l)&&(l=n(l,mn)),l!==r)return!1;if(!l)return!1;const i="down"===o?l.getNextSibling():l.getPreviousSibling();if(!i)return!1;let c=0;"up"===o&&v(i)&&(c=i.getChildrenSize());let a=i;if("up"===o&&v(i)){const e=i.getLastChild();a=e||i,c=f(a)?a.getTextContentSize():0}const u=s.clone();return u.focus.set(a.getKey(),c,f(a)?"text":"element"),O(u),tn(t),!0}if(oe(e)){const e="up"===o?s.getNodes()[s.getNodes().length-1]:s.getNodes()[0];if(e){if(null!==At(r,e)){const e=r.getFirstDescendant(),t=r.getLastDescendant();if(!e||!t)return!1;const[n]=mt(e),[o]=mt(t),s=r.getCordsFromCellNode(n,l.table),i=r.getCordsFromCellNode(o,l.table),c=r.getDOMCellFromCordsOrThrow(s.x,s.y,l.table),a=r.getDOMCellFromCordsOrThrow(i.x,i.y,l.table);return l.$setAnchorCellForSelection(c),l.$setFocusCellForSelection(a,!0),!0}}return!1}{let r=n(e,e=>v(e)&&!e.isInline());if(Oe(r)&&(r=n(r,mn)),!r)return!1;const i="down"===o?r.getNextSibling():r.getPreviousSibling();if(mn(i)&&l.tableNodeKey===i.getKey()){const e=i.getFirstDescendant(),n=i.getLastDescendant();if(!e||!n)return!1;const[r]=mt(e),[l]=mt(n),c=s.clone();return c.focus.set(("up"===o?r:l).getKey(),"up"===o?0:l.getChildrenSize(),"element"),tn(t),O(c),!0}}}}return"down"===o&&an(e)&&l.setShouldCheckSelection(),!1}if(w(s)){if("backward"===o||"forward"===o){return Zt(e,t,s,t.shiftKey?"extend":"move","backward"===o,r,l)}if(s.isCollapsed()){const{anchor:i,focus:c}=s,a=n(i.getNode(),Oe),u=n(c.getNode(),Oe);if(!Oe(a)||!a.is(u))return!1;const h=Qt(a);if(h!==r&&null!=h){const n=Ft(h,e.getElementByKey(h.getKey()));if(null!=n)return l.table=Ht(h,n),en(e,t,o,h,l)}const d=e.getElementByKey(a.__key),f=e.getElementByKey(i.key);if(null==f||null==d)return!1;let g;if("element"===i.type)g=f.getBoundingClientRect();else{const t=K(Ot(e));if(null===t||0===t.rangeCount)return!1;g=t.getRangeAt(0).getBoundingClientRect()}const m="up"===o?a.getFirstChild():a.getLastChild();if(null==m)return!1;const p=e.getElementByKey(m.__key);if(null==p)return!1;const C=p.getBoundingClientRect();if("up"===o?C.top>g.top-g.height:g.bottom+g.height>C.bottom){tn(t);const e=r.getCordsFromCellNode(a,l.table);if(!t.shiftKey)return Dt(l,r,e.x,e.y,o);{const t=r.getDOMCellFromCordsOrThrow(e.x,e.y,l.table);l.$setAnchorCellForSelection(t),l.$setFocusCellForSelection(t,!0)}return!0}}}else if(wt(s)){const{anchor:i,focus:c}=s,a=n(i.getNode(),Oe),u=n(c.getNode(),Oe),[h]=s.getNodes();mn(h)||Ke(251);const d=Ft(h,e.getElementByKey(h.getKey()));if(!Oe(a)||!Oe(u)||!mn(h)||null==d)return!1;l.$updateTableTableSelection(s);const f=Ht(h,d),g=r.getCordsFromCellNode(a,f),m=r.getDOMCellFromCordsOrThrow(g.x,g.y,f);if(l.$setAnchorCellForSelection(m),tn(t),t.shiftKey){const[e,t,n]=ft(r,a,u);return Yt(l,e,t,n,o)}return u.selectEnd(),!0}return!1}function tn(e){e.preventDefault(),e.stopImmediatePropagation(),e.stopPropagation()}function nn(e,t,n){const o=m();"first"===e?t.insertBefore(o):t.insertAfter(o),o.append(...n||[]),o.selectEnd()}function on(e,t,o){const r=o.getParent();if(!r)return;const l=K(Ot(e));if(!l)return;const s=l.anchorNode,i=e.getElementByKey(r.getKey()),c=Ft(o,e.getElementByKey(o.getKey()));if(!s||!i||!c||!i.contains(s)||c.contains(s))return;const a=n(t.anchor.getNode(),e=>Oe(e));if(!a)return;const u=n(a,e=>mn(e));if(!mn(u)||!u.is(o))return;const[h,d]=ft(o,a,a),f=h[0][0],g=h[h.length-1][h[0].length-1],{startRow:m,startColumn:p}=d,C=m===f.startRow&&p===f.startColumn,_=m===g.startRow&&p===g.startColumn;return C?"first":_?"last":void 0}function rn(e,t){const{tableNode:n}=e.$lookup(),o=n.getCordsFromCellNode(t,e.table);return n.getDOMCellFromCordsOrThrow(o.x,o.y,e.table)}function ln(e,t,n){return At(e,ee(t,n))}function sn(t,n,r){if(!n.theme.tableAlignment)return;const l=[],s=[];for(const e of["center","right"]){const t=n.theme.tableAlignment[e];t&&(e===r?s:l).push(t)}o(t,...l),e(t,...s)}const cn=new WeakSet;function an(e=F()){return cn.has(e)}function un(e,t){t?cn.add(e):cn.delete(e)}class hn extends u{__rowStriping;__frozenColumnCount;__frozenRowCount;__colWidths;static getType(){return"table"}getColWidths(){return this.getLatest().__colWidths}setColWidths(e){const t=this.getWritable();return t.__colWidths=e,t}static clone(e){return new hn(e.__key)}afterCloneFrom(e){super.afterCloneFrom(e),this.__colWidths=e.__colWidths,this.__rowStriping=e.__rowStriping,this.__frozenColumnCount=e.__frozenColumnCount,this.__frozenRowCount=e.__frozenRowCount}static importDOM(){return{table:e=>({conversion:fn,priority:1})}}static importJSON(e){return gn().updateFromJSON(e)}updateFromJSON(e){return super.updateFromJSON(e).setRowStriping(e.rowStriping||!1).setFrozenColumns(e.frozenColumnCount||0).setFrozenRows(e.frozenRowCount||0).setColWidths(e.colWidths)}constructor(e){super(e),this.__rowStriping=!1,this.__frozenColumnCount=0,this.__frozenRowCount=0,this.__colWidths=void 0}exportJSON(){return{...super.exportJSON(),colWidths:this.getColWidths(),frozenColumnCount:this.__frozenColumnCount?this.__frozenColumnCount:void 0,frozenRowCount:this.__frozenRowCount?this.__frozenRowCount:void 0,rowStriping:this.__rowStriping?this.__rowStriping:void 0}}extractWithChild(e,t,n){return"html"===n}getDOMSlot(e){const t=Rt(e)?e:e.querySelector("table");return Rt(t)||Ke(229),super.getDOMSlot(e).withElement(t).withAfter(t.querySelector("colgroup"))}createDOM(t,n){const o=document.createElement("table");this.__style&&(o.style.cssText=this.__style);const r=document.createElement("colgroup");if(o.appendChild(r),ge(r),e(o,t.theme.table),this.updateTableElement(null,o,t),an(n)){const n=document.createElement("div"),r=t.theme.tableScrollableWrapper;return r?e(n,r):n.style.cssText="overflow-x: auto;",n.appendChild(o),this.updateTableWrapper(null,n,o,t),n}return o}updateTableWrapper(t,n,r,l){this.__frozenColumnCount!==(t?t.__frozenColumnCount:0)&&function(t,n,r,l){l>0?(e(t,r.theme.tableFrozenColumn),n.setAttribute("data-lexical-frozen-column","true")):(o(t,r.theme.tableFrozenColumn),n.removeAttribute("data-lexical-frozen-column"))}(n,r,l,this.__frozenColumnCount),this.__frozenRowCount!==(t?t.__frozenRowCount:0)&&function(t,n,r,l){l>0?(e(t,r.theme.tableFrozenRow),n.setAttribute("data-lexical-frozen-row","true")):(o(t,r.theme.tableFrozenRow),n.removeAttribute("data-lexical-frozen-row"))}(n,r,l,this.__frozenRowCount)}updateTableElement(t,n,r){this.__style!==(t?t.__style:"")&&(n.style.cssText=this.__style),this.__rowStriping!==(!!t&&t.__rowStriping)&&function(t,n,r){r?(e(t,n.theme.tableRowStriping),t.setAttribute("data-lexical-row-striping","true")):(o(t,n.theme.tableRowStriping),t.removeAttribute("data-lexical-row-striping"))}(n,r,this.__rowStriping),function(e,t,n,o){const r=e.querySelector("colgroup");if(!r)return;const l=[];for(let e=0;e{if(t.after&&(n=t.after(n)),!Rt(n)&&l(n)&&(n=n.querySelector("table")),!Rt(n))return null;sn(n,e._config,this.getFormatType());const[o]=gt(this,null,null),r=new Map;for(const e of o)for(const t of e){const e=t.cell.getKey();r.has(e)||r.set(e,{colSpan:t.cell.getColSpan(),startColumn:t.startColumn})}const s=new Set;for(const e of n.querySelectorAll(":scope > tr > [data-temporary-table-cell-lexical-key]")){const t=e.getAttribute("data-temporary-table-cell-lexical-key");if(t){const n=r.get(t);if(e.removeAttribute("data-temporary-table-cell-lexical-key"),n){r.delete(t);for(let e=0;e colgroup");if(i){const e=Array.from(n.querySelectorAll(":scope > colgroup > col")).filter((e,t)=>s.has(t));i.replaceChildren(...e)}const c=n.querySelectorAll(":scope > tr");if(c.length>0){const e=document.createElement("tbody");for(const t of c)e.appendChild(t);n.append(e)}return n},element:!Rt(n)&&l(n)?n.querySelector("table"):n}}canBeEmpty(){return!1}isShadowRoot(){return!0}getCordsFromCellNode(e,t){const{rows:n,domRows:o}=t;for(let t=0;t{Oe(e)&&(t+=e.getColSpan())}),t}}function dn(e,t){const n=e.getElementByKey(t.getKey());return null===n&&Ke(230),Ht(t,n)}function fn(e){const n=gn();e.hasAttribute("data-lexical-row-striping")&&n.setRowStriping(!0),e.hasAttribute("data-lexical-frozen-column")&&n.setFrozenColumns(1),e.hasAttribute("data-lexical-frozen-row")&&n.setFrozenRows(1);const o=e.querySelector(":scope > colgroup");if(o){let e=[];for(const t of o.querySelectorAll(":scope > col")){let n=t.style.width||"";if(!Ne.test(n)&&(n=t.getAttribute("width")||"",!/^\d+$/.test(n))){e=void 0;break}e.push(parseFloat(n))}e&&n.setColWidths(e)}return{after:e=>t(e,$e),node:n}}function gn(){return p(new hn)}function mn(e){return e instanceof hn}function pn({rows:e,columns:t,includeHeaders:n}){const o=S()||Z();if(!o||!w(o))return!1;if(Qt(o.anchor.getNode()))return!1;const r=Le(Number(e),Number(t),n);c(r);const l=r.getFirstDescendant();return f(l)&&l.select(),!0}function Cn(e){$e(e.getParent())?e.isEmpty()&&e.append(m()):e.remove()}function _n(e){mn(e.getParent())?a(e,Oe):e.remove()}function Sn(e){a(e,$e);const[t]=gt(e,null,null),n=t.reduce((e,t)=>Math.max(e,t.length),0),o=e.getChildren();for(let e=0;et?1+e:e,0);if(l!==n)for(let e=l;ev(e)&&!e.isInline());if(null===o)return!1;return!!Oe(o.getParent())&&(o.select(0),!0)}function bn(e){return e.registerNodeTransform(xe,e=>{if(e.getColSpan()>1||e.getRowSpan()>1){const[,,t]=mt(e),[n]=ft(t,e,e),o=n.length,r=n[0].length;let l=t.getFirstChild();$e(l)||Ke(175);const i=[];for(let e=0;e1||c.getRowSpan()>1){Oe(c)||Ke(176);const e=Fe(c.__headerState);null!==t?t.insertAfter(e):s(l,e)}}}for(const e of i)e.setColSpan(1),e.setRowSpan(1)}})}function yn(e,t=!0){const n=new Map,o=(o,r,l)=>{const s=Ft(o,l),i=Mt(o,s,e,t);n.set(r,[i,s])},r=e.registerMutationListener(hn,t=>{e.getEditorState().read(()=>{for(const[e,r]of t){const t=n.get(e);if("created"===r||"updated"===r){const{tableNode:r,tableElement:l}=vt(e);void 0===t?o(r,e,l):l!==t[1]&&(t[0].removeListeners(),n.delete(e),o(r,e,l))}else"destroyed"===r&&void 0!==t&&(t[0].removeListeners(),n.delete(e))}},{editor:e})},{skipInitialization:!1});return()=>{r();for(const[,[e]]of n)e.removeListeners()}}function Nn(e){return e.hasNodes([hn])||Ke(255),i(e.registerCommand(Ae,pn,me),e.registerCommand(Q,({nodes:t,selection:n},o)=>{if(e!==o||!w(n))return!1;return null!==Qt(n.anchor.getNode())&&t.some(mn)},me),e.registerCommand(pe,wn,me),e.registerNodeTransform(hn,Sn),e.registerNodeTransform(Ee,_n),e.registerNodeTransform(xe,Cn))}const vn=Ce({build:(e,t,n)=>we(t),config:_e({hasCellBackgroundColor:!0,hasCellMerge:!0,hasHorizontalScroll:!0,hasTabHandler:!0}),name:"@lexical/table/Table",nodes:[hn,Ee,xe],register(e,t,n){const o=n.getOutput();return i(Se(()=>{const t=o.hasHorizontalScroll.value;an(e)!==t&&(un(e,t),e.registerNodeTransform(hn,()=>{})())}),Nn(e),Se(()=>yn(e,o.hasTabHandler.value)),Se(()=>o.hasCellMerge.value?void 0:bn(e)),Se(()=>o.hasCellBackgroundColor.value?void 0:e.registerNodeTransform(xe,e=>{null!==e.getBackgroundColor()&&e.setBackgroundColor(null)})))}});export{ft as $computeTableMap,gt as $computeTableMapSkipCellCheck,Fe as $createTableCellNode,gn as $createTableNode,Le as $createTableNodeWithDimensions,Me as $createTableRowNode,bt as $createTableSelection,yt as $createTableSelectionFrom,nt as $deleteTableColumn,lt as $deleteTableColumnAtSelection,st as $deleteTableColumn__EXPERIMENTAL,ot as $deleteTableRowAtSelection,rt as $deleteTableRow__EXPERIMENTAL,Gt as $findCellNode,Qt as $findTableNode,dn as $getElementForTableNode,mt as $getNodeTriplet,vt as $getTableAndElementByKey,Be as $getTableCellNodeFromLexicalNode,Ct as $getTableCellNodeRect,Ue as $getTableColumnIndexFromTableCellNode,De as $getTableNodeFromLexicalNodeOrThrow,Ie as $getTableRowIndexFromTableCellNode,Pe as $getTableRowNodeFromTableCellNodeOrThrow,Qe as $insertTableColumn,Ze as $insertTableColumnAtSelection,et as $insertTableColumn__EXPERIMENTAL,Xe as $insertTableRow,je as $insertTableRowAtSelection,Ve as $insertTableRow__EXPERIMENTAL,an as $isScrollableTablesActive,Oe as $isTableCellNode,mn as $isTableNode,$e as $isTableRowNode,wt as $isTableSelection,at as $mergeCells,Ye as $removeTableRowAtIndex,ht as $unmergeCell,Ae as INSERT_TABLE_COMMAND,ve as TableCellHeaderStates,xe as TableCellNode,vn as TableExtension,hn as TableNode,xt as TableObserver,Ee as TableRowNode,Mt as applyTableHandlers,zt as getDOMCellFromTarget,Ft as getTableElement,$t as getTableObserverFromTableElement,bn as registerTableCellUnmergeTransform,Nn as registerTablePlugin,yn as registerTableSelectionObserver,un as setScrollableTablesActive}; ++import{addClassNamesToElement as e,$descendantsMatching as t,$findMatchingParent as n,removeClassNamesFromElement as o,objectKlassEquals as r,isHTMLElement as l,$insertFirst as s,mergeRegister as i,$insertNodeToNearestRoot as c,$unwrapAndFilterDescendants as a}from"@lexical/utils";import{ElementNode as u,isHTMLElement as h,$isInlineElementOrDecoratorNode as d,$isTextNode as f,$isLineBreakNode as g,$createParagraphNode as m,$applyNodeReplacement as p,createCommand as C,$createTextNode as _,$getSelection as S,$isRangeSelection as w,$isParagraphNode as b,$createPoint as y,$getNodeByKey as N,$isElementNode as v,$normalizeSelection__EXPERIMENTAL as x,isCurrentlyReadOnlyMode as T,TEXT_TYPE_TO_FORMAT as R,$getEditor as F,$setSelection as O,SELECTION_CHANGE_COMMAND as A,getDOMSelectionForEditor as K,$createRangeSelection as k,$isRootNode as E,INSERT_PARAGRAPH_COMMAND as M,KEY_ARROW_DOWN_COMMAND as $,KEY_ARROW_UP_COMMAND as W,KEY_ARROW_LEFT_COMMAND as z,KEY_ARROW_RIGHT_COMMAND as H,COMMAND_PRIORITY_HIGH as L,KEY_ESCAPE_COMMAND as B,DELETE_WORD_COMMAND as P,DELETE_LINE_COMMAND as D,DELETE_CHARACTER_COMMAND as I,KEY_BACKSPACE_COMMAND as U,KEY_DELETE_COMMAND as J,CUT_COMMAND as Y,FORMAT_TEXT_COMMAND as X,FORMAT_ELEMENT_COMMAND as q,CONTROLLED_TEXT_INSERTION_COMMAND as j,KEY_TAB_COMMAND as V,FOCUS_COMMAND as G,SELECTION_INSERT_CLIPBOARD_NODES_COMMAND as Q,$getPreviousSelection as Z,$getNearestNodeFromDOMNode as ee,$createRangeSelectionFromDom as te,isDOMNode as ne,$isRootOrShadowRoot as oe,$caretFromPoint as re,$isExtendableTextPointCaret as le,$extendCaretToRange as se,$isSiblingCaret as ie,$getSiblingCaret as ce,$setPointFromCaret as ae,$normalizeCaret as ue,$isChildCaret as he,$getChildCaret as de,$getAdjacentChildCaret as fe,setDOMUnmanaged as ge,COMMAND_PRIORITY_EDITOR as me,CLICK_COMMAND as pe,defineExtension as Ce,safeCast as _e}from"lexical";import{signal as Se,effect as we,namedSignals as be}from"@lexical/extension";import{copyToClipboard as ye,$getClipboardDataFromSelection as Ne}from"@lexical/clipboard";const ve=/^(\d+(?:\.\d+)?)px$/,xe={BOTH:3,COLUMN:2,NO_STATUS:0,ROW:1};class Te extends u{__colSpan;__rowSpan;__headerState;__width;__backgroundColor;__verticalAlign;static getType(){return"tablecell"}static clone(e){return new Te(e.__headerState,e.__colSpan,e.__width,e.__key)}afterCloneFrom(e){super.afterCloneFrom(e),this.__rowSpan=e.__rowSpan,this.__backgroundColor=e.__backgroundColor,this.__verticalAlign=e.__verticalAlign}static importDOM(){return{td:e=>({conversion:Fe,priority:0}),th:e=>({conversion:Fe,priority:0})}}static importJSON(e){return Oe().updateFromJSON(e)}updateFromJSON(e){return super.updateFromJSON(e).setHeaderStyles(e.headerState).setColSpan(e.colSpan||1).setRowSpan(e.rowSpan||1).setWidth(e.width||void 0).setBackgroundColor(e.backgroundColor||null).setVerticalAlign(e.verticalAlign||void 0)}constructor(e=xe.NO_STATUS,t=1,n,o){super(o),this.__colSpan=t,this.__rowSpan=1,this.__headerState=e,this.__width=n,this.__backgroundColor=null,this.__verticalAlign=void 0}createDOM(t){const n=document.createElement(this.getTag());return this.__width&&(n.style.width=`${this.__width}px`),this.__colSpan>1&&(n.colSpan=this.__colSpan),this.__rowSpan>1&&(n.rowSpan=this.__rowSpan),null!==this.__backgroundColor&&(n.style.backgroundColor=this.__backgroundColor),Re(this.__verticalAlign)&&(n.style.verticalAlign=this.__verticalAlign),e(n,t.theme.tableCell,this.hasHeader()&&t.theme.tableCellHeader),n}exportDOM(e){const t=super.exportDOM(e);if(h(t.element)){const e=t.element;e.setAttribute("data-temporary-table-cell-lexical-key",this.getKey()),e.style.border="1px solid black",this.__colSpan>1&&(e.colSpan=this.__colSpan),this.__rowSpan>1&&(e.rowSpan=this.__rowSpan),e.style.width=`${this.getWidth()||75}px`,e.style.verticalAlign=this.getVerticalAlign()||"top",e.style.textAlign="start",null===this.__backgroundColor&&this.hasHeader()&&(e.style.backgroundColor="#f2f3f5")}return t}exportJSON(){return{...super.exportJSON(),...Re(this.__verticalAlign)&&{verticalAlign:this.__verticalAlign},backgroundColor:this.getBackgroundColor(),colSpan:this.__colSpan,headerState:this.__headerState,rowSpan:this.__rowSpan,width:this.getWidth()}}getColSpan(){return this.getLatest().__colSpan}setColSpan(e){const t=this.getWritable();return t.__colSpan=e,t}getRowSpan(){return this.getLatest().__rowSpan}setRowSpan(e){const t=this.getWritable();return t.__rowSpan=e,t}getTag(){return this.hasHeader()?"th":"td"}setHeaderStyles(e,t=xe.BOTH){const n=this.getWritable();return n.__headerState=e&t|n.__headerState&~t,n}getHeaderStyles(){return this.getLatest().__headerState}setWidth(e){const t=this.getWritable();return t.__width=e,t}getWidth(){return this.getLatest().__width}getBackgroundColor(){return this.getLatest().__backgroundColor}setBackgroundColor(e){const t=this.getWritable();return t.__backgroundColor=e,t}getVerticalAlign(){return this.getLatest().__verticalAlign}setVerticalAlign(e){const t=this.getWritable();return t.__verticalAlign=e||void 0,t}toggleHeaderStyle(e){const t=this.getWritable();return(t.__headerState&e)===e?t.__headerState-=e:t.__headerState+=e,t}hasHeaderState(e){return(this.getHeaderStyles()&e)===e}hasHeader(){return this.getLatest().__headerState!==xe.NO_STATUS}updateDOM(e){return e.__headerState!==this.__headerState||e.__width!==this.__width||e.__colSpan!==this.__colSpan||e.__rowSpan!==this.__rowSpan||e.__backgroundColor!==this.__backgroundColor||e.__verticalAlign!==this.__verticalAlign}isShadowRoot(){return!0}collapseAtStart(){return!0}canBeEmpty(){return!1}canIndent(){return!1}}function Re(e){return"middle"===e||"bottom"===e}function Fe(e){const t=e,n=e.nodeName.toLowerCase();let o;ve.test(t.style.width)&&(o=parseFloat(t.style.width));const r=Oe("th"===n?xe.ROW:xe.NO_STATUS,t.colSpan,o);r.__rowSpan=t.rowSpan;const l=t.style.backgroundColor;""!==l&&(r.__backgroundColor=l);const s=t.style.verticalAlign;Re(s)&&(r.__verticalAlign=s);const i=t.style,c=(i&&i.textDecoration||"").split(" "),a="700"===i.fontWeight||"bold"===i.fontWeight,u=c.includes("line-through"),h="italic"===i.fontStyle,p=c.includes("underline");return{after:e=>{const t=[];let n=null;const o=()=>{if(n){const e=n.getFirstChild();g(e)&&1===n.getChildrenSize()&&e.remove()}};for(const r of e)d(r)||f(r)||g(r)?(f(r)&&(a&&r.toggleFormat("bold"),u&&r.toggleFormat("strikethrough"),h&&r.toggleFormat("italic"),p&&r.toggleFormat("underline")),n?n.append(r):(n=m().append(r),t.push(n))):(t.push(r),o(),n=null);return o(),0===t.length&&t.push(m()),t},node:r}}function Oe(e=xe.NO_STATUS,t=1,n){return p(new Te(e,t,n))}function Ae(e){return e instanceof Te}const Ke=C("INSERT_TABLE_COMMAND");function ke(e,...t){const n=new URL("https://lexical.dev/docs/error"),o=new URLSearchParams;o.append("code",e);for(const e of t)o.append("v",e);throw n.search=o.toString(),Error(`Minified Lexical error #${e}; visit ${n.toString()} for the full message or use the non-minified dev environment for full errors and additional helpful warnings.`)}class Ee extends u{__height;static getType(){return"tablerow"}static clone(e){return new Ee(e.__height,e.__key)}static importDOM(){return{tr:e=>({conversion:Me,priority:0})}}static importJSON(e){return $e().updateFromJSON(e)}updateFromJSON(e){return super.updateFromJSON(e).setHeight(e.height)}constructor(e,t){super(t),this.__height=e}exportJSON(){const e=this.getHeight();return{...super.exportJSON(),...void 0===e?void 0:{height:e}}}createDOM(t){const n=document.createElement("tr");return this.__height&&(n.style.height=`${this.__height}px`),e(n,t.theme.tableRow),n}extractWithChild(e,t,n){return"html"===n}isShadowRoot(){return!0}setHeight(e){const t=this.getWritable();return t.__height=e,t}getHeight(){return this.getLatest().__height}updateDOM(e){return e.__height!==this.__height}canBeEmpty(){return!1}canIndent(){return!1}}function Me(e){const n=e;let o;return ve.test(n.style.height)&&(o=parseFloat(n.style.height)),{after:e=>t(e,Ae),node:$e(o)}}function $e(e){return p(new Ee(e))}function We(e){return e instanceof Ee}const ze="undefined"!=typeof window&&void 0!==window.document&&void 0!==window.document.createElement,He=ze&&"documentMode"in document?document.documentMode:null,Le=ze&&/^(?!.*Seamonkey)(?=.*Firefox).*/i.test(navigator.userAgent);function Be(e,t,n=!0){const o=gn();for(let r=0;rAe(e));return Ae(t)?t:null}function De(e){const t=n(e,e=>We(e));if(We(t))return t;throw new Error("Expected table cell to be inside of table row.")}function Ie(e){const t=n(e,e=>mn(e));if(mn(t))return t;throw new Error("Expected table cell to be inside of table.")}function Ue(e){const t=De(e);return Ie(t).getChildren().findIndex(e=>e.is(t))}function Je(e){return De(e).getChildren().findIndex(t=>t.is(e))}function Ye(e,t){const n=Ie(e),{x:o,y:r}=n.getCordsFromCellNode(e,t);return{above:n.getCellNodeFromCords(o,r-1,t),below:n.getCellNodeFromCords(o,r+1,t),left:n.getCellNodeFromCords(o-1,r,t),right:n.getCellNodeFromCords(o+1,r,t)}}function Xe(e,t){const n=e.getChildren();if(t>=n.length||t<0)throw new Error("Expected table cell to be inside of table row.");return n[t].remove(),e}function qe(e,t,n=!0,o,r){const l=e.getChildren();if(t>=l.length||t<0)throw new Error("Table row target index out of range");const s=l[t];if(!We(s))throw new Error("Row before insertion index does not exist.");for(let e=0;ee===xe.BOTH||e===t?t:xe.NO_STATUS;function Ve(e=!0){const t=S();w(t)||bt(t)||ke(188);const n=t.anchor.getNode(),o=t.focus.getNode(),[r]=pt(n),[l,,s]=pt(o),[,i,c]=gt(s,l,r),{startRow:a}=c,{startRow:u}=i;return e?Qe(a+r.__rowSpan>u+l.__rowSpan?r:l,!0):Qe(u=e.length||t<0)throw new Error("Table column target index out of range");const o=e[t];Ae(o)||ke(12);const{left:l,right:i}=Ye(o,r);let c=xe.NO_STATUS;(l&&l.hasHeaderState(xe.ROW)||i&&i.hasHeaderState(xe.ROW))&&(c|=xe.ROW);const a=Oe(c);a.append(m()),s.push({newTableCell:a,targetCell:o})}}return s.forEach(({newTableCell:e,targetCell:t})=>{n?t.insertAfter(e):t.insertBefore(e)}),e}function et(e=!0){const t=S();w(t)||bt(t)||ke(188);const n=t.anchor.getNode(),o=t.focus.getNode(),[r]=pt(n),[l,,s]=pt(o),[,i,c]=gt(s,l,r),{startColumn:a}=c,{startColumn:u}=i;return e?nt(a+r.__colSpan>u+l.__colSpan?r:l,!0):nt(u1;){if(s-=l.__colSpan,!(s>=0)){d.append(h(o));continue e}{const{cell:e,startRow:o}=t[s];n=e,r=o}}n.insertAfter(h(o))}else l.setColSpan(l.__colSpan+1)}null!==u&&n&&ct(u);const f=o.getColWidths();if(f){const e=[...f],t=c<0?0:c,n=e[t];e.splice(t,0,n),o.setColWidths(e)}return u}function ot(e,t){const n=e.getChildren();for(let e=0;e=e.length||t<0)throw new Error("Table column target index out of range");e[t].remove()}}return e}function rt(){const e=S();w(e)||bt(e)||ke(188);const[t,n]=e.isBackward()?[e.focus.getNode(),e.anchor.getNode()]:[e.anchor.getNode(),e.focus.getNode()],[o,,r]=pt(t),[l]=pt(n),[s,i,c]=gt(r,o,l),{startRow:a}=i,{startRow:u}=c,h=u+l.__rowSpan-1;if(s.length===h-a+1)return void r.remove();const d=s[0].length,f=s[h+1],g=r.getChildAtIndex(h+1);for(let e=h;e>=a;e--){for(let t=d-1;t>=0;t--){const{cell:n,startRow:o,startColumn:r}=s[e][t];if(r===t){if(oh){const e=Math.max(o,a),t=Math.min(n.__rowSpan+o-1,h),r=e<=t?t-e+1:0;n.setRowSpan(n.__rowSpan-r)}if(o>=a&&o+n.__rowSpan-1>h&&e===h){null===g&&ke(122);let o=null;for(let n=0;n1&&(n+=r.__colSpan-1)}null===o?at(g,n):o.insertAfter(n)}}}const t=r.getChildAtIndex(e);We(t)||ke(206,String(e)),t.remove()}if(void 0!==f){const{cell:e}=f[0];ct(e)}else{const e=s[a-1],{cell:t}=e[0];ct(t)}}const lt=rt;function st(){const e=S();w(e)||bt(e)||ke(188);const t=e.anchor.getNode(),n=e.focus.getNode(),[o,,r]=pt(t),[l]=pt(n),[s,i,c]=gt(r,o,l),{startColumn:a}=i,{startRow:u,startColumn:h}=c,d=Math.min(a,h),f=Math.max(a+o.__colSpan-1,h+l.__colSpan-1),g=f-d+1;if(s[0].length===f-d+1)return r.selectPrevious(),void r.remove();const m=s.length;for(let e=0;ef){if(t===f){const e=f-o+1;n.setColSpan(n.__colSpan-e)}}else n.remove()}const p=s[u],C=a>h?p[a+o.__colSpan]:p[h+l.__colSpan];if(void 0!==C){const{cell:e}=C;ct(e)}else{const e=he.is(n.cell))){i.add(t);const e=n.startRow,c=n.startColumn,a=n.cell.__rowSpan||1,u=n.cell.__colSpan||1;o=Math.min(o,e),r=Math.max(r,e+a-1),l=Math.min(l,c),s=Math.max(s,c+u-1)}}if(o===1/0||l===1/0)return null;const c=r-o+1,a=s-l+1,u=n[o][l];if(!u.cell)return null;const h=u.cell;h.setColSpan(a),h.setRowSpan(c);const d=new Set([h.getKey()]);for(let e=o;e<=r;e++)for(let t=l;t<=s;t++){const o=n[e][t];if(!o.cell)continue;const r=o.cell,l=r.getKey();if(!d.has(l)){d.add(l);ht(r)||h.append(...r.getChildren()),r.remove()}}return 0===h.getChildrenSize()&&h.append(m()),h}function ht(e){if(1!==e.getChildrenSize())return!1;const t=e.getFirstChildOrThrow();return!(!b(t)||!t.isEmpty())}function dt(){const e=S();w(e)||bt(e)||ke(188);const t=e.anchor.getNode(),o=n(t,Ae);return Ae(o)||ke(148),ft(o)}function ft(e){const[t,n,o]=pt(e),r=t.__colSpan,l=t.__rowSpan;if(1===r&&1===l)return;const[s,i]=gt(o,t,t),{startColumn:c,startRow:a}=i,u=t.__headerState&xe.COLUMN,h=Array.from({length:r},(e,t)=>{let n=u;for(let e=0;0!==n&&e{let n=d;for(let e=0;0!==n&&e1){for(let e=1;e1){let e;for(let t=1;t1&&(e+=n.__colSpan-1)}if(null===i)for(let n=r-1;n>=0;n--)at(e,Oe(h[n]|f[t]).append(m()));else for(let e=r-1;e>=0;e--)i.insertAfter(Oe(h[e]|f[t]).append(m()))}t.setRowSpan(1)}}function gt(e,t,n){const[o,r,l]=mt(e,t,n);return null===r&&ke(207),null===l&&ke(208),[o,r,l]}function mt(e,t,n){const o=[];let r=null,l=null;function s(e){let t=o[e];return void 0===t&&(o[e]=t=[]),t}const i=e.getChildren();for(let e=0;e=i.length);t++){const n=s(e+t);for(let e=0;e=r,d=c.startRow<=i&&u>=l;if(h&&d){const e=Math.min(r,c.startColumn),t=Math.max(s,a),n=Math.min(l,c.startRow),h=Math.max(i,u);e===r&&t===s&&n===l&&h===i||(r=e,s=t,l=n,i=h,o=!0)}}}while(o);return{maxColumn:s,maxRow:i,minColumn:r,minRow:l}}function _t(e){const[t,,n]=pt(e),o=n.getChildren(),r=o.length,l=o[0].getChildren().length,s=new Array(r);for(let e=0;e{const o=e[t].getNode(),r=n(o,Ae);Ae(r)||ke(238,t,o.getKey(),o.getType());const l=r.getParent();We(l)||ke(239,t);const s=l.getParent();return mn(s)||ke(240,t),[o,r,l,s]});return l.is(a)||ke(241),{anchorCell:o,anchorNode:t,anchorRow:r,anchorTable:l,focusCell:i,focusNode:s,focusRow:c,focusTable:a}}class wt{tableKey;anchor;focus;_cachedNodes;dirty;constructor(e,t,n){this.anchor=t,this.focus=n,t._selection=this,n._selection=this,this._cachedNodes=null,this.dirty=!1,this.tableKey=e}getStartEndPoints(){return[this.anchor,this.focus]}isValid(){if("root"===this.tableKey||"root"===this.anchor.key||"element"!==this.anchor.type||"root"===this.focus.key||"element"!==this.focus.type)return!1;const e=N(this.tableKey),t=N(this.anchor.key),n=N(this.focus.key);return null!==e&&null!==t&&null!==n}isBackward(){return this.focus.isBefore(this.anchor)}getCachedNodes(){return this._cachedNodes}setCachedNodes(e){this._cachedNodes=e}is(e){return bt(e)&&this.tableKey===e.tableKey&&this.anchor.is(e.anchor)&&this.focus.is(e.focus)}set(e,t,n){this.dirty=this.dirty||e!==this.tableKey||t!==this.anchor.key||n!==this.focus.key,this.tableKey=e,this.anchor.key=t,this.focus.key=n,this._cachedNodes=null}clone(){return new wt(this.tableKey,y(this.anchor.key,this.anchor.offset,this.anchor.type),y(this.focus.key,this.focus.offset,this.focus.type))}isCollapsed(){return!1}extract(){return this.getNodes()}insertRawText(e){}insertText(){}hasFormat(e){let t=0;this.getNodes().filter(Ae).forEach(e=>{const n=e.getFirstChild();b(n)&&(t|=n.getTextFormat())});const n=R[e];return 0!==(t&n)}insertNodes(e){const t=this.focus.getNode();v(t)||ke(151);x(t.select(0,t.getChildrenSize())).insertNodes(e)}getShape(){const{anchorCell:e,focusCell:t}=St(this),n=_t(e);null===n&&ke(153);const o=_t(t);null===o&&ke(155);const r=Math.min(n.columnIndex,o.columnIndex),l=Math.max(n.columnIndex+n.colSpan-1,o.columnIndex+o.colSpan-1),s=Math.min(n.rowIndex,o.rowIndex),i=Math.max(n.rowIndex+n.rowSpan-1,o.rowIndex+o.rowSpan-1);return{fromX:Math.min(r,l),fromY:Math.min(s,i),toX:Math.max(r,l),toY:Math.max(s,i)}}getNodes(){if(!this.isValid())return[];const e=this._cachedNodes;if(null!==e)return e;const{anchorTable:t,anchorCell:n,focusCell:o}=St(this),r=o.getParents()[1];if(r!==t){if(t.isParentOf(o)){const e=r.getParent();null==e&&ke(159),this.set(this.tableKey,o.getKey(),e.getKey())}else{const e=t.getParent();null==e&&ke(158),this.set(this.tableKey,e.getKey(),o.getKey())}return this.getNodes()}const[l,s,i]=gt(t,n,o),{minColumn:c,maxColumn:a,minRow:u,maxRow:h}=Ct(l,s,i),d=new Map([[t.getKey(),t]]);let f=null;for(let e=u;e<=h;e++)for(let t=c;t<=a;t++){const{cell:n}=l[e][t],o=n.getParent();We(o)||ke(160),o!==f&&(d.set(o.getKey(),o),f=o),d.has(n.getKey())||vt(n,e=>{d.set(e.getKey(),e)})}const g=Array.from(d.values());return T()||(this._cachedNodes=g),g}getTextContent(){const e=this.getNodes().filter(e=>Ae(e));let t="";for(let n=0;n0;e=n.at(-1)){const o=e.pop();void 0===o?n.pop():!1!==t(o)&&v(o)&&n.push(o.getChildren())}}function xt(e,t=F()){const n=N(e);mn(n)||ke(231,e);const o=Ot(n,t.getElementByKey(e));return null===o&&ke(232,e),{tableElement:o,tableNode:n}}class Tt{focusX;focusY;listenersToRemove;table;isHighlightingCells;anchorX;anchorY;tableNodeKey;anchorCell;focusCell;anchorCellNodeKey;focusCellNodeKey;editor;tableSelection;hasHijackedSelectionStyles;isSelecting;pointerType;shouldCheckSelection;abortController;listenerOptions;nextFocus;constructor(e,t){this.isHighlightingCells=!1,this.anchorX=-1,this.anchorY=-1,this.focusX=-1,this.focusY=-1,this.listenersToRemove=new Set,this.tableNodeKey=t,this.editor=e,this.table={columns:0,domRows:[],rows:0},this.tableSelection=null,this.anchorCellNodeKey=null,this.focusCellNodeKey=null,this.anchorCell=null,this.focusCell=null,this.hasHijackedSelectionStyles=!1,this.isSelecting=!1,this.pointerType=null,this.shouldCheckSelection=!1,this.abortController=new AbortController,this.listenerOptions={signal:this.abortController.signal},this.nextFocus=null,this.trackTable()}getTable(){return this.table}removeListeners(){this.abortController.abort("removeListeners"),Array.from(this.listenersToRemove).forEach(e=>e()),this.listenersToRemove.clear()}$lookup(){return xt(this.tableNodeKey,this.editor)}trackTable(){const e=new MutationObserver(e=>{this.editor.getEditorState().read(()=>{let t=!1;for(let n=0;n{const{tableNode:t,tableElement:n}=this.$lookup();this.table=Ht(t,n),e.observe(n,{attributes:!0,childList:!0,subtree:!0})},{editor:this.editor})}$clearHighlight(){const e=this.editor;this.isHighlightingCells=!1,this.anchorX=-1,this.anchorY=-1,this.focusX=-1,this.focusY=-1,this.tableSelection=null,this.anchorCellNodeKey=null,this.focusCellNodeKey=null,this.anchorCell=null,this.focusCell=null,this.hasHijackedSelectionStyles=!1,this.$enableHighlightStyle();const{tableNode:t,tableElement:n}=this.$lookup();Lt(e,Ht(t,n),null),null!==S()&&(O(null),e.dispatchCommand(A,void 0))}$enableHighlightStyle(){const e=this.editor,{tableElement:t}=this.$lookup();o(t,e._config.theme.tableSelection),t.classList.remove("disable-selection"),this.hasHijackedSelectionStyles=!1}$disableHighlightStyle(){const{tableElement:t}=this.$lookup();e(t,this.editor._config.theme.tableSelection),this.hasHijackedSelectionStyles=!0}$updateTableTableSelection(e){if(null!==e){e.tableKey!==this.tableNodeKey&&ke(233,e.tableKey,this.tableNodeKey);const t=this.editor;this.tableSelection=e,this.isHighlightingCells=!0,this.$disableHighlightStyle(),this.updateDOMSelection(),Lt(t,this.table,this.tableSelection)}else this.$clearHighlight()}setShouldCheckSelection(){this.shouldCheckSelection=!0}getAndClearShouldCheckSelection(){return!!this.shouldCheckSelection&&(this.shouldCheckSelection=!1,!0)}setNextFocus(e){this.nextFocus=e}getAndClearNextFocus(){const{nextFocus:e}=this;return null!==e&&(this.nextFocus=null),e}updateDOMSelection(){if(null!==this.anchorCell&&null!==this.focusCell){const e=K(this.editor);e&&e.rangeCount>0&&e.removeAllRanges()}}$setFocusCellForSelection(e,t=!1){const n=this.editor,{tableNode:o}=this.$lookup(),r=e.x,l=e.y;if(this.focusCell=e,this.isHighlightingCells||this.anchorX===r&&this.anchorY===l&&!t){if(r===this.focusX&&l===this.focusY)return!1}else this.isHighlightingCells=!0,this.$disableHighlightStyle();if(this.focusX=r,this.focusY=l,this.isHighlightingCells){const t=ln(o,e.elem);if(null!=this.tableSelection&&null!=this.anchorCellNodeKey&&null!==t)return this.focusCellNodeKey=t.getKey(),this.tableSelection=Nt(o,this.$getAnchorTableCellOrThrow(),t),O(this.tableSelection),n.dispatchCommand(A,void 0),Lt(n,this.table,this.tableSelection),!0}return!1}$getAnchorTableCell(){return this.anchorCellNodeKey?N(this.anchorCellNodeKey):null}$getAnchorTableCellOrThrow(){const e=this.$getAnchorTableCell();return null===e&&ke(234),e}$getFocusTableCell(){return this.focusCellNodeKey?N(this.focusCellNodeKey):null}$getFocusTableCellOrThrow(){const e=this.$getFocusTableCell();return null===e&&ke(235),e}$setAnchorCellForSelection(e){this.isHighlightingCells=!1,this.anchorCell=e,this.anchorX=e.x,this.anchorY=e.y;const{tableNode:t}=this.$lookup(),n=ln(t,e.elem);if(null!==n){const e=n.getKey();this.tableSelection=null!=this.tableSelection?this.tableSelection.clone():yt(),this.anchorCellNodeKey=e}}$formatCells(e){const t=S();bt(t)||ke(236);const n=k(),o=n.anchor,r=n.focus,l=t.getNodes().filter(Ae);l.length>0||ke(237);const s=l[0].getFirstChild(),i=b(s)?s.getFormatFlags(e,null):null;l.forEach(t=>{o.set(t.getKey(),0,"element"),r.set(t.getKey(),t.getChildrenSize(),"element"),n.formatText(e,i)}),O(t),this.editor.dispatchCommand(A,void 0)}$clearText(){const{editor:e}=this,t=N(this.tableNodeKey);if(!mn(t))throw new Error("Expected TableNode.");const n=S();bt(n)||ke(253);const o=n.getNodes().filter(Ae),r=t.getFirstChild(),l=t.getLastChild();if(o.length>0&&null!==r&&null!==l&&We(r)&&We(l)&&o[0]===r.getFirstChild()&&o[o.length-1]===l.getLastChild()){t.selectPrevious();const n=t.getParent();return t.remove(),void(E(n)&&n.isEmpty()&&e.dispatchCommand(M,void 0))}o.forEach(e=>{if(v(e)){const t=m(),n=_();t.append(n),e.append(t),e.getChildren().forEach(e=>{e!==t&&e.remove()})}}),Lt(e,this.table,null),O(null),e.dispatchCommand(A,void 0)}}const Rt="__lexicalTableSelection";function Ft(e){return h(e)&&"TABLE"===e.nodeName}function Ot(e,t){if(!t)return t;const n=Ft(t)?t:e.getDOMSlot(t).element;return"TABLE"!==n.nodeName&&ke(245,t.nodeName),n}function At(e,t){for(let n=t,o=null;null!==n;n=n.getParent()){if(e.is(n))return o;Ae(n)&&(o=n)}return null}const Kt=[[$,"down"],[W,"up"],[z,"backward"],[H,"forward"]],kt=[P,D,I],Et=[U,J];function Mt(e,t,o,l){const s=o.getRootElement(),i=function(e){return e._window}(o);null!==s&&null!==i||ke(246);const c=new Tt(o,e.getKey()),a=Ot(e,t);!function(e,t){null!==$t(e)&&ke(205);e[Rt]=t}(a,c),c.listenersToRemove.add(()=>function(e,t){$t(e)===t&&delete e[Rt]}(a,c));const u=t=>{if(c.pointerType=t.pointerType,0!==t.button||!ne(t.target)||!i)return;const n=Wt(t.target);null!==n&&o.update(()=>{const o=Z();if(Le&&t.shiftKey&&Xt(o,e)&&(w(o)||bt(o))){const r=o.anchor.getNode(),l=At(e,o.anchor.getNode());if(l)c.$setAnchorCellForSelection(rn(c,l)),c.$setFocusCellForSelection(n),tn(t);else{(e.isBefore(r)?e.selectStart():e.selectEnd()).anchor.set(o.anchor.key,o.anchor.offset,o.anchor.type)}}else"touch"!==t.pointerType&&c.$setAnchorCellForSelection(n)}),(()=>{if(c.isSelecting)return;const e=()=>{c.isSelecting=!1,i.removeEventListener("pointerup",e),i.removeEventListener("pointermove",t)},t=n=>{if(1&~n.buttons&&c.isSelecting)return c.isSelecting=!1,i.removeEventListener("pointerup",e),void i.removeEventListener("pointermove",t);if(!ne(n.target))return;let r=null;const l=!(Le||a.contains(n.target));if(l)r=zt(a,n.target);else for(const e of document.elementsFromPoint(n.clientX,n.clientY))if(r=zt(a,e),r)break;!r||null!==c.focusCell&&r.elem===c.focusCell.elem||(c.setNextFocus({focusCell:r,override:l}),o.dispatchCommand(A,void 0))};c.isSelecting=!0,i.addEventListener("pointerup",e,c.listenerOptions),i.addEventListener("pointermove",t,c.listenerOptions)})()};a.addEventListener("pointerdown",u,c.listenerOptions),c.listenersToRemove.add(()=>{a.removeEventListener("pointerdown",u)});const h=e=>{if(e.detail>=3&&ne(e.target)){null!==Wt(e.target)&&e.preventDefault()}};a.addEventListener("mousedown",h,c.listenerOptions),c.listenersToRemove.add(()=>{a.removeEventListener("mousedown",h)});const d=e=>{const t=e.target;0===e.button&&ne(t)&&o.update(()=>{const e=S();bt(e)&&e.tableKey===c.tableNodeKey&&s.contains(t)&&c.$clearHighlight()})};i.addEventListener("pointerdown",d,c.listenerOptions),c.listenersToRemove.add(()=>{i.removeEventListener("pointerdown",d)});for(const[t,n]of Kt)c.listenersToRemove.add(o.registerCommand(t,t=>en(o,t,n,e,c),L));c.listenersToRemove.add(o.registerCommand(B,t=>{const n=S();if(bt(n)){const o=At(e,n.focus.getNode());if(null!==o)return tn(t),o.selectEnd(),!0}return!1},L));const g=t=>()=>{const o=S();if(!Xt(o,e))return!1;if(bt(o))return c.$clearText(),!0;if(w(o)){if(!Ae(At(e,o.anchor.getNode())))return!1;const r=o.anchor.getNode(),l=o.focus.getNode(),s=e.isParentOf(r),i=e.isParentOf(l);if(s&&!i||i&&!s)return c.$clearText(),!0;const a=n(o.anchor.getNode(),e=>v(e)),u=a&&n(a,e=>v(e)&&Ae(e.getParent()));if(!v(u)||!v(a))return!1;if(t===D&&null===u.getPreviousSibling())return!0}return!1};for(const e of kt)c.listenersToRemove.add(o.registerCommand(e,g(e),L));const p=t=>{const n=S();if(!bt(n)&&!w(n))return!1;const o=e.isParentOf(n.anchor.getNode());if(o!==e.isParentOf(n.focus.getNode())){const t=o?"anchor":"focus",r=o?"focus":"anchor",{key:l,offset:s,type:i}=n[r];return e[n[t].isBefore(n[r])?"selectPrevious":"selectNext"]()[r].set(l,s,i),!1}return!!Xt(n,e)&&(!!bt(n)&&(t&&(t.preventDefault(),t.stopPropagation()),c.$clearText(),!0))};for(const e of Et)c.listenersToRemove.add(o.registerCommand(e,p,L));return c.listenersToRemove.add(o.registerCommand(Y,e=>{const t=S();if(t){if(!bt(t)&&!w(t))return!1;ye(o,r(e,ClipboardEvent)?e:null,Ne(t));const n=p(e);return w(t)?(t.removeText(),!0):n}return!1},L)),c.listenersToRemove.add(o.registerCommand(X,t=>{const o=S();if(!Xt(o,e))return!1;if(bt(o))return c.$formatCells(t),!0;if(w(o)){const e=n(o.anchor.getNode(),e=>Ae(e));if(!Ae(e))return!1}return!1},L)),c.listenersToRemove.add(o.registerCommand(q,t=>{const n=S();if(!bt(n)||!Xt(n,e))return!1;const o=n.anchor.getNode(),r=n.focus.getNode();if(!Ae(o)||!Ae(r))return!1;if(function(e,t){if(bt(e)){const n=e.anchor.getNode(),o=e.focus.getNode();if(t&&n&&o){const[e]=gt(t,n,o);return n.getKey()===e[0][0].cell.getKey()&&o.getKey()===e[e.length-1].at(-1).cell.getKey()}}return!1}(n,e))return e.setFormat(t),!0;const[l,s,i]=gt(e,o,r),c=Math.max(s.startRow+s.cell.__rowSpan-1,i.startRow+i.cell.__rowSpan-1),a=Math.max(s.startColumn+s.cell.__colSpan-1,i.startColumn+i.cell.__colSpan-1),u=Math.min(s.startRow,i.startRow),h=Math.min(s.startColumn,i.startColumn),d=new Set;for(let e=u;e<=c;e++)for(let n=h;n<=a;n++){const o=l[e][n].cell;if(d.has(o))continue;d.add(o),o.setFormat(t);const r=o.getChildren();for(let e=0;e{const r=S();if(!Xt(r,e))return!1;if(bt(r))return c.$clearHighlight(),!1;if(w(r)){const l=n(r.anchor.getNode(),e=>Ae(e));if(!Ae(l))return!1;if("string"==typeof t){const n=on(o,r,e);if(n)return nn(n,e,[_(t)]),!0}}return!1},L)),l&&c.listenersToRemove.add(o.registerCommand(V,t=>{const o=S();if(!w(o)||!o.isCollapsed()||!Xt(o,e))return!1;const r=Gt(o.anchor.getNode());return!(null===r||!e.is(Qt(r)))&&(tn(t),function(e,t){const o="next"===t?"getNextSibling":"getPreviousSibling",r="next"===t?"getFirstChild":"getLastChild",l=e[o]();if(v(l))return l.selectEnd();const s=n(e,We);null===s&&ke(247);for(let e=s[o]();We(e);e=e[o]()){const t=e[r]();if(v(t))return t.selectEnd()}const i=n(s,mn);null===i&&ke(248);"next"===t?i.selectNext():i.selectPrevious()}(r,t.shiftKey?"previous":"next"),!0)},L)),c.listenersToRemove.add(o.registerCommand(G,t=>e.isSelected(),L)),c.listenersToRemove.add(o.registerCommand(Q,(e,t)=>{if(o!==t)return!1;const{nodes:r,selection:l}=e,s=l.getStartEndPoints(),i=bt(l),c=w(l)&&null!==n(l.anchor.getNode(),e=>Ae(e))&&null!==n(l.focus.getNode(),e=>Ae(e))||i;if(1!==r.length||!mn(r[0])||!c||null===s)return!1;const[a,u]=s,[h,d,g]=pt(a),p=n(u.getNode(),e=>Ae(e));if(!(Ae(h)&&Ae(p)&&We(d)&&mn(g)))return!1;const C=r[0],[_,S,b]=gt(g,h,p),[y]=mt(C,null,null),N=_.length,v=N>0?_[0].length:0;let x=S.startRow,T=S.startColumn,R=y.length,F=R>0?y[0].length:0;if(i){const e=Ct(_,S,b),t=e.maxRow-e.minRow+1,n=e.maxColumn-e.minColumn+1;x=e.minRow,T=e.minColumn,R=Math.min(R,t),F=Math.min(F,n)}let O=!1;const A=Math.min(N,x+R)-1,K=Math.min(v,T+F)-1,k=new Set;for(let e=x;e<=A;e++)for(let t=T;t<=K;t++){const n=_[e][t];k.has(n.cell.getKey())||(1===n.cell.__rowSpan&&1===n.cell.__colSpan||(ft(n.cell),k.add(n.cell.getKey()),O=!0))}let[E]=mt(g.getWritable(),null,null);const M=R-N+x;for(let e=0;e{if(f(e)){m().append(e),s.append(e)}else s.append(e)}),i.forEach(e=>e.remove())}if(i&&O){const[e]=mt(g.getWritable(),null,null);e[S.startRow][S.startColumn].cell.selectEnd()}return!0},L)),c.listenersToRemove.add(o.registerCommand(A,()=>{const t=S(),r=Z(),l=c.getAndClearNextFocus();if(null!==l){const{focusCell:n}=l;if(bt(t)&&t.tableKey===c.tableNodeKey)return(n.x!==c.focusX||n.y!==c.focusY)&&(c.$setFocusCellForSelection(n),!0);if(n!==c.anchorCell&&Xt(t,e))return c.$setFocusCellForSelection(n),!0}if(c.getAndClearShouldCheckSelection()&&w(r)&&w(t)&&t.isCollapsed()){const o=t.anchor.getNode(),r=e.getFirstChild(),l=Gt(o);if(null!==l&&We(r)){const t=r.getFirstChild();if(Ae(t)&&e.is(n(l,n=>n.is(e)||n.is(t))))return t.selectStart(),!0}}if(w(t)){const{anchor:n,focus:l}=t,s=n.getNode(),i=l.getNode(),a=Gt(s),u=Gt(i),h=!(!a||!e.is(Qt(a))),d=!(!u||!e.is(Qt(u))),f=h!==d,g=h&&d,m=t.isBackward();if(f){const n=t.clone();if(d){const[t]=gt(e,u,u),o=t[0][0].cell,r=t[t.length-1].at(-1).cell;n.focus.set(m?o.getKey():r.getKey(),m?o.getChildrenSize():r.getChildrenSize(),"element")}else if(h){const[t]=gt(e,a,a),o=t[0][0].cell,r=t[t.length-1].at(-1).cell;n.anchor.set(m?r.getKey():o.getKey(),m?r.getChildrenSize():0,"element")}O(n),Pt(o,c)}else if(g&&(a.is(u)||(c.$setAnchorCellForSelection(rn(c,a)),c.$setFocusCellForSelection(rn(c,u),!0)),"touch"===c.pointerType&&c.isSelecting&&t.isCollapsed()&&w(r)&&r.isCollapsed())){const e=Gt(r.anchor.getNode());e&&!e.is(u)&&(c.$setAnchorCellForSelection(rn(c,e)),c.$setFocusCellForSelection(rn(c,u),!0),c.pointerType=null)}}else if(t&&bt(t)&&t.is(r)&&t.tableKey===e.getKey()){const n=K(o);if(n&&n.anchorNode&&n.focusNode){const r=ee(n.focusNode),l=r&&!e.isParentOf(r),s=ee(n.anchorNode),i=s&&e.isParentOf(s);if(l&&i&&n.rangeCount>0){const r=te(n,o);r&&(r.anchor.set(e.getKey(),t.isBackward()?e.getChildrenSize():0,"element"),n.removeAllRanges(),O(r))}}}return t&&!t.is(r)&&(bt(t)||bt(r))&&c.tableSelection&&!c.tableSelection.is(r)?(bt(t)&&t.tableKey===c.tableNodeKey?c.$updateTableTableSelection(t):!bt(t)&&bt(r)&&r.tableKey===c.tableNodeKey&&c.$updateTableTableSelection(null),!1):(c.hasHijackedSelectionStyles&&!e.isSelected()?function(e,t){t.$enableHighlightStyle(),Bt(t.table,t=>{const n=t.elem;t.highlighted=!1,Vt(e,t),n.getAttribute("style")||n.removeAttribute("style")})}(o,c):!c.hasHijackedSelectionStyles&&e.isSelected()&&Pt(o,c),!1)},L)),c.listenersToRemove.add(o.registerCommand(M,()=>{const t=S();if(!w(t)||!t.isCollapsed()||!Xt(t,e))return!1;const n=on(o,t,e);return!!n&&(nn(n,e),!0)},L)),c}function $t(e){return e[Rt]||null}function Wt(e){let t=e;for(;null!=t;){const e=t.nodeName;if("TD"===e||"TH"===e){const e=t._cell;return void 0===e?null:e}t=t.parentNode}return null}function zt(e,t){if(!e.contains(t))return null;let n=null;for(let o=t;null!=o;o=o.parentNode){if(o===e)return n;const t=o.nodeName;"TD"!==t&&"TH"!==t||(n=o._cell||null)}return null}function Ht(e,t){const n=[],o={columns:0,domRows:n,rows:0};let r=Ot(e,t).querySelector("tr"),l=0,s=0;for(n.length=0;null!=r;){const e=r.nodeName;if("TD"===e||"TH"===e){const e={elem:r,hasBackgroundColor:""!==r.style.backgroundColor,highlighted:!1,x:l,y:s};r._cell=e;let t=n[s];void 0===t&&(t=n[s]=[]),t[l]=e}else{const e=r.firstChild;if(null!=e){r=e;continue}}const t=r.nextSibling;if(null!=t){l++,r=t;continue}const o=r.parentNode;if(null!=o){const e=o.nextSibling;if(null==e)break;s++,l=0,r=e}}return o.columns=l+1,o.rows=s+1,o}function Lt(e,t,n){const o=new Set(n?n.getNodes():[]);Bt(t,(t,n)=>{const r=t.elem;o.has(n)?(t.highlighted=!0,jt(e,t)):(t.highlighted=!1,Vt(e,t),r.getAttribute("style")||r.removeAttribute("style"))})}function Bt(e,t){const{domRows:n}=e;for(let e=0;e{t.highlighted=!0,jt(e,t)})}const Dt=(e,t,n,o,r)=>{const l="forward"===r;switch(r){case"backward":case"forward":return n!==(l?e.table.columns-1:0)?qt(t.getCellNodeFromCordsOrThrow(n+(l?1:-1),o,e.table),l):o!==(l?e.table.rows-1:0)?qt(t.getCellNodeFromCordsOrThrow(l?0:e.table.columns-1,o+(l?1:-1),e.table),l):l?t.selectNext():t.selectPrevious(),!0;case"up":return 0!==o?qt(t.getCellNodeFromCordsOrThrow(n,o-1,e.table),!1):t.selectPrevious(),!0;case"down":return o!==e.table.rows-1?qt(t.getCellNodeFromCordsOrThrow(n,o+1,e.table),!0):t.selectNext(),!0;default:return!1}};function It(e,t){let n,o;if(t.startColumn===e.minColumn)n="minColumn";else{if(t.startColumn+t.cell.__colSpan-1!==e.maxColumn)return null;n="maxColumn"}if(t.startRow===e.minRow)o="minRow";else{if(t.startRow+t.cell.__rowSpan-1!==e.maxRow)return null;o="maxRow"}return[n,o]}function Ut([e,t]){return["minColumn"===e?"maxColumn":"minColumn","minRow"===t?"maxRow":"minRow"]}function Jt(e,t,[n,o]){const r=t[o],l=e[r];void 0===l&&ke(250,o,String(r));const s=t[n],i=l[s];return void 0===i&&ke(250,n,String(s)),i}function Yt(e,t,n,o,r){const l=Ct(t,n,o),s=function(e,t){const{minColumn:n,maxColumn:o,minRow:r,maxRow:l}=t;let s=1,i=1,c=1,a=1;const u=e[r],h=e[l];for(let e=n;e<=o;e++)s=Math.max(s,u[e].cell.__rowSpan),a=Math.max(a,h[e].cell.__rowSpan);for(let t=r;t<=l;t++)i=Math.max(i,e[t][n].cell.__colSpan),c=Math.max(c,e[t][o].cell.__colSpan);return{bottomSpan:a,leftSpan:i,rightSpan:c,topSpan:s}}(t,l),{topSpan:i,leftSpan:c,bottomSpan:a,rightSpan:u}=s,h=function(e,t){const n=It(e,t);return null===n&&ke(249,t.cell.getKey()),n}(l,n),[d,f]=Ut(h);let g=l[d],m=l[f];"forward"===r?g+="maxColumn"===d?1:c:"backward"===r?g-="minColumn"===d?1:u:"down"===r?m+="maxRow"===f?1:i:"up"===r&&(m-="minRow"===f?1:a);const p=t[m];if(void 0===p)return!1;const C=p[g];if(void 0===C)return!1;const[_,S]=function(e,t,n){const o=Ct(e,t,n),r=It(o,t);if(r)return[Jt(e,o,r),Jt(e,o,Ut(r))];const l=It(o,n);if(l)return[Jt(e,o,Ut(l)),Jt(e,o,l)];const s=["minColumn","minRow"];return[Jt(e,o,s),Jt(e,o,Ut(s))]}(t,n,C),w=rn(e,_.cell),b=rn(e,S.cell);return e.$setAnchorCellForSelection(w),e.$setFocusCellForSelection(b,!0),!0}function Xt(e,t){if(w(e)||bt(e)){const n=t.isParentOf(e.anchor.getNode()),o=t.isParentOf(e.focus.getNode());return n&&o}return!1}function qt(e,t){t?e.selectStart():e.selectEnd()}function jt(t,n){const o=n.elem,r=t._config.theme;Ae(ee(o))||ke(131),e(o,r.tableCellSelected)}function Vt(e,t){const n=t.elem;Ae(ee(n))||ke(131);const r=e._config.theme;o(n,r.tableCellSelected)}function Gt(e){const t=n(e,Ae);return Ae(t)?t:null}function Qt(e){const t=n(e,mn);return mn(t)?t:null}function Zt(e,t,o,r,l,s,i){const c=re(o.focus,l?"previous":"next");if(le(c))return!1;let a=c;for(const e of se(c).iterNodeCarets("shadowRoot")){if(!ie(e)||!v(e.origin))return!1;a=e}const u=a.getParentAtCaret();if(!Ae(u))return!1;const h=u,d=function(e){for(const t of se(e).iterNodeCarets("root")){const{origin:n}=t;if(Ae(n)){if(he(t))return de(n,e.direction)}else if(!We(n))break}return null}(ce(h,a.direction)),f=n(h,mn);if(!f||!f.is(s))return!1;const g=e.getElementByKey(h.getKey()),m=Wt(g);if(!g||!m)return!1;const p=dn(e,f);if(i.table=p,d)if("extend"===r){const t=Wt(e.getElementByKey(d.origin.getKey()));if(!t)return!1;i.$setAnchorCellForSelection(m),i.$setFocusCellForSelection(t,!0)}else{const e=ue(d);ae(o.anchor,e),ae(o.focus,e)}else if("extend"===r)i.$setAnchorCellForSelection(m),i.$setFocusCellForSelection(m,!0);else{const e=function(e){const t=fe(e);return he(t)?ue(t):e}(ce(f,c.direction));ae(o.anchor,e),ae(o.focus,e)}return tn(t),!0}function en(e,t,o,r,l){if(("up"===o||"down"===o)&&function(e){const t=e.getRootElement();if(!t)return!1;return t.hasAttribute("aria-controls")&&"typeahead-menu"===t.getAttribute("aria-controls")}(e))return!1;const s=S();if(!Xt(s,r)){if(w(s)){if("backward"===o){if(s.focus.offset>0)return!1;const e=function(e){for(let t=e,n=e;null!==n;t=n,n=n.getParent())if(v(n)){if(n!==t&&n.getFirstChild()!==t)return null;if(!n.isInline())return n}return null}(s.focus.getNode());if(!e)return!1;const n=e.getPreviousSibling();return!!mn(n)&&(tn(t),t.shiftKey?s.focus.set(n.getParentOrThrow().getKey(),n.getIndexWithinParent(),"element"):n.selectEnd(),!0)}if(t.shiftKey&&("up"===o||"down"===o)){const e=s.focus.getNode();if(!s.isCollapsed()&&("up"===o&&!s.isBackward()||"down"===o&&s.isBackward())){let l=n(e,e=>mn(e));if(Ae(l)&&(l=n(l,mn)),l!==r)return!1;if(!l)return!1;const i="down"===o?l.getNextSibling():l.getPreviousSibling();if(!i)return!1;let c=0;"up"===o&&v(i)&&(c=i.getChildrenSize());let a=i;if("up"===o&&v(i)){const e=i.getLastChild();a=e||i,c=f(a)?a.getTextContentSize():0}const u=s.clone();return u.focus.set(a.getKey(),c,f(a)?"text":"element"),O(u),tn(t),!0}if(oe(e)){const e="up"===o?s.getNodes()[s.getNodes().length-1]:s.getNodes()[0];if(e){if(null!==At(r,e)){const e=r.getFirstDescendant(),t=r.getLastDescendant();if(!e||!t)return!1;const[n]=pt(e),[o]=pt(t),s=r.getCordsFromCellNode(n,l.table),i=r.getCordsFromCellNode(o,l.table),c=r.getDOMCellFromCordsOrThrow(s.x,s.y,l.table),a=r.getDOMCellFromCordsOrThrow(i.x,i.y,l.table);return l.$setAnchorCellForSelection(c),l.$setFocusCellForSelection(a,!0),!0}}return!1}{let r=n(e,e=>v(e)&&!e.isInline());if(Ae(r)&&(r=n(r,mn)),!r)return!1;const i="down"===o?r.getNextSibling():r.getPreviousSibling();if(mn(i)&&l.tableNodeKey===i.getKey()){const e=i.getFirstDescendant(),n=i.getLastDescendant();if(!e||!n)return!1;const[r]=pt(e),[l]=pt(n),c=s.clone();return c.focus.set(("up"===o?r:l).getKey(),"up"===o?0:l.getChildrenSize(),"element"),tn(t),O(c),!0}}}}return"down"===o&&an(e)&&l.setShouldCheckSelection(),!1}if(w(s)){if("backward"===o||"forward"===o){return Zt(e,t,s,t.shiftKey?"extend":"move","backward"===o,r,l)}if(s.isCollapsed()){const{anchor:i,focus:c}=s,a=n(i.getNode(),Ae),u=n(c.getNode(),Ae);if(!Ae(a)||!a.is(u))return!1;const h=Qt(a);if(h!==r&&null!=h){const n=Ot(h,e.getElementByKey(h.getKey()));if(null!=n)return l.table=Ht(h,n),en(e,t,o,h,l)}const d=e.getElementByKey(a.__key),f=e.getElementByKey(i.key);if(null==f||null==d)return!1;let g;if("element"===i.type)g=f.getBoundingClientRect();else{const t=K(e);if(null===t||0===t.rangeCount)return!1;g=t.getRangeAt(0).getBoundingClientRect()}const m="up"===o?a.getFirstChild():a.getLastChild();if(null==m)return!1;const p=e.getElementByKey(m.__key);if(null==p)return!1;const C=p.getBoundingClientRect();if("up"===o?C.top>g.top-g.height:g.bottom+g.height>C.bottom){tn(t);const e=r.getCordsFromCellNode(a,l.table);if(!t.shiftKey)return Dt(l,r,e.x,e.y,o);{const t=r.getDOMCellFromCordsOrThrow(e.x,e.y,l.table);l.$setAnchorCellForSelection(t),l.$setFocusCellForSelection(t,!0)}return!0}}}else if(bt(s)){const{anchor:i,focus:c}=s,a=n(i.getNode(),Ae),u=n(c.getNode(),Ae),[h]=s.getNodes();mn(h)||ke(251);const d=Ot(h,e.getElementByKey(h.getKey()));if(!Ae(a)||!Ae(u)||!mn(h)||null==d)return!1;l.$updateTableTableSelection(s);const f=Ht(h,d),g=r.getCordsFromCellNode(a,f),m=r.getDOMCellFromCordsOrThrow(g.x,g.y,f);if(l.$setAnchorCellForSelection(m),tn(t),t.shiftKey){const[e,t,n]=gt(r,a,u);return Yt(l,e,t,n,o)}return u.selectEnd(),!0}return!1}function tn(e){e.preventDefault(),e.stopImmediatePropagation(),e.stopPropagation()}function nn(e,t,n){const o=m();"first"===e?t.insertBefore(o):t.insertAfter(o),o.append(...n||[]),o.selectEnd()}function on(e,t,o){const r=o.getParent();if(!r)return;const l=K(e);if(!l)return;const s=l.anchorNode,i=e.getElementByKey(r.getKey()),c=Ot(o,e.getElementByKey(o.getKey()));if(!s||!i||!c||!i.contains(s)||c.contains(s))return;const a=n(t.anchor.getNode(),e=>Ae(e));if(!a)return;const u=n(a,e=>mn(e));if(!mn(u)||!u.is(o))return;const[h,d]=gt(o,a,a),f=h[0][0],g=h[h.length-1][h[0].length-1],{startRow:m,startColumn:p}=d,C=m===f.startRow&&p===f.startColumn,_=m===g.startRow&&p===g.startColumn;return C?"first":_?"last":void 0}function rn(e,t){const{tableNode:n}=e.$lookup(),o=n.getCordsFromCellNode(t,e.table);return n.getDOMCellFromCordsOrThrow(o.x,o.y,e.table)}function ln(e,t,n){return At(e,ee(t,n))}function sn(t,n,r){if(!n.theme.tableAlignment)return;const l=[],s=[];for(const e of["center","right"]){const t=n.theme.tableAlignment[e];t&&(e===r?s:l).push(t)}o(t,...l),e(t,...s)}const cn=new WeakSet;function an(e=F()){return cn.has(e)}function un(e,t){t?cn.add(e):cn.delete(e)}class hn extends u{__rowStriping;__frozenColumnCount;__frozenRowCount;__colWidths;static getType(){return"table"}getColWidths(){return this.getLatest().__colWidths}setColWidths(e){const t=this.getWritable();return t.__colWidths=e,t}static clone(e){return new hn(e.__key)}afterCloneFrom(e){super.afterCloneFrom(e),this.__colWidths=e.__colWidths,this.__rowStriping=e.__rowStriping,this.__frozenColumnCount=e.__frozenColumnCount,this.__frozenRowCount=e.__frozenRowCount}static importDOM(){return{table:e=>({conversion:fn,priority:1})}}static importJSON(e){return gn().updateFromJSON(e)}updateFromJSON(e){return super.updateFromJSON(e).setRowStriping(e.rowStriping||!1).setFrozenColumns(e.frozenColumnCount||0).setFrozenRows(e.frozenRowCount||0).setColWidths(e.colWidths)}constructor(e){super(e),this.__rowStriping=!1,this.__frozenColumnCount=0,this.__frozenRowCount=0,this.__colWidths=void 0}exportJSON(){return{...super.exportJSON(),colWidths:this.getColWidths(),frozenColumnCount:this.__frozenColumnCount?this.__frozenColumnCount:void 0,frozenRowCount:this.__frozenRowCount?this.__frozenRowCount:void 0,rowStriping:this.__rowStriping?this.__rowStriping:void 0}}extractWithChild(e,t,n){return"html"===n}getDOMSlot(e){const t=Ft(e)?e:e.querySelector("table");return Ft(t)||ke(229),super.getDOMSlot(e).withElement(t).withAfter(t.querySelector("colgroup"))}createDOM(t,n){const o=document.createElement("table");this.__style&&(o.style.cssText=this.__style);const r=document.createElement("colgroup");if(o.appendChild(r),ge(r),e(o,t.theme.table),this.updateTableElement(null,o,t),an(n)){const n=document.createElement("div"),r=t.theme.tableScrollableWrapper;return r?e(n,r):n.style.cssText="overflow-x: auto;",n.appendChild(o),this.updateTableWrapper(null,n,o,t),n}return o}updateTableWrapper(t,n,r,l){this.__frozenColumnCount!==(t?t.__frozenColumnCount:0)&&function(t,n,r,l){l>0?(e(t,r.theme.tableFrozenColumn),n.setAttribute("data-lexical-frozen-column","true")):(o(t,r.theme.tableFrozenColumn),n.removeAttribute("data-lexical-frozen-column"))}(n,r,l,this.__frozenColumnCount),this.__frozenRowCount!==(t?t.__frozenRowCount:0)&&function(t,n,r,l){l>0?(e(t,r.theme.tableFrozenRow),n.setAttribute("data-lexical-frozen-row","true")):(o(t,r.theme.tableFrozenRow),n.removeAttribute("data-lexical-frozen-row"))}(n,r,l,this.__frozenRowCount)}updateTableElement(t,n,r){this.__style!==(t?t.__style:"")&&(n.style.cssText=this.__style),this.__rowStriping!==(!!t&&t.__rowStriping)&&function(t,n,r){r?(e(t,n.theme.tableRowStriping),t.setAttribute("data-lexical-row-striping","true")):(o(t,n.theme.tableRowStriping),t.removeAttribute("data-lexical-row-striping"))}(n,r,this.__rowStriping),function(e,t,n,o){const r=e.querySelector("colgroup");if(!r)return;const l=[];for(let e=0;e{if(t.after&&(n=t.after(n)),!Ft(n)&&l(n)&&(n=n.querySelector("table")),!Ft(n))return null;sn(n,e._config,this.getFormatType());const[o]=mt(this,null,null),r=new Map;for(const e of o)for(const t of e){const e=t.cell.getKey();r.has(e)||r.set(e,{colSpan:t.cell.getColSpan(),startColumn:t.startColumn})}const s=new Set;for(const e of n.querySelectorAll(":scope > tr > [data-temporary-table-cell-lexical-key]")){const t=e.getAttribute("data-temporary-table-cell-lexical-key");if(t){const n=r.get(t);if(e.removeAttribute("data-temporary-table-cell-lexical-key"),n){r.delete(t);for(let e=0;e colgroup");if(i){const e=Array.from(n.querySelectorAll(":scope > colgroup > col")).filter((e,t)=>s.has(t));i.replaceChildren(...e)}const c=n.querySelectorAll(":scope > tr");if(c.length>0){const e=document.createElement("tbody");for(const t of c)e.appendChild(t);n.append(e)}return n},element:!Ft(n)&&l(n)?n.querySelector("table"):n}}canBeEmpty(){return!1}isShadowRoot(){return!0}getCordsFromCellNode(e,t){const{rows:n,domRows:o}=t;for(let t=0;t{Ae(e)&&(t+=e.getColSpan())}),t}}function dn(e,t){const n=e.getElementByKey(t.getKey());return null===n&&ke(230),Ht(t,n)}function fn(e){const n=gn();e.hasAttribute("data-lexical-row-striping")&&n.setRowStriping(!0),e.hasAttribute("data-lexical-frozen-column")&&n.setFrozenColumns(1),e.hasAttribute("data-lexical-frozen-row")&&n.setFrozenRows(1);const o=e.querySelector(":scope > colgroup");if(o){let e=[];for(const t of o.querySelectorAll(":scope > col")){let n=t.style.width||"";if(!ve.test(n)&&(n=t.getAttribute("width")||"",!/^\d+$/.test(n))){e=void 0;break}e.push(parseFloat(n))}e&&n.setColWidths(e)}return{after:e=>t(e,We),node:n}}function gn(){return p(new hn)}function mn(e){return e instanceof hn}function pn(e){We(e.getParent())?e.isEmpty()&&e.append(m()):e.remove()}function Cn(e){mn(e.getParent())?a(e,Ae):e.remove()}function _n(e){a(e,We);const[t]=mt(e,null,null),n=t.reduce((e,t)=>Math.max(e,t.length),0),o=e.getChildren();for(let e=0;et?1+e:e,0);if(l!==n)for(let e=l;e0){const e=r[r.length-1];t=[...r,...Array(l-r.length).fill(e)]}e.setColWidths(t)}}function Sn(e){if(e.detail<3||!ne(e.target))return!1;const t=ee(e.target);if(null===t)return!1;const o=n(t,e=>v(e)&&!e.isInline());if(null===o)return!1;return!!Ae(o.getParent())&&(o.select(0),!0)}function wn(e){return e.registerNodeTransform(Te,e=>{if(e.getColSpan()>1||e.getRowSpan()>1){const[,,t]=pt(e),[n]=gt(t,e,e),o=n.length,r=n[0].length;let l=t.getFirstChild();We(l)||ke(175);const i=[];for(let e=0;e1||c.getRowSpan()>1){Ae(c)||ke(176);const e=Oe(c.__headerState);null!==t?t.insertAfter(e):s(l,e)}}}for(const e of i)e.setColSpan(1),e.setRowSpan(1)}})}function bn(e,t=!0){const n=new Map,o=(o,r,l)=>{const s=Ot(o,l),i=Mt(o,s,e,t);n.set(r,[i,s])},r=e.registerMutationListener(hn,t=>{e.getEditorState().read(()=>{for(const[e,r]of t){const t=n.get(e);if("created"===r||"updated"===r){const{tableNode:r,tableElement:l}=xt(e);void 0===t?o(r,e,l):l!==t[1]&&(t[0].removeListeners(),n.delete(e),o(r,e,l))}else"destroyed"===r&&void 0!==t&&(t[0].removeListeners(),n.delete(e))}},{editor:e})},{skipInitialization:!1});return()=>{r();for(const[,[e]]of n)e.removeListeners()}}function yn(e,t){e.hasNodes([hn])||ke(255);const{hasNestedTables:n=Se(!1)}=t??{};return i(e.registerCommand(Ke,e=>function({rows:e,columns:t,includeHeaders:n},o){const r=S()||Z();if(!r||!w(r))return!1;if(!o&&Qt(r.anchor.getNode()))return!1;const l=Be(Number(e),Number(t),n);c(l);const s=l.getFirstDescendant();return f(s)&&s.select(),!0}(e,n.peek()),me),e.registerCommand(Q,({nodes:t,selection:o},r)=>{if(n.peek()||e!==r||!w(o))return!1;return null!==Qt(o.anchor.getNode())&&t.some(mn)},me),e.registerCommand(pe,Sn,me),e.registerNodeTransform(hn,_n),e.registerNodeTransform(Ee,Cn),e.registerNodeTransform(Te,pn))}const Nn=Ce({build:(e,t,n)=>be(t),config:_e({hasCellBackgroundColor:!0,hasCellMerge:!0,hasHorizontalScroll:!0,hasNestedTables:!1,hasTabHandler:!0}),name:"@lexical/table/Table",nodes:()=>[hn,Ee,Te],register(e,t,n){const o=n.getOutput(),{hasNestedTables:r}=o;return i(we(()=>{const t=o.hasHorizontalScroll.value;an(e)!==t&&(un(e,t),e.registerNodeTransform(hn,()=>{})())}),yn(e,{hasNestedTables:r}),we(()=>bn(e,o.hasTabHandler.value)),we(()=>o.hasCellMerge.value?void 0:wn(e)),we(()=>o.hasCellBackgroundColor.value?void 0:e.registerNodeTransform(Te,e=>{null!==e.getBackgroundColor()&&e.setBackgroundColor(null)})))}});export{gt as $computeTableMap,mt as $computeTableMapSkipCellCheck,Oe as $createTableCellNode,gn as $createTableNode,Be as $createTableNodeWithDimensions,$e as $createTableRowNode,yt as $createTableSelection,Nt as $createTableSelectionFrom,ot as $deleteTableColumn,st as $deleteTableColumnAtSelection,it as $deleteTableColumn__EXPERIMENTAL,rt as $deleteTableRowAtSelection,lt as $deleteTableRow__EXPERIMENTAL,Gt as $findCellNode,Qt as $findTableNode,dn as $getElementForTableNode,pt as $getNodeTriplet,xt as $getTableAndElementByKey,Pe as $getTableCellNodeFromLexicalNode,_t as $getTableCellNodeRect,Je as $getTableColumnIndexFromTableCellNode,Ie as $getTableNodeFromLexicalNodeOrThrow,Ue as $getTableRowIndexFromTableCellNode,De as $getTableRowNodeFromTableCellNodeOrThrow,Ze as $insertTableColumn,et as $insertTableColumnAtSelection,tt as $insertTableColumn__EXPERIMENTAL,qe as $insertTableRow,Ve as $insertTableRowAtSelection,Ge as $insertTableRow__EXPERIMENTAL,an as $isScrollableTablesActive,Ae as $isTableCellNode,mn as $isTableNode,We as $isTableRowNode,bt as $isTableSelection,ut as $mergeCells,Xe as $removeTableRowAtIndex,dt as $unmergeCell,Ke as INSERT_TABLE_COMMAND,xe as TableCellHeaderStates,Te as TableCellNode,Nn as TableExtension,hn as TableNode,Tt as TableObserver,Ee as TableRowNode,Mt as applyTableHandlers,Wt as getDOMCellFromTarget,Ot as getTableElement,$t as getTableObserverFromTableElement,wn as registerTableCellUnmergeTransform,yn as registerTablePlugin,bn as registerTableSelectionObserver,un as setScrollableTablesActive}; +diff --git a/node_modules/@lexical/table/LexicalTableExtension.d.ts b/node_modules/@lexical/table/LexicalTableExtension.d.ts +index ef9c6a4..fde457d 100644 +--- a/node_modules/@lexical/table/LexicalTableExtension.d.ts ++++ b/node_modules/@lexical/table/LexicalTableExtension.d.ts +@@ -23,6 +23,12 @@ export interface TableConfig { + * When `true` (default `true`), tables will be wrapped in a `
` to enable horizontal scrolling + */ + hasHorizontalScroll: boolean; ++ /** ++ * When `true` (default `false`), nested tables will be allowed. ++ * ++ * @experimental Nested tables are not officially supported. ++ */ ++ hasNestedTables: boolean; + } + /** + * Configures {@link TableNode}, {@link TableRowNode}, {@link TableCellNode} and +diff --git a/node_modules/@lexical/table/LexicalTablePluginHelpers.d.ts b/node_modules/@lexical/table/LexicalTablePluginHelpers.d.ts +index f3a54fd..8b2b305 100644 +--- a/node_modules/@lexical/table/LexicalTablePluginHelpers.d.ts ++++ b/node_modules/@lexical/table/LexicalTablePluginHelpers.d.ts +@@ -5,6 +5,7 @@ + * LICENSE file in the root directory of this source tree. + * + */ ++import { Signal } from '@lexical/extension'; + import { LexicalEditor } from 'lexical'; + /** + * Register a transform to ensure that all TableCellNode have a colSpan and rowSpan of 1. +@@ -23,4 +24,6 @@ export declare function registerTableSelectionObserver(editor: LexicalEditor, ha + * @param editor The editor + * @returns An unregister callback + */ +-export declare function registerTablePlugin(editor: LexicalEditor): () => void; ++export declare function registerTablePlugin(editor: LexicalEditor, options?: { ++ hasNestedTables?: Signal; ++}): () => void; diff --git a/patches/@lexical+utils+0.38.2.patch b/patches/@lexical+utils+0.38.2.patch new file mode 100644 index 00000000..f025314d --- /dev/null +++ b/patches/@lexical+utils+0.38.2.patch @@ -0,0 +1,292 @@ +diff --git a/node_modules/@lexical/utils/LexicalUtils.dev.js b/node_modules/@lexical/utils/LexicalUtils.dev.js +index ddd4507..aafc2b0 100644 +--- a/node_modules/@lexical/utils/LexicalUtils.dev.js ++++ b/node_modules/@lexical/utils/LexicalUtils.dev.js +@@ -393,9 +393,39 @@ function markSelection(editor, onReposition) { + function selectionAlwaysOnDisplay(editor) { + let removeSelectionMark = null; + const onSelectionChange = () => { +- const domSelection = getSelection(); +- const domAnchorNode = domSelection && domSelection.anchorNode; + const editorRootElement = editor.getRootElement(); ++ if (!editorRootElement) { ++ return; ++ } ++ ++ // Get selection from the proper context (shadow DOM or document) ++ let domSelection = null; ++ let current = editorRootElement; ++ while (current) { ++ if (lexical.isDocumentFragment(current.nodeType)) { ++ const shadowRoot = current; ++ ++ // Try modern getComposedRanges API first ++ if ('getComposedRanges' in Selection.prototype) { ++ const globalSelection = window.getSelection(); ++ if (globalSelection) { ++ const ranges = globalSelection.getComposedRanges({ ++ shadowRoots: [shadowRoot] ++ }); ++ if (ranges.length > 0) { ++ // Use the global selection with composed ranges context ++ domSelection = globalSelection; ++ } ++ } ++ } ++ break; ++ } ++ current = current.parentNode; ++ } ++ if (!domSelection) { ++ domSelection = getSelection(); ++ } ++ const domAnchorNode = domSelection && domSelection.anchorNode; + const isSelectionInsideEditor = domAnchorNode !== null && editorRootElement !== null && editorRootElement.contains(domAnchorNode); + if (isSelectionInsideEditor) { + if (removeSelectionMark !== null) { +@@ -408,12 +438,27 @@ function selectionAlwaysOnDisplay(editor) { + } + } + }; +- document.addEventListener('selectionchange', onSelectionChange); ++ ++ // Get the proper document context for event listeners ++ const editorRootElement = editor.getRootElement(); ++ let targetDocument = document; ++ if (editorRootElement) { ++ let current = editorRootElement; ++ while (current) { ++ if (lexical.isDocumentFragment(current.nodeType)) { ++ targetDocument = current.ownerDocument || document; ++ break; ++ } ++ current = current.parentNode; ++ } ++ targetDocument = editorRootElement.ownerDocument || document; ++ } ++ targetDocument.addEventListener('selectionchange', onSelectionChange); + return () => { + if (removeSelectionMark !== null) { + removeSelectionMark(); + } +- document.removeEventListener('selectionchange', onSelectionChange); ++ targetDocument.removeEventListener('selectionchange', onSelectionChange); + }; + } + +@@ -525,8 +570,10 @@ function mediaFileReader(files, acceptableMimeTypes) { + * before backtracking and finding a new path. Consider solving a maze by hugging either wall, moving down a + * branch until you hit a dead-end (leaf) and backtracking to find the nearest branching path and repeat. + * It will then return all the nodes found in the search in an array of objects. +- * @param startNode - The node to start the search, if omitted, it will start at the root node. +- * @param endNode - The node to end the search, if omitted, it will find all descendants of the startingNode. ++ * Preorder traversal is used, meaning that nodes are listed in the order of when they are FIRST encountered. ++ * @param startNode - The node to start the search (inclusive), if omitted, it will start at the root node. ++ * @param endNode - The node to end the search (inclusive), if omitted, it will find all descendants of the startingNode. If endNode ++ * is an ElementNode, it will stop before visiting any of its children. + * @returns An array of objects of all the nodes found by the search, including their depth into the tree. + * \\{depth: number, node: LexicalNode\\} It will always return at least 1 node (the start node). + */ +@@ -556,8 +603,10 @@ function $reverseDfs(startNode, endNode) { + + /** + * $dfs iterator (left to right). Tree traversal is done on the fly as new values are requested with O(1) memory. +- * @param startNode - The node to start the search, if omitted, it will start at the root node. +- * @param endNode - The node to end the search, if omitted, it will find all descendants of the startingNode. ++ * Preorder traversal is used, meaning that nodes are iterated over in the order of when they are FIRST encountered. ++ * @param startNode - The node to start the search (inclusive), if omitted, it will start at the root node. ++ * @param endNode - The node to end the search (inclusive), if omitted, it will find all descendants of the startingNode. ++ * If endNode is an ElementNode, the iterator will end as soon as it reaches the endNode (no children will be visited). + * @returns An iterator, each yielded value is a DFSNode. It will always return at least 1 node (the start node). + */ + function $dfsIterator(startNode, endNode) { +@@ -572,7 +621,7 @@ function $dfsCaretIterator(direction, startNode, endNode) { + const start = startNode || root; + const startCaret = lexical.$isElementNode(start) ? lexical.$getChildCaret(start, direction) : lexical.$getSiblingCaret(start, direction); + const startDepth = $getDepth(start); +- const endCaret = endNode ? lexical.$getAdjacentChildCaret(lexical.$getChildCaretOrSelf(lexical.$getSiblingCaret(endNode, direction))) : $getEndCaret(start, direction); ++ const endCaret = endNode ? lexical.$getAdjacentChildCaret(lexical.$getChildCaretOrSelf(lexical.$getSiblingCaret(endNode, direction))) || $getEndCaret(endNode, direction) : $getEndCaret(start, direction); + let depth = startDepth; + return lexical.makeStepwiseIterator({ + hasNext: state => state !== null, +diff --git a/node_modules/@lexical/utils/LexicalUtils.dev.mjs b/node_modules/@lexical/utils/LexicalUtils.dev.mjs +index 1ea9327..4ba0e8a 100644 +--- a/node_modules/@lexical/utils/LexicalUtils.dev.mjs ++++ b/node_modules/@lexical/utils/LexicalUtils.dev.mjs +@@ -6,7 +6,7 @@ + * + */ + +-import { isHTMLElement, $getSelection, $isRangeSelection, $isElementNode, getDOMTextNode, $getAdjacentSiblingOrParentSiblingCaret, $getSiblingCaret, $getChildCaretOrSelf, $findMatchingParent, $cloneWithProperties, $setSelection, $getPreviousSelection, $caretFromPoint, $getChildCaret, $getRoot, $createParagraphNode, $getAdjacentChildCaret, $isChildCaret, $normalizeCaret, $setSelectionFromCaretRange, $getCollapsedCaretRange, $getCaretInDirection, $splitAtPointCaretNext, $isTextPointCaret, $rewindSiblingCaret, $getState, $setState, makeStepwiseIterator, $isSiblingCaret } from 'lexical'; ++import { isHTMLElement, $getSelection, $isRangeSelection, $isElementNode, getDOMTextNode, isDocumentFragment, $getAdjacentSiblingOrParentSiblingCaret, $getSiblingCaret, $getChildCaretOrSelf, $findMatchingParent, $cloneWithProperties, $setSelection, $getPreviousSelection, $caretFromPoint, $getChildCaret, $getRoot, $createParagraphNode, $getAdjacentChildCaret, $isChildCaret, $normalizeCaret, $setSelectionFromCaretRange, $getCollapsedCaretRange, $getCaretInDirection, $splitAtPointCaretNext, $isTextPointCaret, $rewindSiblingCaret, $getState, $setState, makeStepwiseIterator, $isSiblingCaret } from 'lexical'; + export { $findMatchingParent, $getAdjacentSiblingOrParentSiblingCaret, $splitNode, isBlockDomNode, isHTMLAnchorElement, isHTMLElement, isInlineDomNode } from 'lexical'; + import { createRectsFromDOMRange } from '@lexical/selection'; + +@@ -392,9 +392,39 @@ function markSelection(editor, onReposition) { + function selectionAlwaysOnDisplay(editor) { + let removeSelectionMark = null; + const onSelectionChange = () => { +- const domSelection = getSelection(); +- const domAnchorNode = domSelection && domSelection.anchorNode; + const editorRootElement = editor.getRootElement(); ++ if (!editorRootElement) { ++ return; ++ } ++ ++ // Get selection from the proper context (shadow DOM or document) ++ let domSelection = null; ++ let current = editorRootElement; ++ while (current) { ++ if (isDocumentFragment(current.nodeType)) { ++ const shadowRoot = current; ++ ++ // Try modern getComposedRanges API first ++ if ('getComposedRanges' in Selection.prototype) { ++ const globalSelection = window.getSelection(); ++ if (globalSelection) { ++ const ranges = globalSelection.getComposedRanges({ ++ shadowRoots: [shadowRoot] ++ }); ++ if (ranges.length > 0) { ++ // Use the global selection with composed ranges context ++ domSelection = globalSelection; ++ } ++ } ++ } ++ break; ++ } ++ current = current.parentNode; ++ } ++ if (!domSelection) { ++ domSelection = getSelection(); ++ } ++ const domAnchorNode = domSelection && domSelection.anchorNode; + const isSelectionInsideEditor = domAnchorNode !== null && editorRootElement !== null && editorRootElement.contains(domAnchorNode); + if (isSelectionInsideEditor) { + if (removeSelectionMark !== null) { +@@ -407,12 +437,27 @@ function selectionAlwaysOnDisplay(editor) { + } + } + }; +- document.addEventListener('selectionchange', onSelectionChange); ++ ++ // Get the proper document context for event listeners ++ const editorRootElement = editor.getRootElement(); ++ let targetDocument = document; ++ if (editorRootElement) { ++ let current = editorRootElement; ++ while (current) { ++ if (isDocumentFragment(current.nodeType)) { ++ targetDocument = current.ownerDocument || document; ++ break; ++ } ++ current = current.parentNode; ++ } ++ targetDocument = editorRootElement.ownerDocument || document; ++ } ++ targetDocument.addEventListener('selectionchange', onSelectionChange); + return () => { + if (removeSelectionMark !== null) { + removeSelectionMark(); + } +- document.removeEventListener('selectionchange', onSelectionChange); ++ targetDocument.removeEventListener('selectionchange', onSelectionChange); + }; + } + +@@ -524,8 +569,10 @@ function mediaFileReader(files, acceptableMimeTypes) { + * before backtracking and finding a new path. Consider solving a maze by hugging either wall, moving down a + * branch until you hit a dead-end (leaf) and backtracking to find the nearest branching path and repeat. + * It will then return all the nodes found in the search in an array of objects. +- * @param startNode - The node to start the search, if omitted, it will start at the root node. +- * @param endNode - The node to end the search, if omitted, it will find all descendants of the startingNode. ++ * Preorder traversal is used, meaning that nodes are listed in the order of when they are FIRST encountered. ++ * @param startNode - The node to start the search (inclusive), if omitted, it will start at the root node. ++ * @param endNode - The node to end the search (inclusive), if omitted, it will find all descendants of the startingNode. If endNode ++ * is an ElementNode, it will stop before visiting any of its children. + * @returns An array of objects of all the nodes found by the search, including their depth into the tree. + * \\{depth: number, node: LexicalNode\\} It will always return at least 1 node (the start node). + */ +@@ -555,8 +602,10 @@ function $reverseDfs(startNode, endNode) { + + /** + * $dfs iterator (left to right). Tree traversal is done on the fly as new values are requested with O(1) memory. +- * @param startNode - The node to start the search, if omitted, it will start at the root node. +- * @param endNode - The node to end the search, if omitted, it will find all descendants of the startingNode. ++ * Preorder traversal is used, meaning that nodes are iterated over in the order of when they are FIRST encountered. ++ * @param startNode - The node to start the search (inclusive), if omitted, it will start at the root node. ++ * @param endNode - The node to end the search (inclusive), if omitted, it will find all descendants of the startingNode. ++ * If endNode is an ElementNode, the iterator will end as soon as it reaches the endNode (no children will be visited). + * @returns An iterator, each yielded value is a DFSNode. It will always return at least 1 node (the start node). + */ + function $dfsIterator(startNode, endNode) { +@@ -571,7 +620,7 @@ function $dfsCaretIterator(direction, startNode, endNode) { + const start = startNode || root; + const startCaret = $isElementNode(start) ? $getChildCaret(start, direction) : $getSiblingCaret(start, direction); + const startDepth = $getDepth(start); +- const endCaret = endNode ? $getAdjacentChildCaret($getChildCaretOrSelf($getSiblingCaret(endNode, direction))) : $getEndCaret(start, direction); ++ const endCaret = endNode ? $getAdjacentChildCaret($getChildCaretOrSelf($getSiblingCaret(endNode, direction))) || $getEndCaret(endNode, direction) : $getEndCaret(start, direction); + let depth = startDepth; + return makeStepwiseIterator({ + hasNext: state => state !== null, +diff --git a/node_modules/@lexical/utils/LexicalUtils.prod.js b/node_modules/@lexical/utils/LexicalUtils.prod.js +index a85716c..f3ee24d 100644 +--- a/node_modules/@lexical/utils/LexicalUtils.prod.js ++++ b/node_modules/@lexical/utils/LexicalUtils.prod.js +@@ -6,4 +6,4 @@ + * + */ + +-"use strict";var e=require("lexical"),t=require("@lexical/selection");function n(e,...t){const n=new URL("https://lexical.dev/docs/error"),r=new URLSearchParams;r.append("code",e);for(const e of t)r.append("v",e);throw n.search=r.toString(),Error(`Minified Lexical error #${e}; visit ${n.toString()} for the full message or use the non-minified dev environment for full errors and additional helpful warnings.`)}const r="undefined"!=typeof window&&void 0!==window.document&&void 0!==window.document.createElement,o=r&&"documentMode"in document?document.documentMode:null,i=r&&/Mac|iPod|iPhone|iPad/.test(navigator.platform),s=r&&/^(?!.*Seamonkey)(?=.*Firefox).*/i.test(navigator.userAgent),l=!(!r||!("InputEvent"in window)||o)&&"getTargetRanges"in new window.InputEvent("input"),a=r&&/Version\/[\d.]+.*Safari/.test(navigator.userAgent),c=r&&/iPad|iPhone|iPod/.test(navigator.userAgent)&&!window.MSStream,u=r&&/Android/.test(navigator.userAgent),d=r&&/^(?=.*Chrome).*/i.test(navigator.userAgent),g=r&&u&&d,f=r&&/AppleWebKit\/[\d.]+/.test(navigator.userAgent)&&i&&!d;function p(...e){const t=[];for(const n of e)if(n&&"string"==typeof n)for(const[e]of n.matchAll(/\S+/g))t.push(e);return t}function m(...e){return()=>{for(let t=e.length-1;t>=0;t--)e[t]();e.length=0}}function h(e){return`${e}px`}const $={attributes:!0,characterData:!0,childList:!0,subtree:!0};function x(r,o,i){let s=null,l=null,a=null,c=[];const u=document.createElement("div");function d(){null===s&&n(182),null===l&&n(183);const{left:e,top:a}=l.getBoundingClientRect(),d=t.createRectsFromDOMRange(r,o);var g,f;u.isConnected||(f=u,(g=l).insertBefore(f,g.firstChild));let p=!1;for(let t=0;td.length;)c.pop();p&&i(c)}function g(){l=null,s=null,null!==a&&a.disconnect(),a=null,u.remove();for(const e of c)e.remove();c=[]}u.style.position="relative";const f=r.registerRootListener(function t(){const n=r.getRootElement();if(null===n)return g();const o=n.parentElement;if(!e.isHTMLElement(o))return g();g(),s=n,l=o,a=new MutationObserver(e=>{const n=r.getRootElement(),o=n&&n.parentElement;if(n!==s||o!==l)return t();for(const t of e)if(!u.contains(t.target))return d()}),a.observe(o,$),d()});return()=>{f(),g()}}function S(t,n,r){if("text"!==t.type&&e.$isElementNode(n)){const e=n.getDOMSlot(r);return[e.element,e.getFirstChildOffset()+t.offset]}return[e.getDOMTextNode(r)||r,t.offset]}function C(t,n){let r=null,o=null,i=null,s=null,l=null,a=null,c=()=>{};function u(u){u.read(()=>{const u=e.$getSelection();if(!e.$isRangeSelection(u))return r=null,i=null,s=null,a=null,c(),void(c=()=>{});const[d,g]=function(e){const t=e.getStartEndPoints();return e.isBackward()?[t[1],t[0]]:t}(u),f=d.getNode(),p=f.getKey(),m=d.offset,$=g.getNode(),C=$.getKey(),E=g.offset,v=t.getElementByKey(p),N=t.getElementByKey(C),A=null===r||v!==o||m!==i||p!==r.getKey(),w=null===s||N!==l||E!==a||C!==s.getKey();if((A||w)&&null!==v&&null!==N){const e=function(e,t,n,r,o,i,s){const l=(e._window?e._window.document:document).createRange();return l.setStart(...S(t,n,r)),l.setEnd(...S(o,i,s)),l}(t,d,f,v,g,$,N);c(),c=x(t,e,e=>{if(void 0===n)for(const t of e){const e=t.style;"Highlight"!==e.background&&(e.background="Highlight"),"HighlightText"!==e.color&&(e.color="HighlightText"),e.marginTop!==h(-1.5)&&(e.marginTop=h(-1.5)),e.paddingTop!==h(4)&&(e.paddingTop=h(4)),e.paddingBottom!==h(0)&&(e.paddingBottom=h(0))}else n(e)})}r=f,o=v,i=m,s=$,l=N,a=E})}return u(t.getEditorState()),m(t.registerUpdateListener(({editorState:e})=>u(e)),()=>{c()})}const E=l,v=r,N=u,A=g,w=i,b=f,y=d,P=s,R=c,I=a;function O(e,t){for(const n of t)if(e.type.startsWith(n))return!0;return!1}function M(e,t){return T("next",e,t)}function T(t,n,r){const o=e.$getRoot(),i=n||o,s=e.$isElementNode(i)?e.$getChildCaret(i,t):e.$getSiblingCaret(i,t),l=L(i),a=r?e.$getAdjacentChildCaret(e.$getChildCaretOrSelf(e.$getSiblingCaret(r,t))):function(t,n){const r=e.$getAdjacentSiblingOrParentSiblingCaret(e.$getSiblingCaret(t,n));return r&&r[0]}(i,t);let c=l;return e.makeStepwiseIterator({hasNext:e=>null!==e,initial:s,map:e=>({depth:c,node:e.origin}),step:t=>{if(t.isSameNodeCaret(a))return null;e.$isChildCaret(t)&&c++;const n=e.$getAdjacentSiblingOrParentSiblingCaret(t);return!n||n[0].isSameNodeCaret(a)?null:(c+=n[1],n[0])}})}function L(e){let t=-1;for(let n=e;null!==n;n=n.getParent())t++;return t}function _(e,t){return T("previous",e,t)}function D(t,r,o){let i=e.$getCaretInDirection(r,"next");for(let t=i;t;t=e.$splitAtPointCaretNext(t,o))i=t;return e.$isTextPointCaret(i)&&n(283),i.insert(t.isInline()?e.$createParagraphNode().append(t):t),e.$getCaretInDirection(e.$getSiblingCaret(t.getLatest(),"next"),r.direction)}let F=!(P||!v)&&void 0;function B(t,n,r){let o=!1;for(const i of j(t))n(i)?null!==r&&r(i):(o=!0,e.$isElementNode(i)&&B(i,n,r||(e=>i.insertAfter(e))),i.remove());return o}function j(t){return k(e.$getChildCaret(t,"previous"))}function k(t){return e.makeStepwiseIterator({hasNext:e.$isSiblingCaret,initial:t.getAdjacentCaret(),map:e=>e.origin.getLatest(),step:e=>e.getAdjacentCaret()})}exports.$findMatchingParent=e.$findMatchingParent,exports.$getAdjacentSiblingOrParentSiblingCaret=e.$getAdjacentSiblingOrParentSiblingCaret,exports.$splitNode=e.$splitNode,exports.isBlockDomNode=e.isBlockDomNode,exports.isHTMLAnchorElement=e.isHTMLAnchorElement,exports.isHTMLElement=e.isHTMLElement,exports.isInlineDomNode=e.isInlineDomNode,exports.$descendantsMatching=function(t,n){const r=[],o=Array.from(t).reverse();for(let t=o.pop();void 0!==t;t=o.pop())if(n(t))r.push(t);else if(e.$isElementNode(t))for(const e of j(t))o.push(e);return r},exports.$dfs=function(e,t){return Array.from(M(e,t))},exports.$dfsIterator=M,exports.$filter=function(e,t){const n=[];for(let r=0;re.$isElementNode(t)&&!t.isInline());return e.$isElementNode(r)||n(4,t.__key),r},exports.$getNearestNodeOfType=function(e,t){let n=e;for(;null!=n;){if(n instanceof t)return n;n=n.getParent()}return null},exports.$getNextRightPreorderNode=function(t){const n=e.$getChildCaretOrSelf(e.$getSiblingCaret(t,"previous")),r=e.$getAdjacentSiblingOrParentSiblingCaret(n,"root");return r&&r[0].origin},exports.$getNextSiblingOrParentSibling=function(t){const n=e.$getAdjacentSiblingOrParentSiblingCaret(e.$getSiblingCaret(t,"next"));return n&&[n[0].origin,n[1]]},exports.$insertFirst=function(t,n){e.$getChildCaret(t,"next").insert(n)},exports.$insertNodeToNearestRoot=function(t){const n=e.$getSelection()||e.$getPreviousSelection();let r;if(e.$isRangeSelection(n))r=e.$caretFromPoint(n.focus,"next");else{if(null!=n){const t=n.getNodes(),o=t[t.length-1];o&&(r=e.$getSiblingCaret(o,"next"))}r=r||e.$getChildCaret(e.$getRoot(),"previous").getFlipped().insert(e.$createParagraphNode())}const o=D(t,r),i=e.$getAdjacentChildCaret(o),s=e.$isChildCaret(i)?e.$normalizeCaret(i):o;return e.$setSelectionFromCaretRange(e.$getCollapsedCaretRange(s)),t.getLatest()},exports.$insertNodeToNearestRootAtCaret=D,exports.$isEditorIsNestedEditor=function(e){return null!==e._parentEditor},exports.$lastToFirstIterator=j,exports.$restoreEditorState=function(t,n){const r=new Map,o=t._pendingEditorState;for(const[t,o]of n._nodeMap)r.set(t,e.$cloneWithProperties(o));o&&(o._nodeMap=r),t._dirtyType=2;const i=n._selection;e.$setSelection(null===i?null:i.clone())},exports.$reverseDfs=function(e,t){return Array.from(_(e,t))},exports.$reverseDfsIterator=_,exports.$unwrapAndFilterDescendants=function(e,t){return B(e,t,null)},exports.$unwrapNode=function(t){e.$rewindSiblingCaret(e.$getSiblingCaret(t,"next")).splice(1,t.getChildren())},exports.$wrapNodeInElement=function(e,t){const n=t();return e.replace(n),n.append(e),n},exports.CAN_USE_BEFORE_INPUT=E,exports.CAN_USE_DOM=v,exports.IS_ANDROID=N,exports.IS_ANDROID_CHROME=A,exports.IS_APPLE=w,exports.IS_APPLE_WEBKIT=b,exports.IS_CHROME=y,exports.IS_FIREFOX=P,exports.IS_IOS=R,exports.IS_SAFARI=I,exports.addClassNamesToElement=function(e,...t){const n=p(...t);n.length>0&&e.classList.add(...n)},exports.calculateZoomLevel=function(e){let t=1;if(function(){if(void 0===F){const e=document.createElement("div");e.style.cssText="position: absolute; opacity: 0; width: 100px; left: -1000px;",document.body.appendChild(e);const t=e.getBoundingClientRect();e.style.setProperty("zoom","2"),F=e.getBoundingClientRect().width===t.width,document.body.removeChild(e)}return F}())for(;e;)t*=Number(window.getComputedStyle(e).getPropertyValue("zoom")),e=e.parentElement;return t},exports.isMimeType=O,exports.makeStateWrapper=function(t){const n=n=>e.$getState(n,t),r=(n,r)=>e.$setState(n,t,r);return{$get:n,$set:r,accessors:[n,r],makeGetterMethod:()=>function(){return n(this)},makeSetterMethod:()=>function(e){return r(this,e)},stateConfig:t}},exports.markSelection=C,exports.mediaFileReader=function(e,t){const n=e[Symbol.iterator]();return new Promise((e,r)=>{const o=[],i=()=>{const{done:s,value:l}=n.next();if(s)return e(o);const a=new FileReader;a.addEventListener("error",r),a.addEventListener("load",()=>{const e=a.result;"string"==typeof e&&o.push({file:l,result:e}),i()}),O(l,t)?a.readAsDataURL(l):i()};i()})},exports.mergeRegister=m,exports.objectKlassEquals=function(e,t){return null!==e&&Object.getPrototypeOf(e).constructor.name===t.name},exports.positionNodeOnRange=x,exports.registerNestedElementResolver=function(e,t,n,r){const o=e=>e instanceof t;return e.registerNodeTransform(t,e=>{const t=(e=>{const t=e.getChildren();for(let e=0;e0&&e.classList.remove(...n)},exports.selectionAlwaysOnDisplay=function(e){let t=null;const n=()=>{const n=getSelection(),r=n&&n.anchorNode,o=e.getRootElement();null!==r&&null!==o&&o.contains(r)?null!==t&&(t(),t=null):null===t&&(t=C(e))};return document.addEventListener("selectionchange",n),()=>{null!==t&&t(),document.removeEventListener("selectionchange",n)}}; ++"use strict";var e=require("lexical"),t=require("@lexical/selection");function n(e,...t){const n=new URL("https://lexical.dev/docs/error"),o=new URLSearchParams;o.append("code",e);for(const e of t)o.append("v",e);throw n.search=o.toString(),Error(`Minified Lexical error #${e}; visit ${n.toString()} for the full message or use the non-minified dev environment for full errors and additional helpful warnings.`)}const o="undefined"!=typeof window&&void 0!==window.document&&void 0!==window.document.createElement,r=o&&"documentMode"in document?document.documentMode:null,i=o&&/Mac|iPod|iPhone|iPad/.test(navigator.platform),s=o&&/^(?!.*Seamonkey)(?=.*Firefox).*/i.test(navigator.userAgent),l=!(!o||!("InputEvent"in window)||r)&&"getTargetRanges"in new window.InputEvent("input"),a=o&&/Version\/[\d.]+.*Safari/.test(navigator.userAgent),c=o&&/iPad|iPhone|iPod/.test(navigator.userAgent)&&!window.MSStream,u=o&&/Android/.test(navigator.userAgent),d=o&&/^(?=.*Chrome).*/i.test(navigator.userAgent),g=o&&u&&d,f=o&&/AppleWebKit\/[\d.]+/.test(navigator.userAgent)&&i&&!d;function p(...e){const t=[];for(const n of e)if(n&&"string"==typeof n)for(const[e]of n.matchAll(/\S+/g))t.push(e);return t}function m(...e){return()=>{for(let t=e.length-1;t>=0;t--)e[t]();e.length=0}}function h(e){return`${e}px`}const $={attributes:!0,characterData:!0,childList:!0,subtree:!0};function x(o,r,i){let s=null,l=null,a=null,c=[];const u=document.createElement("div");function d(){null===s&&n(182),null===l&&n(183);const{left:e,top:a}=l.getBoundingClientRect(),d=t.createRectsFromDOMRange(o,r);var g,f;u.isConnected||(f=u,(g=l).insertBefore(f,g.firstChild));let p=!1;for(let t=0;td.length;)c.pop();p&&i(c)}function g(){l=null,s=null,null!==a&&a.disconnect(),a=null,u.remove();for(const e of c)e.remove();c=[]}u.style.position="relative";const f=o.registerRootListener(function t(){const n=o.getRootElement();if(null===n)return g();const r=n.parentElement;if(!e.isHTMLElement(r))return g();g(),s=n,l=r,a=new MutationObserver(e=>{const n=o.getRootElement(),r=n&&n.parentElement;if(n!==s||r!==l)return t();for(const t of e)if(!u.contains(t.target))return d()}),a.observe(r,$),d()});return()=>{f(),g()}}function S(t,n,o){if("text"!==t.type&&e.$isElementNode(n)){const e=n.getDOMSlot(o);return[e.element,e.getFirstChildOffset()+t.offset]}return[e.getDOMTextNode(o)||o,t.offset]}function C(t,n){let o=null,r=null,i=null,s=null,l=null,a=null,c=()=>{};function u(u){u.read(()=>{const u=e.$getSelection();if(!e.$isRangeSelection(u))return o=null,i=null,s=null,a=null,c(),void(c=()=>{});const[d,g]=function(e){const t=e.getStartEndPoints();return e.isBackward()?[t[1],t[0]]:t}(u),f=d.getNode(),p=f.getKey(),m=d.offset,$=g.getNode(),C=$.getKey(),E=g.offset,v=t.getElementByKey(p),N=t.getElementByKey(C),w=null===o||v!==r||m!==i||p!==o.getKey(),y=null===s||N!==l||E!==a||C!==s.getKey();if((w||y)&&null!==v&&null!==N){const e=function(e,t,n,o,r,i,s){const l=(e._window?e._window.document:document).createRange();return l.setStart(...S(t,n,o)),l.setEnd(...S(r,i,s)),l}(t,d,f,v,g,$,N);c(),c=x(t,e,e=>{if(void 0===n)for(const t of e){const e=t.style;"Highlight"!==e.background&&(e.background="Highlight"),"HighlightText"!==e.color&&(e.color="HighlightText"),e.marginTop!==h(-1.5)&&(e.marginTop=h(-1.5)),e.paddingTop!==h(4)&&(e.paddingTop=h(4)),e.paddingBottom!==h(0)&&(e.paddingBottom=h(0))}else n(e)})}o=f,r=v,i=m,s=$,l=N,a=E})}return u(t.getEditorState()),m(t.registerUpdateListener(({editorState:e})=>u(e)),()=>{c()})}const E=l,v=o,N=u,w=g,y=i,b=f,A=d,R=s,P=c,I=a;function T(e,t){for(const n of t)if(e.type.startsWith(n))return!0;return!1}function O(e,t){return D("next",e,t)}function M(t,n){const o=e.$getAdjacentSiblingOrParentSiblingCaret(e.$getSiblingCaret(t,n));return o&&o[0]}function D(t,n,o){const r=e.$getRoot(),i=n||r,s=e.$isElementNode(i)?e.$getChildCaret(i,t):e.$getSiblingCaret(i,t),l=L(i),a=o?e.$getAdjacentChildCaret(e.$getChildCaretOrSelf(e.$getSiblingCaret(o,t)))||M(o,t):M(i,t);let c=l;return e.makeStepwiseIterator({hasNext:e=>null!==e,initial:s,map:e=>({depth:c,node:e.origin}),step:t=>{if(t.isSameNodeCaret(a))return null;e.$isChildCaret(t)&&c++;const n=e.$getAdjacentSiblingOrParentSiblingCaret(t);return!n||n[0].isSameNodeCaret(a)?null:(c+=n[1],n[0])}})}function L(e){let t=-1;for(let n=e;null!==n;n=n.getParent())t++;return t}function _(e,t){return D("previous",e,t)}function F(t,o,r){let i=e.$getCaretInDirection(o,"next");for(let t=i;t;t=e.$splitAtPointCaretNext(t,r))i=t;return e.$isTextPointCaret(i)&&n(283),i.insert(t.isInline()?e.$createParagraphNode().append(t):t),e.$getCaretInDirection(e.$getSiblingCaret(t.getLatest(),"next"),o.direction)}let k=!(R||!v)&&void 0;function B(t,n,o){let r=!1;for(const i of j(t))n(i)?null!==o&&o(i):(r=!0,e.$isElementNode(i)&&B(i,n,o||(e=>i.insertAfter(e))),i.remove());return r}function j(t){return H(e.$getChildCaret(t,"previous"))}function H(t){return e.makeStepwiseIterator({hasNext:e.$isSiblingCaret,initial:t.getAdjacentCaret(),map:e=>e.origin.getLatest(),step:e=>e.getAdjacentCaret()})}exports.$findMatchingParent=e.$findMatchingParent,exports.$getAdjacentSiblingOrParentSiblingCaret=e.$getAdjacentSiblingOrParentSiblingCaret,exports.$splitNode=e.$splitNode,exports.isBlockDomNode=e.isBlockDomNode,exports.isHTMLAnchorElement=e.isHTMLAnchorElement,exports.isHTMLElement=e.isHTMLElement,exports.isInlineDomNode=e.isInlineDomNode,exports.$descendantsMatching=function(t,n){const o=[],r=Array.from(t).reverse();for(let t=r.pop();void 0!==t;t=r.pop())if(n(t))o.push(t);else if(e.$isElementNode(t))for(const e of j(t))r.push(e);return o},exports.$dfs=function(e,t){return Array.from(O(e,t))},exports.$dfsIterator=O,exports.$filter=function(e,t){const n=[];for(let o=0;oe.$isElementNode(t)&&!t.isInline());return e.$isElementNode(o)||n(4,t.__key),o},exports.$getNearestNodeOfType=function(e,t){let n=e;for(;null!=n;){if(n instanceof t)return n;n=n.getParent()}return null},exports.$getNextRightPreorderNode=function(t){const n=e.$getChildCaretOrSelf(e.$getSiblingCaret(t,"previous")),o=e.$getAdjacentSiblingOrParentSiblingCaret(n,"root");return o&&o[0].origin},exports.$getNextSiblingOrParentSibling=function(t){const n=e.$getAdjacentSiblingOrParentSiblingCaret(e.$getSiblingCaret(t,"next"));return n&&[n[0].origin,n[1]]},exports.$insertFirst=function(t,n){e.$getChildCaret(t,"next").insert(n)},exports.$insertNodeToNearestRoot=function(t){const n=e.$getSelection()||e.$getPreviousSelection();let o;if(e.$isRangeSelection(n))o=e.$caretFromPoint(n.focus,"next");else{if(null!=n){const t=n.getNodes(),r=t[t.length-1];r&&(o=e.$getSiblingCaret(r,"next"))}o=o||e.$getChildCaret(e.$getRoot(),"previous").getFlipped().insert(e.$createParagraphNode())}const r=F(t,o),i=e.$getAdjacentChildCaret(r),s=e.$isChildCaret(i)?e.$normalizeCaret(i):r;return e.$setSelectionFromCaretRange(e.$getCollapsedCaretRange(s)),t.getLatest()},exports.$insertNodeToNearestRootAtCaret=F,exports.$isEditorIsNestedEditor=function(e){return null!==e._parentEditor},exports.$lastToFirstIterator=j,exports.$restoreEditorState=function(t,n){const o=new Map,r=t._pendingEditorState;for(const[t,r]of n._nodeMap)o.set(t,e.$cloneWithProperties(r));r&&(r._nodeMap=o),t._dirtyType=2;const i=n._selection;e.$setSelection(null===i?null:i.clone())},exports.$reverseDfs=function(e,t){return Array.from(_(e,t))},exports.$reverseDfsIterator=_,exports.$unwrapAndFilterDescendants=function(e,t){return B(e,t,null)},exports.$unwrapNode=function(t){e.$rewindSiblingCaret(e.$getSiblingCaret(t,"next")).splice(1,t.getChildren())},exports.$wrapNodeInElement=function(e,t){const n=t();return e.replace(n),n.append(e),n},exports.CAN_USE_BEFORE_INPUT=E,exports.CAN_USE_DOM=v,exports.IS_ANDROID=N,exports.IS_ANDROID_CHROME=w,exports.IS_APPLE=y,exports.IS_APPLE_WEBKIT=b,exports.IS_CHROME=A,exports.IS_FIREFOX=R,exports.IS_IOS=P,exports.IS_SAFARI=I,exports.addClassNamesToElement=function(e,...t){const n=p(...t);n.length>0&&e.classList.add(...n)},exports.calculateZoomLevel=function(e){let t=1;if(function(){if(void 0===k){const e=document.createElement("div");e.style.cssText="position: absolute; opacity: 0; width: 100px; left: -1000px;",document.body.appendChild(e);const t=e.getBoundingClientRect();e.style.setProperty("zoom","2"),k=e.getBoundingClientRect().width===t.width,document.body.removeChild(e)}return k}())for(;e;)t*=Number(window.getComputedStyle(e).getPropertyValue("zoom")),e=e.parentElement;return t},exports.isMimeType=T,exports.makeStateWrapper=function(t){const n=n=>e.$getState(n,t),o=(n,o)=>e.$setState(n,t,o);return{$get:n,$set:o,accessors:[n,o],makeGetterMethod:()=>function(){return n(this)},makeSetterMethod:()=>function(e){return o(this,e)},stateConfig:t}},exports.markSelection=C,exports.mediaFileReader=function(e,t){const n=e[Symbol.iterator]();return new Promise((e,o)=>{const r=[],i=()=>{const{done:s,value:l}=n.next();if(s)return e(r);const a=new FileReader;a.addEventListener("error",o),a.addEventListener("load",()=>{const e=a.result;"string"==typeof e&&r.push({file:l,result:e}),i()}),T(l,t)?a.readAsDataURL(l):i()};i()})},exports.mergeRegister=m,exports.objectKlassEquals=function(e,t){return null!==e&&Object.getPrototypeOf(e).constructor.name===t.name},exports.positionNodeOnRange=x,exports.registerNestedElementResolver=function(e,t,n,o){const r=e=>e instanceof t;return e.registerNodeTransform(t,e=>{const t=(e=>{const t=e.getChildren();for(let e=0;e0&&e.classList.remove(...n)},exports.selectionAlwaysOnDisplay=function(t){let n=null;const o=()=>{const o=t.getRootElement();if(!o)return;let r=null,i=o;for(;i;){if(e.isDocumentFragment(i.nodeType)){const e=i;if("getComposedRanges"in Selection.prototype){const t=window.getSelection();if(t){t.getComposedRanges({shadowRoots:[e]}).length>0&&(r=t)}}break}i=i.parentNode}r||(r=getSelection());const s=r&&r.anchorNode;null!==s&&null!==o&&o.contains(s)?null!==n&&(n(),n=null):null===n&&(n=C(t))},r=t.getRootElement();let i=document;if(r){let t=r;for(;t;){if(e.isDocumentFragment(t.nodeType)){i=t.ownerDocument||document;break}t=t.parentNode}i=r.ownerDocument||document}return i.addEventListener("selectionchange",o),()=>{null!==n&&n(),i.removeEventListener("selectionchange",o)}}; +diff --git a/node_modules/@lexical/utils/LexicalUtils.prod.mjs b/node_modules/@lexical/utils/LexicalUtils.prod.mjs +index 012f410..f8b373d 100644 +--- a/node_modules/@lexical/utils/LexicalUtils.prod.mjs ++++ b/node_modules/@lexical/utils/LexicalUtils.prod.mjs +@@ -6,4 +6,4 @@ + * + */ + +-import{isHTMLElement as t,$getSelection as e,$isRangeSelection as n,$isElementNode as o,getDOMTextNode as r,$getAdjacentSiblingOrParentSiblingCaret as i,$getSiblingCaret as l,$getChildCaretOrSelf as u,$findMatchingParent as s,$cloneWithProperties as c,$setSelection as a,$getPreviousSelection as f,$caretFromPoint as d,$getChildCaret as g,$getRoot as p,$createParagraphNode as m,$getAdjacentChildCaret as h,$isChildCaret as v,$normalizeCaret as y,$setSelectionFromCaretRange as w,$getCollapsedCaretRange as x,$getCaretInDirection as E,$splitAtPointCaretNext as S,$isTextPointCaret as A,$rewindSiblingCaret as C,$getState as b,$setState as L,makeStepwiseIterator as P,$isSiblingCaret as N}from"lexical";export{$findMatchingParent,$getAdjacentSiblingOrParentSiblingCaret,$splitNode,isBlockDomNode,isHTMLAnchorElement,isHTMLElement,isInlineDomNode}from"lexical";import{createRectsFromDOMRange as M}from"@lexical/selection";function R(t,...e){const n=new URL("https://lexical.dev/docs/error"),o=new URLSearchParams;o.append("code",t);for(const t of e)o.append("v",t);throw n.search=o.toString(),Error(`Minified Lexical error #${t}; visit ${n.toString()} for the full message or use the non-minified dev environment for full errors and additional helpful warnings.`)}const T="undefined"!=typeof window&&void 0!==window.document&&void 0!==window.document.createElement,B=T&&"documentMode"in document?document.documentMode:null,_=T&&/Mac|iPod|iPhone|iPad/.test(navigator.platform),k=T&&/^(?!.*Seamonkey)(?=.*Firefox).*/i.test(navigator.userAgent),$=!(!T||!("InputEvent"in window)||B)&&"getTargetRanges"in new window.InputEvent("input"),K=T&&/Version\/[\d.]+.*Safari/.test(navigator.userAgent),O=T&&/iPad|iPhone|iPod/.test(navigator.userAgent)&&!window.MSStream,H=T&&/Android/.test(navigator.userAgent),j=T&&/^(?=.*Chrome).*/i.test(navigator.userAgent),D=T&&H&&j,I=T&&/AppleWebKit\/[\d.]+/.test(navigator.userAgent)&&_&&!j;function F(...t){const e=[];for(const n of t)if(n&&"string"==typeof n)for(const[t]of n.matchAll(/\S+/g))e.push(t);return e}function U(...t){return()=>{for(let e=t.length-1;e>=0;e--)t[e]();t.length=0}}function z(t){return`${t}px`}const V={attributes:!0,characterData:!0,childList:!0,subtree:!0};function W(e,n,o){let r=null,i=null,l=null,u=[];const s=document.createElement("div");function c(){null===r&&R(182),null===i&&R(183);const{left:t,top:l}=i.getBoundingClientRect(),c=M(e,n);var a,f;s.isConnected||(f=s,(a=i).insertBefore(f,a.firstChild));let d=!1;for(let e=0;ec.length;)u.pop();d&&o(u)}function a(){i=null,r=null,null!==l&&l.disconnect(),l=null,s.remove();for(const t of u)t.remove();u=[]}s.style.position="relative";const f=e.registerRootListener(function n(){const o=e.getRootElement();if(null===o)return a();const u=o.parentElement;if(!t(u))return a();a(),r=o,i=u,l=new MutationObserver(t=>{const o=e.getRootElement(),l=o&&o.parentElement;if(o!==r||l!==i)return n();for(const e of t)if(!s.contains(e.target))return c()}),l.observe(u,V),c()});return()=>{f(),a()}}function G(t,e,n){if("text"!==t.type&&o(e)){const o=e.getDOMSlot(n);return[o.element,o.getFirstChildOffset()+t.offset]}return[r(n)||n,t.offset]}function q(t,o){let r=null,i=null,l=null,u=null,s=null,c=null,a=()=>{};function f(f){f.read(()=>{const f=e();if(!n(f))return r=null,l=null,u=null,c=null,a(),void(a=()=>{});const[d,g]=function(t){const e=t.getStartEndPoints();return t.isBackward()?[e[1],e[0]]:e}(f),p=d.getNode(),m=p.getKey(),h=d.offset,v=g.getNode(),y=v.getKey(),w=g.offset,x=t.getElementByKey(m),E=t.getElementByKey(y),S=null===r||x!==i||h!==l||m!==r.getKey(),A=null===u||E!==s||w!==c||y!==u.getKey();if((S||A)&&null!==x&&null!==E){const e=function(t,e,n,o,r,i,l){const u=(t._window?t._window.document:document).createRange();return u.setStart(...G(e,n,o)),u.setEnd(...G(r,i,l)),u}(t,d,p,x,g,v,E);a(),a=W(t,e,t=>{if(void 0===o)for(const e of t){const t=e.style;"Highlight"!==t.background&&(t.background="Highlight"),"HighlightText"!==t.color&&(t.color="HighlightText"),t.marginTop!==z(-1.5)&&(t.marginTop=z(-1.5)),t.paddingTop!==z(4)&&(t.paddingTop=z(4)),t.paddingBottom!==z(0)&&(t.paddingBottom=z(0))}else o(t)})}r=p,i=x,l=h,u=v,s=E,c=w})}return f(t.getEditorState()),U(t.registerUpdateListener(({editorState:t})=>f(t)),()=>{a()})}function J(t){let e=null;const n=()=>{const n=getSelection(),o=n&&n.anchorNode,r=t.getRootElement();null!==o&&null!==r&&r.contains(o)?null!==e&&(e(),e=null):null===e&&(e=q(t))};return document.addEventListener("selectionchange",n),()=>{null!==e&&e(),document.removeEventListener("selectionchange",n)}}const Q=$,X=T,Y=H,Z=D,tt=_,et=I,nt=j,ot=k,rt=O,it=K;function lt(t,...e){const n=F(...e);n.length>0&&t.classList.add(...n)}function ut(t,...e){const n=F(...e);n.length>0&&t.classList.remove(...n)}function st(t,e){for(const n of e)if(t.type.startsWith(n))return!0;return!1}function ct(t,e){const n=t[Symbol.iterator]();return new Promise((t,o)=>{const r=[],i=()=>{const{done:l,value:u}=n.next();if(l)return t(r);const s=new FileReader;s.addEventListener("error",o),s.addEventListener("load",()=>{const t=s.result;"string"==typeof t&&r.push({file:u,result:t}),i()}),st(u,e)?s.readAsDataURL(u):i()};i()})}function at(t,e){return Array.from(gt(t,e))}function ft(t){return t?t.getAdjacentCaret():null}function dt(t,e){return Array.from(yt(t,e))}function gt(t,e){return pt("next",t,e)}function pt(t,e,n){const r=p(),s=e||r,c=o(s)?g(s,t):l(s,t),a=ht(s),f=n?h(u(l(n,t))):function(t,e){const n=i(l(t,e));return n&&n[0]}(s,t);let d=a;return P({hasNext:t=>null!==t,initial:c,map:t=>({depth:d,node:t.origin}),step:t=>{if(t.isSameNodeCaret(f))return null;v(t)&&d++;const e=i(t);return!e||e[0].isSameNodeCaret(f)?null:(d+=e[1],e[0])}})}function mt(t){const e=i(l(t,"next"));return e&&[e[0].origin,e[1]]}function ht(t){let e=-1;for(let n=t;null!==n;n=n.getParent())e++;return e}function vt(t){const e=u(l(t,"previous")),n=i(e,"root");return n&&n[0].origin}function yt(t,e){return pt("previous",t,e)}function wt(t,e){let n=t;for(;null!=n;){if(n instanceof e)return n;n=n.getParent()}return null}function xt(t){const e=s(t,t=>o(t)&&!t.isInline());return o(e)||R(4,t.__key),e}function Et(t,e,n,o){const r=t=>t instanceof e;return t.registerNodeTransform(e,t=>{const e=(t=>{const e=t.getChildren();for(let t=0;ti.insertAfter(t))),i.remove());return r}function kt(t,e){const n=[],r=Array.from(t).reverse();for(let t=r.pop();void 0!==t;t=r.pop())if(e(t))n.push(t);else if(o(t))for(const e of Kt(t))r.push(e);return n}function $t(t){return Ot(g(t,"next"))}function Kt(t){return Ot(g(t,"previous"))}function Ot(t){return P({hasNext:N,initial:t.getAdjacentCaret(),map:t=>t.origin.getLatest(),step:t=>t.getAdjacentCaret()})}function Ht(t){C(l(t,"next")).splice(1,t.getChildren())}function jt(t){const e=e=>b(e,t),n=(e,n)=>L(e,t,n);return{$get:e,$set:n,accessors:[e,n],makeGetterMethod:()=>function(){return e(this)},makeSetterMethod:()=>function(t){return n(this,t)},stateConfig:t}}export{kt as $descendantsMatching,at as $dfs,gt as $dfsIterator,Pt as $filter,$t as $firstToLastIterator,ft as $getAdjacentCaret,ht as $getDepth,xt as $getNearestBlockElementAncestorOrThrow,wt as $getNearestNodeOfType,vt as $getNextRightPreorderNode,mt as $getNextSiblingOrParentSibling,Nt as $insertFirst,At as $insertNodeToNearestRoot,Ct as $insertNodeToNearestRootAtCaret,Tt as $isEditorIsNestedEditor,Kt as $lastToFirstIterator,St as $restoreEditorState,dt as $reverseDfs,yt as $reverseDfsIterator,Bt as $unwrapAndFilterDescendants,Ht as $unwrapNode,bt as $wrapNodeInElement,Q as CAN_USE_BEFORE_INPUT,X as CAN_USE_DOM,Y as IS_ANDROID,Z as IS_ANDROID_CHROME,tt as IS_APPLE,et as IS_APPLE_WEBKIT,nt as IS_CHROME,ot as IS_FIREFOX,rt as IS_IOS,it as IS_SAFARI,lt as addClassNamesToElement,Rt as calculateZoomLevel,st as isMimeType,jt as makeStateWrapper,q as markSelection,ct as mediaFileReader,U as mergeRegister,Lt as objectKlassEquals,W as positionNodeOnRange,Et as registerNestedElementResolver,ut as removeClassNamesFromElement,J as selectionAlwaysOnDisplay}; ++import{isHTMLElement as t,$getSelection as e,$isRangeSelection as n,$isElementNode as o,getDOMTextNode as r,isDocumentFragment as i,$getAdjacentSiblingOrParentSiblingCaret as l,$getSiblingCaret as s,$getChildCaretOrSelf as u,$findMatchingParent as c,$cloneWithProperties as f,$setSelection as a,$getPreviousSelection as d,$caretFromPoint as g,$getChildCaret as p,$getRoot as m,$createParagraphNode as h,$getAdjacentChildCaret as v,$isChildCaret as y,$normalizeCaret as w,$setSelectionFromCaretRange as x,$getCollapsedCaretRange as E,$getCaretInDirection as S,$splitAtPointCaretNext as C,$isTextPointCaret as A,$rewindSiblingCaret as b,$getState as L,$setState as N,makeStepwiseIterator as R,$isSiblingCaret as P}from"lexical";export{$findMatchingParent,$getAdjacentSiblingOrParentSiblingCaret,$splitNode,isBlockDomNode,isHTMLAnchorElement,isHTMLElement,isInlineDomNode}from"lexical";import{createRectsFromDOMRange as M}from"@lexical/selection";function T(t,...e){const n=new URL("https://lexical.dev/docs/error"),o=new URLSearchParams;o.append("code",t);for(const t of e)o.append("v",t);throw n.search=o.toString(),Error(`Minified Lexical error #${t}; visit ${n.toString()} for the full message or use the non-minified dev environment for full errors and additional helpful warnings.`)}const B="undefined"!=typeof window&&void 0!==window.document&&void 0!==window.document.createElement,k=B&&"documentMode"in document?document.documentMode:null,_=B&&/Mac|iPod|iPhone|iPad/.test(navigator.platform),$=B&&/^(?!.*Seamonkey)(?=.*Firefox).*/i.test(navigator.userAgent),D=!(!B||!("InputEvent"in window)||k)&&"getTargetRanges"in new window.InputEvent("input"),K=B&&/Version\/[\d.]+.*Safari/.test(navigator.userAgent),O=B&&/iPad|iPhone|iPod/.test(navigator.userAgent)&&!window.MSStream,H=B&&/Android/.test(navigator.userAgent),j=B&&/^(?=.*Chrome).*/i.test(navigator.userAgent),I=B&&H&&j,F=B&&/AppleWebKit\/[\d.]+/.test(navigator.userAgent)&&_&&!j;function U(...t){const e=[];for(const n of t)if(n&&"string"==typeof n)for(const[t]of n.matchAll(/\S+/g))e.push(t);return e}function z(...t){return()=>{for(let e=t.length-1;e>=0;e--)t[e]();t.length=0}}function V(t){return`${t}px`}const W={attributes:!0,characterData:!0,childList:!0,subtree:!0};function G(e,n,o){let r=null,i=null,l=null,s=[];const u=document.createElement("div");function c(){null===r&&T(182),null===i&&T(183);const{left:t,top:l}=i.getBoundingClientRect(),c=M(e,n);var f,a;u.isConnected||(a=u,(f=i).insertBefore(a,f.firstChild));let d=!1;for(let e=0;ec.length;)s.pop();d&&o(s)}function f(){i=null,r=null,null!==l&&l.disconnect(),l=null,u.remove();for(const t of s)t.remove();s=[]}u.style.position="relative";const a=e.registerRootListener(function n(){const o=e.getRootElement();if(null===o)return f();const s=o.parentElement;if(!t(s))return f();f(),r=o,i=s,l=new MutationObserver(t=>{const o=e.getRootElement(),l=o&&o.parentElement;if(o!==r||l!==i)return n();for(const e of t)if(!u.contains(e.target))return c()}),l.observe(s,W),c()});return()=>{a(),f()}}function q(t,e,n){if("text"!==t.type&&o(e)){const o=e.getDOMSlot(n);return[o.element,o.getFirstChildOffset()+t.offset]}return[r(n)||n,t.offset]}function J(t,o){let r=null,i=null,l=null,s=null,u=null,c=null,f=()=>{};function a(a){a.read(()=>{const a=e();if(!n(a))return r=null,l=null,s=null,c=null,f(),void(f=()=>{});const[d,g]=function(t){const e=t.getStartEndPoints();return t.isBackward()?[e[1],e[0]]:e}(a),p=d.getNode(),m=p.getKey(),h=d.offset,v=g.getNode(),y=v.getKey(),w=g.offset,x=t.getElementByKey(m),E=t.getElementByKey(y),S=null===r||x!==i||h!==l||m!==r.getKey(),C=null===s||E!==u||w!==c||y!==s.getKey();if((S||C)&&null!==x&&null!==E){const e=function(t,e,n,o,r,i,l){const s=(t._window?t._window.document:document).createRange();return s.setStart(...q(e,n,o)),s.setEnd(...q(r,i,l)),s}(t,d,p,x,g,v,E);f(),f=G(t,e,t=>{if(void 0===o)for(const e of t){const t=e.style;"Highlight"!==t.background&&(t.background="Highlight"),"HighlightText"!==t.color&&(t.color="HighlightText"),t.marginTop!==V(-1.5)&&(t.marginTop=V(-1.5)),t.paddingTop!==V(4)&&(t.paddingTop=V(4)),t.paddingBottom!==V(0)&&(t.paddingBottom=V(0))}else o(t)})}r=p,i=x,l=h,s=v,u=E,c=w})}return a(t.getEditorState()),z(t.registerUpdateListener(({editorState:t})=>a(t)),()=>{f()})}function Q(t){let e=null;const n=()=>{const n=t.getRootElement();if(!n)return;let o=null,r=n;for(;r;){if(i(r.nodeType)){const t=r;if("getComposedRanges"in Selection.prototype){const e=window.getSelection();if(e){e.getComposedRanges({shadowRoots:[t]}).length>0&&(o=e)}}break}r=r.parentNode}o||(o=getSelection());const l=o&&o.anchorNode;null!==l&&null!==n&&n.contains(l)?null!==e&&(e(),e=null):null===e&&(e=J(t))},o=t.getRootElement();let r=document;if(o){let t=o;for(;t;){if(i(t.nodeType)){r=t.ownerDocument||document;break}t=t.parentNode}r=o.ownerDocument||document}return r.addEventListener("selectionchange",n),()=>{null!==e&&e(),r.removeEventListener("selectionchange",n)}}const X=D,Y=B,Z=H,tt=I,et=_,nt=F,ot=j,rt=$,it=O,lt=K;function st(t,...e){const n=U(...e);n.length>0&&t.classList.add(...n)}function ut(t,...e){const n=U(...e);n.length>0&&t.classList.remove(...n)}function ct(t,e){for(const n of e)if(t.type.startsWith(n))return!0;return!1}function ft(t,e){const n=t[Symbol.iterator]();return new Promise((t,o)=>{const r=[],i=()=>{const{done:l,value:s}=n.next();if(l)return t(r);const u=new FileReader;u.addEventListener("error",o),u.addEventListener("load",()=>{const t=u.result;"string"==typeof t&&r.push({file:s,result:t}),i()}),ct(s,e)?u.readAsDataURL(s):i()};i()})}function at(t,e){return Array.from(pt(t,e))}function dt(t){return t?t.getAdjacentCaret():null}function gt(t,e){return Array.from(xt(t,e))}function pt(t,e){return ht("next",t,e)}function mt(t,e){const n=l(s(t,e));return n&&n[0]}function ht(t,e,n){const r=m(),i=e||r,c=o(i)?p(i,t):s(i,t),f=yt(i),a=n?v(u(s(n,t)))||mt(n,t):mt(i,t);let d=f;return R({hasNext:t=>null!==t,initial:c,map:t=>({depth:d,node:t.origin}),step:t=>{if(t.isSameNodeCaret(a))return null;y(t)&&d++;const e=l(t);return!e||e[0].isSameNodeCaret(a)?null:(d+=e[1],e[0])}})}function vt(t){const e=l(s(t,"next"));return e&&[e[0].origin,e[1]]}function yt(t){let e=-1;for(let n=t;null!==n;n=n.getParent())e++;return e}function wt(t){const e=u(s(t,"previous")),n=l(e,"root");return n&&n[0].origin}function xt(t,e){return ht("previous",t,e)}function Et(t,e){let n=t;for(;null!=n;){if(n instanceof e)return n;n=n.getParent()}return null}function St(t){const e=c(t,t=>o(t)&&!t.isInline());return o(e)||T(4,t.__key),e}function Ct(t,e,n,o){const r=t=>t instanceof e;return t.registerNodeTransform(e,t=>{const e=(t=>{const e=t.getChildren();for(let t=0;ti.insertAfter(t))),i.remove());return r}function Dt(t,e){const n=[],r=Array.from(t).reverse();for(let t=r.pop();void 0!==t;t=r.pop())if(e(t))n.push(t);else if(o(t))for(const e of Ot(t))r.push(e);return n}function Kt(t){return Ht(p(t,"next"))}function Ot(t){return Ht(p(t,"previous"))}function Ht(t){return R({hasNext:P,initial:t.getAdjacentCaret(),map:t=>t.origin.getLatest(),step:t=>t.getAdjacentCaret()})}function jt(t){b(s(t,"next")).splice(1,t.getChildren())}function It(t){const e=e=>L(e,t),n=(e,n)=>N(e,t,n);return{$get:e,$set:n,accessors:[e,n],makeGetterMethod:()=>function(){return e(this)},makeSetterMethod:()=>function(t){return n(this,t)},stateConfig:t}}export{Dt as $descendantsMatching,at as $dfs,pt as $dfsIterator,Pt as $filter,Kt as $firstToLastIterator,dt as $getAdjacentCaret,yt as $getDepth,St as $getNearestBlockElementAncestorOrThrow,Et as $getNearestNodeOfType,wt as $getNextRightPreorderNode,vt as $getNextSiblingOrParentSibling,Mt as $insertFirst,bt as $insertNodeToNearestRoot,Lt as $insertNodeToNearestRootAtCaret,kt as $isEditorIsNestedEditor,Ot as $lastToFirstIterator,At as $restoreEditorState,gt as $reverseDfs,xt as $reverseDfsIterator,_t as $unwrapAndFilterDescendants,jt as $unwrapNode,Nt as $wrapNodeInElement,X as CAN_USE_BEFORE_INPUT,Y as CAN_USE_DOM,Z as IS_ANDROID,tt as IS_ANDROID_CHROME,et as IS_APPLE,nt as IS_APPLE_WEBKIT,ot as IS_CHROME,rt as IS_FIREFOX,it as IS_IOS,lt as IS_SAFARI,st as addClassNamesToElement,Bt as calculateZoomLevel,ct as isMimeType,It as makeStateWrapper,J as markSelection,ft as mediaFileReader,z as mergeRegister,Rt as objectKlassEquals,G as positionNodeOnRange,Ct as registerNestedElementResolver,ut as removeClassNamesFromElement,Q as selectionAlwaysOnDisplay}; +diff --git a/node_modules/@lexical/utils/index.d.ts b/node_modules/@lexical/utils/index.d.ts +index 5b130fc..9bb7f02 100644 +--- a/node_modules/@lexical/utils/index.d.ts ++++ b/node_modules/@lexical/utils/index.d.ts +@@ -72,8 +72,10 @@ export interface DFSNode { + * before backtracking and finding a new path. Consider solving a maze by hugging either wall, moving down a + * branch until you hit a dead-end (leaf) and backtracking to find the nearest branching path and repeat. + * It will then return all the nodes found in the search in an array of objects. +- * @param startNode - The node to start the search, if omitted, it will start at the root node. +- * @param endNode - The node to end the search, if omitted, it will find all descendants of the startingNode. ++ * Preorder traversal is used, meaning that nodes are listed in the order of when they are FIRST encountered. ++ * @param startNode - The node to start the search (inclusive), if omitted, it will start at the root node. ++ * @param endNode - The node to end the search (inclusive), if omitted, it will find all descendants of the startingNode. If endNode ++ * is an ElementNode, it will stop before visiting any of its children. + * @returns An array of objects of all the nodes found by the search, including their depth into the tree. + * \\{depth: number, node: LexicalNode\\} It will always return at least 1 node (the start node). + */ +@@ -94,8 +96,10 @@ export declare function $getAdjacentCaret(caret: null + export declare function $reverseDfs(startNode?: LexicalNode, endNode?: LexicalNode): Array; + /** + * $dfs iterator (left to right). Tree traversal is done on the fly as new values are requested with O(1) memory. +- * @param startNode - The node to start the search, if omitted, it will start at the root node. +- * @param endNode - The node to end the search, if omitted, it will find all descendants of the startingNode. ++ * Preorder traversal is used, meaning that nodes are iterated over in the order of when they are FIRST encountered. ++ * @param startNode - The node to start the search (inclusive), if omitted, it will start at the root node. ++ * @param endNode - The node to end the search (inclusive), if omitted, it will find all descendants of the startingNode. ++ * If endNode is an ElementNode, the iterator will end as soon as it reaches the endNode (no children will be visited). + * @returns An iterator, each yielded value is a DFSNode. It will always return at least 1 node (the start node). + */ + export declare function $dfsIterator(startNode?: LexicalNode, endNode?: LexicalNode): IterableIterator; +diff --git a/node_modules/@lexical/utils/selectionAlwaysOnDisplay.d.ts b/node_modules/@lexical/utils/selectionAlwaysOnDisplay.d.ts +index 8c9c157..92c2b14 100644 +--- a/node_modules/@lexical/utils/selectionAlwaysOnDisplay.d.ts ++++ b/node_modules/@lexical/utils/selectionAlwaysOnDisplay.d.ts +@@ -5,5 +5,5 @@ + * LICENSE file in the root directory of this source tree. + * + */ +-import { LexicalEditor } from 'lexical'; ++import { type LexicalEditor } from 'lexical'; + export default function selectionAlwaysOnDisplay(editor: LexicalEditor): () => void; diff --git a/patches/lexical+0.38.2.patch b/patches/lexical+0.38.2.patch new file mode 100644 index 00000000..6b99fdb5 --- /dev/null +++ b/patches/lexical+0.38.2.patch @@ -0,0 +1,3461 @@ +diff --git a/node_modules/lexical/Lexical.dev.js b/node_modules/lexical/Lexical.dev.js +index 34827a5..e7d2916 100644 +--- a/node_modules/lexical/Lexical.dev.js ++++ b/node_modules/lexical/Lexical.dev.js +@@ -308,7 +308,7 @@ function getLastSelection(editor) { + }); + } + function $handleTextMutation(target, node, editor) { +- const domSelection = getDOMSelection(getWindow(editor)); ++ const domSelection = getDOMSelectionForEditor(editor); + let anchorOffset = null; + let focusOffset = null; + if (domSelection !== null && domSelection.anchorNode === target) { +@@ -1328,7 +1328,7 @@ function $normalizePoint(point) { + + let subTreeTextContent = ''; + let subTreeTextFormat = null; +-let subTreeTextStyle = ''; ++let subTreeTextStyle = null; + let editorTextContent = ''; + let activeEditorConfig; + let activeEditor$1; +@@ -1504,8 +1504,6 @@ function $createChildren(children, element, _startIndex, endIndex, slot) { + if (node !== null && $isTextNode(node)) { + if (subTreeTextFormat === null) { + subTreeTextFormat = node.getFormat(); +- } +- if (subTreeTextStyle === '') { + subTreeTextStyle = node.getStyle(); + } + } +@@ -1545,13 +1543,13 @@ function reconcileTextFormat(element) { + } + } + function reconcileTextStyle(element) { +- if (subTreeTextStyle !== '' && subTreeTextStyle !== element.__textStyle && !activeEditorStateReadOnly) { ++ if (subTreeTextStyle != null && subTreeTextStyle !== element.__textStyle && !activeEditorStateReadOnly) { + element.setTextStyle(subTreeTextStyle); + } + } + function $reconcileChildrenWithDirection(prevElement, nextElement, dom) { + subTreeTextFormat = null; +- subTreeTextStyle = ''; ++ subTreeTextStyle = null; + $reconcileChildren(prevElement, nextElement, nextElement.getDOMSlot(dom)); + reconcileTextFormat(nextElement); + reconcileTextStyle(nextElement); +@@ -1601,8 +1599,6 @@ function $reconcileChildren(prevElement, nextElement, slot) { + if ($isTextNode(nextChildNode)) { + if (subTreeTextFormat === null) { + subTreeTextFormat = nextChildNode.getFormat(); +- } +- if (subTreeTextStyle === '') { + subTreeTextStyle = nextChildNode.getStyle(); + } + } +@@ -1810,8 +1806,6 @@ function $reconcileNodeChildren(nextElement, prevChildren, nextChildren, prevChi + if (node !== null && $isTextNode(node)) { + if (subTreeTextFormat === null) { + subTreeTextFormat = node.getFormat(); +- } +- if (subTreeTextStyle === '') { + subTreeTextStyle = node.getStyle(); + } + } +@@ -1935,6 +1929,10 @@ function createCommand(type) { + const SELECTION_CHANGE_COMMAND = createCommand('SELECTION_CHANGE_COMMAND'); + const SELECTION_INSERT_CLIPBOARD_NODES_COMMAND = createCommand('SELECTION_INSERT_CLIPBOARD_NODES_COMMAND'); + const CLICK_COMMAND = createCommand('CLICK_COMMAND'); ++const BEFORE_INPUT_COMMAND = createCommand('BEFORE_INPUT_COMMAND'); ++const INPUT_COMMAND = createCommand('INPUT_COMMAND'); ++const COMPOSITION_START_COMMAND = createCommand('COMPOSITION_START_COMMAND'); ++const COMPOSITION_END_COMMAND = createCommand('COMPOSITION_END_COMMAND'); + /** + * Dispatched to delete a character, the payload will be `true` if the deletion + * is backwards (backspace or delete on macOS) and `false` if forwards +@@ -2110,7 +2108,7 @@ function $shouldPreventDefaultAndInsertText(selection, domTargetRange, text, tim + const focus = selection.focus; + const anchorNode = anchor.getNode(); + const editor = getActiveEditor(); +- const domSelection = getDOMSelection(getWindow(editor)); ++ const domSelection = getDOMSelectionForEditor(editor); + const domAnchorNode = domSelection !== null ? domSelection.anchorNode : null; + const anchorKey = anchor.key; + const backingAnchorElement = editor.getElementByKey(anchorKey); +@@ -2296,7 +2294,7 @@ function $updateSelectionFormatStyleFromElementNode(selection, node) { + function onClick(event, editor) { + updateEditorSync(editor, () => { + const selection = $getSelection(); +- const domSelection = getDOMSelection(getWindow(editor)); ++ const domSelection = getDOMSelectionForEditor(editor); + const lastSelection = $getPreviousSelection(); + if (domSelection) { + if ($isRangeSelection(selection)) { +@@ -2366,9 +2364,15 @@ function $canRemoveText(anchorNode, focusNode) { + function isPossiblyAndroidKeyPress(timeStamp) { + return lastKeyCode === 'MediaLast' && timeStamp < lastKeyDownTimeStamp + ANDROID_COMPOSITION_LATENCY; + } ++function registerDefaultCommandHandlers(editor) { ++ editor.registerCommand(BEFORE_INPUT_COMMAND, $handleBeforeInput, COMMAND_PRIORITY_EDITOR); ++ editor.registerCommand(INPUT_COMMAND, $handleInput, COMMAND_PRIORITY_EDITOR); ++ editor.registerCommand(COMPOSITION_START_COMMAND, $handleCompositionStart, COMMAND_PRIORITY_EDITOR); ++ editor.registerCommand(COMPOSITION_END_COMMAND, $handleCompositionEnd, COMMAND_PRIORITY_EDITOR); ++ editor.registerCommand(KEY_DOWN_COMMAND, $handleKeyDown, COMMAND_PRIORITY_EDITOR); ++} + function onBeforeInput(event, editor) { + const inputType = event.inputType; +- const targetRange = getTargetRange(event); + + // We let the browser do its own thing for composition. + if (inputType === 'deleteCompositionText' || +@@ -2382,237 +2386,242 @@ function onBeforeInput(event, editor) { + } else if (inputType === 'insertCompositionText') { + return; + } +- updateEditorSync(editor, () => { +- const selection = $getSelection(); +- if (inputType === 'deleteContentBackward') { +- if (selection === null) { +- // Use previous selection +- const prevSelection = $getPreviousSelection(); +- if (!$isRangeSelection(prevSelection)) { +- return; +- } +- $setSelection(prevSelection.clone()); ++ dispatchCommand(editor, BEFORE_INPUT_COMMAND, event); ++} ++function $handleBeforeInput(event) { ++ const inputType = event.inputType; ++ const targetRange = getTargetRange(event); ++ const editor = getActiveEditor(); ++ const selection = $getSelection(); ++ if (inputType === 'deleteContentBackward') { ++ if (selection === null) { ++ // Use previous selection ++ const prevSelection = $getPreviousSelection(); ++ if (!$isRangeSelection(prevSelection)) { ++ return true; + } +- if ($isRangeSelection(selection)) { +- const isSelectionAnchorSameAsFocus = selection.anchor.key === selection.focus.key; +- if (isPossiblyAndroidKeyPress(event.timeStamp) && editor.isComposing() && isSelectionAnchorSameAsFocus) { +- $setCompositionKey(null); +- lastKeyDownTimeStamp = 0; +- // Fixes an Android bug where selection flickers when backspacing +- setTimeout(() => { +- updateEditorSync(editor, () => { +- $setCompositionKey(null); +- }); +- }, ANDROID_COMPOSITION_LATENCY); +- if ($isRangeSelection(selection)) { +- const anchorNode = selection.anchor.getNode(); +- anchorNode.markDirty(); +- if (!$isTextNode(anchorNode)) { +- formatDevErrorMessage(`Anchor node must be a TextNode`); +- } +- $updateSelectionFormatStyleFromTextNode(selection, anchorNode); +- } +- } else { +- $setCompositionKey(null); +- event.preventDefault(); +- // Chromium Android at the moment seems to ignore the preventDefault +- // on 'deleteContentBackward' and still deletes the content. Which leads +- // to multiple deletions. So we let the browser handle the deletion in this case. +- const selectedNode = selection.anchor.getNode(); +- const selectedNodeText = selectedNode.getTextContent(); +- // When the target node has `canInsertTextAfter` set to false, the first deletion +- // doesn't have an effect, so we need to handle it with Lexical. +- const selectedNodeCanInsertTextAfter = selectedNode.canInsertTextAfter(); +- const hasSelectedAllTextInNode = selection.anchor.offset === 0 && selection.focus.offset === selectedNodeText.length; +- let shouldLetBrowserHandleDelete = IS_ANDROID_CHROME && isSelectionAnchorSameAsFocus && !hasSelectedAllTextInNode && selectedNodeCanInsertTextAfter; +- // Check if selection is collapsed and if the previous node is a decorator node +- // If so, the browser will not be able to handle the deletion +- if (shouldLetBrowserHandleDelete && selection.isCollapsed()) { +- shouldLetBrowserHandleDelete = !$isDecoratorNode($getAdjacentNode(selection.anchor, true)); ++ $setSelection(prevSelection.clone()); ++ } ++ if ($isRangeSelection(selection)) { ++ const isSelectionAnchorSameAsFocus = selection.anchor.key === selection.focus.key; ++ if (isPossiblyAndroidKeyPress(event.timeStamp) && editor.isComposing() && isSelectionAnchorSameAsFocus) { ++ $setCompositionKey(null); ++ lastKeyDownTimeStamp = 0; ++ // Fixes an Android bug where selection flickers when backspacing ++ setTimeout(() => { ++ updateEditorSync(editor, () => { ++ $setCompositionKey(null); ++ }); ++ }, ANDROID_COMPOSITION_LATENCY); ++ if ($isRangeSelection(selection)) { ++ const anchorNode = selection.anchor.getNode(); ++ anchorNode.markDirty(); ++ if (!$isTextNode(anchorNode)) { ++ formatDevErrorMessage(`Anchor node must be a TextNode`); + } +- if (!shouldLetBrowserHandleDelete) { +- dispatchCommand(editor, DELETE_CHARACTER_COMMAND, true); +- // When deleting across paragraphs, Chrome on Android incorrectly shifts the selection rightwards +- // We save the correct selection to restore later during handling of selectionchange event +- const selectionAfterDelete = $getSelection(); +- if (IS_ANDROID_CHROME && $isRangeSelection(selectionAfterDelete) && selectionAfterDelete.isCollapsed()) { +- postDeleteSelectionToRestore = selectionAfterDelete; +- // Cleanup in case selectionchange does not fire +- setTimeout(() => postDeleteSelectionToRestore = null); +- } ++ $updateSelectionFormatStyleFromTextNode(selection, anchorNode); ++ } ++ } else { ++ $setCompositionKey(null); ++ event.preventDefault(); ++ // Chromium Android at the moment seems to ignore the preventDefault ++ // on 'deleteContentBackward' and still deletes the content. Which leads ++ // to multiple deletions. So we let the browser handle the deletion in this case. ++ const selectedNode = selection.anchor.getNode(); ++ const selectedNodeText = selectedNode.getTextContent(); ++ // When the target node has `canInsertTextAfter` set to false, the first deletion ++ // doesn't have an effect, so we need to handle it with Lexical. ++ const selectedNodeCanInsertTextAfter = selectedNode.canInsertTextAfter(); ++ const hasSelectedAllTextInNode = selection.anchor.offset === 0 && selection.focus.offset === selectedNodeText.length; ++ let shouldLetBrowserHandleDelete = IS_ANDROID_CHROME && isSelectionAnchorSameAsFocus && !hasSelectedAllTextInNode && selectedNodeCanInsertTextAfter; ++ // Check if selection is collapsed and if the previous node is a decorator node ++ // If so, the browser will not be able to handle the deletion ++ if (shouldLetBrowserHandleDelete && selection.isCollapsed()) { ++ shouldLetBrowserHandleDelete = !$isDecoratorNode($getAdjacentNode(selection.anchor, true)); ++ } ++ if (!shouldLetBrowserHandleDelete) { ++ dispatchCommand(editor, DELETE_CHARACTER_COMMAND, true); ++ // When deleting across paragraphs, Chrome on Android incorrectly shifts the selection rightwards ++ // We save the correct selection to restore later during handling of selectionchange event ++ const selectionAfterDelete = $getSelection(); ++ if (IS_ANDROID_CHROME && $isRangeSelection(selectionAfterDelete) && selectionAfterDelete.isCollapsed()) { ++ postDeleteSelectionToRestore = selectionAfterDelete; ++ // Cleanup in case selectionchange does not fire ++ setTimeout(() => postDeleteSelectionToRestore = null); + } + } +- return; + } ++ return true; + } +- if (!$isRangeSelection(selection)) { +- return; +- } +- const data = event.data; ++ } ++ if (!$isRangeSelection(selection)) { ++ return true; ++ } ++ const data = event.data; + +- // This represents the case when two beforeinput events are triggered at the same time (without a +- // full event loop ending at input). This happens with MacOS with the default keyboard settings, +- // a combination of autocorrection + autocapitalization. +- // Having Lexical run everything in controlled mode would fix the issue without additional code +- // but this would kill the massive performance win from the most common typing event. +- // Alternatively, when this happens we can prematurely update our EditorState based on the DOM +- // content, a job that would usually be the input event's responsibility. +- if (unprocessedBeforeInputData !== null) { +- $updateSelectedTextFromDOM(false, editor, unprocessedBeforeInputData); +- } +- if ((!selection.dirty || unprocessedBeforeInputData !== null) && selection.isCollapsed() && !$isRootNode(selection.anchor.getNode()) && targetRange !== null) { +- selection.applyDOMRange(targetRange); ++ // This represents the case when two beforeinput events are triggered at the same time (without a ++ // full event loop ending at input). This happens with MacOS with the default keyboard settings, ++ // a combination of autocorrection + autocapitalization. ++ // Having Lexical run everything in controlled mode would fix the issue without additional code ++ // but this would kill the massive performance win from the most common typing event. ++ // Alternatively, when this happens we can prematurely update our EditorState based on the DOM ++ // content, a job that would usually be the input event's responsibility. ++ if (unprocessedBeforeInputData !== null) { ++ $updateSelectedTextFromDOM(false, editor, unprocessedBeforeInputData); ++ } ++ if ((!selection.dirty || unprocessedBeforeInputData !== null) && selection.isCollapsed() && !$isRootNode(selection.anchor.getNode()) && targetRange !== null) { ++ selection.applyDOMRange(targetRange); ++ } ++ unprocessedBeforeInputData = null; ++ const anchor = selection.anchor; ++ const focus = selection.focus; ++ const anchorNode = anchor.getNode(); ++ const focusNode = focus.getNode(); ++ if (inputType === 'insertText' || inputType === 'insertTranspose') { ++ if (data === '\n') { ++ event.preventDefault(); ++ dispatchCommand(editor, INSERT_LINE_BREAK_COMMAND, false); ++ } else if (data === DOUBLE_LINE_BREAK) { ++ event.preventDefault(); ++ dispatchCommand(editor, INSERT_PARAGRAPH_COMMAND, undefined); ++ } else if (data == null && event.dataTransfer) { ++ // Gets around a Safari text replacement bug. ++ const text = event.dataTransfer.getData('text/plain'); ++ event.preventDefault(); ++ selection.insertRawText(text); ++ } else if (data != null && $shouldPreventDefaultAndInsertText(selection, targetRange, data, event.timeStamp, true)) { ++ event.preventDefault(); ++ dispatchCommand(editor, CONTROLLED_TEXT_INSERTION_COMMAND, data); ++ } else { ++ unprocessedBeforeInputData = data; + } +- unprocessedBeforeInputData = null; +- const anchor = selection.anchor; +- const focus = selection.focus; +- const anchorNode = anchor.getNode(); +- const focusNode = focus.getNode(); +- if (inputType === 'insertText' || inputType === 'insertTranspose') { +- if (data === '\n') { +- event.preventDefault(); ++ lastBeforeInputInsertTextTimeStamp = event.timeStamp; ++ return true; ++ } ++ ++ // Prevent the browser from carrying out ++ // the input event, so we can control the ++ // output. ++ event.preventDefault(); ++ switch (inputType) { ++ case 'insertFromYank': ++ case 'insertFromDrop': ++ case 'insertReplacementText': ++ { ++ dispatchCommand(editor, CONTROLLED_TEXT_INSERTION_COMMAND, event); ++ break; ++ } ++ case 'insertFromComposition': ++ { ++ // This is the end of composition ++ $setCompositionKey(null); ++ dispatchCommand(editor, CONTROLLED_TEXT_INSERTION_COMMAND, event); ++ break; ++ } ++ case 'insertLineBreak': ++ { ++ // Used for Android ++ $setCompositionKey(null); + dispatchCommand(editor, INSERT_LINE_BREAK_COMMAND, false); +- } else if (data === DOUBLE_LINE_BREAK) { +- event.preventDefault(); +- dispatchCommand(editor, INSERT_PARAGRAPH_COMMAND, undefined); +- } else if (data == null && event.dataTransfer) { +- // Gets around a Safari text replacement bug. +- const text = event.dataTransfer.getData('text/plain'); +- event.preventDefault(); +- selection.insertRawText(text); +- } else if (data != null && $shouldPreventDefaultAndInsertText(selection, targetRange, data, event.timeStamp, true)) { +- event.preventDefault(); +- dispatchCommand(editor, CONTROLLED_TEXT_INSERTION_COMMAND, data); +- } else { +- unprocessedBeforeInputData = data; ++ break; + } +- lastBeforeInputInsertTextTimeStamp = event.timeStamp; +- return; +- } ++ case 'insertParagraph': ++ { ++ // Used for Android ++ $setCompositionKey(null); + +- // Prevent the browser from carrying out +- // the input event, so we can control the +- // output. +- event.preventDefault(); +- switch (inputType) { +- case 'insertFromYank': +- case 'insertFromDrop': +- case 'insertReplacementText': +- { +- dispatchCommand(editor, CONTROLLED_TEXT_INSERTION_COMMAND, event); +- break; +- } +- case 'insertFromComposition': +- { +- // This is the end of composition +- $setCompositionKey(null); +- dispatchCommand(editor, CONTROLLED_TEXT_INSERTION_COMMAND, event); +- break; +- } +- case 'insertLineBreak': +- { +- // Used for Android +- $setCompositionKey(null); ++ // Safari does not provide the type "insertLineBreak". ++ // So instead, we need to infer it from the keyboard event. ++ // We do not apply this logic to iOS to allow newline auto-capitalization ++ // work without creating linebreaks when pressing Enter ++ if (isInsertLineBreak && !IS_IOS) { ++ isInsertLineBreak = false; + dispatchCommand(editor, INSERT_LINE_BREAK_COMMAND, false); +- break; +- } +- case 'insertParagraph': +- { +- // Used for Android +- $setCompositionKey(null); +- +- // Safari does not provide the type "insertLineBreak". +- // So instead, we need to infer it from the keyboard event. +- // We do not apply this logic to iOS to allow newline auto-capitalization +- // work without creating linebreaks when pressing Enter +- if (isInsertLineBreak && !IS_IOS) { +- isInsertLineBreak = false; +- dispatchCommand(editor, INSERT_LINE_BREAK_COMMAND, false); +- } else { +- dispatchCommand(editor, INSERT_PARAGRAPH_COMMAND, undefined); +- } +- break; +- } +- case 'insertFromPaste': +- case 'insertFromPasteAsQuotation': +- { +- dispatchCommand(editor, PASTE_COMMAND, event); +- break; +- } +- case 'deleteByComposition': +- { +- if ($canRemoveText(anchorNode, focusNode)) { +- dispatchCommand(editor, REMOVE_TEXT_COMMAND, event); +- } +- break; ++ } else { ++ dispatchCommand(editor, INSERT_PARAGRAPH_COMMAND, undefined); + } +- case 'deleteByDrag': +- case 'deleteByCut': +- { ++ break; ++ } ++ case 'insertFromPaste': ++ case 'insertFromPasteAsQuotation': ++ { ++ dispatchCommand(editor, PASTE_COMMAND, event); ++ break; ++ } ++ case 'deleteByComposition': ++ { ++ if ($canRemoveText(anchorNode, focusNode)) { + dispatchCommand(editor, REMOVE_TEXT_COMMAND, event); +- break; +- } +- case 'deleteContent': +- { +- dispatchCommand(editor, DELETE_CHARACTER_COMMAND, false); +- break; +- } +- case 'deleteWordBackward': +- { +- dispatchCommand(editor, DELETE_WORD_COMMAND, true); +- break; +- } +- case 'deleteWordForward': +- { +- dispatchCommand(editor, DELETE_WORD_COMMAND, false); +- break; +- } +- case 'deleteHardLineBackward': +- case 'deleteSoftLineBackward': +- { +- dispatchCommand(editor, DELETE_LINE_COMMAND, true); +- break; +- } +- case 'deleteContentForward': +- case 'deleteHardLineForward': +- case 'deleteSoftLineForward': +- { +- dispatchCommand(editor, DELETE_LINE_COMMAND, false); +- break; +- } +- case 'formatStrikeThrough': +- { +- dispatchCommand(editor, FORMAT_TEXT_COMMAND, 'strikethrough'); +- break; +- } +- case 'formatBold': +- { +- dispatchCommand(editor, FORMAT_TEXT_COMMAND, 'bold'); +- break; +- } +- case 'formatItalic': +- { +- dispatchCommand(editor, FORMAT_TEXT_COMMAND, 'italic'); +- break; +- } +- case 'formatUnderline': +- { +- dispatchCommand(editor, FORMAT_TEXT_COMMAND, 'underline'); +- break; +- } +- case 'historyUndo': +- { +- dispatchCommand(editor, UNDO_COMMAND, undefined); +- break; + } +- case 'historyRedo': +- { +- dispatchCommand(editor, REDO_COMMAND, undefined); +- break; +- } +- // NO-OP +- } +- }); ++ break; ++ } ++ case 'deleteByDrag': ++ case 'deleteByCut': ++ { ++ dispatchCommand(editor, REMOVE_TEXT_COMMAND, event); ++ break; ++ } ++ case 'deleteContent': ++ { ++ dispatchCommand(editor, DELETE_CHARACTER_COMMAND, false); ++ break; ++ } ++ case 'deleteWordBackward': ++ { ++ dispatchCommand(editor, DELETE_WORD_COMMAND, true); ++ break; ++ } ++ case 'deleteWordForward': ++ { ++ dispatchCommand(editor, DELETE_WORD_COMMAND, false); ++ break; ++ } ++ case 'deleteHardLineBackward': ++ case 'deleteSoftLineBackward': ++ { ++ dispatchCommand(editor, DELETE_LINE_COMMAND, true); ++ break; ++ } ++ case 'deleteContentForward': ++ case 'deleteHardLineForward': ++ case 'deleteSoftLineForward': ++ { ++ dispatchCommand(editor, DELETE_LINE_COMMAND, false); ++ break; ++ } ++ case 'formatStrikeThrough': ++ { ++ dispatchCommand(editor, FORMAT_TEXT_COMMAND, 'strikethrough'); ++ break; ++ } ++ case 'formatBold': ++ { ++ dispatchCommand(editor, FORMAT_TEXT_COMMAND, 'bold'); ++ break; ++ } ++ case 'formatItalic': ++ { ++ dispatchCommand(editor, FORMAT_TEXT_COMMAND, 'italic'); ++ break; ++ } ++ case 'formatUnderline': ++ { ++ dispatchCommand(editor, FORMAT_TEXT_COMMAND, 'underline'); ++ break; ++ } ++ case 'historyUndo': ++ { ++ dispatchCommand(editor, UNDO_COMMAND, undefined); ++ break; ++ } ++ case 'historyRedo': ++ { ++ dispatchCommand(editor, REDO_COMMAND, undefined); ++ break; ++ } ++ // NO-OP ++ } ++ return true; + } + function onInput(event, editor) { + // Note that the MutationObserver may or may not have already fired, +@@ -2624,90 +2633,103 @@ function onInput(event, editor) { + // We don't want the onInput to bubble, in the case of nested editors. + event.stopPropagation(); + updateEditorSync(editor, () => { +- if (isHTMLElement(event.target) && $isSelectionCapturedInDecorator(event.target)) { +- return; ++ editor.dispatchCommand(INPUT_COMMAND, event); ++ }, { ++ event ++ }); ++ unprocessedBeforeInputData = null; ++} ++function $handleInput(event) { ++ if (isHTMLElement(event.target) && $isSelectionCapturedInDecorator(event.target)) { ++ return true; ++ } ++ const editor = getActiveEditor(); ++ const selection = $getSelection(); ++ const data = event.data; ++ const targetRange = getTargetRange(event); ++ if (data != null && $isRangeSelection(selection) && $shouldPreventDefaultAndInsertText(selection, targetRange, data, event.timeStamp, false)) { ++ // Given we're over-riding the default behavior, we will need ++ // to ensure to disable composition before dispatching the ++ // insertText command for when changing the sequence for FF. ++ if (isFirefoxEndingComposition) { ++ $onCompositionEndImpl(editor, data); ++ isFirefoxEndingComposition = false; + } +- const selection = $getSelection(); +- const data = event.data; +- const targetRange = getTargetRange(event); +- if (data != null && $isRangeSelection(selection) && $shouldPreventDefaultAndInsertText(selection, targetRange, data, event.timeStamp, false)) { +- // Given we're over-riding the default behavior, we will need +- // to ensure to disable composition before dispatching the +- // insertText command for when changing the sequence for FF. +- if (isFirefoxEndingComposition) { +- $onCompositionEndImpl(editor, data); +- isFirefoxEndingComposition = false; +- } +- const anchor = selection.anchor; +- const anchorNode = anchor.getNode(); +- const domSelection = getDOMSelection(getWindow(editor)); +- if (domSelection === null) { +- return; +- } +- const isBackward = selection.isBackward(); +- const startOffset = isBackward ? selection.anchor.offset : selection.focus.offset; +- const endOffset = isBackward ? selection.focus.offset : selection.anchor.offset; +- // If the content is the same as inserted, then don't dispatch an insertion. +- // Given onInput doesn't take the current selection (it uses the previous) +- // we can compare that against what the DOM currently says. +- if (!CAN_USE_BEFORE_INPUT || selection.isCollapsed() || !$isTextNode(anchorNode) || domSelection.anchorNode === null || anchorNode.getTextContent().slice(0, startOffset) + data + anchorNode.getTextContent().slice(startOffset + endOffset) !== getAnchorTextFromDOM(domSelection.anchorNode)) { +- dispatchCommand(editor, CONTROLLED_TEXT_INSERTION_COMMAND, data); +- } +- const textLength = data.length; ++ const anchor = selection.anchor; ++ const anchorNode = anchor.getNode(); ++ const domSelection = getDOMSelection(getWindow(editor)); ++ if (domSelection === null) { ++ return true; ++ } ++ const isBackward = selection.isBackward(); ++ const startOffset = isBackward ? selection.anchor.offset : selection.focus.offset; ++ const endOffset = isBackward ? selection.focus.offset : selection.anchor.offset; ++ // If the content is the same as inserted, then don't dispatch an insertion. ++ // Given onInput doesn't take the current selection (it uses the previous) ++ // we can compare that against what the DOM currently says. ++ if (!CAN_USE_BEFORE_INPUT || selection.isCollapsed() || !$isTextNode(anchorNode) || domSelection.anchorNode === null || anchorNode.getTextContent().slice(0, startOffset) + data + anchorNode.getTextContent().slice(startOffset + endOffset) !== getAnchorTextFromDOM(domSelection.anchorNode)) { ++ dispatchCommand(editor, CONTROLLED_TEXT_INSERTION_COMMAND, data); ++ } ++ const textLength = data.length; + +- // Another hack for FF, as it's possible that the IME is still +- // open, even though compositionend has already fired (sigh). +- if (IS_FIREFOX && textLength > 1 && event.inputType === 'insertCompositionText' && !editor.isComposing()) { +- selection.anchor.offset -= textLength; +- } ++ // Another hack for FF, as it's possible that the IME is still ++ // open, even though compositionend has already fired (sigh). ++ if (IS_FIREFOX && textLength > 1 && event.inputType === 'insertCompositionText' && !editor.isComposing()) { ++ selection.anchor.offset -= textLength; ++ } + +- // This ensures consistency on Android. +- if (!IS_SAFARI && !IS_IOS && !IS_APPLE_WEBKIT && editor.isComposing()) { +- lastKeyDownTimeStamp = 0; +- $setCompositionKey(null); +- } +- } else { +- const characterData = data !== null ? data : undefined; +- $updateSelectedTextFromDOM(false, editor, characterData); ++ // This ensures consistency on Android. ++ if (!IS_SAFARI && !IS_IOS && !IS_APPLE_WEBKIT && editor.isComposing()) { ++ lastKeyDownTimeStamp = 0; ++ $setCompositionKey(null); ++ } ++ } else { ++ const characterData = data !== null ? data : undefined; ++ $updateSelectedTextFromDOM(false, editor, characterData); + +- // onInput always fires after onCompositionEnd for FF. +- if (isFirefoxEndingComposition) { +- $onCompositionEndImpl(editor, data || undefined); +- isFirefoxEndingComposition = false; +- } ++ // onInput always fires after onCompositionEnd for FF. ++ if (isFirefoxEndingComposition) { ++ $onCompositionEndImpl(editor, data || undefined); ++ isFirefoxEndingComposition = false; + } ++ } + +- // Also flush any other mutations that might have occurred +- // since the change. +- $flushMutations(); +- }, { +- event +- }); +- unprocessedBeforeInputData = null; ++ // Also flush any other mutations that might have occurred ++ // since the change. ++ $flushMutations(); ++ return true; + } + function onCompositionStart(event, editor) { +- updateEditorSync(editor, () => { +- const selection = $getSelection(); +- if ($isRangeSelection(selection) && !editor.isComposing()) { +- const anchor = selection.anchor; +- const node = selection.anchor.getNode(); +- $setCompositionKey(anchor.key); +- if ( +- // If it has been 30ms since the last keydown, then we should +- // apply the empty space heuristic. We can't do this for Safari, +- // as the keydown fires after composition start. +- event.timeStamp < lastKeyDownTimeStamp + ANDROID_COMPOSITION_LATENCY || +- // FF has issues around composing multibyte characters, so we also +- // need to invoke the empty space heuristic below. +- anchor.type === 'element' || !selection.isCollapsed() || node.getFormat() !== selection.format || $isTextNode(node) && node.getStyle() !== selection.style) { +- // We insert a zero width character, ready for the composition +- // to get inserted into the new node we create. If +- // we don't do this, Safari will fail on us because +- // there is no text node matching the selection. +- dispatchCommand(editor, CONTROLLED_TEXT_INSERTION_COMMAND, COMPOSITION_START_CHAR); +- } ++ dispatchCommand(editor, COMPOSITION_START_COMMAND, event); ++} ++function $handleCompositionStart(event) { ++ const editor = getActiveEditor(); ++ const selection = $getSelection(); ++ if ($isRangeSelection(selection) && !editor.isComposing()) { ++ const anchor = selection.anchor; ++ const node = selection.anchor.getNode(); ++ $setCompositionKey(anchor.key); ++ if ( ++ // If it has been 30ms since the last keydown, then we should ++ // apply the empty space heuristic. We can't do this for Safari, ++ // as the keydown fires after composition start. ++ event.timeStamp < lastKeyDownTimeStamp + ANDROID_COMPOSITION_LATENCY || ++ // FF has issues around composing multibyte characters, so we also ++ // need to invoke the empty space heuristic below. ++ anchor.type === 'element' || !selection.isCollapsed() || node.getFormat() !== selection.format || $isTextNode(node) && node.getStyle() !== selection.style) { ++ // We insert a zero width character, ready for the composition ++ // to get inserted into the new node we create. If ++ // we don't do this, Safari will fail on us because ++ // there is no text node matching the selection. ++ dispatchCommand(editor, CONTROLLED_TEXT_INSERTION_COMMAND, COMPOSITION_START_CHAR); + } +- }); ++ } ++ return true; ++} ++function $handleCompositionEnd(event) { ++ const editor = getActiveEditor(); ++ $onCompositionEndImpl(editor, event.data); ++ return true; + } + function $onCompositionEndImpl(editor, data) { + const compositionKey = editor._compositionKey; +@@ -2759,9 +2781,7 @@ function onCompositionEnd(event, editor) { + isSafariEndingComposition = true; + safariEndCompositionEventData = event.data; + } else { +- updateEditorSync(editor, () => { +- $onCompositionEndImpl(editor, event.data); +- }); ++ dispatchCommand(editor, COMPOSITION_END_COMMAND, event); + } + } + function onKeyDown(event, editor) { +@@ -2770,11 +2790,12 @@ function onKeyDown(event, editor) { + if (editor.isComposing()) { + return; + } +- if (dispatchCommand(editor, KEY_DOWN_COMMAND, event)) { +- return; +- } ++ dispatchCommand(editor, KEY_DOWN_COMMAND, event); ++} ++function $handleKeyDown(event) { ++ const editor = getActiveEditor(); + if (event.key == null) { +- return; ++ return true; + } + if (isSafariEndingComposition && isBackspace(event)) { + updateEditorSync(editor, () => { +@@ -2782,7 +2803,7 @@ function onKeyDown(event, editor) { + }); + isSafariEndingComposition = false; + safariEndCompositionEventData = ''; +- return; ++ return true; + } + if (isMoveForward(event)) { + dispatchCommand(editor, KEY_ARROW_RIGHT_COMMAND, event); +@@ -2873,8 +2894,9 @@ function onKeyDown(event, editor) { + } + } + if (isModifier(event)) { +- dispatchCommand(editor, KEY_MODIFIER_COMMAND, event); ++ editor.dispatchCommand(KEY_MODIFIER_COMMAND, event); + } ++ return true; + } + function getRootElementRemoveHandles(rootElement) { + // @ts-expect-error: internal field +@@ -2949,7 +2971,7 @@ function hasStoppedLexicalPropagation(event) { + function addRootElementEvents(rootElement, editor) { + // We only want to have a single global selectionchange event handler, shared + // between all editor instances. +- const doc = rootElement.ownerDocument; ++ const doc = getShadowRootOrDocument(rootElement); + rootElementToDocument.set(rootElement, doc); + const documentRootElementsCount = rootElementsRegistered.get(doc) ?? 0; + if (documentRootElementsCount < 1) { +@@ -3007,7 +3029,7 @@ function addRootElementEvents(rootElement, editor) { + } + const rootElementNotRegisteredWarning = warnOnlyOnce('Root element not registered'); + function removeRootElementEvents(rootElement) { +- const doc = rootElementToDocument.get(rootElement); ++ const doc = getShadowRootOrDocument(rootElement); + if (doc === undefined) { + rootElementNotRegisteredWarning(); + return; +@@ -6760,7 +6782,7 @@ class RangeSelection { + } + const collapse = alter === 'move'; + const editor = getActiveEditor(); +- const domSelection = getDOMSelection(getWindow(editor)); ++ const domSelection = getDOMSelectionForEditor(editor); + if (!domSelection) { + return; + } +@@ -6848,11 +6870,12 @@ class RangeSelection { + } + /** + * Helper for handling forward character and word deletion that prevents element nodes +- * like a table, columns layout being destroyed ++ * like a table, columns layout being destroyed. Also prevents deletion into shadow roots. + * + * @param anchor the anchor + * @param anchorNode the anchor node in the selection + * @param isBackward whether or not selection is backwards ++ * @returns true if deletion should be prevented + */ + forwardDeletion(anchor, anchorNode, isBackward) { + if (!isBackward && ( +@@ -6956,7 +6979,26 @@ class RangeSelection { + + // Handle the deletion around decorators. + const focus = this.focus; ++ const initialAnchorKey = anchor.key; ++ const initialAnchorOffset = anchor.offset; ++ const initialFocusKey = focus.key; ++ const initialFocusOffset = focus.offset; + this.modify('extend', isBackward, 'character'); ++ ++ // Check if modify actually changed the selection (it might not in shadow DOM) ++ const selectionChanged = this.anchor.key !== initialAnchorKey || this.anchor.offset !== initialAnchorOffset || this.focus.key !== initialFocusKey || this.focus.offset !== initialFocusOffset; ++ if (!selectionChanged && anchor.type === 'text' && $isTextNode(anchorNode)) { ++ // Fallback for environments where modify doesn't work (e.g., shadow DOM) ++ const textContent = anchorNode.getTextContent(); ++ const offset = anchor.offset; ++ if (isBackward && offset > 0) { ++ // Select the character before cursor ++ this.anchor.set(anchor.key, offset - 1, 'text'); ++ } else if (!isBackward && offset < textContent.length) { ++ // Select the character after cursor ++ this.focus.set(focus.key, offset + 1, 'text'); ++ } ++ } + if (!this.isCollapsed()) { + const focusNode = focus.type === 'text' ? focus.getNode() : null; + anchorNode = anchor.type === 'text' ? anchor.getNode() : null; +@@ -7000,7 +7042,31 @@ class RangeSelection { + */ + deleteLine(isBackward) { + if (this.isCollapsed()) { ++ const anchor = this.anchor; ++ const focus = this.focus; ++ const initialAnchorKey = anchor.key; ++ const initialAnchorOffset = anchor.offset; ++ const initialFocusKey = focus.key; ++ const initialFocusOffset = focus.offset; + this.modify('extend', isBackward, 'lineboundary'); ++ ++ // Check if modify actually changed the selection (it might not in shadow DOM) ++ const selectionChanged = this.anchor.key !== initialAnchorKey || this.anchor.offset !== initialAnchorOffset || this.focus.key !== initialFocusKey || this.focus.offset !== initialFocusOffset; ++ if (!selectionChanged && anchor.type === 'text') { ++ // Fallback for environments where modify doesn't work (e.g., shadow DOM) ++ const anchorNode = anchor.getNode(); ++ if ($isTextNode(anchorNode)) { ++ const textContent = anchorNode.getTextContent(); ++ const offset = anchor.offset; ++ if (isBackward && offset > 0) { ++ // Delete from beginning of line to cursor ++ this.anchor.set(anchor.key, 0, 'text'); ++ } else if (!isBackward && offset < textContent.length) { ++ // Delete from cursor to end of line ++ this.focus.set(focus.key, textContent.length, 'text'); ++ } ++ } ++ } + } + if (this.isCollapsed()) { + // If the selection was already collapsed at the lineboundary, +@@ -7012,6 +7078,57 @@ class RangeSelection { + } + } + ++ /** ++ * Helper function to determine if a character is a word boundary (whitespace). ++ * @param char the character to check ++ * @returns true if the character is a word boundary ++ */ ++ isWordBoundary(char) { ++ return char === ' ' || char === '\t' || char === '\n' || char === '\r'; ++ } ++ ++ /** ++ * Find the start of a word going backward from the given offset in text. ++ * @param text the text to search in ++ * @param offset the starting offset ++ * @returns the offset of the word start ++ */ ++ findWordStart(text, offset) { ++ let position = offset - 1; ++ ++ // Skip spaces ++ while (position >= 0 && this.isWordBoundary(text[position])) { ++ position--; ++ } ++ ++ // Find word start ++ while (position > 0 && !this.isWordBoundary(text[position - 1])) { ++ position--; ++ } ++ return position >= 0 ? position : 0; ++ } ++ ++ /** ++ * Find the end of a word going forward from the given offset in text. ++ * @param text the text to search in ++ * @param offset the starting offset ++ * @returns the offset of the word end ++ */ ++ findWordEnd(text, offset) { ++ let position = offset; ++ ++ // Skip spaces ++ while (position < text.length && this.isWordBoundary(text[position])) { ++ position++; ++ } ++ ++ // Find word end ++ while (position < text.length && !this.isWordBoundary(text[position])) { ++ position++; ++ } ++ return position; ++ } ++ + /** + * Performs one logical word deletion operation on the EditorState based on the current Selection. + * Handles different node types. +@@ -7025,7 +7142,69 @@ class RangeSelection { + if (this.forwardDeletion(anchor, anchorNode, isBackward)) { + return; + } ++ const initialAnchorKey = anchor.key; ++ const initialAnchorOffset = anchor.offset; ++ const focus = this.focus; ++ const initialFocusKey = focus.key; ++ const initialFocusOffset = focus.offset; + this.modify('extend', isBackward, 'word'); ++ ++ // Check if modify actually changed the selection (it might not in shadow DOM) ++ const selectionChanged = this.anchor.key !== initialAnchorKey || this.anchor.offset !== initialAnchorOffset || this.focus.key !== initialFocusKey || this.focus.offset !== initialFocusOffset; ++ if (!selectionChanged && anchor.type === 'text' && $isTextNode(anchorNode)) { ++ // Fallback for environments where modify doesn't work (e.g., shadow DOM) ++ const textContent = anchorNode.getTextContent(); ++ const offset = anchor.offset; ++ if (isBackward) { ++ // Backward: find start of word before cursor ++ if (offset === 0) { ++ // At node start, check previous sibling ++ const prevSibling = anchorNode.getPreviousSibling(); ++ if ($isTextNode(prevSibling)) { ++ const prevText = prevSibling.getTextContent(); ++ const position = this.findWordStart(prevText, prevText.length); ++ this.anchor.set(prevSibling.__key, position, 'text'); ++ } ++ } else { ++ const position = this.findWordStart(textContent, offset); ++ if (position === 0 && this.isWordBoundary(textContent[0])) { ++ // Only spaces in this node, try previous sibling ++ const prevSibling = anchorNode.getPreviousSibling(); ++ if ($isTextNode(prevSibling)) { ++ const prevText = prevSibling.getTextContent(); ++ const prevPosition = this.findWordStart(prevText, prevText.length); ++ this.anchor.set(prevSibling.__key, prevPosition, 'text'); ++ return; ++ } ++ } ++ this.anchor.set(anchor.key, position, 'text'); ++ } ++ } else { ++ // Forward: find end of word after cursor ++ if (offset === textContent.length) { ++ // At node end, check next sibling ++ const nextSibling = anchorNode.getNextSibling(); ++ if ($isTextNode(nextSibling)) { ++ const nextText = nextSibling.getTextContent(); ++ const position = this.findWordEnd(nextText, 0); ++ this.focus.set(nextSibling.__key, position, 'text'); ++ } ++ } else { ++ const position = this.findWordEnd(textContent, offset); ++ if (position === textContent.length && this.isWordBoundary(textContent[textContent.length - 1])) { ++ // Only spaces in this node, try next sibling ++ const nextSibling = anchorNode.getNextSibling(); ++ if ($isTextNode(nextSibling)) { ++ const nextText = nextSibling.getTextContent(); ++ const nextPosition = this.findWordEnd(nextText, 0); ++ this.focus.set(nextSibling.__key, nextPosition, 'text'); ++ return; ++ } ++ } ++ this.focus.set(focus.key, position, 'text'); ++ } ++ } ++ } + } + this.removeText(); + } +@@ -7474,7 +7653,7 @@ function $createNodeSelection() { + function $internalCreateSelection(editor, event) { + const currentEditorState = editor.getEditorState(); + const lastSelection = currentEditorState._selection; +- const domSelection = getDOMSelection(getWindow(editor)); ++ const domSelection = getDOMSelectionForEditor(editor); + if ($isRangeSelection(lastSelection) || lastSelection == null) { + return $internalCreateRangeSelection(lastSelection, domSelection, editor, event); + } +@@ -7732,7 +7911,7 @@ function updateDOMSelection(prevSelection, nextSelection, editor, domSelection, + const focusDOMNode = domSelection.focusNode; + const anchorOffset = domSelection.anchorOffset; + const focusOffset = domSelection.focusOffset; +- const activeElement = document.activeElement; ++ const activeElement = getActiveElement(rootElement); + + // TODO: make this not hard-coded, and add another config option + // that makes this configurable. +@@ -8459,7 +8638,7 @@ function $commitPendingUpdates(editor, recoveryEditorState) { + // Reconciliation has finished. Now update selection and trigger listeners. + // ====== + +- const domSelection = shouldSkipDOM ? null : getDOMSelection(getWindow(editor)); ++ const domSelection = shouldSkipDOM ? null : getDOMSelectionForEditor(editor); + + // Attempt to update the DOM selection, including focusing of the root element, + // and scroll into view if needed. +@@ -9491,11 +9670,15 @@ class ElementNode extends LexicalNode { + }; + const textFormat = this.getTextFormat(); + const textStyle = this.getTextStyle(); +- if (textFormat !== 0) { +- json.textFormat = textFormat; +- } +- if (textStyle !== '') { +- json.textStyle = textStyle; ++ // Only persist for cases when there are no TextNode children from which ++ // these would be set on reconcile (#7968) ++ if ((textFormat !== 0 || textStyle !== '') && !$isRootOrShadowRoot(this) && !this.getChildren().some($isTextNode)) { ++ if (textFormat !== 0) { ++ json.textFormat = textFormat; ++ } ++ if (textStyle !== '') { ++ json.textStyle = textStyle; ++ } + } + return json; + } +@@ -9892,12 +10075,20 @@ class ParagraphNode extends ElementNode { + return $createParagraphNode().updateFromJSON(serializedNode); + } + exportJSON() { +- return { +- ...super.exportJSON(), +- // These are included explicitly for backwards compatibility +- textFormat: this.getTextFormat(), +- textStyle: this.getTextStyle() +- }; ++ const json = super.exportJSON(); ++ // Provide backwards compatible values, see #7971 ++ if (json.textFormat === undefined || json.textStyle === undefined) { ++ // Compute the same value that the reconciler would ++ const firstTextNode = this.getChildren().find($isTextNode); ++ if (firstTextNode) { ++ json.textFormat = firstTextNode.getFormat(); ++ json.textStyle = firstTextNode.getStyle(); ++ } else { ++ json.textFormat = this.getTextFormat(); ++ json.textStyle = this.getTextStyle(); ++ } ++ } ++ return json; + } + + // Mutation +@@ -10180,6 +10371,7 @@ function createEditor(editorConfig) { + editor._pendingEditorState = initialEditorState; + editor._dirtyType = FULL_RECONCILE; + } ++ registerDefaultCommandHandlers(editor); + return editor; + } + class LexicalEditor { +@@ -10821,7 +11013,7 @@ class LexicalEditor { + if (rootElement !== null) { + rootElement.blur(); + } +- const domSelection = getDOMSelection(this._window); ++ const domSelection = getDOMSelectionForEditor(this); + if (domSelection !== null) { + domSelection.removeAllRanges(); + } +@@ -10907,7 +11099,9 @@ function $isSelectionCapturedInDecorator(node) { + return $isDecoratorNode($getNearestNodeFromDOMNode(node)); + } + function isSelectionCapturedInDecoratorInput(anchorDOM) { +- const activeElement = document.activeElement; ++ const editor = getNearestEditorFromDOMNode(anchorDOM); ++ const rootElement = editor ? editor.getRootElement() : null; ++ const activeElement = rootElement ? getActiveElement(rootElement) : document.activeElement; + if (!isHTMLElement(activeElement)) { + return false; + } +@@ -11354,7 +11548,7 @@ function getAnchorTextFromDOM(anchorNode) { + } + function $updateSelectedTextFromDOM(isCompositionEnd, editor, data) { + // Update the text content with the latest composition text +- const domSelection = getDOMSelection(getWindow(editor)); ++ const domSelection = getDOMSelectionForEditor(editor); + if (domSelection === null) { + return; + } +@@ -11799,9 +11993,23 @@ function getElementByKeyOrThrow(editor, key) { + } + return element; + } ++ ++/** ++ * Type guard function that checks if a node is a ShadowRoot. This function performs ++ * runtime validation to safely narrow types and enable type-safe Shadow DOM operations. ++ * It checks both the nodeType and the presence of the 'host' property to distinguish ++ * ShadowRoot from regular DocumentFragment nodes. ++ * ++ * @param node - The Node to check (can be null) ++ * @returns True if the node is a ShadowRoot, false otherwise. When true, TypeScript ++ * will narrow the type to ShadowRoot for subsequent operations. ++ */ ++function isShadowRoot(node) { ++ return isDocumentFragment(node) && 'host' in node; ++} + function getParentElement(node) { + const parentElement = node.assignedSlot || node.parentElement; +- return isDocumentFragment(parentElement) ? parentElement.host : parentElement; ++ return isShadowRoot(parentElement) ? parentElement.host : parentElement; + } + function getDOMOwnerDocument(target) { + return isDOMDocumentNode(target) ? target : isHTMLElement(target) ? target.ownerDocument : null; +@@ -11909,7 +12117,7 @@ function getDefaultView(domElem) { + return ownerDoc ? ownerDoc.defaultView : null; + } + function getWindow(editor) { +- const windowObj = editor._window; ++ const windowObj = editor._window || window; + if (windowObj === null) { + { + formatDevErrorMessage(`window object not found`); +@@ -12028,7 +12236,7 @@ function removeDOMBlockCursorElement(blockCursorElement, editor, rootElement) { + } + function updateDOMBlockCursorElement(editor, rootElement, nextSelection) { + let blockCursorElement = editor._blockCursorElement; +- if ($isRangeSelection(nextSelection) && nextSelection.isCollapsed() && nextSelection.anchor.type === 'element' && rootElement.contains(document.activeElement)) { ++ if ($isRangeSelection(nextSelection) && nextSelection.isCollapsed() && nextSelection.anchor.type === 'element' && rootElement.contains(getActiveElement(rootElement))) { + const anchor = nextSelection.anchor; + const elementNode = anchor.getNode(); + const offset = anchor.offset; +@@ -12071,23 +12279,290 @@ function updateDOMBlockCursorElement(editor, rootElement, nextSelection) { + } + + /** +- * Returns the selection for the given window, or the global window if null. +- * Will return null if {@link CAN_USE_DOM} is false. ++ * Returns a Selection object from a ShadowRoot using the best available API. ++ * ++ * This function attempts to get selection from Shadow DOM contexts using modern ++ * getComposedRanges API when available. If the API is not supported or returns ++ * empty ranges, it falls back to the global window selection. ++ * ++ * **Selection Proxy:** ++ * When getComposedRanges returns valid ranges, this function creates a Selection proxy ++ * that properly handles text selection across Shadow DOM boundaries. The proxy ++ * provides all standard Selection methods while ensuring correct behavior with ++ * composed ranges. ++ * ++ * **Browser Support:** ++ * - Modern browsers with getComposedRanges: Full Shadow DOM selection support ++ * - Older browsers: Falls back to window.getSelection() ++ * ++ * @param shadowRoot - The ShadowRoot to get selection from ++ * @returns A Selection object (either a proxy with composed ranges or the global selection), ++ * or null if no selection is available ++ */ ++function getDOMSelectionFromShadowRoot(shadowRoot) { ++ const globalSelection = window.getSelection(); ++ if (!globalSelection) { ++ return null; ++ } ++ if ('getComposedRanges' in Selection.prototype) { ++ const ranges = globalSelection.getComposedRanges({ ++ shadowRoots: [shadowRoot] ++ }); ++ if (ranges.length > 0) { ++ return createSelectionWithComposedRanges(globalSelection, ranges); ++ } ++ } ++ return globalSelection; ++} ++ ++/** ++ * Returns the selection for the given window, with Shadow DOM support. ++ * ++ * This function provides a unified API for getting selections in both regular DOM ++ * and Shadow DOM contexts. When a rootElement is provided, it checks if the element ++ * is within a Shadow DOM and uses the appropriate selection API. ++ * ++ * **Behavior:** ++ * - If CAN_USE_DOM is false: Returns null ++ * - If rootElement is in Shadow DOM: Uses getDOMSelectionFromShadowRoot ++ * - Otherwise: Returns window.getSelection() from the target or global window + * +- * @param targetWindow The window to get the selection from +- * @returns a Selection or null ++ * @param targetWindow - The window to get the selection from (defaults to global window if null) ++ * @param rootElement - Optional root element to check for Shadow DOM context ++ * @returns A Selection object appropriate for the context, or null if selection is unavailable + */ +-function getDOMSelection(targetWindow) { +- return !CAN_USE_DOM ? null : (targetWindow || window).getSelection(); ++function getDOMSelection(targetWindow, rootElement) { ++ if (!CAN_USE_DOM) { ++ return null; ++ } ++ ++ // Check if we're inside a shadow DOM ++ if (rootElement) { ++ const shadowRoot = getShadowRootOrDocument(rootElement); ++ if (shadowRoot && isShadowRoot(shadowRoot)) { ++ return getDOMSelectionFromShadowRoot(shadowRoot); ++ } ++ } ++ return (targetWindow || window).getSelection(); + } + + /** +- * Returns the selection for the defaultView of the ownerDocument of given EventTarget. ++ * Creates a Selection-like proxy object that properly handles StaticRange objects ++ * from the getComposedRanges API for Shadow DOM compatibility. ++ * ++ * This function creates a proxy that: ++ * - Provides all standard Selection properties and methods ++ * - Correctly handles anchor/focus nodes from StaticRange data ++ * - Implements the `type` property ('None', 'Caret', or 'Range') ++ * - Converts StaticRange to Range objects in getRangeAt method ++ * - Delegates other methods to the base Selection object ++ * ++ * **Validation:** ++ * The function validates that composedRanges is a non-empty array with valid ++ * StaticRange objects before creating the proxy. If validation fails, it ++ * returns the base selection unchanged. + * +- * @param eventTarget The node to get the selection from +- * @returns a Selection or null ++ * @param baseSelection - The base Selection object to enhance ++ * @param composedRanges - Array of StaticRange objects from getComposedRanges ++ * @returns A proxy Selection object that correctly handles Shadow DOM ranges, ++ * or the base selection if composedRanges is invalid ++ */ ++ ++function createSelectionWithComposedRanges(baseSelection, composedRanges) { ++ if (composedRanges.length === 0) { ++ return baseSelection; ++ } ++ const firstRange = composedRanges[0]; ++ const selectionLike = Object.create(Selection.prototype); ++ ++ // Copy all methods and properties from base selection ++ const descriptors = Object.getOwnPropertyDescriptors(Selection.prototype); ++ Object.keys(descriptors).forEach(prop => { ++ if (prop === 'constructor') { ++ return; ++ } ++ const descriptor = descriptors[prop]; ++ if (descriptor.value && typeof descriptor.value === 'function') { ++ // It's a method - bind it to base selection ++ const method = baseSelection[prop]; ++ if (typeof method === 'function') { ++ selectionLike[prop] = method.bind(baseSelection); ++ } ++ } else if (!descriptor.get) { ++ // It's a regular property, not a getter - copy the value from base selection ++ const value = baseSelection[prop]; ++ if (value !== undefined) { ++ selectionLike[prop] = value; ++ } ++ } ++ }); ++ ++ // Override specific properties with composed ranges data ++ Object.defineProperty(selectionLike, 'anchorNode', { ++ enumerable: true, ++ get: () => firstRange.startContainer ++ }); ++ Object.defineProperty(selectionLike, 'anchorOffset', { ++ enumerable: true, ++ get: () => firstRange.startOffset ++ }); ++ Object.defineProperty(selectionLike, 'focusNode', { ++ enumerable: true, ++ get: () => firstRange.endContainer ++ }); ++ Object.defineProperty(selectionLike, 'focusOffset', { ++ enumerable: true, ++ get: () => firstRange.endOffset ++ }); ++ Object.defineProperty(selectionLike, 'isCollapsed', { ++ enumerable: true, ++ get: () => firstRange.collapsed ++ }); ++ Object.defineProperty(selectionLike, 'rangeCount', { ++ enumerable: true, ++ get: () => composedRanges.length ++ }); ++ Object.defineProperty(selectionLike, 'type', { ++ enumerable: true, ++ get: () => { ++ const range = composedRanges[0]; ++ if (!range) { ++ return 'None'; ++ } ++ return range.collapsed ? 'Caret' : 'Range'; ++ } ++ }); ++ ++ // Override getRangeAt to return a proper Range object from StaticRange ++ selectionLike.getRangeAt = function (index) { ++ if (index < 0 || index >= composedRanges.length) { ++ throw new DOMException('Index out of range', 'IndexSizeError'); ++ } ++ const staticRange = composedRanges[index]; ++ const range = document.createRange(); ++ range.setStart(staticRange.startContainer, staticRange.startOffset); ++ range.setEnd(staticRange.endContainer, staticRange.endOffset); ++ return range; ++ }; ++ ++ // If the original selection has getComposedRanges, preserve it ++ if ('getComposedRanges' in baseSelection) { ++ selectionLike.getComposedRanges = function () { ++ return composedRanges; ++ }; ++ } ++ return selectionLike; ++} ++function getDOMSelectionForEditor(editor) { ++ return getDOMSelection(getWindow(editor), editor.getRootElement()); ++} ++ ++/** ++ * Traverses up the DOM tree to find a ShadowRoot if the element is inside a shadow DOM. ++ * This function helps determine whether the given element is rendered within Shadow DOM ++ * encapsulation. ++ * ++ * @param element - The HTMLElement to start traversing from ++ * @returns The ShadowRoot if found, or Document if the element is not in shadow DOM ++ */ ++function getShadowRootOrDocument(element) { ++ const shadowRoot = element.getRootNode({ ++ composed: false ++ }); ++ if (isShadowRoot(shadowRoot)) { ++ return shadowRoot; ++ } ++ return document; ++} ++ ++/** ++ * Checks if the Lexical editor is running within a Shadow DOM context. ++ * ++ * This function determines whether the editor's root element is contained within ++ * a ShadowRoot, which is essential for enabling Shadow DOM-specific functionality ++ * like specialized deletion commands and selection handling. ++ * ++ * @param editor - The Lexical editor instance to check ++ * @returns `true` if the editor is in Shadow DOM, `false` otherwise ++ */ ++function $isInShadowDOMContext(editor) { ++ const rootElement = editor.getRootElement(); ++ return rootElement ? isShadowRoot(getShadowRootOrDocument(rootElement)) : false; ++} ++ ++/** ++ * Gets the appropriate Document object for an element, accounting for shadow DOM. ++ * Returns the ownerDocument of the ShadowRoot if the element is in shadow DOM, ++ * otherwise returns the element's ownerDocument or the global document. ++ * ++ * @param element - The HTMLElement to get the document for ++ * @returns The Document object that should be used for DOM operations ++ */ ++function getDocumentFromElement(element) { ++ if (!element || !CAN_USE_DOM) { ++ return document; ++ } ++ const rootNode = element.getRootNode({ ++ composed: true ++ }); ++ ++ // If the element is not connected to a document, return the default document ++ if (rootNode === element || rootNode.nodeType !== Node.DOCUMENT_NODE) { ++ return element.ownerDocument || document; ++ } ++ return rootNode; ++} ++ ++/** ++ * Gets the currently active (focused) element, accounting for shadow DOM encapsulation. ++ * In shadow DOM, the activeElement is tracked separately within the ShadowRoot. ++ * Falls back to the document's activeElement if not in shadow DOM. ++ * ++ * @param rootElement - The root element to check for shadow DOM context ++ * @returns The currently active Element or null if no element is focused ++ */ ++function getActiveElement(rootElement) { ++ const shadowRoot = getShadowRootOrDocument(rootElement); ++ if (shadowRoot && isShadowRoot(shadowRoot) && shadowRoot.activeElement) { ++ return shadowRoot.activeElement; ++ } ++ return getDocumentFromElement(rootElement).activeElement; ++} ++ ++/** ++ * Returns the selection for the defaultView of the ownerDocument of given EventTarget, ++ * with full Shadow DOM support. ++ * ++ * This function determines the appropriate selection context based on whether the ++ * EventTarget is within a Shadow DOM or regular DOM: ++ * ++ * **Shadow DOM Elements:** ++ * Uses getDOMSelectionFromShadowRoot to get a selection that properly handles ++ * Shadow DOM boundaries using the getComposedRanges API when available. ++ * ++ * **Regular DOM Elements:** ++ * Returns the standard window.getSelection() from the element's defaultView. ++ * ++ * **Edge Cases:** ++ * - Returns null for null EventTarget ++ * - Returns null for EventTargets without a valid defaultView ++ * - Handles non-HTML EventTargets gracefully ++ * ++ * @param eventTarget - The EventTarget (typically a DOM node) to get the selection from ++ * @returns A Selection object from the appropriate context or null if unavailable + */ + function getDOMSelectionFromTarget(eventTarget) { ++ if (!eventTarget) { ++ return null; ++ } ++ ++ // Check if eventTarget is in shadow DOM ++ if (isHTMLElement(eventTarget)) { ++ const shadowRoot = getShadowRootOrDocument(eventTarget); ++ if (shadowRoot && isShadowRoot(shadowRoot)) { ++ return getDOMSelectionFromShadowRoot(shadowRoot); ++ } ++ } + const defaultView = getDefaultView(eventTarget); + return defaultView ? defaultView.getSelection() : null; + } +@@ -14039,6 +14514,7 @@ exports.$isDecoratorNode = $isDecoratorNode; + exports.$isEditorState = $isEditorState; + exports.$isElementNode = $isElementNode; + exports.$isExtendableTextPointCaret = $isExtendableTextPointCaret; ++exports.$isInShadowDOMContext = $isInShadowDOMContext; + exports.$isInlineElementOrDecoratorNode = $isInlineElementOrDecoratorNode; + exports.$isLeafNode = $isLeafNode; + exports.$isLineBreakNode = $isLineBreakNode; +@@ -14072,6 +14548,7 @@ exports.$splitAtPointCaretNext = $splitAtPointCaretNext; + exports.$splitNode = $splitNode; + exports.$updateRangeSelectionFromCaretRange = $updateRangeSelectionFromCaretRange; + exports.ArtificialNode__DO_NOT_USE = ArtificialNode__DO_NOT_USE; ++exports.BEFORE_INPUT_COMMAND = BEFORE_INPUT_COMMAND; + exports.BLUR_COMMAND = BLUR_COMMAND; + exports.CAN_REDO_COMMAND = CAN_REDO_COMMAND; + exports.CAN_UNDO_COMMAND = CAN_UNDO_COMMAND; +@@ -14084,6 +14561,8 @@ exports.COMMAND_PRIORITY_EDITOR = COMMAND_PRIORITY_EDITOR; + exports.COMMAND_PRIORITY_HIGH = COMMAND_PRIORITY_HIGH; + exports.COMMAND_PRIORITY_LOW = COMMAND_PRIORITY_LOW; + exports.COMMAND_PRIORITY_NORMAL = COMMAND_PRIORITY_NORMAL; ++exports.COMPOSITION_END_COMMAND = COMPOSITION_END_COMMAND; ++exports.COMPOSITION_START_COMMAND = COMPOSITION_START_COMMAND; + exports.CONTROLLED_TEXT_INSERTION_COMMAND = CONTROLLED_TEXT_INSERTION_COMMAND; + exports.COPY_COMMAND = COPY_COMMAND; + exports.CUT_COMMAND = CUT_COMMAND; +@@ -14103,6 +14582,7 @@ exports.HISTORIC_TAG = HISTORIC_TAG; + exports.HISTORY_MERGE_TAG = HISTORY_MERGE_TAG; + exports.HISTORY_PUSH_TAG = HISTORY_PUSH_TAG; + exports.INDENT_CONTENT_COMMAND = INDENT_CONTENT_COMMAND; ++exports.INPUT_COMMAND = INPUT_COMMAND; + exports.INSERT_LINE_BREAK_COMMAND = INSERT_LINE_BREAK_COMMAND; + exports.INSERT_PARAGRAPH_COMMAND = INSERT_PARAGRAPH_COMMAND; + exports.INSERT_TAB_COMMAND = INSERT_TAB_COMMAND; +@@ -14161,15 +14641,20 @@ exports.defineExtension = defineExtension; + exports.flipDirection = flipDirection; + exports.getDOMOwnerDocument = getDOMOwnerDocument; + exports.getDOMSelection = getDOMSelection; ++exports.getDOMSelectionForEditor = getDOMSelectionForEditor; ++exports.getDOMSelectionFromShadowRoot = getDOMSelectionFromShadowRoot; + exports.getDOMSelectionFromTarget = getDOMSelectionFromTarget; + exports.getDOMTextNode = getDOMTextNode; ++exports.getDocumentFromElement = getDocumentFromElement; + exports.getEditorPropertyFromDOMNode = getEditorPropertyFromDOMNode; + exports.getNearestEditorFromDOMNode = getNearestEditorFromDOMNode; + exports.getRegisteredNode = getRegisteredNode; + exports.getRegisteredNodeOrThrow = getRegisteredNodeOrThrow; ++exports.getShadowRootOrDocument = getShadowRootOrDocument; + exports.getStaticNodeConfig = getStaticNodeConfig; + exports.getTextDirection = getTextDirection; + exports.getTransformSetFromKlass = getTransformSetFromKlass; ++exports.getWindow = getWindow; + exports.isBlockDomNode = isBlockDomNode; + exports.isCurrentlyReadOnlyMode = isCurrentlyReadOnlyMode; + exports.isDOMDocumentNode = isDOMDocumentNode; +@@ -14185,6 +14670,7 @@ exports.isLexicalEditor = isLexicalEditor; + exports.isModifierMatch = isModifierMatch; + exports.isSelectionCapturedInDecoratorInput = isSelectionCapturedInDecoratorInput; + exports.isSelectionWithinEditor = isSelectionWithinEditor; ++exports.isShadowRoot = isShadowRoot; + exports.makeStepwiseIterator = makeStepwiseIterator; + exports.removeFromParent = removeFromParent; + exports.resetRandomKey = resetRandomKey; +diff --git a/node_modules/lexical/Lexical.dev.mjs b/node_modules/lexical/Lexical.dev.mjs +index 37151a9..e2037e9 100644 +--- a/node_modules/lexical/Lexical.dev.mjs ++++ b/node_modules/lexical/Lexical.dev.mjs +@@ -306,7 +306,7 @@ function getLastSelection(editor) { + }); + } + function $handleTextMutation(target, node, editor) { +- const domSelection = getDOMSelection(getWindow(editor)); ++ const domSelection = getDOMSelectionForEditor(editor); + let anchorOffset = null; + let focusOffset = null; + if (domSelection !== null && domSelection.anchorNode === target) { +@@ -1326,7 +1326,7 @@ function $normalizePoint(point) { + + let subTreeTextContent = ''; + let subTreeTextFormat = null; +-let subTreeTextStyle = ''; ++let subTreeTextStyle = null; + let editorTextContent = ''; + let activeEditorConfig; + let activeEditor$1; +@@ -1502,8 +1502,6 @@ function $createChildren(children, element, _startIndex, endIndex, slot) { + if (node !== null && $isTextNode(node)) { + if (subTreeTextFormat === null) { + subTreeTextFormat = node.getFormat(); +- } +- if (subTreeTextStyle === '') { + subTreeTextStyle = node.getStyle(); + } + } +@@ -1543,13 +1541,13 @@ function reconcileTextFormat(element) { + } + } + function reconcileTextStyle(element) { +- if (subTreeTextStyle !== '' && subTreeTextStyle !== element.__textStyle && !activeEditorStateReadOnly) { ++ if (subTreeTextStyle != null && subTreeTextStyle !== element.__textStyle && !activeEditorStateReadOnly) { + element.setTextStyle(subTreeTextStyle); + } + } + function $reconcileChildrenWithDirection(prevElement, nextElement, dom) { + subTreeTextFormat = null; +- subTreeTextStyle = ''; ++ subTreeTextStyle = null; + $reconcileChildren(prevElement, nextElement, nextElement.getDOMSlot(dom)); + reconcileTextFormat(nextElement); + reconcileTextStyle(nextElement); +@@ -1599,8 +1597,6 @@ function $reconcileChildren(prevElement, nextElement, slot) { + if ($isTextNode(nextChildNode)) { + if (subTreeTextFormat === null) { + subTreeTextFormat = nextChildNode.getFormat(); +- } +- if (subTreeTextStyle === '') { + subTreeTextStyle = nextChildNode.getStyle(); + } + } +@@ -1808,8 +1804,6 @@ function $reconcileNodeChildren(nextElement, prevChildren, nextChildren, prevChi + if (node !== null && $isTextNode(node)) { + if (subTreeTextFormat === null) { + subTreeTextFormat = node.getFormat(); +- } +- if (subTreeTextStyle === '') { + subTreeTextStyle = node.getStyle(); + } + } +@@ -1933,6 +1927,10 @@ function createCommand(type) { + const SELECTION_CHANGE_COMMAND = createCommand('SELECTION_CHANGE_COMMAND'); + const SELECTION_INSERT_CLIPBOARD_NODES_COMMAND = createCommand('SELECTION_INSERT_CLIPBOARD_NODES_COMMAND'); + const CLICK_COMMAND = createCommand('CLICK_COMMAND'); ++const BEFORE_INPUT_COMMAND = createCommand('BEFORE_INPUT_COMMAND'); ++const INPUT_COMMAND = createCommand('INPUT_COMMAND'); ++const COMPOSITION_START_COMMAND = createCommand('COMPOSITION_START_COMMAND'); ++const COMPOSITION_END_COMMAND = createCommand('COMPOSITION_END_COMMAND'); + /** + * Dispatched to delete a character, the payload will be `true` if the deletion + * is backwards (backspace or delete on macOS) and `false` if forwards +@@ -2108,7 +2106,7 @@ function $shouldPreventDefaultAndInsertText(selection, domTargetRange, text, tim + const focus = selection.focus; + const anchorNode = anchor.getNode(); + const editor = getActiveEditor(); +- const domSelection = getDOMSelection(getWindow(editor)); ++ const domSelection = getDOMSelectionForEditor(editor); + const domAnchorNode = domSelection !== null ? domSelection.anchorNode : null; + const anchorKey = anchor.key; + const backingAnchorElement = editor.getElementByKey(anchorKey); +@@ -2294,7 +2292,7 @@ function $updateSelectionFormatStyleFromElementNode(selection, node) { + function onClick(event, editor) { + updateEditorSync(editor, () => { + const selection = $getSelection(); +- const domSelection = getDOMSelection(getWindow(editor)); ++ const domSelection = getDOMSelectionForEditor(editor); + const lastSelection = $getPreviousSelection(); + if (domSelection) { + if ($isRangeSelection(selection)) { +@@ -2364,9 +2362,15 @@ function $canRemoveText(anchorNode, focusNode) { + function isPossiblyAndroidKeyPress(timeStamp) { + return lastKeyCode === 'MediaLast' && timeStamp < lastKeyDownTimeStamp + ANDROID_COMPOSITION_LATENCY; + } ++function registerDefaultCommandHandlers(editor) { ++ editor.registerCommand(BEFORE_INPUT_COMMAND, $handleBeforeInput, COMMAND_PRIORITY_EDITOR); ++ editor.registerCommand(INPUT_COMMAND, $handleInput, COMMAND_PRIORITY_EDITOR); ++ editor.registerCommand(COMPOSITION_START_COMMAND, $handleCompositionStart, COMMAND_PRIORITY_EDITOR); ++ editor.registerCommand(COMPOSITION_END_COMMAND, $handleCompositionEnd, COMMAND_PRIORITY_EDITOR); ++ editor.registerCommand(KEY_DOWN_COMMAND, $handleKeyDown, COMMAND_PRIORITY_EDITOR); ++} + function onBeforeInput(event, editor) { + const inputType = event.inputType; +- const targetRange = getTargetRange(event); + + // We let the browser do its own thing for composition. + if (inputType === 'deleteCompositionText' || +@@ -2380,237 +2384,242 @@ function onBeforeInput(event, editor) { + } else if (inputType === 'insertCompositionText') { + return; + } +- updateEditorSync(editor, () => { +- const selection = $getSelection(); +- if (inputType === 'deleteContentBackward') { +- if (selection === null) { +- // Use previous selection +- const prevSelection = $getPreviousSelection(); +- if (!$isRangeSelection(prevSelection)) { +- return; +- } +- $setSelection(prevSelection.clone()); ++ dispatchCommand(editor, BEFORE_INPUT_COMMAND, event); ++} ++function $handleBeforeInput(event) { ++ const inputType = event.inputType; ++ const targetRange = getTargetRange(event); ++ const editor = getActiveEditor(); ++ const selection = $getSelection(); ++ if (inputType === 'deleteContentBackward') { ++ if (selection === null) { ++ // Use previous selection ++ const prevSelection = $getPreviousSelection(); ++ if (!$isRangeSelection(prevSelection)) { ++ return true; + } +- if ($isRangeSelection(selection)) { +- const isSelectionAnchorSameAsFocus = selection.anchor.key === selection.focus.key; +- if (isPossiblyAndroidKeyPress(event.timeStamp) && editor.isComposing() && isSelectionAnchorSameAsFocus) { +- $setCompositionKey(null); +- lastKeyDownTimeStamp = 0; +- // Fixes an Android bug where selection flickers when backspacing +- setTimeout(() => { +- updateEditorSync(editor, () => { +- $setCompositionKey(null); +- }); +- }, ANDROID_COMPOSITION_LATENCY); +- if ($isRangeSelection(selection)) { +- const anchorNode = selection.anchor.getNode(); +- anchorNode.markDirty(); +- if (!$isTextNode(anchorNode)) { +- formatDevErrorMessage(`Anchor node must be a TextNode`); +- } +- $updateSelectionFormatStyleFromTextNode(selection, anchorNode); +- } +- } else { +- $setCompositionKey(null); +- event.preventDefault(); +- // Chromium Android at the moment seems to ignore the preventDefault +- // on 'deleteContentBackward' and still deletes the content. Which leads +- // to multiple deletions. So we let the browser handle the deletion in this case. +- const selectedNode = selection.anchor.getNode(); +- const selectedNodeText = selectedNode.getTextContent(); +- // When the target node has `canInsertTextAfter` set to false, the first deletion +- // doesn't have an effect, so we need to handle it with Lexical. +- const selectedNodeCanInsertTextAfter = selectedNode.canInsertTextAfter(); +- const hasSelectedAllTextInNode = selection.anchor.offset === 0 && selection.focus.offset === selectedNodeText.length; +- let shouldLetBrowserHandleDelete = IS_ANDROID_CHROME && isSelectionAnchorSameAsFocus && !hasSelectedAllTextInNode && selectedNodeCanInsertTextAfter; +- // Check if selection is collapsed and if the previous node is a decorator node +- // If so, the browser will not be able to handle the deletion +- if (shouldLetBrowserHandleDelete && selection.isCollapsed()) { +- shouldLetBrowserHandleDelete = !$isDecoratorNode($getAdjacentNode(selection.anchor, true)); ++ $setSelection(prevSelection.clone()); ++ } ++ if ($isRangeSelection(selection)) { ++ const isSelectionAnchorSameAsFocus = selection.anchor.key === selection.focus.key; ++ if (isPossiblyAndroidKeyPress(event.timeStamp) && editor.isComposing() && isSelectionAnchorSameAsFocus) { ++ $setCompositionKey(null); ++ lastKeyDownTimeStamp = 0; ++ // Fixes an Android bug where selection flickers when backspacing ++ setTimeout(() => { ++ updateEditorSync(editor, () => { ++ $setCompositionKey(null); ++ }); ++ }, ANDROID_COMPOSITION_LATENCY); ++ if ($isRangeSelection(selection)) { ++ const anchorNode = selection.anchor.getNode(); ++ anchorNode.markDirty(); ++ if (!$isTextNode(anchorNode)) { ++ formatDevErrorMessage(`Anchor node must be a TextNode`); + } +- if (!shouldLetBrowserHandleDelete) { +- dispatchCommand(editor, DELETE_CHARACTER_COMMAND, true); +- // When deleting across paragraphs, Chrome on Android incorrectly shifts the selection rightwards +- // We save the correct selection to restore later during handling of selectionchange event +- const selectionAfterDelete = $getSelection(); +- if (IS_ANDROID_CHROME && $isRangeSelection(selectionAfterDelete) && selectionAfterDelete.isCollapsed()) { +- postDeleteSelectionToRestore = selectionAfterDelete; +- // Cleanup in case selectionchange does not fire +- setTimeout(() => postDeleteSelectionToRestore = null); +- } ++ $updateSelectionFormatStyleFromTextNode(selection, anchorNode); ++ } ++ } else { ++ $setCompositionKey(null); ++ event.preventDefault(); ++ // Chromium Android at the moment seems to ignore the preventDefault ++ // on 'deleteContentBackward' and still deletes the content. Which leads ++ // to multiple deletions. So we let the browser handle the deletion in this case. ++ const selectedNode = selection.anchor.getNode(); ++ const selectedNodeText = selectedNode.getTextContent(); ++ // When the target node has `canInsertTextAfter` set to false, the first deletion ++ // doesn't have an effect, so we need to handle it with Lexical. ++ const selectedNodeCanInsertTextAfter = selectedNode.canInsertTextAfter(); ++ const hasSelectedAllTextInNode = selection.anchor.offset === 0 && selection.focus.offset === selectedNodeText.length; ++ let shouldLetBrowserHandleDelete = IS_ANDROID_CHROME && isSelectionAnchorSameAsFocus && !hasSelectedAllTextInNode && selectedNodeCanInsertTextAfter; ++ // Check if selection is collapsed and if the previous node is a decorator node ++ // If so, the browser will not be able to handle the deletion ++ if (shouldLetBrowserHandleDelete && selection.isCollapsed()) { ++ shouldLetBrowserHandleDelete = !$isDecoratorNode($getAdjacentNode(selection.anchor, true)); ++ } ++ if (!shouldLetBrowserHandleDelete) { ++ dispatchCommand(editor, DELETE_CHARACTER_COMMAND, true); ++ // When deleting across paragraphs, Chrome on Android incorrectly shifts the selection rightwards ++ // We save the correct selection to restore later during handling of selectionchange event ++ const selectionAfterDelete = $getSelection(); ++ if (IS_ANDROID_CHROME && $isRangeSelection(selectionAfterDelete) && selectionAfterDelete.isCollapsed()) { ++ postDeleteSelectionToRestore = selectionAfterDelete; ++ // Cleanup in case selectionchange does not fire ++ setTimeout(() => postDeleteSelectionToRestore = null); + } + } +- return; + } ++ return true; + } +- if (!$isRangeSelection(selection)) { +- return; +- } +- const data = event.data; ++ } ++ if (!$isRangeSelection(selection)) { ++ return true; ++ } ++ const data = event.data; + +- // This represents the case when two beforeinput events are triggered at the same time (without a +- // full event loop ending at input). This happens with MacOS with the default keyboard settings, +- // a combination of autocorrection + autocapitalization. +- // Having Lexical run everything in controlled mode would fix the issue without additional code +- // but this would kill the massive performance win from the most common typing event. +- // Alternatively, when this happens we can prematurely update our EditorState based on the DOM +- // content, a job that would usually be the input event's responsibility. +- if (unprocessedBeforeInputData !== null) { +- $updateSelectedTextFromDOM(false, editor, unprocessedBeforeInputData); +- } +- if ((!selection.dirty || unprocessedBeforeInputData !== null) && selection.isCollapsed() && !$isRootNode(selection.anchor.getNode()) && targetRange !== null) { +- selection.applyDOMRange(targetRange); ++ // This represents the case when two beforeinput events are triggered at the same time (without a ++ // full event loop ending at input). This happens with MacOS with the default keyboard settings, ++ // a combination of autocorrection + autocapitalization. ++ // Having Lexical run everything in controlled mode would fix the issue without additional code ++ // but this would kill the massive performance win from the most common typing event. ++ // Alternatively, when this happens we can prematurely update our EditorState based on the DOM ++ // content, a job that would usually be the input event's responsibility. ++ if (unprocessedBeforeInputData !== null) { ++ $updateSelectedTextFromDOM(false, editor, unprocessedBeforeInputData); ++ } ++ if ((!selection.dirty || unprocessedBeforeInputData !== null) && selection.isCollapsed() && !$isRootNode(selection.anchor.getNode()) && targetRange !== null) { ++ selection.applyDOMRange(targetRange); ++ } ++ unprocessedBeforeInputData = null; ++ const anchor = selection.anchor; ++ const focus = selection.focus; ++ const anchorNode = anchor.getNode(); ++ const focusNode = focus.getNode(); ++ if (inputType === 'insertText' || inputType === 'insertTranspose') { ++ if (data === '\n') { ++ event.preventDefault(); ++ dispatchCommand(editor, INSERT_LINE_BREAK_COMMAND, false); ++ } else if (data === DOUBLE_LINE_BREAK) { ++ event.preventDefault(); ++ dispatchCommand(editor, INSERT_PARAGRAPH_COMMAND, undefined); ++ } else if (data == null && event.dataTransfer) { ++ // Gets around a Safari text replacement bug. ++ const text = event.dataTransfer.getData('text/plain'); ++ event.preventDefault(); ++ selection.insertRawText(text); ++ } else if (data != null && $shouldPreventDefaultAndInsertText(selection, targetRange, data, event.timeStamp, true)) { ++ event.preventDefault(); ++ dispatchCommand(editor, CONTROLLED_TEXT_INSERTION_COMMAND, data); ++ } else { ++ unprocessedBeforeInputData = data; + } +- unprocessedBeforeInputData = null; +- const anchor = selection.anchor; +- const focus = selection.focus; +- const anchorNode = anchor.getNode(); +- const focusNode = focus.getNode(); +- if (inputType === 'insertText' || inputType === 'insertTranspose') { +- if (data === '\n') { +- event.preventDefault(); ++ lastBeforeInputInsertTextTimeStamp = event.timeStamp; ++ return true; ++ } ++ ++ // Prevent the browser from carrying out ++ // the input event, so we can control the ++ // output. ++ event.preventDefault(); ++ switch (inputType) { ++ case 'insertFromYank': ++ case 'insertFromDrop': ++ case 'insertReplacementText': ++ { ++ dispatchCommand(editor, CONTROLLED_TEXT_INSERTION_COMMAND, event); ++ break; ++ } ++ case 'insertFromComposition': ++ { ++ // This is the end of composition ++ $setCompositionKey(null); ++ dispatchCommand(editor, CONTROLLED_TEXT_INSERTION_COMMAND, event); ++ break; ++ } ++ case 'insertLineBreak': ++ { ++ // Used for Android ++ $setCompositionKey(null); + dispatchCommand(editor, INSERT_LINE_BREAK_COMMAND, false); +- } else if (data === DOUBLE_LINE_BREAK) { +- event.preventDefault(); +- dispatchCommand(editor, INSERT_PARAGRAPH_COMMAND, undefined); +- } else if (data == null && event.dataTransfer) { +- // Gets around a Safari text replacement bug. +- const text = event.dataTransfer.getData('text/plain'); +- event.preventDefault(); +- selection.insertRawText(text); +- } else if (data != null && $shouldPreventDefaultAndInsertText(selection, targetRange, data, event.timeStamp, true)) { +- event.preventDefault(); +- dispatchCommand(editor, CONTROLLED_TEXT_INSERTION_COMMAND, data); +- } else { +- unprocessedBeforeInputData = data; ++ break; + } +- lastBeforeInputInsertTextTimeStamp = event.timeStamp; +- return; +- } ++ case 'insertParagraph': ++ { ++ // Used for Android ++ $setCompositionKey(null); + +- // Prevent the browser from carrying out +- // the input event, so we can control the +- // output. +- event.preventDefault(); +- switch (inputType) { +- case 'insertFromYank': +- case 'insertFromDrop': +- case 'insertReplacementText': +- { +- dispatchCommand(editor, CONTROLLED_TEXT_INSERTION_COMMAND, event); +- break; +- } +- case 'insertFromComposition': +- { +- // This is the end of composition +- $setCompositionKey(null); +- dispatchCommand(editor, CONTROLLED_TEXT_INSERTION_COMMAND, event); +- break; +- } +- case 'insertLineBreak': +- { +- // Used for Android +- $setCompositionKey(null); ++ // Safari does not provide the type "insertLineBreak". ++ // So instead, we need to infer it from the keyboard event. ++ // We do not apply this logic to iOS to allow newline auto-capitalization ++ // work without creating linebreaks when pressing Enter ++ if (isInsertLineBreak && !IS_IOS) { ++ isInsertLineBreak = false; + dispatchCommand(editor, INSERT_LINE_BREAK_COMMAND, false); +- break; +- } +- case 'insertParagraph': +- { +- // Used for Android +- $setCompositionKey(null); +- +- // Safari does not provide the type "insertLineBreak". +- // So instead, we need to infer it from the keyboard event. +- // We do not apply this logic to iOS to allow newline auto-capitalization +- // work without creating linebreaks when pressing Enter +- if (isInsertLineBreak && !IS_IOS) { +- isInsertLineBreak = false; +- dispatchCommand(editor, INSERT_LINE_BREAK_COMMAND, false); +- } else { +- dispatchCommand(editor, INSERT_PARAGRAPH_COMMAND, undefined); +- } +- break; +- } +- case 'insertFromPaste': +- case 'insertFromPasteAsQuotation': +- { +- dispatchCommand(editor, PASTE_COMMAND, event); +- break; +- } +- case 'deleteByComposition': +- { +- if ($canRemoveText(anchorNode, focusNode)) { +- dispatchCommand(editor, REMOVE_TEXT_COMMAND, event); +- } +- break; ++ } else { ++ dispatchCommand(editor, INSERT_PARAGRAPH_COMMAND, undefined); + } +- case 'deleteByDrag': +- case 'deleteByCut': +- { ++ break; ++ } ++ case 'insertFromPaste': ++ case 'insertFromPasteAsQuotation': ++ { ++ dispatchCommand(editor, PASTE_COMMAND, event); ++ break; ++ } ++ case 'deleteByComposition': ++ { ++ if ($canRemoveText(anchorNode, focusNode)) { + dispatchCommand(editor, REMOVE_TEXT_COMMAND, event); +- break; +- } +- case 'deleteContent': +- { +- dispatchCommand(editor, DELETE_CHARACTER_COMMAND, false); +- break; +- } +- case 'deleteWordBackward': +- { +- dispatchCommand(editor, DELETE_WORD_COMMAND, true); +- break; +- } +- case 'deleteWordForward': +- { +- dispatchCommand(editor, DELETE_WORD_COMMAND, false); +- break; +- } +- case 'deleteHardLineBackward': +- case 'deleteSoftLineBackward': +- { +- dispatchCommand(editor, DELETE_LINE_COMMAND, true); +- break; +- } +- case 'deleteContentForward': +- case 'deleteHardLineForward': +- case 'deleteSoftLineForward': +- { +- dispatchCommand(editor, DELETE_LINE_COMMAND, false); +- break; +- } +- case 'formatStrikeThrough': +- { +- dispatchCommand(editor, FORMAT_TEXT_COMMAND, 'strikethrough'); +- break; +- } +- case 'formatBold': +- { +- dispatchCommand(editor, FORMAT_TEXT_COMMAND, 'bold'); +- break; +- } +- case 'formatItalic': +- { +- dispatchCommand(editor, FORMAT_TEXT_COMMAND, 'italic'); +- break; +- } +- case 'formatUnderline': +- { +- dispatchCommand(editor, FORMAT_TEXT_COMMAND, 'underline'); +- break; +- } +- case 'historyUndo': +- { +- dispatchCommand(editor, UNDO_COMMAND, undefined); +- break; + } +- case 'historyRedo': +- { +- dispatchCommand(editor, REDO_COMMAND, undefined); +- break; +- } +- // NO-OP +- } +- }); ++ break; ++ } ++ case 'deleteByDrag': ++ case 'deleteByCut': ++ { ++ dispatchCommand(editor, REMOVE_TEXT_COMMAND, event); ++ break; ++ } ++ case 'deleteContent': ++ { ++ dispatchCommand(editor, DELETE_CHARACTER_COMMAND, false); ++ break; ++ } ++ case 'deleteWordBackward': ++ { ++ dispatchCommand(editor, DELETE_WORD_COMMAND, true); ++ break; ++ } ++ case 'deleteWordForward': ++ { ++ dispatchCommand(editor, DELETE_WORD_COMMAND, false); ++ break; ++ } ++ case 'deleteHardLineBackward': ++ case 'deleteSoftLineBackward': ++ { ++ dispatchCommand(editor, DELETE_LINE_COMMAND, true); ++ break; ++ } ++ case 'deleteContentForward': ++ case 'deleteHardLineForward': ++ case 'deleteSoftLineForward': ++ { ++ dispatchCommand(editor, DELETE_LINE_COMMAND, false); ++ break; ++ } ++ case 'formatStrikeThrough': ++ { ++ dispatchCommand(editor, FORMAT_TEXT_COMMAND, 'strikethrough'); ++ break; ++ } ++ case 'formatBold': ++ { ++ dispatchCommand(editor, FORMAT_TEXT_COMMAND, 'bold'); ++ break; ++ } ++ case 'formatItalic': ++ { ++ dispatchCommand(editor, FORMAT_TEXT_COMMAND, 'italic'); ++ break; ++ } ++ case 'formatUnderline': ++ { ++ dispatchCommand(editor, FORMAT_TEXT_COMMAND, 'underline'); ++ break; ++ } ++ case 'historyUndo': ++ { ++ dispatchCommand(editor, UNDO_COMMAND, undefined); ++ break; ++ } ++ case 'historyRedo': ++ { ++ dispatchCommand(editor, REDO_COMMAND, undefined); ++ break; ++ } ++ // NO-OP ++ } ++ return true; + } + function onInput(event, editor) { + // Note that the MutationObserver may or may not have already fired, +@@ -2622,90 +2631,103 @@ function onInput(event, editor) { + // We don't want the onInput to bubble, in the case of nested editors. + event.stopPropagation(); + updateEditorSync(editor, () => { +- if (isHTMLElement(event.target) && $isSelectionCapturedInDecorator(event.target)) { +- return; ++ editor.dispatchCommand(INPUT_COMMAND, event); ++ }, { ++ event ++ }); ++ unprocessedBeforeInputData = null; ++} ++function $handleInput(event) { ++ if (isHTMLElement(event.target) && $isSelectionCapturedInDecorator(event.target)) { ++ return true; ++ } ++ const editor = getActiveEditor(); ++ const selection = $getSelection(); ++ const data = event.data; ++ const targetRange = getTargetRange(event); ++ if (data != null && $isRangeSelection(selection) && $shouldPreventDefaultAndInsertText(selection, targetRange, data, event.timeStamp, false)) { ++ // Given we're over-riding the default behavior, we will need ++ // to ensure to disable composition before dispatching the ++ // insertText command for when changing the sequence for FF. ++ if (isFirefoxEndingComposition) { ++ $onCompositionEndImpl(editor, data); ++ isFirefoxEndingComposition = false; + } +- const selection = $getSelection(); +- const data = event.data; +- const targetRange = getTargetRange(event); +- if (data != null && $isRangeSelection(selection) && $shouldPreventDefaultAndInsertText(selection, targetRange, data, event.timeStamp, false)) { +- // Given we're over-riding the default behavior, we will need +- // to ensure to disable composition before dispatching the +- // insertText command for when changing the sequence for FF. +- if (isFirefoxEndingComposition) { +- $onCompositionEndImpl(editor, data); +- isFirefoxEndingComposition = false; +- } +- const anchor = selection.anchor; +- const anchorNode = anchor.getNode(); +- const domSelection = getDOMSelection(getWindow(editor)); +- if (domSelection === null) { +- return; +- } +- const isBackward = selection.isBackward(); +- const startOffset = isBackward ? selection.anchor.offset : selection.focus.offset; +- const endOffset = isBackward ? selection.focus.offset : selection.anchor.offset; +- // If the content is the same as inserted, then don't dispatch an insertion. +- // Given onInput doesn't take the current selection (it uses the previous) +- // we can compare that against what the DOM currently says. +- if (!CAN_USE_BEFORE_INPUT || selection.isCollapsed() || !$isTextNode(anchorNode) || domSelection.anchorNode === null || anchorNode.getTextContent().slice(0, startOffset) + data + anchorNode.getTextContent().slice(startOffset + endOffset) !== getAnchorTextFromDOM(domSelection.anchorNode)) { +- dispatchCommand(editor, CONTROLLED_TEXT_INSERTION_COMMAND, data); +- } +- const textLength = data.length; ++ const anchor = selection.anchor; ++ const anchorNode = anchor.getNode(); ++ const domSelection = getDOMSelection(getWindow(editor)); ++ if (domSelection === null) { ++ return true; ++ } ++ const isBackward = selection.isBackward(); ++ const startOffset = isBackward ? selection.anchor.offset : selection.focus.offset; ++ const endOffset = isBackward ? selection.focus.offset : selection.anchor.offset; ++ // If the content is the same as inserted, then don't dispatch an insertion. ++ // Given onInput doesn't take the current selection (it uses the previous) ++ // we can compare that against what the DOM currently says. ++ if (!CAN_USE_BEFORE_INPUT || selection.isCollapsed() || !$isTextNode(anchorNode) || domSelection.anchorNode === null || anchorNode.getTextContent().slice(0, startOffset) + data + anchorNode.getTextContent().slice(startOffset + endOffset) !== getAnchorTextFromDOM(domSelection.anchorNode)) { ++ dispatchCommand(editor, CONTROLLED_TEXT_INSERTION_COMMAND, data); ++ } ++ const textLength = data.length; + +- // Another hack for FF, as it's possible that the IME is still +- // open, even though compositionend has already fired (sigh). +- if (IS_FIREFOX && textLength > 1 && event.inputType === 'insertCompositionText' && !editor.isComposing()) { +- selection.anchor.offset -= textLength; +- } ++ // Another hack for FF, as it's possible that the IME is still ++ // open, even though compositionend has already fired (sigh). ++ if (IS_FIREFOX && textLength > 1 && event.inputType === 'insertCompositionText' && !editor.isComposing()) { ++ selection.anchor.offset -= textLength; ++ } + +- // This ensures consistency on Android. +- if (!IS_SAFARI && !IS_IOS && !IS_APPLE_WEBKIT && editor.isComposing()) { +- lastKeyDownTimeStamp = 0; +- $setCompositionKey(null); +- } +- } else { +- const characterData = data !== null ? data : undefined; +- $updateSelectedTextFromDOM(false, editor, characterData); ++ // This ensures consistency on Android. ++ if (!IS_SAFARI && !IS_IOS && !IS_APPLE_WEBKIT && editor.isComposing()) { ++ lastKeyDownTimeStamp = 0; ++ $setCompositionKey(null); ++ } ++ } else { ++ const characterData = data !== null ? data : undefined; ++ $updateSelectedTextFromDOM(false, editor, characterData); + +- // onInput always fires after onCompositionEnd for FF. +- if (isFirefoxEndingComposition) { +- $onCompositionEndImpl(editor, data || undefined); +- isFirefoxEndingComposition = false; +- } ++ // onInput always fires after onCompositionEnd for FF. ++ if (isFirefoxEndingComposition) { ++ $onCompositionEndImpl(editor, data || undefined); ++ isFirefoxEndingComposition = false; + } ++ } + +- // Also flush any other mutations that might have occurred +- // since the change. +- $flushMutations(); +- }, { +- event +- }); +- unprocessedBeforeInputData = null; ++ // Also flush any other mutations that might have occurred ++ // since the change. ++ $flushMutations(); ++ return true; + } + function onCompositionStart(event, editor) { +- updateEditorSync(editor, () => { +- const selection = $getSelection(); +- if ($isRangeSelection(selection) && !editor.isComposing()) { +- const anchor = selection.anchor; +- const node = selection.anchor.getNode(); +- $setCompositionKey(anchor.key); +- if ( +- // If it has been 30ms since the last keydown, then we should +- // apply the empty space heuristic. We can't do this for Safari, +- // as the keydown fires after composition start. +- event.timeStamp < lastKeyDownTimeStamp + ANDROID_COMPOSITION_LATENCY || +- // FF has issues around composing multibyte characters, so we also +- // need to invoke the empty space heuristic below. +- anchor.type === 'element' || !selection.isCollapsed() || node.getFormat() !== selection.format || $isTextNode(node) && node.getStyle() !== selection.style) { +- // We insert a zero width character, ready for the composition +- // to get inserted into the new node we create. If +- // we don't do this, Safari will fail on us because +- // there is no text node matching the selection. +- dispatchCommand(editor, CONTROLLED_TEXT_INSERTION_COMMAND, COMPOSITION_START_CHAR); +- } ++ dispatchCommand(editor, COMPOSITION_START_COMMAND, event); ++} ++function $handleCompositionStart(event) { ++ const editor = getActiveEditor(); ++ const selection = $getSelection(); ++ if ($isRangeSelection(selection) && !editor.isComposing()) { ++ const anchor = selection.anchor; ++ const node = selection.anchor.getNode(); ++ $setCompositionKey(anchor.key); ++ if ( ++ // If it has been 30ms since the last keydown, then we should ++ // apply the empty space heuristic. We can't do this for Safari, ++ // as the keydown fires after composition start. ++ event.timeStamp < lastKeyDownTimeStamp + ANDROID_COMPOSITION_LATENCY || ++ // FF has issues around composing multibyte characters, so we also ++ // need to invoke the empty space heuristic below. ++ anchor.type === 'element' || !selection.isCollapsed() || node.getFormat() !== selection.format || $isTextNode(node) && node.getStyle() !== selection.style) { ++ // We insert a zero width character, ready for the composition ++ // to get inserted into the new node we create. If ++ // we don't do this, Safari will fail on us because ++ // there is no text node matching the selection. ++ dispatchCommand(editor, CONTROLLED_TEXT_INSERTION_COMMAND, COMPOSITION_START_CHAR); + } +- }); ++ } ++ return true; ++} ++function $handleCompositionEnd(event) { ++ const editor = getActiveEditor(); ++ $onCompositionEndImpl(editor, event.data); ++ return true; + } + function $onCompositionEndImpl(editor, data) { + const compositionKey = editor._compositionKey; +@@ -2757,9 +2779,7 @@ function onCompositionEnd(event, editor) { + isSafariEndingComposition = true; + safariEndCompositionEventData = event.data; + } else { +- updateEditorSync(editor, () => { +- $onCompositionEndImpl(editor, event.data); +- }); ++ dispatchCommand(editor, COMPOSITION_END_COMMAND, event); + } + } + function onKeyDown(event, editor) { +@@ -2768,11 +2788,12 @@ function onKeyDown(event, editor) { + if (editor.isComposing()) { + return; + } +- if (dispatchCommand(editor, KEY_DOWN_COMMAND, event)) { +- return; +- } ++ dispatchCommand(editor, KEY_DOWN_COMMAND, event); ++} ++function $handleKeyDown(event) { ++ const editor = getActiveEditor(); + if (event.key == null) { +- return; ++ return true; + } + if (isSafariEndingComposition && isBackspace(event)) { + updateEditorSync(editor, () => { +@@ -2780,7 +2801,7 @@ function onKeyDown(event, editor) { + }); + isSafariEndingComposition = false; + safariEndCompositionEventData = ''; +- return; ++ return true; + } + if (isMoveForward(event)) { + dispatchCommand(editor, KEY_ARROW_RIGHT_COMMAND, event); +@@ -2871,8 +2892,9 @@ function onKeyDown(event, editor) { + } + } + if (isModifier(event)) { +- dispatchCommand(editor, KEY_MODIFIER_COMMAND, event); ++ editor.dispatchCommand(KEY_MODIFIER_COMMAND, event); + } ++ return true; + } + function getRootElementRemoveHandles(rootElement) { + // @ts-expect-error: internal field +@@ -2947,7 +2969,7 @@ function hasStoppedLexicalPropagation(event) { + function addRootElementEvents(rootElement, editor) { + // We only want to have a single global selectionchange event handler, shared + // between all editor instances. +- const doc = rootElement.ownerDocument; ++ const doc = getShadowRootOrDocument(rootElement); + rootElementToDocument.set(rootElement, doc); + const documentRootElementsCount = rootElementsRegistered.get(doc) ?? 0; + if (documentRootElementsCount < 1) { +@@ -3005,7 +3027,7 @@ function addRootElementEvents(rootElement, editor) { + } + const rootElementNotRegisteredWarning = warnOnlyOnce('Root element not registered'); + function removeRootElementEvents(rootElement) { +- const doc = rootElementToDocument.get(rootElement); ++ const doc = getShadowRootOrDocument(rootElement); + if (doc === undefined) { + rootElementNotRegisteredWarning(); + return; +@@ -6758,7 +6780,7 @@ class RangeSelection { + } + const collapse = alter === 'move'; + const editor = getActiveEditor(); +- const domSelection = getDOMSelection(getWindow(editor)); ++ const domSelection = getDOMSelectionForEditor(editor); + if (!domSelection) { + return; + } +@@ -6846,11 +6868,12 @@ class RangeSelection { + } + /** + * Helper for handling forward character and word deletion that prevents element nodes +- * like a table, columns layout being destroyed ++ * like a table, columns layout being destroyed. Also prevents deletion into shadow roots. + * + * @param anchor the anchor + * @param anchorNode the anchor node in the selection + * @param isBackward whether or not selection is backwards ++ * @returns true if deletion should be prevented + */ + forwardDeletion(anchor, anchorNode, isBackward) { + if (!isBackward && ( +@@ -6954,7 +6977,26 @@ class RangeSelection { + + // Handle the deletion around decorators. + const focus = this.focus; ++ const initialAnchorKey = anchor.key; ++ const initialAnchorOffset = anchor.offset; ++ const initialFocusKey = focus.key; ++ const initialFocusOffset = focus.offset; + this.modify('extend', isBackward, 'character'); ++ ++ // Check if modify actually changed the selection (it might not in shadow DOM) ++ const selectionChanged = this.anchor.key !== initialAnchorKey || this.anchor.offset !== initialAnchorOffset || this.focus.key !== initialFocusKey || this.focus.offset !== initialFocusOffset; ++ if (!selectionChanged && anchor.type === 'text' && $isTextNode(anchorNode)) { ++ // Fallback for environments where modify doesn't work (e.g., shadow DOM) ++ const textContent = anchorNode.getTextContent(); ++ const offset = anchor.offset; ++ if (isBackward && offset > 0) { ++ // Select the character before cursor ++ this.anchor.set(anchor.key, offset - 1, 'text'); ++ } else if (!isBackward && offset < textContent.length) { ++ // Select the character after cursor ++ this.focus.set(focus.key, offset + 1, 'text'); ++ } ++ } + if (!this.isCollapsed()) { + const focusNode = focus.type === 'text' ? focus.getNode() : null; + anchorNode = anchor.type === 'text' ? anchor.getNode() : null; +@@ -6998,7 +7040,31 @@ class RangeSelection { + */ + deleteLine(isBackward) { + if (this.isCollapsed()) { ++ const anchor = this.anchor; ++ const focus = this.focus; ++ const initialAnchorKey = anchor.key; ++ const initialAnchorOffset = anchor.offset; ++ const initialFocusKey = focus.key; ++ const initialFocusOffset = focus.offset; + this.modify('extend', isBackward, 'lineboundary'); ++ ++ // Check if modify actually changed the selection (it might not in shadow DOM) ++ const selectionChanged = this.anchor.key !== initialAnchorKey || this.anchor.offset !== initialAnchorOffset || this.focus.key !== initialFocusKey || this.focus.offset !== initialFocusOffset; ++ if (!selectionChanged && anchor.type === 'text') { ++ // Fallback for environments where modify doesn't work (e.g., shadow DOM) ++ const anchorNode = anchor.getNode(); ++ if ($isTextNode(anchorNode)) { ++ const textContent = anchorNode.getTextContent(); ++ const offset = anchor.offset; ++ if (isBackward && offset > 0) { ++ // Delete from beginning of line to cursor ++ this.anchor.set(anchor.key, 0, 'text'); ++ } else if (!isBackward && offset < textContent.length) { ++ // Delete from cursor to end of line ++ this.focus.set(focus.key, textContent.length, 'text'); ++ } ++ } ++ } + } + if (this.isCollapsed()) { + // If the selection was already collapsed at the lineboundary, +@@ -7010,6 +7076,57 @@ class RangeSelection { + } + } + ++ /** ++ * Helper function to determine if a character is a word boundary (whitespace). ++ * @param char the character to check ++ * @returns true if the character is a word boundary ++ */ ++ isWordBoundary(char) { ++ return char === ' ' || char === '\t' || char === '\n' || char === '\r'; ++ } ++ ++ /** ++ * Find the start of a word going backward from the given offset in text. ++ * @param text the text to search in ++ * @param offset the starting offset ++ * @returns the offset of the word start ++ */ ++ findWordStart(text, offset) { ++ let position = offset - 1; ++ ++ // Skip spaces ++ while (position >= 0 && this.isWordBoundary(text[position])) { ++ position--; ++ } ++ ++ // Find word start ++ while (position > 0 && !this.isWordBoundary(text[position - 1])) { ++ position--; ++ } ++ return position >= 0 ? position : 0; ++ } ++ ++ /** ++ * Find the end of a word going forward from the given offset in text. ++ * @param text the text to search in ++ * @param offset the starting offset ++ * @returns the offset of the word end ++ */ ++ findWordEnd(text, offset) { ++ let position = offset; ++ ++ // Skip spaces ++ while (position < text.length && this.isWordBoundary(text[position])) { ++ position++; ++ } ++ ++ // Find word end ++ while (position < text.length && !this.isWordBoundary(text[position])) { ++ position++; ++ } ++ return position; ++ } ++ + /** + * Performs one logical word deletion operation on the EditorState based on the current Selection. + * Handles different node types. +@@ -7023,7 +7140,69 @@ class RangeSelection { + if (this.forwardDeletion(anchor, anchorNode, isBackward)) { + return; + } ++ const initialAnchorKey = anchor.key; ++ const initialAnchorOffset = anchor.offset; ++ const focus = this.focus; ++ const initialFocusKey = focus.key; ++ const initialFocusOffset = focus.offset; + this.modify('extend', isBackward, 'word'); ++ ++ // Check if modify actually changed the selection (it might not in shadow DOM) ++ const selectionChanged = this.anchor.key !== initialAnchorKey || this.anchor.offset !== initialAnchorOffset || this.focus.key !== initialFocusKey || this.focus.offset !== initialFocusOffset; ++ if (!selectionChanged && anchor.type === 'text' && $isTextNode(anchorNode)) { ++ // Fallback for environments where modify doesn't work (e.g., shadow DOM) ++ const textContent = anchorNode.getTextContent(); ++ const offset = anchor.offset; ++ if (isBackward) { ++ // Backward: find start of word before cursor ++ if (offset === 0) { ++ // At node start, check previous sibling ++ const prevSibling = anchorNode.getPreviousSibling(); ++ if ($isTextNode(prevSibling)) { ++ const prevText = prevSibling.getTextContent(); ++ const position = this.findWordStart(prevText, prevText.length); ++ this.anchor.set(prevSibling.__key, position, 'text'); ++ } ++ } else { ++ const position = this.findWordStart(textContent, offset); ++ if (position === 0 && this.isWordBoundary(textContent[0])) { ++ // Only spaces in this node, try previous sibling ++ const prevSibling = anchorNode.getPreviousSibling(); ++ if ($isTextNode(prevSibling)) { ++ const prevText = prevSibling.getTextContent(); ++ const prevPosition = this.findWordStart(prevText, prevText.length); ++ this.anchor.set(prevSibling.__key, prevPosition, 'text'); ++ return; ++ } ++ } ++ this.anchor.set(anchor.key, position, 'text'); ++ } ++ } else { ++ // Forward: find end of word after cursor ++ if (offset === textContent.length) { ++ // At node end, check next sibling ++ const nextSibling = anchorNode.getNextSibling(); ++ if ($isTextNode(nextSibling)) { ++ const nextText = nextSibling.getTextContent(); ++ const position = this.findWordEnd(nextText, 0); ++ this.focus.set(nextSibling.__key, position, 'text'); ++ } ++ } else { ++ const position = this.findWordEnd(textContent, offset); ++ if (position === textContent.length && this.isWordBoundary(textContent[textContent.length - 1])) { ++ // Only spaces in this node, try next sibling ++ const nextSibling = anchorNode.getNextSibling(); ++ if ($isTextNode(nextSibling)) { ++ const nextText = nextSibling.getTextContent(); ++ const nextPosition = this.findWordEnd(nextText, 0); ++ this.focus.set(nextSibling.__key, nextPosition, 'text'); ++ return; ++ } ++ } ++ this.focus.set(focus.key, position, 'text'); ++ } ++ } ++ } + } + this.removeText(); + } +@@ -7472,7 +7651,7 @@ function $createNodeSelection() { + function $internalCreateSelection(editor, event) { + const currentEditorState = editor.getEditorState(); + const lastSelection = currentEditorState._selection; +- const domSelection = getDOMSelection(getWindow(editor)); ++ const domSelection = getDOMSelectionForEditor(editor); + if ($isRangeSelection(lastSelection) || lastSelection == null) { + return $internalCreateRangeSelection(lastSelection, domSelection, editor, event); + } +@@ -7730,7 +7909,7 @@ function updateDOMSelection(prevSelection, nextSelection, editor, domSelection, + const focusDOMNode = domSelection.focusNode; + const anchorOffset = domSelection.anchorOffset; + const focusOffset = domSelection.focusOffset; +- const activeElement = document.activeElement; ++ const activeElement = getActiveElement(rootElement); + + // TODO: make this not hard-coded, and add another config option + // that makes this configurable. +@@ -8457,7 +8636,7 @@ function $commitPendingUpdates(editor, recoveryEditorState) { + // Reconciliation has finished. Now update selection and trigger listeners. + // ====== + +- const domSelection = shouldSkipDOM ? null : getDOMSelection(getWindow(editor)); ++ const domSelection = shouldSkipDOM ? null : getDOMSelectionForEditor(editor); + + // Attempt to update the DOM selection, including focusing of the root element, + // and scroll into view if needed. +@@ -9489,11 +9668,15 @@ class ElementNode extends LexicalNode { + }; + const textFormat = this.getTextFormat(); + const textStyle = this.getTextStyle(); +- if (textFormat !== 0) { +- json.textFormat = textFormat; +- } +- if (textStyle !== '') { +- json.textStyle = textStyle; ++ // Only persist for cases when there are no TextNode children from which ++ // these would be set on reconcile (#7968) ++ if ((textFormat !== 0 || textStyle !== '') && !$isRootOrShadowRoot(this) && !this.getChildren().some($isTextNode)) { ++ if (textFormat !== 0) { ++ json.textFormat = textFormat; ++ } ++ if (textStyle !== '') { ++ json.textStyle = textStyle; ++ } + } + return json; + } +@@ -9890,12 +10073,20 @@ class ParagraphNode extends ElementNode { + return $createParagraphNode().updateFromJSON(serializedNode); + } + exportJSON() { +- return { +- ...super.exportJSON(), +- // These are included explicitly for backwards compatibility +- textFormat: this.getTextFormat(), +- textStyle: this.getTextStyle() +- }; ++ const json = super.exportJSON(); ++ // Provide backwards compatible values, see #7971 ++ if (json.textFormat === undefined || json.textStyle === undefined) { ++ // Compute the same value that the reconciler would ++ const firstTextNode = this.getChildren().find($isTextNode); ++ if (firstTextNode) { ++ json.textFormat = firstTextNode.getFormat(); ++ json.textStyle = firstTextNode.getStyle(); ++ } else { ++ json.textFormat = this.getTextFormat(); ++ json.textStyle = this.getTextStyle(); ++ } ++ } ++ return json; + } + + // Mutation +@@ -10178,6 +10369,7 @@ function createEditor(editorConfig) { + editor._pendingEditorState = initialEditorState; + editor._dirtyType = FULL_RECONCILE; + } ++ registerDefaultCommandHandlers(editor); + return editor; + } + class LexicalEditor { +@@ -10819,7 +11011,7 @@ class LexicalEditor { + if (rootElement !== null) { + rootElement.blur(); + } +- const domSelection = getDOMSelection(this._window); ++ const domSelection = getDOMSelectionForEditor(this); + if (domSelection !== null) { + domSelection.removeAllRanges(); + } +@@ -10905,7 +11097,9 @@ function $isSelectionCapturedInDecorator(node) { + return $isDecoratorNode($getNearestNodeFromDOMNode(node)); + } + function isSelectionCapturedInDecoratorInput(anchorDOM) { +- const activeElement = document.activeElement; ++ const editor = getNearestEditorFromDOMNode(anchorDOM); ++ const rootElement = editor ? editor.getRootElement() : null; ++ const activeElement = rootElement ? getActiveElement(rootElement) : document.activeElement; + if (!isHTMLElement(activeElement)) { + return false; + } +@@ -11352,7 +11546,7 @@ function getAnchorTextFromDOM(anchorNode) { + } + function $updateSelectedTextFromDOM(isCompositionEnd, editor, data) { + // Update the text content with the latest composition text +- const domSelection = getDOMSelection(getWindow(editor)); ++ const domSelection = getDOMSelectionForEditor(editor); + if (domSelection === null) { + return; + } +@@ -11797,9 +11991,23 @@ function getElementByKeyOrThrow(editor, key) { + } + return element; + } ++ ++/** ++ * Type guard function that checks if a node is a ShadowRoot. This function performs ++ * runtime validation to safely narrow types and enable type-safe Shadow DOM operations. ++ * It checks both the nodeType and the presence of the 'host' property to distinguish ++ * ShadowRoot from regular DocumentFragment nodes. ++ * ++ * @param node - The Node to check (can be null) ++ * @returns True if the node is a ShadowRoot, false otherwise. When true, TypeScript ++ * will narrow the type to ShadowRoot for subsequent operations. ++ */ ++function isShadowRoot(node) { ++ return isDocumentFragment(node) && 'host' in node; ++} + function getParentElement(node) { + const parentElement = node.assignedSlot || node.parentElement; +- return isDocumentFragment(parentElement) ? parentElement.host : parentElement; ++ return isShadowRoot(parentElement) ? parentElement.host : parentElement; + } + function getDOMOwnerDocument(target) { + return isDOMDocumentNode(target) ? target : isHTMLElement(target) ? target.ownerDocument : null; +@@ -11907,7 +12115,7 @@ function getDefaultView(domElem) { + return ownerDoc ? ownerDoc.defaultView : null; + } + function getWindow(editor) { +- const windowObj = editor._window; ++ const windowObj = editor._window || window; + if (windowObj === null) { + { + formatDevErrorMessage(`window object not found`); +@@ -12026,7 +12234,7 @@ function removeDOMBlockCursorElement(blockCursorElement, editor, rootElement) { + } + function updateDOMBlockCursorElement(editor, rootElement, nextSelection) { + let blockCursorElement = editor._blockCursorElement; +- if ($isRangeSelection(nextSelection) && nextSelection.isCollapsed() && nextSelection.anchor.type === 'element' && rootElement.contains(document.activeElement)) { ++ if ($isRangeSelection(nextSelection) && nextSelection.isCollapsed() && nextSelection.anchor.type === 'element' && rootElement.contains(getActiveElement(rootElement))) { + const anchor = nextSelection.anchor; + const elementNode = anchor.getNode(); + const offset = anchor.offset; +@@ -12069,23 +12277,290 @@ function updateDOMBlockCursorElement(editor, rootElement, nextSelection) { + } + + /** +- * Returns the selection for the given window, or the global window if null. +- * Will return null if {@link CAN_USE_DOM} is false. ++ * Returns a Selection object from a ShadowRoot using the best available API. ++ * ++ * This function attempts to get selection from Shadow DOM contexts using modern ++ * getComposedRanges API when available. If the API is not supported or returns ++ * empty ranges, it falls back to the global window selection. ++ * ++ * **Selection Proxy:** ++ * When getComposedRanges returns valid ranges, this function creates a Selection proxy ++ * that properly handles text selection across Shadow DOM boundaries. The proxy ++ * provides all standard Selection methods while ensuring correct behavior with ++ * composed ranges. ++ * ++ * **Browser Support:** ++ * - Modern browsers with getComposedRanges: Full Shadow DOM selection support ++ * - Older browsers: Falls back to window.getSelection() ++ * ++ * @param shadowRoot - The ShadowRoot to get selection from ++ * @returns A Selection object (either a proxy with composed ranges or the global selection), ++ * or null if no selection is available ++ */ ++function getDOMSelectionFromShadowRoot(shadowRoot) { ++ const globalSelection = window.getSelection(); ++ if (!globalSelection) { ++ return null; ++ } ++ if ('getComposedRanges' in Selection.prototype) { ++ const ranges = globalSelection.getComposedRanges({ ++ shadowRoots: [shadowRoot] ++ }); ++ if (ranges.length > 0) { ++ return createSelectionWithComposedRanges(globalSelection, ranges); ++ } ++ } ++ return globalSelection; ++} ++ ++/** ++ * Returns the selection for the given window, with Shadow DOM support. ++ * ++ * This function provides a unified API for getting selections in both regular DOM ++ * and Shadow DOM contexts. When a rootElement is provided, it checks if the element ++ * is within a Shadow DOM and uses the appropriate selection API. ++ * ++ * **Behavior:** ++ * - If CAN_USE_DOM is false: Returns null ++ * - If rootElement is in Shadow DOM: Uses getDOMSelectionFromShadowRoot ++ * - Otherwise: Returns window.getSelection() from the target or global window + * +- * @param targetWindow The window to get the selection from +- * @returns a Selection or null ++ * @param targetWindow - The window to get the selection from (defaults to global window if null) ++ * @param rootElement - Optional root element to check for Shadow DOM context ++ * @returns A Selection object appropriate for the context, or null if selection is unavailable + */ +-function getDOMSelection(targetWindow) { +- return !CAN_USE_DOM ? null : (targetWindow || window).getSelection(); ++function getDOMSelection(targetWindow, rootElement) { ++ if (!CAN_USE_DOM) { ++ return null; ++ } ++ ++ // Check if we're inside a shadow DOM ++ if (rootElement) { ++ const shadowRoot = getShadowRootOrDocument(rootElement); ++ if (shadowRoot && isShadowRoot(shadowRoot)) { ++ return getDOMSelectionFromShadowRoot(shadowRoot); ++ } ++ } ++ return (targetWindow || window).getSelection(); + } + + /** +- * Returns the selection for the defaultView of the ownerDocument of given EventTarget. ++ * Creates a Selection-like proxy object that properly handles StaticRange objects ++ * from the getComposedRanges API for Shadow DOM compatibility. ++ * ++ * This function creates a proxy that: ++ * - Provides all standard Selection properties and methods ++ * - Correctly handles anchor/focus nodes from StaticRange data ++ * - Implements the `type` property ('None', 'Caret', or 'Range') ++ * - Converts StaticRange to Range objects in getRangeAt method ++ * - Delegates other methods to the base Selection object ++ * ++ * **Validation:** ++ * The function validates that composedRanges is a non-empty array with valid ++ * StaticRange objects before creating the proxy. If validation fails, it ++ * returns the base selection unchanged. + * +- * @param eventTarget The node to get the selection from +- * @returns a Selection or null ++ * @param baseSelection - The base Selection object to enhance ++ * @param composedRanges - Array of StaticRange objects from getComposedRanges ++ * @returns A proxy Selection object that correctly handles Shadow DOM ranges, ++ * or the base selection if composedRanges is invalid ++ */ ++ ++function createSelectionWithComposedRanges(baseSelection, composedRanges) { ++ if (composedRanges.length === 0) { ++ return baseSelection; ++ } ++ const firstRange = composedRanges[0]; ++ const selectionLike = Object.create(Selection.prototype); ++ ++ // Copy all methods and properties from base selection ++ const descriptors = Object.getOwnPropertyDescriptors(Selection.prototype); ++ Object.keys(descriptors).forEach(prop => { ++ if (prop === 'constructor') { ++ return; ++ } ++ const descriptor = descriptors[prop]; ++ if (descriptor.value && typeof descriptor.value === 'function') { ++ // It's a method - bind it to base selection ++ const method = baseSelection[prop]; ++ if (typeof method === 'function') { ++ selectionLike[prop] = method.bind(baseSelection); ++ } ++ } else if (!descriptor.get) { ++ // It's a regular property, not a getter - copy the value from base selection ++ const value = baseSelection[prop]; ++ if (value !== undefined) { ++ selectionLike[prop] = value; ++ } ++ } ++ }); ++ ++ // Override specific properties with composed ranges data ++ Object.defineProperty(selectionLike, 'anchorNode', { ++ enumerable: true, ++ get: () => firstRange.startContainer ++ }); ++ Object.defineProperty(selectionLike, 'anchorOffset', { ++ enumerable: true, ++ get: () => firstRange.startOffset ++ }); ++ Object.defineProperty(selectionLike, 'focusNode', { ++ enumerable: true, ++ get: () => firstRange.endContainer ++ }); ++ Object.defineProperty(selectionLike, 'focusOffset', { ++ enumerable: true, ++ get: () => firstRange.endOffset ++ }); ++ Object.defineProperty(selectionLike, 'isCollapsed', { ++ enumerable: true, ++ get: () => firstRange.collapsed ++ }); ++ Object.defineProperty(selectionLike, 'rangeCount', { ++ enumerable: true, ++ get: () => composedRanges.length ++ }); ++ Object.defineProperty(selectionLike, 'type', { ++ enumerable: true, ++ get: () => { ++ const range = composedRanges[0]; ++ if (!range) { ++ return 'None'; ++ } ++ return range.collapsed ? 'Caret' : 'Range'; ++ } ++ }); ++ ++ // Override getRangeAt to return a proper Range object from StaticRange ++ selectionLike.getRangeAt = function (index) { ++ if (index < 0 || index >= composedRanges.length) { ++ throw new DOMException('Index out of range', 'IndexSizeError'); ++ } ++ const staticRange = composedRanges[index]; ++ const range = document.createRange(); ++ range.setStart(staticRange.startContainer, staticRange.startOffset); ++ range.setEnd(staticRange.endContainer, staticRange.endOffset); ++ return range; ++ }; ++ ++ // If the original selection has getComposedRanges, preserve it ++ if ('getComposedRanges' in baseSelection) { ++ selectionLike.getComposedRanges = function () { ++ return composedRanges; ++ }; ++ } ++ return selectionLike; ++} ++function getDOMSelectionForEditor(editor) { ++ return getDOMSelection(getWindow(editor), editor.getRootElement()); ++} ++ ++/** ++ * Traverses up the DOM tree to find a ShadowRoot if the element is inside a shadow DOM. ++ * This function helps determine whether the given element is rendered within Shadow DOM ++ * encapsulation. ++ * ++ * @param element - The HTMLElement to start traversing from ++ * @returns The ShadowRoot if found, or Document if the element is not in shadow DOM ++ */ ++function getShadowRootOrDocument(element) { ++ const shadowRoot = element.getRootNode({ ++ composed: false ++ }); ++ if (isShadowRoot(shadowRoot)) { ++ return shadowRoot; ++ } ++ return document; ++} ++ ++/** ++ * Checks if the Lexical editor is running within a Shadow DOM context. ++ * ++ * This function determines whether the editor's root element is contained within ++ * a ShadowRoot, which is essential for enabling Shadow DOM-specific functionality ++ * like specialized deletion commands and selection handling. ++ * ++ * @param editor - The Lexical editor instance to check ++ * @returns `true` if the editor is in Shadow DOM, `false` otherwise ++ */ ++function $isInShadowDOMContext(editor) { ++ const rootElement = editor.getRootElement(); ++ return rootElement ? isShadowRoot(getShadowRootOrDocument(rootElement)) : false; ++} ++ ++/** ++ * Gets the appropriate Document object for an element, accounting for shadow DOM. ++ * Returns the ownerDocument of the ShadowRoot if the element is in shadow DOM, ++ * otherwise returns the element's ownerDocument or the global document. ++ * ++ * @param element - The HTMLElement to get the document for ++ * @returns The Document object that should be used for DOM operations ++ */ ++function getDocumentFromElement(element) { ++ if (!element || !CAN_USE_DOM) { ++ return document; ++ } ++ const rootNode = element.getRootNode({ ++ composed: true ++ }); ++ ++ // If the element is not connected to a document, return the default document ++ if (rootNode === element || rootNode.nodeType !== Node.DOCUMENT_NODE) { ++ return element.ownerDocument || document; ++ } ++ return rootNode; ++} ++ ++/** ++ * Gets the currently active (focused) element, accounting for shadow DOM encapsulation. ++ * In shadow DOM, the activeElement is tracked separately within the ShadowRoot. ++ * Falls back to the document's activeElement if not in shadow DOM. ++ * ++ * @param rootElement - The root element to check for shadow DOM context ++ * @returns The currently active Element or null if no element is focused ++ */ ++function getActiveElement(rootElement) { ++ const shadowRoot = getShadowRootOrDocument(rootElement); ++ if (shadowRoot && isShadowRoot(shadowRoot) && shadowRoot.activeElement) { ++ return shadowRoot.activeElement; ++ } ++ return getDocumentFromElement(rootElement).activeElement; ++} ++ ++/** ++ * Returns the selection for the defaultView of the ownerDocument of given EventTarget, ++ * with full Shadow DOM support. ++ * ++ * This function determines the appropriate selection context based on whether the ++ * EventTarget is within a Shadow DOM or regular DOM: ++ * ++ * **Shadow DOM Elements:** ++ * Uses getDOMSelectionFromShadowRoot to get a selection that properly handles ++ * Shadow DOM boundaries using the getComposedRanges API when available. ++ * ++ * **Regular DOM Elements:** ++ * Returns the standard window.getSelection() from the element's defaultView. ++ * ++ * **Edge Cases:** ++ * - Returns null for null EventTarget ++ * - Returns null for EventTargets without a valid defaultView ++ * - Handles non-HTML EventTargets gracefully ++ * ++ * @param eventTarget - The EventTarget (typically a DOM node) to get the selection from ++ * @returns A Selection object from the appropriate context or null if unavailable + */ + function getDOMSelectionFromTarget(eventTarget) { ++ if (!eventTarget) { ++ return null; ++ } ++ ++ // Check if eventTarget is in shadow DOM ++ if (isHTMLElement(eventTarget)) { ++ const shadowRoot = getShadowRootOrDocument(eventTarget); ++ if (shadowRoot && isShadowRoot(shadowRoot)) { ++ return getDOMSelectionFromShadowRoot(shadowRoot); ++ } ++ } + const defaultView = getDefaultView(eventTarget); + return defaultView ? defaultView.getSelection() : null; + } +@@ -13979,4 +14454,4 @@ function shallowMergeConfig(config, overrides) { + return config; + } + +-export { $addUpdateTag, $applyNodeReplacement, $caretFromPoint, $caretRangeFromSelection, $cloneWithProperties, $cloneWithPropertiesEphemeral, $comparePointCaretNext, $copyNode, $create, $createLineBreakNode, $createNodeSelection, $createParagraphNode, $createPoint, $createRangeSelection, $createRangeSelectionFromDom, $createTabNode, $createTextNode, $extendCaretToRange, $findMatchingParent, $getAdjacentChildCaret, $getAdjacentNode, $getAdjacentSiblingOrParentSiblingCaret, $getCaretInDirection, $getCaretRange, $getCaretRangeInDirection, $getCharacterOffsets, $getChildCaret, $getChildCaretAtIndex, $getChildCaretOrSelf, $getCollapsedCaretRange, $getCommonAncestor, $getCommonAncestorResultBranchOrder, $getEditor, $getNearestNodeFromDOMNode, $getNearestRootOrShadowRoot, $getNodeByKey, $getNodeByKeyOrThrow, $getNodeFromDOMNode, $getPreviousSelection, $getRoot, $getSelection, $getSiblingCaret, $getState, $getStateChange, $getTextContent, $getTextNodeOffset, $getTextPointCaret, $getTextPointCaretSlice, $getWritableNodeState, $hasAncestor, $hasUpdateTag, $insertNodes, $isBlockElementNode, $isChildCaret, $isDecoratorNode, $isEditorState, $isElementNode, $isExtendableTextPointCaret, $isInlineElementOrDecoratorNode, $isLeafNode, $isLineBreakNode, $isNodeCaret, $isNodeSelection, $isParagraphNode, $isRangeSelection, $isRootNode, $isRootOrShadowRoot, $isSiblingCaret, $isTabNode, $isTextNode, $isTextPointCaret, $isTextPointCaretSlice, $isTokenOrSegmented, $isTokenOrTab, $nodesOfType, $normalizeCaret, $normalizeSelection as $normalizeSelection__EXPERIMENTAL, $onUpdate, $parseSerializedNode, $removeTextFromCaretRange, $rewindSiblingCaret, $selectAll, $setCompositionKey, $setPointFromCaret, $setSelection, $setSelectionFromCaretRange, $setState, $splitAtPointCaretNext, $splitNode, $updateRangeSelectionFromCaretRange, ArtificialNode__DO_NOT_USE, BLUR_COMMAND, CAN_REDO_COMMAND, CAN_UNDO_COMMAND, CLEAR_EDITOR_COMMAND, CLEAR_HISTORY_COMMAND, CLICK_COMMAND, COLLABORATION_TAG, COMMAND_PRIORITY_CRITICAL, COMMAND_PRIORITY_EDITOR, COMMAND_PRIORITY_HIGH, COMMAND_PRIORITY_LOW, COMMAND_PRIORITY_NORMAL, CONTROLLED_TEXT_INSERTION_COMMAND, COPY_COMMAND, CUT_COMMAND, DELETE_CHARACTER_COMMAND, DELETE_LINE_COMMAND, DELETE_WORD_COMMAND, DRAGEND_COMMAND, DRAGOVER_COMMAND, DRAGSTART_COMMAND, DROP_COMMAND, DecoratorNode, ElementNode, FOCUS_COMMAND, FORMAT_ELEMENT_COMMAND, FORMAT_TEXT_COMMAND, HISTORIC_TAG, HISTORY_MERGE_TAG, HISTORY_PUSH_TAG, INDENT_CONTENT_COMMAND, INSERT_LINE_BREAK_COMMAND, INSERT_PARAGRAPH_COMMAND, INSERT_TAB_COMMAND, INTERNAL_$isBlock, IS_ALL_FORMATTING, IS_BOLD, IS_CODE, IS_HIGHLIGHT, IS_ITALIC, IS_STRIKETHROUGH, IS_SUBSCRIPT, IS_SUPERSCRIPT, IS_UNDERLINE, KEY_ARROW_DOWN_COMMAND, KEY_ARROW_LEFT_COMMAND, KEY_ARROW_RIGHT_COMMAND, KEY_ARROW_UP_COMMAND, KEY_BACKSPACE_COMMAND, KEY_DELETE_COMMAND, KEY_DOWN_COMMAND, KEY_ENTER_COMMAND, KEY_ESCAPE_COMMAND, KEY_MODIFIER_COMMAND, KEY_SPACE_COMMAND, KEY_TAB_COMMAND, LineBreakNode, MOVE_TO_END, MOVE_TO_START, NODE_STATE_KEY, OUTDENT_CONTENT_COMMAND, PASTE_COMMAND, PASTE_TAG, ParagraphNode, REDO_COMMAND, REMOVE_TEXT_COMMAND, RootNode, SELECTION_CHANGE_COMMAND, SELECTION_INSERT_CLIPBOARD_NODES_COMMAND, SELECT_ALL_COMMAND, SKIP_COLLAB_TAG, SKIP_DOM_SELECTION_TAG, SKIP_SCROLL_INTO_VIEW_TAG, SKIP_SELECTION_FOCUS_TAG, TEXT_TYPE_TO_FORMAT, TabNode, TextNode, UNDO_COMMAND, buildImportMap, configExtension, createCommand, createEditor, createSharedNodeState, createState, declarePeerDependency, defineExtension, flipDirection, getDOMOwnerDocument, getDOMSelection, getDOMSelectionFromTarget, getDOMTextNode, getEditorPropertyFromDOMNode, getNearestEditorFromDOMNode, getRegisteredNode, getRegisteredNodeOrThrow, getStaticNodeConfig, getTextDirection, getTransformSetFromKlass, isBlockDomNode, isCurrentlyReadOnlyMode, isDOMDocumentNode, isDOMNode, isDOMTextNode, isDOMUnmanaged, isDocumentFragment, isExactShortcutMatch, isHTMLAnchorElement, isHTMLElement, isInlineDomNode, isLexicalEditor, isModifierMatch, isSelectionCapturedInDecoratorInput, isSelectionWithinEditor, makeStepwiseIterator, removeFromParent, resetRandomKey, safeCast, setDOMUnmanaged, setNodeIndentFromDOM, shallowMergeConfig }; ++export { $addUpdateTag, $applyNodeReplacement, $caretFromPoint, $caretRangeFromSelection, $cloneWithProperties, $cloneWithPropertiesEphemeral, $comparePointCaretNext, $copyNode, $create, $createLineBreakNode, $createNodeSelection, $createParagraphNode, $createPoint, $createRangeSelection, $createRangeSelectionFromDom, $createTabNode, $createTextNode, $extendCaretToRange, $findMatchingParent, $getAdjacentChildCaret, $getAdjacentNode, $getAdjacentSiblingOrParentSiblingCaret, $getCaretInDirection, $getCaretRange, $getCaretRangeInDirection, $getCharacterOffsets, $getChildCaret, $getChildCaretAtIndex, $getChildCaretOrSelf, $getCollapsedCaretRange, $getCommonAncestor, $getCommonAncestorResultBranchOrder, $getEditor, $getNearestNodeFromDOMNode, $getNearestRootOrShadowRoot, $getNodeByKey, $getNodeByKeyOrThrow, $getNodeFromDOMNode, $getPreviousSelection, $getRoot, $getSelection, $getSiblingCaret, $getState, $getStateChange, $getTextContent, $getTextNodeOffset, $getTextPointCaret, $getTextPointCaretSlice, $getWritableNodeState, $hasAncestor, $hasUpdateTag, $insertNodes, $isBlockElementNode, $isChildCaret, $isDecoratorNode, $isEditorState, $isElementNode, $isExtendableTextPointCaret, $isInShadowDOMContext, $isInlineElementOrDecoratorNode, $isLeafNode, $isLineBreakNode, $isNodeCaret, $isNodeSelection, $isParagraphNode, $isRangeSelection, $isRootNode, $isRootOrShadowRoot, $isSiblingCaret, $isTabNode, $isTextNode, $isTextPointCaret, $isTextPointCaretSlice, $isTokenOrSegmented, $isTokenOrTab, $nodesOfType, $normalizeCaret, $normalizeSelection as $normalizeSelection__EXPERIMENTAL, $onUpdate, $parseSerializedNode, $removeTextFromCaretRange, $rewindSiblingCaret, $selectAll, $setCompositionKey, $setPointFromCaret, $setSelection, $setSelectionFromCaretRange, $setState, $splitAtPointCaretNext, $splitNode, $updateRangeSelectionFromCaretRange, ArtificialNode__DO_NOT_USE, BEFORE_INPUT_COMMAND, BLUR_COMMAND, CAN_REDO_COMMAND, CAN_UNDO_COMMAND, CLEAR_EDITOR_COMMAND, CLEAR_HISTORY_COMMAND, CLICK_COMMAND, COLLABORATION_TAG, COMMAND_PRIORITY_CRITICAL, COMMAND_PRIORITY_EDITOR, COMMAND_PRIORITY_HIGH, COMMAND_PRIORITY_LOW, COMMAND_PRIORITY_NORMAL, COMPOSITION_END_COMMAND, COMPOSITION_START_COMMAND, CONTROLLED_TEXT_INSERTION_COMMAND, COPY_COMMAND, CUT_COMMAND, DELETE_CHARACTER_COMMAND, DELETE_LINE_COMMAND, DELETE_WORD_COMMAND, DRAGEND_COMMAND, DRAGOVER_COMMAND, DRAGSTART_COMMAND, DROP_COMMAND, DecoratorNode, ElementNode, FOCUS_COMMAND, FORMAT_ELEMENT_COMMAND, FORMAT_TEXT_COMMAND, HISTORIC_TAG, HISTORY_MERGE_TAG, HISTORY_PUSH_TAG, INDENT_CONTENT_COMMAND, INPUT_COMMAND, INSERT_LINE_BREAK_COMMAND, INSERT_PARAGRAPH_COMMAND, INSERT_TAB_COMMAND, INTERNAL_$isBlock, IS_ALL_FORMATTING, IS_BOLD, IS_CODE, IS_HIGHLIGHT, IS_ITALIC, IS_STRIKETHROUGH, IS_SUBSCRIPT, IS_SUPERSCRIPT, IS_UNDERLINE, KEY_ARROW_DOWN_COMMAND, KEY_ARROW_LEFT_COMMAND, KEY_ARROW_RIGHT_COMMAND, KEY_ARROW_UP_COMMAND, KEY_BACKSPACE_COMMAND, KEY_DELETE_COMMAND, KEY_DOWN_COMMAND, KEY_ENTER_COMMAND, KEY_ESCAPE_COMMAND, KEY_MODIFIER_COMMAND, KEY_SPACE_COMMAND, KEY_TAB_COMMAND, LineBreakNode, MOVE_TO_END, MOVE_TO_START, NODE_STATE_KEY, OUTDENT_CONTENT_COMMAND, PASTE_COMMAND, PASTE_TAG, ParagraphNode, REDO_COMMAND, REMOVE_TEXT_COMMAND, RootNode, SELECTION_CHANGE_COMMAND, SELECTION_INSERT_CLIPBOARD_NODES_COMMAND, SELECT_ALL_COMMAND, SKIP_COLLAB_TAG, SKIP_DOM_SELECTION_TAG, SKIP_SCROLL_INTO_VIEW_TAG, SKIP_SELECTION_FOCUS_TAG, TEXT_TYPE_TO_FORMAT, TabNode, TextNode, UNDO_COMMAND, buildImportMap, configExtension, createCommand, createEditor, createSharedNodeState, createState, declarePeerDependency, defineExtension, flipDirection, getDOMOwnerDocument, getDOMSelection, getDOMSelectionForEditor, getDOMSelectionFromShadowRoot, getDOMSelectionFromTarget, getDOMTextNode, getDocumentFromElement, getEditorPropertyFromDOMNode, getNearestEditorFromDOMNode, getRegisteredNode, getRegisteredNodeOrThrow, getShadowRootOrDocument, getStaticNodeConfig, getTextDirection, getTransformSetFromKlass, getWindow, isBlockDomNode, isCurrentlyReadOnlyMode, isDOMDocumentNode, isDOMNode, isDOMTextNode, isDOMUnmanaged, isDocumentFragment, isExactShortcutMatch, isHTMLAnchorElement, isHTMLElement, isInlineDomNode, isLexicalEditor, isModifierMatch, isSelectionCapturedInDecoratorInput, isSelectionWithinEditor, isShadowRoot, makeStepwiseIterator, removeFromParent, resetRandomKey, safeCast, setDOMUnmanaged, setNodeIndentFromDOM, shallowMergeConfig }; +diff --git a/node_modules/lexical/Lexical.js.flow b/node_modules/lexical/Lexical.js.flow +index f560067..6a5c126 100644 +--- a/node_modules/lexical/Lexical.js.flow ++++ b/node_modules/lexical/Lexical.js.flow +@@ -1633,13 +1633,13 @@ export type LexicalExtensionArgument< + > = + | LexicalExtension + | NormalizedLexicalExtensionArgument; +-export type LexicalExtensionConfig = ++export type LexicalExtensionConfig<+Extension: AnyLexicalExtension> = + $NonMaybeType; + export interface LexicalExtensionDependency< + +Dependency: AnyLexicalExtension, + > { +- config: LexicalExtensionConfig; +- output: LexicalExtensionOutput; ++ +config: LexicalExtensionConfig; ++ +output: LexicalExtensionOutput; + } + export type LexicalExtensionInit = + $NonMaybeType; +@@ -1656,7 +1656,7 @@ interface LexicalExtensionInternalOutput { + export type LexicalExtensionName = + Extension['name']; + +-export type LexicalExtensionOutput = ++export type LexicalExtensionOutput<+Extension: AnyLexicalExtension> = + $NonMaybeType; + declare export const peerDependencySymbol: symbol; + export type NormalizedLexicalExtensionArgument< +diff --git a/node_modules/lexical/Lexical.mjs b/node_modules/lexical/Lexical.mjs +index f6e9204..e7419f9 100644 +--- a/node_modules/lexical/Lexical.mjs ++++ b/node_modules/lexical/Lexical.mjs +@@ -67,6 +67,7 @@ export const $isDecoratorNode = mod.$isDecoratorNode; + export const $isEditorState = mod.$isEditorState; + export const $isElementNode = mod.$isElementNode; + export const $isExtendableTextPointCaret = mod.$isExtendableTextPointCaret; ++export const $isInShadowDOMContext = mod.$isInShadowDOMContext; + export const $isInlineElementOrDecoratorNode = mod.$isInlineElementOrDecoratorNode; + export const $isLeafNode = mod.$isLeafNode; + export const $isLineBreakNode = mod.$isLineBreakNode; +@@ -100,6 +101,7 @@ export const $splitAtPointCaretNext = mod.$splitAtPointCaretNext; + export const $splitNode = mod.$splitNode; + export const $updateRangeSelectionFromCaretRange = mod.$updateRangeSelectionFromCaretRange; + export const ArtificialNode__DO_NOT_USE = mod.ArtificialNode__DO_NOT_USE; ++export const BEFORE_INPUT_COMMAND = mod.BEFORE_INPUT_COMMAND; + export const BLUR_COMMAND = mod.BLUR_COMMAND; + export const CAN_REDO_COMMAND = mod.CAN_REDO_COMMAND; + export const CAN_UNDO_COMMAND = mod.CAN_UNDO_COMMAND; +@@ -112,6 +114,8 @@ export const COMMAND_PRIORITY_EDITOR = mod.COMMAND_PRIORITY_EDITOR; + export const COMMAND_PRIORITY_HIGH = mod.COMMAND_PRIORITY_HIGH; + export const COMMAND_PRIORITY_LOW = mod.COMMAND_PRIORITY_LOW; + export const COMMAND_PRIORITY_NORMAL = mod.COMMAND_PRIORITY_NORMAL; ++export const COMPOSITION_END_COMMAND = mod.COMPOSITION_END_COMMAND; ++export const COMPOSITION_START_COMMAND = mod.COMPOSITION_START_COMMAND; + export const CONTROLLED_TEXT_INSERTION_COMMAND = mod.CONTROLLED_TEXT_INSERTION_COMMAND; + export const COPY_COMMAND = mod.COPY_COMMAND; + export const CUT_COMMAND = mod.CUT_COMMAND; +@@ -131,6 +135,7 @@ export const HISTORIC_TAG = mod.HISTORIC_TAG; + export const HISTORY_MERGE_TAG = mod.HISTORY_MERGE_TAG; + export const HISTORY_PUSH_TAG = mod.HISTORY_PUSH_TAG; + export const INDENT_CONTENT_COMMAND = mod.INDENT_CONTENT_COMMAND; ++export const INPUT_COMMAND = mod.INPUT_COMMAND; + export const INSERT_LINE_BREAK_COMMAND = mod.INSERT_LINE_BREAK_COMMAND; + export const INSERT_PARAGRAPH_COMMAND = mod.INSERT_PARAGRAPH_COMMAND; + export const INSERT_TAB_COMMAND = mod.INSERT_TAB_COMMAND; +@@ -189,15 +194,20 @@ export const defineExtension = mod.defineExtension; + export const flipDirection = mod.flipDirection; + export const getDOMOwnerDocument = mod.getDOMOwnerDocument; + export const getDOMSelection = mod.getDOMSelection; ++export const getDOMSelectionForEditor = mod.getDOMSelectionForEditor; ++export const getDOMSelectionFromShadowRoot = mod.getDOMSelectionFromShadowRoot; + export const getDOMSelectionFromTarget = mod.getDOMSelectionFromTarget; + export const getDOMTextNode = mod.getDOMTextNode; ++export const getDocumentFromElement = mod.getDocumentFromElement; + export const getEditorPropertyFromDOMNode = mod.getEditorPropertyFromDOMNode; + export const getNearestEditorFromDOMNode = mod.getNearestEditorFromDOMNode; + export const getRegisteredNode = mod.getRegisteredNode; + export const getRegisteredNodeOrThrow = mod.getRegisteredNodeOrThrow; ++export const getShadowRootOrDocument = mod.getShadowRootOrDocument; + export const getStaticNodeConfig = mod.getStaticNodeConfig; + export const getTextDirection = mod.getTextDirection; + export const getTransformSetFromKlass = mod.getTransformSetFromKlass; ++export const getWindow = mod.getWindow; + export const isBlockDomNode = mod.isBlockDomNode; + export const isCurrentlyReadOnlyMode = mod.isCurrentlyReadOnlyMode; + export const isDOMDocumentNode = mod.isDOMDocumentNode; +@@ -213,6 +223,7 @@ export const isLexicalEditor = mod.isLexicalEditor; + export const isModifierMatch = mod.isModifierMatch; + export const isSelectionCapturedInDecoratorInput = mod.isSelectionCapturedInDecoratorInput; + export const isSelectionWithinEditor = mod.isSelectionWithinEditor; ++export const isShadowRoot = mod.isShadowRoot; + export const makeStepwiseIterator = mod.makeStepwiseIterator; + export const removeFromParent = mod.removeFromParent; + export const resetRandomKey = mod.resetRandomKey; +diff --git a/node_modules/lexical/Lexical.node.mjs b/node_modules/lexical/Lexical.node.mjs +index d17db8c..40f880a 100644 +--- a/node_modules/lexical/Lexical.node.mjs ++++ b/node_modules/lexical/Lexical.node.mjs +@@ -65,6 +65,7 @@ export const $isDecoratorNode = mod.$isDecoratorNode; + export const $isEditorState = mod.$isEditorState; + export const $isElementNode = mod.$isElementNode; + export const $isExtendableTextPointCaret = mod.$isExtendableTextPointCaret; ++export const $isInShadowDOMContext = mod.$isInShadowDOMContext; + export const $isInlineElementOrDecoratorNode = mod.$isInlineElementOrDecoratorNode; + export const $isLeafNode = mod.$isLeafNode; + export const $isLineBreakNode = mod.$isLineBreakNode; +@@ -98,6 +99,7 @@ export const $splitAtPointCaretNext = mod.$splitAtPointCaretNext; + export const $splitNode = mod.$splitNode; + export const $updateRangeSelectionFromCaretRange = mod.$updateRangeSelectionFromCaretRange; + export const ArtificialNode__DO_NOT_USE = mod.ArtificialNode__DO_NOT_USE; ++export const BEFORE_INPUT_COMMAND = mod.BEFORE_INPUT_COMMAND; + export const BLUR_COMMAND = mod.BLUR_COMMAND; + export const CAN_REDO_COMMAND = mod.CAN_REDO_COMMAND; + export const CAN_UNDO_COMMAND = mod.CAN_UNDO_COMMAND; +@@ -110,6 +112,8 @@ export const COMMAND_PRIORITY_EDITOR = mod.COMMAND_PRIORITY_EDITOR; + export const COMMAND_PRIORITY_HIGH = mod.COMMAND_PRIORITY_HIGH; + export const COMMAND_PRIORITY_LOW = mod.COMMAND_PRIORITY_LOW; + export const COMMAND_PRIORITY_NORMAL = mod.COMMAND_PRIORITY_NORMAL; ++export const COMPOSITION_END_COMMAND = mod.COMPOSITION_END_COMMAND; ++export const COMPOSITION_START_COMMAND = mod.COMPOSITION_START_COMMAND; + export const CONTROLLED_TEXT_INSERTION_COMMAND = mod.CONTROLLED_TEXT_INSERTION_COMMAND; + export const COPY_COMMAND = mod.COPY_COMMAND; + export const CUT_COMMAND = mod.CUT_COMMAND; +@@ -129,6 +133,7 @@ export const HISTORIC_TAG = mod.HISTORIC_TAG; + export const HISTORY_MERGE_TAG = mod.HISTORY_MERGE_TAG; + export const HISTORY_PUSH_TAG = mod.HISTORY_PUSH_TAG; + export const INDENT_CONTENT_COMMAND = mod.INDENT_CONTENT_COMMAND; ++export const INPUT_COMMAND = mod.INPUT_COMMAND; + export const INSERT_LINE_BREAK_COMMAND = mod.INSERT_LINE_BREAK_COMMAND; + export const INSERT_PARAGRAPH_COMMAND = mod.INSERT_PARAGRAPH_COMMAND; + export const INSERT_TAB_COMMAND = mod.INSERT_TAB_COMMAND; +@@ -187,15 +192,20 @@ export const defineExtension = mod.defineExtension; + export const flipDirection = mod.flipDirection; + export const getDOMOwnerDocument = mod.getDOMOwnerDocument; + export const getDOMSelection = mod.getDOMSelection; ++export const getDOMSelectionForEditor = mod.getDOMSelectionForEditor; ++export const getDOMSelectionFromShadowRoot = mod.getDOMSelectionFromShadowRoot; + export const getDOMSelectionFromTarget = mod.getDOMSelectionFromTarget; + export const getDOMTextNode = mod.getDOMTextNode; ++export const getDocumentFromElement = mod.getDocumentFromElement; + export const getEditorPropertyFromDOMNode = mod.getEditorPropertyFromDOMNode; + export const getNearestEditorFromDOMNode = mod.getNearestEditorFromDOMNode; + export const getRegisteredNode = mod.getRegisteredNode; + export const getRegisteredNodeOrThrow = mod.getRegisteredNodeOrThrow; ++export const getShadowRootOrDocument = mod.getShadowRootOrDocument; + export const getStaticNodeConfig = mod.getStaticNodeConfig; + export const getTextDirection = mod.getTextDirection; + export const getTransformSetFromKlass = mod.getTransformSetFromKlass; ++export const getWindow = mod.getWindow; + export const isBlockDomNode = mod.isBlockDomNode; + export const isCurrentlyReadOnlyMode = mod.isCurrentlyReadOnlyMode; + export const isDOMDocumentNode = mod.isDOMDocumentNode; +@@ -211,6 +221,7 @@ export const isLexicalEditor = mod.isLexicalEditor; + export const isModifierMatch = mod.isModifierMatch; + export const isSelectionCapturedInDecoratorInput = mod.isSelectionCapturedInDecoratorInput; + export const isSelectionWithinEditor = mod.isSelectionWithinEditor; ++export const isShadowRoot = mod.isShadowRoot; + export const makeStepwiseIterator = mod.makeStepwiseIterator; + export const removeFromParent = mod.removeFromParent; + export const resetRandomKey = mod.resetRandomKey; +diff --git a/node_modules/lexical/Lexical.prod.js b/node_modules/lexical/Lexical.prod.js +index 7241718..d49bf3c 100644 +--- a/node_modules/lexical/Lexical.prod.js ++++ b/node_modules/lexical/Lexical.prod.js +@@ -6,4 +6,4 @@ + * + */ + +-"use strict";function t(t,...e){const n=new URL("https://lexical.dev/docs/error"),r=new URLSearchParams;r.append("code",t);for(const t of e)r.append("v",t);throw n.search=r.toString(),Error(`Minified Lexical error #${t}; visit ${n.toString()} for the full message or use the non-minified dev environment for full errors and additional helpful warnings.`)}function e(t,...e){const n=new URL("https://lexical.dev/docs/error"),r=new URLSearchParams;r.append("code",t);for(const t of e)r.append("v",t);n.search=r.toString(),console.warn(`Minified Lexical warning #${t}; visit ${n.toString()} for the full message or use the non-minified dev environment for full errors and additional helpful warnings.`)}const n="undefined"!=typeof window&&void 0!==window.document&&void 0!==window.document.createElement,r=n&&"documentMode"in document?document.documentMode:null,o=n&&/Mac|iPod|iPhone|iPad/.test(navigator.platform),i=n&&/^(?!.*Seamonkey)(?=.*Firefox).*/i.test(navigator.userAgent),s=!(!n||!("InputEvent"in window)||r)&&"getTargetRanges"in new window.InputEvent("input"),l=n&&/Version\/[\d.]+.*Safari/.test(navigator.userAgent),c=n&&/iPad|iPhone|iPod/.test(navigator.userAgent)&&!window.MSStream,a=n&&/Android/.test(navigator.userAgent),u=n&&/^(?=.*Chrome).*/i.test(navigator.userAgent),f=n&&a&&u,d=n&&/AppleWebKit\/[\d.]+/.test(navigator.userAgent)&&o&&!u;function h(...t){const e=[];for(const n of t)if(n&&"string"==typeof n)for(const[t]of n.matchAll(/\S+/g))e.push(t);return e}const g=0,_=1,p=2,y=128,m=1,x=2,C=3,S=4,N=5,T=6,v=l||c||d?" ":"​",k="\n\n",E=i?" ":v,b="֑-߿יִ-﷽ﹰ-ﻼ",O="A-Za-zÀ-ÖØ-öø-ʸ̀-֐ࠀ-῿‎Ⰰ-﬜︀-﹯﻽-￿",M=new RegExp("^[^"+O+"]*["+b+"]"),A=new RegExp("^[^"+b+"]*["+O+"]"),w={bold:1,capitalize:1024,code:16,highlight:y,italic:2,lowercase:256,strikethrough:4,subscript:32,superscript:64,underline:8,uppercase:512},D={directionless:1,unmergeable:2},P={center:2,end:6,justify:4,left:1,right:3,start:5},I={[x]:"center",[T]:"end",[S]:"justify",[m]:"left",[C]:"right",[N]:"start"},L={normal:0,segmented:2,token:1},F={[g]:"normal",[p]:"segmented",[_]:"token"},R="$config";function K(t,e,n,r,o,i){let s=t.getFirstChild();for(;null!==s;){const t=s.__key;s.__parent===e&&(Zr(s)&&K(s,t,n,r,o,i),n.has(t)||i.delete(t),o.push(t)),s=s.getNextSibling()}}let B=!1,z=0;function W(t){z=t.timeStamp}function $(t,e,n){const r="BR"===t.nodeName,o=e.__lexicalLineBreak;return o&&(t===o||r&&t.previousSibling===o)||r&&void 0!==Uo(t,n)}function U(t,e,n){const r=Ii(ki(n));let o=null,i=null;null!==r&&r.anchorNode===t&&(o=r.anchorOffset,i=r.focusOffset);const s=t.nodeValue;null!==s&&ni(e,s,o,i,!1)}function J(t,e,n){if(tr(t)){const e=t.anchor.getNode();if(e.is(n)&&t.format!==e.getFormat())return!1}return Do(e)&&n.isAttached()}function Y(t,e,n,r){for(let o=t;o&&!Vi(o);o=xi(o)){const t=Uo(o,e);if(void 0!==t){const e=Wo(t,n);if(e)return no(e)||!Fi(o)?void 0:[o,e]}else if(o===r)return[r,Vo(n)]}}function j(t,e,n){B=!0;const r=performance.now()-z>100;try{Gr(t,()=>{const o=pr()||function(t){return t.getEditorState().read(()=>{const t=pr();return null!==t?t.clone():null})}(t),s=new Map,l=t.getRootElement(),c=t._editorState,a=t._blockCursorElement;let u=!1,f="";for(let n=0;n0){let e=0;for(let o=0;o0)for(const[e,n]of s)n.reconcileObservedMutation(e,t);const d=n.takeRecords();if(d.length>0){for(let e=0;e{j(t,e,n)})}class G{key;parse;unparse;isEqual;defaultValue;constructor(t,e){this.key=t,this.parse=e.parse.bind(e),this.unparse=(e.unparse||nt).bind(e),this.isEqual=(e.isEqual||Object.is).bind(e),this.defaultValue=this.parse(void 0)}}function q(t,e,n="latest"){const r=("latest"===n?t.getLatest():t).__state;return r?r.getValue(e):e.defaultValue}function X(t){const e=new Map,n=new Set;for(let r="function"==typeof t?t:t.replace;r.prototype&&void 0!==r.prototype.getType;r=Object.getPrototypeOf(r)){const{ownNodeConfig:t}=qi(r);if(t&&t.stateConfigs)for(const r of t.stateConfigs){let t;"stateConfig"in r?(t=r.stateConfig,r.flat&&n.add(t.key)):t=r,e.set(t.key,t)}}return{flatKeys:n,sharedConfigMap:e}}class Q{node;knownState;unknownState;sharedNodeState;size;constructor(t,e,n=void 0,r=new Map,o=void 0){this.node=t,this.sharedNodeState=e,this.unknownState=n,this.knownState=r;const{sharedConfigMap:i}=this.sharedNodeState,s=void 0!==o?o:function(t,e,n){let r=n.size;if(e)for(const o in e){const e=t.get(o);e&&n.has(e)||r++}return r}(i,n,r);this.size=s}getValue(t){const e=this.knownState.get(t);if(void 0!==e)return e;this.sharedNodeState.sharedConfigMap.set(t.key,t);let n=t.defaultValue;if(this.unknownState&&t.key in this.unknownState){const e=this.unknownState[t.key];void 0!==e&&(n=t.parse(e)),this.updateFromKnown(t,n)}return n}getInternalState(){return[this.unknownState,this.knownState]}toJSON(){const t={...this.unknownState},e={};for(const[e,n]of this.knownState)e.isEqual(n,e.defaultValue)?delete t[e.key]:t[e.key]=e.unparse(n);for(const n of this.sharedNodeState.flatKeys)n in t&&(e[n]=t[n],delete t[n]);return et(t)&&(e.$=t),e}getWritable(t){if(this.node===t)return this;const{sharedNodeState:e,unknownState:n}=this,r=new Map(this.knownState);return new Q(t,e,function(t,e,n){let r;if(n)for(const[o,i]of Object.entries(n)){const n=t.get(o);n?e.has(n)||e.set(n,n.parse(i)):(r=r||{},r[o]=i)}return r}(e.sharedConfigMap,r,n),r,this.size)}updateFromKnown(t,e){const n=t.key;this.sharedNodeState.sharedConfigMap.set(n,t);const{knownState:r,unknownState:o}=this;r.has(t)||o&&n in o||(o&&(delete o[n],this.unknownState=et(o)),this.size++),r.set(t,e)}updateFromUnknown(t,e){const n=this.sharedNodeState.sharedConfigMap.get(t);n?this.updateFromKnown(n,n.parse(e)):(this.unknownState=this.unknownState||{},t in this.unknownState||this.size++,this.unknownState[t]=e)}updateFromJSON(t){const{knownState:e}=this;for(const t of e.keys())e.set(t,t.defaultValue);if(this.size=e.size,this.unknownState=void 0,t)for(const[e,n]of Object.entries(t))this.updateFromUnknown(e,n)}}function Z(t){const e=t.getWritable(),n=e.__state?e.__state.getWritable(e):new Q(e,tt(e));return e.__state=n,n}function tt(t){return t.__state?t.__state.sharedNodeState:So($i(),t.getType()).sharedNodeState}function et(t){if(t)for(const e in t)return t}function nt(t){return t}function rt(t,e,n){for(const[r,o]of e.knownState){if(t.has(r.key))continue;t.add(r.key);const e=n?n.getValue(r):r.defaultValue;if(e!==o&&!r.isEqual(e,o))return!0}return!1}function ot(t,e,n){const{unknownState:r}=e,o=n?n.unknownState:void 0;if(r)for(const[e,n]of Object.entries(r)){if(t.has(e))continue;t.add(e);if(n!==(o?o[e]:void 0))return!0}return!1}function it(t,e){const n=t.__state;return n&&n.node===t?n.getWritable(e):n}function st(t,e){const n=t.__mode,r=t.__format,o=t.__style,i=e.__mode,s=e.__format,l=e.__style,c=t.__state,a=e.__state;return(null===n||n===i)&&(null===r||r===s)&&(null===o||o===l)&&(null===t.__state||c===a||function(t,e){if(t===e)return!0;if(t&&e&&t.size!==e.size)return!1;const n=new Set;return!(t&&rt(n,t,e)||e&&rt(n,e,t)||t&&ot(n,t,e)||e&&ot(n,e,t))}(c,a))}function lt(t,e){const n=t.mergeWithSibling(e),r=Rr()._normalizedNodes;return r.add(t.__key),r.add(e.__key),n}function ct(t){let e,n,r=t;if(""!==r.__text||!r.isSimpleText()||r.isUnmergeable()){for(;null!==(e=r.getPreviousSibling())&&Jn(e)&&e.isSimpleText()&&!e.isUnmergeable();){if(""!==e.__text){if(st(e,r)){r=lt(e,r);break}break}e.remove()}for(;null!==(n=r.getNextSibling())&&Jn(n)&&n.isSimpleText()&&!n.isUnmergeable();){if(""!==n.__text){if(st(r,n)){r=lt(r,n);break}break}n.remove()}}else r.remove()}function at(t){return ut(t.anchor),ut(t.focus),t}function ut(t){for(;"element"===t.type;){const e=t.getNode(),n=t.offset;let r,o;if(n===e.getChildrenSize()?(r=e.getChildAtIndex(n-1),o=!0):(r=e.getChildAtIndex(n),o=!1),Jn(r)){t.set(r.__key,o?r.getTextContentSize():0,"text",!0);break}if(!Zr(r))break;t.set(r.__key,o?r.getChildrenSize():0,"element",!0)}}let ft,dt,ht,gt,_t,pt,yt,mt,xt,Ct,St="",Nt=null,Tt="",vt="",kt=!1,Et=!1;function bt(t,e){const n=yt.get(t);if(null!==e){const n=Jt(t);n.parentNode===e&&e.removeChild(n)}if(mt.has(t)||dt._keyToDOMMap.delete(t),Zr(n)){const t=Bt(n,yt);Ot(t,0,t.length-1,null)}void 0!==n&&di(Ct,ht,gt,n,"destroyed")}function Ot(t,e,n,r){let o=e;for(;o<=n;++o){const e=t[o];void 0!==e&&bt(e,r)}}function Mt(t,e){t.setProperty("text-align",e)}const At="40px";function wt(t,e){const n=ft.theme.indent;if("string"==typeof n){const r=t.classList.contains(n);e>0&&!r?t.classList.add(n):e<1&&r&&t.classList.remove(n)}const r=getComputedStyle(t).getPropertyValue("--lexical-indent-base-value")||At;t.style.setProperty("padding-inline-start",0===e?"":`calc(${e} * ${r})`)}function Dt(t,e){const n=t.style;0===e?Mt(n,""):1===e?Mt(n,"left"):2===e?Mt(n,"center"):3===e?Mt(n,"right"):4===e?Mt(n,"justify"):5===e?Mt(n,"start"):6===e&&Mt(n,"end")}function Pt(t,e){const n=function(t){const e=t.__dir;if(null!==e)return e;if(oo(t))return null;const n=t.getParentOrThrow();return oo(n)&&null===n.__dir?"auto":null}(e);null!==n?t.dir=n:t.removeAttribute("dir")}function It(e,n){const r=mt.get(e);void 0===r&&t(60);const o=r.createDOM(ft,dt);if(function(t,e,n){const r=n._keyToDOMMap;(function(t,e,n){const r=`__lexicalKey_${e._key}`;t[r]=n})(e,n,t),r.set(t,e)}(e,o,dt),Jn(r)?o.setAttribute("data-lexical-text","true"):no(r)&&o.setAttribute("data-lexical-decorator","true"),Zr(r)){const t=r.__indent,e=r.__size;if(Pt(o,r),0!==t&&wt(o,t),0!==e){const t=e-1;Lt(Bt(r,mt),r,0,t,r.getDOMSlot(o))}const n=r.__format;0!==n&&Dt(o,n),r.isInline()||Rt(null,r,o),yi(r)&&(St+=k,vt+=k)}else{const t=r.getTextContent();if(no(r)){const t=r.decorate(dt,ft);null!==t&&Wt(e,t),o.contentEditable="false"}St+=t,vt+=t}return null!==n&&n.insertChild(o),di(Ct,ht,gt,r,"created"),o}function Lt(t,e,n,r,o){const i=St;St="";let s=n;for(;s<=r;++s){It(t[s],o);const e=mt.get(t[s]);null!==e&&Jn(e)&&(null===Nt&&(Nt=e.getFormat()),""===Tt&&(Tt=e.getStyle()))}yi(e)&&(St+=k);o.element.__lexicalTextContent=St,St=i+St}function Ft(t,e){if(t){const n=t.__last;if(n){const t=e.get(n);if(t)return En(t)?"line-break":no(t)&&t.isInline()?"decorator":null}return"empty"}return null}function Rt(t,e,n){const r=Ft(t,yt),o=Ft(e,mt);r!==o&&e.getDOMSlot(n).setManagedLineBreak(o)}function Kt(e,n,r){var o;Nt=null,Tt="",function(e,n,r){const o=St,i=e.__size,s=n.__size;St="";const l=r.element;if(1===i&&1===s){const t=e.__first,r=n.__first;if(t===r)zt(t,l);else{const e=Jt(t),n=It(r,null);try{l.replaceChild(n,e)}catch(o){if("object"==typeof o&&null!=o){const i=`${o.toString()} Parent: ${l.tagName}, new child: {tag: ${n.tagName} key: ${r}}, old child: {tag: ${e.tagName}, key: ${t}}.`;throw new Error(i)}throw o}bt(t,null)}const o=mt.get(r);Jn(o)&&(null===Nt&&(Nt=o.getFormat()),""===Tt&&(Tt=o.getStyle()))}else{const o=Bt(e,yt),c=Bt(n,mt);if(o.length!==i&&t(227),c.length!==s&&t(228),0===i)0!==s&&Lt(c,n,0,s-1,r);else if(0===s){if(0!==i){const t=null==r.after&&null==r.before&&null==r.element.__lexicalLineBreak;Ot(o,0,i-1,t?null:l),t&&(l.textContent="")}}else!function(t,e,n,r,o,i){const s=r-1,l=o-1;let c,a,u=i.getFirstChild(),f=0,d=0;for(;f<=s&&d<=l;){const t=e[f],r=n[d];if(t===r)u=$t(zt(r,i.element)),f++,d++;else{void 0===c&&(c=new Set(e)),void 0===a&&(a=new Set(n));const o=a.has(t),s=c.has(r);if(o)if(s){const t=mi(dt,r);t===u?u=$t(zt(r,i.element)):(i.withBefore(u).insertChild(t),zt(r,i.element)),f++,d++}else It(r,i.withBefore(u)),d++;else u=$t(Jt(t)),bt(t,i.element),f++}const o=mt.get(r);null!==o&&Jn(o)&&(null===Nt&&(Nt=o.getFormat()),""===Tt&&(Tt=o.getStyle()))}const h=f>s,g=d>l;if(h&&!g){const e=n[l+1],r=void 0===e?null:dt.getElementByKey(e);Lt(n,t,d,l,i.withBefore(r))}else g&&!h&&Ot(e,f,s,i.element)}(n,o,c,i,s,r)}yi(n)&&(St+=k);l.__lexicalTextContent=St,St=o+St}(e,n,n.getDOMSlot(r)),o=n,null==Nt||Nt===o.__textFormat||Et||o.setTextFormat(Nt),function(t){""===Tt||Tt===t.__textStyle||Et||t.setTextStyle(Tt)}(n)}function Bt(e,n){const r=[];let o=e.__first;for(;null!==o;){const e=n.get(o);void 0===e&&t(101),r.push(o),o=e.__next}return r}function zt(e,n){const r=yt.get(e);let o=mt.get(e);void 0!==r&&void 0!==o||t(61);const i=kt||pt.has(e)||_t.has(e),s=mi(dt,e);if(r===o&&!i){if(Zr(r)){const t=s.__lexicalTextContent;void 0!==t&&(St+=t,vt+=t)}else{const t=r.getTextContent();vt+=t,St+=t}return s}if(r!==o&&i&&di(Ct,ht,gt,o,"updated"),o.updateDOM(r,s,ft)){const r=It(e,null);return null===n&&t(62),n.replaceChild(r,s),bt(e,null),r}if(Zr(r)&&Zr(o)){const t=o.__indent;(kt||t!==r.__indent)&&wt(s,t);const e=o.__format;if((kt||e!==r.__format)&&Dt(s,e),i&&(Kt(r,o,s),oo(o)||o.isInline()||Rt(r,o,s)),yi(o)&&(St+=k,vt+=k),(kt||o.__dir!==r.__dir)&&(Pt(s,o),oo(o)&&!kt))for(const t of o.getChildren())if(Zr(t)){Pt(mi(dt,t.getKey()),t)}}else{const t=o.getTextContent();if(no(o)){const t=o.decorate(dt,ft);null!==t&&Wt(e,t)}St+=t,vt+=t}if(!Et&&oo(o)&&o.__cachedText!==vt){const t=o.getWritable();t.__cachedText=vt,o=t}return s}function Wt(t,e){let n=dt._pendingDecorators;const r=dt._decorators;if(null===n){if(r[t]===e)return;n=Yo(dt)}n[t]=e}function $t(t){let e=t.nextSibling;return null!==e&&e===dt._blockCursorElement&&(e=e.nextSibling),e}function Ut(t,e,n,r,o,i){St="",vt="",kt=2===r,dt=n,ft=n._config,ht=n._nodes,gt=dt._listeners.mutation,_t=o,pt=i,yt=t._nodeMap,mt=e._nodeMap,Et=e._readOnly,xt=new Map(n._keyToDOMMap);const s=new Map;return Ct=s,zt("root",null),dt=void 0,ht=void 0,_t=void 0,pt=void 0,yt=void 0,mt=void 0,ft=void 0,xt=void 0,Ct=void 0,s}function Jt(e){const n=xt.get(e);return void 0===n&&t(75,e),n}function Yt(t){return{type:t}}const jt=Yt("SELECTION_CHANGE_COMMAND"),Ht=Yt("SELECTION_INSERT_CLIPBOARD_NODES_COMMAND"),Vt=Yt("CLICK_COMMAND"),Gt=Yt("DELETE_CHARACTER_COMMAND"),qt=Yt("INSERT_LINE_BREAK_COMMAND"),Xt=Yt("INSERT_PARAGRAPH_COMMAND"),Qt=Yt("CONTROLLED_TEXT_INSERTION_COMMAND"),Zt=Yt("PASTE_COMMAND"),te=Yt("REMOVE_TEXT_COMMAND"),ee=Yt("DELETE_WORD_COMMAND"),ne=Yt("DELETE_LINE_COMMAND"),re=Yt("FORMAT_TEXT_COMMAND"),oe=Yt("UNDO_COMMAND"),ie=Yt("REDO_COMMAND"),se=Yt("KEYDOWN_COMMAND"),le=Yt("KEY_ARROW_RIGHT_COMMAND"),ce=Yt("MOVE_TO_END"),ae=Yt("KEY_ARROW_LEFT_COMMAND"),ue=Yt("MOVE_TO_START"),fe=Yt("KEY_ARROW_UP_COMMAND"),de=Yt("KEY_ARROW_DOWN_COMMAND"),he=Yt("KEY_ENTER_COMMAND"),ge=Yt("KEY_SPACE_COMMAND"),_e=Yt("KEY_BACKSPACE_COMMAND"),pe=Yt("KEY_ESCAPE_COMMAND"),ye=Yt("KEY_DELETE_COMMAND"),me=Yt("KEY_TAB_COMMAND"),xe=Yt("INSERT_TAB_COMMAND"),Ce=Yt("INDENT_CONTENT_COMMAND"),Se=Yt("OUTDENT_CONTENT_COMMAND"),Ne=Yt("DROP_COMMAND"),Te=Yt("FORMAT_ELEMENT_COMMAND"),ve=Yt("DRAGSTART_COMMAND"),ke=Yt("DRAGOVER_COMMAND"),Ee=Yt("DRAGEND_COMMAND"),be=Yt("COPY_COMMAND"),Oe=Yt("CUT_COMMAND"),Me=Yt("SELECT_ALL_COMMAND"),Ae=Yt("CLEAR_EDITOR_COMMAND"),we=Yt("CLEAR_HISTORY_COMMAND"),De=Yt("CAN_REDO_COMMAND"),Pe=Yt("CAN_UNDO_COMMAND"),Ie=Yt("FOCUS_COMMAND"),Le=Yt("BLUR_COMMAND"),Fe=Yt("KEY_MODIFIER_COMMAND"),Re=Object.freeze({}),Ke=[["keydown",function(t,e){if(Be=t.timeStamp,ze=t.key,e.isComposing())return;if(pi(e,se,t))return;if(null==t.key)return;if(Ge&&ai(t))return Gr(e,()=>{sn(e,qe)}),Ge=!1,void(qe="");if(function(t){return si(t,"ArrowRight",{shiftKey:"any"})}(t))pi(e,le,t);else if(function(t){return si(t,"ArrowRight",li)}(t))pi(e,ce,t);else if(function(t){return si(t,"ArrowLeft",{shiftKey:"any"})}(t))pi(e,ae,t);else if(function(t){return si(t,"ArrowLeft",li)}(t))pi(e,ue,t);else if(function(t){return si(t,"ArrowUp",{altKey:"any",shiftKey:"any"})}(t))pi(e,fe,t);else if(function(t){return si(t,"ArrowDown",{altKey:"any",shiftKey:"any"})}(t))pi(e,de,t);else if(function(t){return si(t,"Enter",{altKey:"any",ctrlKey:"any",metaKey:"any",shiftKey:!0})}(t))He=!0,pi(e,he,t);else if(function(t){return" "===t.key}(t))pi(e,ge,t);else if(function(t){return o&&si(t,"o",{ctrlKey:!0})}(t))t.preventDefault(),He=!0,pi(e,qt,!0);else if(function(t){return si(t,"Enter",{altKey:"any",ctrlKey:"any",metaKey:"any"})}(t))He=!1,pi(e,he,t);else if(function(t){return si(t,"Backspace",{shiftKey:"any"})||o&&si(t,"h",{ctrlKey:!0})}(t))ai(t)?pi(e,_e,t):(t.preventDefault(),pi(e,Gt,!0));else if(function(t){return"Escape"===t.key}(t))pi(e,pe,t);else if(function(t){return si(t,"Delete",{})||o&&si(t,"d",{ctrlKey:!0})}(t))!function(t){return"Delete"===t.key}(t)?(t.preventDefault(),pi(e,Gt,!1)):pi(e,ye,t);else if(function(t){return si(t,"Backspace",ci)}(t))t.preventDefault(),pi(e,ee,!0);else if(function(t){return si(t,"Delete",ci)}(t))t.preventDefault(),pi(e,ee,!1);else if(function(t){return o&&si(t,"Backspace",{metaKey:!0})}(t))t.preventDefault(),pi(e,ne,!0);else if(function(t){return o&&(si(t,"Delete",{metaKey:!0})||si(t,"k",{ctrlKey:!0}))}(t))t.preventDefault(),pi(e,ne,!1);else if(function(t){return si(t,"b",li)}(t))t.preventDefault(),pi(e,re,"bold");else if(function(t){return si(t,"u",li)}(t))t.preventDefault(),pi(e,re,"underline");else if(function(t){return si(t,"i",li)}(t))t.preventDefault(),pi(e,re,"italic");else if(function(t){return si(t,"Tab",{shiftKey:"any"})}(t))pi(e,me,t);else if(function(t){return si(t,"z",li)}(t))t.preventDefault(),pi(e,oe,void 0);else if(function(t){if(o)return si(t,"z",{metaKey:!0,shiftKey:!0});return si(t,"y",{ctrlKey:!0})||si(t,"z",{ctrlKey:!0,shiftKey:!0})}(t))t.preventDefault(),pi(e,ie,void 0);else{const n=e._editorState._selection;null===n||tr(n)?ui(t)&&(t.preventDefault(),pi(e,Me,t)):!function(t){return si(t,"c",li)}(t)?!function(t){return si(t,"x",li)}(t)?ui(t)&&(t.preventDefault(),pi(e,Me,t)):(t.preventDefault(),pi(e,Oe,t)):(t.preventDefault(),pi(e,be,t))}(function(t){return t.ctrlKey||t.shiftKey||t.altKey||t.metaKey})(t)&&pi(e,Fe,t)}],["pointerdown",function(t,e){const n=t.target,r=t.pointerType;Ri(n)&&"touch"!==r&&"pen"!==r&&0===t.button&&Gr(e,()=>{vo(n)||(je=!0)})}],["compositionstart",function(t,e){Gr(e,()=>{const n=pr();if(tr(n)&&!e.isComposing()){const r=n.anchor,o=n.anchor.getNode();Bo(r.key),(t.timeStamp{sn(e,t.data)}):(Ge=!0,qe=t.data)}],["input",function(t,e){t.stopPropagation(),Gr(e,()=>{if(Fi(t.target)&&vo(t.target))return;const n=pr(),r=t.data,o=on(t);if(null!=r&&tr(n)&&Ze(n,o,r,t.timeStamp,!1)){Ve&&(sn(e,r),Ve=!1);const o=n.anchor.getNode(),a=Ii(ki(e));if(null===a)return;const u=n.isBackward(),f=u?n.anchor.offset:n.focus.offset,h=u?n.focus.offset:n.anchor.offset;s&&!n.isCollapsed()&&Jn(o)&&null!==a.anchorNode&&o.getTextContent().slice(0,f)+r+o.getTextContent().slice(f+h)===ti(a.anchorNode)||pi(e,Qt,r);const g=r.length;i&&g>1&&"insertCompositionText"===t.inputType&&!e.isComposing()&&(n.anchor.offset-=g),l||c||d||!e.isComposing()||(Be=0,Bo(null))}else{ei(!1,e,null!==r?r:void 0),Ve&&(sn(e,r||void 0),Ve=!1)}!function(){Ir();const t=Rr();H(t)}()},{event:t}),$e=null}],["click",function(t,e){Gr(e,()=>{const n=pr(),r=Ii(ki(e)),o=yr();if(r)if(tr(n)){const e=n.anchor,i=e.getNode();if("element"===e.type&&0===e.offset&&n.isCollapsed()&&!oo(i)&&1===Ho().getChildrenSize()&&i.getTopLevelElementOrThrow().isEmpty()&&null!==o&&n.is(o))r.removeAllRanges(),n.dirty=!0;else if(3===t.detail&&!n.isCollapsed()){if(i!==n.focus.getNode()){const t=Xi(i,t=>Zr(t)&&!t.isInline());Zr(t)&&t.select(0)}}}else if("touch"===t.pointerType||"pen"===t.pointerType){const n=r.anchorNode;if(Fi(n)||Do(n)){Go(_r(o,r,e,t))}}pi(e,Vt,t)})}],["cut",Re],["copy",Re],["dragstart",Re],["dragover",Re],["dragend",Re],["paste",Re],["focus",Re],["blur",Re],["drop",Re]];s&&Ke.push(["beforeinput",(e,n)=>function(e,n){const r=e.inputType,o=on(e);if("deleteCompositionText"===r||i&&_i(n))return;if("insertCompositionText"===r)return;Gr(n,()=>{const i=pr();if("deleteContentBackward"===r){if(null===i){const t=yr();if(!tr(t))return;Go(t.clone())}if(tr(i)){const r=i.anchor.key===i.focus.key;if(s=e.timeStamp,"MediaLast"===ze&&s{Gr(n,()=>{Bo(null)})},30),tr(i)){const e=i.anchor.getNode();e.markDirty(),Jn(e)||t(142),rn(i,e)}}else{Bo(null),e.preventDefault();const t=i.anchor.getNode(),o=t.getTextContent(),s=t.canInsertTextAfter(),l=0===i.anchor.offset&&i.focus.offset===o.length;let c=f&&r&&!l&&s;if(c&&i.isCollapsed()&&(c=!no(gi(i.anchor,!0))),!c){pi(n,Gt,!0);const t=pr();f&&tr(t)&&t.isCollapsed()&&(Xe=t,setTimeout(()=>Xe=null))}}return}}var s;if(!tr(i))return;const l=e.data;null!==$e&&ei(!1,n,$e),i.dirty&&null===$e||!i.isCollapsed()||oo(i.anchor.getNode())||null===o||i.applyDOMRange(o),$e=null;const a=i.anchor,u=i.focus,d=a.getNode(),h=u.getNode();if("insertText"!==r&&"insertTranspose"!==r)switch(e.preventDefault(),r){case"insertFromYank":case"insertFromDrop":case"insertReplacementText":pi(n,Qt,e);break;case"insertFromComposition":Bo(null),pi(n,Qt,e);break;case"insertLineBreak":Bo(null),pi(n,qt,!1);break;case"insertParagraph":Bo(null),He&&!c?(He=!1,pi(n,qt,!1)):pi(n,Xt,void 0);break;case"insertFromPaste":case"insertFromPasteAsQuotation":pi(n,Zt,e);break;case"deleteByComposition":(function(t,e){return t!==e||Zr(t)||Zr(e)||!Ao(t)||!Ao(e)})(d,h)&&pi(n,te,e);break;case"deleteByDrag":case"deleteByCut":pi(n,te,e);break;case"deleteContent":pi(n,Gt,!1);break;case"deleteWordBackward":pi(n,ee,!0);break;case"deleteWordForward":pi(n,ee,!1);break;case"deleteHardLineBackward":case"deleteSoftLineBackward":pi(n,ne,!0);break;case"deleteContentForward":case"deleteHardLineForward":case"deleteSoftLineForward":pi(n,ne,!1);break;case"formatStrikeThrough":pi(n,re,"strikethrough");break;case"formatBold":pi(n,re,"bold");break;case"formatItalic":pi(n,re,"italic");break;case"formatUnderline":pi(n,re,"underline");break;case"historyUndo":pi(n,oe,void 0);break;case"historyRedo":pi(n,ie,void 0)}else{if("\n"===l)e.preventDefault(),pi(n,qt,!1);else if(l===k)e.preventDefault(),pi(n,Xt,void 0);else if(null==l&&e.dataTransfer){const t=e.dataTransfer.getData("text/plain");e.preventDefault(),i.insertRawText(t)}else null!=l&&Ze(i,o,l,e.timeStamp,!0)?(e.preventDefault(),pi(n,Qt,l)):$e=l;We=e.timeStamp}})}(e,n)]);let Be=0,ze=null,We=0,$e=null;const Ue=new WeakMap,Je=new WeakMap;let Ye=!1,je=!1,He=!1,Ve=!1,Ge=!1,qe="",Xe=null,Qe=[0,"",0,"root",0];function Ze(t,e,n,r,o){const i=t.anchor,l=t.focus,c=i.getNode(),a=Rr(),u=Ii(ki(a)),f=null!==u?u.anchorNode:null,d=i.key,h=a.getElementByKey(d),g=n.length;return d!==l.key||!Jn(c)||(!o&&(!s||We1||(o||!s)&&null!==h&&!c.isComposing()&&f!==Io(h)||null!==u&&null!==e&&(!e.collapsed||e.startContainer!==u.anchorNode||e.startOffset!==u.anchorOffset)||c.getFormat()!==t.format||c.getStyle()!==t.style||function(t,e){if(e.isSegmented())return!0;if(!t.isCollapsed())return!1;const n=t.anchor.offset,r=e.getParentOrThrow(),o=Ao(e);return 0===n?!e.canInsertTextBefore()||!r.canInsertTextBefore()&&!e.isComposing()||o||function(t){const e=t.getPreviousSibling();return(Jn(e)||Zr(e)&&e.isInline())&&!e.canInsertTextAfter()}(e):n===e.getTextContentSize()&&(!e.canInsertTextAfter()||!r.canInsertTextAfter()&&!e.isComposing()||o)}(t,c)}function tn(t,e){return Do(t)&&null!==t.nodeValue&&0!==e&&e!==t.nodeValue.length}function en(e,n,r){const{anchorNode:o,anchorOffset:i,focusNode:s,focusOffset:l}=e;Ye&&(Ye=!1,tn(o,i)&&tn(s,l)&&!Xe)||Gr(n,()=>{if(!r)return void Go(null);if(!Eo(n,o,s))return;let c=pr();if(Xe&&tr(c)&&c.isCollapsed()){const t=c.anchor,e=Xe.anchor;(t.key===e.key&&t.offset===e.offset+1||1===t.offset&&e.getNode().is(t.getNode().getPreviousSibling()))&&(c=Xe.clone(),Go(c))}if(Xe=null,tr(c)){const r=c.anchor,o=r.getNode();if(c.isCollapsed()){"Range"===e.type&&e.anchorNode===e.focusNode&&(c.dirty=!0);const i=ki(n).event,s=i?i.timeStamp:performance.now(),[l,a,u,f,d]=Qe,h=Ho(),g=!1===n.isComposing()&&""===h.getTextContent();if(s{const r=yr(),o=e.anchorNode;if(Fi(o)||Do(o)){Go(_r(r,e,n,t))}}));const r=Qo(n),o=r[r.length-1],i=o._key,s=cn.get(i),l=s||o;l!==n&&en(e,l,!1),en(e,n,!0),n!==o?cn.set(i,n):s&&cn.delete(i)}function un(t){t._lexicalHandled=!0}function fn(t){return!0===t._lexicalHandled}const dn=()=>{};function hn(e){const n=Ue.get(e);if(void 0===n)return void dn();const r=Je.get(n);if(void 0===r)return void dn();const o=r-1;o>=0||t(164),Ue.delete(e),Je.set(n,o),0===o&&n.removeEventListener("selectionchange",an);const i=Mo(e);bo(i)?(!function(t){if(null!==t._parentEditor){const e=Qo(t),n=e[e.length-1]._key;cn.get(n)===t&&cn.delete(n)}else cn.delete(t._key)}(i),e.__lexicalEditor=null):i&&t(198);const s=ln(e);for(let t=0;tt.__key===this.__key);if(Jn(this))return n;if(tr(e)&&"element"===e.anchor.type&&"element"===e.focus.type){if(e.isCollapsed())return!1;const t=this.getParent();if(no(this)&&this.isInline()&&t){const n=e.isBackward()?e.focus:e.anchor;if(t.is(n.getNode())&&n.offset===t.getChildrenSize()&&this.is(t.getLastChild()))return!1}}return n}getKey(){return this.__key}getIndexWithinParent(){const t=this.getParent();if(null===t)return-1;let e=t.getFirstChild(),n=0;for(;null!==e;){if(this.is(e))return n;n++,e=e.getNextSibling()}return-1}getParent(){const t=this.getLatest().__parent;return null===t?null:Wo(t)}getParentOrThrow(){const e=this.getParent();return null===e&&t(66,this.__key),e}getTopLevelElement(){let e=this;for(;null!==e;){const n=e.getParent();if(bi(n))return Zr(e)||e===this&&no(e)||t(194),e;e=n}return null}getTopLevelElementOrThrow(){const e=this.getTopLevelElement();return null===e&&t(67,this.__key),e}getParents(){const t=[];let e=this.getParent();for(;null!==e;)t.push(e),e=e.getParent();return t}getParentKeys(){const t=[];let e=this.getParent();for(;null!==e;)t.push(e.__key),e=e.getParent();return t}getPreviousSibling(){const t=this.getLatest().__prev;return null===t?null:Wo(t)}getPreviousSiblings(){const t=[],e=this.getParent();if(null===e)return t;let n=e.getFirstChild();for(;null!==n&&!n.is(this);)t.push(n),n=n.getNextSibling();return t}getNextSibling(){const t=this.getLatest().__next;return null===t?null:Wo(t)}getNextSiblings(){const t=[];let e=this.getNextSibling();for(;null!==e;)t.push(e),e=e.getNextSibling();return t}getCommonAncestor(t){const e=Zr(this)?this:this.getParent(),n=Zr(t)?t:t.getParent(),r=e&&n?Ms(e,n):null;return r?r.commonAncestor:null}is(t){return null!=t&&this.__key===t.__key}isBefore(e){const n=Ms(this,e);return null!==n&&("descendant"===n.type||("branch"===n.type?-1===Es(n):("same"!==n.type&&"ancestor"!==n.type&&t(279),!1)))}isParentOf(t){const e=Ms(this,t);return null!==e&&"ancestor"===e.type}getNodesBetween(e){const n=this.isBefore(e),r=[],o=new Set;let i=this;for(;null!==i;){const s=i.__key;if(o.has(s)||(o.add(s),r.push(i)),i===e)break;const l=Zr(i)?n?i.getFirstChild():i.getLastChild():null;if(null!==l){i=l;continue}const c=n?i.getNextSibling():i.getPreviousSibling();if(null!==c){i=c;continue}const a=i.getParentOrThrow();if(o.has(a.__key)||r.push(a),a===e)break;let u=null,f=a;do{if(null===f&&t(68),u=n?f.getNextSibling():f.getPreviousSibling(),f=f.getParent(),null===f)break;null!==u||o.has(f.__key)||r.push(f)}while(null===u);i=u}return n||r.reverse(),r}isDirty(){const t=Rr()._dirtyLeaves;return null!==t&&t.has(this.__key)}getLatest(){if(pn(this))return this;const e=Wo(this.__key);return null===e&&t(113),e}getWritable(){if(pn(this))return this;Ir();const t=Fr(),e=Rr(),n=t._nodeMap,r=this.__key,o=this.getLatest(),i=e._cloneNotNeeded,s=pr();if(null!==s&&s.setCachedNodes(null),i.has(r))return Ko(o),o;const l=ji(o);return i.add(r),Ko(l),n.set(r,l),l}getTextContent(){return""}getTextContentSize(){return this.getTextContent().length}createDOM(e,n){t(70)}updateDOM(e,n,r){t(71)}exportDOM(t){return{element:this.createDOM(t._config,t)}}exportJSON(){const t=this.__state?this.__state.toJSON():void 0;return{type:this.__type,version:1,...t}}static importJSON(e){t(18,this.name)}updateFromJSON(t){return function(t,e){const n=t.getWritable(),r=e.$;let o=r;for(const t of tt(n).flatKeys)t in e&&(void 0!==o&&o!==r||(o={...r}),o[t]=e[t]);return(n.__state||o)&&Z(t).updateFromJSON(o),n}(this,t)}static transform(){return null}remove(t){gn(this,!0,t)}replace(e,n){Ir();let r=pr();null!==r&&(r=r.clone()),Ai(this,e);const o=this.getLatest(),i=this.__key,s=e.__key,l=e.getWritable(),c=this.getParentOrThrow().getWritable(),a=c.__size;Ro(l);const u=o.getPreviousSibling(),f=o.getNextSibling(),d=o.__prev,h=o.__next,g=o.__parent;if(gn(o,!1,!0),null===u)c.__first=s;else{u.getWritable().__next=s}if(l.__prev=d,null===f)c.__last=s;else{f.getWritable().__prev=s}if(l.__next=h,l.__parent=g,c.__size=a,n&&(Zr(this)&&Zr(l)||t(139),this.getChildren().forEach(t=>{l.append(t)})),tr(r)){Go(r);const t=r.anchor,e=r.focus;t.key===i&&Qn(t,l),e.key===i&&Qn(e,l)}return zo()===i&&Bo(s),l}insertAfter(t,e=!0){Ir(),Ai(this,t);const n=this.getWritable(),r=t.getWritable(),o=r.getParent(),i=pr();let s=!1,l=!1;if(null!==o){const e=t.getIndexWithinParent();if(Ro(r),tr(i)){const t=o.__key,n=i.anchor,r=i.focus;s="element"===n.type&&n.key===t&&n.offset===e+1,l="element"===r.type&&r.key===t&&r.offset===e+1}}const c=this.getNextSibling(),a=this.getParentOrThrow().getWritable(),u=r.__key,f=n.__next;if(null===c)a.__last=u;else{c.getWritable().__prev=u}if(a.__size++,n.__next=u,r.__next=f,r.__prev=n.__key,r.__parent=n.__parent,e&&tr(i)){const t=this.getIndexWithinParent();mr(i,a,t+1);const e=a.__key;s&&i.anchor.set(e,t+2,"element"),l&&i.focus.set(e,t+2,"element")}return t}insertBefore(t,e=!0){Ir(),Ai(this,t);const n=this.getWritable(),r=t.getWritable(),o=r.__key;Ro(r);const i=this.getPreviousSibling(),s=this.getParentOrThrow().getWritable(),l=n.__prev,c=this.getIndexWithinParent();if(null===i)s.__first=o;else{i.getWritable().__next=o}s.__size++,n.__prev=o,r.__prev=l,r.__next=n.__key,r.__parent=n.__parent;const a=pr();if(e&&tr(a)){mr(a,this.getParentOrThrow(),c)}return t}isParentRequired(){return!1}createParentElementNode(){return ho()}selectStart(){return this.selectPrevious()}selectEnd(){return this.selectNext(0,0)}selectPrevious(t,e){Ir();const n=this.getPreviousSibling(),r=this.getParentOrThrow();if(null===n)return r.select(0,0);if(Zr(n))return n.select();if(!Jn(n)){const t=n.getIndexWithinParent()+1;return r.select(t,t)}return n.select(t,e)}selectNext(t,e){Ir();const n=this.getNextSibling(),r=this.getParentOrThrow();if(null===n)return r.select();if(Zr(n))return n.select(0,0);if(!Jn(n)){const t=n.getIndexWithinParent();return r.select(t,t)}return n.select(t,e)}markDirty(){this.getWritable()}reconcileObservedMutation(t,e){this.markDirty()}}const mn="history-merge",xn="collaboration",Cn="skip-scroll-into-view",Sn="skip-dom-selection",Nn="skip-selection-focus";class Tn extends yn{static getType(){return"linebreak"}static clone(t){return new Tn(t.__key)}constructor(t){super(t)}getTextContent(){return"\n"}createDOM(){return document.createElement("br")}updateDOM(){return!1}isInline(){return!0}static importDOM(){return{br:t=>function(t){const e=t.parentElement;if(null!==e&&zi(e)){const n=e.firstChild;if(n===t||n.nextSibling===t&&bn(n)){const n=e.lastChild;if(n===t||n.previousSibling===t&&bn(n))return!0}}return!1}(t)||function(t){const e=t.parentElement;if(null!==e&&zi(e)){const n=e.firstChild;if(n===t||n.nextSibling===t&&bn(n))return!1;const r=e.lastChild;if(r===t||r.previousSibling===t&&bn(r))return!0}return!1}(t)?null:{conversion:vn,priority:0}}}static importJSON(t){return kn().updateFromJSON(t)}}function vn(t){return{node:kn()}}function kn(){return Mi(new Tn)}function En(t){return t instanceof Tn}function bn(t){return Do(t)&&/^( |\t|\r?\n)+$/.test(t.textContent||"")}function On(t,e){return 16&e?"code":e&y?"mark":32&e?"sub":64&e?"sup":null}function Mn(t,e){return 1&e?"strong":2&e?"em":"span"}function An(t,e,n,r,o){const i=r.classList;let s=fi(o,"base");void 0!==s&&i.add(...s),s=fi(o,"underlineStrikethrough");let l=!1;const c=8&e&&4&e;void 0!==s&&(8&n&&4&n?(l=!0,c||i.add(...s)):c&&i.remove(...s));for(const t in w){const r=w[t];if(s=fi(o,t),void 0!==s)if(n&r){if(l&&("underline"===t||"strikethrough"===t)){e&r&&i.remove(...s);continue}(0===(e&r)||c&&"underline"===t||"strikethrough"===t)&&i.add(...s)}else e&r&&i.remove(...s)}}function wn(t,e,n){const r=e.firstChild,o=n.isComposing(),s=t+(o?v:"");if(null==r)e.textContent=s;else{const t=r.nodeValue;if(t!==s)if(o||i){const[e,n,o]=function(t,e){const n=t.length,r=e.length;let o=0,i=0;for(;o({conversion:Bn,priority:0}),b:()=>({conversion:Fn,priority:0}),code:()=>({conversion:$n,priority:0}),em:()=>({conversion:$n,priority:0}),i:()=>({conversion:$n,priority:0}),mark:()=>({conversion:$n,priority:0}),s:()=>({conversion:$n,priority:0}),span:()=>({conversion:Ln,priority:0}),strong:()=>({conversion:$n,priority:0}),sub:()=>({conversion:$n,priority:0}),sup:()=>({conversion:$n,priority:0}),u:()=>({conversion:$n,priority:0})}}static importJSON(t){return Un().updateFromJSON(t)}updateFromJSON(t){return super.updateFromJSON(t).setTextContent(t.text).setFormat(t.format).setDetail(t.detail).setMode(t.mode).setStyle(t.style)}exportDOM(e){let{element:n}=super.exportDOM(e);return Fi(n)||t(132),n.style.whiteSpace="pre-wrap",this.hasFormat("lowercase")?n.style.textTransform="lowercase":this.hasFormat("uppercase")?n.style.textTransform="uppercase":this.hasFormat("capitalize")&&(n.style.textTransform="capitalize"),this.hasFormat("bold")&&(n=Pn(n,"b")),this.hasFormat("italic")&&(n=Pn(n,"i")),this.hasFormat("strikethrough")&&(n=Pn(n,"s")),this.hasFormat("underline")&&(n=Pn(n,"u")),{element:n}}exportJSON(){return{detail:this.getDetail(),format:this.getFormat(),mode:this.getMode(),style:this.getStyle(),text:this.getTextContent(),...super.exportJSON()}}selectionTransform(t,e){}setFormat(t){const e=this.getWritable();return e.__format="string"==typeof t?w[t]:t,e}setDetail(t){const e=this.getWritable();return e.__detail="string"==typeof t?D[t]:t,e}setStyle(t){const e=this.getWritable();return e.__style=t,e}toggleFormat(t){const e=Lo(this.getFormat(),t,null);return this.setFormat(e)}toggleDirectionless(){const t=this.getWritable();return t.__detail^=1,t}toggleUnmergeable(){const t=this.getWritable();return t.__detail^=2,t}setMode(t){const e=L[t];if(this.__mode===e)return this;const n=this.getWritable();return n.__mode=e,n}setTextContent(t){if(this.__text===t)return this;const e=this.getWritable();return e.__text=t,e}select(t,e){Ir();let n=t,r=e;const o=pr(),i=this.getTextContent(),s=this.__key;if("string"==typeof i){const t=i.length;void 0===n&&(n=t),void 0===r&&(r=t)}else n=0,r=0;if(!tr(o))return dr(s,n,s,r,"text","text");{const t=zo();t!==o.anchor.key&&t!==o.focus.key||Bo(s),o.setTextNodeRange(this,n,this,r)}return o}selectStart(){return this.select(0,0)}selectEnd(){const t=this.getTextContentSize();return this.select(t,t)}spliceText(t,e,n,r){const o=this.getWritable(),i=o.__text,s=n.length;let l=t;l<0&&(l=s+l,l<0&&(l=0));const c=pr();if(r&&tr(c)){const e=t+s;c.setTextNodeRange(o,e,o,e)}const a=i.slice(0,l)+n+i.slice(l+e);return o.__text=a,o}canInsertTextBefore(){return!0}canInsertTextAfter(){return!0}splitText(...t){Ir();const e=this.getLatest(),n=e.getTextContent();if(""===n)return[];const r=e.__key,o=zo(),i=n.length;t.sort((t,e)=>t-e),t.push(i);const s=[],l=t.length;for(let e=0,r=0;ee&&(s.push(n.slice(e,o)),e=o)}const c=s.length;if(1===c)return[e];const a=s[0],u=e.getParent();let f;const d=e.getFormat(),h=e.getStyle(),g=e.__detail;let _=!1,p=null,y=null;const m=pr();if(tr(m)){const[t,e]=m.isBackward()?[m.focus,m.anchor]:[m.anchor,m.focus];"text"===t.type&&t.key===r&&(p=t),"text"===e.type&&e.key===r&&(y=e)}e.isSegmented()?(f=Un(a),f.__format=d,f.__style=h,f.__detail=g,f.__state=it(e,f),_=!0):f=e.setTextContent(a);const x=[f];for(let t=1;t=N&&(p.set(t.getKey(),C-N,"text"),C=N){y.set(t.getKey(),S-N,"text");break}N=e}if(null!==u){!function(t){const e=t.getPreviousSibling(),n=t.getNextSibling();null!==e&&Ko(e);null!==n&&Ko(n)}(this);const t=u.getWritable(),e=this.getIndexWithinParent();_?(t.splice(e,0,x),this.remove()):t.splice(e,1,x),tr(m)&&mr(m,u,e,c-1)}return x}mergeWithSibling(e){const n=e===this.getPreviousSibling();n||e===this.getNextSibling()||t(50);const r=this.__key,o=e.__key,i=this.__text,s=i.length;zo()===o&&Bo(r);const l=pr();if(tr(l)){const t=l.anchor,i=l.focus;null!==t&&t.key===o&&Sr(t,n,r,e,s),null!==i&&i.key===o&&Sr(i,n,r,e,s)}const c=e.__text,a=n?c+i:i+c;this.setTextContent(a);const u=this.getWritable();return e.remove(),u}isTextEntity(){return!1}}function Ln(t){return{forChild:Yn(t.style),node:null}}function Fn(t){const e=t,n="normal"===e.style.fontWeight;return{forChild:Yn(e.style,n?void 0:"bold"),node:null}}const Rn=new WeakMap;function Kn(t){if(!Fi(t))return!1;if("PRE"===t.nodeName)return!0;const e=t.style.whiteSpace;return"string"==typeof e&&e.startsWith("pre")}function Bn(e){const n=e;null===e.parentElement&&t(129);let r=n.textContent||"";if(null!==function(t){let e,n=t.parentNode;const r=[t];for(;null!==n&&void 0===(e=Rn.get(n))&&!Kn(n);)r.push(n),n=n.parentNode;const o=void 0===e?n:e;for(let t=0;t0){/[ \t\n]$/.test(n)&&(r=r.slice(1)),e=!1;break}}e&&(r=r.slice(1))}if(" "===r[r.length-1]){let t=n,e=!0;for(;null!==t&&null!==(t=zn(t,!0));){if((t.textContent||"").replace(/^( |\t|\r?\n)+/,"").length>0){e=!1;break}}e&&(r=r.slice(0,r.length-1))}return""===r?{node:null}:{node:Un(r)}}function zn(t,e){let n=t;for(;;){let t;for(;null===(t=e?n.nextSibling:n.previousSibling);){const t=n.parentElement;if(null===t)return null;n=t}if(n=t,Fi(n)){const t=n.style.display;if(""===t&&!Bi(n)||""!==t&&!t.startsWith("inline"))return null}let r=n;for(;null!==(r=e?n.firstChild:n.lastChild);)n=r;if(Do(n))return n;if("BR"===n.nodeName)return null}}const Wn={code:"code",em:"italic",i:"italic",mark:"highlight",s:"strikethrough",strong:"bold",sub:"subscript",sup:"superscript",u:"underline"};function $n(t){const e=Wn[t.nodeName.toLowerCase()];return void 0===e?{node:null}:{forChild:Yn(t.style,e),node:null}}function Un(t=""){return Mi(new In(t))}function Jn(t){return t instanceof In}function Yn(t,e){const n=t.fontWeight,r=t.textDecoration.split(" "),o="700"===n||"bold"===n,i=r.includes("line-through"),s="italic"===t.fontStyle,l=r.includes("underline"),c=t.verticalAlign;return t=>Jn(t)?(o&&!t.hasFormat("bold")&&t.toggleFormat("bold"),i&&!t.hasFormat("strikethrough")&&t.toggleFormat("strikethrough"),s&&!t.hasFormat("italic")&&t.toggleFormat("italic"),l&&!t.hasFormat("underline")&&t.toggleFormat("underline"),"sub"!==c||t.hasFormat("subscript")||t.toggleFormat("subscript"),"super"!==c||t.hasFormat("superscript")||t.toggleFormat("superscript"),e&&!t.hasFormat(e)&&t.toggleFormat(e),t):t}class jn extends In{static getType(){return"tab"}static clone(t){return new jn(t.__key)}constructor(t){super("\t",t),this.__detail=2}static importDOM(){return null}createDOM(t){const e=super.createDOM(t),n=fi(t.theme,"tab");if(void 0!==n){e.classList.add(...n)}return e}static importJSON(t){return Hn().updateFromJSON(t)}setTextContent(t){return"\t"!==t&&""!==t&&e(126),super.setTextContent("\t")}spliceText(e,n,r,o){return""===r&&0===n||"\t"===r&&1===n||t(286),this}setDetail(e){return 2!==e&&t(127),this}setMode(e){return"normal"!==e&&t(128),this}canInsertTextBefore(){return!1}canInsertTextAfter(){return!1}}function Hn(){return Mi(new jn)}function Vn(t){return t instanceof jn}class Gn{key;offset;type;_selection;constructor(t,e,n){this._selection=null,this.key=t,this.offset=e,this.type=n}is(t){return this.key===t.key&&this.offset===t.offset&&this.type===t.type}isBefore(t){if(this.key===t.key)return this.offsett&&(r=t)}else if(!Zr(e)){const t=e.getNextSibling();if(Jn(t))n=t.__key,r=0,o="text";else{const t=e.getParent();t&&(n=t.__key,r=e.getIndexWithinParent()+1)}}t.set(n,r,o)}function Qn(t,e){if(Zr(e)){const n=e.getLastDescendant();Zr(n)||Jn(n)?Xn(t,n):Xn(t,e)}else Xn(t,e)}class Zn{_nodes;_cachedNodes;dirty;constructor(t){this._cachedNodes=null,this._nodes=t,this.dirty=!1}getCachedNodes(){return this._cachedNodes}setCachedNodes(t){this._cachedNodes=t}is(t){if(!nr(t))return!1;const e=this._nodes,n=t._nodes;return e.size===n.size&&Array.from(e).every(t=>n.has(t))}isCollapsed(){return!1}isBackward(){return!1}getStartEndPoints(){return null}add(t){this.dirty=!0,this._nodes.add(t),this._cachedNodes=null}delete(t){this.dirty=!0,this._nodes.delete(t),this._cachedNodes=null}clear(){this.dirty=!0,this._nodes.clear(),this._cachedNodes=null}has(t){return this._nodes.has(t)}clone(){return new Zn(new Set(this._nodes))}extract(){return this.getNodes()}insertRawText(t){}insertText(){}insertNodes(t){const e=this.getNodes(),n=e.length,r=e[n-1];let o;if(Jn(r))o=r.select();else{const t=r.getIndexWithinParent()+1;o=r.getParentOrThrow().select(t,t)}o.insertNodes(t);for(let t=0;t1;){const t=e[e.length-1];if(!Zr(t)||i.has(t)||t.isEmpty()||o.has(t))break;e.pop()}if(0===e.length&&t.isCollapsed()){const n=Bs(t.anchor),r=Bs(t.anchor.getFlipped()),o=t=>ss(t)?t.origin:t.getNodeAtCaret(),i=o(n)||o(r)||(t.anchor.getNodeAtCaret()?n.origin:r.origin);e.push(i)}return e}($s(Is(this),"next"));return Pr()||(this._cachedNodes=e),e}setTextNodeRange(t,e,n,r){this.anchor.set(t.__key,e,"text"),this.focus.set(n.__key,r,"text")}getTextContent(){const t=this.getNodes();if(0===t.length)return"";const e=t[0],n=t[t.length-1],r=this.anchor,o=this.focus,i=r.isBefore(o),[s,l]=or(this);let c="",a=!0;for(let u=0;u=0;t--){const e=i[t];if(e.is(d)||Zr(e)&&e.isParentOf(d))break;e.isAttached()&&(!s.has(e)||e.is(o)?g||p.insertAfter(e,!1):e.remove())}if(!g){let e=r,n=null;for(;null!==e;){const r=e.getChildren(),o=r.length;(0===o||r[o-1].is(n))&&(t.delete(e.__key),n=e),e=e.getParent()}}if(Ao(d))if(c===h)d.select();else{const t=Un(e);t.select(),d.replace(t)}else d=d.spliceText(c,h-c,e,!0),""===d.getTextContent()?d.remove():d.isComposing()&&"text"===this.anchor.type&&(this.anchor.offset-=e.length);for(let e=1;e{n.forEach(n=>{if(Zr(n)){const r=n.getFormatFlags(t,e);n.setTextFormat(r)}})},i=r.length;if(0===i)return this.toggleFormat(t),Bo(null),void o(e);const s=this.anchor,l=this.focus,c=this.isBackward(),a=c?l:s,u=c?s:l;let f=0,d=r[0],h="element"===a.type?0:a.offset;if("text"===a.type&&h===d.getTextContentSize()&&(f=1,d=r[1],h=0),null==d)return;const g=d.getFormatFlags(t,e);o(g);const _=i-1;let p=r[_];const y="text"===u.type?u.offset:p.getTextContentSize();if(d.is(p)){if(h===y)return;if(wo(d)||0===h&&y===d.getTextContentSize())d.setFormat(g);else{const t=d.splitText(h,y),e=0===h?t[0]:t[1];e.setFormat(g),"text"===a.type&&a.set(e.__key,0,"text"),"text"===u.type&&u.set(e.__key,y-h,"text")}return void(this.format=g)}0===h||wo(d)||([,d]=d.splitText(h),h=0),d.setFormat(g);const m=p.getFormatFlags(t,g);y>0&&(y===p.getTextContentSize()||wo(p)||([p]=p.splitText(y)),p.setFormat(m));for(let e=f+1;e<_;e++){const n=r[e],o=n.getFormatFlags(t,m);n.setFormat(o)}"text"===a.type&&a.set(d.__key,h,"text"),"text"===u.type&&u.set(p.__key,y,"text"),this.format=g|m}insertNodes(e){if(0===e.length)return;if(this.isCollapsed()||this.removeText(),"root"===this.anchor.key){this.insertParagraph();const n=pr();return tr(n)||t(134),n.insertNodes(e)}const n=(this.isBackward()?this.focus:this.anchor).getNode(),r=Xi(n,Wi),o=e[e.length-1];if(Zr(r)&&"__language"in r){if("__language"in e[0])this.insertText(e[0].getTextContent());else{const t=vr(this);r.splice(t,0,e),o.selectEnd()}return}if(!e.some(t=>(Zr(t)||no(t))&&!t.isInline())){Zr(r)||t(211,n.constructor.name,n.getType());const i=vr(this);return r.splice(i,0,e),void o.selectEnd()}const i=function(t){const e=ho();let n=null;for(let r=0;r0){const t=i.getRangeAt(0),n=this.anchor.getNode(),o=oo(n)?n:Ei(n);if(this.applyDOMRange(t),this.dirty=!0,!r){const n=this.getNodes(),r=[];let s=!1;for(let t=0;t0)if(e){const t=r[0];Zr(t)?t.selectStart():t.getParentOrThrow().selectStart()}else{const t=r[r.length-1];Zr(t)?t.selectEnd():t.getParentOrThrow().selectEnd()}i.anchorNode===t.startContainer&&i.anchorOffset===t.startOffset||function(t){const e=t.focus,n=t.anchor,r=n.key,o=n.offset,i=n.type;n.set(e.key,e.offset,e.type,!0),e.set(r,o,i,!0)}(this)}}"lineboundary"===n&&Er(this,t,e,n,"decorators")}forwardDeletion(t,e,n){if(!n&&("element"===t.type&&Zr(e)&&t.offset===e.getChildrenSize()||"text"===t.type&&t.offset===e.getTextContentSize())){const t=e.getParent(),n=e.getNextSibling()||(null===t?null:t.getNextSibling());if(Zr(n)&&n.isShadowRoot())return!0}return!1}deleteCharacter(t){const e=this.isCollapsed();if(this.isCollapsed()){const e=this.anchor;let n=e.getNode();if(this.forwardDeletion(e,n,t))return;const r=Ss(As(e,t?"previous":"next"));if(r.getTextSlices().every(t=>null===t||0===t.distance)){let t={type:"initial"};for(const e of r.iterNodeCarets("shadowRoot"))if(cs(e))if(e.origin.isInline());else{if(e.origin.isShadowRoot()){if("merge-block"===t.type)break;if(Zr(r.anchor.origin)&&r.anchor.origin.isEmpty()){const t=Bs(e);Ps(this,Ts(t,t)),r.anchor.origin.remove()}return}"merge-next-block"!==t.type&&"merge-block"!==t.type||(t={block:t.block,caret:e,type:"merge-block"})}else{if("merge-block"===t.type)break;if(ls(e)){if(Zr(e.origin)){if(e.origin.isInline()){if(!e.origin.isParentOf(r.anchor.origin))break}else t={block:e.origin,type:"merge-next-block"};continue}if(no(e.origin)){if(e.origin.isIsolated());else if("merge-next-block"===t.type&&(e.origin.isKeyboardSelectable()||!e.origin.isInline())&&Zr(r.anchor.origin)&&r.anchor.origin.isEmpty()){r.anchor.origin.remove();const t=gr();t.add(e.origin.getKey()),Go(t)}else e.origin.remove();return}break}}if("merge-block"===t.type){const{caret:e,block:n}=t;return Ps(this,Ts(!e.origin.isEmpty()&&n.isEmpty()?Ls(ds(n,e.direction)):r.anchor,e)),this.removeText()}}const o=this.focus;if(this.modify("extend",t,"character"),this.isCollapsed()){if(t&&0===e.offset&&ir(this,e.getNode()))return}else{const r="text"===o.type?o.getNode():null;if(n="text"===e.type?e.getNode():null,null!==r&&r.isSegmented()){const e=o.offset,i=r.getTextContentSize();if(r.is(n)||t&&e!==i||!t&&0!==e)return void lr(r,t,e)}else if(null!==n&&n.isSegmented()){const o=e.offset,i=n.getTextContentSize();if(n.is(r)||t&&0!==o||!t&&o!==i)return void lr(n,t,o)}!function(t,e){const n=t.anchor,r=t.focus,o=n.getNode(),i=r.getNode();if(o===i&&"text"===n.type&&"text"===r.type){const t=n.offset,i=r.offset,s=t{try{const t=new RegExp("\\p{Emoji}","u"),e=t.test.bind(t);if(e("❤️")&&e("#️⃣")&&e("👍"))return e}catch(t){}return()=>!1})();function lr(t,e,n){const r=t,o=r.getTextContent().split(/(?=\s)/g),i=o.length;let s=0,l=0;for(let t=0;tn||r){o.splice(t,1),r&&(l=void 0);break}}const c=o.join("").trim();""===c?r.remove():(r.setTextContent(c),r.select(l,l))}function cr(e,n,r,o){let i,s=n;if(Fi(e)){let l=!1;const c=e.childNodes,a=c.length,u=o._blockCursorElement;s===a&&(l=!0,s=a-1);let f=c[s],d=!1;if(f===u)f=c[s+1],d=!0;else if(null!==u){const t=u.parentNode;if(e===t){n>Array.prototype.indexOf.call(t.children,u)&&s--}}if(i=qo(f),Jn(i))s=gs(i,l?"next":"previous");else{let c=qo(e);if(null===c)return null;if(Zr(c)){const a=o.getElementByKey(c.getKey());null===a&&t(214);const u=c.getDOMSlot(a);[c,s]=u.resolveChildIndex(c,a,e,n),Zr(c)||t(215),l&&s>=c.getChildrenSize()&&(s=Math.max(0,c.getChildrenSize()-1));let f=c.getChildAtIndex(s);if(Zr(f)&&function(t,e,n){const r=t.getParent();return null===n||null===r||!r.canBeEmpty()||r!==n.getNode()}(f,0,r)){const t=l?f.getLastDescendant():f.getFirstDescendant();null===t?c=f:(f=t,c=Zr(f)?f:f.getParentOrThrow()),s=0}Jn(f)?(i=f,c=null,s=gs(f,l?"next":"previous")):f!==c&&l&&!d&&(Zr(c)||t(216),s=Math.min(c.getChildrenSize(),s+1))}else{const t=c.getIndexWithinParent();s=0===n&&no(c)&&qo(e)===c?t:t+1,c=c.getParentOrThrow()}if(Zr(c))return qn(c.__key,s,"element")}}else i=qo(e);return Jn(i)?qn(i.__key,gs(i,s,"clamp"),"text"):null}function ar(t,e,n){const r=t.offset,o=t.getNode();if(0===r){const r=o.getPreviousSibling(),i=o.getParent();if(e){if((n||!e)&&null===r&&Zr(i)&&i.isInline()){const e=i.getPreviousSibling();Jn(e)&&t.set(e.__key,e.getTextContent().length,"text")}}else Zr(r)&&!n&&r.isInline()?t.set(r.__key,r.getChildrenSize(),"element"):Jn(r)&&t.set(r.__key,r.getTextContent().length,"text")}else if(r===o.getTextContent().length){const r=o.getNextSibling(),i=o.getParent();if(e&&Zr(r)&&r.isInline())t.set(r.__key,0,"element");else if((n||e)&&null===r&&Zr(i)&&i.isInline()&&!i.canInsertTextAfter()){const e=i.getNextSibling();Jn(e)&&t.set(e.__key,0,"text")}}}function ur(t,e,n){if("text"===t.type&&"text"===e.type){const r=t.isBefore(e),o=t.is(e);ar(t,r,o),ar(e,!r,o),o&&e.set(t.key,t.offset,t.type);const i=Rr();if(i.isComposing()&&i._compositionKey!==t.key&&tr(n)){const r=n.anchor,o=n.focus;t.set(r.key,r.offset,r.type,!0),e.set(o.key,o.offset,o.type,!0)}}}function fr(t,e,n,r,o,i){if(null===t||null===n||!Eo(o,t,n))return null;const s=cr(t,e,tr(i)?i.anchor:null,o);if(null===s)return null;const l=cr(n,r,tr(i)?i.focus:null,o);if(null===l)return null;if("element"===s.type&&"element"===l.type){const e=qo(t),r=qo(n);if(no(e)&&no(r))return null}return ur(s,l,i),[s,l]}function dr(t,e,n,r,o,i){const s=Fr(),l=new er(qn(t,e,o),qn(n,r,i),0,"");return l.dirty=!0,s._selection=l,l}function hr(){const t=qn("root",0,"element"),e=qn("root",0,"element");return new er(t,e,0,"")}function gr(){return new Zn(new Set)}function _r(t,e,n,r){const o=n._window;if(null===o)return null;const i=r||o.event,s=i?i.type:void 0,l="selectionchange"===s,c=!B&&(l||"beforeinput"===s||"compositionstart"===s||"compositionend"===s||"click"===s&&i&&3===i.detail||"drop"===s||void 0===s);let a,u,f,d;if(tr(t)&&!c)return t.clone();if(null===e)return null;if(a=e.anchorNode,u=e.focusNode,f=e.anchorOffset,d=e.focusOffset,(l||void 0===s)&&tr(t)&&!Eo(n,a,u))return t.clone();const h=fr(a,f,u,d,n,t);if(null===h)return null;const[g,_]=h;return new er(g,_,tr(t)?t.format:0,tr(t)?t.style:"")}function pr(){return Fr()._selection}function yr(){return Rr()._editorState._selection}function mr(t,e,n,r=1){const o=t.anchor,i=t.focus,s=o.getNode(),l=i.getNode();if(!e.is(s)&&!e.is(l))return;const c=e.__key;if(t.isCollapsed()){const e=o.offset;if(n<=e&&r>0||n0||n0||n=t,s=o?i.getChildAtIndex(t-1):i.getChildAtIndex(n);if(Jn(s)){let t=0;o&&(t=s.getTextContentSize()),e.set(s.__key,t,"text"),r.set(s.__key,t,"text")}return}if(Zr(i)){const t=i.getChildrenSize(),r=n>=t,o=r?i.getChildAtIndex(t-1):i.getChildAtIndex(n);if(Jn(o)){let t=0;r&&(t=o.getTextContentSize()),e.set(o.__key,t,"text")}}if(Zr(s)){const t=s.getChildrenSize(),e=o>=t,n=e?s.getChildAtIndex(t-1):s.getChildAtIndex(o);if(Jn(n)){let t=0;e&&(t=n.getTextContentSize()),r.set(n.__key,t,"text")}}}function Cr(t,e,n,r,o){let i=null,s=0,l=null;null!==r?(i=r.__key,Jn(r)?(s=r.getTextContentSize(),l="text"):Zr(r)&&(s=r.getChildrenSize(),l="element")):null!==o&&(i=o.__key,Jn(o)?l="text":Zr(o)&&(l="element")),null!==i&&null!==l?t.set(i,s,l):(s=e.getIndexWithinParent(),-1===s&&(s=n.getChildrenSize()),t.set(n.__key,s,"element"))}function Sr(t,e,n,r,o){"text"===t.type?t.set(n,t.offset+(e?0:o),"text"):t.offset>r.getIndexWithinParent()&&t.set(t.key,t.offset-1,"element")}function Nr(t,e,n,r,o){try{t.setBaseAndExtent(e,n,r,o)}catch(t){}}function Tr(t,e,n,r,o,i,s){const l=r.anchorNode,c=r.focusNode,a=r.anchorOffset,u=r.focusOffset,f=document.activeElement;if(o.has(xn)&&f!==i||null!==f&&ko(f))return;if(!tr(e))return void(null!==t&&Eo(n,l,c)&&r.removeAllRanges());const d=e.anchor,h=e.focus,g=d.key,_=h.key,p=mi(n,g),y=mi(n,_),m=d.offset,x=h.offset,C=e.format,S=e.style,N=e.isCollapsed();let T=p,v=y,k=!1;if("text"===d.type){T=Io(p);const t=d.getNode();k=t.getFormat()!==C||t.getStyle()!==S}else tr(t)&&"text"===t.anchor.type&&(k=!0);var E,b,O,M,A;if(("text"===h.type&&(v=Io(y)),null!==T&&null!==v)&&(N&&(null===t||k||tr(t)&&(t.format!==C||t.style!==S))&&(E=C,b=S,O=m,M=g,A=performance.now(),Qe=[E,b,O,M,A]),a!==m||u!==x||l!==T||c!==v||"Range"===r.type&&N||(null!==f&&i.contains(f)||o.has(Nn)||i.focus({preventScroll:!0}),"element"===d.type))){if(Nr(r,T,m,v,x),!o.has(Cn)&&e.isCollapsed()&&null!==i&&i===document.activeElement){const t=tr(e)&&"element"===e.anchor.type?T.childNodes[m]||null:r.rangeCount>0?r.getRangeAt(0):null;if(null!==t){let e;if(t instanceof Text){const n=document.createRange();n.selectNode(t),e=n.getBoundingClientRect()}else e=t.getBoundingClientRect();!function(t,e,n){const r=Ci(n),o=vi(r);if(null===r||null===o)return;let{top:i,bottom:s}=e,l=0,c=0,a=n;for(;null!==a;){const e=a===r.body;if(e)l=0,c=ki(t).innerHeight;else{const t=a.getBoundingClientRect();l=t.top,c=t.bottom}let n=0;if(ic&&(n=s-c),0!==n)if(e)o.scrollBy(0,n);else{const t=a.scrollTop;a.scrollTop+=n;const e=a.scrollTop-t;i-=e,s-=e}if(e)break;a=xi(a)}}(n,e,i)}}Ye=!0}}function vr(e){let n=e;e.isCollapsed()||n.removeText();const r=pr();tr(r)&&(n=r),tr(n)||t(161);const o=n.anchor;let i=o.getNode(),s=o.offset;for(;!Wi(i);){const t=i;if([i,s]=kr(i,s),t.is(i))break}return s}function kr(t,e){const n=t.getParent();if(!n){const t=ho();return Ho().append(t),t.select(),[Ho(),0]}if(Jn(t)){const r=t.splitText(e);if(0===r.length)return[n,t.getIndexWithinParent()];const o=0===e?0:1;return[n,r[0].getIndexWithinParent()+o]}if(!Zr(t)||0===e)return[n,t.getIndexWithinParent()];const r=t.getChildAtIndex(e);if(r){const n=new er(qn(t.__key,e,"element"),qn(t.__key,e,"element"),0,""),o=t.insertNewAfter(n);o&&o.append(r,...r.getNextSiblings())}return[n,t.getIndexWithinParent()+1]}function Er(t,e,n,r,o="decorators-and-blocks"){if("move"===e&&"character"===r&&!t.isCollapsed()){const[e,r]=n===t.isBackward()?[t.focus,t.anchor]:[t.anchor,t.focus];return r.set(e.key,e.offset,e.type),!0}const i=As(t.focus,n?"previous":"next"),s="lineboundary"===r,l="move"===e;let c=i,a="decorators-and-blocks"===o;if(!zs(c)){for(const t of c){a=!1;const{origin:e}=t;if(!no(e)||e.isIsolated()||(c=t,!s||!e.isInline()))break}if(a)for(const t of Ss(i).iterNodeCarets("extend"===e?"shadowRoot":"root")){if(cs(t))t.origin.isInline()||(c=t);else{if(Zr(t.origin))continue;no(t.origin)&&!t.origin.isInline()&&(c=t)}break}}if(c===i)return!1;if(l&&!s&&no(c.origin)&&c.origin.isKeyboardSelectable()){const t=gr();return t.add(c.origin.getKey()),Go(t),!0}return c=Bs(c),l&&ws(t.anchor,c),ws(t.focus,c),a||!s}let br=null,Or=null,Mr=!1,Ar=!1,wr=0;const Dr={characterData:!0,childList:!0,subtree:!0};function Pr(){return Mr||null!==br&&br._readOnly}function Ir(){Mr&&t(13)}function Lr(){wr>99&&t(14)}function Fr(){return null===br&&t(195,Kr()),br}function Rr(){return null===Or&&t(196,Kr()),Or}function Kr(){let t=0;const e=new Set,n=yo.version;if("undefined"!=typeof window)for(const r of document.querySelectorAll("[contenteditable]")){const o=Mo(r);if(bo(o))t++;else if(o){let t=String(o.constructor.version||"<0.17.1");t===n&&(t+=" (separately built, likely a bundler configuration issue)"),e.add(t)}}let r=` Detected on the page: ${t} compatible editor(s) with version ${n}`;return e.size&&(r+=` and incompatible editors with versions ${Array.from(e).join(", ")}`),r}function Br(){return Or}function zr(t,e,n){const r=e.__type,o=So(t,r);let i=n.get(r);void 0===i&&(i=Array.from(o.transforms),n.set(r,i));const s=i.length;for(let t=0;t0||u>0;){if(c>0){e._dirtyLeaves=new Set;for(const t of l){const r=o.get(t);Jn(r)&&r.isAttached()&&r.isSimpleText()&&!r.isUnmergeable()&&ct(r),void 0!==r&&Wr(r,i)&&zr(e,r,s),n.add(t)}if(l=e._dirtyLeaves,c=l.size,c>0){wr++;continue}}e._dirtyLeaves=new Set,e._dirtyElements=new Map,a.delete("root")&&a.set("root",!0);for(const t of a){const n=t[0],l=t[1];if(r.set(n,l),!l)continue;const c=o.get(n);void 0!==c&&Wr(c,i)&&zr(e,c,s)}l=e._dirtyLeaves,c=l.size,a=e._dirtyElements,u=a.size,wr++}e._dirtyLeaves=n,e._dirtyElements=r}(a,e),Hr(e),function(t,e,n,r){const o=t._nodeMap,i=e._nodeMap,s=[];for(const[t]of r){const e=i.get(t);void 0!==e&&(e.isAttached()||(Zr(e)&&K(e,t,o,i,s,r),o.has(t)||r.delete(t),s.push(t)))}for(const t of s)i.delete(t);for(const t of n){const e=i.get(t);void 0===e||e.isAttached()||(o.has(t)||n.delete(t),i.delete(t))}}(c,a,e._dirtyLeaves,e._dirtyElements));o!==e._compositionKey&&(a._flushSync=!0);const i=a._selection;if(tr(i)){const e=a._nodeMap,n=i.anchor.key,r=i.focus.key;void 0!==e.get(n)&&void 0!==e.get(r)||t(19)}else nr(i)&&0===i._nodes.size&&(a._selection=null)}catch(t){return t instanceof Error&&e._onError(t),e._pendingEditorState=c,e._dirtyType=2,e._cloneNotNeeded.clear(),e._dirtyLeaves=new Set,e._dirtyElements.clear(),void Yr(e)}finally{br=f,Mr=d,Or=h,e._updating=g,wr=0}const p=0!==e._dirtyType||e._deferred.length>0||function(t,e){const n=e.getEditorState()._selection,r=t._selection;if(null!==r){if(r.dirty||!r.is(n))return!0}else if(null!==n)return!0;return!1}(a,e);p?a._flushSync?(a._flushSync=!1,Yr(e)):u&&To(()=>{Yr(e)}):(a._flushSync=!1,u&&(o.clear(),e._deferred=[],e._pendingEditorState=null))}function Gr(t,e,n){Or===t&&void 0===n?e():Vr(t,e,n)}class qr{element;before;after;constructor(t,e,n){this.element=t,this.before=e||null,this.after=n||null}withBefore(t){return new qr(this.element,t,this.after)}withAfter(t){return new qr(this.element,this.before,t)}withElement(t){return this.element===t?this:new qr(t,this.before,this.after)}insertChild(e){const n=this.before||this.getManagedLineBreak();return null!==n&&n.parentElement!==this.element&&t(222),this.element.insertBefore(e,n),this}removeChild(e){return e.parentElement!==this.element&&t(223),this.element.removeChild(e),this}replaceChild(e,n){return n.parentElement!==this.element&&t(224),this.element.replaceChild(e,n),this}getFirstChild(){const t=this.after?this.after.nextSibling:this.element.firstChild;return t===this.before||t===this.getManagedLineBreak()?null:t}getManagedLineBreak(){return this.element.__lexicalLineBreak||null}setManagedLineBreak(t){if(null===t)this.removeManagedLineBreak();else{const e="decorator"===t&&(d||c||l);this.insertManagedLineBreak(e)}}removeManagedLineBreak(){const t=this.getManagedLineBreak();if(t){const e=this.element,n="IMG"===t.nodeName?t.nextSibling:null;n&&e.removeChild(n),e.removeChild(t),e.__lexicalLineBreak=void 0}}insertManagedLineBreak(t){const e=this.getManagedLineBreak();if(e){if(t===("IMG"===e.nodeName))return;this.removeManagedLineBreak()}const n=this.element,r=this.before,o=document.createElement("br");if(n.insertBefore(o,r),t){const t=document.createElement("img");t.setAttribute("data-lexical-linebreak","true"),t.style.cssText="display: inline !important; border: 0px !important; margin: 0px !important;",t.alt="",n.insertBefore(t,o),n.__lexicalLineBreak=t}else n.__lexicalLineBreak=o}getFirstChildOffset(){let t=0;for(let e=this.after;null!==e;e=e.previousSibling)t++;return t}resolveChildIndex(t,e,n,r){if(n===this.element){const e=this.getFirstChildOffset();return[t,Math.min(e+t.getChildrenSize(),Math.max(e,r))]}const o=Xr(e,n);o.push(r);const i=Xr(e,this.element);let s=t.getIndexWithinParent();for(let t=0;tn){s+=1;break}}return[t.getParentOrThrow(),s]}}function Xr(e,n){const r=[];let o=n;for(;o!==e&&null!==o;o=o.parentNode){let t=0;for(let e=o.previousSibling;null!==e;e=e.previousSibling)t++;r.push(t)}return o!==e&&t(225),r.reverse()}class Qr extends yn{__first;__last;__size;__format;__style;__indent;__dir;__textFormat;__textStyle;constructor(t){super(t),this.__first=null,this.__last=null,this.__size=0,this.__format=0,this.__style="",this.__indent=0,this.__dir=null,this.__textFormat=0,this.__textStyle=""}afterCloneFrom(t){super.afterCloneFrom(t),this.__key===t.__key&&(this.__first=t.__first,this.__last=t.__last,this.__size=t.__size),this.__indent=t.__indent,this.__format=t.__format,this.__style=t.__style,this.__dir=t.__dir,this.__textFormat=t.__textFormat,this.__textStyle=t.__textStyle}getFormat(){return this.getLatest().__format}getFormatType(){const t=this.getFormat();return I[t]||""}getStyle(){return this.getLatest().__style}getIndent(){return this.getLatest().__indent}getChildren(){const t=[];let e=this.getFirstChild();for(;null!==e;)t.push(e),e=e.getNextSibling();return t}getChildrenKeys(){const t=[];let e=this.getFirstChild();for(;null!==e;)t.push(e.__key),e=e.getNextSibling();return t}getChildrenSize(){return this.getLatest().__size}isEmpty(){return 0===this.getChildrenSize()}isDirty(){const t=Rr()._dirtyElements;return null!==t&&t.has(this.__key)}isLastChild(){const t=this.getLatest(),e=this.getParentOrThrow().getLastChild();return null!==e&&e.is(t)}getAllTextNodes(){const t=[];let e=this.getFirstChild();for(;null!==e;){if(Jn(e)&&t.push(e),Zr(e)){const n=e.getAllTextNodes();t.push(...n)}e=e.getNextSibling()}return t}getFirstDescendant(){let t=this.getFirstChild();for(;Zr(t);){const e=t.getFirstChild();if(null===e)break;t=e}return t}getLastDescendant(){let t=this.getLastChild();for(;Zr(t);){const e=t.getLastChild();if(null===e)break;t=e}return t}getDescendantByIndex(t){const e=this.getChildren(),n=e.length;if(t>=n){const t=e[n-1];return Zr(t)&&t.getLastDescendant()||t||null}const r=e[t];return Zr(r)&&r.getFirstDescendant()||r||null}getFirstChild(){const t=this.getLatest().__first;return null===t?null:Wo(t)}getFirstChildOrThrow(){const e=this.getFirstChild();return null===e&&t(45,this.__key),e}getLastChild(){const t=this.getLatest().__last;return null===t?null:Wo(t)}getLastChildOrThrow(){const e=this.getLastChild();return null===e&&t(96,this.__key),e}getChildAtIndex(t){const e=this.getChildrenSize();let n,r;if(t=t;){if(r===t)return n;n=n.getPreviousSibling(),r--}return null}getTextContent(){let t="";const e=this.getChildren(),n=e.length;for(let r=0;rt.remove()),t}append(...t){return this.splice(this.getChildrenSize(),0,t)}setDirection(t){const e=this.getWritable();return e.__dir=t,e}setFormat(t){return this.getWritable().__format=""!==t?P[t]:0,this}setStyle(t){return this.getWritable().__style=t||"",this}setTextFormat(t){const e=this.getWritable();return e.__textFormat=t,e}setTextStyle(t){const e=this.getWritable();return e.__textStyle=t,e}setIndent(t){return this.getWritable().__indent=t,this}splice(e,n,r){pn(this)&&t(324,this.__key,this.__type);const o=this.getChildrenSize(),i=this.getWritable();e+n<=o||t(226,String(e),String(n),String(o));const s=i.__key,l=[],c=[],a=this.getChildAtIndex(e+n);let u=null,f=o-n+r.length;if(0!==e)if(e===o)u=this.getLastChild();else{const t=this.getChildAtIndex(e);null!==t&&(u=t.getPreviousSibling())}if(n>0){let e=null===u?this.getFirstChild():u.getNextSibling();for(let r=0;r0&&(e.style.paddingInlineStart=40*t+"px");const n=this.getDirection();n&&(e.dir=n)}return{element:e}}exportJSON(){const t={children:[],direction:this.getDirection(),format:this.getFormatType(),indent:this.getIndent(),...super.exportJSON()},e=this.getTextFormat(),n=this.getTextStyle();return 0!==e&&(t.textFormat=e),""!==n&&(t.textStyle=n),t}updateFromJSON(t){return super.updateFromJSON(t).setFormat(t.format).setIndent(t.indent).setDirection(t.direction).setTextFormat(t.textFormat||0).setTextStyle(t.textStyle||"")}insertNewAfter(t,e){return null}canIndent(){return!0}collapseAtStart(t){return!1}excludeFromCopy(t){return!1}canReplaceWith(t){return!0}canInsertAfter(t){return!0}canBeEmpty(){return!0}canInsertTextBefore(){return!0}canInsertTextAfter(){return!0}isInline(){return!1}isShadowRoot(){return!1}canMergeWith(t){return!1}extractWithChild(t,e,n){return!1}canMergeWhenEmpty(){return!1}reconcileObservedMutation(t,e){const n=this.getDOMSlot(t);let r=n.getFirstChild();for(let t=this.getFirstChild();t;t=t.getNextSibling()){const o=e.getElementByKey(t.getKey());null!==o&&(null==r?(n.insertChild(o),r=o):r!==o&&n.replaceChild(o,r),r=r.nextSibling)}}}function Zr(t){return t instanceof Qr}function to(t,e,n){let r=t.getNode();for(;r;){const t=r.__key;if(e.has(t)&&!n.has(t))return!0;r=r.getParent()}return!1}class eo extends yn{decorate(t,e){return null}isIsolated(){return!1}isInline(){return!0}isKeyboardSelectable(){return!0}}function no(t){return t instanceof eo}class ro extends Qr{__cachedText;static getType(){return"root"}static clone(){return new ro}constructor(){super("root"),this.__cachedText=null}getTopLevelElementOrThrow(){t(51)}getTextContent(){const t=this.__cachedText;return!Pr()&&0!==Rr()._dirtyType||null===t?super.getTextContent():t}remove(){t(52)}replace(e){t(53)}insertBefore(e){t(54)}insertAfter(e){t(55)}updateDOM(t,e){return!1}splice(e,n,r){for(const e of r)Zr(e)||no(e)||t(282);return super.splice(e,n,r)}static importJSON(t){return Ho().updateFromJSON(t)}collapseAtStart(){return!0}}function oo(t){return t instanceof ro}function io(t){return new co(new Map(t._nodeMap))}function so(){return new co(new Map([["root",new ro]]))}function lo(e){const n=e.exportJSON(),r=e.constructor;if(n.type!==r.getType()&&t(130,r.name),Zr(e)){const o=n.children;Array.isArray(o)||t(59,r.name);const i=e.getChildren();for(let t=0;t({root:lo(Ho())}))}}class ao extends Qr{static getType(){return"artificial"}createDOM(t){return document.createElement("div")}}class uo extends Qr{static getType(){return"paragraph"}static clone(t){return new uo(t.__key)}createDOM(t){const e=document.createElement("p"),n=fi(t.theme,"paragraph");if(void 0!==n){e.classList.add(...n)}return e}updateDOM(t,e,n){return!1}static importDOM(){return{p:t=>({conversion:fo,priority:0})}}exportDOM(t){const{element:e}=super.exportDOM(t);if(Fi(e)){this.isEmpty()&&e.append(document.createElement("br"));const t=this.getFormatType();t&&(e.style.textAlign=t)}return{element:e}}static importJSON(t){return ho().updateFromJSON(t)}exportJSON(){return{...super.exportJSON(),textFormat:this.getTextFormat(),textStyle:this.getTextStyle()}}insertNewAfter(t,e){const n=ho();n.setTextFormat(t.format),n.setTextStyle(t.style);const r=this.getDirection();return n.setDirection(r),n.setFormat(this.getFormatType()),n.setStyle(this.getStyle()),this.insertAfter(n,e),n}collapseAtStart(){const t=this.getChildren();if(0===t.length||Jn(t[0])&&""===t[0].getTextContent().trim()){if(null!==this.getNextSibling())return this.selectNext(),this.remove(),!0;if(null!==this.getPreviousSibling())return this.selectPrevious(),this.remove(),!0}return!1}}function fo(t){const e=ho();return t.style&&(e.setFormat(t.style.textAlign),Hi(t,e)),{node:e}}function ho(){return Mi(new uo)}function go(t){return t instanceof uo}function _o(t,e,n,r){const o=t._keyToDOMMap;o.clear(),t._editorState=so(),t._pendingEditorState=r,t._compositionKey=null,t._dirtyType=0,t._cloneNotNeeded.clear(),t._dirtyLeaves=new Set,t._dirtyElements.clear(),t._normalizedNodes=new Set,t._updateTags=new Set,t._updates=[],t._blockCursorElement=null;const i=t._observer;null!==i&&(i.disconnect(),t._observer=null),null!==e&&(e.textContent=""),null!==n&&(n.textContent="",o.set("root",n))}function po(t){const e=new Set,n=new Set;let r=t;for(;r;){const{ownNodeConfig:t}=qi(r),o=r.transform;if(!n.has(o)){n.add(o);const t=r.transform();t&&e.add(t)}if(t){const n=t.$transform;n&&e.add(n),r=t.extends}else{const t=Object.getPrototypeOf(r);r=t.prototype instanceof yn&&t!==yn?t:void 0}}return e}class yo{static version;_headless;_parentEditor;_rootElement;_editorState;_pendingEditorState;_compositionKey;_deferred;_keyToDOMMap;_updates;_updating;_listeners;_commands;_nodes;_decorators;_pendingDecorators;_config;_dirtyType;_cloneNotNeeded;_dirtyLeaves;_dirtyElements;_normalizedNodes;_updateTags;_observer;_key;_onError;_htmlConversions;_window;_editable;_blockCursorElement;_createEditorArgs;constructor(t,e,n,r,o,i,s,l){this._createEditorArgs=l,this._parentEditor=e,this._rootElement=null,this._editorState=t,this._pendingEditorState=null,this._compositionKey=null,this._deferred=[],this._keyToDOMMap=new Map,this._updates=[],this._updating=!1,this._listeners={decorator:new Set,editable:new Set,mutation:new Map,root:new Set,textcontent:new Set,update:new Set},this._commands=new Map,this._config=r,this._nodes=n,this._decorators={},this._pendingDecorators=null,this._dirtyType=0,this._cloneNotNeeded=new Set,this._dirtyLeaves=new Set,this._dirtyElements=new Map,this._normalizedNodes=new Set,this._updateTags=new Set,this._observer=null,this._key=Zo(),this._onError=o,this._htmlConversions=i,this._editable=s,this._headless=null!==e&&e._headless,this._window=null,this._blockCursorElement=null}isComposing(){return null!=this._compositionKey}registerUpdateListener(t){const e=this._listeners.update;return e.add(t),()=>{e.delete(t)}}registerEditableListener(t){const e=this._listeners.editable;return e.add(t),()=>{e.delete(t)}}registerDecoratorListener(t){const e=this._listeners.decorator;return e.add(t),()=>{e.delete(t)}}registerTextContentListener(t){const e=this._listeners.textcontent;return e.add(t),()=>{e.delete(t)}}registerRootListener(t){const e=this._listeners.root;return t(this._rootElement,null),e.add(t),()=>{t(null,this._rootElement),e.delete(t)}}registerCommand(e,n,r){void 0===r&&t(35);const o=this._commands;o.has(e)||o.set(e,[new Set,new Set,new Set,new Set,new Set]);const i=o.get(e);void 0===i&&t(36,String(e));const s=i[r];return s.add(n),()=>{s.delete(n),i.every(t=>0===t.size)&&o.delete(e)}}registerMutationListener(t,e,n){const r=this.resolveRegisteredNodeAfterReplacements(this.getRegisteredNode(t)).klass,o=this._listeners.mutation;let i=o.get(e);void 0===i&&(i=new Set,o.set(e,i)),i.add(r);const s=n&&n.skipInitialization;return void 0!==s&&s||this.initializeMutationListener(e,r),()=>{i.delete(r),0===i.size&&o.delete(e)}}getRegisteredNode(e){const n=this._nodes.get(e.getType());return void 0===n&&t(37,e.name),n}resolveRegisteredNodeAfterReplacements(t){for(;t.replaceWithKlass;)t=this.getRegisteredNode(t.replaceWithKlass);return t}initializeMutationListener(t,e){const n=this._editorState,r=Yi(n).get(e.getType());if(!r)return;const o=new Map;for(const t of r.keys())o.set(t,"created");o.size>0&&t(o,{dirtyLeaves:new Set,prevEditorState:n,updateTags:new Set(["registerMutationListener"])})}registerNodeTransformToKlass(t,e){const n=this.getRegisteredNode(t);return n.transforms.add(e),n}registerNodeTransform(t,e){const n=this.registerNodeTransformToKlass(t,e),r=[n],o=n.replaceWithKlass;if(null!=o){const t=this.registerNodeTransformToKlass(o,e);r.push(t)}return function(t,e){const n=Yi(t.getEditorState()),r=[];for(const t of e){const e=n.get(t);e&&r.push(e)}if(0===r.length)return;t.update(()=>{for(const t of r)for(const e of t.keys()){const t=Wo(e);t&&t.markDirty()}},null===t._pendingEditorState?{tag:mn}:void 0)}(this,r.map(t=>t.klass.getType())),()=>{r.forEach(t=>t.transforms.delete(e))}}hasNode(t){return this._nodes.has(t.getType())}hasNodes(t){return t.every(this.hasNode.bind(this))}dispatchCommand(t,e){return pi(this,t,e)}getDecorators(){return this._decorators}getRootElement(){return this._rootElement}getKey(){return this._key}setRootElement(t){const e=this._rootElement;if(t!==e){const n=fi(this._config.theme,"root"),r=this._pendingEditorState||this._editorState;if(this._rootElement=t,_o(this,e,t,r),null!==e&&(this._config.disableEvents||hn(e),null!=n&&e.classList.remove(...n)),null!==t){const e=vi(t),r=t.style;r.userSelect="text",r.whiteSpace="pre-wrap",r.wordBreak="break-word",t.setAttribute("data-lexical-editor","true"),this._window=e,this._dirtyType=2,V(this),this._updateTags.add(mn),Yr(this),this._config.disableEvents||function(t,e){const n=t.ownerDocument;Ue.set(t,n);const r=Je.get(n)??0;r<1&&n.addEventListener("selectionchange",an),Je.set(n,r+1),t.__lexicalEditor=e;const o=ln(t);for(let n=0;n{fn(t)||(un(t),(e.isEditable()||"click"===r)&&i(t,e))}:t=>{if(fn(t))return;un(t);const n=e.isEditable();switch(r){case"cut":return n&&pi(e,Oe,t);case"copy":return pi(e,be,t);case"paste":return n&&pi(e,Zt,t);case"dragstart":return n&&pi(e,ve,t);case"dragover":return n&&pi(e,ke,t);case"dragend":return n&&pi(e,Ee,t);case"focus":return n&&pi(e,Ie,t);case"blur":return n&&pi(e,Le,t);case"drop":return n&&pi(e,Ne,t)}};t.addEventListener(r,s),o.push(()=>{t.removeEventListener(r,s)})}}(t,this),null!=n&&t.classList.add(...n)}else this._window=null,this._updateTags.add(mn),Yr(this);jr("root",this,!1,t,e)}}getElementByKey(t){return this._keyToDOMMap.get(t)||null}getEditorState(){return this._editorState}setEditorState(e,n){e.isEmpty()&&t(38);let r=e;r._readOnly&&(r=io(e),r._selection=e._selection?e._selection.clone():null),H(this);const o=this._pendingEditorState,i=this._updateTags,s=void 0!==n?n.tag:null;null===o||o.isEmpty()||(null!=s&&i.add(s),Yr(this)),this._pendingEditorState=r,this._dirtyType=2,this._dirtyElements.set("root",!1),this._compositionKey=null,null!=s&&i.add(s),this._updating||Yr(this)}parseEditorState(t,e){return function(t,e,n){const r=so(),o=br,i=Mr,s=Or,l=e._dirtyElements,c=e._dirtyLeaves,a=e._cloneNotNeeded,u=e._dirtyType;e._dirtyElements=new Map,e._dirtyLeaves=new Set,e._cloneNotNeeded=new Set,e._dirtyType=0,br=r,Mr=!1,Or=e,xo(null);try{const o=e._nodes;Ur(t.root,o),n&&n(),r._readOnly=!0}catch(t){t instanceof Error&&e._onError(t)}finally{e._dirtyElements=l,e._dirtyLeaves=c,e._cloneNotNeeded=a,e._dirtyType=u,br=o,Mr=i,Or=s}return r}("string"==typeof t?JSON.parse(t):t,this,e)}read(t){return Yr(this),this.getEditorState().read(t,{editor:this})}update(t,e){!function(t,e,n){t._updating?t._updates.push([e,n]):Vr(t,e,n)}(this,t,e)}focus(t,e={}){const n=this._rootElement;null!==n&&(n.setAttribute("autocapitalize","off"),Gr(this,()=>{const r=pr(),o=Ho();null!==r?r.dirty||Go(r.clone()):0!==o.getChildrenSize()&&("rootStart"===e.defaultSelection?o.selectStart():o.selectEnd()),Si("focus"),Ni(()=>{n.removeAttribute("autocapitalize"),t&&t()})}),null===this._pendingEditorState&&n.removeAttribute("autocapitalize"))}blur(){const t=this._rootElement;null!==t&&t.blur();const e=Ii(this._window);null!==e&&e.removeAllRanges()}isEditable(){return this._editable}setEditable(t){this._editable!==t&&(this._editable=t,jr("editable",this,!0,t))}toJSON(){return{editorState:this._editorState.toJSON()}}}yo.version="0.38.2+prod.cjs";let mo=null;function xo(t){mo=t}let Co=1;function So(e,n){const r=No(e,n);return void 0===r&&t(30,n),r}function No(t,e){return t._nodes.get(e)}const To="function"==typeof queueMicrotask?queueMicrotask:t=>{Promise.resolve().then(t)};function vo(t){return no(Jo(t))}function ko(t){const e=document.activeElement;if(!Fi(e))return!1;const n=e.nodeName;return no(Jo(t))&&("INPUT"===n||"TEXTAREA"===n||"true"===e.contentEditable&&null==Mo(e))}function Eo(t,e,n){const r=t.getRootElement();try{return null!==r&&r.contains(e)&&r.contains(n)&&null!==e&&!ko(e)&&Oo(e)===t}catch(t){return!1}}function bo(t){return t instanceof yo}function Oo(t){let e=t;for(;null!=e;){const t=Mo(e);if(bo(t))return t;e=xi(e)}return null}function Mo(t){return t?t.__lexicalEditor:null}function Ao(t){return Vn(t)||t.isToken()}function wo(t){return Ao(t)||t.isSegmented()}function Do(t){return Ri(t)&&3===t.nodeType}function Po(t){return Ri(t)&&9===t.nodeType}function Io(t){let e=t;for(;null!=e;){if(Do(e))return e;e=e.firstChild}return null}function Lo(t,e,n){const r=w[e];if(null!==n&&(t&r)===(n&r))return t;let o=t^r;return"subscript"===e?o&=~w.superscript:"superscript"===e?o&=~w.subscript:"lowercase"===e?(o&=~w.uppercase,o&=~w.capitalize):"uppercase"===e?(o&=~w.lowercase,o&=~w.capitalize):"capitalize"===e&&(o&=~w.lowercase,o&=~w.uppercase),o}function Fo(t,e){const n=function(){const t=mo;return mo=null,t}();if(null!=(e=e||n&&n.__key))return void(t.__key=e);Ir(),Lr();const r=Rr(),o=Fr(),i=""+Co++;o._nodeMap.set(i,t),Zr(t)?r._dirtyElements.set(i,!0):r._dirtyLeaves.add(i),r._cloneNotNeeded.add(i),r._dirtyType=1,t.__key=i}function Ro(t){const e=t.getParent();if(null!==e){const n=t.getWritable(),r=e.getWritable(),o=t.getPreviousSibling(),i=t.getNextSibling(),s=null!==i?i.__key:null,l=null!==o?o.__key:null,c=null!==o?o.getWritable():null,a=null!==i?i.getWritable():null;null===o&&(r.__first=s),null===i&&(r.__last=l),null!==c&&(c.__next=s),null!==a&&(a.__prev=l),n.__prev=null,n.__next=null,n.__parent=null,r.__size--}}function Ko(e){Lr(),pn(e)&&t(323,e.__key,e.__type);const n=e.getLatest(),r=n.__parent,o=Fr(),i=Rr(),s=o._nodeMap,l=i._dirtyElements;null!==r&&function(t,e,n){let r=t;for(;null!==r;){if(n.has(r))return;const t=e.get(r);if(void 0===t)break;n.set(r,!1),r=t.__parent}}(r,s,l);const c=n.__key;i._dirtyType=1,Zr(e)?l.set(c,!0):i._dirtyLeaves.add(c)}function Bo(t){Ir();const e=Rr(),n=e._compositionKey;if(t!==n){if(e._compositionKey=t,null!==n){const t=Wo(n);null!==t&&t.getWritable()}if(null!==t){const e=Wo(t);null!==e&&e.getWritable()}}}function zo(){if(Pr())return null;return Rr()._compositionKey}function Wo(t,e){const n=(e||Fr())._nodeMap.get(t);return void 0===n?null:n}function $o(t,e){const n=Uo(t,Rr());return void 0!==n?Wo(n,e):null}function Uo(t,e){return t[`__lexicalKey_${e._key}`]}function Jo(t,e){let n=t;for(;null!=n;){const t=$o(n,e);if(null!==t)return t;n=xi(n)}return null}function Yo(t){const e=t._decorators,n=Object.assign({},e);return t._pendingDecorators=n,n}function jo(t){return t.read(()=>Ho().getTextContent())}function Ho(){return Vo(Fr())}function Vo(t){return t._nodeMap.get("root")}function Go(t){Ir();const e=Fr();null!==t&&(t.dirty=!0,t.setCachedNodes(null)),e._selection=t}function qo(t){const e=Rr(),n=function(t,e){let n=t;for(;null!=n;){const t=Uo(n,e);if(void 0!==t)return t;n=xi(n)}return null}(t,e);if(null===n){return t===e.getRootElement()?Wo("root"):null}return Wo(n)}function Xo(t){return/[\uD800-\uDBFF][\uDC00-\uDFFF]/g.test(t)}function Qo(t){const e=[];let n=t;for(;null!==n;)e.push(n),n=n._parentEditor;return e}function Zo(){return Math.random().toString(36).replace(/[^a-z]+/g,"").substring(0,5)}function ti(t){return Do(t)?t.nodeValue:null}function ei(t,e,n){const r=Ii(ki(e));if(null===r)return;const o=r.anchorNode;let{anchorOffset:i,focusOffset:s}=r;if(null!==o){let e=ti(o);const r=Jo(o);if(null!==e&&Jn(r)){if(e===v&&n){const t=n.length;e=n,i=t,s=t}null!==e&&ni(r,e,i,s,t)}}}function ni(t,e,n,r,o){let i=t;if(i.isAttached()&&(o||!i.isDirty())){const s=i.isComposing();let a=e;(s||o)&&e[e.length-1]===v&&(a=e.slice(0,-1));const u=i.getTextContent();if(o||a!==u){if(""===a){if(Bo(null),l||c||d)i.remove();else{const t=Rr();setTimeout(()=>{t.update(()=>{i.isAttached()&&i.remove()})},20)}return}const e=i.getParent(),o=yr(),u=i.getTextContentSize(),f=zo(),h=i.getKey();if(i.isToken()||null!==f&&h===f&&!s||tr(o)&&(null!==e&&!e.canInsertTextBefore()&&0===o.anchor.offset||o.anchor.key===t.__key&&0===o.anchor.offset&&!i.canInsertTextBefore()&&!s||o.focus.key===t.__key&&o.focus.offset===u&&!i.canInsertTextAfter()&&!s))return void i.markDirty();const g=pr();if(!tr(g)||null===n||null===r)return void ri(i,a,g);if(g.setTextNodeRange(i,n,i,r),i.isSegmented()){const t=Un(i.getTextContent());i.replace(t),i=t}ri(i,a,g)}}}function ri(t,e,n){if(t.setTextContent(e),tr(n)){const e=t.getKey();for(const r of["anchor","focus"]){const o=n[r];"text"===o.type&&o.key===e&&(o.offset=gs(t,o.offset,"clamp"))}}}function oi(t,e,n){const r=e[n]||!1;return"any"===r||r===t[n]}function ii(t,e){return oi(t,e,"altKey")&&oi(t,e,"ctrlKey")&&oi(t,e,"shiftKey")&&oi(t,e,"metaKey")}function si(t,e,n){return ii(t,n)&&t.key.toLowerCase()===e.toLowerCase()}const li={ctrlKey:!o,metaKey:o},ci={altKey:o,ctrlKey:!o};function ai(t){return"Backspace"===t.key}function ui(t){return si(t,"a",li)}function fi(t,e){void 0===t.__lexicalClassNameCache&&(t.__lexicalClassNameCache={});const n=t.__lexicalClassNameCache,r=n[e];if(void 0!==r)return r;const o=t[e];if("string"==typeof o){const t=h(o);return n[e]=t,t}return o}function di(e,n,r,o,i){if(0===r.size)return;const s=o.__type,l=o.__key,c=n.get(s);void 0===c&&t(33,s);const a=c.klass;let u=e.get(a);void 0===u&&(u=new Map,e.set(a,u));const f=u.get(l),d="destroyed"===f&&"created"===i;(void 0===f||d)&&u.set(l,d?"updated":i)}function hi(t,e,n){const r=t.getParent();let o=n,i=t;return null!==r&&(e&&0===n?(o=i.getIndexWithinParent(),i=r):e||n!==i.getChildrenSize()||(o=i.getIndexWithinParent()+1,i=r)),i.getChildAtIndex(e?o-1:o)}function gi(t,e){const n=t.offset;if("element"===t.type){return hi(t.getNode(),e,n)}{const r=t.getNode();if(e&&0===n||!e&&n===r.getTextContentSize()){const t=e?r.getPreviousSibling():r.getNextSibling();return null===t?hi(r.getParentOrThrow(),e,r.getIndexWithinParent()+(e?0:1)):t}}return null}function _i(t){const e=ki(t).event,n=e&&e.inputType;return"insertFromPaste"===n||"insertFromPasteAsQuotation"===n}function pi(t,e,n){return function(t,e,n){const r=Qo(t);for(let o=4;o>=0;o--)for(let i=0;i{for(let e=0;es),Gi(e,"clone")||(e.clone=t=>(xo(t),new e)),Gi(e,"importJSON")||(e.importJSON=i&&i.$importJSON||(t=>(new e).updateFromJSON(t))),!Gi(e,"importDOM")&&i)){const{importDOM:t}=i;t&&(e.importDOM=()=>t)}return{ownNodeConfig:i,ownNodeType:s}}const Xi=(t,e)=>{let n=t;for(;null!=n&&!oo(n);){if(e(n))return n;n=n.getParent()}return null},Qi={next:"previous",previous:"next"};class Zi{origin;constructor(t){this.origin=t}[Symbol.iterator](){return vs({hasNext:ls,initial:this.getAdjacentCaret(),map:t=>t,step:t=>t.getAdjacentCaret()})}getAdjacentCaret(){return ds(this.getNodeAtCaret(),this.direction)}getSiblingCaret(){return ds(this.origin,this.direction)}remove(){const t=this.getNodeAtCaret();return t&&t.remove(),this}replaceOrInsert(t,e){const n=this.getNodeAtCaret();return t.is(this.origin)||t.is(n)||(null===n?this.insert(t):n.replace(t,e)),this}splice(e,n,r="next"){const o=r===this.direction?n:Array.from(n).reverse();let i=this;const s=this.getParentAtCaret(),l=new Map;for(let t=i.getAdjacentCaret();null!==t&&l.size0){const n=i.getNodeAtCaret();if(n)if(l.delete(n.getKey()),l.delete(e.getKey()),n.is(e)||i.origin.is(e));else{const t=e.getParent();t&&t.is(s)&&e.remove(),n.replace(e)}else null===n&&t(263,Array.from(l).join(" "))}else i.insert(e);i=ds(e,this.direction)}for(const t of l.values())t.remove();return this}}class ts extends Zi{type="child";getLatest(){const t=this.origin.getLatest();return t===this.origin?this:ps(t,this.direction)}getParentCaret(t="root"){return ds(rs(this.getParentAtCaret(),t),this.direction)}getFlipped(){const t=ns(this.direction);return ds(this.getNodeAtCaret(),t)||ps(this.origin,t)}getParentAtCaret(){return this.origin}getChildCaret(){return this}isSameNodeCaret(t){return t instanceof ts&&this.direction===t.direction&&this.origin.is(t.origin)}isSamePointCaret(t){return this.isSameNodeCaret(t)}}const es={root:oo,shadowRoot:bi};function ns(t){return Qi[t]}function rs(t,e="root"){return es[e](t)?null:t}class os extends Zi{type="sibling";getLatest(){const t=this.origin.getLatest();return t===this.origin?this:ds(t,this.direction)}getSiblingCaret(){return this}getParentAtCaret(){return this.origin.getParent()}getChildCaret(){return Zr(this.origin)?ps(this.origin,this.direction):null}getParentCaret(t="root"){return ds(rs(this.getParentAtCaret(),t),this.direction)}getFlipped(){const t=ns(this.direction);return ds(this.getNodeAtCaret(),t)||ps(this.origin.getParentOrThrow(),t)}isSamePointCaret(t){return t instanceof os&&this.direction===t.direction&&this.origin.is(t.origin)}isSameNodeCaret(t){return(t instanceof os||t instanceof is)&&this.direction===t.direction&&this.origin.is(t.origin)}}class is extends Zi{type="text";offset;constructor(t,e){super(t),this.offset=e}getLatest(){const t=this.origin.getLatest();return t===this.origin?this:hs(t,this.direction,this.offset)}getParentAtCaret(){return this.origin.getParent()}getChildCaret(){return null}getParentCaret(t="root"){return ds(rs(this.getParentAtCaret(),t),this.direction)}getFlipped(){return hs(this.origin,ns(this.direction),this.offset)}isSamePointCaret(t){return t instanceof is&&this.direction===t.direction&&this.origin.is(t.origin)&&this.offset===t.offset}isSameNodeCaret(t){return(t instanceof os||t instanceof is)&&this.direction===t.direction&&this.origin.is(t.origin)}getSiblingCaret(){return ds(this.origin,this.direction)}}function ss(t){return t instanceof is}function ls(t){return t instanceof os}function cs(t){return t instanceof ts}const as={next:class extends is{direction="next";getNodeAtCaret(){return this.origin.getNextSibling()}insert(t){return this.origin.insertAfter(t),this}},previous:class extends is{direction="previous";getNodeAtCaret(){return this.origin.getPreviousSibling()}insert(t){return this.origin.insertBefore(t),this}}},us={next:class extends os{direction="next";getNodeAtCaret(){return this.origin.getNextSibling()}insert(t){return this.origin.insertAfter(t),this}},previous:class extends os{direction="previous";getNodeAtCaret(){return this.origin.getPreviousSibling()}insert(t){return this.origin.insertBefore(t),this}}},fs={next:class extends ts{direction="next";getNodeAtCaret(){return this.origin.getFirstChild()}insert(t){return this.origin.splice(0,0,[t]),this}},previous:class extends ts{direction="previous";getNodeAtCaret(){return this.origin.getLastChild()}insert(t){return this.origin.splice(this.origin.getChildrenSize(),0,[t]),this}}};function ds(t,e){return t?new us[e](t):null}function hs(t,e,n){return t?new as[e](t,gs(t,n)):null}function gs(t,n,r="error"){const o=t.getTextContentSize();let i="next"===n?o:"previous"===n?0:n;return(i<0||i>o)&&("clamp"!==r&&e(284,String(n),String(o),t.getKey()),i=i<0?0:o),i}function _s(t,e){return new Cs(t,e)}function ps(t,e){return Zr(t)?new fs[e](t):null}function ys(t){return t&&t.getChildCaret()||t}function ms(t){return t&&ys(t.getAdjacentCaret())}class xs{type="node-caret-range";direction;anchor;focus;constructor(t,e,n){this.anchor=t,this.focus=e,this.direction=n}getLatest(){const t=this.anchor.getLatest(),e=this.focus.getLatest();return t===this.anchor&&e===this.focus?this:new xs(t,e,this.direction)}isCollapsed(){return this.anchor.isSamePointCaret(this.focus)}getTextSlices(){const t=t=>{const e=this[t].getLatest();return ss(e)?function(t,e){const{direction:n,origin:r}=t,o=gs(r,"focus"===e?ns(n):n);return _s(t,o-t.offset)}(e,t):null},e=t("anchor"),n=t("focus");if(e&&n){const{caret:t}=e,{caret:r}=n;if(t.isSameNodeCaret(r))return[_s(t,r.offset-t.offset),null]}return[e,n]}iterNodeCarets(t="root"){const e=ss(this.anchor)?this.anchor.getSiblingCaret():this.anchor.getLatest(),n=this.focus.getLatest(),r=ss(n),o=e=>e.isSameNodeCaret(n)?null:ms(e)||e.getParentCaret(t);return vs({hasNext:t=>null!==t&&!(r&&n.isSameNodeCaret(t)),initial:e.isSameNodeCaret(n)?null:o(e),map:t=>t,step:o})}[Symbol.iterator](){return this.iterNodeCarets("root")}}class Cs{type="slice";caret;distance;constructor(t,e){this.caret=t,this.distance=e}getSliceIndices(){const{distance:t,caret:{offset:e}}=this,n=e+t;return n{let n;for(let r=c;rn.has(t.getKey())&&Wi(t));return u&&f?[u,f]:null}(f,d,a);if(h){const[t,e]=h;ps(t,"previous").splice(0,e.getChildren()),e.remove()}const g=[f,d,...l,...c].find(Rs);if(g){return Ns(Ws(Bs(g),e.direction))}t(269,JSON.stringify(l.map(t=>t.origin.__key)))}function Bs(t){const e=function(t){let e=t;for(;cs(e);){const t=ms(e);if(!cs(t))break;e=t}return e}(t.getLatest()),{direction:n}=e;if(Jn(e.origin))return ss(e)?e:hs(e.origin,n,n);const r=e.getAdjacentCaret();return ls(r)&&Jn(r.origin)?hs(r.origin,n,ns(n)):e}function zs(t){return ss(t)&&t.offset!==gs(t.origin,t.direction)}function Ws(t,e){return t.direction===e?t:t.getFlipped()}function $s(t,e){return t.direction===e?t:Ts(Ws(t.focus,e),Ws(t.anchor,e))}function Us(t,e,n){let r=ps(t,"next");for(let t=0;t0||n.canBeEmpty()&&o(n,"last"))&&i.insert(e(n).splice(0,0,r))}return i},exports.$splitNode=function(e,n){let r=e.getChildAtIndex(n);null==r&&(r=e),bi(e)&&t(102);const o=e=>{const n=e.getParentOrThrow(),i=bi(n),s=e!==r||i?Oi(e):e;if(i)return Zr(e)&&Zr(s)||t(133),e.insertAfter(s),[e,s,s];{const[t,r,i]=o(n),l=e.getNextSiblings();return i.append(s,...l),[t,r,s]}},[i,s]=o(r);return[i,s]},exports.$updateRangeSelectionFromCaretRange=Ps,exports.ArtificialNode__DO_NOT_USE=ao,exports.BLUR_COMMAND=Le,exports.CAN_REDO_COMMAND=De,exports.CAN_UNDO_COMMAND=Pe,exports.CLEAR_EDITOR_COMMAND=Ae,exports.CLEAR_HISTORY_COMMAND=we,exports.CLICK_COMMAND=Vt,exports.COLLABORATION_TAG=xn,exports.COMMAND_PRIORITY_CRITICAL=4,exports.COMMAND_PRIORITY_EDITOR=0,exports.COMMAND_PRIORITY_HIGH=3,exports.COMMAND_PRIORITY_LOW=1,exports.COMMAND_PRIORITY_NORMAL=2,exports.CONTROLLED_TEXT_INSERTION_COMMAND=Qt,exports.COPY_COMMAND=be,exports.CUT_COMMAND=Oe,exports.DELETE_CHARACTER_COMMAND=Gt,exports.DELETE_LINE_COMMAND=ne,exports.DELETE_WORD_COMMAND=ee,exports.DRAGEND_COMMAND=Ee,exports.DRAGOVER_COMMAND=ke,exports.DRAGSTART_COMMAND=ve,exports.DROP_COMMAND=Ne,exports.DecoratorNode=eo,exports.ElementNode=Qr,exports.FOCUS_COMMAND=Ie,exports.FORMAT_ELEMENT_COMMAND=Te,exports.FORMAT_TEXT_COMMAND=re,exports.HISTORIC_TAG="historic",exports.HISTORY_MERGE_TAG=mn,exports.HISTORY_PUSH_TAG="history-push",exports.INDENT_CONTENT_COMMAND=Ce,exports.INSERT_LINE_BREAK_COMMAND=qt,exports.INSERT_PARAGRAPH_COMMAND=Xt,exports.INSERT_TAB_COMMAND=xe,exports.INTERNAL_$isBlock=Wi,exports.IS_ALL_FORMATTING=2047,exports.IS_BOLD=1,exports.IS_CODE=16,exports.IS_HIGHLIGHT=y,exports.IS_ITALIC=2,exports.IS_STRIKETHROUGH=4,exports.IS_SUBSCRIPT=32,exports.IS_SUPERSCRIPT=64,exports.IS_UNDERLINE=8,exports.KEY_ARROW_DOWN_COMMAND=de,exports.KEY_ARROW_LEFT_COMMAND=ae,exports.KEY_ARROW_RIGHT_COMMAND=le,exports.KEY_ARROW_UP_COMMAND=fe,exports.KEY_BACKSPACE_COMMAND=_e,exports.KEY_DELETE_COMMAND=ye,exports.KEY_DOWN_COMMAND=se,exports.KEY_ENTER_COMMAND=he,exports.KEY_ESCAPE_COMMAND=pe,exports.KEY_MODIFIER_COMMAND=Fe,exports.KEY_SPACE_COMMAND=ge,exports.KEY_TAB_COMMAND=me,exports.LineBreakNode=Tn,exports.MOVE_TO_END=ce,exports.MOVE_TO_START=ue,exports.NODE_STATE_KEY="$",exports.OUTDENT_CONTENT_COMMAND=Se,exports.PASTE_COMMAND=Zt,exports.PASTE_TAG="paste",exports.ParagraphNode=uo,exports.REDO_COMMAND=ie,exports.REMOVE_TEXT_COMMAND=te,exports.RootNode=ro,exports.SELECTION_CHANGE_COMMAND=jt,exports.SELECTION_INSERT_CLIPBOARD_NODES_COMMAND=Ht,exports.SELECT_ALL_COMMAND=Me,exports.SKIP_COLLAB_TAG="skip-collab",exports.SKIP_DOM_SELECTION_TAG=Sn,exports.SKIP_SCROLL_INTO_VIEW_TAG=Cn,exports.SKIP_SELECTION_FOCUS_TAG=Nn,exports.TEXT_TYPE_TO_FORMAT=w,exports.TabNode=jn,exports.TextNode=In,exports.UNDO_COMMAND=oe,exports.buildImportMap=function(t){return t},exports.configExtension=function(...t){return t},exports.createCommand=Yt,exports.createEditor=function(t){const e=t||{},n=Br(),r=e.theme||{},o=void 0===t?n:e.parentEditor||null,i=e.disableEvents||!1,s=so(),l=e.namespace||(null!==o?o._config.namespace:Zo()),c=e.editorState,a=[ro,In,Tn,jn,uo,ao,...e.nodes||[]],{onError:u,html:f}=e,d=void 0===e.editable||e.editable;let h;if(void 0===t&&null!==n)h=n._nodes;else{h=new Map;for(let t=0;t{Object.keys(t).forEach(e=>{let r=n.get(e);void 0===r&&(r=[],n.set(e,r)),r.push(t[e])})};return t.forEach(t=>{const e=t.klass.importDOM;if(null==e||r.has(e))return;r.add(e);const n=e.call(t.klass);null!==n&&o(n)}),e&&o(e),n}(h,f?f.import:void 0),d,t);return void 0!==c&&(g._pendingEditorState=c,g._dirtyType=2),g},exports.createSharedNodeState=X,exports.createState=function(t,e){return new G(t,e)},exports.declarePeerDependency=function(t,e){return[t,e]},exports.defineExtension=function(t){return t},exports.flipDirection=ns,exports.getDOMOwnerDocument=Ci,exports.getDOMSelection=Ii,exports.getDOMSelectionFromTarget=Li,exports.getDOMTextNode=Io,exports.getEditorPropertyFromDOMNode=Mo,exports.getNearestEditorFromDOMNode=Oo,exports.getRegisteredNode=No,exports.getRegisteredNodeOrThrow=So,exports.getStaticNodeConfig=qi,exports.getTextDirection=function(t){return M.test(t)?"rtl":A.test(t)?"ltr":null},exports.getTransformSetFromKlass=po,exports.isBlockDomNode=zi,exports.isCurrentlyReadOnlyMode=Pr,exports.isDOMDocumentNode=Po,exports.isDOMNode=Ri,exports.isDOMTextNode=Do,exports.isDOMUnmanaged=Vi,exports.isDocumentFragment=Ki,exports.isExactShortcutMatch=si,exports.isHTMLAnchorElement=function(t){return Fi(t)&&"A"===t.tagName},exports.isHTMLElement=Fi,exports.isInlineDomNode=Bi,exports.isLexicalEditor=bo,exports.isModifierMatch=ii,exports.isSelectionCapturedInDecoratorInput=ko,exports.isSelectionWithinEditor=Eo,exports.makeStepwiseIterator=vs,exports.removeFromParent=Ro,exports.resetRandomKey=function(){Co=1},exports.safeCast=function(t){return t},exports.setDOMUnmanaged=function(t){t.__lexicalUnmanaged=!0},exports.setNodeIndentFromDOM=Hi,exports.shallowMergeConfig=function(t,e){if(!e||t===e)return t;for(const n in e)if(t[n]!==e[n])return{...t,...e};return t}; ++"use strict";function t(t,...e){const n=new URL("https://lexical.dev/docs/error"),r=new URLSearchParams;r.append("code",t);for(const t of e)r.append("v",t);throw n.search=r.toString(),Error(`Minified Lexical error #${t}; visit ${n.toString()} for the full message or use the non-minified dev environment for full errors and additional helpful warnings.`)}function e(t,...e){const n=new URL("https://lexical.dev/docs/error"),r=new URLSearchParams;r.append("code",t);for(const t of e)r.append("v",t);n.search=r.toString(),console.warn(`Minified Lexical warning #${t}; visit ${n.toString()} for the full message or use the non-minified dev environment for full errors and additional helpful warnings.`)}const n="undefined"!=typeof window&&void 0!==window.document&&void 0!==window.document.createElement,r=n&&"documentMode"in document?document.documentMode:null,o=n&&/Mac|iPod|iPhone|iPad/.test(navigator.platform),i=n&&/^(?!.*Seamonkey)(?=.*Firefox).*/i.test(navigator.userAgent),s=!(!n||!("InputEvent"in window)||r)&&"getTargetRanges"in new window.InputEvent("input"),l=n&&/Version\/[\d.]+.*Safari/.test(navigator.userAgent),c=n&&/iPad|iPhone|iPod/.test(navigator.userAgent)&&!window.MSStream,a=n&&/Android/.test(navigator.userAgent),u=n&&/^(?=.*Chrome).*/i.test(navigator.userAgent),f=n&&a&&u,d=n&&/AppleWebKit\/[\d.]+/.test(navigator.userAgent)&&o&&!u;function h(...t){const e=[];for(const n of t)if(n&&"string"==typeof n)for(const[t]of n.matchAll(/\S+/g))e.push(t);return e}const g=0,_=1,p=2,y=128,m=1,x=2,C=3,S=4,N=5,T=6,v=l||c||d?" ":"​",k="\n\n",E=i?" ":v,O="֑-߿יִ-﷽ﹰ-ﻼ",b="A-Za-zÀ-ÖØ-öø-ʸ̀-֐ࠀ-῿‎Ⰰ-﬜︀-﹯﻽-￿",M=new RegExp("^[^"+b+"]*["+O+"]"),A=new RegExp("^[^"+O+"]*["+b+"]"),w={bold:1,capitalize:1024,code:16,highlight:y,italic:2,lowercase:256,strikethrough:4,subscript:32,superscript:64,underline:8,uppercase:512},D={directionless:1,unmergeable:2},P={center:2,end:6,justify:4,left:1,right:3,start:5},I={[x]:"center",[T]:"end",[S]:"justify",[m]:"left",[C]:"right",[N]:"start"},R={normal:0,segmented:2,token:1},L={[g]:"normal",[p]:"segmented",[_]:"token"},F="$config";function K(t,e,n,r,o,i){let s=t.getFirstChild();for(;null!==s;){const t=s.__key;s.__parent===e&&(co(s)&&K(s,t,n,r,o,i),n.has(t)||i.delete(t),o.push(t)),s=s.getNextSibling()}}let B=!1,W=0;function z(t){W=t.timeStamp}function $(t,e,n){const r="BR"===t.nodeName,o=e.__lexicalLineBreak;return o&&(t===o||r&&t.previousSibling===o)||r&&void 0!==Zo(t,n)}function U(t,e,n){const r=Hi(n);let o=null,i=null;null!==r&&r.anchorNode===t&&(o=r.anchorOffset,i=r.focusOffset);const s=t.nodeValue;null!==s&&di(e,s,o,i,!1)}function j(t,e,n){if(ar(t)){const e=t.anchor.getNode();if(e.is(n)&&t.format!==e.getFormat())return!1}return $o(e)&&n.isAttached()}function J(t,e,n,r){for(let o=t;o&&!us(o);o=Ai(o)){const t=Zo(o,e);if(void 0!==t){const e=Xo(t,n);if(e)return fo(e)||!Qi(o)?void 0:[o,e]}else if(o===r)return[r,oi(n)]}}function Y(t,e,n){B=!0;const r=performance.now()-W>100;try{oo(t,()=>{const o=kr()||function(t){return t.getEditorState().read(()=>{const t=kr();return null!==t?t.clone():null})}(t),s=new Map,l=t.getRootElement(),c=t._editorState,a=t._blockCursorElement;let u=!1,f="";for(let n=0;n0){let e=0;for(let o=0;o0)for(const[e,n]of s)n.reconcileObservedMutation(e,t);const d=n.takeRecords();if(d.length>0){for(let e=0;e{Y(t,e,n)})}class G{key;parse;unparse;isEqual;defaultValue;constructor(t,e){this.key=t,this.parse=e.parse.bind(e),this.unparse=(e.unparse||nt).bind(e),this.isEqual=(e.isEqual||Object.is).bind(e),this.defaultValue=this.parse(void 0)}}function q(t,e,n="latest"){const r=("latest"===n?t.getLatest():t).__state;return r?r.getValue(e):e.defaultValue}function X(t){const e=new Map,n=new Set;for(let r="function"==typeof t?t:t.replace;r.prototype&&void 0!==r.prototype.getType;r=Object.getPrototypeOf(r)){const{ownNodeConfig:t}=ds(r);if(t&&t.stateConfigs)for(const r of t.stateConfigs){let t;"stateConfig"in r?(t=r.stateConfig,r.flat&&n.add(t.key)):t=r,e.set(t.key,t)}}return{flatKeys:n,sharedConfigMap:e}}class Q{node;knownState;unknownState;sharedNodeState;size;constructor(t,e,n=void 0,r=new Map,o=void 0){this.node=t,this.sharedNodeState=e,this.unknownState=n,this.knownState=r;const{sharedConfigMap:i}=this.sharedNodeState,s=void 0!==o?o:function(t,e,n){let r=n.size;if(e)for(const o in e){const e=t.get(o);e&&n.has(e)||r++}return r}(i,n,r);this.size=s}getValue(t){const e=this.knownState.get(t);if(void 0!==e)return e;this.sharedNodeState.sharedConfigMap.set(t.key,t);let n=t.defaultValue;if(this.unknownState&&t.key in this.unknownState){const e=this.unknownState[t.key];void 0!==e&&(n=t.parse(e)),this.updateFromKnown(t,n)}return n}getInternalState(){return[this.unknownState,this.knownState]}toJSON(){const t={...this.unknownState},e={};for(const[e,n]of this.knownState)e.isEqual(n,e.defaultValue)?delete t[e.key]:t[e.key]=e.unparse(n);for(const n of this.sharedNodeState.flatKeys)n in t&&(e[n]=t[n],delete t[n]);return et(t)&&(e.$=t),e}getWritable(t){if(this.node===t)return this;const{sharedNodeState:e,unknownState:n}=this,r=new Map(this.knownState);return new Q(t,e,function(t,e,n){let r;if(n)for(const[o,i]of Object.entries(n)){const n=t.get(o);n?e.has(n)||e.set(n,n.parse(i)):(r=r||{},r[o]=i)}return r}(e.sharedConfigMap,r,n),r,this.size)}updateFromKnown(t,e){const n=t.key;this.sharedNodeState.sharedConfigMap.set(n,t);const{knownState:r,unknownState:o}=this;r.has(t)||o&&n in o||(o&&(delete o[n],this.unknownState=et(o)),this.size++),r.set(t,e)}updateFromUnknown(t,e){const n=this.sharedNodeState.sharedConfigMap.get(t);n?this.updateFromKnown(n,n.parse(e)):(this.unknownState=this.unknownState||{},t in this.unknownState||this.size++,this.unknownState[t]=e)}updateFromJSON(t){const{knownState:e}=this;for(const t of e.keys())e.set(t,t.defaultValue);if(this.size=e.size,this.unknownState=void 0,t)for(const[e,n]of Object.entries(t))this.updateFromUnknown(e,n)}}function Z(t){const e=t.getWritable(),n=e.__state?e.__state.getWritable(e):new Q(e,tt(e));return e.__state=n,n}function tt(t){return t.__state?t.__state.sharedNodeState:wo(os(),t.getType()).sharedNodeState}function et(t){if(t)for(const e in t)return t}function nt(t){return t}function rt(t,e,n){for(const[r,o]of e.knownState){if(t.has(r.key))continue;t.add(r.key);const e=n?n.getValue(r):r.defaultValue;if(e!==o&&!r.isEqual(e,o))return!0}return!1}function ot(t,e,n){const{unknownState:r}=e,o=n?n.unknownState:void 0;if(r)for(const[e,n]of Object.entries(r)){if(t.has(e))continue;t.add(e);if(n!==(o?o[e]:void 0))return!0}return!1}function it(t,e){const n=t.__state;return n&&n.node===t?n.getWritable(e):n}function st(t,e){const n=t.__mode,r=t.__format,o=t.__style,i=e.__mode,s=e.__format,l=e.__style,c=t.__state,a=e.__state;return(null===n||n===i)&&(null===r||r===s)&&(null===o||o===l)&&(null===t.__state||c===a||function(t,e){if(t===e)return!0;if(t&&e&&t.size!==e.size)return!1;const n=new Set;return!(t&&rt(n,t,e)||e&&rt(n,e,t)||t&&ot(n,t,e)||e&&ot(n,e,t))}(c,a))}function lt(t,e){const n=t.mergeWithSibling(e),r=Yr()._normalizedNodes;return r.add(t.__key),r.add(e.__key),n}function ct(t){let e,n,r=t;if(""!==r.__text||!r.isSimpleText()||r.isUnmergeable()){for(;null!==(e=r.getPreviousSibling())&&Zn(e)&&e.isSimpleText()&&!e.isUnmergeable();){if(""!==e.__text){if(st(e,r)){r=lt(e,r);break}break}e.remove()}for(;null!==(n=r.getNextSibling())&&Zn(n)&&n.isSimpleText()&&!n.isUnmergeable();){if(""!==n.__text){if(st(r,n)){r=lt(r,n);break}break}n.remove()}}else r.remove()}function at(t){return ut(t.anchor),ut(t.focus),t}function ut(t){for(;"element"===t.type;){const e=t.getNode(),n=t.offset;let r,o;if(n===e.getChildrenSize()?(r=e.getChildAtIndex(n-1),o=!0):(r=e.getChildAtIndex(n),o=!1),Zn(r)){t.set(r.__key,o?r.getTextContentSize():0,"text",!0);break}if(!co(r))break;t.set(r.__key,o?r.getChildrenSize():0,"element",!0)}}let ft,dt,ht,gt,_t,pt,yt,mt,xt,Ct,St="",Nt=null,Tt=null,vt="",kt=!1,Et=!1;function Ot(t,e){const n=yt.get(t);if(null!==e){const n=jt(t);n.parentNode===e&&e.removeChild(n)}if(mt.has(t)||dt._keyToDOMMap.delete(t),co(n)){const t=Bt(n,yt);bt(t,0,t.length-1,null)}void 0!==n&&Ni(Ct,ht,gt,n,"destroyed")}function bt(t,e,n,r){let o=e;for(;o<=n;++o){const e=t[o];void 0!==e&&Ot(e,r)}}function Mt(t,e){t.setProperty("text-align",e)}const At="40px";function wt(t,e){const n=ft.theme.indent;if("string"==typeof n){const r=t.classList.contains(n);e>0&&!r?t.classList.add(n):e<1&&r&&t.classList.remove(n)}const r=getComputedStyle(t).getPropertyValue("--lexical-indent-base-value")||At;t.style.setProperty("padding-inline-start",0===e?"":`calc(${e} * ${r})`)}function Dt(t,e){const n=t.style;0===e?Mt(n,""):1===e?Mt(n,"left"):2===e?Mt(n,"center"):3===e?Mt(n,"right"):4===e?Mt(n,"justify"):5===e?Mt(n,"start"):6===e&&Mt(n,"end")}function Pt(t,e){const n=function(t){const e=t.__dir;if(null!==e)return e;if(go(t))return null;const n=t.getParentOrThrow();return go(n)&&null===n.__dir?"auto":null}(e);null!==n?t.dir=n:t.removeAttribute("dir")}function It(e,n){const r=mt.get(e);void 0===r&&t(60);const o=r.createDOM(ft,dt);if(function(t,e,n){const r=n._keyToDOMMap;(function(t,e,n){const r=`__lexicalKey_${e._key}`;t[r]=n})(e,n,t),r.set(t,e)}(e,o,dt),Zn(r)?o.setAttribute("data-lexical-text","true"):fo(r)&&o.setAttribute("data-lexical-decorator","true"),co(r)){const t=r.__indent,e=r.__size;if(Pt(o,r),0!==t&&wt(o,t),0!==e){const t=e-1;Rt(Bt(r,mt),r,0,t,r.getDOMSlot(o))}const n=r.__format;0!==n&&Dt(o,n),r.isInline()||Ft(null,r,o),Oi(r)&&(St+=k,vt+=k)}else{const t=r.getTextContent();if(fo(r)){const t=r.decorate(dt,ft);null!==t&&zt(e,t),o.contentEditable="false"}St+=t,vt+=t}return null!==n&&n.insertChild(o),Ni(Ct,ht,gt,r,"created"),o}function Rt(t,e,n,r,o){const i=St;St="";let s=n;for(;s<=r;++s){It(t[s],o);const e=mt.get(t[s]);null!==e&&Zn(e)&&null===Nt&&(Nt=e.getFormat(),Tt=e.getStyle())}Oi(e)&&(St+=k);o.element.__lexicalTextContent=St,St=i+St}function Lt(t,e){if(t){const n=t.__last;if(n){const t=e.get(n);if(t)return Rn(t)?"line-break":fo(t)&&t.isInline()?"decorator":null}return"empty"}return null}function Ft(t,e,n){const r=Lt(t,yt),o=Lt(e,mt);r!==o&&e.getDOMSlot(n).setManagedLineBreak(o)}function Kt(e,n,r){var o;Nt=null,Tt=null,function(e,n,r){const o=St,i=e.__size,s=n.__size;St="";const l=r.element;if(1===i&&1===s){const t=e.__first,r=n.__first;if(t===r)Wt(t,l);else{const e=jt(t),n=It(r,null);try{l.replaceChild(n,e)}catch(o){if("object"==typeof o&&null!=o){const i=`${o.toString()} Parent: ${l.tagName}, new child: {tag: ${n.tagName} key: ${r}}, old child: {tag: ${e.tagName}, key: ${t}}.`;throw new Error(i)}throw o}Ot(t,null)}const o=mt.get(r);Zn(o)&&null===Nt&&(Nt=o.getFormat(),Tt=o.getStyle())}else{const o=Bt(e,yt),c=Bt(n,mt);if(o.length!==i&&t(227),c.length!==s&&t(228),0===i)0!==s&&Rt(c,n,0,s-1,r);else if(0===s){if(0!==i){const t=null==r.after&&null==r.before&&null==r.element.__lexicalLineBreak;bt(o,0,i-1,t?null:l),t&&(l.textContent="")}}else!function(t,e,n,r,o,i){const s=r-1,l=o-1;let c,a,u=i.getFirstChild(),f=0,d=0;for(;f<=s&&d<=l;){const t=e[f],r=n[d];if(t===r)u=$t(Wt(r,i.element)),f++,d++;else{void 0===c&&(c=new Set(e)),void 0===a&&(a=new Set(n));const o=a.has(t),s=c.has(r);if(o)if(s){const t=bi(dt,r);t===u?u=$t(Wt(r,i.element)):(i.withBefore(u).insertChild(t),Wt(r,i.element)),f++,d++}else It(r,i.withBefore(u)),d++;else u=$t(jt(t)),Ot(t,i.element),f++}const o=mt.get(r);null!==o&&Zn(o)&&null===Nt&&(Nt=o.getFormat(),Tt=o.getStyle())}const h=f>s,g=d>l;if(h&&!g){const e=n[l+1],r=void 0===e?null:dt.getElementByKey(e);Rt(n,t,d,l,i.withBefore(r))}else g&&!h&&bt(e,f,s,i.element)}(n,o,c,i,s,r)}Oi(n)&&(St+=k);l.__lexicalTextContent=St,St=o+St}(e,n,n.getDOMSlot(r)),o=n,null==Nt||Nt===o.__textFormat||Et||o.setTextFormat(Nt),function(t){null==Tt||Tt===t.__textStyle||Et||t.setTextStyle(Tt)}(n)}function Bt(e,n){const r=[];let o=e.__first;for(;null!==o;){const e=n.get(o);void 0===e&&t(101),r.push(o),o=e.__next}return r}function Wt(e,n){const r=yt.get(e);let o=mt.get(e);void 0!==r&&void 0!==o||t(61);const i=kt||pt.has(e)||_t.has(e),s=bi(dt,e);if(r===o&&!i){if(co(r)){const t=s.__lexicalTextContent;void 0!==t&&(St+=t,vt+=t)}else{const t=r.getTextContent();vt+=t,St+=t}return s}if(r!==o&&i&&Ni(Ct,ht,gt,o,"updated"),o.updateDOM(r,s,ft)){const r=It(e,null);return null===n&&t(62),n.replaceChild(r,s),Ot(e,null),r}if(co(r)&&co(o)){const t=o.__indent;(kt||t!==r.__indent)&&wt(s,t);const e=o.__format;if((kt||e!==r.__format)&&Dt(s,e),i&&(Kt(r,o,s),go(o)||o.isInline()||Ft(r,o,s)),Oi(o)&&(St+=k,vt+=k),(kt||o.__dir!==r.__dir)&&(Pt(s,o),go(o)&&!kt))for(const t of o.getChildren())if(co(t)){Pt(bi(dt,t.getKey()),t)}}else{const t=o.getTextContent();if(fo(o)){const t=o.decorate(dt,ft);null!==t&&zt(e,t)}St+=t,vt+=t}if(!Et&&go(o)&&o.__cachedText!==vt){const t=o.getWritable();t.__cachedText=vt,o=t}return s}function zt(t,e){let n=dt._pendingDecorators;const r=dt._decorators;if(null===n){if(r[t]===e)return;n=ei(dt)}n[t]=e}function $t(t){let e=t.nextSibling;return null!==e&&e===dt._blockCursorElement&&(e=e.nextSibling),e}function Ut(t,e,n,r,o,i){St="",vt="",kt=2===r,dt=n,ft=n._config,ht=n._nodes,gt=dt._listeners.mutation,_t=o,pt=i,yt=t._nodeMap,mt=e._nodeMap,Et=e._readOnly,xt=new Map(n._keyToDOMMap);const s=new Map;return Ct=s,Wt("root",null),dt=void 0,ht=void 0,_t=void 0,pt=void 0,yt=void 0,mt=void 0,ft=void 0,xt=void 0,Ct=void 0,s}function jt(e){const n=xt.get(e);return void 0===n&&t(75,e),n}function Jt(t){return{type:t}}const Yt=Jt("SELECTION_CHANGE_COMMAND"),Ht=Jt("SELECTION_INSERT_CLIPBOARD_NODES_COMMAND"),Vt=Jt("CLICK_COMMAND"),Gt=Jt("BEFORE_INPUT_COMMAND"),qt=Jt("INPUT_COMMAND"),Xt=Jt("COMPOSITION_START_COMMAND"),Qt=Jt("COMPOSITION_END_COMMAND"),Zt=Jt("DELETE_CHARACTER_COMMAND"),te=Jt("INSERT_LINE_BREAK_COMMAND"),ee=Jt("INSERT_PARAGRAPH_COMMAND"),ne=Jt("CONTROLLED_TEXT_INSERTION_COMMAND"),re=Jt("PASTE_COMMAND"),oe=Jt("REMOVE_TEXT_COMMAND"),ie=Jt("DELETE_WORD_COMMAND"),se=Jt("DELETE_LINE_COMMAND"),le=Jt("FORMAT_TEXT_COMMAND"),ce=Jt("UNDO_COMMAND"),ae=Jt("REDO_COMMAND"),ue=Jt("KEYDOWN_COMMAND"),fe=Jt("KEY_ARROW_RIGHT_COMMAND"),de=Jt("MOVE_TO_END"),he=Jt("KEY_ARROW_LEFT_COMMAND"),ge=Jt("MOVE_TO_START"),_e=Jt("KEY_ARROW_UP_COMMAND"),pe=Jt("KEY_ARROW_DOWN_COMMAND"),ye=Jt("KEY_ENTER_COMMAND"),me=Jt("KEY_SPACE_COMMAND"),xe=Jt("KEY_BACKSPACE_COMMAND"),Ce=Jt("KEY_ESCAPE_COMMAND"),Se=Jt("KEY_DELETE_COMMAND"),Ne=Jt("KEY_TAB_COMMAND"),Te=Jt("INSERT_TAB_COMMAND"),ve=Jt("INDENT_CONTENT_COMMAND"),ke=Jt("OUTDENT_CONTENT_COMMAND"),Ee=Jt("DROP_COMMAND"),Oe=Jt("FORMAT_ELEMENT_COMMAND"),be=Jt("DRAGSTART_COMMAND"),Me=Jt("DRAGOVER_COMMAND"),Ae=Jt("DRAGEND_COMMAND"),we=Jt("COPY_COMMAND"),De=Jt("CUT_COMMAND"),Pe=Jt("SELECT_ALL_COMMAND"),Ie=Jt("CLEAR_EDITOR_COMMAND"),Re=Jt("CLEAR_HISTORY_COMMAND"),Le=Jt("CAN_REDO_COMMAND"),Fe=Jt("CAN_UNDO_COMMAND"),Ke=Jt("FOCUS_COMMAND"),Be=Jt("BLUR_COMMAND"),We=Jt("KEY_MODIFIER_COMMAND"),ze=Object.freeze({}),$e=[["keydown",function(t,e){if(Ue=t.timeStamp,je=t.key,e.isComposing())return;Ei(e,ue,t)}],["pointerdown",function(t,e){const n=t.target,r=t.pointerType;Zi(n)&&"touch"!==r&&"pen"!==r&&0===t.button&&oo(e,()=>{Io(n)||(qe=!0)})}],["compositionstart",function(t,e){Ei(e,Xt,t)}],["compositionend",function(t,e){i?Qe=!0:c||!l&&!d?Ei(e,Qt,t):(Ze=!0,tn=t.data)}],["input",function(t,e){t.stopPropagation(),oo(e,()=>{e.dispatchCommand(qt,t)},{event:t}),Ye=null}],["click",function(t,e){oo(e,()=>{const n=kr(),r=Hi(e),o=Er();if(r)if(ar(n)){const e=n.anchor,i=e.getNode();if("element"===e.type&&0===e.offset&&n.isCollapsed()&&!go(i)&&1===ri().getChildrenSize()&&i.getTopLevelElementOrThrow().isEmpty()&&null!==o&&n.is(o))r.removeAllRanges(),n.dirty=!0;else if(3===t.detail&&!n.isCollapsed()){if(i!==n.focus.getNode()){const t=hs(i,t=>co(t)&&!t.isInline());co(t)&&t.select(0)}}}else if("touch"===t.pointerType||"pen"===t.pointerType){const n=r.anchorNode;if(Qi(n)||$o(n)){ii(vr(o,r,e,t))}}Ei(e,Vt,t)})}],["cut",ze],["copy",ze],["dragstart",ze],["dragover",ze],["dragend",ze],["paste",ze],["focus",ze],["blur",ze],["drop",ze]];s&&$e.push(["beforeinput",(t,e)=>function(t,e){const n=t.inputType;if("deleteCompositionText"===n||i&&ki(e))return;if("insertCompositionText"===n)return;Ei(e,Gt,t)}(t,e)]);let Ue=0,je=null,Je=0,Ye=null;const He=new WeakMap,Ve=new WeakMap;let Ge=!1,qe=!1,Xe=!1,Qe=!1,Ze=!1,tn="",en=null,nn=[0,"",0,"root",0];function rn(t,e,n,r,o){const i=t.anchor,l=t.focus,c=i.getNode(),a=Yr(),u=Hi(a),f=null!==u?u.anchorNode:null,d=i.key,h=a.getElementByKey(d),g=n.length;return d!==l.key||!Zn(c)||(!o&&(!s||Je1||(o||!s)&&null!==h&&!c.isComposing()&&f!==jo(h)||null!==u&&null!==e&&(!e.collapsed||e.startContainer!==u.anchorNode||e.startOffset!==u.anchorOffset)||c.getFormat()!==t.format||c.getStyle()!==t.style||function(t,e){if(e.isSegmented())return!0;if(!t.isCollapsed())return!1;const n=t.anchor.offset,r=e.getParentOrThrow(),o=Wo(e);return 0===n?!e.canInsertTextBefore()||!r.canInsertTextBefore()&&!e.isComposing()||o||function(t){const e=t.getPreviousSibling();return(Zn(e)||co(e)&&e.isInline())&&!e.canInsertTextAfter()}(e):n===e.getTextContentSize()&&(!e.canInsertTextAfter()||!r.canInsertTextAfter()&&!e.isComposing()||o)}(t,c)}function on(t,e){return $o(t)&&null!==t.nodeValue&&0!==e&&e!==t.nodeValue.length}function sn(e,n,r){const{anchorNode:o,anchorOffset:i,focusNode:s,focusOffset:l}=e;Ge&&(Ge=!1,on(o,i)&&on(s,l)&&!en)||oo(n,()=>{if(!r)return void ii(null);if(!Lo(n,o,s))return;let c=kr();if(en&&ar(c)&&c.isCollapsed()){const t=c.anchor,e=en.anchor;(t.key===e.key&&t.offset===e.offset+1||1===t.offset&&e.getNode().is(t.getNode().getPreviousSibling()))&&(c=en.clone(),ii(c))}if(en=null,ar(c)){const r=c.anchor,o=r.getNode();if(c.isCollapsed()){"Range"===e.type&&e.anchorNode===e.focusNode&&(c.dirty=!0);const i=Li(n).event,s=i?i.timeStamp:performance.now(),[l,a,u,f,d]=nn,h=ri(),g=!1===n.isComposing()&&""===h.getTextContent();if(s{oo(o,()=>{Go(null)})},30),ar(i)){const e=i.anchor.getNode();e.markDirty(),Zn(e)||t(142),cn(i,e)}}else{Go(null),e.preventDefault();const t=i.anchor.getNode(),r=t.getTextContent(),s=t.canInsertTextAfter(),l=0===i.anchor.offset&&i.focus.offset===r.length;let c=f&&n&&!l&&s;if(c&&i.isCollapsed()&&(c=!fo(vi(i.anchor,!0))),!c){Ei(o,Zt,!0);const t=kr();f&&ar(t)&&t.isCollapsed()&&(en=t,setTimeout(()=>en=null))}}return!0}}var s;if(!ar(i))return!0;const l=e.data;null!==Ye&&fi(!1,o,Ye),i.dirty&&null===Ye||!i.isCollapsed()||go(i.anchor.getNode())||null===r||i.applyDOMRange(r),Ye=null;const a=i.anchor,u=i.focus,d=a.getNode(),h=u.getNode();if("insertText"===n||"insertTranspose"===n){if("\n"===l)e.preventDefault(),Ei(o,te,!1);else if(l===k)e.preventDefault(),Ei(o,ee,void 0);else if(null==l&&e.dataTransfer){const t=e.dataTransfer.getData("text/plain");e.preventDefault(),i.insertRawText(t)}else null!=l&&rn(i,r,l,e.timeStamp,!0)?(e.preventDefault(),Ei(o,ne,l)):Ye=l;return Je=e.timeStamp,!0}switch(e.preventDefault(),n){case"insertFromYank":case"insertFromDrop":case"insertReplacementText":Ei(o,ne,e);break;case"insertFromComposition":Go(null),Ei(o,ne,e);break;case"insertLineBreak":Go(null),Ei(o,te,!1);break;case"insertParagraph":Go(null),Xe&&!c?(Xe=!1,Ei(o,te,!1)):Ei(o,ee,void 0);break;case"insertFromPaste":case"insertFromPasteAsQuotation":Ei(o,re,e);break;case"deleteByComposition":(function(t,e){return t!==e||co(t)||co(e)||!Wo(t)||!Wo(e)})(d,h)&&Ei(o,oe,e);break;case"deleteByDrag":case"deleteByCut":Ei(o,oe,e);break;case"deleteContent":Ei(o,Zt,!1);break;case"deleteWordBackward":Ei(o,ie,!0);break;case"deleteWordForward":Ei(o,ie,!1);break;case"deleteHardLineBackward":case"deleteSoftLineBackward":Ei(o,se,!0);break;case"deleteContentForward":case"deleteHardLineForward":case"deleteSoftLineForward":Ei(o,se,!1);break;case"formatStrikeThrough":Ei(o,le,"strikethrough");break;case"formatBold":Ei(o,le,"bold");break;case"formatItalic":Ei(o,le,"italic");break;case"formatUnderline":Ei(o,le,"underline");break;case"historyUndo":Ei(o,ce,void 0);break;case"historyRedo":Ei(o,ae,void 0)}return!0}function fn(t){if(Qi(t.target)&&Io(t.target))return!0;const e=Yr(),n=kr(),r=t.data,o=an(t);if(null!=r&&ar(n)&&rn(n,o,r,t.timeStamp,!1)){Qe&&(gn(e,r),Qe=!1);const o=n.anchor.getNode(),a=Yi(Li(e));if(null===a)return!0;const u=n.isBackward(),f=u?n.anchor.offset:n.focus.offset,h=u?n.focus.offset:n.anchor.offset;s&&!n.isCollapsed()&&Zn(o)&&null!==a.anchorNode&&o.getTextContent().slice(0,f)+r+o.getTextContent().slice(f+h)===ui(a.anchorNode)||Ei(e,ne,r);const g=r.length;i&&g>1&&"insertCompositionText"===t.inputType&&!e.isComposing()&&(n.anchor.offset-=g),l||c||d||!e.isComposing()||(Ue=0,Go(null))}else{fi(!1,e,null!==r?r:void 0),Qe&&(gn(e,r||void 0),Qe=!1)}return function(){Ur();const t=Yr();H(t)}(),!0}function dn(t){const e=Yr(),n=kr();if(ar(n)&&!e.isComposing()){const r=n.anchor,o=n.anchor.getNode();Go(r.key),(t.timeStamp{gn(e,tn)}),Ze=!1,tn="",!0;if(function(t){return pi(t,"ArrowRight",{shiftKey:"any"})}(t))Ei(e,fe,t);else if(function(t){return pi(t,"ArrowRight",yi)}(t))Ei(e,de,t);else if(function(t){return pi(t,"ArrowLeft",{shiftKey:"any"})}(t))Ei(e,he,t);else if(function(t){return pi(t,"ArrowLeft",yi)}(t))Ei(e,ge,t);else if(function(t){return pi(t,"ArrowUp",{altKey:"any",shiftKey:"any"})}(t))Ei(e,_e,t);else if(function(t){return pi(t,"ArrowDown",{altKey:"any",shiftKey:"any"})}(t))Ei(e,pe,t);else if(function(t){return pi(t,"Enter",{altKey:"any",ctrlKey:"any",metaKey:"any",shiftKey:!0})}(t))Xe=!0,Ei(e,ye,t);else if(function(t){return" "===t.key}(t))Ei(e,me,t);else if(function(t){return o&&pi(t,"o",{ctrlKey:!0})}(t))t.preventDefault(),Xe=!0,Ei(e,te,!0);else if(function(t){return pi(t,"Enter",{altKey:"any",ctrlKey:"any",metaKey:"any"})}(t))Xe=!1,Ei(e,ye,t);else if(function(t){return pi(t,"Backspace",{shiftKey:"any"})||o&&pi(t,"h",{ctrlKey:!0})}(t))xi(t)?Ei(e,xe,t):(t.preventDefault(),Ei(e,Zt,!0));else if(function(t){return"Escape"===t.key}(t))Ei(e,Ce,t);else if(function(t){return pi(t,"Delete",{})||o&&pi(t,"d",{ctrlKey:!0})}(t))!function(t){return"Delete"===t.key}(t)?(t.preventDefault(),Ei(e,Zt,!1)):Ei(e,Se,t);else if(function(t){return pi(t,"Backspace",mi)}(t))t.preventDefault(),Ei(e,ie,!0);else if(function(t){return pi(t,"Delete",mi)}(t))t.preventDefault(),Ei(e,ie,!1);else if(function(t){return o&&pi(t,"Backspace",{metaKey:!0})}(t))t.preventDefault(),Ei(e,se,!0);else if(function(t){return o&&(pi(t,"Delete",{metaKey:!0})||pi(t,"k",{ctrlKey:!0}))}(t))t.preventDefault(),Ei(e,se,!1);else if(function(t){return pi(t,"b",yi)}(t))t.preventDefault(),Ei(e,le,"bold");else if(function(t){return pi(t,"u",yi)}(t))t.preventDefault(),Ei(e,le,"underline");else if(function(t){return pi(t,"i",yi)}(t))t.preventDefault(),Ei(e,le,"italic");else if(function(t){return pi(t,"Tab",{shiftKey:"any"})}(t))Ei(e,Ne,t);else if(function(t){return pi(t,"z",yi)}(t))t.preventDefault(),Ei(e,ce,void 0);else if(function(t){if(o)return pi(t,"z",{metaKey:!0,shiftKey:!0});return pi(t,"y",{ctrlKey:!0})||pi(t,"z",{ctrlKey:!0,shiftKey:!0})}(t))t.preventDefault(),Ei(e,ae,void 0);else{const n=e._editorState._selection;null===n||ar(n)?Ci(t)&&(t.preventDefault(),Ei(e,Pe,t)):!function(t){return pi(t,"c",yi)}(t)?!function(t){return pi(t,"x",yi)}(t)?Ci(t)&&(t.preventDefault(),Ei(e,Pe,t)):(t.preventDefault(),Ei(e,De,t)):(t.preventDefault(),Ei(e,we,t))}return function(t){return t.ctrlKey||t.shiftKey||t.altKey||t.metaKey}(t)&&e.dispatchCommand(We,t),!0}function pn(t){let e=t.__lexicalEventHandles;return void 0===e&&(e=[],t.__lexicalEventHandles=e),e}const yn=new Map;function mn(t){const e=Xi(t.target);if(null===e)return;const n=Ko(e.anchorNode);if(null===n)return;qe&&(qe=!1,oo(n,()=>{const r=Er(),o=e.anchorNode;if(Qi(o)||$o(o)){ii(vr(r,e,n,t))}}));const r=ci(n),o=r[r.length-1],i=o._key,s=yn.get(i),l=s||o;l!==n&&sn(e,l,!1),sn(e,n,!0),n!==o?yn.set(i,n):s&&yn.delete(i)}function xn(t){t._lexicalHandled=!0}function Cn(t){return!0===t._lexicalHandled}const Sn=()=>{};function Nn(e){const n=Vi(e);if(void 0===n)return void Sn();const r=Ve.get(n);if(void 0===r)return void Sn();const o=r-1;o>=0||t(164),He.delete(e),Ve.set(n,o),0===o&&n.removeEventListener("selectionchange",mn);const i=Bo(e);Fo(i)?(!function(t){if(null!==t._parentEditor){const e=ci(t),n=e[e.length-1]._key;yn.get(n)===t&&yn.delete(n)}else yn.delete(t._key)}(i),e.__lexicalEditor=null):i&&t(198);const s=pn(e);for(let t=0;tt.__key===this.__key);if(Zn(this))return n;if(ar(e)&&"element"===e.anchor.type&&"element"===e.focus.type){if(e.isCollapsed())return!1;const t=this.getParent();if(fo(this)&&this.isInline()&&t){const n=e.isBackward()?e.focus:e.anchor;if(t.is(n.getNode())&&n.offset===t.getChildrenSize()&&this.is(t.getLastChild()))return!1}}return n}getKey(){return this.__key}getIndexWithinParent(){const t=this.getParent();if(null===t)return-1;let e=t.getFirstChild(),n=0;for(;null!==e;){if(this.is(e))return n;n++,e=e.getNextSibling()}return-1}getParent(){const t=this.getLatest().__parent;return null===t?null:Xo(t)}getParentOrThrow(){const e=this.getParent();return null===e&&t(66,this.__key),e}getTopLevelElement(){let e=this;for(;null!==e;){const n=e.getParent();if(Ki(n))return co(e)||e===this&&fo(e)||t(194),e;e=n}return null}getTopLevelElementOrThrow(){const e=this.getTopLevelElement();return null===e&&t(67,this.__key),e}getParents(){const t=[];let e=this.getParent();for(;null!==e;)t.push(e),e=e.getParent();return t}getParentKeys(){const t=[];let e=this.getParent();for(;null!==e;)t.push(e.__key),e=e.getParent();return t}getPreviousSibling(){const t=this.getLatest().__prev;return null===t?null:Xo(t)}getPreviousSiblings(){const t=[],e=this.getParent();if(null===e)return t;let n=e.getFirstChild();for(;null!==n&&!n.is(this);)t.push(n),n=n.getNextSibling();return t}getNextSibling(){const t=this.getLatest().__next;return null===t?null:Xo(t)}getNextSiblings(){const t=[];let e=this.getNextSibling();for(;null!==e;)t.push(e),e=e.getNextSibling();return t}getCommonAncestor(t){const e=co(this)?this:this.getParent(),n=co(t)?t:t.getParent(),r=e&&n?Js(e,n):null;return r?r.commonAncestor:null}is(t){return null!=t&&this.__key===t.__key}isBefore(e){const n=Js(this,e);return null!==n&&("descendant"===n.type||("branch"===n.type?-1===$s(n):("same"!==n.type&&"ancestor"!==n.type&&t(279),!1)))}isParentOf(t){const e=Js(this,t);return null!==e&&"ancestor"===e.type}getNodesBetween(e){const n=this.isBefore(e),r=[],o=new Set;let i=this;for(;null!==i;){const s=i.__key;if(o.has(s)||(o.add(s),r.push(i)),i===e)break;const l=co(i)?n?i.getFirstChild():i.getLastChild():null;if(null!==l){i=l;continue}const c=n?i.getNextSibling():i.getPreviousSibling();if(null!==c){i=c;continue}const a=i.getParentOrThrow();if(o.has(a.__key)||r.push(a),a===e)break;let u=null,f=a;do{if(null===f&&t(68),u=n?f.getNextSibling():f.getPreviousSibling(),f=f.getParent(),null===f)break;null!==u||o.has(f.__key)||r.push(f)}while(null===u);i=u}return n||r.reverse(),r}isDirty(){const t=Yr()._dirtyLeaves;return null!==t&&t.has(this.__key)}getLatest(){if(kn(this))return this;const e=Xo(this.__key);return null===e&&t(113),e}getWritable(){if(kn(this))return this;Ur();const t=Jr(),e=Yr(),n=t._nodeMap,r=this.__key,o=this.getLatest(),i=e._cloneNotNeeded,s=kr();if(null!==s&&s.setCachedNodes(null),i.has(r))return Vo(o),o;const l=cs(o);return i.add(r),Vo(l),n.set(r,l),l}getTextContent(){return""}getTextContentSize(){return this.getTextContent().length}createDOM(e,n){t(70)}updateDOM(e,n,r){t(71)}exportDOM(t){return{element:this.createDOM(t._config,t)}}exportJSON(){const t=this.__state?this.__state.toJSON():void 0;return{type:this.__type,version:1,...t}}static importJSON(e){t(18,this.name)}updateFromJSON(t){return function(t,e){const n=t.getWritable(),r=e.$;let o=r;for(const t of tt(n).flatKeys)t in e&&(void 0!==o&&o!==r||(o={...r}),o[t]=e[t]);return(n.__state||o)&&Z(t).updateFromJSON(o),n}(this,t)}static transform(){return null}remove(t){Tn(this,!0,t)}replace(e,n){Ur();let r=kr();null!==r&&(r=r.clone()),zi(this,e);const o=this.getLatest(),i=this.__key,s=e.__key,l=e.getWritable(),c=this.getParentOrThrow().getWritable(),a=c.__size;Ho(l);const u=o.getPreviousSibling(),f=o.getNextSibling(),d=o.__prev,h=o.__next,g=o.__parent;if(Tn(o,!1,!0),null===u)c.__first=s;else{u.getWritable().__next=s}if(l.__prev=d,null===f)c.__last=s;else{f.getWritable().__prev=s}if(l.__next=h,l.__parent=g,c.__size=a,n&&(co(this)&&co(l)||t(139),this.getChildren().forEach(t=>{l.append(t)})),ar(r)){ii(r);const t=r.anchor,e=r.focus;t.key===i&&lr(t,l),e.key===i&&lr(e,l)}return qo()===i&&Go(s),l}insertAfter(t,e=!0){Ur(),zi(this,t);const n=this.getWritable(),r=t.getWritable(),o=r.getParent(),i=kr();let s=!1,l=!1;if(null!==o){const e=t.getIndexWithinParent();if(Ho(r),ar(i)){const t=o.__key,n=i.anchor,r=i.focus;s="element"===n.type&&n.key===t&&n.offset===e+1,l="element"===r.type&&r.key===t&&r.offset===e+1}}const c=this.getNextSibling(),a=this.getParentOrThrow().getWritable(),u=r.__key,f=n.__next;if(null===c)a.__last=u;else{c.getWritable().__prev=u}if(a.__size++,n.__next=u,r.__next=f,r.__prev=n.__key,r.__parent=n.__parent,e&&ar(i)){const t=this.getIndexWithinParent();Or(i,a,t+1);const e=a.__key;s&&i.anchor.set(e,t+2,"element"),l&&i.focus.set(e,t+2,"element")}return t}insertBefore(t,e=!0){Ur(),zi(this,t);const n=this.getWritable(),r=t.getWritable(),o=r.__key;Ho(r);const i=this.getPreviousSibling(),s=this.getParentOrThrow().getWritable(),l=n.__prev,c=this.getIndexWithinParent();if(null===i)s.__first=o;else{i.getWritable().__next=o}s.__size++,n.__prev=o,r.__prev=l,r.__next=n.__key,r.__parent=n.__parent;const a=kr();if(e&&ar(a)){Or(a,this.getParentOrThrow(),c)}return t}isParentRequired(){return!1}createParentElementNode(){return No()}selectStart(){return this.selectPrevious()}selectEnd(){return this.selectNext(0,0)}selectPrevious(t,e){Ur();const n=this.getPreviousSibling(),r=this.getParentOrThrow();if(null===n)return r.select(0,0);if(co(n))return n.select();if(!Zn(n)){const t=n.getIndexWithinParent()+1;return r.select(t,t)}return n.select(t,e)}selectNext(t,e){Ur();const n=this.getNextSibling(),r=this.getParentOrThrow();if(null===n)return r.select();if(co(n))return n.select(0,0);if(!Zn(n)){const t=n.getIndexWithinParent();return r.select(t,t)}return n.select(t,e)}markDirty(){this.getWritable()}reconcileObservedMutation(t,e){this.markDirty()}}const On="history-merge",bn="collaboration",Mn="skip-scroll-into-view",An="skip-dom-selection",wn="skip-selection-focus";class Dn extends En{static getType(){return"linebreak"}static clone(t){return new Dn(t.__key)}constructor(t){super(t)}getTextContent(){return"\n"}createDOM(){return document.createElement("br")}updateDOM(){return!1}isInline(){return!0}static importDOM(){return{br:t=>function(t){const e=t.parentElement;if(null!==e&&ns(e)){const n=e.firstChild;if(n===t||n.nextSibling===t&&Ln(n)){const n=e.lastChild;if(n===t||n.previousSibling===t&&Ln(n))return!0}}return!1}(t)||function(t){const e=t.parentElement;if(null!==e&&ns(e)){const n=e.firstChild;if(n===t||n.nextSibling===t&&Ln(n))return!1;const r=e.lastChild;if(r===t||r.previousSibling===t&&Ln(r))return!0}return!1}(t)?null:{conversion:Pn,priority:0}}}static importJSON(t){return In().updateFromJSON(t)}}function Pn(t){return{node:In()}}function In(){return Wi(new Dn)}function Rn(t){return t instanceof Dn}function Ln(t){return $o(t)&&/^( |\t|\r?\n)+$/.test(t.textContent||"")}function Fn(t,e){return 16&e?"code":e&y?"mark":32&e?"sub":64&e?"sup":null}function Kn(t,e){return 1&e?"strong":2&e?"em":"span"}function Bn(t,e,n,r,o){const i=r.classList;let s=Si(o,"base");void 0!==s&&i.add(...s),s=Si(o,"underlineStrikethrough");let l=!1;const c=8&e&&4&e;void 0!==s&&(8&n&&4&n?(l=!0,c||i.add(...s)):c&&i.remove(...s));for(const t in w){const r=w[t];if(s=Si(o,t),void 0!==s)if(n&r){if(l&&("underline"===t||"strikethrough"===t)){e&r&&i.remove(...s);continue}(0===(e&r)||c&&"underline"===t||"strikethrough"===t)&&i.add(...s)}else e&r&&i.remove(...s)}}function Wn(t,e,n){const r=e.firstChild,o=n.isComposing(),s=t+(o?v:"");if(null==r)e.textContent=s;else{const t=r.nodeValue;if(t!==s)if(o||i){const[e,n,o]=function(t,e){const n=t.length,r=e.length;let o=0,i=0;for(;o({conversion:Vn,priority:0}),b:()=>({conversion:Jn,priority:0}),code:()=>({conversion:Xn,priority:0}),em:()=>({conversion:Xn,priority:0}),i:()=>({conversion:Xn,priority:0}),mark:()=>({conversion:Xn,priority:0}),s:()=>({conversion:Xn,priority:0}),span:()=>({conversion:jn,priority:0}),strong:()=>({conversion:Xn,priority:0}),sub:()=>({conversion:Xn,priority:0}),sup:()=>({conversion:Xn,priority:0}),u:()=>({conversion:Xn,priority:0})}}static importJSON(t){return Qn().updateFromJSON(t)}updateFromJSON(t){return super.updateFromJSON(t).setTextContent(t.text).setFormat(t.format).setDetail(t.detail).setMode(t.mode).setStyle(t.style)}exportDOM(e){let{element:n}=super.exportDOM(e);return Qi(n)||t(132),n.style.whiteSpace="pre-wrap",this.hasFormat("lowercase")?n.style.textTransform="lowercase":this.hasFormat("uppercase")?n.style.textTransform="uppercase":this.hasFormat("capitalize")&&(n.style.textTransform="capitalize"),this.hasFormat("bold")&&(n=$n(n,"b")),this.hasFormat("italic")&&(n=$n(n,"i")),this.hasFormat("strikethrough")&&(n=$n(n,"s")),this.hasFormat("underline")&&(n=$n(n,"u")),{element:n}}exportJSON(){return{detail:this.getDetail(),format:this.getFormat(),mode:this.getMode(),style:this.getStyle(),text:this.getTextContent(),...super.exportJSON()}}selectionTransform(t,e){}setFormat(t){const e=this.getWritable();return e.__format="string"==typeof t?w[t]:t,e}setDetail(t){const e=this.getWritable();return e.__detail="string"==typeof t?D[t]:t,e}setStyle(t){const e=this.getWritable();return e.__style=t,e}toggleFormat(t){const e=Jo(this.getFormat(),t,null);return this.setFormat(e)}toggleDirectionless(){const t=this.getWritable();return t.__detail^=1,t}toggleUnmergeable(){const t=this.getWritable();return t.__detail^=2,t}setMode(t){const e=R[t];if(this.__mode===e)return this;const n=this.getWritable();return n.__mode=e,n}setTextContent(t){if(this.__text===t)return this;const e=this.getWritable();return e.__text=t,e}select(t,e){Ur();let n=t,r=e;const o=kr(),i=this.getTextContent(),s=this.__key;if("string"==typeof i){const t=i.length;void 0===n&&(n=t),void 0===r&&(r=t)}else n=0,r=0;if(!ar(o))return Sr(s,n,s,r,"text","text");{const t=qo();t!==o.anchor.key&&t!==o.focus.key||Go(s),o.setTextNodeRange(this,n,this,r)}return o}selectStart(){return this.select(0,0)}selectEnd(){const t=this.getTextContentSize();return this.select(t,t)}spliceText(t,e,n,r){const o=this.getWritable(),i=o.__text,s=n.length;let l=t;l<0&&(l=s+l,l<0&&(l=0));const c=kr();if(r&&ar(c)){const e=t+s;c.setTextNodeRange(o,e,o,e)}const a=i.slice(0,l)+n+i.slice(l+e);return o.__text=a,o}canInsertTextBefore(){return!0}canInsertTextAfter(){return!0}splitText(...t){Ur();const e=this.getLatest(),n=e.getTextContent();if(""===n)return[];const r=e.__key,o=qo(),i=n.length;t.sort((t,e)=>t-e),t.push(i);const s=[],l=t.length;for(let e=0,r=0;ee&&(s.push(n.slice(e,o)),e=o)}const c=s.length;if(1===c)return[e];const a=s[0],u=e.getParent();let f;const d=e.getFormat(),h=e.getStyle(),g=e.__detail;let _=!1,p=null,y=null;const m=kr();if(ar(m)){const[t,e]=m.isBackward()?[m.focus,m.anchor]:[m.anchor,m.focus];"text"===t.type&&t.key===r&&(p=t),"text"===e.type&&e.key===r&&(y=e)}e.isSegmented()?(f=Qn(a),f.__format=d,f.__style=h,f.__detail=g,f.__state=it(e,f),_=!0):f=e.setTextContent(a);const x=[f];for(let t=1;t=N&&(p.set(t.getKey(),C-N,"text"),C=N){y.set(t.getKey(),S-N,"text");break}N=e}if(null!==u){!function(t){const e=t.getPreviousSibling(),n=t.getNextSibling();null!==e&&Vo(e);null!==n&&Vo(n)}(this);const t=u.getWritable(),e=this.getIndexWithinParent();_?(t.splice(e,0,x),this.remove()):t.splice(e,1,x),ar(m)&&Or(m,u,e,c-1)}return x}mergeWithSibling(e){const n=e===this.getPreviousSibling();n||e===this.getNextSibling()||t(50);const r=this.__key,o=e.__key,i=this.__text,s=i.length;qo()===o&&Go(r);const l=kr();if(ar(l)){const t=l.anchor,i=l.focus;null!==t&&t.key===o&&Ar(t,n,r,e,s),null!==i&&i.key===o&&Ar(i,n,r,e,s)}const c=e.__text,a=n?c+i:i+c;this.setTextContent(a);const u=this.getWritable();return e.remove(),u}isTextEntity(){return!1}}function jn(t){return{forChild:tr(t.style),node:null}}function Jn(t){const e=t,n="normal"===e.style.fontWeight;return{forChild:tr(e.style,n?void 0:"bold"),node:null}}const Yn=new WeakMap;function Hn(t){if(!Qi(t))return!1;if("PRE"===t.nodeName)return!0;const e=t.style.whiteSpace;return"string"==typeof e&&e.startsWith("pre")}function Vn(e){const n=e;null===e.parentElement&&t(129);let r=n.textContent||"";if(null!==function(t){let e,n=t.parentNode;const r=[t];for(;null!==n&&void 0===(e=Yn.get(n))&&!Hn(n);)r.push(n),n=n.parentNode;const o=void 0===e?n:e;for(let t=0;t0){/[ \t\n]$/.test(n)&&(r=r.slice(1)),e=!1;break}}e&&(r=r.slice(1))}if(" "===r[r.length-1]){let t=n,e=!0;for(;null!==t&&null!==(t=Gn(t,!0));){if((t.textContent||"").replace(/^( |\t|\r?\n)+/,"").length>0){e=!1;break}}e&&(r=r.slice(0,r.length-1))}return""===r?{node:null}:{node:Qn(r)}}function Gn(t,e){let n=t;for(;;){let t;for(;null===(t=e?n.nextSibling:n.previousSibling);){const t=n.parentElement;if(null===t)return null;n=t}if(n=t,Qi(n)){const t=n.style.display;if(""===t&&!es(n)||""!==t&&!t.startsWith("inline"))return null}let r=n;for(;null!==(r=e?n.firstChild:n.lastChild);)n=r;if($o(n))return n;if("BR"===n.nodeName)return null}}const qn={code:"code",em:"italic",i:"italic",mark:"highlight",s:"strikethrough",strong:"bold",sub:"subscript",sup:"superscript",u:"underline"};function Xn(t){const e=qn[t.nodeName.toLowerCase()];return void 0===e?{node:null}:{forChild:tr(t.style,e),node:null}}function Qn(t=""){return Wi(new Un(t))}function Zn(t){return t instanceof Un}function tr(t,e){const n=t.fontWeight,r=t.textDecoration.split(" "),o="700"===n||"bold"===n,i=r.includes("line-through"),s="italic"===t.fontStyle,l=r.includes("underline"),c=t.verticalAlign;return t=>Zn(t)?(o&&!t.hasFormat("bold")&&t.toggleFormat("bold"),i&&!t.hasFormat("strikethrough")&&t.toggleFormat("strikethrough"),s&&!t.hasFormat("italic")&&t.toggleFormat("italic"),l&&!t.hasFormat("underline")&&t.toggleFormat("underline"),"sub"!==c||t.hasFormat("subscript")||t.toggleFormat("subscript"),"super"!==c||t.hasFormat("superscript")||t.toggleFormat("superscript"),e&&!t.hasFormat(e)&&t.toggleFormat(e),t):t}class er extends Un{static getType(){return"tab"}static clone(t){return new er(t.__key)}constructor(t){super("\t",t),this.__detail=2}static importDOM(){return null}createDOM(t){const e=super.createDOM(t),n=Si(t.theme,"tab");if(void 0!==n){e.classList.add(...n)}return e}static importJSON(t){return nr().updateFromJSON(t)}setTextContent(t){return"\t"!==t&&""!==t&&e(126),super.setTextContent("\t")}spliceText(e,n,r,o){return""===r&&0===n||"\t"===r&&1===n||t(286),this}setDetail(e){return 2!==e&&t(127),this}setMode(e){return"normal"!==e&&t(128),this}canInsertTextBefore(){return!1}canInsertTextAfter(){return!1}}function nr(){return Wi(new er)}function rr(t){return t instanceof er}class or{key;offset;type;_selection;constructor(t,e,n){this._selection=null,this.key=t,this.offset=e,this.type=n}is(t){return this.key===t.key&&this.offset===t.offset&&this.type===t.type}isBefore(t){if(this.key===t.key)return this.offsett&&(r=t)}else if(!co(e)){const t=e.getNextSibling();if(Zn(t))n=t.__key,r=0,o="text";else{const t=e.getParent();t&&(n=t.__key,r=e.getIndexWithinParent()+1)}}t.set(n,r,o)}function lr(t,e){if(co(e)){const n=e.getLastDescendant();co(n)||Zn(n)?sr(t,n):sr(t,e)}else sr(t,e)}class cr{_nodes;_cachedNodes;dirty;constructor(t){this._cachedNodes=null,this._nodes=t,this.dirty=!1}getCachedNodes(){return this._cachedNodes}setCachedNodes(t){this._cachedNodes=t}is(t){if(!fr(t))return!1;const e=this._nodes,n=t._nodes;return e.size===n.size&&Array.from(e).every(t=>n.has(t))}isCollapsed(){return!1}isBackward(){return!1}getStartEndPoints(){return null}add(t){this.dirty=!0,this._nodes.add(t),this._cachedNodes=null}delete(t){this.dirty=!0,this._nodes.delete(t),this._cachedNodes=null}clear(){this.dirty=!0,this._nodes.clear(),this._cachedNodes=null}has(t){return this._nodes.has(t)}clone(){return new cr(new Set(this._nodes))}extract(){return this.getNodes()}insertRawText(t){}insertText(){}insertNodes(t){const e=this.getNodes(),n=e.length,r=e[n-1];let o;if(Zn(r))o=r.select();else{const t=r.getIndexWithinParent()+1;o=r.getParentOrThrow().select(t,t)}o.insertNodes(t);for(let t=0;t1;){const t=e[e.length-1];if(!co(t)||i.has(t)||t.isEmpty()||o.has(t))break;e.pop()}if(0===e.length&&t.isCollapsed()){const n=el(t.anchor),r=el(t.anchor.getFlipped()),o=t=>Ns(t)?t.origin:t.getNodeAtCaret(),i=o(n)||o(r)||(t.anchor.getNodeAtCaret()?n.origin:r.origin);e.push(i)}return e}(ol(qs(this),"next"));return $r()||(this._cachedNodes=e),e}setTextNodeRange(t,e,n,r){this.anchor.set(t.__key,e,"text"),this.focus.set(n.__key,r,"text")}getTextContent(){const t=this.getNodes();if(0===t.length)return"";const e=t[0],n=t[t.length-1],r=this.anchor,o=this.focus,i=r.isBefore(o),[s,l]=hr(this);let c="",a=!0;for(let u=0;u=0;t--){const e=i[t];if(e.is(d)||co(e)&&e.isParentOf(d))break;e.isAttached()&&(!s.has(e)||e.is(o)?g||p.insertAfter(e,!1):e.remove())}if(!g){let e=r,n=null;for(;null!==e;){const r=e.getChildren(),o=r.length;(0===o||r[o-1].is(n))&&(t.delete(e.__key),n=e),e=e.getParent()}}if(Wo(d))if(c===h)d.select();else{const t=Qn(e);t.select(),d.replace(t)}else d=d.spliceText(c,h-c,e,!0),""===d.getTextContent()?d.remove():d.isComposing()&&"text"===this.anchor.type&&(this.anchor.offset-=e.length);for(let e=1;e{n.forEach(n=>{if(co(n)){const r=n.getFormatFlags(t,e);n.setTextFormat(r)}})},i=r.length;if(0===i)return this.toggleFormat(t),Go(null),void o(e);const s=this.anchor,l=this.focus,c=this.isBackward(),a=c?l:s,u=c?s:l;let f=0,d=r[0],h="element"===a.type?0:a.offset;if("text"===a.type&&h===d.getTextContentSize()&&(f=1,d=r[1],h=0),null==d)return;const g=d.getFormatFlags(t,e);o(g);const _=i-1;let p=r[_];const y="text"===u.type?u.offset:p.getTextContentSize();if(d.is(p)){if(h===y)return;if(zo(d)||0===h&&y===d.getTextContentSize())d.setFormat(g);else{const t=d.splitText(h,y),e=0===h?t[0]:t[1];e.setFormat(g),"text"===a.type&&a.set(e.__key,0,"text"),"text"===u.type&&u.set(e.__key,y-h,"text")}return void(this.format=g)}0===h||zo(d)||([,d]=d.splitText(h),h=0),d.setFormat(g);const m=p.getFormatFlags(t,g);y>0&&(y===p.getTextContentSize()||zo(p)||([p]=p.splitText(y)),p.setFormat(m));for(let e=f+1;e<_;e++){const n=r[e],o=n.getFormatFlags(t,m);n.setFormat(o)}"text"===a.type&&a.set(d.__key,h,"text"),"text"===u.type&&u.set(p.__key,y,"text"),this.format=g|m}insertNodes(e){if(0===e.length)return;if(this.isCollapsed()||this.removeText(),"root"===this.anchor.key){this.insertParagraph();const n=kr();return ar(n)||t(134),n.insertNodes(e)}const n=(this.isBackward()?this.focus:this.anchor).getNode(),r=hs(n,rs),o=e[e.length-1];if(co(r)&&"__language"in r){if("__language"in e[0])this.insertText(e[0].getTextContent());else{const t=Pr(this);r.splice(t,0,e),o.selectEnd()}return}if(!e.some(t=>(co(t)||fo(t))&&!t.isInline())){co(r)||t(211,n.constructor.name,n.getType());const i=Pr(this);return r.splice(i,0,e),void o.selectEnd()}const i=function(t){const e=No();let n=null;for(let r=0;r0){const t=i.getRangeAt(0),n=this.anchor.getNode(),o=go(n)?n:Fi(n);if(this.applyDOMRange(t),this.dirty=!0,!r){const n=this.getNodes(),r=[];let s=!1;for(let t=0;t0)if(e){const t=r[0];co(t)?t.selectStart():t.getParentOrThrow().selectStart()}else{const t=r[r.length-1];co(t)?t.selectEnd():t.getParentOrThrow().selectEnd()}i.anchorNode===t.startContainer&&i.anchorOffset===t.startOffset||function(t){const e=t.focus,n=t.anchor,r=n.key,o=n.offset,i=n.type;n.set(e.key,e.offset,e.type,!0),e.set(r,o,i,!0)}(this)}}"lineboundary"===n&&Rr(this,t,e,n,"decorators")}forwardDeletion(t,e,n){if(!n&&("element"===t.type&&co(e)&&t.offset===e.getChildrenSize()||"text"===t.type&&t.offset===e.getTextContentSize())){const t=e.getParent(),n=e.getNextSibling()||(null===t?null:t.getNextSibling());if(co(n)&&n.isShadowRoot())return!0}return!1}deleteCharacter(t){const e=this.isCollapsed();if(this.isCollapsed()){const e=this.anchor;let n=e.getNode();if(this.forwardDeletion(e,n,t))return;const r=Fs(Ys(e,t?"previous":"next"));if(r.getTextSlices().every(t=>null===t||0===t.distance)){let t={type:"initial"};for(const e of r.iterNodeCarets("shadowRoot"))if(vs(e))if(e.origin.isInline());else{if(e.origin.isShadowRoot()){if("merge-block"===t.type)break;if(co(r.anchor.origin)&&r.anchor.origin.isEmpty()){const t=el(e);Gs(this,Bs(t,t)),r.anchor.origin.remove()}return}"merge-next-block"!==t.type&&"merge-block"!==t.type||(t={block:t.block,caret:e,type:"merge-block"})}else{if("merge-block"===t.type)break;if(Ts(e)){if(co(e.origin)){if(e.origin.isInline()){if(!e.origin.isParentOf(r.anchor.origin))break}else t={block:e.origin,type:"merge-next-block"};continue}if(fo(e.origin)){if(e.origin.isIsolated());else if("merge-next-block"===t.type&&(e.origin.isKeyboardSelectable()||!e.origin.isInline())&&co(r.anchor.origin)&&r.anchor.origin.isEmpty()){r.anchor.origin.remove();const t=Tr();t.add(e.origin.getKey()),ii(t)}else e.origin.remove();return}break}}if("merge-block"===t.type){const{caret:e,block:n}=t;return Gs(this,Bs(!e.origin.isEmpty()&&n.isEmpty()?Xs(bs(n,e.direction)):r.anchor,e)),this.removeText()}}const o=this.focus,i=e.key,s=e.offset,l=o.key,c=o.offset;this.modify("extend",t,"character");if(!(this.anchor.key!==i||this.anchor.offset!==s||this.focus.key!==l||this.focus.offset!==c)&&"text"===e.type&&Zn(n)){const r=n.getTextContent(),i=e.offset;t&&i>0?this.anchor.set(e.key,i-1,"text"):!t&&i0?this.anchor.set(e.key,0,"text"):!t&&i=0&&this.isWordBoundary(t[n]);)n--;for(;n>0&&!this.isWordBoundary(t[n-1]);)n--;return n>=0?n:0}findWordEnd(t,e){let n=e;for(;n{try{const t=new RegExp("\\p{Emoji}","u"),e=t.test.bind(t);if(e("❤️")&&e("#️⃣")&&e("👍"))return e}catch(t){}return()=>!1})();function pr(t,e,n){const r=t,o=r.getTextContent().split(/(?=\s)/g),i=o.length;let s=0,l=0;for(let t=0;tn||r){o.splice(t,1),r&&(l=void 0);break}}const c=o.join("").trim();""===c?r.remove():(r.setTextContent(c),r.select(l,l))}function yr(e,n,r,o){let i,s=n;if(Qi(e)){let l=!1;const c=e.childNodes,a=c.length,u=o._blockCursorElement;s===a&&(l=!0,s=a-1);let f=c[s],d=!1;if(f===u)f=c[s+1],d=!0;else if(null!==u){const t=u.parentNode;if(e===t){n>Array.prototype.indexOf.call(t.children,u)&&s--}}if(i=si(f),Zn(i))s=As(i,l?"next":"previous");else{let c=si(e);if(null===c)return null;if(co(c)){const a=o.getElementByKey(c.getKey());null===a&&t(214);const u=c.getDOMSlot(a);[c,s]=u.resolveChildIndex(c,a,e,n),co(c)||t(215),l&&s>=c.getChildrenSize()&&(s=Math.max(0,c.getChildrenSize()-1));let f=c.getChildAtIndex(s);if(co(f)&&function(t,e,n){const r=t.getParent();return null===n||null===r||!r.canBeEmpty()||r!==n.getNode()}(f,0,r)){const t=l?f.getLastDescendant():f.getFirstDescendant();null===t?c=f:(f=t,c=co(f)?f:f.getParentOrThrow()),s=0}Zn(f)?(i=f,c=null,s=As(f,l?"next":"previous")):f!==c&&l&&!d&&(co(c)||t(216),s=Math.min(c.getChildrenSize(),s+1))}else{const t=c.getIndexWithinParent();s=0===n&&fo(c)&&si(e)===c?t:t+1,c=c.getParentOrThrow()}if(co(c))return ir(c.__key,s,"element")}}else i=si(e);return Zn(i)?ir(i.__key,As(i,s,"clamp"),"text"):null}function mr(t,e,n){const r=t.offset,o=t.getNode();if(0===r){const r=o.getPreviousSibling(),i=o.getParent();if(e){if((n||!e)&&null===r&&co(i)&&i.isInline()){const e=i.getPreviousSibling();Zn(e)&&t.set(e.__key,e.getTextContent().length,"text")}}else co(r)&&!n&&r.isInline()?t.set(r.__key,r.getChildrenSize(),"element"):Zn(r)&&t.set(r.__key,r.getTextContent().length,"text")}else if(r===o.getTextContent().length){const r=o.getNextSibling(),i=o.getParent();if(e&&co(r)&&r.isInline())t.set(r.__key,0,"element");else if((n||e)&&null===r&&co(i)&&i.isInline()&&!i.canInsertTextAfter()){const e=i.getNextSibling();Zn(e)&&t.set(e.__key,0,"text")}}}function xr(t,e,n){if("text"===t.type&&"text"===e.type){const r=t.isBefore(e),o=t.is(e);mr(t,r,o),mr(e,!r,o),o&&e.set(t.key,t.offset,t.type);const i=Yr();if(i.isComposing()&&i._compositionKey!==t.key&&ar(n)){const r=n.anchor,o=n.focus;t.set(r.key,r.offset,r.type,!0),e.set(o.key,o.offset,o.type,!0)}}}function Cr(t,e,n,r,o,i){if(null===t||null===n||!Lo(o,t,n))return null;const s=yr(t,e,ar(i)?i.anchor:null,o);if(null===s)return null;const l=yr(n,r,ar(i)?i.focus:null,o);if(null===l)return null;if("element"===s.type&&"element"===l.type){const e=si(t),r=si(n);if(fo(e)&&fo(r))return null}return xr(s,l,i),[s,l]}function Sr(t,e,n,r,o,i){const s=Jr(),l=new ur(ir(t,e,o),ir(n,r,i),0,"");return l.dirty=!0,s._selection=l,l}function Nr(){const t=ir("root",0,"element"),e=ir("root",0,"element");return new ur(t,e,0,"")}function Tr(){return new cr(new Set)}function vr(t,e,n,r){const o=n._window;if(null===o)return null;const i=r||o.event,s=i?i.type:void 0,l="selectionchange"===s,c=!B&&(l||"beforeinput"===s||"compositionstart"===s||"compositionend"===s||"click"===s&&i&&3===i.detail||"drop"===s||void 0===s);let a,u,f,d;if(ar(t)&&!c)return t.clone();if(null===e)return null;if(a=e.anchorNode,u=e.focusNode,f=e.anchorOffset,d=e.focusOffset,(l||void 0===s)&&ar(t)&&!Lo(n,a,u))return t.clone();const h=Cr(a,f,u,d,n,t);if(null===h)return null;const[g,_]=h;return new ur(g,_,ar(t)?t.format:0,ar(t)?t.style:"")}function kr(){return Jr()._selection}function Er(){return Yr()._editorState._selection}function Or(t,e,n,r=1){const o=t.anchor,i=t.focus,s=o.getNode(),l=i.getNode();if(!e.is(s)&&!e.is(l))return;const c=e.__key;if(t.isCollapsed()){const e=o.offset;if(n<=e&&r>0||n0||n0||n=t,s=o?i.getChildAtIndex(t-1):i.getChildAtIndex(n);if(Zn(s)){let t=0;o&&(t=s.getTextContentSize()),e.set(s.__key,t,"text"),r.set(s.__key,t,"text")}return}if(co(i)){const t=i.getChildrenSize(),r=n>=t,o=r?i.getChildAtIndex(t-1):i.getChildAtIndex(n);if(Zn(o)){let t=0;r&&(t=o.getTextContentSize()),e.set(o.__key,t,"text")}}if(co(s)){const t=s.getChildrenSize(),e=o>=t,n=e?s.getChildAtIndex(t-1):s.getChildAtIndex(o);if(Zn(n)){let t=0;e&&(t=n.getTextContentSize()),r.set(n.__key,t,"text")}}}function Mr(t,e,n,r,o){let i=null,s=0,l=null;null!==r?(i=r.__key,Zn(r)?(s=r.getTextContentSize(),l="text"):co(r)&&(s=r.getChildrenSize(),l="element")):null!==o&&(i=o.__key,Zn(o)?l="text":co(o)&&(l="element")),null!==i&&null!==l?t.set(i,s,l):(s=e.getIndexWithinParent(),-1===s&&(s=n.getChildrenSize()),t.set(n.__key,s,"element"))}function Ar(t,e,n,r,o){"text"===t.type?t.set(n,t.offset+(e?0:o),"text"):t.offset>r.getIndexWithinParent()&&t.set(t.key,t.offset-1,"element")}function wr(t,e,n,r,o){try{t.setBaseAndExtent(e,n,r,o)}catch(t){}}function Dr(t,e,n,r,o,i,s){const l=r.anchorNode,c=r.focusNode,a=r.anchorOffset,u=r.focusOffset,f=qi(i);if(o.has(bn)&&f!==i||null!==f&&Ro(f))return;if(!ar(e))return void(null!==t&&Lo(n,l,c)&&r.removeAllRanges());const d=e.anchor,h=e.focus,g=d.key,_=h.key,p=bi(n,g),y=bi(n,_),m=d.offset,x=h.offset,C=e.format,S=e.style,N=e.isCollapsed();let T=p,v=y,k=!1;if("text"===d.type){T=jo(p);const t=d.getNode();k=t.getFormat()!==C||t.getStyle()!==S}else ar(t)&&"text"===t.anchor.type&&(k=!0);var E,O,b,M,A;if(("text"===h.type&&(v=jo(y)),null!==T&&null!==v)&&(N&&(null===t||k||ar(t)&&(t.format!==C||t.style!==S))&&(E=C,O=S,b=m,M=g,A=performance.now(),nn=[E,O,b,M,A]),a!==m||u!==x||l!==T||c!==v||"Range"===r.type&&N||(null!==f&&i.contains(f)||o.has(wn)||i.focus({preventScroll:!0}),"element"===d.type))){if(wr(r,T,m,v,x),!o.has(Mn)&&e.isCollapsed()&&null!==i&&i===document.activeElement){const t=ar(e)&&"element"===e.anchor.type?T.childNodes[m]||null:r.rangeCount>0?r.getRangeAt(0):null;if(null!==t){let e;if(t instanceof Text){const n=document.createRange();n.selectNode(t),e=n.getBoundingClientRect()}else e=t.getBoundingClientRect();!function(t,e,n){const r=wi(n),o=Ri(r);if(null===r||null===o)return;let{top:i,bottom:s}=e,l=0,c=0,a=n;for(;null!==a;){const e=a===r.body;if(e)l=0,c=Li(t).innerHeight;else{const t=a.getBoundingClientRect();l=t.top,c=t.bottom}let n=0;if(ic&&(n=s-c),0!==n)if(e)o.scrollBy(0,n);else{const t=a.scrollTop;a.scrollTop+=n;const e=a.scrollTop-t;i-=e,s-=e}if(e)break;a=Ai(a)}}(n,e,i)}}Ge=!0}}function Pr(e){let n=e;e.isCollapsed()||n.removeText();const r=kr();ar(r)&&(n=r),ar(n)||t(161);const o=n.anchor;let i=o.getNode(),s=o.offset;for(;!rs(i);){const t=i;if([i,s]=Ir(i,s),t.is(i))break}return s}function Ir(t,e){const n=t.getParent();if(!n){const t=No();return ri().append(t),t.select(),[ri(),0]}if(Zn(t)){const r=t.splitText(e);if(0===r.length)return[n,t.getIndexWithinParent()];const o=0===e?0:1;return[n,r[0].getIndexWithinParent()+o]}if(!co(t)||0===e)return[n,t.getIndexWithinParent()];const r=t.getChildAtIndex(e);if(r){const n=new ur(ir(t.__key,e,"element"),ir(t.__key,e,"element"),0,""),o=t.insertNewAfter(n);o&&o.append(r,...r.getNextSiblings())}return[n,t.getIndexWithinParent()+1]}function Rr(t,e,n,r,o="decorators-and-blocks"){if("move"===e&&"character"===r&&!t.isCollapsed()){const[e,r]=n===t.isBackward()?[t.focus,t.anchor]:[t.anchor,t.focus];return r.set(e.key,e.offset,e.type),!0}const i=Ys(t.focus,n?"previous":"next"),s="lineboundary"===r,l="move"===e;let c=i,a="decorators-and-blocks"===o;if(!nl(c)){for(const t of c){a=!1;const{origin:e}=t;if(!fo(e)||e.isIsolated()||(c=t,!s||!e.isInline()))break}if(a)for(const t of Fs(i).iterNodeCarets("extend"===e?"shadowRoot":"root")){if(vs(t))t.origin.isInline()||(c=t);else{if(co(t.origin))continue;fo(t.origin)&&!t.origin.isInline()&&(c=t)}break}}if(c===i)return!1;if(l&&!s&&fo(c.origin)&&c.origin.isKeyboardSelectable()){const t=Tr();return t.add(c.origin.getKey()),ii(t),!0}return c=el(c),l&&Hs(t.anchor,c),Hs(t.focus,c),a||!s}let Lr=null,Fr=null,Kr=!1,Br=!1,Wr=0;const zr={characterData:!0,childList:!0,subtree:!0};function $r(){return Kr||null!==Lr&&Lr._readOnly}function Ur(){Kr&&t(13)}function jr(){Wr>99&&t(14)}function Jr(){return null===Lr&&t(195,Hr()),Lr}function Yr(){return null===Fr&&t(196,Hr()),Fr}function Hr(){let t=0;const e=new Set,n=Oo.version;if("undefined"!=typeof window)for(const r of document.querySelectorAll("[contenteditable]")){const o=Bo(r);if(Fo(o))t++;else if(o){let t=String(o.constructor.version||"<0.17.1");t===n&&(t+=" (separately built, likely a bundler configuration issue)"),e.add(t)}}let r=` Detected on the page: ${t} compatible editor(s) with version ${n}`;return e.size&&(r+=` and incompatible editors with versions ${Array.from(e).join(", ")}`),r}function Vr(){return Fr}function Gr(t,e,n){const r=e.__type,o=wo(t,r);let i=n.get(r);void 0===i&&(i=Array.from(o.transforms),n.set(r,i));const s=i.length;for(let t=0;t0||u>0;){if(c>0){e._dirtyLeaves=new Set;for(const t of l){const r=o.get(t);Zn(r)&&r.isAttached()&&r.isSimpleText()&&!r.isUnmergeable()&&ct(r),void 0!==r&&qr(r,i)&&Gr(e,r,s),n.add(t)}if(l=e._dirtyLeaves,c=l.size,c>0){Wr++;continue}}e._dirtyLeaves=new Set,e._dirtyElements=new Map,a.delete("root")&&a.set("root",!0);for(const t of a){const n=t[0],l=t[1];if(r.set(n,l),!l)continue;const c=o.get(n);void 0!==c&&qr(c,i)&&Gr(e,c,s)}l=e._dirtyLeaves,c=l.size,a=e._dirtyElements,u=a.size,Wr++}e._dirtyLeaves=n,e._dirtyElements=r}(a,e),no(e),function(t,e,n,r){const o=t._nodeMap,i=e._nodeMap,s=[];for(const[t]of r){const e=i.get(t);void 0!==e&&(e.isAttached()||(co(e)&&K(e,t,o,i,s,r),o.has(t)||r.delete(t),s.push(t)))}for(const t of s)i.delete(t);for(const t of n){const e=i.get(t);void 0===e||e.isAttached()||(o.has(t)||n.delete(t),i.delete(t))}}(c,a,e._dirtyLeaves,e._dirtyElements));o!==e._compositionKey&&(a._flushSync=!0);const i=a._selection;if(ar(i)){const e=a._nodeMap,n=i.anchor.key,r=i.focus.key;void 0!==e.get(n)&&void 0!==e.get(r)||t(19)}else fr(i)&&0===i._nodes.size&&(a._selection=null)}catch(t){return t instanceof Error&&e._onError(t),e._pendingEditorState=c,e._dirtyType=2,e._cloneNotNeeded.clear(),e._dirtyLeaves=new Set,e._dirtyElements.clear(),void to(e)}finally{Lr=f,Kr=d,Fr=h,e._updating=g,Wr=0}const p=0!==e._dirtyType||e._deferred.length>0||function(t,e){const n=e.getEditorState()._selection,r=t._selection;if(null!==r){if(r.dirty||!r.is(n))return!0}else if(null!==n)return!0;return!1}(a,e);p?a._flushSync?(a._flushSync=!1,to(e)):u&&Po(()=>{to(e)}):(a._flushSync=!1,u&&(o.clear(),e._deferred=[],e._pendingEditorState=null))}function oo(t,e,n){Fr===t&&void 0===n?e():ro(t,e,n)}class io{element;before;after;constructor(t,e,n){this.element=t,this.before=e||null,this.after=n||null}withBefore(t){return new io(this.element,t,this.after)}withAfter(t){return new io(this.element,this.before,t)}withElement(t){return this.element===t?this:new io(t,this.before,this.after)}insertChild(e){const n=this.before||this.getManagedLineBreak();return null!==n&&n.parentElement!==this.element&&t(222),this.element.insertBefore(e,n),this}removeChild(e){return e.parentElement!==this.element&&t(223),this.element.removeChild(e),this}replaceChild(e,n){return n.parentElement!==this.element&&t(224),this.element.replaceChild(e,n),this}getFirstChild(){const t=this.after?this.after.nextSibling:this.element.firstChild;return t===this.before||t===this.getManagedLineBreak()?null:t}getManagedLineBreak(){return this.element.__lexicalLineBreak||null}setManagedLineBreak(t){if(null===t)this.removeManagedLineBreak();else{const e="decorator"===t&&(d||c||l);this.insertManagedLineBreak(e)}}removeManagedLineBreak(){const t=this.getManagedLineBreak();if(t){const e=this.element,n="IMG"===t.nodeName?t.nextSibling:null;n&&e.removeChild(n),e.removeChild(t),e.__lexicalLineBreak=void 0}}insertManagedLineBreak(t){const e=this.getManagedLineBreak();if(e){if(t===("IMG"===e.nodeName))return;this.removeManagedLineBreak()}const n=this.element,r=this.before,o=document.createElement("br");if(n.insertBefore(o,r),t){const t=document.createElement("img");t.setAttribute("data-lexical-linebreak","true"),t.style.cssText="display: inline !important; border: 0px !important; margin: 0px !important;",t.alt="",n.insertBefore(t,o),n.__lexicalLineBreak=t}else n.__lexicalLineBreak=o}getFirstChildOffset(){let t=0;for(let e=this.after;null!==e;e=e.previousSibling)t++;return t}resolveChildIndex(t,e,n,r){if(n===this.element){const e=this.getFirstChildOffset();return[t,Math.min(e+t.getChildrenSize(),Math.max(e,r))]}const o=so(e,n);o.push(r);const i=so(e,this.element);let s=t.getIndexWithinParent();for(let t=0;tn){s+=1;break}}return[t.getParentOrThrow(),s]}}function so(e,n){const r=[];let o=n;for(;o!==e&&null!==o;o=o.parentNode){let t=0;for(let e=o.previousSibling;null!==e;e=e.previousSibling)t++;r.push(t)}return o!==e&&t(225),r.reverse()}class lo extends En{__first;__last;__size;__format;__style;__indent;__dir;__textFormat;__textStyle;constructor(t){super(t),this.__first=null,this.__last=null,this.__size=0,this.__format=0,this.__style="",this.__indent=0,this.__dir=null,this.__textFormat=0,this.__textStyle=""}afterCloneFrom(t){super.afterCloneFrom(t),this.__key===t.__key&&(this.__first=t.__first,this.__last=t.__last,this.__size=t.__size),this.__indent=t.__indent,this.__format=t.__format,this.__style=t.__style,this.__dir=t.__dir,this.__textFormat=t.__textFormat,this.__textStyle=t.__textStyle}getFormat(){return this.getLatest().__format}getFormatType(){const t=this.getFormat();return I[t]||""}getStyle(){return this.getLatest().__style}getIndent(){return this.getLatest().__indent}getChildren(){const t=[];let e=this.getFirstChild();for(;null!==e;)t.push(e),e=e.getNextSibling();return t}getChildrenKeys(){const t=[];let e=this.getFirstChild();for(;null!==e;)t.push(e.__key),e=e.getNextSibling();return t}getChildrenSize(){return this.getLatest().__size}isEmpty(){return 0===this.getChildrenSize()}isDirty(){const t=Yr()._dirtyElements;return null!==t&&t.has(this.__key)}isLastChild(){const t=this.getLatest(),e=this.getParentOrThrow().getLastChild();return null!==e&&e.is(t)}getAllTextNodes(){const t=[];let e=this.getFirstChild();for(;null!==e;){if(Zn(e)&&t.push(e),co(e)){const n=e.getAllTextNodes();t.push(...n)}e=e.getNextSibling()}return t}getFirstDescendant(){let t=this.getFirstChild();for(;co(t);){const e=t.getFirstChild();if(null===e)break;t=e}return t}getLastDescendant(){let t=this.getLastChild();for(;co(t);){const e=t.getLastChild();if(null===e)break;t=e}return t}getDescendantByIndex(t){const e=this.getChildren(),n=e.length;if(t>=n){const t=e[n-1];return co(t)&&t.getLastDescendant()||t||null}const r=e[t];return co(r)&&r.getFirstDescendant()||r||null}getFirstChild(){const t=this.getLatest().__first;return null===t?null:Xo(t)}getFirstChildOrThrow(){const e=this.getFirstChild();return null===e&&t(45,this.__key),e}getLastChild(){const t=this.getLatest().__last;return null===t?null:Xo(t)}getLastChildOrThrow(){const e=this.getLastChild();return null===e&&t(96,this.__key),e}getChildAtIndex(t){const e=this.getChildrenSize();let n,r;if(t=t;){if(r===t)return n;n=n.getPreviousSibling(),r--}return null}getTextContent(){let t="";const e=this.getChildren(),n=e.length;for(let r=0;rt.remove()),t}append(...t){return this.splice(this.getChildrenSize(),0,t)}setDirection(t){const e=this.getWritable();return e.__dir=t,e}setFormat(t){return this.getWritable().__format=""!==t?P[t]:0,this}setStyle(t){return this.getWritable().__style=t||"",this}setTextFormat(t){const e=this.getWritable();return e.__textFormat=t,e}setTextStyle(t){const e=this.getWritable();return e.__textStyle=t,e}setIndent(t){return this.getWritable().__indent=t,this}splice(e,n,r){kn(this)&&t(324,this.__key,this.__type);const o=this.getChildrenSize(),i=this.getWritable();e+n<=o||t(226,String(e),String(n),String(o));const s=i.__key,l=[],c=[],a=this.getChildAtIndex(e+n);let u=null,f=o-n+r.length;if(0!==e)if(e===o)u=this.getLastChild();else{const t=this.getChildAtIndex(e);null!==t&&(u=t.getPreviousSibling())}if(n>0){let e=null===u?this.getFirstChild():u.getNextSibling();for(let r=0;r0&&(e.style.paddingInlineStart=40*t+"px");const n=this.getDirection();n&&(e.dir=n)}return{element:e}}exportJSON(){const t={children:[],direction:this.getDirection(),format:this.getFormatType(),indent:this.getIndent(),...super.exportJSON()},e=this.getTextFormat(),n=this.getTextStyle();return 0===e&&""===n||Ki(this)||this.getChildren().some(Zn)||(0!==e&&(t.textFormat=e),""!==n&&(t.textStyle=n)),t}updateFromJSON(t){return super.updateFromJSON(t).setFormat(t.format).setIndent(t.indent).setDirection(t.direction).setTextFormat(t.textFormat||0).setTextStyle(t.textStyle||"")}insertNewAfter(t,e){return null}canIndent(){return!0}collapseAtStart(t){return!1}excludeFromCopy(t){return!1}canReplaceWith(t){return!0}canInsertAfter(t){return!0}canBeEmpty(){return!0}canInsertTextBefore(){return!0}canInsertTextAfter(){return!0}isInline(){return!1}isShadowRoot(){return!1}canMergeWith(t){return!1}extractWithChild(t,e,n){return!1}canMergeWhenEmpty(){return!1}reconcileObservedMutation(t,e){const n=this.getDOMSlot(t);let r=n.getFirstChild();for(let t=this.getFirstChild();t;t=t.getNextSibling()){const o=e.getElementByKey(t.getKey());null!==o&&(null==r?(n.insertChild(o),r=o):r!==o&&n.replaceChild(o,r),r=r.nextSibling)}}}function co(t){return t instanceof lo}function ao(t,e,n){let r=t.getNode();for(;r;){const t=r.__key;if(e.has(t)&&!n.has(t))return!0;r=r.getParent()}return!1}class uo extends En{decorate(t,e){return null}isIsolated(){return!1}isInline(){return!0}isKeyboardSelectable(){return!0}}function fo(t){return t instanceof uo}class ho extends lo{__cachedText;static getType(){return"root"}static clone(){return new ho}constructor(){super("root"),this.__cachedText=null}getTopLevelElementOrThrow(){t(51)}getTextContent(){const t=this.__cachedText;return!$r()&&0!==Yr()._dirtyType||null===t?super.getTextContent():t}remove(){t(52)}replace(e){t(53)}insertBefore(e){t(54)}insertAfter(e){t(55)}updateDOM(t,e){return!1}splice(e,n,r){for(const e of r)co(e)||fo(e)||t(282);return super.splice(e,n,r)}static importJSON(t){return ri().updateFromJSON(t)}collapseAtStart(){return!0}}function go(t){return t instanceof ho}function _o(t){return new mo(new Map(t._nodeMap))}function po(){return new mo(new Map([["root",new ho]]))}function yo(e){const n=e.exportJSON(),r=e.constructor;if(n.type!==r.getType()&&t(130,r.name),co(e)){const o=n.children;Array.isArray(o)||t(59,r.name);const i=e.getChildren();for(let t=0;t({root:yo(ri())}))}}class xo extends lo{static getType(){return"artificial"}createDOM(t){return document.createElement("div")}}class Co extends lo{static getType(){return"paragraph"}static clone(t){return new Co(t.__key)}createDOM(t){const e=document.createElement("p"),n=Si(t.theme,"paragraph");if(void 0!==n){e.classList.add(...n)}return e}updateDOM(t,e,n){return!1}static importDOM(){return{p:t=>({conversion:So,priority:0})}}exportDOM(t){const{element:e}=super.exportDOM(t);if(Qi(e)){this.isEmpty()&&e.append(document.createElement("br"));const t=this.getFormatType();t&&(e.style.textAlign=t)}return{element:e}}static importJSON(t){return No().updateFromJSON(t)}exportJSON(){const t=super.exportJSON();if(void 0===t.textFormat||void 0===t.textStyle){const e=this.getChildren().find(Zn);e?(t.textFormat=e.getFormat(),t.textStyle=e.getStyle()):(t.textFormat=this.getTextFormat(),t.textStyle=this.getTextStyle())}return t}insertNewAfter(t,e){const n=No();n.setTextFormat(t.format),n.setTextStyle(t.style);const r=this.getDirection();return n.setDirection(r),n.setFormat(this.getFormatType()),n.setStyle(this.getStyle()),this.insertAfter(n,e),n}collapseAtStart(){const t=this.getChildren();if(0===t.length||Zn(t[0])&&""===t[0].getTextContent().trim()){if(null!==this.getNextSibling())return this.selectNext(),this.remove(),!0;if(null!==this.getPreviousSibling())return this.selectPrevious(),this.remove(),!0}return!1}}function So(t){const e=No();return t.style&&(e.setFormat(t.style.textAlign),as(t,e)),{node:e}}function No(){return Wi(new Co)}function To(t){return t instanceof Co}const vo=0;function ko(t,e,n,r){const o=t._keyToDOMMap;o.clear(),t._editorState=po(),t._pendingEditorState=r,t._compositionKey=null,t._dirtyType=0,t._cloneNotNeeded.clear(),t._dirtyLeaves=new Set,t._dirtyElements.clear(),t._normalizedNodes=new Set,t._updateTags=new Set,t._updates=[],t._blockCursorElement=null;const i=t._observer;null!==i&&(i.disconnect(),t._observer=null),null!==e&&(e.textContent=""),null!==n&&(n.textContent="",o.set("root",n))}function Eo(t){const e=new Set,n=new Set;let r=t;for(;r;){const{ownNodeConfig:t}=ds(r),o=r.transform;if(!n.has(o)){n.add(o);const t=r.transform();t&&e.add(t)}if(t){const n=t.$transform;n&&e.add(n),r=t.extends}else{const t=Object.getPrototypeOf(r);r=t.prototype instanceof En&&t!==En?t:void 0}}return e}class Oo{static version;_headless;_parentEditor;_rootElement;_editorState;_pendingEditorState;_compositionKey;_deferred;_keyToDOMMap;_updates;_updating;_listeners;_commands;_nodes;_decorators;_pendingDecorators;_config;_dirtyType;_cloneNotNeeded;_dirtyLeaves;_dirtyElements;_normalizedNodes;_updateTags;_observer;_key;_onError;_htmlConversions;_window;_editable;_blockCursorElement;_createEditorArgs;constructor(t,e,n,r,o,i,s,l){this._createEditorArgs=l,this._parentEditor=e,this._rootElement=null,this._editorState=t,this._pendingEditorState=null,this._compositionKey=null,this._deferred=[],this._keyToDOMMap=new Map,this._updates=[],this._updating=!1,this._listeners={decorator:new Set,editable:new Set,mutation:new Map,root:new Set,textcontent:new Set,update:new Set},this._commands=new Map,this._config=r,this._nodes=n,this._decorators={},this._pendingDecorators=null,this._dirtyType=0,this._cloneNotNeeded=new Set,this._dirtyLeaves=new Set,this._dirtyElements=new Map,this._normalizedNodes=new Set,this._updateTags=new Set,this._observer=null,this._key=ai(),this._onError=o,this._htmlConversions=i,this._editable=s,this._headless=null!==e&&e._headless,this._window=null,this._blockCursorElement=null}isComposing(){return null!=this._compositionKey}registerUpdateListener(t){const e=this._listeners.update;return e.add(t),()=>{e.delete(t)}}registerEditableListener(t){const e=this._listeners.editable;return e.add(t),()=>{e.delete(t)}}registerDecoratorListener(t){const e=this._listeners.decorator;return e.add(t),()=>{e.delete(t)}}registerTextContentListener(t){const e=this._listeners.textcontent;return e.add(t),()=>{e.delete(t)}}registerRootListener(t){const e=this._listeners.root;return t(this._rootElement,null),e.add(t),()=>{t(null,this._rootElement),e.delete(t)}}registerCommand(e,n,r){void 0===r&&t(35);const o=this._commands;o.has(e)||o.set(e,[new Set,new Set,new Set,new Set,new Set]);const i=o.get(e);void 0===i&&t(36,String(e));const s=i[r];return s.add(n),()=>{s.delete(n),i.every(t=>0===t.size)&&o.delete(e)}}registerMutationListener(t,e,n){const r=this.resolveRegisteredNodeAfterReplacements(this.getRegisteredNode(t)).klass,o=this._listeners.mutation;let i=o.get(e);void 0===i&&(i=new Set,o.set(e,i)),i.add(r);const s=n&&n.skipInitialization;return void 0!==s&&s||this.initializeMutationListener(e,r),()=>{i.delete(r),0===i.size&&o.delete(e)}}getRegisteredNode(e){const n=this._nodes.get(e.getType());return void 0===n&&t(37,e.name),n}resolveRegisteredNodeAfterReplacements(t){for(;t.replaceWithKlass;)t=this.getRegisteredNode(t.replaceWithKlass);return t}initializeMutationListener(t,e){const n=this._editorState,r=ls(n).get(e.getType());if(!r)return;const o=new Map;for(const t of r.keys())o.set(t,"created");o.size>0&&t(o,{dirtyLeaves:new Set,prevEditorState:n,updateTags:new Set(["registerMutationListener"])})}registerNodeTransformToKlass(t,e){const n=this.getRegisteredNode(t);return n.transforms.add(e),n}registerNodeTransform(t,e){const n=this.registerNodeTransformToKlass(t,e),r=[n],o=n.replaceWithKlass;if(null!=o){const t=this.registerNodeTransformToKlass(o,e);r.push(t)}return function(t,e){const n=ls(t.getEditorState()),r=[];for(const t of e){const e=n.get(t);e&&r.push(e)}if(0===r.length)return;t.update(()=>{for(const t of r)for(const e of t.keys()){const t=Xo(e);t&&t.markDirty()}},null===t._pendingEditorState?{tag:On}:void 0)}(this,r.map(t=>t.klass.getType())),()=>{r.forEach(t=>t.transforms.delete(e))}}hasNode(t){return this._nodes.has(t.getType())}hasNodes(t){return t.every(this.hasNode.bind(this))}dispatchCommand(t,e){return Ei(this,t,e)}getDecorators(){return this._decorators}getRootElement(){return this._rootElement}getKey(){return this._key}setRootElement(t){const e=this._rootElement;if(t!==e){const n=Si(this._config.theme,"root"),r=this._pendingEditorState||this._editorState;if(this._rootElement=t,ko(this,e,t,r),null!==e&&(this._config.disableEvents||Nn(e),null!=n&&e.classList.remove(...n)),null!==t){const e=Ri(t),r=t.style;r.userSelect="text",r.whiteSpace="pre-wrap",r.wordBreak="break-word",t.setAttribute("data-lexical-editor","true"),this._window=e,this._dirtyType=2,V(this),this._updateTags.add(On),to(this),this._config.disableEvents||function(t,e){const n=Vi(t);He.set(t,n);const r=Ve.get(n)??0;r<1&&n.addEventListener("selectionchange",mn),Ve.set(n,r+1),t.__lexicalEditor=e;const o=pn(t);for(let n=0;n<$e.length;n++){const[r,i]=$e[n],s="function"==typeof i?t=>{Cn(t)||(xn(t),(e.isEditable()||"click"===r)&&i(t,e))}:t=>{if(Cn(t))return;xn(t);const n=e.isEditable();switch(r){case"cut":return n&&Ei(e,De,t);case"copy":return Ei(e,we,t);case"paste":return n&&Ei(e,re,t);case"dragstart":return n&&Ei(e,be,t);case"dragover":return n&&Ei(e,Me,t);case"dragend":return n&&Ei(e,Ae,t);case"focus":return n&&Ei(e,Ke,t);case"blur":return n&&Ei(e,Be,t);case"drop":return n&&Ei(e,Ee,t)}};t.addEventListener(r,s),o.push(()=>{t.removeEventListener(r,s)})}}(t,this),null!=n&&t.classList.add(...n)}else this._window=null,this._updateTags.add(On),to(this);eo("root",this,!1,t,e)}}getElementByKey(t){return this._keyToDOMMap.get(t)||null}getEditorState(){return this._editorState}setEditorState(e,n){e.isEmpty()&&t(38);let r=e;r._readOnly&&(r=_o(e),r._selection=e._selection?e._selection.clone():null),H(this);const o=this._pendingEditorState,i=this._updateTags,s=void 0!==n?n.tag:null;null===o||o.isEmpty()||(null!=s&&i.add(s),to(this)),this._pendingEditorState=r,this._dirtyType=2,this._dirtyElements.set("root",!1),this._compositionKey=null,null!=s&&i.add(s),this._updating||to(this)}parseEditorState(t,e){return function(t,e,n){const r=po(),o=Lr,i=Kr,s=Fr,l=e._dirtyElements,c=e._dirtyLeaves,a=e._cloneNotNeeded,u=e._dirtyType;e._dirtyElements=new Map,e._dirtyLeaves=new Set,e._cloneNotNeeded=new Set,e._dirtyType=0,Lr=r,Kr=!1,Fr=e,Mo(null);try{const o=e._nodes;Qr(t.root,o),n&&n(),r._readOnly=!0}catch(t){t instanceof Error&&e._onError(t)}finally{e._dirtyElements=l,e._dirtyLeaves=c,e._cloneNotNeeded=a,e._dirtyType=u,Lr=o,Kr=i,Fr=s}return r}("string"==typeof t?JSON.parse(t):t,this,e)}read(t){return to(this),this.getEditorState().read(t,{editor:this})}update(t,e){!function(t,e,n){t._updating?t._updates.push([e,n]):ro(t,e,n)}(this,t,e)}focus(t,e={}){const n=this._rootElement;null!==n&&(n.setAttribute("autocapitalize","off"),oo(this,()=>{const r=kr(),o=ri();null!==r?r.dirty||ii(r.clone()):0!==o.getChildrenSize()&&("rootStart"===e.defaultSelection?o.selectStart():o.selectEnd()),Di("focus"),Pi(()=>{n.removeAttribute("autocapitalize"),t&&t()})}),null===this._pendingEditorState&&n.removeAttribute("autocapitalize"))}blur(){const t=this._rootElement;null!==t&&t.blur();const e=Hi(this);null!==e&&e.removeAllRanges()}isEditable(){return this._editable}setEditable(t){this._editable!==t&&(this._editable=t,eo("editable",this,!0,t))}toJSON(){return{editorState:this._editorState.toJSON()}}}Oo.version="0.38.2+prod.cjs";let bo=null;function Mo(t){bo=t}let Ao=1;function wo(e,n){const r=Do(e,n);return void 0===r&&t(30,n),r}function Do(t,e){return t._nodes.get(e)}const Po="function"==typeof queueMicrotask?queueMicrotask:t=>{Promise.resolve().then(t)};function Io(t){return fo(ti(t))}function Ro(t){const e=Ko(t),n=e?e.getRootElement():null,r=n?qi(n):document.activeElement;if(!Qi(r))return!1;const o=r.nodeName;return fo(ti(t))&&("INPUT"===o||"TEXTAREA"===o||"true"===r.contentEditable&&null==Bo(r))}function Lo(t,e,n){const r=t.getRootElement();try{return null!==r&&r.contains(e)&&r.contains(n)&&null!==e&&!Ro(e)&&Ko(e)===t}catch(t){return!1}}function Fo(t){return t instanceof Oo}function Ko(t){let e=t;for(;null!=e;){const t=Bo(e);if(Fo(t))return t;e=Ai(e)}return null}function Bo(t){return t?t.__lexicalEditor:null}function Wo(t){return rr(t)||t.isToken()}function zo(t){return Wo(t)||t.isSegmented()}function $o(t){return Zi(t)&&3===t.nodeType}function Uo(t){return Zi(t)&&9===t.nodeType}function jo(t){let e=t;for(;null!=e;){if($o(e))return e;e=e.firstChild}return null}function Jo(t,e,n){const r=w[e];if(null!==n&&(t&r)===(n&r))return t;let o=t^r;return"subscript"===e?o&=~w.superscript:"superscript"===e?o&=~w.subscript:"lowercase"===e?(o&=~w.uppercase,o&=~w.capitalize):"uppercase"===e?(o&=~w.lowercase,o&=~w.capitalize):"capitalize"===e&&(o&=~w.lowercase,o&=~w.uppercase),o}function Yo(t,e){const n=function(){const t=bo;return bo=null,t}();if(null!=(e=e||n&&n.__key))return void(t.__key=e);Ur(),jr();const r=Yr(),o=Jr(),i=""+Ao++;o._nodeMap.set(i,t),co(t)?r._dirtyElements.set(i,!0):r._dirtyLeaves.add(i),r._cloneNotNeeded.add(i),r._dirtyType=1,t.__key=i}function Ho(t){const e=t.getParent();if(null!==e){const n=t.getWritable(),r=e.getWritable(),o=t.getPreviousSibling(),i=t.getNextSibling(),s=null!==i?i.__key:null,l=null!==o?o.__key:null,c=null!==o?o.getWritable():null,a=null!==i?i.getWritable():null;null===o&&(r.__first=s),null===i&&(r.__last=l),null!==c&&(c.__next=s),null!==a&&(a.__prev=l),n.__prev=null,n.__next=null,n.__parent=null,r.__size--}}function Vo(e){jr(),kn(e)&&t(323,e.__key,e.__type);const n=e.getLatest(),r=n.__parent,o=Jr(),i=Yr(),s=o._nodeMap,l=i._dirtyElements;null!==r&&function(t,e,n){let r=t;for(;null!==r;){if(n.has(r))return;const t=e.get(r);if(void 0===t)break;n.set(r,!1),r=t.__parent}}(r,s,l);const c=n.__key;i._dirtyType=1,co(e)?l.set(c,!0):i._dirtyLeaves.add(c)}function Go(t){Ur();const e=Yr(),n=e._compositionKey;if(t!==n){if(e._compositionKey=t,null!==n){const t=Xo(n);null!==t&&t.getWritable()}if(null!==t){const e=Xo(t);null!==e&&e.getWritable()}}}function qo(){if($r())return null;return Yr()._compositionKey}function Xo(t,e){const n=(e||Jr())._nodeMap.get(t);return void 0===n?null:n}function Qo(t,e){const n=Zo(t,Yr());return void 0!==n?Xo(n,e):null}function Zo(t,e){return t[`__lexicalKey_${e._key}`]}function ti(t,e){let n=t;for(;null!=n;){const t=Qo(n,e);if(null!==t)return t;n=Ai(n)}return null}function ei(t){const e=t._decorators,n=Object.assign({},e);return t._pendingDecorators=n,n}function ni(t){return t.read(()=>ri().getTextContent())}function ri(){return oi(Jr())}function oi(t){return t._nodeMap.get("root")}function ii(t){Ur();const e=Jr();null!==t&&(t.dirty=!0,t.setCachedNodes(null)),e._selection=t}function si(t){const e=Yr(),n=function(t,e){let n=t;for(;null!=n;){const t=Zo(n,e);if(void 0!==t)return t;n=Ai(n)}return null}(t,e);if(null===n){return t===e.getRootElement()?Xo("root"):null}return Xo(n)}function li(t){return/[\uD800-\uDBFF][\uDC00-\uDFFF]/g.test(t)}function ci(t){const e=[];let n=t;for(;null!==n;)e.push(n),n=n._parentEditor;return e}function ai(){return Math.random().toString(36).replace(/[^a-z]+/g,"").substring(0,5)}function ui(t){return $o(t)?t.nodeValue:null}function fi(t,e,n){const r=Hi(e);if(null===r)return;const o=r.anchorNode;let{anchorOffset:i,focusOffset:s}=r;if(null!==o){let e=ui(o);const r=ti(o);if(null!==e&&Zn(r)){if(e===v&&n){const t=n.length;e=n,i=t,s=t}null!==e&&di(r,e,i,s,t)}}}function di(t,e,n,r,o){let i=t;if(i.isAttached()&&(o||!i.isDirty())){const s=i.isComposing();let a=e;(s||o)&&e[e.length-1]===v&&(a=e.slice(0,-1));const u=i.getTextContent();if(o||a!==u){if(""===a){if(Go(null),l||c||d)i.remove();else{const t=Yr();setTimeout(()=>{t.update(()=>{i.isAttached()&&i.remove()})},20)}return}const e=i.getParent(),o=Er(),u=i.getTextContentSize(),f=qo(),h=i.getKey();if(i.isToken()||null!==f&&h===f&&!s||ar(o)&&(null!==e&&!e.canInsertTextBefore()&&0===o.anchor.offset||o.anchor.key===t.__key&&0===o.anchor.offset&&!i.canInsertTextBefore()&&!s||o.focus.key===t.__key&&o.focus.offset===u&&!i.canInsertTextAfter()&&!s))return void i.markDirty();const g=kr();if(!ar(g)||null===n||null===r)return void hi(i,a,g);if(g.setTextNodeRange(i,n,i,r),i.isSegmented()){const t=Qn(i.getTextContent());i.replace(t),i=t}hi(i,a,g)}}}function hi(t,e,n){if(t.setTextContent(e),ar(n)){const e=t.getKey();for(const r of["anchor","focus"]){const o=n[r];"text"===o.type&&o.key===e&&(o.offset=As(t,o.offset,"clamp"))}}}function gi(t,e,n){const r=e[n]||!1;return"any"===r||r===t[n]}function _i(t,e){return gi(t,e,"altKey")&&gi(t,e,"ctrlKey")&&gi(t,e,"shiftKey")&&gi(t,e,"metaKey")}function pi(t,e,n){return _i(t,n)&&t.key.toLowerCase()===e.toLowerCase()}const yi={ctrlKey:!o,metaKey:o},mi={altKey:o,ctrlKey:!o};function xi(t){return"Backspace"===t.key}function Ci(t){return pi(t,"a",yi)}function Si(t,e){void 0===t.__lexicalClassNameCache&&(t.__lexicalClassNameCache={});const n=t.__lexicalClassNameCache,r=n[e];if(void 0!==r)return r;const o=t[e];if("string"==typeof o){const t=h(o);return n[e]=t,t}return o}function Ni(e,n,r,o,i){if(0===r.size)return;const s=o.__type,l=o.__key,c=n.get(s);void 0===c&&t(33,s);const a=c.klass;let u=e.get(a);void 0===u&&(u=new Map,e.set(a,u));const f=u.get(l),d="destroyed"===f&&"created"===i;(void 0===f||d)&&u.set(l,d?"updated":i)}function Ti(t,e,n){const r=t.getParent();let o=n,i=t;return null!==r&&(e&&0===n?(o=i.getIndexWithinParent(),i=r):e||n!==i.getChildrenSize()||(o=i.getIndexWithinParent()+1,i=r)),i.getChildAtIndex(e?o-1:o)}function vi(t,e){const n=t.offset;if("element"===t.type){return Ti(t.getNode(),e,n)}{const r=t.getNode();if(e&&0===n||!e&&n===r.getTextContentSize()){const t=e?r.getPreviousSibling():r.getNextSibling();return null===t?Ti(r.getParentOrThrow(),e,r.getIndexWithinParent()+(e?0:1)):t}}return null}function ki(t){const e=Li(t).event,n=e&&e.inputType;return"insertFromPaste"===n||"insertFromPasteAsQuotation"===n}function Ei(t,e,n){return function(t,e,n){const r=ci(t);for(let o=4;o>=0;o--)for(let i=0;i{for(let e=0;e0)return function(t,e){if(0===e.length)return t;const n=e[0],r=Object.create(Selection.prototype),o=Object.getOwnPropertyDescriptors(Selection.prototype);Object.keys(o).forEach(e=>{if("constructor"===e)return;const n=o[e];if(n.value&&"function"==typeof n.value){const n=t[e];"function"==typeof n&&(r[e]=n.bind(t))}else if(!n.get){const n=t[e];void 0!==n&&(r[e]=n)}}),Object.defineProperty(r,"anchorNode",{enumerable:!0,get:()=>n.startContainer}),Object.defineProperty(r,"anchorOffset",{enumerable:!0,get:()=>n.startOffset}),Object.defineProperty(r,"focusNode",{enumerable:!0,get:()=>n.endContainer}),Object.defineProperty(r,"focusOffset",{enumerable:!0,get:()=>n.endOffset}),Object.defineProperty(r,"isCollapsed",{enumerable:!0,get:()=>n.collapsed}),Object.defineProperty(r,"rangeCount",{enumerable:!0,get:()=>e.length}),Object.defineProperty(r,"type",{enumerable:!0,get:()=>{const t=e[0];return t?t.collapsed?"Caret":"Range":"None"}}),r.getRangeAt=function(t){if(t<0||t>=e.length)throw new DOMException("Index out of range","IndexSizeError");const n=e[t],r=document.createRange();return r.setStart(n.startContainer,n.startOffset),r.setEnd(n.endContainer,n.endOffset),r},"getComposedRanges"in t&&(r.getComposedRanges=function(){return e});return r}(e,n)}return e}function Yi(t,e){if(!n)return null;if(e){const t=Vi(e);if(t&&Mi(t))return Ji(t)}return(t||window).getSelection()}function Hi(t){return Yi(Li(t),t.getRootElement())}function Vi(t){const e=t.getRootNode({composed:!1});return Mi(e)?e:document}function Gi(t){if(!t||!n)return document;const e=t.getRootNode({composed:!0});return e===t||e.nodeType!==Node.DOCUMENT_NODE?t.ownerDocument||document:e}function qi(t){const e=Vi(t);return e&&Mi(e)&&e.activeElement?e.activeElement:Gi(t).activeElement}function Xi(t){if(!t)return null;if(Qi(t)){const e=Vi(t);if(e&&Mi(e))return Ji(e)}const e=Ri(t);return e?e.getSelection():null}function Qi(t){return Zi(t)&&1===t.nodeType}function Zi(t){return"object"==typeof t&&null!==t&&"nodeType"in t&&"number"==typeof t.nodeType}function ts(t){return Zi(t)&&11===t.nodeType}function es(t){const e=new RegExp(/^(a|abbr|acronym|b|cite|code|del|em|i|ins|kbd|label|mark|output|q|ruby|s|samp|span|strong|sub|sup|time|u|tt|var|#text)$/,"i");return null!==t.nodeName.match(e)}function ns(t){const e=new RegExp(/^(address|article|aside|blockquote|canvas|dd|div|dl|dt|fieldset|figcaption|figure|footer|form|h1|h2|h3|h4|h5|h6|header|hr|li|main|nav|noscript|ol|p|pre|section|table|td|tfoot|ul|video)$/,"i");return null!==t.nodeName.match(e)}function rs(t){if(fo(t)&&!t.isInline())return!0;if(!co(t)||Ki(t))return!1;const e=t.getFirstChild(),n=null===e||Rn(e)||Zn(e)||e.isInline();return!t.isInline()&&!1!==t.canBeEmpty()&&n}function os(){return Yr()}const is=new WeakMap,ss=new Map;function ls(e){if(!e._readOnly&&e.isEmpty())return ss;e._readOnly||t(192);let n=is.get(e);return n||(n=function(t){const e=new Map;for(const[n,r]of t._nodeMap){const t=r.__type;let o=e.get(t);o||(o=new Map,e.set(t,o)),o.set(n,r)}return e}(e),is.set(e,n)),n}function cs(t){const e=t.constructor.clone(t);return e.afterCloneFrom(t),e}function as(t,e){const n=parseInt(t.style.paddingInlineStart,10)||0,r=Math.round(n/40);e.setIndent(r)}function us(t){return!0===t.__lexicalUnmanaged}function fs(t,e){return function(t,e){return Object.prototype.hasOwnProperty.call(t,e)}(t,e)&&t[e]!==En[e]}function ds(e){const n=F in e.prototype?e.prototype[F]():void 0,r=function(e){if(!(e===En||e.prototype instanceof En)){let n="",r="";try{n=e.getType()}catch(t){}try{Oo.version&&(r=JSON.parse(Oo.version))}catch(t){}t(290,e.name,n,r)}return e===uo||e===lo||e===En}(e),o=!r&&fs(e,"getType")?e.getType():void 0;let i,s=o;if(n)if(o)i=n[o];else for(const[t,e]of Object.entries(n))s=t,i=e;if(!r&&s&&(fs(e,"getType")||(e.getType=()=>s),fs(e,"clone")||(e.clone=t=>(Mo(t),new e)),fs(e,"importJSON")||(e.importJSON=i&&i.$importJSON||(t=>(new e).updateFromJSON(t))),!fs(e,"importDOM")&&i)){const{importDOM:t}=i;t&&(e.importDOM=()=>t)}return{ownNodeConfig:i,ownNodeType:s}}const hs=(t,e)=>{let n=t;for(;null!=n&&!go(n);){if(e(n))return n;n=n.getParent()}return null},gs={next:"previous",previous:"next"};class _s{origin;constructor(t){this.origin=t}[Symbol.iterator](){return Ws({hasNext:Ts,initial:this.getAdjacentCaret(),map:t=>t,step:t=>t.getAdjacentCaret()})}getAdjacentCaret(){return bs(this.getNodeAtCaret(),this.direction)}getSiblingCaret(){return bs(this.origin,this.direction)}remove(){const t=this.getNodeAtCaret();return t&&t.remove(),this}replaceOrInsert(t,e){const n=this.getNodeAtCaret();return t.is(this.origin)||t.is(n)||(null===n?this.insert(t):n.replace(t,e)),this}splice(e,n,r="next"){const o=r===this.direction?n:Array.from(n).reverse();let i=this;const s=this.getParentAtCaret(),l=new Map;for(let t=i.getAdjacentCaret();null!==t&&l.size0){const n=i.getNodeAtCaret();if(n)if(l.delete(n.getKey()),l.delete(e.getKey()),n.is(e)||i.origin.is(e));else{const t=e.getParent();t&&t.is(s)&&e.remove(),n.replace(e)}else null===n&&t(263,Array.from(l).join(" "))}else i.insert(e);i=bs(e,this.direction)}for(const t of l.values())t.remove();return this}}class ps extends _s{type="child";getLatest(){const t=this.origin.getLatest();return t===this.origin?this:Ds(t,this.direction)}getParentCaret(t="root"){return bs(xs(this.getParentAtCaret(),t),this.direction)}getFlipped(){const t=ms(this.direction);return bs(this.getNodeAtCaret(),t)||Ds(this.origin,t)}getParentAtCaret(){return this.origin}getChildCaret(){return this}isSameNodeCaret(t){return t instanceof ps&&this.direction===t.direction&&this.origin.is(t.origin)}isSamePointCaret(t){return this.isSameNodeCaret(t)}}const ys={root:go,shadowRoot:Ki};function ms(t){return gs[t]}function xs(t,e="root"){return ys[e](t)?null:t}class Cs extends _s{type="sibling";getLatest(){const t=this.origin.getLatest();return t===this.origin?this:bs(t,this.direction)}getSiblingCaret(){return this}getParentAtCaret(){return this.origin.getParent()}getChildCaret(){return co(this.origin)?Ds(this.origin,this.direction):null}getParentCaret(t="root"){return bs(xs(this.getParentAtCaret(),t),this.direction)}getFlipped(){const t=ms(this.direction);return bs(this.getNodeAtCaret(),t)||Ds(this.origin.getParentOrThrow(),t)}isSamePointCaret(t){return t instanceof Cs&&this.direction===t.direction&&this.origin.is(t.origin)}isSameNodeCaret(t){return(t instanceof Cs||t instanceof Ss)&&this.direction===t.direction&&this.origin.is(t.origin)}}class Ss extends _s{type="text";offset;constructor(t,e){super(t),this.offset=e}getLatest(){const t=this.origin.getLatest();return t===this.origin?this:Ms(t,this.direction,this.offset)}getParentAtCaret(){return this.origin.getParent()}getChildCaret(){return null}getParentCaret(t="root"){return bs(xs(this.getParentAtCaret(),t),this.direction)}getFlipped(){return Ms(this.origin,ms(this.direction),this.offset)}isSamePointCaret(t){return t instanceof Ss&&this.direction===t.direction&&this.origin.is(t.origin)&&this.offset===t.offset}isSameNodeCaret(t){return(t instanceof Cs||t instanceof Ss)&&this.direction===t.direction&&this.origin.is(t.origin)}getSiblingCaret(){return bs(this.origin,this.direction)}}function Ns(t){return t instanceof Ss}function Ts(t){return t instanceof Cs}function vs(t){return t instanceof ps}const ks={next:class extends Ss{direction="next";getNodeAtCaret(){return this.origin.getNextSibling()}insert(t){return this.origin.insertAfter(t),this}},previous:class extends Ss{direction="previous";getNodeAtCaret(){return this.origin.getPreviousSibling()}insert(t){return this.origin.insertBefore(t),this}}},Es={next:class extends Cs{direction="next";getNodeAtCaret(){return this.origin.getNextSibling()}insert(t){return this.origin.insertAfter(t),this}},previous:class extends Cs{direction="previous";getNodeAtCaret(){return this.origin.getPreviousSibling()}insert(t){return this.origin.insertBefore(t),this}}},Os={next:class extends ps{direction="next";getNodeAtCaret(){return this.origin.getFirstChild()}insert(t){return this.origin.splice(0,0,[t]),this}},previous:class extends ps{direction="previous";getNodeAtCaret(){return this.origin.getLastChild()}insert(t){return this.origin.splice(this.origin.getChildrenSize(),0,[t]),this}}};function bs(t,e){return t?new Es[e](t):null}function Ms(t,e,n){return t?new ks[e](t,As(t,n)):null}function As(t,n,r="error"){const o=t.getTextContentSize();let i="next"===n?o:"previous"===n?0:n;return(i<0||i>o)&&("clamp"!==r&&e(284,String(n),String(o),t.getKey()),i=i<0?0:o),i}function ws(t,e){return new Ls(t,e)}function Ds(t,e){return co(t)?new Os[e](t):null}function Ps(t){return t&&t.getChildCaret()||t}function Is(t){return t&&Ps(t.getAdjacentCaret())}class Rs{type="node-caret-range";direction;anchor;focus;constructor(t,e,n){this.anchor=t,this.focus=e,this.direction=n}getLatest(){const t=this.anchor.getLatest(),e=this.focus.getLatest();return t===this.anchor&&e===this.focus?this:new Rs(t,e,this.direction)}isCollapsed(){return this.anchor.isSamePointCaret(this.focus)}getTextSlices(){const t=t=>{const e=this[t].getLatest();return Ns(e)?function(t,e){const{direction:n,origin:r}=t,o=As(r,"focus"===e?ms(n):n);return ws(t,o-t.offset)}(e,t):null},e=t("anchor"),n=t("focus");if(e&&n){const{caret:t}=e,{caret:r}=n;if(t.isSameNodeCaret(r))return[ws(t,r.offset-t.offset),null]}return[e,n]}iterNodeCarets(t="root"){const e=Ns(this.anchor)?this.anchor.getSiblingCaret():this.anchor.getLatest(),n=this.focus.getLatest(),r=Ns(n),o=e=>e.isSameNodeCaret(n)?null:Is(e)||e.getParentCaret(t);return Ws({hasNext:t=>null!==t&&!(r&&n.isSameNodeCaret(t)),initial:e.isSameNodeCaret(n)?null:o(e),map:t=>t,step:o})}[Symbol.iterator](){return this.iterNodeCarets("root")}}class Ls{type="slice";caret;distance;constructor(t,e){this.caret=t,this.distance=e}getSliceIndices(){const{distance:t,caret:{offset:e}}=this,n=e+t;return n{let n;for(let r=c;rn.has(t.getKey())&&rs(t));return u&&f?[u,f]:null}(f,d,a);if(h){const[t,e]=h;Ds(t,"previous").splice(0,e.getChildren()),e.remove()}const g=[f,d,...l,...c].find(Zs);if(g){return Ks(rl(el(g),e.direction))}t(269,JSON.stringify(l.map(t=>t.origin.__key)))}function el(t){const e=function(t){let e=t;for(;vs(e);){const t=Is(e);if(!vs(t))break;e=t}return e}(t.getLatest()),{direction:n}=e;if(Zn(e.origin))return Ns(e)?e:Ms(e.origin,n,n);const r=e.getAdjacentCaret();return Ts(r)&&Zn(r.origin)?Ms(r.origin,n,ms(n)):e}function nl(t){return Ns(t)&&t.offset!==As(t.origin,t.direction)}function rl(t,e){return t.direction===e?t:t.getFlipped()}function ol(t,e){return t.direction===e?t:Bs(rl(t.focus,e),rl(t.anchor,e))}function il(t,e,n){let r=Ds(t,"next");for(let t=0;t0||n.canBeEmpty()&&o(n,"last"))&&i.insert(e(n).splice(0,0,r))}return i},exports.$splitNode=function(e,n){let r=e.getChildAtIndex(n);null==r&&(r=e),Ki(e)&&t(102);const o=e=>{const n=e.getParentOrThrow(),i=Ki(n),s=e!==r||i?Bi(e):e;if(i)return co(e)&&co(s)||t(133),e.insertAfter(s),[e,s,s];{const[t,r,i]=o(n),l=e.getNextSiblings();return i.append(s,...l),[t,r,s]}},[i,s]=o(r);return[i,s]},exports.$updateRangeSelectionFromCaretRange=Gs,exports.ArtificialNode__DO_NOT_USE=xo,exports.BEFORE_INPUT_COMMAND=Gt,exports.BLUR_COMMAND=Be,exports.CAN_REDO_COMMAND=Le,exports.CAN_UNDO_COMMAND=Fe,exports.CLEAR_EDITOR_COMMAND=Ie,exports.CLEAR_HISTORY_COMMAND=Re,exports.CLICK_COMMAND=Vt,exports.COLLABORATION_TAG=bn,exports.COMMAND_PRIORITY_CRITICAL=4,exports.COMMAND_PRIORITY_EDITOR=vo,exports.COMMAND_PRIORITY_HIGH=3,exports.COMMAND_PRIORITY_LOW=1,exports.COMMAND_PRIORITY_NORMAL=2,exports.COMPOSITION_END_COMMAND=Qt,exports.COMPOSITION_START_COMMAND=Xt,exports.CONTROLLED_TEXT_INSERTION_COMMAND=ne,exports.COPY_COMMAND=we,exports.CUT_COMMAND=De,exports.DELETE_CHARACTER_COMMAND=Zt,exports.DELETE_LINE_COMMAND=se,exports.DELETE_WORD_COMMAND=ie,exports.DRAGEND_COMMAND=Ae,exports.DRAGOVER_COMMAND=Me,exports.DRAGSTART_COMMAND=be,exports.DROP_COMMAND=Ee,exports.DecoratorNode=uo,exports.ElementNode=lo,exports.FOCUS_COMMAND=Ke,exports.FORMAT_ELEMENT_COMMAND=Oe,exports.FORMAT_TEXT_COMMAND=le,exports.HISTORIC_TAG="historic",exports.HISTORY_MERGE_TAG=On,exports.HISTORY_PUSH_TAG="history-push",exports.INDENT_CONTENT_COMMAND=ve,exports.INPUT_COMMAND=qt,exports.INSERT_LINE_BREAK_COMMAND=te,exports.INSERT_PARAGRAPH_COMMAND=ee,exports.INSERT_TAB_COMMAND=Te,exports.INTERNAL_$isBlock=rs,exports.IS_ALL_FORMATTING=2047,exports.IS_BOLD=1,exports.IS_CODE=16,exports.IS_HIGHLIGHT=y,exports.IS_ITALIC=2,exports.IS_STRIKETHROUGH=4,exports.IS_SUBSCRIPT=32,exports.IS_SUPERSCRIPT=64,exports.IS_UNDERLINE=8,exports.KEY_ARROW_DOWN_COMMAND=pe,exports.KEY_ARROW_LEFT_COMMAND=he,exports.KEY_ARROW_RIGHT_COMMAND=fe,exports.KEY_ARROW_UP_COMMAND=_e,exports.KEY_BACKSPACE_COMMAND=xe,exports.KEY_DELETE_COMMAND=Se,exports.KEY_DOWN_COMMAND=ue,exports.KEY_ENTER_COMMAND=ye,exports.KEY_ESCAPE_COMMAND=Ce,exports.KEY_MODIFIER_COMMAND=We,exports.KEY_SPACE_COMMAND=me,exports.KEY_TAB_COMMAND=Ne,exports.LineBreakNode=Dn,exports.MOVE_TO_END=de,exports.MOVE_TO_START=ge,exports.NODE_STATE_KEY="$",exports.OUTDENT_CONTENT_COMMAND=ke,exports.PASTE_COMMAND=re,exports.PASTE_TAG="paste",exports.ParagraphNode=Co,exports.REDO_COMMAND=ae,exports.REMOVE_TEXT_COMMAND=oe,exports.RootNode=ho,exports.SELECTION_CHANGE_COMMAND=Yt,exports.SELECTION_INSERT_CLIPBOARD_NODES_COMMAND=Ht,exports.SELECT_ALL_COMMAND=Pe,exports.SKIP_COLLAB_TAG="skip-collab",exports.SKIP_DOM_SELECTION_TAG=An,exports.SKIP_SCROLL_INTO_VIEW_TAG=Mn,exports.SKIP_SELECTION_FOCUS_TAG=wn,exports.TEXT_TYPE_TO_FORMAT=w,exports.TabNode=er,exports.TextNode=Un,exports.UNDO_COMMAND=ce,exports.buildImportMap=function(t){return t},exports.configExtension=function(...t){return t},exports.createCommand=Jt,exports.createEditor=function(t){const e=t||{},n=Vr(),r=e.theme||{},o=void 0===t?n:e.parentEditor||null,i=e.disableEvents||!1,s=po(),l=e.namespace||(null!==o?o._config.namespace:ai()),c=e.editorState,a=[ho,Un,Dn,er,Co,xo,...e.nodes||[]],{onError:u,html:f}=e,d=void 0===e.editable||e.editable;let h;if(void 0===t&&null!==n)h=n._nodes;else{h=new Map;for(let t=0;t{Object.keys(t).forEach(e=>{let r=n.get(e);void 0===r&&(r=[],n.set(e,r)),r.push(t[e])})};return t.forEach(t=>{const e=t.klass.importDOM;if(null==e||r.has(e))return;r.add(e);const n=e.call(t.klass);null!==n&&o(n)}),e&&o(e),n}(h,f?f.import:void 0),d,t);return void 0!==c&&(g._pendingEditorState=c,g._dirtyType=2),function(t){t.registerCommand(Gt,un,vo),t.registerCommand(qt,fn,vo),t.registerCommand(Xt,dn,vo),t.registerCommand(Qt,hn,vo),t.registerCommand(ue,_n,vo)}(g),g},exports.createSharedNodeState=X,exports.createState=function(t,e){return new G(t,e)},exports.declarePeerDependency=function(t,e){return[t,e]},exports.defineExtension=function(t){return t},exports.flipDirection=ms,exports.getDOMOwnerDocument=wi,exports.getDOMSelection=Yi,exports.getDOMSelectionForEditor=Hi,exports.getDOMSelectionFromShadowRoot=Ji,exports.getDOMSelectionFromTarget=Xi,exports.getDOMTextNode=jo,exports.getDocumentFromElement=Gi,exports.getEditorPropertyFromDOMNode=Bo,exports.getNearestEditorFromDOMNode=Ko,exports.getRegisteredNode=Do,exports.getRegisteredNodeOrThrow=wo,exports.getShadowRootOrDocument=Vi,exports.getStaticNodeConfig=ds,exports.getTextDirection=function(t){return M.test(t)?"rtl":A.test(t)?"ltr":null},exports.getTransformSetFromKlass=Eo,exports.getWindow=Li,exports.isBlockDomNode=ns,exports.isCurrentlyReadOnlyMode=$r,exports.isDOMDocumentNode=Uo,exports.isDOMNode=Zi,exports.isDOMTextNode=$o,exports.isDOMUnmanaged=us,exports.isDocumentFragment=ts,exports.isExactShortcutMatch=pi,exports.isHTMLAnchorElement=function(t){return Qi(t)&&"A"===t.tagName},exports.isHTMLElement=Qi,exports.isInlineDomNode=es,exports.isLexicalEditor=Fo,exports.isModifierMatch=_i,exports.isSelectionCapturedInDecoratorInput=Ro,exports.isSelectionWithinEditor=Lo,exports.isShadowRoot=Mi,exports.makeStepwiseIterator=Ws,exports.removeFromParent=Ho,exports.resetRandomKey=function(){Ao=1},exports.safeCast=function(t){return t},exports.setDOMUnmanaged=function(t){t.__lexicalUnmanaged=!0},exports.setNodeIndentFromDOM=as,exports.shallowMergeConfig=function(t,e){if(!e||t===e)return t;for(const n in e)if(t[n]!==e[n])return{...t,...e};return t}; +diff --git a/node_modules/lexical/Lexical.prod.mjs b/node_modules/lexical/Lexical.prod.mjs +index 2708e66..c9f17d3 100644 +--- a/node_modules/lexical/Lexical.prod.mjs ++++ b/node_modules/lexical/Lexical.prod.mjs +@@ -6,4 +6,4 @@ + * + */ + +-function t(t,...e){const n=new URL("https://lexical.dev/docs/error"),r=new URLSearchParams;r.append("code",t);for(const t of e)r.append("v",t);throw n.search=r.toString(),Error(`Minified Lexical error #${t}; visit ${n.toString()} for the full message or use the non-minified dev environment for full errors and additional helpful warnings.`)}function e(t,...e){const n=new URL("https://lexical.dev/docs/error"),r=new URLSearchParams;r.append("code",t);for(const t of e)r.append("v",t);n.search=r.toString(),console.warn(`Minified Lexical warning #${t}; visit ${n.toString()} for the full message or use the non-minified dev environment for full errors and additional helpful warnings.`)}const n="undefined"!=typeof window&&void 0!==window.document&&void 0!==window.document.createElement,r=n&&"documentMode"in document?document.documentMode:null,i=n&&/Mac|iPod|iPhone|iPad/.test(navigator.platform),o=n&&/^(?!.*Seamonkey)(?=.*Firefox).*/i.test(navigator.userAgent),s=!(!n||!("InputEvent"in window)||r)&&"getTargetRanges"in new window.InputEvent("input"),l=n&&/Version\/[\d.]+.*Safari/.test(navigator.userAgent),c=n&&/iPad|iPhone|iPod/.test(navigator.userAgent)&&!window.MSStream,a=n&&/Android/.test(navigator.userAgent),u=n&&/^(?=.*Chrome).*/i.test(navigator.userAgent),f=n&&a&&u,d=n&&/AppleWebKit\/[\d.]+/.test(navigator.userAgent)&&i&&!u;function h(...t){const e=[];for(const n of t)if(n&&"string"==typeof n)for(const[t]of n.matchAll(/\S+/g))e.push(t);return e}const g=0,_=1,p=2,y=1,m=2,x=4,C=8,S=16,v=32,k=64,T=128,N=2047,b=1,w=2,E=3,O=4,M=5,A=6,P=l||c||d?" ":"​",D="\n\n",F=o?" ":P,L="֑-߿יִ-﷽ﹰ-ﻼ",I="A-Za-zÀ-ÖØ-öø-ʸ̀-֐ࠀ-῿‎Ⰰ-﬜︀-﹯﻽-￿",K=new RegExp("^[^"+I+"]*["+L+"]"),z=new RegExp("^[^"+L+"]*["+I+"]"),R={bold:1,capitalize:1024,code:16,highlight:T,italic:2,lowercase:256,strikethrough:4,subscript:32,superscript:64,underline:8,uppercase:512},B={directionless:1,unmergeable:2},W={center:2,end:6,justify:4,left:1,right:3,start:5},J={[w]:"center",[A]:"end",[O]:"justify",[b]:"left",[E]:"right",[M]:"start"},j={normal:0,segmented:2,token:1},$={[g]:"normal",[p]:"segmented",[_]:"token"},U="$",V="$config";function Y(t,e,n,r,i,o){let s=t.getFirstChild();for(;null!==s;){const t=s.__key;s.__parent===e&&(Si(s)&&Y(s,t,n,r,i,o),n.has(t)||o.delete(t),i.push(t)),s=s.getNextSibling()}}let q=!1,H=0;function G(t){H=t.timeStamp}function X(t,e,n){const r="BR"===t.nodeName,i=e.__lexicalLineBreak;return i&&(t===i||r&&t.previousSibling===i)||r&&void 0!==So(t,n)}function Q(t,e,n){const r=ps(ss(n));let i=null,o=null;null!==r&&r.anchorNode===t&&(i=r.anchorOffset,o=r.focusOffset);const s=t.nodeValue;null!==s&&Fo(e,s,i,o,!1)}function Z(t,e,n){if(yr(t)){const e=t.anchor.getNode();if(e.is(n)&&t.format!==e.getFormat())return!1}return co(e)&&n.isAttached()}function tt(t,e,n,r){for(let i=t;i&&!Fs(i);i=Zo(i)){const t=So(i,e);if(void 0!==t){const e=xo(t,n);if(e)return Ti(e)||!Cs(i)?void 0:[i,e]}else if(i===r)return[r,bo(n)]}}function et(t,e,n){q=!0;const r=performance.now()-H>100;try{yi(t,()=>{const i=Lr()||function(t){return t.getEditorState().read(()=>{const t=Lr();return null!==t?t.clone():null})}(t),s=new Map,l=t.getRootElement(),c=t._editorState,a=t._blockCursorElement;let u=!1,f="";for(let n=0;n0){let e=0;for(let i=0;i0)for(const[e,n]of s)n.reconcileObservedMutation(e,t);const d=n.takeRecords();if(d.length>0){for(let e=0;e{et(t,e,n)})}class it{key;parse;unparse;isEqual;defaultValue;constructor(t,e){this.key=t,this.parse=e.parse.bind(e),this.unparse=(e.unparse||gt).bind(e),this.isEqual=(e.isEqual||Object.is).bind(e),this.defaultValue=this.parse(void 0)}}function ot(t,e){return new it(t,e)}function st(t,e,n="latest"){const r=("latest"===n?t.getLatest():t).__state;return r?r.getValue(e):e.defaultValue}function lt(t,e,n){const r=st(t,n,"direct"),i=st(e,n,"direct");return n.isEqual(r,i)?null:[r,i]}function ct(t,e,n){let r;if(ei(),"function"==typeof n){const i=t.getLatest(),o=st(i,e);if(r=n(o),e.isEqual(o,r))return i}else r=n;const i=t.getWritable();return ft(i).updateFromKnown(e,r),i}function at(t){const e=new Map,n=new Set;for(let r="function"==typeof t?t:t.replace;r.prototype&&void 0!==r.prototype.getType;r=Object.getPrototypeOf(r)){const{ownNodeConfig:t}=Is(r);if(t&&t.stateConfigs)for(const r of t.stateConfigs){let t;"stateConfig"in r?(t=r.stateConfig,r.flat&&n.add(t.key)):t=r,e.set(t.key,t)}}return{flatKeys:n,sharedConfigMap:e}}class ut{node;knownState;unknownState;sharedNodeState;size;constructor(t,e,n=void 0,r=new Map,i=void 0){this.node=t,this.sharedNodeState=e,this.unknownState=n,this.knownState=r;const{sharedConfigMap:o}=this.sharedNodeState,s=void 0!==i?i:function(t,e,n){let r=n.size;if(e)for(const i in e){const e=t.get(i);e&&n.has(e)||r++}return r}(o,n,r);this.size=s}getValue(t){const e=this.knownState.get(t);if(void 0!==e)return e;this.sharedNodeState.sharedConfigMap.set(t.key,t);let n=t.defaultValue;if(this.unknownState&&t.key in this.unknownState){const e=this.unknownState[t.key];void 0!==e&&(n=t.parse(e)),this.updateFromKnown(t,n)}return n}getInternalState(){return[this.unknownState,this.knownState]}toJSON(){const t={...this.unknownState},e={};for(const[e,n]of this.knownState)e.isEqual(n,e.defaultValue)?delete t[e.key]:t[e.key]=e.unparse(n);for(const n of this.sharedNodeState.flatKeys)n in t&&(e[n]=t[n],delete t[n]);return ht(t)&&(e.$=t),e}getWritable(t){if(this.node===t)return this;const{sharedNodeState:e,unknownState:n}=this,r=new Map(this.knownState);return new ut(t,e,function(t,e,n){let r;if(n)for(const[i,o]of Object.entries(n)){const n=t.get(i);n?e.has(n)||e.set(n,n.parse(o)):(r=r||{},r[i]=o)}return r}(e.sharedConfigMap,r,n),r,this.size)}updateFromKnown(t,e){const n=t.key;this.sharedNodeState.sharedConfigMap.set(n,t);const{knownState:r,unknownState:i}=this;r.has(t)||i&&n in i||(i&&(delete i[n],this.unknownState=ht(i)),this.size++),r.set(t,e)}updateFromUnknown(t,e){const n=this.sharedNodeState.sharedConfigMap.get(t);n?this.updateFromKnown(n,n.parse(e)):(this.unknownState=this.unknownState||{},t in this.unknownState||this.size++,this.unknownState[t]=e)}updateFromJSON(t){const{knownState:e}=this;for(const t of e.keys())e.set(t,t.defaultValue);if(this.size=e.size,this.unknownState=void 0,t)for(const[e,n]of Object.entries(t))this.updateFromUnknown(e,n)}}function ft(t){const e=t.getWritable(),n=e.__state?e.__state.getWritable(e):new ut(e,dt(e));return e.__state=n,n}function dt(t){return t.__state?t.__state.sharedNodeState:Gi(bs(),t.getType()).sharedNodeState}function ht(t){if(t)for(const e in t)return t}function gt(t){return t}function _t(t,e,n){for(const[r,i]of e.knownState){if(t.has(r.key))continue;t.add(r.key);const e=n?n.getValue(r):r.defaultValue;if(e!==i&&!r.isEqual(e,i))return!0}return!1}function pt(t,e,n){const{unknownState:r}=e,i=n?n.unknownState:void 0;if(r)for(const[e,n]of Object.entries(r)){if(t.has(e))continue;t.add(e);if(n!==(i?i[e]:void 0))return!0}return!1}function yt(t,e){const n=t.__state;return n&&n.node===t?n.getWritable(e):n}function mt(t,e){const n=t.__mode,r=t.__format,i=t.__style,o=e.__mode,s=e.__format,l=e.__style,c=t.__state,a=e.__state;return(null===n||n===o)&&(null===r||r===s)&&(null===i||i===l)&&(null===t.__state||c===a||function(t,e){if(t===e)return!0;if(t&&e&&t.size!==e.size)return!1;const n=new Set;return!(t&&_t(n,t,e)||e&&_t(n,e,t)||t&&pt(n,t,e)||e&&pt(n,e,t))}(c,a))}function xt(t,e){const n=t.mergeWithSibling(e),r=ii()._normalizedNodes;return r.add(t.__key),r.add(e.__key),n}function Ct(t){let e,n,r=t;if(""!==r.__text||!r.isSimpleText()||r.isUnmergeable()){for(;null!==(e=r.getPreviousSibling())&&lr(e)&&e.isSimpleText()&&!e.isUnmergeable();){if(""!==e.__text){if(mt(e,r)){r=xt(e,r);break}break}e.remove()}for(;null!==(n=r.getNextSibling())&&lr(n)&&n.isSimpleText()&&!n.isUnmergeable();){if(""!==n.__text){if(mt(r,n)){r=xt(r,n);break}break}n.remove()}}else r.remove()}function St(t){return vt(t.anchor),vt(t.focus),t}function vt(t){for(;"element"===t.type;){const e=t.getNode(),n=t.offset;let r,i;if(n===e.getChildrenSize()?(r=e.getChildAtIndex(n-1),i=!0):(r=e.getChildAtIndex(n),i=!1),lr(r)){t.set(r.__key,i?r.getTextContentSize():0,"text",!0);break}if(!Si(r))break;t.set(r.__key,i?r.getChildrenSize():0,"element",!0)}}let kt,Tt,Nt,bt,wt,Et,Ot,Mt,At,Pt,Dt="",Ft=null,Lt="",It="",Kt=!1,zt=!1;function Rt(t,e){const n=Ot.get(t);if(null!==e){const n=ne(t);n.parentNode===e&&e.removeChild(n)}if(Mt.has(t)||Tt._keyToDOMMap.delete(t),Si(n)){const t=Xt(n,Ot);Bt(t,0,t.length-1,null)}void 0!==n&&Uo(Pt,Nt,bt,n,"destroyed")}function Bt(t,e,n,r){let i=e;for(;i<=n;++i){const e=t[i];void 0!==e&&Rt(e,r)}}function Wt(t,e){t.setProperty("text-align",e)}const Jt="40px";function jt(t,e){const n=kt.theme.indent;if("string"==typeof n){const r=t.classList.contains(n);e>0&&!r?t.classList.add(n):e<1&&r&&t.classList.remove(n)}const r=getComputedStyle(t).getPropertyValue("--lexical-indent-base-value")||Jt;t.style.setProperty("padding-inline-start",0===e?"":`calc(${e} * ${r})`)}function $t(t,e){const n=t.style;0===e?Wt(n,""):1===e?Wt(n,"left"):2===e?Wt(n,"center"):3===e?Wt(n,"right"):4===e?Wt(n,"justify"):5===e?Wt(n,"start"):6===e&&Wt(n,"end")}function Ut(t,e){const n=function(t){const e=t.__dir;if(null!==e)return e;if(bi(t))return null;const n=t.getParentOrThrow();return bi(n)&&null===n.__dir?"auto":null}(e);null!==n?t.dir=n:t.removeAttribute("dir")}function Vt(e,n){const r=Mt.get(e);void 0===r&&t(60);const i=r.createDOM(kt,Tt);if(function(t,e,n){const r=n._keyToDOMMap;(function(t,e,n){const r=`__lexicalKey_${e._key}`;t[r]=n})(e,n,t),r.set(t,e)}(e,i,Tt),lr(r)?i.setAttribute("data-lexical-text","true"):Ti(r)&&i.setAttribute("data-lexical-decorator","true"),Si(r)){const t=r.__indent,e=r.__size;if(Ut(i,r),0!==t&&jt(i,t),0!==e){const t=e-1;Yt(Xt(r,Mt),r,0,t,r.getDOMSlot(i))}const n=r.__format;0!==n&&$t(i,n),r.isInline()||Ht(null,r,i),Xo(r)&&(Dt+=D,It+=D)}else{const t=r.getTextContent();if(Ti(r)){const t=r.decorate(Tt,kt);null!==t&&Zt(e,t),i.contentEditable="false"}Dt+=t,It+=t}return null!==n&&n.insertChild(i),Uo(Pt,Nt,bt,r,"created"),i}function Yt(t,e,n,r,i){const o=Dt;Dt="";let s=n;for(;s<=r;++s){Vt(t[s],i);const e=Mt.get(t[s]);null!==e&&lr(e)&&(null===Ft&&(Ft=e.getFormat()),""===Lt&&(Lt=e.getStyle()))}Xo(e)&&(Dt+=D);i.element.__lexicalTextContent=Dt,Dt=o+Dt}function qt(t,e){if(t){const n=t.__last;if(n){const t=e.get(n);if(t)return jn(t)?"line-break":Ti(t)&&t.isInline()?"decorator":null}return"empty"}return null}function Ht(t,e,n){const r=qt(t,Ot),i=qt(e,Mt);r!==i&&e.getDOMSlot(n).setManagedLineBreak(i)}function Gt(e,n,r){var i;Ft=null,Lt="",function(e,n,r){const i=Dt,o=e.__size,s=n.__size;Dt="";const l=r.element;if(1===o&&1===s){const t=e.__first,r=n.__first;if(t===r)Qt(t,l);else{const e=ne(t),n=Vt(r,null);try{l.replaceChild(n,e)}catch(i){if("object"==typeof i&&null!=i){const o=`${i.toString()} Parent: ${l.tagName}, new child: {tag: ${n.tagName} key: ${r}}, old child: {tag: ${e.tagName}, key: ${t}}.`;throw new Error(o)}throw i}Rt(t,null)}const i=Mt.get(r);lr(i)&&(null===Ft&&(Ft=i.getFormat()),""===Lt&&(Lt=i.getStyle()))}else{const i=Xt(e,Ot),c=Xt(n,Mt);if(i.length!==o&&t(227),c.length!==s&&t(228),0===o)0!==s&&Yt(c,n,0,s-1,r);else if(0===s){if(0!==o){const t=null==r.after&&null==r.before&&null==r.element.__lexicalLineBreak;Bt(i,0,o-1,t?null:l),t&&(l.textContent="")}}else!function(t,e,n,r,i,o){const s=r-1,l=i-1;let c,a,u=o.getFirstChild(),f=0,d=0;for(;f<=s&&d<=l;){const t=e[f],r=n[d];if(t===r)u=te(Qt(r,o.element)),f++,d++;else{void 0===c&&(c=new Set(e)),void 0===a&&(a=new Set(n));const i=a.has(t),s=c.has(r);if(i)if(s){const t=Qo(Tt,r);t===u?u=te(Qt(r,o.element)):(o.withBefore(u).insertChild(t),Qt(r,o.element)),f++,d++}else Vt(r,o.withBefore(u)),d++;else u=te(ne(t)),Rt(t,o.element),f++}const i=Mt.get(r);null!==i&&lr(i)&&(null===Ft&&(Ft=i.getFormat()),""===Lt&&(Lt=i.getStyle()))}const h=f>s,g=d>l;if(h&&!g){const e=n[l+1],r=void 0===e?null:Tt.getElementByKey(e);Yt(n,t,d,l,o.withBefore(r))}else g&&!h&&Bt(e,f,s,o.element)}(n,i,c,o,s,r)}Xo(n)&&(Dt+=D);l.__lexicalTextContent=Dt,Dt=i+Dt}(e,n,n.getDOMSlot(r)),i=n,null==Ft||Ft===i.__textFormat||zt||i.setTextFormat(Ft),function(t){""===Lt||Lt===t.__textStyle||zt||t.setTextStyle(Lt)}(n)}function Xt(e,n){const r=[];let i=e.__first;for(;null!==i;){const e=n.get(i);void 0===e&&t(101),r.push(i),i=e.__next}return r}function Qt(e,n){const r=Ot.get(e);let i=Mt.get(e);void 0!==r&&void 0!==i||t(61);const o=Kt||Et.has(e)||wt.has(e),s=Qo(Tt,e);if(r===i&&!o){if(Si(r)){const t=s.__lexicalTextContent;void 0!==t&&(Dt+=t,It+=t)}else{const t=r.getTextContent();It+=t,Dt+=t}return s}if(r!==i&&o&&Uo(Pt,Nt,bt,i,"updated"),i.updateDOM(r,s,kt)){const r=Vt(e,null);return null===n&&t(62),n.replaceChild(r,s),Rt(e,null),r}if(Si(r)&&Si(i)){const t=i.__indent;(Kt||t!==r.__indent)&&jt(s,t);const e=i.__format;if((Kt||e!==r.__format)&&$t(s,e),o&&(Gt(r,i,s),bi(i)||i.isInline()||Ht(r,i,s)),Xo(i)&&(Dt+=D,It+=D),(Kt||i.__dir!==r.__dir)&&(Ut(s,i),bi(i)&&!Kt))for(const t of i.getChildren())if(Si(t)){Ut(Qo(Tt,t.getKey()),t)}}else{const t=i.getTextContent();if(Ti(i)){const t=i.decorate(Tt,kt);null!==t&&Zt(e,t)}Dt+=t,It+=t}if(!zt&&bi(i)&&i.__cachedText!==It){const t=i.getWritable();t.__cachedText=It,i=t}return s}function Zt(t,e){let n=Tt._pendingDecorators;const r=Tt._decorators;if(null===n){if(r[t]===e)return;n=ko(Tt)}n[t]=e}function te(t){let e=t.nextSibling;return null!==e&&e===Tt._blockCursorElement&&(e=e.nextSibling),e}function ee(t,e,n,r,i,o){Dt="",It="",Kt=2===r,Tt=n,kt=n._config,Nt=n._nodes,bt=Tt._listeners.mutation,wt=i,Et=o,Ot=t._nodeMap,Mt=e._nodeMap,zt=e._readOnly,At=new Map(n._keyToDOMMap);const s=new Map;return Pt=s,Qt("root",null),Tt=void 0,Nt=void 0,wt=void 0,Et=void 0,Ot=void 0,Mt=void 0,kt=void 0,At=void 0,Pt=void 0,s}function ne(e){const n=At.get(e);return void 0===n&&t(75,e),n}function re(t){return{type:t}}const ie=re("SELECTION_CHANGE_COMMAND"),oe=re("SELECTION_INSERT_CLIPBOARD_NODES_COMMAND"),se=re("CLICK_COMMAND"),le=re("DELETE_CHARACTER_COMMAND"),ce=re("INSERT_LINE_BREAK_COMMAND"),ae=re("INSERT_PARAGRAPH_COMMAND"),ue=re("CONTROLLED_TEXT_INSERTION_COMMAND"),fe=re("PASTE_COMMAND"),de=re("REMOVE_TEXT_COMMAND"),he=re("DELETE_WORD_COMMAND"),ge=re("DELETE_LINE_COMMAND"),_e=re("FORMAT_TEXT_COMMAND"),pe=re("UNDO_COMMAND"),ye=re("REDO_COMMAND"),me=re("KEYDOWN_COMMAND"),xe=re("KEY_ARROW_RIGHT_COMMAND"),Ce=re("MOVE_TO_END"),Se=re("KEY_ARROW_LEFT_COMMAND"),ve=re("MOVE_TO_START"),ke=re("KEY_ARROW_UP_COMMAND"),Te=re("KEY_ARROW_DOWN_COMMAND"),Ne=re("KEY_ENTER_COMMAND"),be=re("KEY_SPACE_COMMAND"),we=re("KEY_BACKSPACE_COMMAND"),Ee=re("KEY_ESCAPE_COMMAND"),Oe=re("KEY_DELETE_COMMAND"),Me=re("KEY_TAB_COMMAND"),Ae=re("INSERT_TAB_COMMAND"),Pe=re("INDENT_CONTENT_COMMAND"),De=re("OUTDENT_CONTENT_COMMAND"),Fe=re("DROP_COMMAND"),Le=re("FORMAT_ELEMENT_COMMAND"),Ie=re("DRAGSTART_COMMAND"),Ke=re("DRAGOVER_COMMAND"),ze=re("DRAGEND_COMMAND"),Re=re("COPY_COMMAND"),Be=re("CUT_COMMAND"),We=re("SELECT_ALL_COMMAND"),Je=re("CLEAR_EDITOR_COMMAND"),je=re("CLEAR_HISTORY_COMMAND"),$e=re("CAN_REDO_COMMAND"),Ue=re("CAN_UNDO_COMMAND"),Ve=re("FOCUS_COMMAND"),Ye=re("BLUR_COMMAND"),qe=re("KEY_MODIFIER_COMMAND"),He=Object.freeze({}),Ge=[["keydown",function(t,e){if(Xe=t.timeStamp,Qe=t.key,e.isComposing())return;if(Go(e,me,t))return;if(null==t.key)return;if(cn&&Wo(t))return yi(e,()=>{mn(e,an)}),cn=!1,void(an="");if(function(t){return zo(t,"ArrowRight",{shiftKey:"any"})}(t))Go(e,xe,t);else if(function(t){return zo(t,"ArrowRight",Ro)}(t))Go(e,Ce,t);else if(function(t){return zo(t,"ArrowLeft",{shiftKey:"any"})}(t))Go(e,Se,t);else if(function(t){return zo(t,"ArrowLeft",Ro)}(t))Go(e,ve,t);else if(function(t){return zo(t,"ArrowUp",{altKey:"any",shiftKey:"any"})}(t))Go(e,ke,t);else if(function(t){return zo(t,"ArrowDown",{altKey:"any",shiftKey:"any"})}(t))Go(e,Te,t);else if(function(t){return zo(t,"Enter",{altKey:"any",ctrlKey:"any",metaKey:"any",shiftKey:!0})}(t))sn=!0,Go(e,Ne,t);else if(function(t){return" "===t.key}(t))Go(e,be,t);else if(function(t){return i&&zo(t,"o",{ctrlKey:!0})}(t))t.preventDefault(),sn=!0,Go(e,ce,!0);else if(function(t){return zo(t,"Enter",{altKey:"any",ctrlKey:"any",metaKey:"any"})}(t))sn=!1,Go(e,Ne,t);else if(function(t){return zo(t,"Backspace",{shiftKey:"any"})||i&&zo(t,"h",{ctrlKey:!0})}(t))Wo(t)?Go(e,we,t):(t.preventDefault(),Go(e,le,!0));else if(function(t){return"Escape"===t.key}(t))Go(e,Ee,t);else if(function(t){return zo(t,"Delete",{})||i&&zo(t,"d",{ctrlKey:!0})}(t))!function(t){return"Delete"===t.key}(t)?(t.preventDefault(),Go(e,le,!1)):Go(e,Oe,t);else if(function(t){return zo(t,"Backspace",Bo)}(t))t.preventDefault(),Go(e,he,!0);else if(function(t){return zo(t,"Delete",Bo)}(t))t.preventDefault(),Go(e,he,!1);else if(function(t){return i&&zo(t,"Backspace",{metaKey:!0})}(t))t.preventDefault(),Go(e,ge,!0);else if(function(t){return i&&(zo(t,"Delete",{metaKey:!0})||zo(t,"k",{ctrlKey:!0}))}(t))t.preventDefault(),Go(e,ge,!1);else if(function(t){return zo(t,"b",Ro)}(t))t.preventDefault(),Go(e,_e,"bold");else if(function(t){return zo(t,"u",Ro)}(t))t.preventDefault(),Go(e,_e,"underline");else if(function(t){return zo(t,"i",Ro)}(t))t.preventDefault(),Go(e,_e,"italic");else if(function(t){return zo(t,"Tab",{shiftKey:"any"})}(t))Go(e,Me,t);else if(function(t){return zo(t,"z",Ro)}(t))t.preventDefault(),Go(e,pe,void 0);else if(function(t){if(i)return zo(t,"z",{metaKey:!0,shiftKey:!0});return zo(t,"y",{ctrlKey:!0})||zo(t,"z",{ctrlKey:!0,shiftKey:!0})}(t))t.preventDefault(),Go(e,ye,void 0);else{const n=e._editorState._selection;null===n||yr(n)?Jo(t)&&(t.preventDefault(),Go(e,We,t)):!function(t){return zo(t,"c",Ro)}(t)?!function(t){return zo(t,"x",Ro)}(t)?Jo(t)&&(t.preventDefault(),Go(e,We,t)):(t.preventDefault(),Go(e,Be,t)):(t.preventDefault(),Go(e,Re,t))}(function(t){return t.ctrlKey||t.shiftKey||t.altKey||t.metaKey})(t)&&Go(e,qe,t)}],["pointerdown",function(t,e){const n=t.target,r=t.pointerType;Ss(n)&&"touch"!==r&&"pen"!==r&&0===t.button&&yi(e,()=>{Zi(n)||(on=!0)})}],["compositionstart",function(t,e){yi(e,()=>{const n=Lr();if(yr(n)&&!e.isComposing()){const r=n.anchor,i=n.anchor.getNode();yo(r.key),(t.timeStamp{mn(e,t.data)}):(cn=!0,an=t.data)}],["input",function(t,e){t.stopPropagation(),yi(e,()=>{if(Cs(t.target)&&Zi(t.target))return;const n=Lr(),r=t.data,i=yn(t);if(null!=r&&yr(n)&&dn(n,i,r,t.timeStamp,!1)){ln&&(mn(e,r),ln=!1);const i=n.anchor.getNode(),a=ps(ss(e));if(null===a)return;const u=n.isBackward(),f=u?n.anchor.offset:n.focus.offset,h=u?n.focus.offset:n.anchor.offset;s&&!n.isCollapsed()&&lr(i)&&null!==a.anchorNode&&i.getTextContent().slice(0,f)+r+i.getTextContent().slice(f+h)===Po(a.anchorNode)||Go(e,ue,r);const g=r.length;o&&g>1&&"insertCompositionText"===t.inputType&&!e.isComposing()&&(n.anchor.offset-=g),l||c||d||!e.isComposing()||(Xe=0,yo(null))}else{Do(!1,e,null!==r?r:void 0),ln&&(mn(e,r||void 0),ln=!1)}!function(){ei();const t=ii();nt(t)}()},{event:t}),tn=null}],["click",function(t,e){yi(e,()=>{const n=Lr(),r=ps(ss(e)),i=Ir();if(r)if(yr(n)){const e=n.anchor,o=e.getNode();if("element"===e.type&&0===e.offset&&n.isCollapsed()&&!bi(o)&&1===No().getChildrenSize()&&o.getTopLevelElementOrThrow().isEmpty()&&null!==i&&n.is(i))r.removeAllRanges(),n.dirty=!0;else if(3===t.detail&&!n.isCollapsed()){if(o!==n.focus.getNode()){const t=zs(o,t=>Si(t)&&!t.isInline());Si(t)&&t.select(0)}}}else if("touch"===t.pointerType||"pen"===t.pointerType){const n=r.anchorNode;if(Cs(n)||co(n)){wo(Fr(i,r,e,t))}}Go(e,se,t)})}],["cut",He],["copy",He],["dragstart",He],["dragover",He],["dragend",He],["paste",He],["focus",He],["blur",He],["drop",He]];s&&Ge.push(["beforeinput",(e,n)=>function(e,n){const r=e.inputType,i=yn(e);if("deleteCompositionText"===r||o&&Ho(n))return;if("insertCompositionText"===r)return;yi(n,()=>{const o=Lr();if("deleteContentBackward"===r){if(null===o){const t=Ir();if(!yr(t))return;wo(t.clone())}if(yr(o)){const r=o.anchor.key===o.focus.key;if(s=e.timeStamp,"MediaLast"===Qe&&s{yi(n,()=>{yo(null)})},30),yr(o)){const e=o.anchor.getNode();e.markDirty(),lr(e)||t(142),pn(o,e)}}else{yo(null),e.preventDefault();const t=o.anchor.getNode(),i=t.getTextContent(),s=t.canInsertTextAfter(),l=0===o.anchor.offset&&o.focus.offset===i.length;let c=f&&r&&!l&&s;if(c&&o.isCollapsed()&&(c=!Ti(qo(o.anchor,!0))),!c){Go(n,le,!0);const t=Lr();f&&yr(t)&&t.isCollapsed()&&(un=t,setTimeout(()=>un=null))}}return}}var s;if(!yr(o))return;const l=e.data;null!==tn&&Do(!1,n,tn),o.dirty&&null===tn||!o.isCollapsed()||bi(o.anchor.getNode())||null===i||o.applyDOMRange(i),tn=null;const a=o.anchor,u=o.focus,d=a.getNode(),h=u.getNode();if("insertText"!==r&&"insertTranspose"!==r)switch(e.preventDefault(),r){case"insertFromYank":case"insertFromDrop":case"insertReplacementText":Go(n,ue,e);break;case"insertFromComposition":yo(null),Go(n,ue,e);break;case"insertLineBreak":yo(null),Go(n,ce,!1);break;case"insertParagraph":yo(null),sn&&!c?(sn=!1,Go(n,ce,!1)):Go(n,ae,void 0);break;case"insertFromPaste":case"insertFromPasteAsQuotation":Go(n,fe,e);break;case"deleteByComposition":(function(t,e){return t!==e||Si(t)||Si(e)||!so(t)||!so(e)})(d,h)&&Go(n,de,e);break;case"deleteByDrag":case"deleteByCut":Go(n,de,e);break;case"deleteContent":Go(n,le,!1);break;case"deleteWordBackward":Go(n,he,!0);break;case"deleteWordForward":Go(n,he,!1);break;case"deleteHardLineBackward":case"deleteSoftLineBackward":Go(n,ge,!0);break;case"deleteContentForward":case"deleteHardLineForward":case"deleteSoftLineForward":Go(n,ge,!1);break;case"formatStrikeThrough":Go(n,_e,"strikethrough");break;case"formatBold":Go(n,_e,"bold");break;case"formatItalic":Go(n,_e,"italic");break;case"formatUnderline":Go(n,_e,"underline");break;case"historyUndo":Go(n,pe,void 0);break;case"historyRedo":Go(n,ye,void 0)}else{if("\n"===l)e.preventDefault(),Go(n,ce,!1);else if(l===D)e.preventDefault(),Go(n,ae,void 0);else if(null==l&&e.dataTransfer){const t=e.dataTransfer.getData("text/plain");e.preventDefault(),o.insertRawText(t)}else null!=l&&dn(o,i,l,e.timeStamp,!0)?(e.preventDefault(),Go(n,ue,l)):tn=l;Ze=e.timeStamp}})}(e,n)]);let Xe=0,Qe=null,Ze=0,tn=null;const en=new WeakMap,nn=new WeakMap;let rn=!1,on=!1,sn=!1,ln=!1,cn=!1,an="",un=null,fn=[0,"",0,"root",0];function dn(t,e,n,r,i){const o=t.anchor,l=t.focus,c=o.getNode(),a=ii(),u=ps(ss(a)),f=null!==u?u.anchorNode:null,d=o.key,h=a.getElementByKey(d),g=n.length;return d!==l.key||!lr(c)||(!i&&(!s||Ze1||(i||!s)&&null!==h&&!c.isComposing()&&f!==uo(h)||null!==u&&null!==e&&(!e.collapsed||e.startContainer!==u.anchorNode||e.startOffset!==u.anchorOffset)||c.getFormat()!==t.format||c.getStyle()!==t.style||function(t,e){if(e.isSegmented())return!0;if(!t.isCollapsed())return!1;const n=t.anchor.offset,r=e.getParentOrThrow(),i=so(e);return 0===n?!e.canInsertTextBefore()||!r.canInsertTextBefore()&&!e.isComposing()||i||function(t){const e=t.getPreviousSibling();return(lr(e)||Si(e)&&e.isInline())&&!e.canInsertTextAfter()}(e):n===e.getTextContentSize()&&(!e.canInsertTextAfter()||!r.canInsertTextAfter()&&!e.isComposing()||i)}(t,c)}function hn(t,e){return co(t)&&null!==t.nodeValue&&0!==e&&e!==t.nodeValue.length}function gn(e,n,r){const{anchorNode:i,anchorOffset:o,focusNode:s,focusOffset:l}=e;rn&&(rn=!1,hn(i,o)&&hn(s,l)&&!un)||yi(n,()=>{if(!r)return void wo(null);if(!eo(n,i,s))return;let c=Lr();if(un&&yr(c)&&c.isCollapsed()){const t=c.anchor,e=un.anchor;(t.key===e.key&&t.offset===e.offset+1||1===t.offset&&e.getNode().is(t.getNode().getPreviousSibling()))&&(c=un.clone(),wo(c))}if(un=null,yr(c)){const r=c.anchor,i=r.getNode();if(c.isCollapsed()){"Range"===e.type&&e.anchorNode===e.focusNode&&(c.dirty=!0);const o=ss(n).event,s=o?o.timeStamp:performance.now(),[l,a,u,f,d]=fn,h=No(),g=!1===n.isComposing()&&""===h.getTextContent();if(s{const r=Ir(),i=e.anchorNode;if(Cs(i)||co(i)){wo(Fr(r,e,n,t))}}));const r=Mo(n),i=r[r.length-1],o=i._key,s=Cn.get(o),l=s||i;l!==n&&gn(e,l,!1),gn(e,n,!0),n!==i?Cn.set(o,n):s&&Cn.delete(o)}function vn(t){t._lexicalHandled=!0}function kn(t){return!0===t._lexicalHandled}const Tn=()=>{};function Nn(e){const n=en.get(e);if(void 0===n)return void Tn();const r=nn.get(n);if(void 0===r)return void Tn();const i=r-1;i>=0||t(164),en.delete(e),nn.set(n,i),0===i&&n.removeEventListener("selectionchange",Sn);const o=io(e);no(o)?(!function(t){if(null!==t._parentEditor){const e=Mo(t),n=e[e.length-1]._key;Cn.get(n)===t&&Cn.delete(n)}else Cn.delete(t._key)}(o),e.__lexicalEditor=null):o&&t(198);const s=xn(e);for(let t=0;tt.__key===this.__key);if(lr(this))return n;if(yr(e)&&"element"===e.anchor.type&&"element"===e.focus.type){if(e.isCollapsed())return!1;const t=this.getParent();if(Ti(this)&&this.isInline()&&t){const n=e.isBackward()?e.focus:e.anchor;if(t.is(n.getNode())&&n.offset===t.getChildrenSize()&&this.is(t.getLastChild()))return!1}}return n}getKey(){return this.__key}getIndexWithinParent(){const t=this.getParent();if(null===t)return-1;let e=t.getFirstChild(),n=0;for(;null!==e;){if(this.is(e))return n;n++,e=e.getNextSibling()}return-1}getParent(){const t=this.getLatest().__parent;return null===t?null:xo(t)}getParentOrThrow(){const e=this.getParent();return null===e&&t(66,this.__key),e}getTopLevelElement(){let e=this;for(;null!==e;){const n=e.getParent();if(as(n))return Si(e)||e===this&&Ti(e)||t(194),e;e=n}return null}getTopLevelElementOrThrow(){const e=this.getTopLevelElement();return null===e&&t(67,this.__key),e}getParents(){const t=[];let e=this.getParent();for(;null!==e;)t.push(e),e=e.getParent();return t}getParentKeys(){const t=[];let e=this.getParent();for(;null!==e;)t.push(e.__key),e=e.getParent();return t}getPreviousSibling(){const t=this.getLatest().__prev;return null===t?null:xo(t)}getPreviousSiblings(){const t=[],e=this.getParent();if(null===e)return t;let n=e.getFirstChild();for(;null!==n&&!n.is(this);)t.push(n),n=n.getNextSibling();return t}getNextSibling(){const t=this.getLatest().__next;return null===t?null:xo(t)}getNextSiblings(){const t=[];let e=this.getNextSibling();for(;null!==e;)t.push(e),e=e.getNextSibling();return t}getCommonAncestor(t){const e=Si(this)?this:this.getParent(),n=Si(t)?t:t.getParent(),r=e&&n?ml(e,n):null;return r?r.commonAncestor:null}is(t){return null!=t&&this.__key===t.__key}isBefore(e){const n=ml(this,e);return null!==n&&("descendant"===n.type||("branch"===n.type?-1===_l(n):("same"!==n.type&&"ancestor"!==n.type&&t(279),!1)))}isParentOf(t){const e=ml(this,t);return null!==e&&"ancestor"===e.type}getNodesBetween(e){const n=this.isBefore(e),r=[],i=new Set;let o=this;for(;null!==o;){const s=o.__key;if(i.has(s)||(i.add(s),r.push(o)),o===e)break;const l=Si(o)?n?o.getFirstChild():o.getLastChild():null;if(null!==l){o=l;continue}const c=n?o.getNextSibling():o.getPreviousSibling();if(null!==c){o=c;continue}const a=o.getParentOrThrow();if(i.has(a.__key)||r.push(a),a===e)break;let u=null,f=a;do{if(null===f&&t(68),u=n?f.getNextSibling():f.getPreviousSibling(),f=f.getParent(),null===f)break;null!==u||i.has(f.__key)||r.push(f)}while(null===u);o=u}return n||r.reverse(),r}isDirty(){const t=ii()._dirtyLeaves;return null!==t&&t.has(this.__key)}getLatest(){if(On(this))return this;const e=xo(this.__key);return null===e&&t(113),e}getWritable(){if(On(this))return this;ei();const t=ri(),e=ii(),n=t._nodeMap,r=this.__key,i=this.getLatest(),o=e._cloneNotNeeded,s=Lr();if(null!==s&&s.setCachedNodes(null),o.has(r))return po(i),i;const l=Ms(i);return o.add(r),po(l),n.set(r,l),l}getTextContent(){return""}getTextContentSize(){return this.getTextContent().length}createDOM(e,n){t(70)}updateDOM(e,n,r){t(71)}exportDOM(t){return{element:this.createDOM(t._config,t)}}exportJSON(){const t=this.__state?this.__state.toJSON():void 0;return{type:this.__type,version:1,...t}}static importJSON(e){t(18,this.name)}updateFromJSON(t){return function(t,e){const n=t.getWritable(),r=e.$;let i=r;for(const t of dt(n).flatKeys)t in e&&(void 0!==i&&i!==r||(i={...r}),i[t]=e[t]);return(n.__state||i)&&ft(t).updateFromJSON(i),n}(this,t)}static transform(){return null}remove(t){bn(this,!0,t)}replace(e,n){ei();let r=Lr();null!==r&&(r=r.clone()),ds(this,e);const i=this.getLatest(),o=this.__key,s=e.__key,l=e.getWritable(),c=this.getParentOrThrow().getWritable(),a=c.__size;_o(l);const u=i.getPreviousSibling(),f=i.getNextSibling(),d=i.__prev,h=i.__next,g=i.__parent;if(bn(i,!1,!0),null===u)c.__first=s;else{u.getWritable().__next=s}if(l.__prev=d,null===f)c.__last=s;else{f.getWritable().__prev=s}if(l.__next=h,l.__parent=g,c.__size=a,n&&(Si(this)&&Si(l)||t(139),this.getChildren().forEach(t=>{l.append(t)})),yr(r)){wo(r);const t=r.anchor,e=r.focus;t.key===o&&_r(t,l),e.key===o&&_r(e,l)}return mo()===o&&yo(s),l}insertAfter(t,e=!0){ei(),ds(this,t);const n=this.getWritable(),r=t.getWritable(),i=r.getParent(),o=Lr();let s=!1,l=!1;if(null!==i){const e=t.getIndexWithinParent();if(_o(r),yr(o)){const t=i.__key,n=o.anchor,r=o.focus;s="element"===n.type&&n.key===t&&n.offset===e+1,l="element"===r.type&&r.key===t&&r.offset===e+1}}const c=this.getNextSibling(),a=this.getParentOrThrow().getWritable(),u=r.__key,f=n.__next;if(null===c)a.__last=u;else{c.getWritable().__prev=u}if(a.__size++,n.__next=u,r.__next=f,r.__prev=n.__key,r.__parent=n.__parent,e&&yr(o)){const t=this.getIndexWithinParent();Kr(o,a,t+1);const e=a.__key;s&&o.anchor.set(e,t+2,"element"),l&&o.focus.set(e,t+2,"element")}return t}insertBefore(t,e=!0){ei(),ds(this,t);const n=this.getWritable(),r=t.getWritable(),i=r.__key;_o(r);const o=this.getPreviousSibling(),s=this.getParentOrThrow().getWritable(),l=n.__prev,c=this.getIndexWithinParent();if(null===o)s.__first=i;else{o.getWritable().__next=i}s.__size++,n.__prev=i,r.__prev=l,r.__next=n.__key,r.__parent=n.__parent;const a=Lr();if(e&&yr(a)){Kr(a,this.getParentOrThrow(),c)}return t}isParentRequired(){return!1}createParentElementNode(){return Li()}selectStart(){return this.selectPrevious()}selectEnd(){return this.selectNext(0,0)}selectPrevious(t,e){ei();const n=this.getPreviousSibling(),r=this.getParentOrThrow();if(null===n)return r.select(0,0);if(Si(n))return n.select();if(!lr(n)){const t=n.getIndexWithinParent()+1;return r.select(t,t)}return n.select(t,e)}selectNext(t,e){ei();const n=this.getNextSibling(),r=this.getParentOrThrow();if(null===n)return r.select();if(Si(n))return n.select(0,0);if(!lr(n)){const t=n.getIndexWithinParent();return r.select(t,t)}return n.select(t,e)}markDirty(){this.getWritable()}reconcileObservedMutation(t,e){this.markDirty()}}const An="historic",Pn="history-push",Dn="history-merge",Fn="paste",Ln="collaboration",In="skip-collab",Kn="skip-scroll-into-view",zn="skip-dom-selection",Rn="skip-selection-focus";class Bn extends Mn{static getType(){return"linebreak"}static clone(t){return new Bn(t.__key)}constructor(t){super(t)}getTextContent(){return"\n"}createDOM(){return document.createElement("br")}updateDOM(){return!1}isInline(){return!0}static importDOM(){return{br:t=>function(t){const e=t.parentElement;if(null!==e&&Ts(e)){const n=e.firstChild;if(n===t||n.nextSibling===t&&$n(n)){const n=e.lastChild;if(n===t||n.previousSibling===t&&$n(n))return!0}}return!1}(t)||function(t){const e=t.parentElement;if(null!==e&&Ts(e)){const n=e.firstChild;if(n===t||n.nextSibling===t&&$n(n))return!1;const r=e.lastChild;if(r===t||r.previousSibling===t&&$n(r))return!0}return!1}(t)?null:{conversion:Wn,priority:0}}}static importJSON(t){return Jn().updateFromJSON(t)}}function Wn(t){return{node:Jn()}}function Jn(){return fs(new Bn)}function jn(t){return t instanceof Bn}function $n(t){return co(t)&&/^( |\t|\r?\n)+$/.test(t.textContent||"")}function Un(t,e){return 16&e?"code":e&T?"mark":32&e?"sub":64&e?"sup":null}function Vn(t,e){return 1&e?"strong":2&e?"em":"span"}function Yn(t,e,n,r,i){const o=r.classList;let s=$o(i,"base");void 0!==s&&o.add(...s),s=$o(i,"underlineStrikethrough");let l=!1;const c=8&e&&4&e;void 0!==s&&(8&n&&4&n?(l=!0,c||o.add(...s)):c&&o.remove(...s));for(const t in R){const r=R[t];if(s=$o(i,t),void 0!==s)if(n&r){if(l&&("underline"===t||"strikethrough"===t)){e&r&&o.remove(...s);continue}(0===(e&r)||c&&"underline"===t||"strikethrough"===t)&&o.add(...s)}else e&r&&o.remove(...s)}}function qn(t,e,n){const r=e.firstChild,i=n.isComposing(),s=t+(i?P:"");if(null==r)e.textContent=s;else{const t=r.nodeValue;if(t!==s)if(i||o){const[e,n,i]=function(t,e){const n=t.length,r=e.length;let i=0,o=0;for(;i({conversion:nr,priority:0}),b:()=>({conversion:Zn,priority:0}),code:()=>({conversion:or,priority:0}),em:()=>({conversion:or,priority:0}),i:()=>({conversion:or,priority:0}),mark:()=>({conversion:or,priority:0}),s:()=>({conversion:or,priority:0}),span:()=>({conversion:Qn,priority:0}),strong:()=>({conversion:or,priority:0}),sub:()=>({conversion:or,priority:0}),sup:()=>({conversion:or,priority:0}),u:()=>({conversion:or,priority:0})}}static importJSON(t){return sr().updateFromJSON(t)}updateFromJSON(t){return super.updateFromJSON(t).setTextContent(t.text).setFormat(t.format).setDetail(t.detail).setMode(t.mode).setStyle(t.style)}exportDOM(e){let{element:n}=super.exportDOM(e);return Cs(n)||t(132),n.style.whiteSpace="pre-wrap",this.hasFormat("lowercase")?n.style.textTransform="lowercase":this.hasFormat("uppercase")?n.style.textTransform="uppercase":this.hasFormat("capitalize")&&(n.style.textTransform="capitalize"),this.hasFormat("bold")&&(n=Gn(n,"b")),this.hasFormat("italic")&&(n=Gn(n,"i")),this.hasFormat("strikethrough")&&(n=Gn(n,"s")),this.hasFormat("underline")&&(n=Gn(n,"u")),{element:n}}exportJSON(){return{detail:this.getDetail(),format:this.getFormat(),mode:this.getMode(),style:this.getStyle(),text:this.getTextContent(),...super.exportJSON()}}selectionTransform(t,e){}setFormat(t){const e=this.getWritable();return e.__format="string"==typeof t?R[t]:t,e}setDetail(t){const e=this.getWritable();return e.__detail="string"==typeof t?B[t]:t,e}setStyle(t){const e=this.getWritable();return e.__style=t,e}toggleFormat(t){const e=fo(this.getFormat(),t,null);return this.setFormat(e)}toggleDirectionless(){const t=this.getWritable();return t.__detail^=1,t}toggleUnmergeable(){const t=this.getWritable();return t.__detail^=2,t}setMode(t){const e=j[t];if(this.__mode===e)return this;const n=this.getWritable();return n.__mode=e,n}setTextContent(t){if(this.__text===t)return this;const e=this.getWritable();return e.__text=t,e}select(t,e){ei();let n=t,r=e;const i=Lr(),o=this.getTextContent(),s=this.__key;if("string"==typeof o){const t=o.length;void 0===n&&(n=t),void 0===r&&(r=t)}else n=0,r=0;if(!yr(i))return Mr(s,n,s,r,"text","text");{const t=mo();t!==i.anchor.key&&t!==i.focus.key||yo(s),i.setTextNodeRange(this,n,this,r)}return i}selectStart(){return this.select(0,0)}selectEnd(){const t=this.getTextContentSize();return this.select(t,t)}spliceText(t,e,n,r){const i=this.getWritable(),o=i.__text,s=n.length;let l=t;l<0&&(l=s+l,l<0&&(l=0));const c=Lr();if(r&&yr(c)){const e=t+s;c.setTextNodeRange(i,e,i,e)}const a=o.slice(0,l)+n+o.slice(l+e);return i.__text=a,i}canInsertTextBefore(){return!0}canInsertTextAfter(){return!0}splitText(...t){ei();const e=this.getLatest(),n=e.getTextContent();if(""===n)return[];const r=e.__key,i=mo(),o=n.length;t.sort((t,e)=>t-e),t.push(o);const s=[],l=t.length;for(let e=0,r=0;ee&&(s.push(n.slice(e,i)),e=i)}const c=s.length;if(1===c)return[e];const a=s[0],u=e.getParent();let f;const d=e.getFormat(),h=e.getStyle(),g=e.__detail;let _=!1,p=null,y=null;const m=Lr();if(yr(m)){const[t,e]=m.isBackward()?[m.focus,m.anchor]:[m.anchor,m.focus];"text"===t.type&&t.key===r&&(p=t),"text"===e.type&&e.key===r&&(y=e)}e.isSegmented()?(f=sr(a),f.__format=d,f.__style=h,f.__detail=g,f.__state=yt(e,f),_=!0):f=e.setTextContent(a);const x=[f];for(let t=1;t=v&&(p.set(t.getKey(),C-v,"text"),C=v){y.set(t.getKey(),S-v,"text");break}v=e}if(null!==u){!function(t){const e=t.getPreviousSibling(),n=t.getNextSibling();null!==e&&po(e);null!==n&&po(n)}(this);const t=u.getWritable(),e=this.getIndexWithinParent();_?(t.splice(e,0,x),this.remove()):t.splice(e,1,x),yr(m)&&Kr(m,u,e,c-1)}return x}mergeWithSibling(e){const n=e===this.getPreviousSibling();n||e===this.getNextSibling()||t(50);const r=this.__key,i=e.__key,o=this.__text,s=o.length;mo()===i&&yo(r);const l=Lr();if(yr(l)){const t=l.anchor,o=l.focus;null!==t&&t.key===i&&Br(t,n,r,e,s),null!==o&&o.key===i&&Br(o,n,r,e,s)}const c=e.__text,a=n?c+o:o+c;this.setTextContent(a);const u=this.getWritable();return e.remove(),u}isTextEntity(){return!1}}function Qn(t){return{forChild:cr(t.style),node:null}}function Zn(t){const e=t,n="normal"===e.style.fontWeight;return{forChild:cr(e.style,n?void 0:"bold"),node:null}}const tr=new WeakMap;function er(t){if(!Cs(t))return!1;if("PRE"===t.nodeName)return!0;const e=t.style.whiteSpace;return"string"==typeof e&&e.startsWith("pre")}function nr(e){const n=e;null===e.parentElement&&t(129);let r=n.textContent||"";if(null!==function(t){let e,n=t.parentNode;const r=[t];for(;null!==n&&void 0===(e=tr.get(n))&&!er(n);)r.push(n),n=n.parentNode;const i=void 0===e?n:e;for(let t=0;t0){/[ \t\n]$/.test(n)&&(r=r.slice(1)),e=!1;break}}e&&(r=r.slice(1))}if(" "===r[r.length-1]){let t=n,e=!0;for(;null!==t&&null!==(t=rr(t,!0));){if((t.textContent||"").replace(/^( |\t|\r?\n)+/,"").length>0){e=!1;break}}e&&(r=r.slice(0,r.length-1))}return""===r?{node:null}:{node:sr(r)}}function rr(t,e){let n=t;for(;;){let t;for(;null===(t=e?n.nextSibling:n.previousSibling);){const t=n.parentElement;if(null===t)return null;n=t}if(n=t,Cs(n)){const t=n.style.display;if(""===t&&!ks(n)||""!==t&&!t.startsWith("inline"))return null}let r=n;for(;null!==(r=e?n.firstChild:n.lastChild);)n=r;if(co(n))return n;if("BR"===n.nodeName)return null}}const ir={code:"code",em:"italic",i:"italic",mark:"highlight",s:"strikethrough",strong:"bold",sub:"subscript",sup:"superscript",u:"underline"};function or(t){const e=ir[t.nodeName.toLowerCase()];return void 0===e?{node:null}:{forChild:cr(t.style,e),node:null}}function sr(t=""){return fs(new Xn(t))}function lr(t){return t instanceof Xn}function cr(t,e){const n=t.fontWeight,r=t.textDecoration.split(" "),i="700"===n||"bold"===n,o=r.includes("line-through"),s="italic"===t.fontStyle,l=r.includes("underline"),c=t.verticalAlign;return t=>lr(t)?(i&&!t.hasFormat("bold")&&t.toggleFormat("bold"),o&&!t.hasFormat("strikethrough")&&t.toggleFormat("strikethrough"),s&&!t.hasFormat("italic")&&t.toggleFormat("italic"),l&&!t.hasFormat("underline")&&t.toggleFormat("underline"),"sub"!==c||t.hasFormat("subscript")||t.toggleFormat("subscript"),"super"!==c||t.hasFormat("superscript")||t.toggleFormat("superscript"),e&&!t.hasFormat(e)&&t.toggleFormat(e),t):t}class ar extends Xn{static getType(){return"tab"}static clone(t){return new ar(t.__key)}constructor(t){super("\t",t),this.__detail=2}static importDOM(){return null}createDOM(t){const e=super.createDOM(t),n=$o(t.theme,"tab");if(void 0!==n){e.classList.add(...n)}return e}static importJSON(t){return ur().updateFromJSON(t)}setTextContent(t){return"\t"!==t&&""!==t&&e(126),super.setTextContent("\t")}spliceText(e,n,r,i){return""===r&&0===n||"\t"===r&&1===n||t(286),this}setDetail(e){return 2!==e&&t(127),this}setMode(e){return"normal"!==e&&t(128),this}canInsertTextBefore(){return!1}canInsertTextAfter(){return!1}}function ur(){return fs(new ar)}function fr(t){return t instanceof ar}class dr{key;offset;type;_selection;constructor(t,e,n){this._selection=null,this.key=t,this.offset=e,this.type=n}is(t){return this.key===t.key&&this.offset===t.offset&&this.type===t.type}isBefore(t){if(this.key===t.key)return this.offsett&&(r=t)}else if(!Si(e)){const t=e.getNextSibling();if(lr(t))n=t.__key,r=0,i="text";else{const t=e.getParent();t&&(n=t.__key,r=e.getIndexWithinParent()+1)}}t.set(n,r,i)}function _r(t,e){if(Si(e)){const n=e.getLastDescendant();Si(n)||lr(n)?gr(t,n):gr(t,e)}else gr(t,e)}class pr{_nodes;_cachedNodes;dirty;constructor(t){this._cachedNodes=null,this._nodes=t,this.dirty=!1}getCachedNodes(){return this._cachedNodes}setCachedNodes(t){this._cachedNodes=t}is(t){if(!xr(t))return!1;const e=this._nodes,n=t._nodes;return e.size===n.size&&Array.from(e).every(t=>n.has(t))}isCollapsed(){return!1}isBackward(){return!1}getStartEndPoints(){return null}add(t){this.dirty=!0,this._nodes.add(t),this._cachedNodes=null}delete(t){this.dirty=!0,this._nodes.delete(t),this._cachedNodes=null}clear(){this.dirty=!0,this._nodes.clear(),this._cachedNodes=null}has(t){return this._nodes.has(t)}clone(){return new pr(new Set(this._nodes))}extract(){return this.getNodes()}insertRawText(t){}insertText(){}insertNodes(t){const e=this.getNodes(),n=e.length,r=e[n-1];let i;if(lr(r))i=r.select();else{const t=r.getIndexWithinParent()+1;i=r.getParentOrThrow().select(t,t)}i.insertNodes(t);for(let t=0;t1;){const t=e[e.length-1];if(!Si(t)||o.has(t)||t.isEmpty()||i.has(t))break;e.pop()}if(0===e.length&&t.isCollapsed()){const n=El(t.anchor),r=El(t.anchor.getFlipped()),i=t=>Ys(t)?t.origin:t.getNodeAtCaret(),o=i(n)||i(r)||(t.anchor.getNodeAtCaret()?n.origin:r.origin);e.push(o)}return e}(Al(kl(this),"next"));return ti()||(this._cachedNodes=e),e}setTextNodeRange(t,e,n,r){this.anchor.set(t.__key,e,"text"),this.focus.set(n.__key,r,"text")}getTextContent(){const t=this.getNodes();if(0===t.length)return"";const e=t[0],n=t[t.length-1],r=this.anchor,i=this.focus,o=r.isBefore(i),[s,l]=Sr(this);let c="",a=!0;for(let u=0;u=0;t--){const e=o[t];if(e.is(d)||Si(e)&&e.isParentOf(d))break;e.isAttached()&&(!s.has(e)||e.is(i)?g||p.insertAfter(e,!1):e.remove())}if(!g){let e=r,n=null;for(;null!==e;){const r=e.getChildren(),i=r.length;(0===i||r[i-1].is(n))&&(t.delete(e.__key),n=e),e=e.getParent()}}if(so(d))if(c===h)d.select();else{const t=sr(e);t.select(),d.replace(t)}else d=d.spliceText(c,h-c,e,!0),""===d.getTextContent()?d.remove():d.isComposing()&&"text"===this.anchor.type&&(this.anchor.offset-=e.length);for(let e=1;e{n.forEach(n=>{if(Si(n)){const r=n.getFormatFlags(t,e);n.setTextFormat(r)}})},o=r.length;if(0===o)return this.toggleFormat(t),yo(null),void i(e);const s=this.anchor,l=this.focus,c=this.isBackward(),a=c?l:s,u=c?s:l;let f=0,d=r[0],h="element"===a.type?0:a.offset;if("text"===a.type&&h===d.getTextContentSize()&&(f=1,d=r[1],h=0),null==d)return;const g=d.getFormatFlags(t,e);i(g);const _=o-1;let p=r[_];const y="text"===u.type?u.offset:p.getTextContentSize();if(d.is(p)){if(h===y)return;if(lo(d)||0===h&&y===d.getTextContentSize())d.setFormat(g);else{const t=d.splitText(h,y),e=0===h?t[0]:t[1];e.setFormat(g),"text"===a.type&&a.set(e.__key,0,"text"),"text"===u.type&&u.set(e.__key,y-h,"text")}return void(this.format=g)}0===h||lo(d)||([,d]=d.splitText(h),h=0),d.setFormat(g);const m=p.getFormatFlags(t,g);y>0&&(y===p.getTextContentSize()||lo(p)||([p]=p.splitText(y)),p.setFormat(m));for(let e=f+1;e<_;e++){const n=r[e],i=n.getFormatFlags(t,m);n.setFormat(i)}"text"===a.type&&a.set(d.__key,h,"text"),"text"===u.type&&u.set(p.__key,y,"text"),this.format=g|m}insertNodes(e){if(0===e.length)return;if(this.isCollapsed()||this.removeText(),"root"===this.anchor.key){this.insertParagraph();const n=Lr();return yr(n)||t(134),n.insertNodes(e)}const n=(this.isBackward()?this.focus:this.anchor).getNode(),r=zs(n,Ns),i=e[e.length-1];if(Si(r)&&"__language"in r){if("__language"in e[0])this.insertText(e[0].getTextContent());else{const t=Ur(this);r.splice(t,0,e),i.selectEnd()}return}if(!e.some(t=>(Si(t)||Ti(t))&&!t.isInline())){Si(r)||t(211,n.constructor.name,n.getType());const o=Ur(this);return r.splice(o,0,e),void i.selectEnd()}const o=function(t){const e=Li();let n=null;for(let r=0;r0){const t=o.getRangeAt(0),n=this.anchor.getNode(),i=bi(n)?n:cs(n);if(this.applyDOMRange(t),this.dirty=!0,!r){const n=this.getNodes(),r=[];let s=!1;for(let t=0;t0)if(e){const t=r[0];Si(t)?t.selectStart():t.getParentOrThrow().selectStart()}else{const t=r[r.length-1];Si(t)?t.selectEnd():t.getParentOrThrow().selectEnd()}o.anchorNode===t.startContainer&&o.anchorOffset===t.startOffset||function(t){const e=t.focus,n=t.anchor,r=n.key,i=n.offset,o=n.type;n.set(e.key,e.offset,e.type,!0),e.set(r,i,o,!0)}(this)}}"lineboundary"===n&&Yr(this,t,e,n,"decorators")}forwardDeletion(t,e,n){if(!n&&("element"===t.type&&Si(e)&&t.offset===e.getChildrenSize()||"text"===t.type&&t.offset===e.getTextContentSize())){const t=e.getParent(),n=e.getNextSibling()||(null===t?null:t.getNextSibling());if(Si(n)&&n.isShadowRoot())return!0}return!1}deleteCharacter(t){const e=this.isCollapsed();if(this.isCollapsed()){const e=this.anchor;let n=e.getNode();if(this.forwardDeletion(e,n,t))return;const r=ul(xl(e,t?"previous":"next"));if(r.getTextSlices().every(t=>null===t||0===t.distance)){let t={type:"initial"};for(const e of r.iterNodeCarets("shadowRoot"))if(Gs(e))if(e.origin.isInline());else{if(e.origin.isShadowRoot()){if("merge-block"===t.type)break;if(Si(r.anchor.origin)&&r.anchor.origin.isEmpty()){const t=El(e);vl(this,dl(t,t)),r.anchor.origin.remove()}return}"merge-next-block"!==t.type&&"merge-block"!==t.type||(t={block:t.block,caret:e,type:"merge-block"})}else{if("merge-block"===t.type)break;if(Hs(e)){if(Si(e.origin)){if(e.origin.isInline()){if(!e.origin.isParentOf(r.anchor.origin))break}else t={block:e.origin,type:"merge-next-block"};continue}if(Ti(e.origin)){if(e.origin.isIsolated());else if("merge-next-block"===t.type&&(e.origin.isKeyboardSelectable()||!e.origin.isInline())&&Si(r.anchor.origin)&&r.anchor.origin.isEmpty()){r.anchor.origin.remove();const t=Pr();t.add(e.origin.getKey()),wo(t)}else e.origin.remove();return}break}}if("merge-block"===t.type){const{caret:e,block:n}=t;return vl(this,dl(!e.origin.isEmpty()&&n.isEmpty()?Tl(tl(n,e.direction)):r.anchor,e)),this.removeText()}}const i=this.focus;if(this.modify("extend",t,"character"),this.isCollapsed()){if(t&&0===e.offset&&vr(this,e.getNode()))return}else{const r="text"===i.type?i.getNode():null;if(n="text"===e.type?e.getNode():null,null!==r&&r.isSegmented()){const e=i.offset,o=r.getTextContentSize();if(r.is(n)||t&&e!==o||!t&&0!==e)return void Tr(r,t,e)}else if(null!==n&&n.isSegmented()){const i=e.offset,o=n.getTextContentSize();if(n.is(r)||t&&0!==i||!t&&i!==o)return void Tr(n,t,i)}!function(t,e){const n=t.anchor,r=t.focus,i=n.getNode(),o=r.getNode();if(i===o&&"text"===n.type&&"text"===r.type){const t=n.offset,o=r.offset,s=t{try{const t=new RegExp("\\p{Emoji}","u"),e=t.test.bind(t);if(e("❤️")&&e("#️⃣")&&e("👍"))return e}catch(t){}return()=>!1})();function Tr(t,e,n){const r=t,i=r.getTextContent().split(/(?=\s)/g),o=i.length;let s=0,l=0;for(let t=0;tn||r){i.splice(t,1),r&&(l=void 0);break}}const c=i.join("").trim();""===c?r.remove():(r.setTextContent(c),r.select(l,l))}function Nr(e,n,r,i){let o,s=n;if(Cs(e)){let l=!1;const c=e.childNodes,a=c.length,u=i._blockCursorElement;s===a&&(l=!0,s=a-1);let f=c[s],d=!1;if(f===u)f=c[s+1],d=!0;else if(null!==u){const t=u.parentNode;if(e===t){n>Array.prototype.indexOf.call(t.children,u)&&s--}}if(o=Eo(f),lr(o))s=nl(o,l?"next":"previous");else{let c=Eo(e);if(null===c)return null;if(Si(c)){const a=i.getElementByKey(c.getKey());null===a&&t(214);const u=c.getDOMSlot(a);[c,s]=u.resolveChildIndex(c,a,e,n),Si(c)||t(215),l&&s>=c.getChildrenSize()&&(s=Math.max(0,c.getChildrenSize()-1));let f=c.getChildAtIndex(s);if(Si(f)&&function(t,e,n){const r=t.getParent();return null===n||null===r||!r.canBeEmpty()||r!==n.getNode()}(f,0,r)){const t=l?f.getLastDescendant():f.getFirstDescendant();null===t?c=f:(f=t,c=Si(f)?f:f.getParentOrThrow()),s=0}lr(f)?(o=f,c=null,s=nl(f,l?"next":"previous")):f!==c&&l&&!d&&(Si(c)||t(216),s=Math.min(c.getChildrenSize(),s+1))}else{const t=c.getIndexWithinParent();s=0===n&&Ti(c)&&Eo(e)===c?t:t+1,c=c.getParentOrThrow()}if(Si(c))return hr(c.__key,s,"element")}}else o=Eo(e);return lr(o)?hr(o.__key,nl(o,s,"clamp"),"text"):null}function br(t,e,n){const r=t.offset,i=t.getNode();if(0===r){const r=i.getPreviousSibling(),o=i.getParent();if(e){if((n||!e)&&null===r&&Si(o)&&o.isInline()){const e=o.getPreviousSibling();lr(e)&&t.set(e.__key,e.getTextContent().length,"text")}}else Si(r)&&!n&&r.isInline()?t.set(r.__key,r.getChildrenSize(),"element"):lr(r)&&t.set(r.__key,r.getTextContent().length,"text")}else if(r===i.getTextContent().length){const r=i.getNextSibling(),o=i.getParent();if(e&&Si(r)&&r.isInline())t.set(r.__key,0,"element");else if((n||e)&&null===r&&Si(o)&&o.isInline()&&!o.canInsertTextAfter()){const e=o.getNextSibling();lr(e)&&t.set(e.__key,0,"text")}}}function wr(t,e,n){if("text"===t.type&&"text"===e.type){const r=t.isBefore(e),i=t.is(e);br(t,r,i),br(e,!r,i),i&&e.set(t.key,t.offset,t.type);const o=ii();if(o.isComposing()&&o._compositionKey!==t.key&&yr(n)){const r=n.anchor,i=n.focus;t.set(r.key,r.offset,r.type,!0),e.set(i.key,i.offset,i.type,!0)}}}function Er(t,e,n,r,i,o){if(null===t||null===n||!eo(i,t,n))return null;const s=Nr(t,e,yr(o)?o.anchor:null,i);if(null===s)return null;const l=Nr(n,r,yr(o)?o.focus:null,i);if(null===l)return null;if("element"===s.type&&"element"===l.type){const e=Eo(t),r=Eo(n);if(Ti(e)&&Ti(r))return null}return wr(s,l,o),[s,l]}function Or(t){return Si(t)&&!t.isInline()}function Mr(t,e,n,r,i,o){const s=ri(),l=new mr(hr(t,e,i),hr(n,r,o),0,"");return l.dirty=!0,s._selection=l,l}function Ar(){const t=hr("root",0,"element"),e=hr("root",0,"element");return new mr(t,e,0,"")}function Pr(){return new pr(new Set)}function Dr(t,e){return Fr(null,t,e,null)}function Fr(t,e,n,r){const i=n._window;if(null===i)return null;const o=r||i.event,s=o?o.type:void 0,l="selectionchange"===s,c=!q&&(l||"beforeinput"===s||"compositionstart"===s||"compositionend"===s||"click"===s&&o&&3===o.detail||"drop"===s||void 0===s);let a,u,f,d;if(yr(t)&&!c)return t.clone();if(null===e)return null;if(a=e.anchorNode,u=e.focusNode,f=e.anchorOffset,d=e.focusOffset,(l||void 0===s)&&yr(t)&&!eo(n,a,u))return t.clone();const h=Er(a,f,u,d,n,t);if(null===h)return null;const[g,_]=h;return new mr(g,_,yr(t)?t.format:0,yr(t)?t.style:"")}function Lr(){return ri()._selection}function Ir(){return ii()._editorState._selection}function Kr(t,e,n,r=1){const i=t.anchor,o=t.focus,s=i.getNode(),l=o.getNode();if(!e.is(s)&&!e.is(l))return;const c=e.__key;if(t.isCollapsed()){const e=i.offset;if(n<=e&&r>0||n0||n0||n=t,s=i?o.getChildAtIndex(t-1):o.getChildAtIndex(n);if(lr(s)){let t=0;i&&(t=s.getTextContentSize()),e.set(s.__key,t,"text"),r.set(s.__key,t,"text")}return}if(Si(o)){const t=o.getChildrenSize(),r=n>=t,i=r?o.getChildAtIndex(t-1):o.getChildAtIndex(n);if(lr(i)){let t=0;r&&(t=i.getTextContentSize()),e.set(i.__key,t,"text")}}if(Si(s)){const t=s.getChildrenSize(),e=i>=t,n=e?s.getChildAtIndex(t-1):s.getChildAtIndex(i);if(lr(n)){let t=0;e&&(t=n.getTextContentSize()),r.set(n.__key,t,"text")}}}function Rr(t,e,n,r,i){let o=null,s=0,l=null;null!==r?(o=r.__key,lr(r)?(s=r.getTextContentSize(),l="text"):Si(r)&&(s=r.getChildrenSize(),l="element")):null!==i&&(o=i.__key,lr(i)?l="text":Si(i)&&(l="element")),null!==o&&null!==l?t.set(o,s,l):(s=e.getIndexWithinParent(),-1===s&&(s=n.getChildrenSize()),t.set(n.__key,s,"element"))}function Br(t,e,n,r,i){"text"===t.type?t.set(n,t.offset+(e?0:i),"text"):t.offset>r.getIndexWithinParent()&&t.set(t.key,t.offset-1,"element")}function Wr(t,e,n,r,i){try{t.setBaseAndExtent(e,n,r,i)}catch(t){}}function Jr(t,e,n,r,i,o,s){const l=r.anchorNode,c=r.focusNode,a=r.anchorOffset,u=r.focusOffset,f=document.activeElement;if(i.has(Ln)&&f!==o||null!==f&&to(f))return;if(!yr(e))return void(null!==t&&eo(n,l,c)&&r.removeAllRanges());const d=e.anchor,h=e.focus,g=d.key,_=h.key,p=Qo(n,g),y=Qo(n,_),m=d.offset,x=h.offset,C=e.format,S=e.style,v=e.isCollapsed();let k=p,T=y,N=!1;if("text"===d.type){k=uo(p);const t=d.getNode();N=t.getFormat()!==C||t.getStyle()!==S}else yr(t)&&"text"===t.anchor.type&&(N=!0);var b,w,E,O,M;if(("text"===h.type&&(T=uo(y)),null!==k&&null!==T)&&(v&&(null===t||N||yr(t)&&(t.format!==C||t.style!==S))&&(b=C,w=S,E=m,O=g,M=performance.now(),fn=[b,w,E,O,M]),a!==m||u!==x||l!==k||c!==T||"Range"===r.type&&v||(null!==f&&o.contains(f)||i.has(Rn)||o.focus({preventScroll:!0}),"element"===d.type))){if(Wr(r,k,m,T,x),!i.has(Kn)&&e.isCollapsed()&&null!==o&&o===document.activeElement){const t=yr(e)&&"element"===e.anchor.type?k.childNodes[m]||null:r.rangeCount>0?r.getRangeAt(0):null;if(null!==t){let e;if(t instanceof Text){const n=document.createRange();n.selectNode(t),e=n.getBoundingClientRect()}else e=t.getBoundingClientRect();!function(t,e,n){const r=ts(n),i=os(r);if(null===r||null===i)return;let{top:o,bottom:s}=e,l=0,c=0,a=n;for(;null!==a;){const e=a===r.body;if(e)l=0,c=ss(t).innerHeight;else{const t=a.getBoundingClientRect();l=t.top,c=t.bottom}let n=0;if(oc&&(n=s-c),0!==n)if(e)i.scrollBy(0,n);else{const t=a.scrollTop;a.scrollTop+=n;const e=a.scrollTop-t;o-=e,s-=e}if(e)break;a=Zo(a)}}(n,e,o)}}rn=!0}}function jr(t){let e=Lr()||Ir();null===e&&(e=No().selectEnd()),e.insertNodes(t)}function $r(){const t=Lr();return null===t?"":t.getTextContent()}function Ur(e){let n=e;e.isCollapsed()||n.removeText();const r=Lr();yr(r)&&(n=r),yr(n)||t(161);const i=n.anchor;let o=i.getNode(),s=i.offset;for(;!Ns(o);){const t=o;if([o,s]=Vr(o,s),t.is(o))break}return s}function Vr(t,e){const n=t.getParent();if(!n){const t=Li();return No().append(t),t.select(),[No(),0]}if(lr(t)){const r=t.splitText(e);if(0===r.length)return[n,t.getIndexWithinParent()];const i=0===e?0:1;return[n,r[0].getIndexWithinParent()+i]}if(!Si(t)||0===e)return[n,t.getIndexWithinParent()];const r=t.getChildAtIndex(e);if(r){const n=new mr(hr(t.__key,e,"element"),hr(t.__key,e,"element"),0,""),i=t.insertNewAfter(n);i&&i.append(r,...r.getNextSiblings())}return[n,t.getIndexWithinParent()+1]}function Yr(t,e,n,r,i="decorators-and-blocks"){if("move"===e&&"character"===r&&!t.isCollapsed()){const[e,r]=n===t.isBackward()?[t.focus,t.anchor]:[t.anchor,t.focus];return r.set(e.key,e.offset,e.type),!0}const o=xl(t.focus,n?"previous":"next"),s="lineboundary"===r,l="move"===e;let c=o,a="decorators-and-blocks"===i;if(!Ol(c)){for(const t of c){a=!1;const{origin:e}=t;if(!Ti(e)||e.isIsolated()||(c=t,!s||!e.isInline()))break}if(a)for(const t of ul(o).iterNodeCarets("extend"===e?"shadowRoot":"root")){if(Gs(t))t.origin.isInline()||(c=t);else{if(Si(t.origin))continue;Ti(t.origin)&&!t.origin.isInline()&&(c=t)}break}}if(c===o)return!1;if(l&&!s&&Ti(c.origin)&&c.origin.isKeyboardSelectable()){const t=Pr();return t.add(c.origin.getKey()),wo(t),!0}return c=El(c),l&&Cl(t.anchor,c),Cl(t.focus,c),a||!s}let qr=null,Hr=null,Gr=!1,Xr=!1,Qr=0;const Zr={characterData:!0,childList:!0,subtree:!0};function ti(){return Gr||null!==qr&&qr._readOnly}function ei(){Gr&&t(13)}function ni(){Qr>99&&t(14)}function ri(){return null===qr&&t(195,oi()),qr}function ii(){return null===Hr&&t(196,oi()),Hr}function oi(){let t=0;const e=new Set,n=Ui.version;if("undefined"!=typeof window)for(const r of document.querySelectorAll("[contenteditable]")){const i=io(r);if(no(i))t++;else if(i){let t=String(i.constructor.version||"<0.17.1");t===n&&(t+=" (separately built, likely a bundler configuration issue)"),e.add(t)}}let r=` Detected on the page: ${t} compatible editor(s) with version ${n}`;return e.size&&(r+=` and incompatible editors with versions ${Array.from(e).join(", ")}`),r}function si(){return Hr}function li(t,e,n){const r=e.__type,i=Gi(t,r);let o=n.get(r);void 0===o&&(o=Array.from(i.transforms),n.set(r,o));const s=o.length;for(let t=0;t0||u>0;){if(c>0){e._dirtyLeaves=new Set;for(const t of l){const r=i.get(t);lr(r)&&r.isAttached()&&r.isSimpleText()&&!r.isUnmergeable()&&Ct(r),void 0!==r&&ci(r,o)&&li(e,r,s),n.add(t)}if(l=e._dirtyLeaves,c=l.size,c>0){Qr++;continue}}e._dirtyLeaves=new Set,e._dirtyElements=new Map,a.delete("root")&&a.set("root",!0);for(const t of a){const n=t[0],l=t[1];if(r.set(n,l),!l)continue;const c=i.get(n);void 0!==c&&ci(c,o)&&li(e,c,s)}l=e._dirtyLeaves,c=l.size,a=e._dirtyElements,u=a.size,Qr++}e._dirtyLeaves=n,e._dirtyElements=r}(a,e),_i(e),function(t,e,n,r){const i=t._nodeMap,o=e._nodeMap,s=[];for(const[t]of r){const e=o.get(t);void 0!==e&&(e.isAttached()||(Si(e)&&Y(e,t,i,o,s,r),i.has(t)||r.delete(t),s.push(t)))}for(const t of s)o.delete(t);for(const t of n){const e=o.get(t);void 0===e||e.isAttached()||(i.has(t)||n.delete(t),o.delete(t))}}(c,a,e._dirtyLeaves,e._dirtyElements));i!==e._compositionKey&&(a._flushSync=!0);const o=a._selection;if(yr(o)){const e=a._nodeMap,n=o.anchor.key,r=o.focus.key;void 0!==e.get(n)&&void 0!==e.get(r)||t(19)}else xr(o)&&0===o._nodes.size&&(a._selection=null)}catch(t){return t instanceof Error&&e._onError(t),e._pendingEditorState=c,e._dirtyType=2,e._cloneNotNeeded.clear(),e._dirtyLeaves=new Set,e._dirtyElements.clear(),void hi(e)}finally{qr=f,Gr=d,Hr=h,e._updating=g,Qr=0}const p=0!==e._dirtyType||e._deferred.length>0||function(t,e){const n=e.getEditorState()._selection,r=t._selection;if(null!==r){if(r.dirty||!r.is(n))return!0}else if(null!==n)return!0;return!1}(a,e);p?a._flushSync?(a._flushSync=!1,hi(e)):u&&Qi(()=>{hi(e)}):(a._flushSync=!1,u&&(i.clear(),e._deferred=[],e._pendingEditorState=null))}function yi(t,e,n){Hr===t&&void 0===n?e():pi(t,e,n)}class mi{element;before;after;constructor(t,e,n){this.element=t,this.before=e||null,this.after=n||null}withBefore(t){return new mi(this.element,t,this.after)}withAfter(t){return new mi(this.element,this.before,t)}withElement(t){return this.element===t?this:new mi(t,this.before,this.after)}insertChild(e){const n=this.before||this.getManagedLineBreak();return null!==n&&n.parentElement!==this.element&&t(222),this.element.insertBefore(e,n),this}removeChild(e){return e.parentElement!==this.element&&t(223),this.element.removeChild(e),this}replaceChild(e,n){return n.parentElement!==this.element&&t(224),this.element.replaceChild(e,n),this}getFirstChild(){const t=this.after?this.after.nextSibling:this.element.firstChild;return t===this.before||t===this.getManagedLineBreak()?null:t}getManagedLineBreak(){return this.element.__lexicalLineBreak||null}setManagedLineBreak(t){if(null===t)this.removeManagedLineBreak();else{const e="decorator"===t&&(d||c||l);this.insertManagedLineBreak(e)}}removeManagedLineBreak(){const t=this.getManagedLineBreak();if(t){const e=this.element,n="IMG"===t.nodeName?t.nextSibling:null;n&&e.removeChild(n),e.removeChild(t),e.__lexicalLineBreak=void 0}}insertManagedLineBreak(t){const e=this.getManagedLineBreak();if(e){if(t===("IMG"===e.nodeName))return;this.removeManagedLineBreak()}const n=this.element,r=this.before,i=document.createElement("br");if(n.insertBefore(i,r),t){const t=document.createElement("img");t.setAttribute("data-lexical-linebreak","true"),t.style.cssText="display: inline !important; border: 0px !important; margin: 0px !important;",t.alt="",n.insertBefore(t,i),n.__lexicalLineBreak=t}else n.__lexicalLineBreak=i}getFirstChildOffset(){let t=0;for(let e=this.after;null!==e;e=e.previousSibling)t++;return t}resolveChildIndex(t,e,n,r){if(n===this.element){const e=this.getFirstChildOffset();return[t,Math.min(e+t.getChildrenSize(),Math.max(e,r))]}const i=xi(e,n);i.push(r);const o=xi(e,this.element);let s=t.getIndexWithinParent();for(let t=0;tn){s+=1;break}}return[t.getParentOrThrow(),s]}}function xi(e,n){const r=[];let i=n;for(;i!==e&&null!==i;i=i.parentNode){let t=0;for(let e=i.previousSibling;null!==e;e=e.previousSibling)t++;r.push(t)}return i!==e&&t(225),r.reverse()}class Ci extends Mn{__first;__last;__size;__format;__style;__indent;__dir;__textFormat;__textStyle;constructor(t){super(t),this.__first=null,this.__last=null,this.__size=0,this.__format=0,this.__style="",this.__indent=0,this.__dir=null,this.__textFormat=0,this.__textStyle=""}afterCloneFrom(t){super.afterCloneFrom(t),this.__key===t.__key&&(this.__first=t.__first,this.__last=t.__last,this.__size=t.__size),this.__indent=t.__indent,this.__format=t.__format,this.__style=t.__style,this.__dir=t.__dir,this.__textFormat=t.__textFormat,this.__textStyle=t.__textStyle}getFormat(){return this.getLatest().__format}getFormatType(){const t=this.getFormat();return J[t]||""}getStyle(){return this.getLatest().__style}getIndent(){return this.getLatest().__indent}getChildren(){const t=[];let e=this.getFirstChild();for(;null!==e;)t.push(e),e=e.getNextSibling();return t}getChildrenKeys(){const t=[];let e=this.getFirstChild();for(;null!==e;)t.push(e.__key),e=e.getNextSibling();return t}getChildrenSize(){return this.getLatest().__size}isEmpty(){return 0===this.getChildrenSize()}isDirty(){const t=ii()._dirtyElements;return null!==t&&t.has(this.__key)}isLastChild(){const t=this.getLatest(),e=this.getParentOrThrow().getLastChild();return null!==e&&e.is(t)}getAllTextNodes(){const t=[];let e=this.getFirstChild();for(;null!==e;){if(lr(e)&&t.push(e),Si(e)){const n=e.getAllTextNodes();t.push(...n)}e=e.getNextSibling()}return t}getFirstDescendant(){let t=this.getFirstChild();for(;Si(t);){const e=t.getFirstChild();if(null===e)break;t=e}return t}getLastDescendant(){let t=this.getLastChild();for(;Si(t);){const e=t.getLastChild();if(null===e)break;t=e}return t}getDescendantByIndex(t){const e=this.getChildren(),n=e.length;if(t>=n){const t=e[n-1];return Si(t)&&t.getLastDescendant()||t||null}const r=e[t];return Si(r)&&r.getFirstDescendant()||r||null}getFirstChild(){const t=this.getLatest().__first;return null===t?null:xo(t)}getFirstChildOrThrow(){const e=this.getFirstChild();return null===e&&t(45,this.__key),e}getLastChild(){const t=this.getLatest().__last;return null===t?null:xo(t)}getLastChildOrThrow(){const e=this.getLastChild();return null===e&&t(96,this.__key),e}getChildAtIndex(t){const e=this.getChildrenSize();let n,r;if(t=t;){if(r===t)return n;n=n.getPreviousSibling(),r--}return null}getTextContent(){let t="";const e=this.getChildren(),n=e.length;for(let r=0;rt.remove()),t}append(...t){return this.splice(this.getChildrenSize(),0,t)}setDirection(t){const e=this.getWritable();return e.__dir=t,e}setFormat(t){return this.getWritable().__format=""!==t?W[t]:0,this}setStyle(t){return this.getWritable().__style=t||"",this}setTextFormat(t){const e=this.getWritable();return e.__textFormat=t,e}setTextStyle(t){const e=this.getWritable();return e.__textStyle=t,e}setIndent(t){return this.getWritable().__indent=t,this}splice(e,n,r){On(this)&&t(324,this.__key,this.__type);const i=this.getChildrenSize(),o=this.getWritable();e+n<=i||t(226,String(e),String(n),String(i));const s=o.__key,l=[],c=[],a=this.getChildAtIndex(e+n);let u=null,f=i-n+r.length;if(0!==e)if(e===i)u=this.getLastChild();else{const t=this.getChildAtIndex(e);null!==t&&(u=t.getPreviousSibling())}if(n>0){let e=null===u?this.getFirstChild():u.getNextSibling();for(let r=0;r0&&(e.style.paddingInlineStart=40*t+"px");const n=this.getDirection();n&&(e.dir=n)}return{element:e}}exportJSON(){const t={children:[],direction:this.getDirection(),format:this.getFormatType(),indent:this.getIndent(),...super.exportJSON()},e=this.getTextFormat(),n=this.getTextStyle();return 0!==e&&(t.textFormat=e),""!==n&&(t.textStyle=n),t}updateFromJSON(t){return super.updateFromJSON(t).setFormat(t.format).setIndent(t.indent).setDirection(t.direction).setTextFormat(t.textFormat||0).setTextStyle(t.textStyle||"")}insertNewAfter(t,e){return null}canIndent(){return!0}collapseAtStart(t){return!1}excludeFromCopy(t){return!1}canReplaceWith(t){return!0}canInsertAfter(t){return!0}canBeEmpty(){return!0}canInsertTextBefore(){return!0}canInsertTextAfter(){return!0}isInline(){return!1}isShadowRoot(){return!1}canMergeWith(t){return!1}extractWithChild(t,e,n){return!1}canMergeWhenEmpty(){return!1}reconcileObservedMutation(t,e){const n=this.getDOMSlot(t);let r=n.getFirstChild();for(let t=this.getFirstChild();t;t=t.getNextSibling()){const i=e.getElementByKey(t.getKey());null!==i&&(null==r?(n.insertChild(i),r=i):r!==i&&n.replaceChild(i,r),r=r.nextSibling)}}}function Si(t){return t instanceof Ci}function vi(t,e,n){let r=t.getNode();for(;r;){const t=r.__key;if(e.has(t)&&!n.has(t))return!0;r=r.getParent()}return!1}class ki extends Mn{decorate(t,e){return null}isIsolated(){return!1}isInline(){return!0}isKeyboardSelectable(){return!0}}function Ti(t){return t instanceof ki}class Ni extends Ci{__cachedText;static getType(){return"root"}static clone(){return new Ni}constructor(){super("root"),this.__cachedText=null}getTopLevelElementOrThrow(){t(51)}getTextContent(){const t=this.__cachedText;return!ti()&&0!==ii()._dirtyType||null===t?super.getTextContent():t}remove(){t(52)}replace(e){t(53)}insertBefore(e){t(54)}insertAfter(e){t(55)}updateDOM(t,e){return!1}splice(e,n,r){for(const e of r)Si(e)||Ti(e)||t(282);return super.splice(e,n,r)}static importJSON(t){return No().updateFromJSON(t)}collapseAtStart(){return!0}}function bi(t){return t instanceof Ni}function wi(t){return new Ai(new Map(t._nodeMap))}function Ei(){return new Ai(new Map([["root",new Ni]]))}function Oi(e){const n=e.exportJSON(),r=e.constructor;if(n.type!==r.getType()&&t(130,r.name),Si(e)){const i=n.children;Array.isArray(i)||t(59,r.name);const o=e.getChildren();for(let t=0;t({root:Oi(No())}))}}class Pi extends Ci{static getType(){return"artificial"}createDOM(t){return document.createElement("div")}}class Di extends Ci{static getType(){return"paragraph"}static clone(t){return new Di(t.__key)}createDOM(t){const e=document.createElement("p"),n=$o(t.theme,"paragraph");if(void 0!==n){e.classList.add(...n)}return e}updateDOM(t,e,n){return!1}static importDOM(){return{p:t=>({conversion:Fi,priority:0})}}exportDOM(t){const{element:e}=super.exportDOM(t);if(Cs(e)){this.isEmpty()&&e.append(document.createElement("br"));const t=this.getFormatType();t&&(e.style.textAlign=t)}return{element:e}}static importJSON(t){return Li().updateFromJSON(t)}exportJSON(){return{...super.exportJSON(),textFormat:this.getTextFormat(),textStyle:this.getTextStyle()}}insertNewAfter(t,e){const n=Li();n.setTextFormat(t.format),n.setTextStyle(t.style);const r=this.getDirection();return n.setDirection(r),n.setFormat(this.getFormatType()),n.setStyle(this.getStyle()),this.insertAfter(n,e),n}collapseAtStart(){const t=this.getChildren();if(0===t.length||lr(t[0])&&""===t[0].getTextContent().trim()){if(null!==this.getNextSibling())return this.selectNext(),this.remove(),!0;if(null!==this.getPreviousSibling())return this.selectPrevious(),this.remove(),!0}return!1}}function Fi(t){const e=Li();return t.style&&(e.setFormat(t.style.textAlign),Ps(t,e)),{node:e}}function Li(){return fs(new Di)}function Ii(t){return t instanceof Di}const Ki=0,zi=1,Ri=2,Bi=3,Wi=4;function Ji(t,e,n,r){const i=t._keyToDOMMap;i.clear(),t._editorState=Ei(),t._pendingEditorState=r,t._compositionKey=null,t._dirtyType=0,t._cloneNotNeeded.clear(),t._dirtyLeaves=new Set,t._dirtyElements.clear(),t._normalizedNodes=new Set,t._updateTags=new Set,t._updates=[],t._blockCursorElement=null;const o=t._observer;null!==o&&(o.disconnect(),t._observer=null),null!==e&&(e.textContent=""),null!==n&&(n.textContent="",i.set("root",n))}function ji(t){const e=new Set,n=new Set;let r=t;for(;r;){const{ownNodeConfig:t}=Is(r),i=r.transform;if(!n.has(i)){n.add(i);const t=r.transform();t&&e.add(t)}if(t){const n=t.$transform;n&&e.add(n),r=t.extends}else{const t=Object.getPrototypeOf(r);r=t.prototype instanceof Mn&&t!==Mn?t:void 0}}return e}function $i(t){const e=t||{},n=si(),r=e.theme||{},i=void 0===t?n:e.parentEditor||null,o=e.disableEvents||!1,s=Ei(),l=e.namespace||(null!==i?i._config.namespace:Ao()),c=e.editorState,a=[Ni,Xn,Bn,ar,Di,Pi,...e.nodes||[]],{onError:u,html:f}=e,d=void 0===e.editable||e.editable;let h;if(void 0===t&&null!==n)h=n._nodes;else{h=new Map;for(let t=0;t{Object.keys(t).forEach(e=>{let r=n.get(e);void 0===r&&(r=[],n.set(e,r)),r.push(t[e])})};return t.forEach(t=>{const e=t.klass.importDOM;if(null==e||r.has(e))return;r.add(e);const n=e.call(t.klass);null!==n&&i(n)}),e&&i(e),n}(h,f?f.import:void 0),d,t);return void 0!==c&&(g._pendingEditorState=c,g._dirtyType=2),g}class Ui{static version;_headless;_parentEditor;_rootElement;_editorState;_pendingEditorState;_compositionKey;_deferred;_keyToDOMMap;_updates;_updating;_listeners;_commands;_nodes;_decorators;_pendingDecorators;_config;_dirtyType;_cloneNotNeeded;_dirtyLeaves;_dirtyElements;_normalizedNodes;_updateTags;_observer;_key;_onError;_htmlConversions;_window;_editable;_blockCursorElement;_createEditorArgs;constructor(t,e,n,r,i,o,s,l){this._createEditorArgs=l,this._parentEditor=e,this._rootElement=null,this._editorState=t,this._pendingEditorState=null,this._compositionKey=null,this._deferred=[],this._keyToDOMMap=new Map,this._updates=[],this._updating=!1,this._listeners={decorator:new Set,editable:new Set,mutation:new Map,root:new Set,textcontent:new Set,update:new Set},this._commands=new Map,this._config=r,this._nodes=n,this._decorators={},this._pendingDecorators=null,this._dirtyType=0,this._cloneNotNeeded=new Set,this._dirtyLeaves=new Set,this._dirtyElements=new Map,this._normalizedNodes=new Set,this._updateTags=new Set,this._observer=null,this._key=Ao(),this._onError=i,this._htmlConversions=o,this._editable=s,this._headless=null!==e&&e._headless,this._window=null,this._blockCursorElement=null}isComposing(){return null!=this._compositionKey}registerUpdateListener(t){const e=this._listeners.update;return e.add(t),()=>{e.delete(t)}}registerEditableListener(t){const e=this._listeners.editable;return e.add(t),()=>{e.delete(t)}}registerDecoratorListener(t){const e=this._listeners.decorator;return e.add(t),()=>{e.delete(t)}}registerTextContentListener(t){const e=this._listeners.textcontent;return e.add(t),()=>{e.delete(t)}}registerRootListener(t){const e=this._listeners.root;return t(this._rootElement,null),e.add(t),()=>{t(null,this._rootElement),e.delete(t)}}registerCommand(e,n,r){void 0===r&&t(35);const i=this._commands;i.has(e)||i.set(e,[new Set,new Set,new Set,new Set,new Set]);const o=i.get(e);void 0===o&&t(36,String(e));const s=o[r];return s.add(n),()=>{s.delete(n),o.every(t=>0===t.size)&&i.delete(e)}}registerMutationListener(t,e,n){const r=this.resolveRegisteredNodeAfterReplacements(this.getRegisteredNode(t)).klass,i=this._listeners.mutation;let o=i.get(e);void 0===o&&(o=new Set,i.set(e,o)),o.add(r);const s=n&&n.skipInitialization;return void 0!==s&&s||this.initializeMutationListener(e,r),()=>{o.delete(r),0===o.size&&i.delete(e)}}getRegisteredNode(e){const n=this._nodes.get(e.getType());return void 0===n&&t(37,e.name),n}resolveRegisteredNodeAfterReplacements(t){for(;t.replaceWithKlass;)t=this.getRegisteredNode(t.replaceWithKlass);return t}initializeMutationListener(t,e){const n=this._editorState,r=Os(n).get(e.getType());if(!r)return;const i=new Map;for(const t of r.keys())i.set(t,"created");i.size>0&&t(i,{dirtyLeaves:new Set,prevEditorState:n,updateTags:new Set(["registerMutationListener"])})}registerNodeTransformToKlass(t,e){const n=this.getRegisteredNode(t);return n.transforms.add(e),n}registerNodeTransform(t,e){const n=this.registerNodeTransformToKlass(t,e),r=[n],i=n.replaceWithKlass;if(null!=i){const t=this.registerNodeTransformToKlass(i,e);r.push(t)}return function(t,e){const n=Os(t.getEditorState()),r=[];for(const t of e){const e=n.get(t);e&&r.push(e)}if(0===r.length)return;t.update(()=>{for(const t of r)for(const e of t.keys()){const t=xo(e);t&&t.markDirty()}},null===t._pendingEditorState?{tag:Dn}:void 0)}(this,r.map(t=>t.klass.getType())),()=>{r.forEach(t=>t.transforms.delete(e))}}hasNode(t){return this._nodes.has(t.getType())}hasNodes(t){return t.every(this.hasNode.bind(this))}dispatchCommand(t,e){return Go(this,t,e)}getDecorators(){return this._decorators}getRootElement(){return this._rootElement}getKey(){return this._key}setRootElement(t){const e=this._rootElement;if(t!==e){const n=$o(this._config.theme,"root"),r=this._pendingEditorState||this._editorState;if(this._rootElement=t,Ji(this,e,t,r),null!==e&&(this._config.disableEvents||Nn(e),null!=n&&e.classList.remove(...n)),null!==t){const e=os(t),r=t.style;r.userSelect="text",r.whiteSpace="pre-wrap",r.wordBreak="break-word",t.setAttribute("data-lexical-editor","true"),this._window=e,this._dirtyType=2,rt(this),this._updateTags.add(Dn),hi(this),this._config.disableEvents||function(t,e){const n=t.ownerDocument;en.set(t,n);const r=nn.get(n)??0;r<1&&n.addEventListener("selectionchange",Sn),nn.set(n,r+1),t.__lexicalEditor=e;const i=xn(t);for(let n=0;n{kn(t)||(vn(t),(e.isEditable()||"click"===r)&&o(t,e))}:t=>{if(kn(t))return;vn(t);const n=e.isEditable();switch(r){case"cut":return n&&Go(e,Be,t);case"copy":return Go(e,Re,t);case"paste":return n&&Go(e,fe,t);case"dragstart":return n&&Go(e,Ie,t);case"dragover":return n&&Go(e,Ke,t);case"dragend":return n&&Go(e,ze,t);case"focus":return n&&Go(e,Ve,t);case"blur":return n&&Go(e,Ye,t);case"drop":return n&&Go(e,Fe,t)}};t.addEventListener(r,s),i.push(()=>{t.removeEventListener(r,s)})}}(t,this),null!=n&&t.classList.add(...n)}else this._window=null,this._updateTags.add(Dn),hi(this);gi("root",this,!1,t,e)}}getElementByKey(t){return this._keyToDOMMap.get(t)||null}getEditorState(){return this._editorState}setEditorState(e,n){e.isEmpty()&&t(38);let r=e;r._readOnly&&(r=wi(e),r._selection=e._selection?e._selection.clone():null),nt(this);const i=this._pendingEditorState,o=this._updateTags,s=void 0!==n?n.tag:null;null===i||i.isEmpty()||(null!=s&&o.add(s),hi(this)),this._pendingEditorState=r,this._dirtyType=2,this._dirtyElements.set("root",!1),this._compositionKey=null,null!=s&&o.add(s),this._updating||hi(this)}parseEditorState(t,e){return function(t,e,n){const r=Ei(),i=qr,o=Gr,s=Hr,l=e._dirtyElements,c=e._dirtyLeaves,a=e._cloneNotNeeded,u=e._dirtyType;e._dirtyElements=new Map,e._dirtyLeaves=new Set,e._cloneNotNeeded=new Set,e._dirtyType=0,qr=r,Gr=!1,Hr=e,Yi(null);try{const i=e._nodes;fi(t.root,i),n&&n(),r._readOnly=!0}catch(t){t instanceof Error&&e._onError(t)}finally{e._dirtyElements=l,e._dirtyLeaves=c,e._cloneNotNeeded=a,e._dirtyType=u,qr=i,Gr=o,Hr=s}return r}("string"==typeof t?JSON.parse(t):t,this,e)}read(t){return hi(this),this.getEditorState().read(t,{editor:this})}update(t,e){!function(t,e,n){t._updating?t._updates.push([e,n]):pi(t,e,n)}(this,t,e)}focus(t,e={}){const n=this._rootElement;null!==n&&(n.setAttribute("autocapitalize","off"),yi(this,()=>{const r=Lr(),i=No();null!==r?r.dirty||wo(r.clone()):0!==i.getChildrenSize()&&("rootStart"===e.defaultSelection?i.selectStart():i.selectEnd()),ns("focus"),rs(()=>{n.removeAttribute("autocapitalize"),t&&t()})}),null===this._pendingEditorState&&n.removeAttribute("autocapitalize"))}blur(){const t=this._rootElement;null!==t&&t.blur();const e=ps(this._window);null!==e&&e.removeAllRanges()}isEditable(){return this._editable}setEditable(t){this._editable!==t&&(this._editable=t,gi("editable",this,!0,t))}toJSON(){return{editorState:this._editorState.toJSON()}}}Ui.version="0.38.2+prod.esm";let Vi=null;function Yi(t){Vi=t}let qi=1;function Hi(){qi=1}function Gi(e,n){const r=Xi(e,n);return void 0===r&&t(30,n),r}function Xi(t,e){return t._nodes.get(e)}const Qi="function"==typeof queueMicrotask?queueMicrotask:t=>{Promise.resolve().then(t)};function Zi(t){return Ti(vo(t))}function to(t){const e=document.activeElement;if(!Cs(e))return!1;const n=e.nodeName;return Ti(vo(t))&&("INPUT"===n||"TEXTAREA"===n||"true"===e.contentEditable&&null==io(e))}function eo(t,e,n){const r=t.getRootElement();try{return null!==r&&r.contains(e)&&r.contains(n)&&null!==e&&!to(e)&&ro(e)===t}catch(t){return!1}}function no(t){return t instanceof Ui}function ro(t){let e=t;for(;null!=e;){const t=io(e);if(no(t))return t;e=Zo(e)}return null}function io(t){return t?t.__lexicalEditor:null}function oo(t){return K.test(t)?"rtl":z.test(t)?"ltr":null}function so(t){return fr(t)||t.isToken()}function lo(t){return so(t)||t.isSegmented()}function co(t){return Ss(t)&&3===t.nodeType}function ao(t){return Ss(t)&&9===t.nodeType}function uo(t){let e=t;for(;null!=e;){if(co(e))return e;e=e.firstChild}return null}function fo(t,e,n){const r=R[e];if(null!==n&&(t&r)===(n&r))return t;let i=t^r;return"subscript"===e?i&=~R.superscript:"superscript"===e?i&=~R.subscript:"lowercase"===e?(i&=~R.uppercase,i&=~R.capitalize):"uppercase"===e?(i&=~R.lowercase,i&=~R.capitalize):"capitalize"===e&&(i&=~R.lowercase,i&=~R.uppercase),i}function ho(t){return lr(t)||jn(t)||Ti(t)}function go(t,e){const n=function(){const t=Vi;return Vi=null,t}();if(null!=(e=e||n&&n.__key))return void(t.__key=e);ei(),ni();const r=ii(),i=ri(),o=""+qi++;i._nodeMap.set(o,t),Si(t)?r._dirtyElements.set(o,!0):r._dirtyLeaves.add(o),r._cloneNotNeeded.add(o),r._dirtyType=1,t.__key=o}function _o(t){const e=t.getParent();if(null!==e){const n=t.getWritable(),r=e.getWritable(),i=t.getPreviousSibling(),o=t.getNextSibling(),s=null!==o?o.__key:null,l=null!==i?i.__key:null,c=null!==i?i.getWritable():null,a=null!==o?o.getWritable():null;null===i&&(r.__first=s),null===o&&(r.__last=l),null!==c&&(c.__next=s),null!==a&&(a.__prev=l),n.__prev=null,n.__next=null,n.__parent=null,r.__size--}}function po(e){ni(),On(e)&&t(323,e.__key,e.__type);const n=e.getLatest(),r=n.__parent,i=ri(),o=ii(),s=i._nodeMap,l=o._dirtyElements;null!==r&&function(t,e,n){let r=t;for(;null!==r;){if(n.has(r))return;const t=e.get(r);if(void 0===t)break;n.set(r,!1),r=t.__parent}}(r,s,l);const c=n.__key;o._dirtyType=1,Si(e)?l.set(c,!0):o._dirtyLeaves.add(c)}function yo(t){ei();const e=ii(),n=e._compositionKey;if(t!==n){if(e._compositionKey=t,null!==n){const t=xo(n);null!==t&&t.getWritable()}if(null!==t){const e=xo(t);null!==e&&e.getWritable()}}}function mo(){if(ti())return null;return ii()._compositionKey}function xo(t,e){const n=(e||ri())._nodeMap.get(t);return void 0===n?null:n}function Co(t,e){const n=So(t,ii());return void 0!==n?xo(n,e):null}function So(t,e){return t[`__lexicalKey_${e._key}`]}function vo(t,e){let n=t;for(;null!=n;){const t=Co(n,e);if(null!==t)return t;n=Zo(n)}return null}function ko(t){const e=t._decorators,n=Object.assign({},e);return t._pendingDecorators=n,n}function To(t){return t.read(()=>No().getTextContent())}function No(){return bo(ri())}function bo(t){return t._nodeMap.get("root")}function wo(t){ei();const e=ri();null!==t&&(t.dirty=!0,t.setCachedNodes(null)),e._selection=t}function Eo(t){const e=ii(),n=function(t,e){let n=t;for(;null!=n;){const t=So(n,e);if(void 0!==t)return t;n=Zo(n)}return null}(t,e);if(null===n){return t===e.getRootElement()?xo("root"):null}return xo(n)}function Oo(t){return/[\uD800-\uDBFF][\uDC00-\uDFFF]/g.test(t)}function Mo(t){const e=[];let n=t;for(;null!==n;)e.push(n),n=n._parentEditor;return e}function Ao(){return Math.random().toString(36).replace(/[^a-z]+/g,"").substring(0,5)}function Po(t){return co(t)?t.nodeValue:null}function Do(t,e,n){const r=ps(ss(e));if(null===r)return;const i=r.anchorNode;let{anchorOffset:o,focusOffset:s}=r;if(null!==i){let e=Po(i);const r=vo(i);if(null!==e&&lr(r)){if(e===P&&n){const t=n.length;e=n,o=t,s=t}null!==e&&Fo(r,e,o,s,t)}}}function Fo(t,e,n,r,i){let o=t;if(o.isAttached()&&(i||!o.isDirty())){const s=o.isComposing();let a=e;(s||i)&&e[e.length-1]===P&&(a=e.slice(0,-1));const u=o.getTextContent();if(i||a!==u){if(""===a){if(yo(null),l||c||d)o.remove();else{const t=ii();setTimeout(()=>{t.update(()=>{o.isAttached()&&o.remove()})},20)}return}const e=o.getParent(),i=Ir(),u=o.getTextContentSize(),f=mo(),h=o.getKey();if(o.isToken()||null!==f&&h===f&&!s||yr(i)&&(null!==e&&!e.canInsertTextBefore()&&0===i.anchor.offset||i.anchor.key===t.__key&&0===i.anchor.offset&&!o.canInsertTextBefore()&&!s||i.focus.key===t.__key&&i.focus.offset===u&&!o.canInsertTextAfter()&&!s))return void o.markDirty();const g=Lr();if(!yr(g)||null===n||null===r)return void Lo(o,a,g);if(g.setTextNodeRange(o,n,o,r),o.isSegmented()){const t=sr(o.getTextContent());o.replace(t),o=t}Lo(o,a,g)}}}function Lo(t,e,n){if(t.setTextContent(e),yr(n)){const e=t.getKey();for(const r of["anchor","focus"]){const i=n[r];"text"===i.type&&i.key===e&&(i.offset=nl(t,i.offset,"clamp"))}}}function Io(t,e,n){const r=e[n]||!1;return"any"===r||r===t[n]}function Ko(t,e){return Io(t,e,"altKey")&&Io(t,e,"ctrlKey")&&Io(t,e,"shiftKey")&&Io(t,e,"metaKey")}function zo(t,e,n){return Ko(t,n)&&t.key.toLowerCase()===e.toLowerCase()}const Ro={ctrlKey:!i,metaKey:i},Bo={altKey:i,ctrlKey:!i};function Wo(t){return"Backspace"===t.key}function Jo(t){return zo(t,"a",Ro)}function jo(t){const e=No();if(yr(t)){const e=t.anchor,n=t.focus,r=e.getNode().getTopLevelElementOrThrow().getParentOrThrow();return e.set(r.getKey(),0,"element"),n.set(r.getKey(),r.getChildrenSize(),"element"),St(t),t}{const t=e.select(0,e.getChildrenSize());return wo(St(t)),t}}function $o(t,e){void 0===t.__lexicalClassNameCache&&(t.__lexicalClassNameCache={});const n=t.__lexicalClassNameCache,r=n[e];if(void 0!==r)return r;const i=t[e];if("string"==typeof i){const t=h(i);return n[e]=t,t}return i}function Uo(e,n,r,i,o){if(0===r.size)return;const s=i.__type,l=i.__key,c=n.get(s);void 0===c&&t(33,s);const a=c.klass;let u=e.get(a);void 0===u&&(u=new Map,e.set(a,u));const f=u.get(l),d="destroyed"===f&&"created"===o;(void 0===f||d)&&u.set(l,d?"updated":o)}function Vo(t){const e=t.getType(),n=ri();if(n._readOnly){const t=Os(n).get(e);return t?Array.from(t.values()):[]}const r=n._nodeMap,i=[];for(const[,n]of r)n instanceof t&&n.__type===e&&n.isAttached()&&i.push(n);return i}function Yo(t,e,n){const r=t.getParent();let i=n,o=t;return null!==r&&(e&&0===n?(i=o.getIndexWithinParent(),o=r):e||n!==o.getChildrenSize()||(i=o.getIndexWithinParent()+1,o=r)),o.getChildAtIndex(e?i-1:i)}function qo(t,e){const n=t.offset;if("element"===t.type){return Yo(t.getNode(),e,n)}{const r=t.getNode();if(e&&0===n||!e&&n===r.getTextContentSize()){const t=e?r.getPreviousSibling():r.getNextSibling();return null===t?Yo(r.getParentOrThrow(),e,r.getIndexWithinParent()+(e?0:1)):t}}return null}function Ho(t){const e=ss(t).event,n=e&&e.inputType;return"insertFromPaste"===n||"insertFromPasteAsQuotation"===n}function Go(t,e,n){return function(t,e,n){const r=Mo(t);for(let i=4;i>=0;i--)for(let o=0;o{for(let e=0;e{const n=e.getParentOrThrow(),o=as(n),s=e!==r||o?us(e):e;if(o)return Si(e)&&Si(s)||t(133),e.insertAfter(s),[e,s,s];{const[t,r,o]=i(n),l=e.getNextSiblings();return o.append(s,...l),[t,r,s]}},[o,s]=i(r);return[o,s]}function xs(t){return Cs(t)&&"A"===t.tagName}function Cs(t){return Ss(t)&&1===t.nodeType}function Ss(t){return"object"==typeof t&&null!==t&&"nodeType"in t&&"number"==typeof t.nodeType}function vs(t){return Ss(t)&&11===t.nodeType}function ks(t){const e=new RegExp(/^(a|abbr|acronym|b|cite|code|del|em|i|ins|kbd|label|mark|output|q|ruby|s|samp|span|strong|sub|sup|time|u|tt|var|#text)$/,"i");return null!==t.nodeName.match(e)}function Ts(t){const e=new RegExp(/^(address|article|aside|blockquote|canvas|dd|div|dl|dt|fieldset|figcaption|figure|footer|form|h1|h2|h3|h4|h5|h6|header|hr|li|main|nav|noscript|ol|p|pre|section|table|td|tfoot|ul|video)$/,"i");return null!==t.nodeName.match(e)}function Ns(t){if(Ti(t)&&!t.isInline())return!0;if(!Si(t)||as(t))return!1;const e=t.getFirstChild(),n=null===e||jn(e)||lr(e)||e.isInline();return!t.isInline()&&!1!==t.canBeEmpty()&&n}function bs(){return ii()}const ws=new WeakMap,Es=new Map;function Os(e){if(!e._readOnly&&e.isEmpty())return Es;e._readOnly||t(192);let n=ws.get(e);return n||(n=function(t){const e=new Map;for(const[n,r]of t._nodeMap){const t=r.__type;let i=e.get(t);i||(i=new Map,e.set(t,i)),i.set(n,r)}return e}(e),ws.set(e,n)),n}function Ms(t){const e=t.constructor.clone(t);return e.afterCloneFrom(t),e}function As(t){return(e=Ms(t))[En]=!0,e;var e}function Ps(t,e){const n=parseInt(t.style.paddingInlineStart,10)||0,r=Math.round(n/40);e.setIndent(r)}function Ds(t){t.__lexicalUnmanaged=!0}function Fs(t){return!0===t.__lexicalUnmanaged}function Ls(t,e){return function(t,e){return Object.prototype.hasOwnProperty.call(t,e)}(t,e)&&t[e]!==Mn[e]}function Is(e){const n=V in e.prototype?e.prototype[V]():void 0,r=function(e){if(!(e===Mn||e.prototype instanceof Mn)){let n="",r="";try{n=e.getType()}catch(t){}try{Ui.version&&(r=JSON.parse(Ui.version))}catch(t){}t(290,e.name,n,r)}return e===ki||e===Ci||e===Mn}(e),i=!r&&Ls(e,"getType")?e.getType():void 0;let o,s=i;if(n)if(i)o=n[i];else for(const[t,e]of Object.entries(n))s=t,o=e;if(!r&&s&&(Ls(e,"getType")||(e.getType=()=>s),Ls(e,"clone")||(e.clone=t=>(Yi(t),new e)),Ls(e,"importJSON")||(e.importJSON=o&&o.$importJSON||(t=>(new e).updateFromJSON(t))),!Ls(e,"importDOM")&&o)){const{importDOM:t}=o;t&&(e.importDOM=()=>t)}return{ownNodeConfig:o,ownNodeType:s}}function Ks(t){const e=bs();ei();return new(e.resolveRegisteredNodeAfterReplacements(e.getRegisteredNode(t)).klass)}const zs=(t,e)=>{let n=t;for(;null!=n&&!bi(n);){if(e(n))return n;n=n.getParent()}return null},Rs={next:"previous",previous:"next"};class Bs{origin;constructor(t){this.origin=t}[Symbol.iterator](){return hl({hasNext:Hs,initial:this.getAdjacentCaret(),map:t=>t,step:t=>t.getAdjacentCaret()})}getAdjacentCaret(){return tl(this.getNodeAtCaret(),this.direction)}getSiblingCaret(){return tl(this.origin,this.direction)}remove(){const t=this.getNodeAtCaret();return t&&t.remove(),this}replaceOrInsert(t,e){const n=this.getNodeAtCaret();return t.is(this.origin)||t.is(n)||(null===n?this.insert(t):n.replace(t,e)),this}splice(e,n,r="next"){const i=r===this.direction?n:Array.from(n).reverse();let o=this;const s=this.getParentAtCaret(),l=new Map;for(let t=o.getAdjacentCaret();null!==t&&l.size0){const n=o.getNodeAtCaret();if(n)if(l.delete(n.getKey()),l.delete(e.getKey()),n.is(e)||o.origin.is(e));else{const t=e.getParent();t&&t.is(s)&&e.remove(),n.replace(e)}else null===n&&t(263,Array.from(l).join(" "))}else o.insert(e);o=tl(e,this.direction)}for(const t of l.values())t.remove();return this}}class Ws extends Bs{type="child";getLatest(){const t=this.origin.getLatest();return t===this.origin?this:il(t,this.direction)}getParentCaret(t="root"){return tl($s(this.getParentAtCaret(),t),this.direction)}getFlipped(){const t=js(this.direction);return tl(this.getNodeAtCaret(),t)||il(this.origin,t)}getParentAtCaret(){return this.origin}getChildCaret(){return this}isSameNodeCaret(t){return t instanceof Ws&&this.direction===t.direction&&this.origin.is(t.origin)}isSamePointCaret(t){return this.isSameNodeCaret(t)}}const Js={root:bi,shadowRoot:as};function js(t){return Rs[t]}function $s(t,e="root"){return Js[e](t)?null:t}class Us extends Bs{type="sibling";getLatest(){const t=this.origin.getLatest();return t===this.origin?this:tl(t,this.direction)}getSiblingCaret(){return this}getParentAtCaret(){return this.origin.getParent()}getChildCaret(){return Si(this.origin)?il(this.origin,this.direction):null}getParentCaret(t="root"){return tl($s(this.getParentAtCaret(),t),this.direction)}getFlipped(){const t=js(this.direction);return tl(this.getNodeAtCaret(),t)||il(this.origin.getParentOrThrow(),t)}isSamePointCaret(t){return t instanceof Us&&this.direction===t.direction&&this.origin.is(t.origin)}isSameNodeCaret(t){return(t instanceof Us||t instanceof Vs)&&this.direction===t.direction&&this.origin.is(t.origin)}}class Vs extends Bs{type="text";offset;constructor(t,e){super(t),this.offset=e}getLatest(){const t=this.origin.getLatest();return t===this.origin?this:el(t,this.direction,this.offset)}getParentAtCaret(){return this.origin.getParent()}getChildCaret(){return null}getParentCaret(t="root"){return tl($s(this.getParentAtCaret(),t),this.direction)}getFlipped(){return el(this.origin,js(this.direction),this.offset)}isSamePointCaret(t){return t instanceof Vs&&this.direction===t.direction&&this.origin.is(t.origin)&&this.offset===t.offset}isSameNodeCaret(t){return(t instanceof Us||t instanceof Vs)&&this.direction===t.direction&&this.origin.is(t.origin)}getSiblingCaret(){return tl(this.origin,this.direction)}}function Ys(t){return t instanceof Vs}function qs(t){return t instanceof Bs}function Hs(t){return t instanceof Us}function Gs(t){return t instanceof Ws}const Xs={next:class extends Vs{direction="next";getNodeAtCaret(){return this.origin.getNextSibling()}insert(t){return this.origin.insertAfter(t),this}},previous:class extends Vs{direction="previous";getNodeAtCaret(){return this.origin.getPreviousSibling()}insert(t){return this.origin.insertBefore(t),this}}},Qs={next:class extends Us{direction="next";getNodeAtCaret(){return this.origin.getNextSibling()}insert(t){return this.origin.insertAfter(t),this}},previous:class extends Us{direction="previous";getNodeAtCaret(){return this.origin.getPreviousSibling()}insert(t){return this.origin.insertBefore(t),this}}},Zs={next:class extends Ws{direction="next";getNodeAtCaret(){return this.origin.getFirstChild()}insert(t){return this.origin.splice(0,0,[t]),this}},previous:class extends Ws{direction="previous";getNodeAtCaret(){return this.origin.getLastChild()}insert(t){return this.origin.splice(this.origin.getChildrenSize(),0,[t]),this}}};function tl(t,e){return t?new Qs[e](t):null}function el(t,e,n){return t?new Xs[e](t,nl(t,n)):null}function nl(t,n,r="error"){const i=t.getTextContentSize();let o="next"===n?i:"previous"===n?0:n;return(o<0||o>i)&&("clamp"!==r&&e(284,String(n),String(i),t.getKey()),o=o<0?0:i),o}function rl(t,e){return new cl(t,e)}function il(t,e){return Si(t)?new Zs[e](t):null}function ol(t){return t&&t.getChildCaret()||t}function sl(t){return t&&ol(t.getAdjacentCaret())}class ll{type="node-caret-range";direction;anchor;focus;constructor(t,e,n){this.anchor=t,this.focus=e,this.direction=n}getLatest(){const t=this.anchor.getLatest(),e=this.focus.getLatest();return t===this.anchor&&e===this.focus?this:new ll(t,e,this.direction)}isCollapsed(){return this.anchor.isSamePointCaret(this.focus)}getTextSlices(){const t=t=>{const e=this[t].getLatest();return Ys(e)?function(t,e){const{direction:n,origin:r}=t,i=nl(r,"focus"===e?js(n):n);return rl(t,i-t.offset)}(e,t):null},e=t("anchor"),n=t("focus");if(e&&n){const{caret:t}=e,{caret:r}=n;if(t.isSameNodeCaret(r))return[rl(t,r.offset-t.offset),null]}return[e,n]}iterNodeCarets(t="root"){const e=Ys(this.anchor)?this.anchor.getSiblingCaret():this.anchor.getLatest(),n=this.focus.getLatest(),r=Ys(n),i=e=>e.isSameNodeCaret(n)?null:sl(e)||e.getParentCaret(t);return hl({hasNext:t=>null!==t&&!(r&&n.isSameNodeCaret(t)),initial:e.isSameNodeCaret(n)?null:i(e),map:t=>t,step:i})}[Symbol.iterator](){return this.iterNodeCarets("root")}}class cl{type="slice";caret;distance;constructor(t,e){this.caret=t,this.distance=e}getSliceIndices(){const{distance:t,caret:{offset:e}}=this,n=e+t;return n{let n;for(let r=c;rn.has(t.getKey())&&Ns(t));return u&&f?[u,f]:null}(f,d,a);if(h){const[t,e]=h;il(t,"previous").splice(0,e.getChildren()),e.remove()}const g=[f,d,...l,...c].find(bl);if(g){return fl(Ml(El(g),e.direction))}t(269,JSON.stringify(l.map(t=>t.origin.__key)))}function El(t){const e=function(t){let e=t;for(;Gs(e);){const t=sl(e);if(!Gs(t))break;e=t}return e}(t.getLatest()),{direction:n}=e;if(lr(e.origin))return Ys(e)?e:el(e.origin,n,n);const r=e.getAdjacentCaret();return Hs(r)&&lr(r.origin)?el(r.origin,n,js(n)):e}function Ol(t){return Ys(t)&&t.offset!==nl(t.origin,t.direction)}function Ml(t,e){return t.direction===e?t:t.getFlipped()}function Al(t,e){return t.direction===e?t:dl(Ml(t.focus,e),Ml(t.anchor,e))}function Pl(t,e,n){let r=il(t,"next");for(let t=0;t0||n.canBeEmpty()&&i(n,"last"))&&o.insert(e(n).splice(0,0,r))}return o}function Kl(t){return t}function zl(...t){return t}function Rl(t,e){return[t,e]}function Bl(t){return t}function Wl(t,e){if(!e||t===e)return t;for(const n in e)if(t[n]!==e[n])return{...t,...e};return t}export{ns as $addUpdateTag,fs as $applyNodeReplacement,xl as $caretFromPoint,kl as $caretRangeFromSelection,Ms as $cloneWithProperties,As as $cloneWithPropertiesEphemeral,gl as $comparePointCaretNext,us as $copyNode,Ks as $create,Jn as $createLineBreakNode,Pr as $createNodeSelection,Li as $createParagraphNode,hr as $createPoint,Ar as $createRangeSelection,Dr as $createRangeSelectionFromDom,ur as $createTabNode,sr as $createTextNode,ul as $extendCaretToRange,zs as $findMatchingParent,sl as $getAdjacentChildCaret,qo as $getAdjacentNode,Dl as $getAdjacentSiblingOrParentSiblingCaret,Ml as $getCaretInDirection,dl as $getCaretRange,Al as $getCaretRangeInDirection,Sr as $getCharacterOffsets,il as $getChildCaret,Pl as $getChildCaretAtIndex,ol as $getChildCaretOrSelf,fl as $getCollapsedCaretRange,ml as $getCommonAncestor,_l as $getCommonAncestorResultBranchOrder,bs as $getEditor,vo as $getNearestNodeFromDOMNode,cs as $getNearestRootOrShadowRoot,xo as $getNodeByKey,hs as $getNodeByKeyOrThrow,Co as $getNodeFromDOMNode,Ir as $getPreviousSelection,No as $getRoot,Lr as $getSelection,tl as $getSiblingCaret,st as $getState,lt as $getStateChange,$r as $getTextContent,nl as $getTextNodeOffset,el as $getTextPointCaret,rl as $getTextPointCaretSlice,ft as $getWritableNodeState,is as $hasAncestor,es as $hasUpdateTag,jr as $insertNodes,Or as $isBlockElementNode,Gs as $isChildCaret,Ti as $isDecoratorNode,Mi as $isEditorState,Si as $isElementNode,Ol as $isExtendableTextPointCaret,ls as $isInlineElementOrDecoratorNode,ho as $isLeafNode,jn as $isLineBreakNode,qs as $isNodeCaret,xr as $isNodeSelection,Ii as $isParagraphNode,yr as $isRangeSelection,bi as $isRootNode,as as $isRootOrShadowRoot,Hs as $isSiblingCaret,fr as $isTabNode,lr as $isTextNode,Ys as $isTextPointCaret,al as $isTextPointCaretSlice,lo as $isTokenOrSegmented,so as $isTokenOrTab,Vo as $nodesOfType,El as $normalizeCaret,St as $normalizeSelection__EXPERIMENTAL,rs as $onUpdate,ui as $parseSerializedNode,wl as $removeTextFromCaretRange,Tl as $rewindSiblingCaret,jo as $selectAll,yo as $setCompositionKey,Cl as $setPointFromCaret,wo as $setSelection,Sl as $setSelectionFromCaretRange,ct as $setState,Il as $splitAtPointCaretNext,ms as $splitNode,vl as $updateRangeSelectionFromCaretRange,Pi as ArtificialNode__DO_NOT_USE,Ye as BLUR_COMMAND,$e as CAN_REDO_COMMAND,Ue as CAN_UNDO_COMMAND,Je as CLEAR_EDITOR_COMMAND,je as CLEAR_HISTORY_COMMAND,se as CLICK_COMMAND,Ln as COLLABORATION_TAG,Wi as COMMAND_PRIORITY_CRITICAL,Ki as COMMAND_PRIORITY_EDITOR,Bi as COMMAND_PRIORITY_HIGH,zi as COMMAND_PRIORITY_LOW,Ri as COMMAND_PRIORITY_NORMAL,ue as CONTROLLED_TEXT_INSERTION_COMMAND,Re as COPY_COMMAND,Be as CUT_COMMAND,le as DELETE_CHARACTER_COMMAND,ge as DELETE_LINE_COMMAND,he as DELETE_WORD_COMMAND,ze as DRAGEND_COMMAND,Ke as DRAGOVER_COMMAND,Ie as DRAGSTART_COMMAND,Fe as DROP_COMMAND,ki as DecoratorNode,Ci as ElementNode,Ve as FOCUS_COMMAND,Le as FORMAT_ELEMENT_COMMAND,_e as FORMAT_TEXT_COMMAND,An as HISTORIC_TAG,Dn as HISTORY_MERGE_TAG,Pn as HISTORY_PUSH_TAG,Pe as INDENT_CONTENT_COMMAND,ce as INSERT_LINE_BREAK_COMMAND,ae as INSERT_PARAGRAPH_COMMAND,Ae as INSERT_TAB_COMMAND,Ns as INTERNAL_$isBlock,N as IS_ALL_FORMATTING,y as IS_BOLD,S as IS_CODE,T as IS_HIGHLIGHT,m as IS_ITALIC,x as IS_STRIKETHROUGH,v as IS_SUBSCRIPT,k as IS_SUPERSCRIPT,C as IS_UNDERLINE,Te as KEY_ARROW_DOWN_COMMAND,Se as KEY_ARROW_LEFT_COMMAND,xe as KEY_ARROW_RIGHT_COMMAND,ke as KEY_ARROW_UP_COMMAND,we as KEY_BACKSPACE_COMMAND,Oe as KEY_DELETE_COMMAND,me as KEY_DOWN_COMMAND,Ne as KEY_ENTER_COMMAND,Ee as KEY_ESCAPE_COMMAND,qe as KEY_MODIFIER_COMMAND,be as KEY_SPACE_COMMAND,Me as KEY_TAB_COMMAND,Bn as LineBreakNode,Ce as MOVE_TO_END,ve as MOVE_TO_START,U as NODE_STATE_KEY,De as OUTDENT_CONTENT_COMMAND,fe as PASTE_COMMAND,Fn as PASTE_TAG,Di as ParagraphNode,ye as REDO_COMMAND,de as REMOVE_TEXT_COMMAND,Ni as RootNode,ie as SELECTION_CHANGE_COMMAND,oe as SELECTION_INSERT_CLIPBOARD_NODES_COMMAND,We as SELECT_ALL_COMMAND,In as SKIP_COLLAB_TAG,zn as SKIP_DOM_SELECTION_TAG,Kn as SKIP_SCROLL_INTO_VIEW_TAG,Rn as SKIP_SELECTION_FOCUS_TAG,R as TEXT_TYPE_TO_FORMAT,ar as TabNode,Xn as TextNode,pe as UNDO_COMMAND,wn as buildImportMap,zl as configExtension,re as createCommand,$i as createEditor,at as createSharedNodeState,ot as createState,Rl as declarePeerDependency,Kl as defineExtension,js as flipDirection,ts as getDOMOwnerDocument,ps as getDOMSelection,ys as getDOMSelectionFromTarget,uo as getDOMTextNode,io as getEditorPropertyFromDOMNode,ro as getNearestEditorFromDOMNode,Xi as getRegisteredNode,Gi as getRegisteredNodeOrThrow,Is as getStaticNodeConfig,oo as getTextDirection,ji as getTransformSetFromKlass,Ts as isBlockDomNode,ti as isCurrentlyReadOnlyMode,ao as isDOMDocumentNode,Ss as isDOMNode,co as isDOMTextNode,Fs as isDOMUnmanaged,vs as isDocumentFragment,zo as isExactShortcutMatch,xs as isHTMLAnchorElement,Cs as isHTMLElement,ks as isInlineDomNode,no as isLexicalEditor,Ko as isModifierMatch,to as isSelectionCapturedInDecoratorInput,eo as isSelectionWithinEditor,hl as makeStepwiseIterator,_o as removeFromParent,Hi as resetRandomKey,Bl as safeCast,Ds as setDOMUnmanaged,Ps as setNodeIndentFromDOM,Wl as shallowMergeConfig}; ++function t(t,...e){const n=new URL("https://lexical.dev/docs/error"),r=new URLSearchParams;r.append("code",t);for(const t of e)r.append("v",t);throw n.search=r.toString(),Error(`Minified Lexical error #${t}; visit ${n.toString()} for the full message or use the non-minified dev environment for full errors and additional helpful warnings.`)}function e(t,...e){const n=new URL("https://lexical.dev/docs/error"),r=new URLSearchParams;r.append("code",t);for(const t of e)r.append("v",t);n.search=r.toString(),console.warn(`Minified Lexical warning #${t}; visit ${n.toString()} for the full message or use the non-minified dev environment for full errors and additional helpful warnings.`)}const n="undefined"!=typeof window&&void 0!==window.document&&void 0!==window.document.createElement,r=n&&"documentMode"in document?document.documentMode:null,i=n&&/Mac|iPod|iPhone|iPad/.test(navigator.platform),o=n&&/^(?!.*Seamonkey)(?=.*Firefox).*/i.test(navigator.userAgent),s=!(!n||!("InputEvent"in window)||r)&&"getTargetRanges"in new window.InputEvent("input"),l=n&&/Version\/[\d.]+.*Safari/.test(navigator.userAgent),c=n&&/iPad|iPhone|iPod/.test(navigator.userAgent)&&!window.MSStream,a=n&&/Android/.test(navigator.userAgent),u=n&&/^(?=.*Chrome).*/i.test(navigator.userAgent),f=n&&a&&u,d=n&&/AppleWebKit\/[\d.]+/.test(navigator.userAgent)&&i&&!u;function h(...t){const e=[];for(const n of t)if(n&&"string"==typeof n)for(const[t]of n.matchAll(/\S+/g))e.push(t);return e}const g=0,_=1,p=2,y=1,m=2,x=4,C=8,S=16,v=32,k=64,T=128,N=2047,b=1,w=2,E=3,O=4,M=5,A=6,P=l||c||d?" ":"​",D="\n\n",F=o?" ":P,L="֑-߿יִ-﷽ﹰ-ﻼ",I="A-Za-zÀ-ÖØ-öø-ʸ̀-֐ࠀ-῿‎Ⰰ-﬜︀-﹯﻽-￿",R=new RegExp("^[^"+I+"]*["+L+"]"),K=new RegExp("^[^"+L+"]*["+I+"]"),z={bold:1,capitalize:1024,code:16,highlight:T,italic:2,lowercase:256,strikethrough:4,subscript:32,superscript:64,underline:8,uppercase:512},B={directionless:1,unmergeable:2},W={center:2,end:6,justify:4,left:1,right:3,start:5},j={[w]:"center",[A]:"end",[O]:"justify",[b]:"left",[E]:"right",[M]:"start"},J={normal:0,segmented:2,token:1},U={[g]:"normal",[p]:"segmented",[_]:"token"},$="$",V="$config";function Y(t,e,n,r,i,o){let s=t.getFirstChild();for(;null!==s;){const t=s.__key;s.__parent===e&&(Mi(s)&&Y(s,t,n,r,i,o),n.has(t)||o.delete(t),i.push(t)),s=s.getNextSibling()}}let q=!1,H=0;function G(t){H=t.timeStamp}function X(t,e,n){const r="BR"===t.nodeName,i=e.__lexicalLineBreak;return i&&(t===i||r&&t.previousSibling===i)||r&&void 0!==Mo(t,n)}function Q(t,e,n){const r=Es(n);let i=null,o=null;null!==r&&r.anchorNode===t&&(i=r.anchorOffset,o=r.focusOffset);const s=t.nodeValue;null!==s&&Jo(e,s,i,o,!1)}function Z(t,e,n){if(br(t)){const e=t.anchor.getNode();if(e.is(n)&&t.format!==e.getFormat())return!1}return mo(e)&&n.isAttached()}function tt(t,e,n,r){for(let i=t;i&&!Gs(i);i=as(i)){const t=Mo(i,e);if(void 0!==t){const e=Eo(t,n);if(e)return Di(e)||!Is(i)?void 0:[i,e]}else if(i===r)return[r,Lo(n)]}}function et(t,e,n){q=!0;const r=performance.now()-H>100;try{bi(t,()=>{const i=Ur()||function(t){return t.getEditorState().read(()=>{const t=Ur();return null!==t?t.clone():null})}(t),s=new Map,l=t.getRootElement(),c=t._editorState,a=t._blockCursorElement;let u=!1,f="";for(let n=0;n0){let e=0;for(let i=0;i0)for(const[e,n]of s)n.reconcileObservedMutation(e,t);const d=n.takeRecords();if(d.length>0){for(let e=0;e{et(t,e,n)})}class it{key;parse;unparse;isEqual;defaultValue;constructor(t,e){this.key=t,this.parse=e.parse.bind(e),this.unparse=(e.unparse||gt).bind(e),this.isEqual=(e.isEqual||Object.is).bind(e),this.defaultValue=this.parse(void 0)}}function ot(t,e){return new it(t,e)}function st(t,e,n="latest"){const r=("latest"===n?t.getLatest():t).__state;return r?r.getValue(e):e.defaultValue}function lt(t,e,n){const r=st(t,n,"direct"),i=st(e,n,"direct");return n.isEqual(r,i)?null:[r,i]}function ct(t,e,n){let r;if(ui(),"function"==typeof n){const i=t.getLatest(),o=st(i,e);if(r=n(o),e.isEqual(o,r))return i}else r=n;const i=t.getWritable();return ft(i).updateFromKnown(e,r),i}function at(t){const e=new Map,n=new Set;for(let r="function"==typeof t?t:t.replace;r.prototype&&void 0!==r.prototype.getType;r=Object.getPrototypeOf(r)){const{ownNodeConfig:t}=Qs(r);if(t&&t.stateConfigs)for(const r of t.stateConfigs){let t;"stateConfig"in r?(t=r.stateConfig,r.flat&&n.add(t.key)):t=r,e.set(t.key,t)}}return{flatKeys:n,sharedConfigMap:e}}class ut{node;knownState;unknownState;sharedNodeState;size;constructor(t,e,n=void 0,r=new Map,i=void 0){this.node=t,this.sharedNodeState=e,this.unknownState=n,this.knownState=r;const{sharedConfigMap:o}=this.sharedNodeState,s=void 0!==i?i:function(t,e,n){let r=n.size;if(e)for(const i in e){const e=t.get(i);e&&n.has(e)||r++}return r}(o,n,r);this.size=s}getValue(t){const e=this.knownState.get(t);if(void 0!==e)return e;this.sharedNodeState.sharedConfigMap.set(t.key,t);let n=t.defaultValue;if(this.unknownState&&t.key in this.unknownState){const e=this.unknownState[t.key];void 0!==e&&(n=t.parse(e)),this.updateFromKnown(t,n)}return n}getInternalState(){return[this.unknownState,this.knownState]}toJSON(){const t={...this.unknownState},e={};for(const[e,n]of this.knownState)e.isEqual(n,e.defaultValue)?delete t[e.key]:t[e.key]=e.unparse(n);for(const n of this.sharedNodeState.flatKeys)n in t&&(e[n]=t[n],delete t[n]);return ht(t)&&(e.$=t),e}getWritable(t){if(this.node===t)return this;const{sharedNodeState:e,unknownState:n}=this,r=new Map(this.knownState);return new ut(t,e,function(t,e,n){let r;if(n)for(const[i,o]of Object.entries(n)){const n=t.get(i);n?e.has(n)||e.set(n,n.parse(o)):(r=r||{},r[i]=o)}return r}(e.sharedConfigMap,r,n),r,this.size)}updateFromKnown(t,e){const n=t.key;this.sharedNodeState.sharedConfigMap.set(n,t);const{knownState:r,unknownState:i}=this;r.has(t)||i&&n in i||(i&&(delete i[n],this.unknownState=ht(i)),this.size++),r.set(t,e)}updateFromUnknown(t,e){const n=this.sharedNodeState.sharedConfigMap.get(t);n?this.updateFromKnown(n,n.parse(e)):(this.unknownState=this.unknownState||{},t in this.unknownState||this.size++,this.unknownState[t]=e)}updateFromJSON(t){const{knownState:e}=this;for(const t of e.keys())e.set(t,t.defaultValue);if(this.size=e.size,this.unknownState=void 0,t)for(const[e,n]of Object.entries(t))this.updateFromUnknown(e,n)}}function ft(t){const e=t.getWritable(),n=e.__state?e.__state.getWritable(e):new ut(e,dt(e));return e.__state=n,n}function dt(t){return t.__state?t.__state.sharedNodeState:oo(js(),t.getType()).sharedNodeState}function ht(t){if(t)for(const e in t)return t}function gt(t){return t}function _t(t,e,n){for(const[r,i]of e.knownState){if(t.has(r.key))continue;t.add(r.key);const e=n?n.getValue(r):r.defaultValue;if(e!==i&&!r.isEqual(e,i))return!0}return!1}function pt(t,e,n){const{unknownState:r}=e,i=n?n.unknownState:void 0;if(r)for(const[e,n]of Object.entries(r)){if(t.has(e))continue;t.add(e);if(n!==(i?i[e]:void 0))return!0}return!1}function yt(t,e){const n=t.__state;return n&&n.node===t?n.getWritable(e):n}function mt(t,e){const n=t.__mode,r=t.__format,i=t.__style,o=e.__mode,s=e.__format,l=e.__style,c=t.__state,a=e.__state;return(null===n||n===o)&&(null===r||r===s)&&(null===i||i===l)&&(null===t.__state||c===a||function(t,e){if(t===e)return!0;if(t&&e&&t.size!==e.size)return!1;const n=new Set;return!(t&&_t(n,t,e)||e&&_t(n,e,t)||t&&pt(n,t,e)||e&&pt(n,e,t))}(c,a))}function xt(t,e){const n=t.mergeWithSibling(e),r=hi()._normalizedNodes;return r.add(t.__key),r.add(e.__key),n}function Ct(t){let e,n,r=t;if(""!==r.__text||!r.isSimpleText()||r.isUnmergeable()){for(;null!==(e=r.getPreviousSibling())&&pr(e)&&e.isSimpleText()&&!e.isUnmergeable();){if(""!==e.__text){if(mt(e,r)){r=xt(e,r);break}break}e.remove()}for(;null!==(n=r.getNextSibling())&&pr(n)&&n.isSimpleText()&&!n.isUnmergeable();){if(""!==n.__text){if(mt(r,n)){r=xt(r,n);break}break}n.remove()}}else r.remove()}function St(t){return vt(t.anchor),vt(t.focus),t}function vt(t){for(;"element"===t.type;){const e=t.getNode(),n=t.offset;let r,i;if(n===e.getChildrenSize()?(r=e.getChildAtIndex(n-1),i=!0):(r=e.getChildAtIndex(n),i=!1),pr(r)){t.set(r.__key,i?r.getTextContentSize():0,"text",!0);break}if(!Mi(r))break;t.set(r.__key,i?r.getChildrenSize():0,"element",!0)}}let kt,Tt,Nt,bt,wt,Et,Ot,Mt,At,Pt,Dt="",Ft=null,Lt=null,It="",Rt=!1,Kt=!1;function zt(t,e){const n=Ot.get(t);if(null!==e){const n=ne(t);n.parentNode===e&&e.removeChild(n)}if(Mt.has(t)||Tt._keyToDOMMap.delete(t),Mi(n)){const t=Xt(n,Ot);Bt(t,0,t.length-1,null)}void 0!==n&&ts(Pt,Nt,bt,n,"destroyed")}function Bt(t,e,n,r){let i=e;for(;i<=n;++i){const e=t[i];void 0!==e&&zt(e,r)}}function Wt(t,e){t.setProperty("text-align",e)}const jt="40px";function Jt(t,e){const n=kt.theme.indent;if("string"==typeof n){const r=t.classList.contains(n);e>0&&!r?t.classList.add(n):e<1&&r&&t.classList.remove(n)}const r=getComputedStyle(t).getPropertyValue("--lexical-indent-base-value")||jt;t.style.setProperty("padding-inline-start",0===e?"":`calc(${e} * ${r})`)}function Ut(t,e){const n=t.style;0===e?Wt(n,""):1===e?Wt(n,"left"):2===e?Wt(n,"center"):3===e?Wt(n,"right"):4===e?Wt(n,"justify"):5===e?Wt(n,"start"):6===e&&Wt(n,"end")}function $t(t,e){const n=function(t){const e=t.__dir;if(null!==e)return e;if(Li(t))return null;const n=t.getParentOrThrow();return Li(n)&&null===n.__dir?"auto":null}(e);null!==n?t.dir=n:t.removeAttribute("dir")}function Vt(e,n){const r=Mt.get(e);void 0===r&&t(60);const i=r.createDOM(kt,Tt);if(function(t,e,n){const r=n._keyToDOMMap;(function(t,e,n){const r=`__lexicalKey_${e._key}`;t[r]=n})(e,n,t),r.set(t,e)}(e,i,Tt),pr(r)?i.setAttribute("data-lexical-text","true"):Di(r)&&i.setAttribute("data-lexical-decorator","true"),Mi(r)){const t=r.__indent,e=r.__size;if($t(i,r),0!==t&&Jt(i,t),0!==e){const t=e-1;Yt(Xt(r,Mt),r,0,t,r.getDOMSlot(i))}const n=r.__format;0!==n&&Ut(i,n),r.isInline()||Ht(null,r,i),ss(r)&&(Dt+=D,It+=D)}else{const t=r.getTextContent();if(Di(r)){const t=r.decorate(Tt,kt);null!==t&&Zt(e,t),i.contentEditable="false"}Dt+=t,It+=t}return null!==n&&n.insertChild(i),ts(Pt,Nt,bt,r,"created"),i}function Yt(t,e,n,r,i){const o=Dt;Dt="";let s=n;for(;s<=r;++s){Vt(t[s],i);const e=Mt.get(t[s]);null!==e&&pr(e)&&null===Ft&&(Ft=e.getFormat(),Lt=e.getStyle())}ss(e)&&(Dt+=D);i.element.__lexicalTextContent=Dt,Dt=o+Dt}function qt(t,e){if(t){const n=t.__last;if(n){const t=e.get(n);if(t)return Qn(t)?"line-break":Di(t)&&t.isInline()?"decorator":null}return"empty"}return null}function Ht(t,e,n){const r=qt(t,Ot),i=qt(e,Mt);r!==i&&e.getDOMSlot(n).setManagedLineBreak(i)}function Gt(e,n,r){var i;Ft=null,Lt=null,function(e,n,r){const i=Dt,o=e.__size,s=n.__size;Dt="";const l=r.element;if(1===o&&1===s){const t=e.__first,r=n.__first;if(t===r)Qt(t,l);else{const e=ne(t),n=Vt(r,null);try{l.replaceChild(n,e)}catch(i){if("object"==typeof i&&null!=i){const o=`${i.toString()} Parent: ${l.tagName}, new child: {tag: ${n.tagName} key: ${r}}, old child: {tag: ${e.tagName}, key: ${t}}.`;throw new Error(o)}throw i}zt(t,null)}const i=Mt.get(r);pr(i)&&null===Ft&&(Ft=i.getFormat(),Lt=i.getStyle())}else{const i=Xt(e,Ot),c=Xt(n,Mt);if(i.length!==o&&t(227),c.length!==s&&t(228),0===o)0!==s&&Yt(c,n,0,s-1,r);else if(0===s){if(0!==o){const t=null==r.after&&null==r.before&&null==r.element.__lexicalLineBreak;Bt(i,0,o-1,t?null:l),t&&(l.textContent="")}}else!function(t,e,n,r,i,o){const s=r-1,l=i-1;let c,a,u=o.getFirstChild(),f=0,d=0;for(;f<=s&&d<=l;){const t=e[f],r=n[d];if(t===r)u=te(Qt(r,o.element)),f++,d++;else{void 0===c&&(c=new Set(e)),void 0===a&&(a=new Set(n));const i=a.has(t),s=c.has(r);if(i)if(s){const t=ls(Tt,r);t===u?u=te(Qt(r,o.element)):(o.withBefore(u).insertChild(t),Qt(r,o.element)),f++,d++}else Vt(r,o.withBefore(u)),d++;else u=te(ne(t)),zt(t,o.element),f++}const i=Mt.get(r);null!==i&&pr(i)&&null===Ft&&(Ft=i.getFormat(),Lt=i.getStyle())}const h=f>s,g=d>l;if(h&&!g){const e=n[l+1],r=void 0===e?null:Tt.getElementByKey(e);Yt(n,t,d,l,o.withBefore(r))}else g&&!h&&Bt(e,f,s,o.element)}(n,i,c,o,s,r)}ss(n)&&(Dt+=D);l.__lexicalTextContent=Dt,Dt=i+Dt}(e,n,n.getDOMSlot(r)),i=n,null==Ft||Ft===i.__textFormat||Kt||i.setTextFormat(Ft),function(t){null==Lt||Lt===t.__textStyle||Kt||t.setTextStyle(Lt)}(n)}function Xt(e,n){const r=[];let i=e.__first;for(;null!==i;){const e=n.get(i);void 0===e&&t(101),r.push(i),i=e.__next}return r}function Qt(e,n){const r=Ot.get(e);let i=Mt.get(e);void 0!==r&&void 0!==i||t(61);const o=Rt||Et.has(e)||wt.has(e),s=ls(Tt,e);if(r===i&&!o){if(Mi(r)){const t=s.__lexicalTextContent;void 0!==t&&(Dt+=t,It+=t)}else{const t=r.getTextContent();It+=t,Dt+=t}return s}if(r!==i&&o&&ts(Pt,Nt,bt,i,"updated"),i.updateDOM(r,s,kt)){const r=Vt(e,null);return null===n&&t(62),n.replaceChild(r,s),zt(e,null),r}if(Mi(r)&&Mi(i)){const t=i.__indent;(Rt||t!==r.__indent)&&Jt(s,t);const e=i.__format;if((Rt||e!==r.__format)&&Ut(s,e),o&&(Gt(r,i,s),Li(i)||i.isInline()||Ht(r,i,s)),ss(i)&&(Dt+=D,It+=D),(Rt||i.__dir!==r.__dir)&&($t(s,i),Li(i)&&!Rt))for(const t of i.getChildren())if(Mi(t)){$t(ls(Tt,t.getKey()),t)}}else{const t=i.getTextContent();if(Di(i)){const t=i.decorate(Tt,kt);null!==t&&Zt(e,t)}Dt+=t,It+=t}if(!Kt&&Li(i)&&i.__cachedText!==It){const t=i.getWritable();t.__cachedText=It,i=t}return s}function Zt(t,e){let n=Tt._pendingDecorators;const r=Tt._decorators;if(null===n){if(r[t]===e)return;n=Po(Tt)}n[t]=e}function te(t){let e=t.nextSibling;return null!==e&&e===Tt._blockCursorElement&&(e=e.nextSibling),e}function ee(t,e,n,r,i,o){Dt="",It="",Rt=2===r,Tt=n,kt=n._config,Nt=n._nodes,bt=Tt._listeners.mutation,wt=i,Et=o,Ot=t._nodeMap,Mt=e._nodeMap,Kt=e._readOnly,At=new Map(n._keyToDOMMap);const s=new Map;return Pt=s,Qt("root",null),Tt=void 0,Nt=void 0,wt=void 0,Et=void 0,Ot=void 0,Mt=void 0,kt=void 0,At=void 0,Pt=void 0,s}function ne(e){const n=At.get(e);return void 0===n&&t(75,e),n}function re(t){return{type:t}}const ie=re("SELECTION_CHANGE_COMMAND"),oe=re("SELECTION_INSERT_CLIPBOARD_NODES_COMMAND"),se=re("CLICK_COMMAND"),le=re("BEFORE_INPUT_COMMAND"),ce=re("INPUT_COMMAND"),ae=re("COMPOSITION_START_COMMAND"),ue=re("COMPOSITION_END_COMMAND"),fe=re("DELETE_CHARACTER_COMMAND"),de=re("INSERT_LINE_BREAK_COMMAND"),he=re("INSERT_PARAGRAPH_COMMAND"),ge=re("CONTROLLED_TEXT_INSERTION_COMMAND"),_e=re("PASTE_COMMAND"),pe=re("REMOVE_TEXT_COMMAND"),ye=re("DELETE_WORD_COMMAND"),me=re("DELETE_LINE_COMMAND"),xe=re("FORMAT_TEXT_COMMAND"),Ce=re("UNDO_COMMAND"),Se=re("REDO_COMMAND"),ve=re("KEYDOWN_COMMAND"),ke=re("KEY_ARROW_RIGHT_COMMAND"),Te=re("MOVE_TO_END"),Ne=re("KEY_ARROW_LEFT_COMMAND"),be=re("MOVE_TO_START"),we=re("KEY_ARROW_UP_COMMAND"),Ee=re("KEY_ARROW_DOWN_COMMAND"),Oe=re("KEY_ENTER_COMMAND"),Me=re("KEY_SPACE_COMMAND"),Ae=re("KEY_BACKSPACE_COMMAND"),Pe=re("KEY_ESCAPE_COMMAND"),De=re("KEY_DELETE_COMMAND"),Fe=re("KEY_TAB_COMMAND"),Le=re("INSERT_TAB_COMMAND"),Ie=re("INDENT_CONTENT_COMMAND"),Re=re("OUTDENT_CONTENT_COMMAND"),Ke=re("DROP_COMMAND"),ze=re("FORMAT_ELEMENT_COMMAND"),Be=re("DRAGSTART_COMMAND"),We=re("DRAGOVER_COMMAND"),je=re("DRAGEND_COMMAND"),Je=re("COPY_COMMAND"),Ue=re("CUT_COMMAND"),$e=re("SELECT_ALL_COMMAND"),Ve=re("CLEAR_EDITOR_COMMAND"),Ye=re("CLEAR_HISTORY_COMMAND"),qe=re("CAN_REDO_COMMAND"),He=re("CAN_UNDO_COMMAND"),Ge=re("FOCUS_COMMAND"),Xe=re("BLUR_COMMAND"),Qe=re("KEY_MODIFIER_COMMAND"),Ze=Object.freeze({}),tn=[["keydown",function(t,e){if(en=t.timeStamp,nn=t.key,e.isComposing())return;os(e,ve,t)}],["pointerdown",function(t,e){const n=t.target,r=t.pointerType;Rs(n)&&"touch"!==r&&"pen"!==r&&0===t.button&&bi(e,()=>{co(n)||(an=!0)})}],["compositionstart",function(t,e){os(e,ae,t)}],["compositionend",function(t,e){o?fn=!0:c||!l&&!d?os(e,ue,t):(dn=!0,hn=t.data)}],["input",function(t,e){t.stopPropagation(),bi(e,()=>{e.dispatchCommand(ce,t)},{event:t}),on=null}],["click",function(t,e){bi(e,()=>{const n=Ur(),r=Es(e),i=$r();if(r)if(br(n)){const e=n.anchor,o=e.getNode();if("element"===e.type&&0===e.offset&&n.isCollapsed()&&!Li(o)&&1===Fo().getChildrenSize()&&o.getTopLevelElementOrThrow().isEmpty()&&null!==i&&n.is(i))r.removeAllRanges(),n.dirty=!0;else if(3===t.detail&&!n.isCollapsed()){if(o!==n.focus.getNode()){const t=tl(o,t=>Mi(t)&&!t.isInline());Mi(t)&&t.select(0)}}}else if("touch"===t.pointerType||"pen"===t.pointerType){const n=r.anchorNode;if(Is(n)||mo(n)){Io(Jr(i,r,e,t))}}os(e,se,t)})}],["cut",Ze],["copy",Ze],["dragstart",Ze],["dragover",Ze],["dragend",Ze],["paste",Ze],["focus",Ze],["blur",Ze],["drop",Ze]];s&&tn.push(["beforeinput",(t,e)=>function(t,e){const n=t.inputType;if("deleteCompositionText"===n||o&&is(e))return;if("insertCompositionText"===n)return;os(e,le,t)}(t,e)]);let en=0,nn=null,rn=0,on=null;const sn=new WeakMap,ln=new WeakMap;let cn=!1,an=!1,un=!1,fn=!1,dn=!1,hn="",gn=null,_n=[0,"",0,"root",0];function pn(t,e,n,r,i){const o=t.anchor,l=t.focus,c=o.getNode(),a=hi(),u=Es(a),f=null!==u?u.anchorNode:null,d=o.key,h=a.getElementByKey(d),g=n.length;return d!==l.key||!pr(c)||(!i&&(!s||rn1||(i||!s)&&null!==h&&!c.isComposing()&&f!==Co(h)||null!==u&&null!==e&&(!e.collapsed||e.startContainer!==u.anchorNode||e.startOffset!==u.anchorOffset)||c.getFormat()!==t.format||c.getStyle()!==t.style||function(t,e){if(e.isSegmented())return!0;if(!t.isCollapsed())return!1;const n=t.anchor.offset,r=e.getParentOrThrow(),i=po(e);return 0===n?!e.canInsertTextBefore()||!r.canInsertTextBefore()&&!e.isComposing()||i||function(t){const e=t.getPreviousSibling();return(pr(e)||Mi(e)&&e.isInline())&&!e.canInsertTextAfter()}(e):n===e.getTextContentSize()&&(!e.canInsertTextAfter()||!r.canInsertTextAfter()&&!e.isComposing()||i)}(t,c)}function yn(t,e){return mo(t)&&null!==t.nodeValue&&0!==e&&e!==t.nodeValue.length}function mn(e,n,r){const{anchorNode:i,anchorOffset:o,focusNode:s,focusOffset:l}=e;cn&&(cn=!1,yn(i,o)&&yn(s,l)&&!gn)||bi(n,()=>{if(!r)return void Io(null);if(!uo(n,i,s))return;let c=Ur();if(gn&&br(c)&&c.isCollapsed()){const t=c.anchor,e=gn.anchor;(t.key===e.key&&t.offset===e.offset+1||1===t.offset&&e.getNode().is(t.getNode().getPreviousSibling()))&&(c=gn.clone(),Io(c))}if(gn=null,br(c)){const r=c.anchor,i=r.getNode();if(c.isCollapsed()){"Range"===e.type&&e.anchorNode===e.focusNode&&(c.dirty=!0);const o=ps(n).event,s=o?o.timeStamp:performance.now(),[l,a,u,f,d]=_n,h=Fo(),g=!1===n.isComposing()&&""===h.getTextContent();if(s{bi(i,()=>{bo(null)})},30),br(o)){const e=o.anchor.getNode();e.markDirty(),pr(e)||t(142),Cn(o,e)}}else{bo(null),e.preventDefault();const t=o.anchor.getNode(),r=t.getTextContent(),s=t.canInsertTextAfter(),l=0===o.anchor.offset&&o.focus.offset===r.length;let c=f&&n&&!l&&s;if(c&&o.isCollapsed()&&(c=!Di(rs(o.anchor,!0))),!c){os(i,fe,!0);const t=Ur();f&&br(t)&&t.isCollapsed()&&(gn=t,setTimeout(()=>gn=null))}}return!0}}var s;if(!br(o))return!0;const l=e.data;null!==on&&jo(!1,i,on),o.dirty&&null===on||!o.isCollapsed()||Li(o.anchor.getNode())||null===r||o.applyDOMRange(r),on=null;const a=o.anchor,u=o.focus,d=a.getNode(),h=u.getNode();if("insertText"===n||"insertTranspose"===n){if("\n"===l)e.preventDefault(),os(i,de,!1);else if(l===D)e.preventDefault(),os(i,he,void 0);else if(null==l&&e.dataTransfer){const t=e.dataTransfer.getData("text/plain");e.preventDefault(),o.insertRawText(t)}else null!=l&&pn(o,r,l,e.timeStamp,!0)?(e.preventDefault(),os(i,ge,l)):on=l;return rn=e.timeStamp,!0}switch(e.preventDefault(),n){case"insertFromYank":case"insertFromDrop":case"insertReplacementText":os(i,ge,e);break;case"insertFromComposition":bo(null),os(i,ge,e);break;case"insertLineBreak":bo(null),os(i,de,!1);break;case"insertParagraph":bo(null),un&&!c?(un=!1,os(i,de,!1)):os(i,he,void 0);break;case"insertFromPaste":case"insertFromPasteAsQuotation":os(i,_e,e);break;case"deleteByComposition":(function(t,e){return t!==e||Mi(t)||Mi(e)||!po(t)||!po(e)})(d,h)&&os(i,pe,e);break;case"deleteByDrag":case"deleteByCut":os(i,pe,e);break;case"deleteContent":os(i,fe,!1);break;case"deleteWordBackward":os(i,ye,!0);break;case"deleteWordForward":os(i,ye,!1);break;case"deleteHardLineBackward":case"deleteSoftLineBackward":os(i,me,!0);break;case"deleteContentForward":case"deleteHardLineForward":case"deleteSoftLineForward":os(i,me,!1);break;case"formatStrikeThrough":os(i,xe,"strikethrough");break;case"formatBold":os(i,xe,"bold");break;case"formatItalic":os(i,xe,"italic");break;case"formatUnderline":os(i,xe,"underline");break;case"historyUndo":os(i,Ce,void 0);break;case"historyRedo":os(i,Se,void 0)}return!0}function kn(t){if(Is(t.target)&&co(t.target))return!0;const e=hi(),n=Ur(),r=t.data,i=Sn(t);if(null!=r&&br(n)&&pn(n,i,r,t.timeStamp,!1)){fn&&(bn(e,r),fn=!1);const i=n.anchor.getNode(),a=ws(ps(e));if(null===a)return!0;const u=n.isBackward(),f=u?n.anchor.offset:n.focus.offset,h=u?n.focus.offset:n.anchor.offset;s&&!n.isCollapsed()&&pr(i)&&null!==a.anchorNode&&i.getTextContent().slice(0,f)+r+i.getTextContent().slice(f+h)===Wo(a.anchorNode)||os(e,ge,r);const g=r.length;o&&g>1&&"insertCompositionText"===t.inputType&&!e.isComposing()&&(n.anchor.offset-=g),l||c||d||!e.isComposing()||(en=0,bo(null))}else{jo(!1,e,null!==r?r:void 0),fn&&(bn(e,r||void 0),fn=!1)}return function(){ui();const t=hi();nt(t)}(),!0}function Tn(t){const e=hi(),n=Ur();if(br(n)&&!e.isComposing()){const r=n.anchor,i=n.anchor.getNode();bo(r.key),(t.timeStamp{bn(e,hn)}),dn=!1,hn="",!0;if(function(t){return Yo(t,"ArrowRight",{shiftKey:"any"})}(t))os(e,ke,t);else if(function(t){return Yo(t,"ArrowRight",qo)}(t))os(e,Te,t);else if(function(t){return Yo(t,"ArrowLeft",{shiftKey:"any"})}(t))os(e,Ne,t);else if(function(t){return Yo(t,"ArrowLeft",qo)}(t))os(e,be,t);else if(function(t){return Yo(t,"ArrowUp",{altKey:"any",shiftKey:"any"})}(t))os(e,we,t);else if(function(t){return Yo(t,"ArrowDown",{altKey:"any",shiftKey:"any"})}(t))os(e,Ee,t);else if(function(t){return Yo(t,"Enter",{altKey:"any",ctrlKey:"any",metaKey:"any",shiftKey:!0})}(t))un=!0,os(e,Oe,t);else if(function(t){return" "===t.key}(t))os(e,Me,t);else if(function(t){return i&&Yo(t,"o",{ctrlKey:!0})}(t))t.preventDefault(),un=!0,os(e,de,!0);else if(function(t){return Yo(t,"Enter",{altKey:"any",ctrlKey:"any",metaKey:"any"})}(t))un=!1,os(e,Oe,t);else if(function(t){return Yo(t,"Backspace",{shiftKey:"any"})||i&&Yo(t,"h",{ctrlKey:!0})}(t))Go(t)?os(e,Ae,t):(t.preventDefault(),os(e,fe,!0));else if(function(t){return"Escape"===t.key}(t))os(e,Pe,t);else if(function(t){return Yo(t,"Delete",{})||i&&Yo(t,"d",{ctrlKey:!0})}(t))!function(t){return"Delete"===t.key}(t)?(t.preventDefault(),os(e,fe,!1)):os(e,De,t);else if(function(t){return Yo(t,"Backspace",Ho)}(t))t.preventDefault(),os(e,ye,!0);else if(function(t){return Yo(t,"Delete",Ho)}(t))t.preventDefault(),os(e,ye,!1);else if(function(t){return i&&Yo(t,"Backspace",{metaKey:!0})}(t))t.preventDefault(),os(e,me,!0);else if(function(t){return i&&(Yo(t,"Delete",{metaKey:!0})||Yo(t,"k",{ctrlKey:!0}))}(t))t.preventDefault(),os(e,me,!1);else if(function(t){return Yo(t,"b",qo)}(t))t.preventDefault(),os(e,xe,"bold");else if(function(t){return Yo(t,"u",qo)}(t))t.preventDefault(),os(e,xe,"underline");else if(function(t){return Yo(t,"i",qo)}(t))t.preventDefault(),os(e,xe,"italic");else if(function(t){return Yo(t,"Tab",{shiftKey:"any"})}(t))os(e,Fe,t);else if(function(t){return Yo(t,"z",qo)}(t))t.preventDefault(),os(e,Ce,void 0);else if(function(t){if(i)return Yo(t,"z",{metaKey:!0,shiftKey:!0});return Yo(t,"y",{ctrlKey:!0})||Yo(t,"z",{ctrlKey:!0,shiftKey:!0})}(t))t.preventDefault(),os(e,Se,void 0);else{const n=e._editorState._selection;null===n||br(n)?Xo(t)&&(t.preventDefault(),os(e,$e,t)):!function(t){return Yo(t,"c",qo)}(t)?!function(t){return Yo(t,"x",qo)}(t)?Xo(t)&&(t.preventDefault(),os(e,$e,t)):(t.preventDefault(),os(e,Ue,t)):(t.preventDefault(),os(e,Je,t))}return function(t){return t.ctrlKey||t.shiftKey||t.altKey||t.metaKey}(t)&&e.dispatchCommand(Qe,t),!0}function En(t){let e=t.__lexicalEventHandles;return void 0===e&&(e=[],t.__lexicalEventHandles=e),e}const On=new Map;function Mn(t){const e=Ds(t.target);if(null===e)return;const n=ho(e.anchorNode);if(null===n)return;an&&(an=!1,bi(n,()=>{const r=$r(),i=e.anchorNode;if(Is(i)||mo(i)){Io(Jr(r,e,n,t))}}));const r=zo(n),i=r[r.length-1],o=i._key,s=On.get(o),l=s||i;l!==n&&mn(e,l,!1),mn(e,n,!0),n!==i?On.set(o,n):s&&On.delete(o)}function An(t){t._lexicalHandled=!0}function Pn(t){return!0===t._lexicalHandled}const Dn=()=>{};function Fn(e){const n=Os(e);if(void 0===n)return void Dn();const r=ln.get(n);if(void 0===r)return void Dn();const i=r-1;i>=0||t(164),sn.delete(e),ln.set(n,i),0===i&&n.removeEventListener("selectionchange",Mn);const o=go(e);fo(o)?(!function(t){if(null!==t._parentEditor){const e=zo(t),n=e[e.length-1]._key;On.get(n)===t&&On.delete(n)}else On.delete(t._key)}(o),e.__lexicalEditor=null):o&&t(198);const s=En(e);for(let t=0;tt.__key===this.__key);if(pr(this))return n;if(br(e)&&"element"===e.anchor.type&&"element"===e.focus.type){if(e.isCollapsed())return!1;const t=this.getParent();if(Di(this)&&this.isInline()&&t){const n=e.isBackward()?e.focus:e.anchor;if(t.is(n.getNode())&&n.offset===t.getChildrenSize()&&this.is(t.getLastChild()))return!1}}return n}getKey(){return this.__key}getIndexWithinParent(){const t=this.getParent();if(null===t)return-1;let e=t.getFirstChild(),n=0;for(;null!==e;){if(this.is(e))return n;n++,e=e.getNextSibling()}return-1}getParent(){const t=this.getLatest().__parent;return null===t?null:Eo(t)}getParentOrThrow(){const e=this.getParent();return null===e&&t(66,this.__key),e}getTopLevelElement(){let e=this;for(;null!==e;){const n=e.getParent();if(xs(n))return Mi(e)||e===this&&Di(e)||t(194),e;e=n}return null}getTopLevelElementOrThrow(){const e=this.getTopLevelElement();return null===e&&t(67,this.__key),e}getParents(){const t=[];let e=this.getParent();for(;null!==e;)t.push(e),e=e.getParent();return t}getParentKeys(){const t=[];let e=this.getParent();for(;null!==e;)t.push(e.__key),e=e.getParent();return t}getPreviousSibling(){const t=this.getLatest().__prev;return null===t?null:Eo(t)}getPreviousSiblings(){const t=[],e=this.getParent();if(null===e)return t;let n=e.getFirstChild();for(;null!==n&&!n.is(this);)t.push(n),n=n.getNextSibling();return t}getNextSibling(){const t=this.getLatest().__next;return null===t?null:Eo(t)}getNextSiblings(){const t=[];let e=this.getNextSibling();for(;null!==e;)t.push(e),e=e.getNextSibling();return t}getCommonAncestor(t){const e=Mi(this)?this:this.getParent(),n=Mi(t)?t:t.getParent(),r=e&&n?Fl(e,n):null;return r?r.commonAncestor:null}is(t){return null!=t&&this.__key===t.__key}isBefore(e){const n=Fl(this,e);return null!==n&&("descendant"===n.type||("branch"===n.type?-1===Al(n):("same"!==n.type&&"ancestor"!==n.type&&t(279),!1)))}isParentOf(t){const e=Fl(this,t);return null!==e&&"ancestor"===e.type}getNodesBetween(e){const n=this.isBefore(e),r=[],i=new Set;let o=this;for(;null!==o;){const s=o.__key;if(i.has(s)||(i.add(s),r.push(o)),o===e)break;const l=Mi(o)?n?o.getFirstChild():o.getLastChild():null;if(null!==l){o=l;continue}const c=n?o.getNextSibling():o.getPreviousSibling();if(null!==c){o=c;continue}const a=o.getParentOrThrow();if(i.has(a.__key)||r.push(a),a===e)break;let u=null,f=a;do{if(null===f&&t(68),u=n?f.getNextSibling():f.getPreviousSibling(),f=f.getParent(),null===f)break;null!==u||i.has(f.__key)||r.push(f)}while(null===u);o=u}return n||r.reverse(),r}isDirty(){const t=hi()._dirtyLeaves;return null!==t&&t.has(this.__key)}getLatest(){if(Kn(this))return this;const e=Eo(this.__key);return null===e&&t(113),e}getWritable(){if(Kn(this))return this;ui();const t=di(),e=hi(),n=t._nodeMap,r=this.__key,i=this.getLatest(),o=e._cloneNotNeeded,s=Ur();if(null!==s&&s.setCachedNodes(null),o.has(r))return No(i),i;const l=Vs(i);return o.add(r),No(l),n.set(r,l),l}getTextContent(){return""}getTextContentSize(){return this.getTextContent().length}createDOM(e,n){t(70)}updateDOM(e,n,r){t(71)}exportDOM(t){return{element:this.createDOM(t._config,t)}}exportJSON(){const t=this.__state?this.__state.toJSON():void 0;return{type:this.__type,version:1,...t}}static importJSON(e){t(18,this.name)}updateFromJSON(t){return function(t,e){const n=t.getWritable(),r=e.$;let i=r;for(const t of dt(n).flatKeys)t in e&&(void 0!==i&&i!==r||(i={...r}),i[t]=e[t]);return(n.__state||i)&&ft(t).updateFromJSON(i),n}(this,t)}static transform(){return null}remove(t){Ln(this,!0,t)}replace(e,n){ui();let r=Ur();null!==r&&(r=r.clone()),vs(this,e);const i=this.getLatest(),o=this.__key,s=e.__key,l=e.getWritable(),c=this.getParentOrThrow().getWritable(),a=c.__size;To(l);const u=i.getPreviousSibling(),f=i.getNextSibling(),d=i.__prev,h=i.__next,g=i.__parent;if(Ln(i,!1,!0),null===u)c.__first=s;else{u.getWritable().__next=s}if(l.__prev=d,null===f)c.__last=s;else{f.getWritable().__prev=s}if(l.__next=h,l.__parent=g,c.__size=a,n&&(Mi(this)&&Mi(l)||t(139),this.getChildren().forEach(t=>{l.append(t)})),br(r)){Io(r);const t=r.anchor,e=r.focus;t.key===o&&Tr(t,l),e.key===o&&Tr(e,l)}return wo()===o&&bo(s),l}insertAfter(t,e=!0){ui(),vs(this,t);const n=this.getWritable(),r=t.getWritable(),i=r.getParent(),o=Ur();let s=!1,l=!1;if(null!==i){const e=t.getIndexWithinParent();if(To(r),br(o)){const t=i.__key,n=o.anchor,r=o.focus;s="element"===n.type&&n.key===t&&n.offset===e+1,l="element"===r.type&&r.key===t&&r.offset===e+1}}const c=this.getNextSibling(),a=this.getParentOrThrow().getWritable(),u=r.__key,f=n.__next;if(null===c)a.__last=u;else{c.getWritable().__prev=u}if(a.__size++,n.__next=u,r.__next=f,r.__prev=n.__key,r.__parent=n.__parent,e&&br(o)){const t=this.getIndexWithinParent();Vr(o,a,t+1);const e=a.__key;s&&o.anchor.set(e,t+2,"element"),l&&o.focus.set(e,t+2,"element")}return t}insertBefore(t,e=!0){ui(),vs(this,t);const n=this.getWritable(),r=t.getWritable(),i=r.__key;To(r);const o=this.getPreviousSibling(),s=this.getParentOrThrow().getWritable(),l=n.__prev,c=this.getIndexWithinParent();if(null===o)s.__first=i;else{o.getWritable().__next=i}s.__size++,n.__prev=i,r.__prev=l,r.__next=n.__key,r.__parent=n.__parent;const a=Ur();if(e&&br(a)){Vr(a,this.getParentOrThrow(),c)}return t}isParentRequired(){return!1}createParentElementNode(){return Ui()}selectStart(){return this.selectPrevious()}selectEnd(){return this.selectNext(0,0)}selectPrevious(t,e){ui();const n=this.getPreviousSibling(),r=this.getParentOrThrow();if(null===n)return r.select(0,0);if(Mi(n))return n.select();if(!pr(n)){const t=n.getIndexWithinParent()+1;return r.select(t,t)}return n.select(t,e)}selectNext(t,e){ui();const n=this.getNextSibling(),r=this.getParentOrThrow();if(null===n)return r.select();if(Mi(n))return n.select(0,0);if(!pr(n)){const t=n.getIndexWithinParent();return r.select(t,t)}return n.select(t,e)}markDirty(){this.getWritable()}reconcileObservedMutation(t,e){this.markDirty()}}const Bn="historic",Wn="history-push",jn="history-merge",Jn="paste",Un="collaboration",$n="skip-collab",Vn="skip-scroll-into-view",Yn="skip-dom-selection",qn="skip-selection-focus";class Hn extends zn{static getType(){return"linebreak"}static clone(t){return new Hn(t.__key)}constructor(t){super(t)}getTextContent(){return"\n"}createDOM(){return document.createElement("br")}updateDOM(){return!1}isInline(){return!0}static importDOM(){return{br:t=>function(t){const e=t.parentElement;if(null!==e&&Bs(e)){const n=e.firstChild;if(n===t||n.nextSibling===t&&Zn(n)){const n=e.lastChild;if(n===t||n.previousSibling===t&&Zn(n))return!0}}return!1}(t)||function(t){const e=t.parentElement;if(null!==e&&Bs(e)){const n=e.firstChild;if(n===t||n.nextSibling===t&&Zn(n))return!1;const r=e.lastChild;if(r===t||r.previousSibling===t&&Zn(r))return!0}return!1}(t)?null:{conversion:Gn,priority:0}}}static importJSON(t){return Xn().updateFromJSON(t)}}function Gn(t){return{node:Xn()}}function Xn(){return Ss(new Hn)}function Qn(t){return t instanceof Hn}function Zn(t){return mo(t)&&/^( |\t|\r?\n)+$/.test(t.textContent||"")}function tr(t,e){return 16&e?"code":e&T?"mark":32&e?"sub":64&e?"sup":null}function er(t,e){return 1&e?"strong":2&e?"em":"span"}function nr(t,e,n,r,i){const o=r.classList;let s=Zo(i,"base");void 0!==s&&o.add(...s),s=Zo(i,"underlineStrikethrough");let l=!1;const c=8&e&&4&e;void 0!==s&&(8&n&&4&n?(l=!0,c||o.add(...s)):c&&o.remove(...s));for(const t in z){const r=z[t];if(s=Zo(i,t),void 0!==s)if(n&r){if(l&&("underline"===t||"strikethrough"===t)){e&r&&o.remove(...s);continue}(0===(e&r)||c&&"underline"===t||"strikethrough"===t)&&o.add(...s)}else e&r&&o.remove(...s)}}function rr(t,e,n){const r=e.firstChild,i=n.isComposing(),s=t+(i?P:"");if(null==r)e.textContent=s;else{const t=r.nodeValue;if(t!==s)if(i||o){const[e,n,i]=function(t,e){const n=t.length,r=e.length;let i=0,o=0;for(;i({conversion:fr,priority:0}),b:()=>({conversion:cr,priority:0}),code:()=>({conversion:gr,priority:0}),em:()=>({conversion:gr,priority:0}),i:()=>({conversion:gr,priority:0}),mark:()=>({conversion:gr,priority:0}),s:()=>({conversion:gr,priority:0}),span:()=>({conversion:lr,priority:0}),strong:()=>({conversion:gr,priority:0}),sub:()=>({conversion:gr,priority:0}),sup:()=>({conversion:gr,priority:0}),u:()=>({conversion:gr,priority:0})}}static importJSON(t){return _r().updateFromJSON(t)}updateFromJSON(t){return super.updateFromJSON(t).setTextContent(t.text).setFormat(t.format).setDetail(t.detail).setMode(t.mode).setStyle(t.style)}exportDOM(e){let{element:n}=super.exportDOM(e);return Is(n)||t(132),n.style.whiteSpace="pre-wrap",this.hasFormat("lowercase")?n.style.textTransform="lowercase":this.hasFormat("uppercase")?n.style.textTransform="uppercase":this.hasFormat("capitalize")&&(n.style.textTransform="capitalize"),this.hasFormat("bold")&&(n=or(n,"b")),this.hasFormat("italic")&&(n=or(n,"i")),this.hasFormat("strikethrough")&&(n=or(n,"s")),this.hasFormat("underline")&&(n=or(n,"u")),{element:n}}exportJSON(){return{detail:this.getDetail(),format:this.getFormat(),mode:this.getMode(),style:this.getStyle(),text:this.getTextContent(),...super.exportJSON()}}selectionTransform(t,e){}setFormat(t){const e=this.getWritable();return e.__format="string"==typeof t?z[t]:t,e}setDetail(t){const e=this.getWritable();return e.__detail="string"==typeof t?B[t]:t,e}setStyle(t){const e=this.getWritable();return e.__style=t,e}toggleFormat(t){const e=So(this.getFormat(),t,null);return this.setFormat(e)}toggleDirectionless(){const t=this.getWritable();return t.__detail^=1,t}toggleUnmergeable(){const t=this.getWritable();return t.__detail^=2,t}setMode(t){const e=J[t];if(this.__mode===e)return this;const n=this.getWritable();return n.__mode=e,n}setTextContent(t){if(this.__text===t)return this;const e=this.getWritable();return e.__text=t,e}select(t,e){ui();let n=t,r=e;const i=Ur(),o=this.getTextContent(),s=this.__key;if("string"==typeof o){const t=o.length;void 0===n&&(n=t),void 0===r&&(r=t)}else n=0,r=0;if(!br(i))return zr(s,n,s,r,"text","text");{const t=wo();t!==i.anchor.key&&t!==i.focus.key||bo(s),i.setTextNodeRange(this,n,this,r)}return i}selectStart(){return this.select(0,0)}selectEnd(){const t=this.getTextContentSize();return this.select(t,t)}spliceText(t,e,n,r){const i=this.getWritable(),o=i.__text,s=n.length;let l=t;l<0&&(l=s+l,l<0&&(l=0));const c=Ur();if(r&&br(c)){const e=t+s;c.setTextNodeRange(i,e,i,e)}const a=o.slice(0,l)+n+o.slice(l+e);return i.__text=a,i}canInsertTextBefore(){return!0}canInsertTextAfter(){return!0}splitText(...t){ui();const e=this.getLatest(),n=e.getTextContent();if(""===n)return[];const r=e.__key,i=wo(),o=n.length;t.sort((t,e)=>t-e),t.push(o);const s=[],l=t.length;for(let e=0,r=0;ee&&(s.push(n.slice(e,i)),e=i)}const c=s.length;if(1===c)return[e];const a=s[0],u=e.getParent();let f;const d=e.getFormat(),h=e.getStyle(),g=e.__detail;let _=!1,p=null,y=null;const m=Ur();if(br(m)){const[t,e]=m.isBackward()?[m.focus,m.anchor]:[m.anchor,m.focus];"text"===t.type&&t.key===r&&(p=t),"text"===e.type&&e.key===r&&(y=e)}e.isSegmented()?(f=_r(a),f.__format=d,f.__style=h,f.__detail=g,f.__state=yt(e,f),_=!0):f=e.setTextContent(a);const x=[f];for(let t=1;t=v&&(p.set(t.getKey(),C-v,"text"),C=v){y.set(t.getKey(),S-v,"text");break}v=e}if(null!==u){!function(t){const e=t.getPreviousSibling(),n=t.getNextSibling();null!==e&&No(e);null!==n&&No(n)}(this);const t=u.getWritable(),e=this.getIndexWithinParent();_?(t.splice(e,0,x),this.remove()):t.splice(e,1,x),br(m)&&Vr(m,u,e,c-1)}return x}mergeWithSibling(e){const n=e===this.getPreviousSibling();n||e===this.getNextSibling()||t(50);const r=this.__key,i=e.__key,o=this.__text,s=o.length;wo()===i&&bo(r);const l=Ur();if(br(l)){const t=l.anchor,o=l.focus;null!==t&&t.key===i&&Hr(t,n,r,e,s),null!==o&&o.key===i&&Hr(o,n,r,e,s)}const c=e.__text,a=n?c+o:o+c;this.setTextContent(a);const u=this.getWritable();return e.remove(),u}isTextEntity(){return!1}}function lr(t){return{forChild:yr(t.style),node:null}}function cr(t){const e=t,n="normal"===e.style.fontWeight;return{forChild:yr(e.style,n?void 0:"bold"),node:null}}const ar=new WeakMap;function ur(t){if(!Is(t))return!1;if("PRE"===t.nodeName)return!0;const e=t.style.whiteSpace;return"string"==typeof e&&e.startsWith("pre")}function fr(e){const n=e;null===e.parentElement&&t(129);let r=n.textContent||"";if(null!==function(t){let e,n=t.parentNode;const r=[t];for(;null!==n&&void 0===(e=ar.get(n))&&!ur(n);)r.push(n),n=n.parentNode;const i=void 0===e?n:e;for(let t=0;t0){/[ \t\n]$/.test(n)&&(r=r.slice(1)),e=!1;break}}e&&(r=r.slice(1))}if(" "===r[r.length-1]){let t=n,e=!0;for(;null!==t&&null!==(t=dr(t,!0));){if((t.textContent||"").replace(/^( |\t|\r?\n)+/,"").length>0){e=!1;break}}e&&(r=r.slice(0,r.length-1))}return""===r?{node:null}:{node:_r(r)}}function dr(t,e){let n=t;for(;;){let t;for(;null===(t=e?n.nextSibling:n.previousSibling);){const t=n.parentElement;if(null===t)return null;n=t}if(n=t,Is(n)){const t=n.style.display;if(""===t&&!zs(n)||""!==t&&!t.startsWith("inline"))return null}let r=n;for(;null!==(r=e?n.firstChild:n.lastChild);)n=r;if(mo(n))return n;if("BR"===n.nodeName)return null}}const hr={code:"code",em:"italic",i:"italic",mark:"highlight",s:"strikethrough",strong:"bold",sub:"subscript",sup:"superscript",u:"underline"};function gr(t){const e=hr[t.nodeName.toLowerCase()];return void 0===e?{node:null}:{forChild:yr(t.style,e),node:null}}function _r(t=""){return Ss(new sr(t))}function pr(t){return t instanceof sr}function yr(t,e){const n=t.fontWeight,r=t.textDecoration.split(" "),i="700"===n||"bold"===n,o=r.includes("line-through"),s="italic"===t.fontStyle,l=r.includes("underline"),c=t.verticalAlign;return t=>pr(t)?(i&&!t.hasFormat("bold")&&t.toggleFormat("bold"),o&&!t.hasFormat("strikethrough")&&t.toggleFormat("strikethrough"),s&&!t.hasFormat("italic")&&t.toggleFormat("italic"),l&&!t.hasFormat("underline")&&t.toggleFormat("underline"),"sub"!==c||t.hasFormat("subscript")||t.toggleFormat("subscript"),"super"!==c||t.hasFormat("superscript")||t.toggleFormat("superscript"),e&&!t.hasFormat(e)&&t.toggleFormat(e),t):t}class mr extends sr{static getType(){return"tab"}static clone(t){return new mr(t.__key)}constructor(t){super("\t",t),this.__detail=2}static importDOM(){return null}createDOM(t){const e=super.createDOM(t),n=Zo(t.theme,"tab");if(void 0!==n){e.classList.add(...n)}return e}static importJSON(t){return xr().updateFromJSON(t)}setTextContent(t){return"\t"!==t&&""!==t&&e(126),super.setTextContent("\t")}spliceText(e,n,r,i){return""===r&&0===n||"\t"===r&&1===n||t(286),this}setDetail(e){return 2!==e&&t(127),this}setMode(e){return"normal"!==e&&t(128),this}canInsertTextBefore(){return!1}canInsertTextAfter(){return!1}}function xr(){return Ss(new mr)}function Cr(t){return t instanceof mr}class Sr{key;offset;type;_selection;constructor(t,e,n){this._selection=null,this.key=t,this.offset=e,this.type=n}is(t){return this.key===t.key&&this.offset===t.offset&&this.type===t.type}isBefore(t){if(this.key===t.key)return this.offsett&&(r=t)}else if(!Mi(e)){const t=e.getNextSibling();if(pr(t))n=t.__key,r=0,i="text";else{const t=e.getParent();t&&(n=t.__key,r=e.getIndexWithinParent()+1)}}t.set(n,r,i)}function Tr(t,e){if(Mi(e)){const n=e.getLastDescendant();Mi(n)||pr(n)?kr(t,n):kr(t,e)}else kr(t,e)}class Nr{_nodes;_cachedNodes;dirty;constructor(t){this._cachedNodes=null,this._nodes=t,this.dirty=!1}getCachedNodes(){return this._cachedNodes}setCachedNodes(t){this._cachedNodes=t}is(t){if(!Er(t))return!1;const e=this._nodes,n=t._nodes;return e.size===n.size&&Array.from(e).every(t=>n.has(t))}isCollapsed(){return!1}isBackward(){return!1}getStartEndPoints(){return null}add(t){this.dirty=!0,this._nodes.add(t),this._cachedNodes=null}delete(t){this.dirty=!0,this._nodes.delete(t),this._cachedNodes=null}clear(){this.dirty=!0,this._nodes.clear(),this._cachedNodes=null}has(t){return this._nodes.has(t)}clone(){return new Nr(new Set(this._nodes))}extract(){return this.getNodes()}insertRawText(t){}insertText(){}insertNodes(t){const e=this.getNodes(),n=e.length,r=e[n-1];let i;if(pr(r))i=r.select();else{const t=r.getIndexWithinParent()+1;i=r.getParentOrThrow().select(t,t)}i.insertNodes(t);for(let t=0;t1;){const t=e[e.length-1];if(!Mi(t)||o.has(t)||t.isEmpty()||i.has(t))break;e.pop()}if(0===e.length&&t.isCollapsed()){const n=Ul(t.anchor),r=Ul(t.anchor.getFlipped()),i=t=>al(t)?t.origin:t.getNodeAtCaret(),o=i(n)||i(r)||(t.anchor.getNodeAtCaret()?n.origin:r.origin);e.push(o)}return e}(Yl(zl(this),"next"));return ai()||(this._cachedNodes=e),e}setTextNodeRange(t,e,n,r){this.anchor.set(t.__key,e,"text"),this.focus.set(n.__key,r,"text")}getTextContent(){const t=this.getNodes();if(0===t.length)return"";const e=t[0],n=t[t.length-1],r=this.anchor,i=this.focus,o=r.isBefore(i),[s,l]=Mr(this);let c="",a=!0;for(let u=0;u=0;t--){const e=o[t];if(e.is(d)||Mi(e)&&e.isParentOf(d))break;e.isAttached()&&(!s.has(e)||e.is(i)?g||p.insertAfter(e,!1):e.remove())}if(!g){let e=r,n=null;for(;null!==e;){const r=e.getChildren(),i=r.length;(0===i||r[i-1].is(n))&&(t.delete(e.__key),n=e),e=e.getParent()}}if(po(d))if(c===h)d.select();else{const t=_r(e);t.select(),d.replace(t)}else d=d.spliceText(c,h-c,e,!0),""===d.getTextContent()?d.remove():d.isComposing()&&"text"===this.anchor.type&&(this.anchor.offset-=e.length);for(let e=1;e{n.forEach(n=>{if(Mi(n)){const r=n.getFormatFlags(t,e);n.setTextFormat(r)}})},o=r.length;if(0===o)return this.toggleFormat(t),bo(null),void i(e);const s=this.anchor,l=this.focus,c=this.isBackward(),a=c?l:s,u=c?s:l;let f=0,d=r[0],h="element"===a.type?0:a.offset;if("text"===a.type&&h===d.getTextContentSize()&&(f=1,d=r[1],h=0),null==d)return;const g=d.getFormatFlags(t,e);i(g);const _=o-1;let p=r[_];const y="text"===u.type?u.offset:p.getTextContentSize();if(d.is(p)){if(h===y)return;if(yo(d)||0===h&&y===d.getTextContentSize())d.setFormat(g);else{const t=d.splitText(h,y),e=0===h?t[0]:t[1];e.setFormat(g),"text"===a.type&&a.set(e.__key,0,"text"),"text"===u.type&&u.set(e.__key,y-h,"text")}return void(this.format=g)}0===h||yo(d)||([,d]=d.splitText(h),h=0),d.setFormat(g);const m=p.getFormatFlags(t,g);y>0&&(y===p.getTextContentSize()||yo(p)||([p]=p.splitText(y)),p.setFormat(m));for(let e=f+1;e<_;e++){const n=r[e],i=n.getFormatFlags(t,m);n.setFormat(i)}"text"===a.type&&a.set(d.__key,h,"text"),"text"===u.type&&u.set(p.__key,y,"text"),this.format=g|m}insertNodes(e){if(0===e.length)return;if(this.isCollapsed()||this.removeText(),"root"===this.anchor.key){this.insertParagraph();const n=Ur();return br(n)||t(134),n.insertNodes(e)}const n=(this.isBackward()?this.focus:this.anchor).getNode(),r=tl(n,Ws),i=e[e.length-1];if(Mi(r)&&"__language"in r){if("__language"in e[0])this.insertText(e[0].getTextContent());else{const t=ti(this);r.splice(t,0,e),i.selectEnd()}return}if(!e.some(t=>(Mi(t)||Di(t))&&!t.isInline())){Mi(r)||t(211,n.constructor.name,n.getType());const o=ti(this);return r.splice(o,0,e),void i.selectEnd()}const o=function(t){const e=Ui();let n=null;for(let r=0;r0){const t=o.getRangeAt(0),n=this.anchor.getNode(),i=Li(n)?n:ms(n);if(this.applyDOMRange(t),this.dirty=!0,!r){const n=this.getNodes(),r=[];let s=!1;for(let t=0;t0)if(e){const t=r[0];Mi(t)?t.selectStart():t.getParentOrThrow().selectStart()}else{const t=r[r.length-1];Mi(t)?t.selectEnd():t.getParentOrThrow().selectEnd()}o.anchorNode===t.startContainer&&o.anchorOffset===t.startOffset||function(t){const e=t.focus,n=t.anchor,r=n.key,i=n.offset,o=n.type;n.set(e.key,e.offset,e.type,!0),e.set(r,i,o,!0)}(this)}}"lineboundary"===n&&ni(this,t,e,n,"decorators")}forwardDeletion(t,e,n){if(!n&&("element"===t.type&&Mi(e)&&t.offset===e.getChildrenSize()||"text"===t.type&&t.offset===e.getTextContentSize())){const t=e.getParent(),n=e.getNextSibling()||(null===t?null:t.getNextSibling());if(Mi(n)&&n.isShadowRoot())return!0}return!1}deleteCharacter(t){const e=this.isCollapsed();if(this.isCollapsed()){const e=this.anchor;let n=e.getNode();if(this.forwardDeletion(e,n,t))return;const r=bl(Ll(e,t?"previous":"next"));if(r.getTextSlices().every(t=>null===t||0===t.distance)){let t={type:"initial"};for(const e of r.iterNodeCarets("shadowRoot"))if(dl(e))if(e.origin.isInline());else{if(e.origin.isShadowRoot()){if("merge-block"===t.type)break;if(Mi(r.anchor.origin)&&r.anchor.origin.isEmpty()){const t=Ul(e);Kl(this,El(t,t)),r.anchor.origin.remove()}return}"merge-next-block"!==t.type&&"merge-block"!==t.type||(t={block:t.block,caret:e,type:"merge-block"})}else{if("merge-block"===t.type)break;if(fl(e)){if(Mi(e.origin)){if(e.origin.isInline()){if(!e.origin.isParentOf(r.anchor.origin))break}else t={block:e.origin,type:"merge-next-block"};continue}if(Di(e.origin)){if(e.origin.isIsolated());else if("merge-next-block"===t.type&&(e.origin.isKeyboardSelectable()||!e.origin.isInline())&&Mi(r.anchor.origin)&&r.anchor.origin.isEmpty()){r.anchor.origin.remove();const t=Wr();t.add(e.origin.getKey()),Io(t)}else e.origin.remove();return}break}}if("merge-block"===t.type){const{caret:e,block:n}=t;return Kl(this,El(!e.origin.isEmpty()&&n.isEmpty()?Bl(pl(n,e.direction)):r.anchor,e)),this.removeText()}}const i=this.focus,o=e.key,s=e.offset,l=i.key,c=i.offset;this.modify("extend",t,"character");if(!(this.anchor.key!==o||this.anchor.offset!==s||this.focus.key!==l||this.focus.offset!==c)&&"text"===e.type&&pr(n)){const r=n.getTextContent(),o=e.offset;t&&o>0?this.anchor.set(e.key,o-1,"text"):!t&&o0?this.anchor.set(e.key,0,"text"):!t&&o=0&&this.isWordBoundary(t[n]);)n--;for(;n>0&&!this.isWordBoundary(t[n-1]);)n--;return n>=0?n:0}findWordEnd(t,e){let n=e;for(;n{try{const t=new RegExp("\\p{Emoji}","u"),e=t.test.bind(t);if(e("❤️")&&e("#️⃣")&&e("👍"))return e}catch(t){}return()=>!1})();function Dr(t,e,n){const r=t,i=r.getTextContent().split(/(?=\s)/g),o=i.length;let s=0,l=0;for(let t=0;tn||r){i.splice(t,1),r&&(l=void 0);break}}const c=i.join("").trim();""===c?r.remove():(r.setTextContent(c),r.select(l,l))}function Fr(e,n,r,i){let o,s=n;if(Is(e)){let l=!1;const c=e.childNodes,a=c.length,u=i._blockCursorElement;s===a&&(l=!0,s=a-1);let f=c[s],d=!1;if(f===u)f=c[s+1],d=!0;else if(null!==u){const t=u.parentNode;if(e===t){n>Array.prototype.indexOf.call(t.children,u)&&s--}}if(o=Ro(f),pr(o))s=ml(o,l?"next":"previous");else{let c=Ro(e);if(null===c)return null;if(Mi(c)){const a=i.getElementByKey(c.getKey());null===a&&t(214);const u=c.getDOMSlot(a);[c,s]=u.resolveChildIndex(c,a,e,n),Mi(c)||t(215),l&&s>=c.getChildrenSize()&&(s=Math.max(0,c.getChildrenSize()-1));let f=c.getChildAtIndex(s);if(Mi(f)&&function(t,e,n){const r=t.getParent();return null===n||null===r||!r.canBeEmpty()||r!==n.getNode()}(f,0,r)){const t=l?f.getLastDescendant():f.getFirstDescendant();null===t?c=f:(f=t,c=Mi(f)?f:f.getParentOrThrow()),s=0}pr(f)?(o=f,c=null,s=ml(f,l?"next":"previous")):f!==c&&l&&!d&&(Mi(c)||t(216),s=Math.min(c.getChildrenSize(),s+1))}else{const t=c.getIndexWithinParent();s=0===n&&Di(c)&&Ro(e)===c?t:t+1,c=c.getParentOrThrow()}if(Mi(c))return vr(c.__key,s,"element")}}else o=Ro(e);return pr(o)?vr(o.__key,ml(o,s,"clamp"),"text"):null}function Lr(t,e,n){const r=t.offset,i=t.getNode();if(0===r){const r=i.getPreviousSibling(),o=i.getParent();if(e){if((n||!e)&&null===r&&Mi(o)&&o.isInline()){const e=o.getPreviousSibling();pr(e)&&t.set(e.__key,e.getTextContent().length,"text")}}else Mi(r)&&!n&&r.isInline()?t.set(r.__key,r.getChildrenSize(),"element"):pr(r)&&t.set(r.__key,r.getTextContent().length,"text")}else if(r===i.getTextContent().length){const r=i.getNextSibling(),o=i.getParent();if(e&&Mi(r)&&r.isInline())t.set(r.__key,0,"element");else if((n||e)&&null===r&&Mi(o)&&o.isInline()&&!o.canInsertTextAfter()){const e=o.getNextSibling();pr(e)&&t.set(e.__key,0,"text")}}}function Ir(t,e,n){if("text"===t.type&&"text"===e.type){const r=t.isBefore(e),i=t.is(e);Lr(t,r,i),Lr(e,!r,i),i&&e.set(t.key,t.offset,t.type);const o=hi();if(o.isComposing()&&o._compositionKey!==t.key&&br(n)){const r=n.anchor,i=n.focus;t.set(r.key,r.offset,r.type,!0),e.set(i.key,i.offset,i.type,!0)}}}function Rr(t,e,n,r,i,o){if(null===t||null===n||!uo(i,t,n))return null;const s=Fr(t,e,br(o)?o.anchor:null,i);if(null===s)return null;const l=Fr(n,r,br(o)?o.focus:null,i);if(null===l)return null;if("element"===s.type&&"element"===l.type){const e=Ro(t),r=Ro(n);if(Di(e)&&Di(r))return null}return Ir(s,l,o),[s,l]}function Kr(t){return Mi(t)&&!t.isInline()}function zr(t,e,n,r,i,o){const s=di(),l=new wr(vr(t,e,i),vr(n,r,o),0,"");return l.dirty=!0,s._selection=l,l}function Br(){const t=vr("root",0,"element"),e=vr("root",0,"element");return new wr(t,e,0,"")}function Wr(){return new Nr(new Set)}function jr(t,e){return Jr(null,t,e,null)}function Jr(t,e,n,r){const i=n._window;if(null===i)return null;const o=r||i.event,s=o?o.type:void 0,l="selectionchange"===s,c=!q&&(l||"beforeinput"===s||"compositionstart"===s||"compositionend"===s||"click"===s&&o&&3===o.detail||"drop"===s||void 0===s);let a,u,f,d;if(br(t)&&!c)return t.clone();if(null===e)return null;if(a=e.anchorNode,u=e.focusNode,f=e.anchorOffset,d=e.focusOffset,(l||void 0===s)&&br(t)&&!uo(n,a,u))return t.clone();const h=Rr(a,f,u,d,n,t);if(null===h)return null;const[g,_]=h;return new wr(g,_,br(t)?t.format:0,br(t)?t.style:"")}function Ur(){return di()._selection}function $r(){return hi()._editorState._selection}function Vr(t,e,n,r=1){const i=t.anchor,o=t.focus,s=i.getNode(),l=o.getNode();if(!e.is(s)&&!e.is(l))return;const c=e.__key;if(t.isCollapsed()){const e=i.offset;if(n<=e&&r>0||n0||n0||n=t,s=i?o.getChildAtIndex(t-1):o.getChildAtIndex(n);if(pr(s)){let t=0;i&&(t=s.getTextContentSize()),e.set(s.__key,t,"text"),r.set(s.__key,t,"text")}return}if(Mi(o)){const t=o.getChildrenSize(),r=n>=t,i=r?o.getChildAtIndex(t-1):o.getChildAtIndex(n);if(pr(i)){let t=0;r&&(t=i.getTextContentSize()),e.set(i.__key,t,"text")}}if(Mi(s)){const t=s.getChildrenSize(),e=i>=t,n=e?s.getChildAtIndex(t-1):s.getChildAtIndex(i);if(pr(n)){let t=0;e&&(t=n.getTextContentSize()),r.set(n.__key,t,"text")}}}function qr(t,e,n,r,i){let o=null,s=0,l=null;null!==r?(o=r.__key,pr(r)?(s=r.getTextContentSize(),l="text"):Mi(r)&&(s=r.getChildrenSize(),l="element")):null!==i&&(o=i.__key,pr(i)?l="text":Mi(i)&&(l="element")),null!==o&&null!==l?t.set(o,s,l):(s=e.getIndexWithinParent(),-1===s&&(s=n.getChildrenSize()),t.set(n.__key,s,"element"))}function Hr(t,e,n,r,i){"text"===t.type?t.set(n,t.offset+(e?0:i),"text"):t.offset>r.getIndexWithinParent()&&t.set(t.key,t.offset-1,"element")}function Gr(t,e,n,r,i){try{t.setBaseAndExtent(e,n,r,i)}catch(t){}}function Xr(t,e,n,r,i,o,s){const l=r.anchorNode,c=r.focusNode,a=r.anchorOffset,u=r.focusOffset,f=Ps(o);if(i.has(Un)&&f!==o||null!==f&&ao(f))return;if(!br(e))return void(null!==t&&uo(n,l,c)&&r.removeAllRanges());const d=e.anchor,h=e.focus,g=d.key,_=h.key,p=ls(n,g),y=ls(n,_),m=d.offset,x=h.offset,C=e.format,S=e.style,v=e.isCollapsed();let k=p,T=y,N=!1;if("text"===d.type){k=Co(p);const t=d.getNode();N=t.getFormat()!==C||t.getStyle()!==S}else br(t)&&"text"===t.anchor.type&&(N=!0);var b,w,E,O,M;if(("text"===h.type&&(T=Co(y)),null!==k&&null!==T)&&(v&&(null===t||N||br(t)&&(t.format!==C||t.style!==S))&&(b=C,w=S,E=m,O=g,M=performance.now(),_n=[b,w,E,O,M]),a!==m||u!==x||l!==k||c!==T||"Range"===r.type&&v||(null!==f&&o.contains(f)||i.has(qn)||o.focus({preventScroll:!0}),"element"===d.type))){if(Gr(r,k,m,T,x),!i.has(Vn)&&e.isCollapsed()&&null!==o&&o===document.activeElement){const t=br(e)&&"element"===e.anchor.type?k.childNodes[m]||null:r.rangeCount>0?r.getRangeAt(0):null;if(null!==t){let e;if(t instanceof Text){const n=document.createRange();n.selectNode(t),e=n.getBoundingClientRect()}else e=t.getBoundingClientRect();!function(t,e,n){const r=us(n),i=_s(r);if(null===r||null===i)return;let{top:o,bottom:s}=e,l=0,c=0,a=n;for(;null!==a;){const e=a===r.body;if(e)l=0,c=ps(t).innerHeight;else{const t=a.getBoundingClientRect();l=t.top,c=t.bottom}let n=0;if(oc&&(n=s-c),0!==n)if(e)i.scrollBy(0,n);else{const t=a.scrollTop;a.scrollTop+=n;const e=a.scrollTop-t;o-=e,s-=e}if(e)break;a=as(a)}}(n,e,o)}}cn=!0}}function Qr(t){let e=Ur()||$r();null===e&&(e=Fo().selectEnd()),e.insertNodes(t)}function Zr(){const t=Ur();return null===t?"":t.getTextContent()}function ti(e){let n=e;e.isCollapsed()||n.removeText();const r=Ur();br(r)&&(n=r),br(n)||t(161);const i=n.anchor;let o=i.getNode(),s=i.offset;for(;!Ws(o);){const t=o;if([o,s]=ei(o,s),t.is(o))break}return s}function ei(t,e){const n=t.getParent();if(!n){const t=Ui();return Fo().append(t),t.select(),[Fo(),0]}if(pr(t)){const r=t.splitText(e);if(0===r.length)return[n,t.getIndexWithinParent()];const i=0===e?0:1;return[n,r[0].getIndexWithinParent()+i]}if(!Mi(t)||0===e)return[n,t.getIndexWithinParent()];const r=t.getChildAtIndex(e);if(r){const n=new wr(vr(t.__key,e,"element"),vr(t.__key,e,"element"),0,""),i=t.insertNewAfter(n);i&&i.append(r,...r.getNextSiblings())}return[n,t.getIndexWithinParent()+1]}function ni(t,e,n,r,i="decorators-and-blocks"){if("move"===e&&"character"===r&&!t.isCollapsed()){const[e,r]=n===t.isBackward()?[t.focus,t.anchor]:[t.anchor,t.focus];return r.set(e.key,e.offset,e.type),!0}const o=Ll(t.focus,n?"previous":"next"),s="lineboundary"===r,l="move"===e;let c=o,a="decorators-and-blocks"===i;if(!$l(c)){for(const t of c){a=!1;const{origin:e}=t;if(!Di(e)||e.isIsolated()||(c=t,!s||!e.isInline()))break}if(a)for(const t of bl(o).iterNodeCarets("extend"===e?"shadowRoot":"root")){if(dl(t))t.origin.isInline()||(c=t);else{if(Mi(t.origin))continue;Di(t.origin)&&!t.origin.isInline()&&(c=t)}break}}if(c===o)return!1;if(l&&!s&&Di(c.origin)&&c.origin.isKeyboardSelectable()){const t=Wr();return t.add(c.origin.getKey()),Io(t),!0}return c=Ul(c),l&&Il(t.anchor,c),Il(t.focus,c),a||!s}let ri=null,ii=null,oi=!1,si=!1,li=0;const ci={characterData:!0,childList:!0,subtree:!0};function ai(){return oi||null!==ri&&ri._readOnly}function ui(){oi&&t(13)}function fi(){li>99&&t(14)}function di(){return null===ri&&t(195,gi()),ri}function hi(){return null===ii&&t(196,gi()),ii}function gi(){let t=0;const e=new Set,n=to.version;if("undefined"!=typeof window)for(const r of document.querySelectorAll("[contenteditable]")){const i=go(r);if(fo(i))t++;else if(i){let t=String(i.constructor.version||"<0.17.1");t===n&&(t+=" (separately built, likely a bundler configuration issue)"),e.add(t)}}let r=` Detected on the page: ${t} compatible editor(s) with version ${n}`;return e.size&&(r+=` and incompatible editors with versions ${Array.from(e).join(", ")}`),r}function _i(){return ii}function pi(t,e,n){const r=e.__type,i=oo(t,r);let o=n.get(r);void 0===o&&(o=Array.from(i.transforms),n.set(r,o));const s=o.length;for(let t=0;t0||u>0;){if(c>0){e._dirtyLeaves=new Set;for(const t of l){const r=i.get(t);pr(r)&&r.isAttached()&&r.isSimpleText()&&!r.isUnmergeable()&&Ct(r),void 0!==r&&yi(r,o)&&pi(e,r,s),n.add(t)}if(l=e._dirtyLeaves,c=l.size,c>0){li++;continue}}e._dirtyLeaves=new Set,e._dirtyElements=new Map,a.delete("root")&&a.set("root",!0);for(const t of a){const n=t[0],l=t[1];if(r.set(n,l),!l)continue;const c=i.get(n);void 0!==c&&yi(c,o)&&pi(e,c,s)}l=e._dirtyLeaves,c=l.size,a=e._dirtyElements,u=a.size,li++}e._dirtyLeaves=n,e._dirtyElements=r}(a,e),Ti(e),function(t,e,n,r){const i=t._nodeMap,o=e._nodeMap,s=[];for(const[t]of r){const e=o.get(t);void 0!==e&&(e.isAttached()||(Mi(e)&&Y(e,t,i,o,s,r),i.has(t)||r.delete(t),s.push(t)))}for(const t of s)o.delete(t);for(const t of n){const e=o.get(t);void 0===e||e.isAttached()||(i.has(t)||n.delete(t),o.delete(t))}}(c,a,e._dirtyLeaves,e._dirtyElements));i!==e._compositionKey&&(a._flushSync=!0);const o=a._selection;if(br(o)){const e=a._nodeMap,n=o.anchor.key,r=o.focus.key;void 0!==e.get(n)&&void 0!==e.get(r)||t(19)}else Er(o)&&0===o._nodes.size&&(a._selection=null)}catch(t){return t instanceof Error&&e._onError(t),e._pendingEditorState=c,e._dirtyType=2,e._cloneNotNeeded.clear(),e._dirtyLeaves=new Set,e._dirtyElements.clear(),void vi(e)}finally{ri=f,oi=d,ii=h,e._updating=g,li=0}const p=0!==e._dirtyType||e._deferred.length>0||function(t,e){const n=e.getEditorState()._selection,r=t._selection;if(null!==r){if(r.dirty||!r.is(n))return!0}else if(null!==n)return!0;return!1}(a,e);p?a._flushSync?(a._flushSync=!1,vi(e)):u&&lo(()=>{vi(e)}):(a._flushSync=!1,u&&(i.clear(),e._deferred=[],e._pendingEditorState=null))}function bi(t,e,n){ii===t&&void 0===n?e():Ni(t,e,n)}class wi{element;before;after;constructor(t,e,n){this.element=t,this.before=e||null,this.after=n||null}withBefore(t){return new wi(this.element,t,this.after)}withAfter(t){return new wi(this.element,this.before,t)}withElement(t){return this.element===t?this:new wi(t,this.before,this.after)}insertChild(e){const n=this.before||this.getManagedLineBreak();return null!==n&&n.parentElement!==this.element&&t(222),this.element.insertBefore(e,n),this}removeChild(e){return e.parentElement!==this.element&&t(223),this.element.removeChild(e),this}replaceChild(e,n){return n.parentElement!==this.element&&t(224),this.element.replaceChild(e,n),this}getFirstChild(){const t=this.after?this.after.nextSibling:this.element.firstChild;return t===this.before||t===this.getManagedLineBreak()?null:t}getManagedLineBreak(){return this.element.__lexicalLineBreak||null}setManagedLineBreak(t){if(null===t)this.removeManagedLineBreak();else{const e="decorator"===t&&(d||c||l);this.insertManagedLineBreak(e)}}removeManagedLineBreak(){const t=this.getManagedLineBreak();if(t){const e=this.element,n="IMG"===t.nodeName?t.nextSibling:null;n&&e.removeChild(n),e.removeChild(t),e.__lexicalLineBreak=void 0}}insertManagedLineBreak(t){const e=this.getManagedLineBreak();if(e){if(t===("IMG"===e.nodeName))return;this.removeManagedLineBreak()}const n=this.element,r=this.before,i=document.createElement("br");if(n.insertBefore(i,r),t){const t=document.createElement("img");t.setAttribute("data-lexical-linebreak","true"),t.style.cssText="display: inline !important; border: 0px !important; margin: 0px !important;",t.alt="",n.insertBefore(t,i),n.__lexicalLineBreak=t}else n.__lexicalLineBreak=i}getFirstChildOffset(){let t=0;for(let e=this.after;null!==e;e=e.previousSibling)t++;return t}resolveChildIndex(t,e,n,r){if(n===this.element){const e=this.getFirstChildOffset();return[t,Math.min(e+t.getChildrenSize(),Math.max(e,r))]}const i=Ei(e,n);i.push(r);const o=Ei(e,this.element);let s=t.getIndexWithinParent();for(let t=0;tn){s+=1;break}}return[t.getParentOrThrow(),s]}}function Ei(e,n){const r=[];let i=n;for(;i!==e&&null!==i;i=i.parentNode){let t=0;for(let e=i.previousSibling;null!==e;e=e.previousSibling)t++;r.push(t)}return i!==e&&t(225),r.reverse()}class Oi extends zn{__first;__last;__size;__format;__style;__indent;__dir;__textFormat;__textStyle;constructor(t){super(t),this.__first=null,this.__last=null,this.__size=0,this.__format=0,this.__style="",this.__indent=0,this.__dir=null,this.__textFormat=0,this.__textStyle=""}afterCloneFrom(t){super.afterCloneFrom(t),this.__key===t.__key&&(this.__first=t.__first,this.__last=t.__last,this.__size=t.__size),this.__indent=t.__indent,this.__format=t.__format,this.__style=t.__style,this.__dir=t.__dir,this.__textFormat=t.__textFormat,this.__textStyle=t.__textStyle}getFormat(){return this.getLatest().__format}getFormatType(){const t=this.getFormat();return j[t]||""}getStyle(){return this.getLatest().__style}getIndent(){return this.getLatest().__indent}getChildren(){const t=[];let e=this.getFirstChild();for(;null!==e;)t.push(e),e=e.getNextSibling();return t}getChildrenKeys(){const t=[];let e=this.getFirstChild();for(;null!==e;)t.push(e.__key),e=e.getNextSibling();return t}getChildrenSize(){return this.getLatest().__size}isEmpty(){return 0===this.getChildrenSize()}isDirty(){const t=hi()._dirtyElements;return null!==t&&t.has(this.__key)}isLastChild(){const t=this.getLatest(),e=this.getParentOrThrow().getLastChild();return null!==e&&e.is(t)}getAllTextNodes(){const t=[];let e=this.getFirstChild();for(;null!==e;){if(pr(e)&&t.push(e),Mi(e)){const n=e.getAllTextNodes();t.push(...n)}e=e.getNextSibling()}return t}getFirstDescendant(){let t=this.getFirstChild();for(;Mi(t);){const e=t.getFirstChild();if(null===e)break;t=e}return t}getLastDescendant(){let t=this.getLastChild();for(;Mi(t);){const e=t.getLastChild();if(null===e)break;t=e}return t}getDescendantByIndex(t){const e=this.getChildren(),n=e.length;if(t>=n){const t=e[n-1];return Mi(t)&&t.getLastDescendant()||t||null}const r=e[t];return Mi(r)&&r.getFirstDescendant()||r||null}getFirstChild(){const t=this.getLatest().__first;return null===t?null:Eo(t)}getFirstChildOrThrow(){const e=this.getFirstChild();return null===e&&t(45,this.__key),e}getLastChild(){const t=this.getLatest().__last;return null===t?null:Eo(t)}getLastChildOrThrow(){const e=this.getLastChild();return null===e&&t(96,this.__key),e}getChildAtIndex(t){const e=this.getChildrenSize();let n,r;if(t=t;){if(r===t)return n;n=n.getPreviousSibling(),r--}return null}getTextContent(){let t="";const e=this.getChildren(),n=e.length;for(let r=0;rt.remove()),t}append(...t){return this.splice(this.getChildrenSize(),0,t)}setDirection(t){const e=this.getWritable();return e.__dir=t,e}setFormat(t){return this.getWritable().__format=""!==t?W[t]:0,this}setStyle(t){return this.getWritable().__style=t||"",this}setTextFormat(t){const e=this.getWritable();return e.__textFormat=t,e}setTextStyle(t){const e=this.getWritable();return e.__textStyle=t,e}setIndent(t){return this.getWritable().__indent=t,this}splice(e,n,r){Kn(this)&&t(324,this.__key,this.__type);const i=this.getChildrenSize(),o=this.getWritable();e+n<=i||t(226,String(e),String(n),String(i));const s=o.__key,l=[],c=[],a=this.getChildAtIndex(e+n);let u=null,f=i-n+r.length;if(0!==e)if(e===i)u=this.getLastChild();else{const t=this.getChildAtIndex(e);null!==t&&(u=t.getPreviousSibling())}if(n>0){let e=null===u?this.getFirstChild():u.getNextSibling();for(let r=0;r0&&(e.style.paddingInlineStart=40*t+"px");const n=this.getDirection();n&&(e.dir=n)}return{element:e}}exportJSON(){const t={children:[],direction:this.getDirection(),format:this.getFormatType(),indent:this.getIndent(),...super.exportJSON()},e=this.getTextFormat(),n=this.getTextStyle();return 0===e&&""===n||xs(this)||this.getChildren().some(pr)||(0!==e&&(t.textFormat=e),""!==n&&(t.textStyle=n)),t}updateFromJSON(t){return super.updateFromJSON(t).setFormat(t.format).setIndent(t.indent).setDirection(t.direction).setTextFormat(t.textFormat||0).setTextStyle(t.textStyle||"")}insertNewAfter(t,e){return null}canIndent(){return!0}collapseAtStart(t){return!1}excludeFromCopy(t){return!1}canReplaceWith(t){return!0}canInsertAfter(t){return!0}canBeEmpty(){return!0}canInsertTextBefore(){return!0}canInsertTextAfter(){return!0}isInline(){return!1}isShadowRoot(){return!1}canMergeWith(t){return!1}extractWithChild(t,e,n){return!1}canMergeWhenEmpty(){return!1}reconcileObservedMutation(t,e){const n=this.getDOMSlot(t);let r=n.getFirstChild();for(let t=this.getFirstChild();t;t=t.getNextSibling()){const i=e.getElementByKey(t.getKey());null!==i&&(null==r?(n.insertChild(i),r=i):r!==i&&n.replaceChild(i,r),r=r.nextSibling)}}}function Mi(t){return t instanceof Oi}function Ai(t,e,n){let r=t.getNode();for(;r;){const t=r.__key;if(e.has(t)&&!n.has(t))return!0;r=r.getParent()}return!1}class Pi extends zn{decorate(t,e){return null}isIsolated(){return!1}isInline(){return!0}isKeyboardSelectable(){return!0}}function Di(t){return t instanceof Pi}class Fi extends Oi{__cachedText;static getType(){return"root"}static clone(){return new Fi}constructor(){super("root"),this.__cachedText=null}getTopLevelElementOrThrow(){t(51)}getTextContent(){const t=this.__cachedText;return!ai()&&0!==hi()._dirtyType||null===t?super.getTextContent():t}remove(){t(52)}replace(e){t(53)}insertBefore(e){t(54)}insertAfter(e){t(55)}updateDOM(t,e){return!1}splice(e,n,r){for(const e of r)Mi(e)||Di(e)||t(282);return super.splice(e,n,r)}static importJSON(t){return Fo().updateFromJSON(t)}collapseAtStart(){return!0}}function Li(t){return t instanceof Fi}function Ii(t){return new Bi(new Map(t._nodeMap))}function Ri(){return new Bi(new Map([["root",new Fi]]))}function Ki(e){const n=e.exportJSON(),r=e.constructor;if(n.type!==r.getType()&&t(130,r.name),Mi(e)){const i=n.children;Array.isArray(i)||t(59,r.name);const o=e.getChildren();for(let t=0;t({root:Ki(Fo())}))}}class Wi extends Oi{static getType(){return"artificial"}createDOM(t){return document.createElement("div")}}class ji extends Oi{static getType(){return"paragraph"}static clone(t){return new ji(t.__key)}createDOM(t){const e=document.createElement("p"),n=Zo(t.theme,"paragraph");if(void 0!==n){e.classList.add(...n)}return e}updateDOM(t,e,n){return!1}static importDOM(){return{p:t=>({conversion:Ji,priority:0})}}exportDOM(t){const{element:e}=super.exportDOM(t);if(Is(e)){this.isEmpty()&&e.append(document.createElement("br"));const t=this.getFormatType();t&&(e.style.textAlign=t)}return{element:e}}static importJSON(t){return Ui().updateFromJSON(t)}exportJSON(){const t=super.exportJSON();if(void 0===t.textFormat||void 0===t.textStyle){const e=this.getChildren().find(pr);e?(t.textFormat=e.getFormat(),t.textStyle=e.getStyle()):(t.textFormat=this.getTextFormat(),t.textStyle=this.getTextStyle())}return t}insertNewAfter(t,e){const n=Ui();n.setTextFormat(t.format),n.setTextStyle(t.style);const r=this.getDirection();return n.setDirection(r),n.setFormat(this.getFormatType()),n.setStyle(this.getStyle()),this.insertAfter(n,e),n}collapseAtStart(){const t=this.getChildren();if(0===t.length||pr(t[0])&&""===t[0].getTextContent().trim()){if(null!==this.getNextSibling())return this.selectNext(),this.remove(),!0;if(null!==this.getPreviousSibling())return this.selectPrevious(),this.remove(),!0}return!1}}function Ji(t){const e=Ui();return t.style&&(e.setFormat(t.style.textAlign),qs(t,e)),{node:e}}function Ui(){return Ss(new ji)}function $i(t){return t instanceof ji}const Vi=0,Yi=1,qi=2,Hi=3,Gi=4;function Xi(t,e,n,r){const i=t._keyToDOMMap;i.clear(),t._editorState=Ri(),t._pendingEditorState=r,t._compositionKey=null,t._dirtyType=0,t._cloneNotNeeded.clear(),t._dirtyLeaves=new Set,t._dirtyElements.clear(),t._normalizedNodes=new Set,t._updateTags=new Set,t._updates=[],t._blockCursorElement=null;const o=t._observer;null!==o&&(o.disconnect(),t._observer=null),null!==e&&(e.textContent=""),null!==n&&(n.textContent="",i.set("root",n))}function Qi(t){const e=new Set,n=new Set;let r=t;for(;r;){const{ownNodeConfig:t}=Qs(r),i=r.transform;if(!n.has(i)){n.add(i);const t=r.transform();t&&e.add(t)}if(t){const n=t.$transform;n&&e.add(n),r=t.extends}else{const t=Object.getPrototypeOf(r);r=t.prototype instanceof zn&&t!==zn?t:void 0}}return e}function Zi(t){const e=t||{},n=_i(),r=e.theme||{},i=void 0===t?n:e.parentEditor||null,o=e.disableEvents||!1,s=Ri(),l=e.namespace||(null!==i?i._config.namespace:Bo()),c=e.editorState,a=[Fi,sr,Hn,mr,ji,Wi,...e.nodes||[]],{onError:u,html:f}=e,d=void 0===e.editable||e.editable;let h;if(void 0===t&&null!==n)h=n._nodes;else{h=new Map;for(let t=0;t{Object.keys(t).forEach(e=>{let r=n.get(e);void 0===r&&(r=[],n.set(e,r)),r.push(t[e])})};return t.forEach(t=>{const e=t.klass.importDOM;if(null==e||r.has(e))return;r.add(e);const n=e.call(t.klass);null!==n&&i(n)}),e&&i(e),n}(h,f?f.import:void 0),d,t);return void 0!==c&&(g._pendingEditorState=c,g._dirtyType=2),function(t){t.registerCommand(le,vn,Vi),t.registerCommand(ce,kn,Vi),t.registerCommand(ae,Tn,Vi),t.registerCommand(ue,Nn,Vi),t.registerCommand(ve,wn,Vi)}(g),g}class to{static version;_headless;_parentEditor;_rootElement;_editorState;_pendingEditorState;_compositionKey;_deferred;_keyToDOMMap;_updates;_updating;_listeners;_commands;_nodes;_decorators;_pendingDecorators;_config;_dirtyType;_cloneNotNeeded;_dirtyLeaves;_dirtyElements;_normalizedNodes;_updateTags;_observer;_key;_onError;_htmlConversions;_window;_editable;_blockCursorElement;_createEditorArgs;constructor(t,e,n,r,i,o,s,l){this._createEditorArgs=l,this._parentEditor=e,this._rootElement=null,this._editorState=t,this._pendingEditorState=null,this._compositionKey=null,this._deferred=[],this._keyToDOMMap=new Map,this._updates=[],this._updating=!1,this._listeners={decorator:new Set,editable:new Set,mutation:new Map,root:new Set,textcontent:new Set,update:new Set},this._commands=new Map,this._config=r,this._nodes=n,this._decorators={},this._pendingDecorators=null,this._dirtyType=0,this._cloneNotNeeded=new Set,this._dirtyLeaves=new Set,this._dirtyElements=new Map,this._normalizedNodes=new Set,this._updateTags=new Set,this._observer=null,this._key=Bo(),this._onError=i,this._htmlConversions=o,this._editable=s,this._headless=null!==e&&e._headless,this._window=null,this._blockCursorElement=null}isComposing(){return null!=this._compositionKey}registerUpdateListener(t){const e=this._listeners.update;return e.add(t),()=>{e.delete(t)}}registerEditableListener(t){const e=this._listeners.editable;return e.add(t),()=>{e.delete(t)}}registerDecoratorListener(t){const e=this._listeners.decorator;return e.add(t),()=>{e.delete(t)}}registerTextContentListener(t){const e=this._listeners.textcontent;return e.add(t),()=>{e.delete(t)}}registerRootListener(t){const e=this._listeners.root;return t(this._rootElement,null),e.add(t),()=>{t(null,this._rootElement),e.delete(t)}}registerCommand(e,n,r){void 0===r&&t(35);const i=this._commands;i.has(e)||i.set(e,[new Set,new Set,new Set,new Set,new Set]);const o=i.get(e);void 0===o&&t(36,String(e));const s=o[r];return s.add(n),()=>{s.delete(n),o.every(t=>0===t.size)&&i.delete(e)}}registerMutationListener(t,e,n){const r=this.resolveRegisteredNodeAfterReplacements(this.getRegisteredNode(t)).klass,i=this._listeners.mutation;let o=i.get(e);void 0===o&&(o=new Set,i.set(e,o)),o.add(r);const s=n&&n.skipInitialization;return void 0!==s&&s||this.initializeMutationListener(e,r),()=>{o.delete(r),0===o.size&&i.delete(e)}}getRegisteredNode(e){const n=this._nodes.get(e.getType());return void 0===n&&t(37,e.name),n}resolveRegisteredNodeAfterReplacements(t){for(;t.replaceWithKlass;)t=this.getRegisteredNode(t.replaceWithKlass);return t}initializeMutationListener(t,e){const n=this._editorState,r=$s(n).get(e.getType());if(!r)return;const i=new Map;for(const t of r.keys())i.set(t,"created");i.size>0&&t(i,{dirtyLeaves:new Set,prevEditorState:n,updateTags:new Set(["registerMutationListener"])})}registerNodeTransformToKlass(t,e){const n=this.getRegisteredNode(t);return n.transforms.add(e),n}registerNodeTransform(t,e){const n=this.registerNodeTransformToKlass(t,e),r=[n],i=n.replaceWithKlass;if(null!=i){const t=this.registerNodeTransformToKlass(i,e);r.push(t)}return function(t,e){const n=$s(t.getEditorState()),r=[];for(const t of e){const e=n.get(t);e&&r.push(e)}if(0===r.length)return;t.update(()=>{for(const t of r)for(const e of t.keys()){const t=Eo(e);t&&t.markDirty()}},null===t._pendingEditorState?{tag:jn}:void 0)}(this,r.map(t=>t.klass.getType())),()=>{r.forEach(t=>t.transforms.delete(e))}}hasNode(t){return this._nodes.has(t.getType())}hasNodes(t){return t.every(this.hasNode.bind(this))}dispatchCommand(t,e){return os(this,t,e)}getDecorators(){return this._decorators}getRootElement(){return this._rootElement}getKey(){return this._key}setRootElement(t){const e=this._rootElement;if(t!==e){const n=Zo(this._config.theme,"root"),r=this._pendingEditorState||this._editorState;if(this._rootElement=t,Xi(this,e,t,r),null!==e&&(this._config.disableEvents||Fn(e),null!=n&&e.classList.remove(...n)),null!==t){const e=_s(t),r=t.style;r.userSelect="text",r.whiteSpace="pre-wrap",r.wordBreak="break-word",t.setAttribute("data-lexical-editor","true"),this._window=e,this._dirtyType=2,rt(this),this._updateTags.add(jn),vi(this),this._config.disableEvents||function(t,e){const n=Os(t);sn.set(t,n);const r=ln.get(n)??0;r<1&&n.addEventListener("selectionchange",Mn),ln.set(n,r+1),t.__lexicalEditor=e;const i=En(t);for(let n=0;n{Pn(t)||(An(t),(e.isEditable()||"click"===r)&&o(t,e))}:t=>{if(Pn(t))return;An(t);const n=e.isEditable();switch(r){case"cut":return n&&os(e,Ue,t);case"copy":return os(e,Je,t);case"paste":return n&&os(e,_e,t);case"dragstart":return n&&os(e,Be,t);case"dragover":return n&&os(e,We,t);case"dragend":return n&&os(e,je,t);case"focus":return n&&os(e,Ge,t);case"blur":return n&&os(e,Xe,t);case"drop":return n&&os(e,Ke,t)}};t.addEventListener(r,s),i.push(()=>{t.removeEventListener(r,s)})}}(t,this),null!=n&&t.classList.add(...n)}else this._window=null,this._updateTags.add(jn),vi(this);ki("root",this,!1,t,e)}}getElementByKey(t){return this._keyToDOMMap.get(t)||null}getEditorState(){return this._editorState}setEditorState(e,n){e.isEmpty()&&t(38);let r=e;r._readOnly&&(r=Ii(e),r._selection=e._selection?e._selection.clone():null),nt(this);const i=this._pendingEditorState,o=this._updateTags,s=void 0!==n?n.tag:null;null===i||i.isEmpty()||(null!=s&&o.add(s),vi(this)),this._pendingEditorState=r,this._dirtyType=2,this._dirtyElements.set("root",!1),this._compositionKey=null,null!=s&&o.add(s),this._updating||vi(this)}parseEditorState(t,e){return function(t,e,n){const r=Ri(),i=ri,o=oi,s=ii,l=e._dirtyElements,c=e._dirtyLeaves,a=e._cloneNotNeeded,u=e._dirtyType;e._dirtyElements=new Map,e._dirtyLeaves=new Set,e._cloneNotNeeded=new Set,e._dirtyType=0,ri=r,oi=!1,ii=e,no(null);try{const i=e._nodes;Ci(t.root,i),n&&n(),r._readOnly=!0}catch(t){t instanceof Error&&e._onError(t)}finally{e._dirtyElements=l,e._dirtyLeaves=c,e._cloneNotNeeded=a,e._dirtyType=u,ri=i,oi=o,ii=s}return r}("string"==typeof t?JSON.parse(t):t,this,e)}read(t){return vi(this),this.getEditorState().read(t,{editor:this})}update(t,e){!function(t,e,n){t._updating?t._updates.push([e,n]):Ni(t,e,n)}(this,t,e)}focus(t,e={}){const n=this._rootElement;null!==n&&(n.setAttribute("autocapitalize","off"),bi(this,()=>{const r=Ur(),i=Fo();null!==r?r.dirty||Io(r.clone()):0!==i.getChildrenSize()&&("rootStart"===e.defaultSelection?i.selectStart():i.selectEnd()),ds("focus"),hs(()=>{n.removeAttribute("autocapitalize"),t&&t()})}),null===this._pendingEditorState&&n.removeAttribute("autocapitalize"))}blur(){const t=this._rootElement;null!==t&&t.blur();const e=Es(this);null!==e&&e.removeAllRanges()}isEditable(){return this._editable}setEditable(t){this._editable!==t&&(this._editable=t,ki("editable",this,!0,t))}toJSON(){return{editorState:this._editorState.toJSON()}}}to.version="0.38.2+prod.esm";let eo=null;function no(t){eo=t}let ro=1;function io(){ro=1}function oo(e,n){const r=so(e,n);return void 0===r&&t(30,n),r}function so(t,e){return t._nodes.get(e)}const lo="function"==typeof queueMicrotask?queueMicrotask:t=>{Promise.resolve().then(t)};function co(t){return Di(Ao(t))}function ao(t){const e=ho(t),n=e?e.getRootElement():null,r=n?Ps(n):document.activeElement;if(!Is(r))return!1;const i=r.nodeName;return Di(Ao(t))&&("INPUT"===i||"TEXTAREA"===i||"true"===r.contentEditable&&null==go(r))}function uo(t,e,n){const r=t.getRootElement();try{return null!==r&&r.contains(e)&&r.contains(n)&&null!==e&&!ao(e)&&ho(e)===t}catch(t){return!1}}function fo(t){return t instanceof to}function ho(t){let e=t;for(;null!=e;){const t=go(e);if(fo(t))return t;e=as(e)}return null}function go(t){return t?t.__lexicalEditor:null}function _o(t){return R.test(t)?"rtl":K.test(t)?"ltr":null}function po(t){return Cr(t)||t.isToken()}function yo(t){return po(t)||t.isSegmented()}function mo(t){return Rs(t)&&3===t.nodeType}function xo(t){return Rs(t)&&9===t.nodeType}function Co(t){let e=t;for(;null!=e;){if(mo(e))return e;e=e.firstChild}return null}function So(t,e,n){const r=z[e];if(null!==n&&(t&r)===(n&r))return t;let i=t^r;return"subscript"===e?i&=~z.superscript:"superscript"===e?i&=~z.subscript:"lowercase"===e?(i&=~z.uppercase,i&=~z.capitalize):"uppercase"===e?(i&=~z.lowercase,i&=~z.capitalize):"capitalize"===e&&(i&=~z.lowercase,i&=~z.uppercase),i}function vo(t){return pr(t)||Qn(t)||Di(t)}function ko(t,e){const n=function(){const t=eo;return eo=null,t}();if(null!=(e=e||n&&n.__key))return void(t.__key=e);ui(),fi();const r=hi(),i=di(),o=""+ro++;i._nodeMap.set(o,t),Mi(t)?r._dirtyElements.set(o,!0):r._dirtyLeaves.add(o),r._cloneNotNeeded.add(o),r._dirtyType=1,t.__key=o}function To(t){const e=t.getParent();if(null!==e){const n=t.getWritable(),r=e.getWritable(),i=t.getPreviousSibling(),o=t.getNextSibling(),s=null!==o?o.__key:null,l=null!==i?i.__key:null,c=null!==i?i.getWritable():null,a=null!==o?o.getWritable():null;null===i&&(r.__first=s),null===o&&(r.__last=l),null!==c&&(c.__next=s),null!==a&&(a.__prev=l),n.__prev=null,n.__next=null,n.__parent=null,r.__size--}}function No(e){fi(),Kn(e)&&t(323,e.__key,e.__type);const n=e.getLatest(),r=n.__parent,i=di(),o=hi(),s=i._nodeMap,l=o._dirtyElements;null!==r&&function(t,e,n){let r=t;for(;null!==r;){if(n.has(r))return;const t=e.get(r);if(void 0===t)break;n.set(r,!1),r=t.__parent}}(r,s,l);const c=n.__key;o._dirtyType=1,Mi(e)?l.set(c,!0):o._dirtyLeaves.add(c)}function bo(t){ui();const e=hi(),n=e._compositionKey;if(t!==n){if(e._compositionKey=t,null!==n){const t=Eo(n);null!==t&&t.getWritable()}if(null!==t){const e=Eo(t);null!==e&&e.getWritable()}}}function wo(){if(ai())return null;return hi()._compositionKey}function Eo(t,e){const n=(e||di())._nodeMap.get(t);return void 0===n?null:n}function Oo(t,e){const n=Mo(t,hi());return void 0!==n?Eo(n,e):null}function Mo(t,e){return t[`__lexicalKey_${e._key}`]}function Ao(t,e){let n=t;for(;null!=n;){const t=Oo(n,e);if(null!==t)return t;n=as(n)}return null}function Po(t){const e=t._decorators,n=Object.assign({},e);return t._pendingDecorators=n,n}function Do(t){return t.read(()=>Fo().getTextContent())}function Fo(){return Lo(di())}function Lo(t){return t._nodeMap.get("root")}function Io(t){ui();const e=di();null!==t&&(t.dirty=!0,t.setCachedNodes(null)),e._selection=t}function Ro(t){const e=hi(),n=function(t,e){let n=t;for(;null!=n;){const t=Mo(n,e);if(void 0!==t)return t;n=as(n)}return null}(t,e);if(null===n){return t===e.getRootElement()?Eo("root"):null}return Eo(n)}function Ko(t){return/[\uD800-\uDBFF][\uDC00-\uDFFF]/g.test(t)}function zo(t){const e=[];let n=t;for(;null!==n;)e.push(n),n=n._parentEditor;return e}function Bo(){return Math.random().toString(36).replace(/[^a-z]+/g,"").substring(0,5)}function Wo(t){return mo(t)?t.nodeValue:null}function jo(t,e,n){const r=Es(e);if(null===r)return;const i=r.anchorNode;let{anchorOffset:o,focusOffset:s}=r;if(null!==i){let e=Wo(i);const r=Ao(i);if(null!==e&&pr(r)){if(e===P&&n){const t=n.length;e=n,o=t,s=t}null!==e&&Jo(r,e,o,s,t)}}}function Jo(t,e,n,r,i){let o=t;if(o.isAttached()&&(i||!o.isDirty())){const s=o.isComposing();let a=e;(s||i)&&e[e.length-1]===P&&(a=e.slice(0,-1));const u=o.getTextContent();if(i||a!==u){if(""===a){if(bo(null),l||c||d)o.remove();else{const t=hi();setTimeout(()=>{t.update(()=>{o.isAttached()&&o.remove()})},20)}return}const e=o.getParent(),i=$r(),u=o.getTextContentSize(),f=wo(),h=o.getKey();if(o.isToken()||null!==f&&h===f&&!s||br(i)&&(null!==e&&!e.canInsertTextBefore()&&0===i.anchor.offset||i.anchor.key===t.__key&&0===i.anchor.offset&&!o.canInsertTextBefore()&&!s||i.focus.key===t.__key&&i.focus.offset===u&&!o.canInsertTextAfter()&&!s))return void o.markDirty();const g=Ur();if(!br(g)||null===n||null===r)return void Uo(o,a,g);if(g.setTextNodeRange(o,n,o,r),o.isSegmented()){const t=_r(o.getTextContent());o.replace(t),o=t}Uo(o,a,g)}}}function Uo(t,e,n){if(t.setTextContent(e),br(n)){const e=t.getKey();for(const r of["anchor","focus"]){const i=n[r];"text"===i.type&&i.key===e&&(i.offset=ml(t,i.offset,"clamp"))}}}function $o(t,e,n){const r=e[n]||!1;return"any"===r||r===t[n]}function Vo(t,e){return $o(t,e,"altKey")&&$o(t,e,"ctrlKey")&&$o(t,e,"shiftKey")&&$o(t,e,"metaKey")}function Yo(t,e,n){return Vo(t,n)&&t.key.toLowerCase()===e.toLowerCase()}const qo={ctrlKey:!i,metaKey:i},Ho={altKey:i,ctrlKey:!i};function Go(t){return"Backspace"===t.key}function Xo(t){return Yo(t,"a",qo)}function Qo(t){const e=Fo();if(br(t)){const e=t.anchor,n=t.focus,r=e.getNode().getTopLevelElementOrThrow().getParentOrThrow();return e.set(r.getKey(),0,"element"),n.set(r.getKey(),r.getChildrenSize(),"element"),St(t),t}{const t=e.select(0,e.getChildrenSize());return Io(St(t)),t}}function Zo(t,e){void 0===t.__lexicalClassNameCache&&(t.__lexicalClassNameCache={});const n=t.__lexicalClassNameCache,r=n[e];if(void 0!==r)return r;const i=t[e];if("string"==typeof i){const t=h(i);return n[e]=t,t}return i}function ts(e,n,r,i,o){if(0===r.size)return;const s=i.__type,l=i.__key,c=n.get(s);void 0===c&&t(33,s);const a=c.klass;let u=e.get(a);void 0===u&&(u=new Map,e.set(a,u));const f=u.get(l),d="destroyed"===f&&"created"===o;(void 0===f||d)&&u.set(l,d?"updated":o)}function es(t){const e=t.getType(),n=di();if(n._readOnly){const t=$s(n).get(e);return t?Array.from(t.values()):[]}const r=n._nodeMap,i=[];for(const[,n]of r)n instanceof t&&n.__type===e&&n.isAttached()&&i.push(n);return i}function ns(t,e,n){const r=t.getParent();let i=n,o=t;return null!==r&&(e&&0===n?(i=o.getIndexWithinParent(),o=r):e||n!==o.getChildrenSize()||(i=o.getIndexWithinParent()+1,o=r)),o.getChildAtIndex(e?i-1:i)}function rs(t,e){const n=t.offset;if("element"===t.type){return ns(t.getNode(),e,n)}{const r=t.getNode();if(e&&0===n||!e&&n===r.getTextContentSize()){const t=e?r.getPreviousSibling():r.getNextSibling();return null===t?ns(r.getParentOrThrow(),e,r.getIndexWithinParent()+(e?0:1)):t}}return null}function is(t){const e=ps(t).event,n=e&&e.inputType;return"insertFromPaste"===n||"insertFromPasteAsQuotation"===n}function os(t,e,n){return function(t,e,n){const r=zo(t);for(let i=4;i>=0;i--)for(let o=0;o{for(let e=0;e0)return function(t,e){if(0===e.length)return t;const n=e[0],r=Object.create(Selection.prototype),i=Object.getOwnPropertyDescriptors(Selection.prototype);Object.keys(i).forEach(e=>{if("constructor"===e)return;const n=i[e];if(n.value&&"function"==typeof n.value){const n=t[e];"function"==typeof n&&(r[e]=n.bind(t))}else if(!n.get){const n=t[e];void 0!==n&&(r[e]=n)}}),Object.defineProperty(r,"anchorNode",{enumerable:!0,get:()=>n.startContainer}),Object.defineProperty(r,"anchorOffset",{enumerable:!0,get:()=>n.startOffset}),Object.defineProperty(r,"focusNode",{enumerable:!0,get:()=>n.endContainer}),Object.defineProperty(r,"focusOffset",{enumerable:!0,get:()=>n.endOffset}),Object.defineProperty(r,"isCollapsed",{enumerable:!0,get:()=>n.collapsed}),Object.defineProperty(r,"rangeCount",{enumerable:!0,get:()=>e.length}),Object.defineProperty(r,"type",{enumerable:!0,get:()=>{const t=e[0];return t?t.collapsed?"Caret":"Range":"None"}}),r.getRangeAt=function(t){if(t<0||t>=e.length)throw new DOMException("Index out of range","IndexSizeError");const n=e[t],r=document.createRange();return r.setStart(n.startContainer,n.startOffset),r.setEnd(n.endContainer,n.endOffset),r},"getComposedRanges"in t&&(r.getComposedRanges=function(){return e});return r}(e,n)}return e}function ws(t,e){if(!n)return null;if(e){const t=Os(e);if(t&&cs(t))return bs(t)}return(t||window).getSelection()}function Es(t){return ws(ps(t),t.getRootElement())}function Os(t){const e=t.getRootNode({composed:!1});return cs(e)?e:document}function Ms(t){const e=t.getRootElement();return!!e&&cs(Os(e))}function As(t){if(!t||!n)return document;const e=t.getRootNode({composed:!0});return e===t||e.nodeType!==Node.DOCUMENT_NODE?t.ownerDocument||document:e}function Ps(t){const e=Os(t);return e&&cs(e)&&e.activeElement?e.activeElement:As(t).activeElement}function Ds(t){if(!t)return null;if(Is(t)){const e=Os(t);if(e&&cs(e))return bs(e)}const e=_s(t);return e?e.getSelection():null}function Fs(e,n){let r=e.getChildAtIndex(n);null==r&&(r=e),xs(e)&&t(102);const i=e=>{const n=e.getParentOrThrow(),o=xs(n),s=e!==r||o?Cs(e):e;if(o)return Mi(e)&&Mi(s)||t(133),e.insertAfter(s),[e,s,s];{const[t,r,o]=i(n),l=e.getNextSiblings();return o.append(s,...l),[t,r,s]}},[o,s]=i(r);return[o,s]}function Ls(t){return Is(t)&&"A"===t.tagName}function Is(t){return Rs(t)&&1===t.nodeType}function Rs(t){return"object"==typeof t&&null!==t&&"nodeType"in t&&"number"==typeof t.nodeType}function Ks(t){return Rs(t)&&11===t.nodeType}function zs(t){const e=new RegExp(/^(a|abbr|acronym|b|cite|code|del|em|i|ins|kbd|label|mark|output|q|ruby|s|samp|span|strong|sub|sup|time|u|tt|var|#text)$/,"i");return null!==t.nodeName.match(e)}function Bs(t){const e=new RegExp(/^(address|article|aside|blockquote|canvas|dd|div|dl|dt|fieldset|figcaption|figure|footer|form|h1|h2|h3|h4|h5|h6|header|hr|li|main|nav|noscript|ol|p|pre|section|table|td|tfoot|ul|video)$/,"i");return null!==t.nodeName.match(e)}function Ws(t){if(Di(t)&&!t.isInline())return!0;if(!Mi(t)||xs(t))return!1;const e=t.getFirstChild(),n=null===e||Qn(e)||pr(e)||e.isInline();return!t.isInline()&&!1!==t.canBeEmpty()&&n}function js(){return hi()}const Js=new WeakMap,Us=new Map;function $s(e){if(!e._readOnly&&e.isEmpty())return Us;e._readOnly||t(192);let n=Js.get(e);return n||(n=function(t){const e=new Map;for(const[n,r]of t._nodeMap){const t=r.__type;let i=e.get(t);i||(i=new Map,e.set(t,i)),i.set(n,r)}return e}(e),Js.set(e,n)),n}function Vs(t){const e=t.constructor.clone(t);return e.afterCloneFrom(t),e}function Ys(t){return(e=Vs(t))[Rn]=!0,e;var e}function qs(t,e){const n=parseInt(t.style.paddingInlineStart,10)||0,r=Math.round(n/40);e.setIndent(r)}function Hs(t){t.__lexicalUnmanaged=!0}function Gs(t){return!0===t.__lexicalUnmanaged}function Xs(t,e){return function(t,e){return Object.prototype.hasOwnProperty.call(t,e)}(t,e)&&t[e]!==zn[e]}function Qs(e){const n=V in e.prototype?e.prototype[V]():void 0,r=function(e){if(!(e===zn||e.prototype instanceof zn)){let n="",r="";try{n=e.getType()}catch(t){}try{to.version&&(r=JSON.parse(to.version))}catch(t){}t(290,e.name,n,r)}return e===Pi||e===Oi||e===zn}(e),i=!r&&Xs(e,"getType")?e.getType():void 0;let o,s=i;if(n)if(i)o=n[i];else for(const[t,e]of Object.entries(n))s=t,o=e;if(!r&&s&&(Xs(e,"getType")||(e.getType=()=>s),Xs(e,"clone")||(e.clone=t=>(no(t),new e)),Xs(e,"importJSON")||(e.importJSON=o&&o.$importJSON||(t=>(new e).updateFromJSON(t))),!Xs(e,"importDOM")&&o)){const{importDOM:t}=o;t&&(e.importDOM=()=>t)}return{ownNodeConfig:o,ownNodeType:s}}function Zs(t){const e=js();ui();return new(e.resolveRegisteredNodeAfterReplacements(e.getRegisteredNode(t)).klass)}const tl=(t,e)=>{let n=t;for(;null!=n&&!Li(n);){if(e(n))return n;n=n.getParent()}return null},el={next:"previous",previous:"next"};class nl{origin;constructor(t){this.origin=t}[Symbol.iterator](){return Ol({hasNext:fl,initial:this.getAdjacentCaret(),map:t=>t,step:t=>t.getAdjacentCaret()})}getAdjacentCaret(){return pl(this.getNodeAtCaret(),this.direction)}getSiblingCaret(){return pl(this.origin,this.direction)}remove(){const t=this.getNodeAtCaret();return t&&t.remove(),this}replaceOrInsert(t,e){const n=this.getNodeAtCaret();return t.is(this.origin)||t.is(n)||(null===n?this.insert(t):n.replace(t,e)),this}splice(e,n,r="next"){const i=r===this.direction?n:Array.from(n).reverse();let o=this;const s=this.getParentAtCaret(),l=new Map;for(let t=o.getAdjacentCaret();null!==t&&l.size0){const n=o.getNodeAtCaret();if(n)if(l.delete(n.getKey()),l.delete(e.getKey()),n.is(e)||o.origin.is(e));else{const t=e.getParent();t&&t.is(s)&&e.remove(),n.replace(e)}else null===n&&t(263,Array.from(l).join(" "))}else o.insert(e);o=pl(e,this.direction)}for(const t of l.values())t.remove();return this}}class rl extends nl{type="child";getLatest(){const t=this.origin.getLatest();return t===this.origin?this:Cl(t,this.direction)}getParentCaret(t="root"){return pl(sl(this.getParentAtCaret(),t),this.direction)}getFlipped(){const t=ol(this.direction);return pl(this.getNodeAtCaret(),t)||Cl(this.origin,t)}getParentAtCaret(){return this.origin}getChildCaret(){return this}isSameNodeCaret(t){return t instanceof rl&&this.direction===t.direction&&this.origin.is(t.origin)}isSamePointCaret(t){return this.isSameNodeCaret(t)}}const il={root:Li,shadowRoot:xs};function ol(t){return el[t]}function sl(t,e="root"){return il[e](t)?null:t}class ll extends nl{type="sibling";getLatest(){const t=this.origin.getLatest();return t===this.origin?this:pl(t,this.direction)}getSiblingCaret(){return this}getParentAtCaret(){return this.origin.getParent()}getChildCaret(){return Mi(this.origin)?Cl(this.origin,this.direction):null}getParentCaret(t="root"){return pl(sl(this.getParentAtCaret(),t),this.direction)}getFlipped(){const t=ol(this.direction);return pl(this.getNodeAtCaret(),t)||Cl(this.origin.getParentOrThrow(),t)}isSamePointCaret(t){return t instanceof ll&&this.direction===t.direction&&this.origin.is(t.origin)}isSameNodeCaret(t){return(t instanceof ll||t instanceof cl)&&this.direction===t.direction&&this.origin.is(t.origin)}}class cl extends nl{type="text";offset;constructor(t,e){super(t),this.offset=e}getLatest(){const t=this.origin.getLatest();return t===this.origin?this:yl(t,this.direction,this.offset)}getParentAtCaret(){return this.origin.getParent()}getChildCaret(){return null}getParentCaret(t="root"){return pl(sl(this.getParentAtCaret(),t),this.direction)}getFlipped(){return yl(this.origin,ol(this.direction),this.offset)}isSamePointCaret(t){return t instanceof cl&&this.direction===t.direction&&this.origin.is(t.origin)&&this.offset===t.offset}isSameNodeCaret(t){return(t instanceof ll||t instanceof cl)&&this.direction===t.direction&&this.origin.is(t.origin)}getSiblingCaret(){return pl(this.origin,this.direction)}}function al(t){return t instanceof cl}function ul(t){return t instanceof nl}function fl(t){return t instanceof ll}function dl(t){return t instanceof rl}const hl={next:class extends cl{direction="next";getNodeAtCaret(){return this.origin.getNextSibling()}insert(t){return this.origin.insertAfter(t),this}},previous:class extends cl{direction="previous";getNodeAtCaret(){return this.origin.getPreviousSibling()}insert(t){return this.origin.insertBefore(t),this}}},gl={next:class extends ll{direction="next";getNodeAtCaret(){return this.origin.getNextSibling()}insert(t){return this.origin.insertAfter(t),this}},previous:class extends ll{direction="previous";getNodeAtCaret(){return this.origin.getPreviousSibling()}insert(t){return this.origin.insertBefore(t),this}}},_l={next:class extends rl{direction="next";getNodeAtCaret(){return this.origin.getFirstChild()}insert(t){return this.origin.splice(0,0,[t]),this}},previous:class extends rl{direction="previous";getNodeAtCaret(){return this.origin.getLastChild()}insert(t){return this.origin.splice(this.origin.getChildrenSize(),0,[t]),this}}};function pl(t,e){return t?new gl[e](t):null}function yl(t,e,n){return t?new hl[e](t,ml(t,n)):null}function ml(t,n,r="error"){const i=t.getTextContentSize();let o="next"===n?i:"previous"===n?0:n;return(o<0||o>i)&&("clamp"!==r&&e(284,String(n),String(i),t.getKey()),o=o<0?0:i),o}function xl(t,e){return new Tl(t,e)}function Cl(t,e){return Mi(t)?new _l[e](t):null}function Sl(t){return t&&t.getChildCaret()||t}function vl(t){return t&&Sl(t.getAdjacentCaret())}class kl{type="node-caret-range";direction;anchor;focus;constructor(t,e,n){this.anchor=t,this.focus=e,this.direction=n}getLatest(){const t=this.anchor.getLatest(),e=this.focus.getLatest();return t===this.anchor&&e===this.focus?this:new kl(t,e,this.direction)}isCollapsed(){return this.anchor.isSamePointCaret(this.focus)}getTextSlices(){const t=t=>{const e=this[t].getLatest();return al(e)?function(t,e){const{direction:n,origin:r}=t,i=ml(r,"focus"===e?ol(n):n);return xl(t,i-t.offset)}(e,t):null},e=t("anchor"),n=t("focus");if(e&&n){const{caret:t}=e,{caret:r}=n;if(t.isSameNodeCaret(r))return[xl(t,r.offset-t.offset),null]}return[e,n]}iterNodeCarets(t="root"){const e=al(this.anchor)?this.anchor.getSiblingCaret():this.anchor.getLatest(),n=this.focus.getLatest(),r=al(n),i=e=>e.isSameNodeCaret(n)?null:vl(e)||e.getParentCaret(t);return Ol({hasNext:t=>null!==t&&!(r&&n.isSameNodeCaret(t)),initial:e.isSameNodeCaret(n)?null:i(e),map:t=>t,step:i})}[Symbol.iterator](){return this.iterNodeCarets("root")}}class Tl{type="slice";caret;distance;constructor(t,e){this.caret=t,this.distance=e}getSliceIndices(){const{distance:t,caret:{offset:e}}=this,n=e+t;return n{let n;for(let r=c;rn.has(t.getKey())&&Ws(t));return u&&f?[u,f]:null}(f,d,a);if(h){const[t,e]=h;Cl(t,"previous").splice(0,e.getChildren()),e.remove()}const g=[f,d,...l,...c].find(jl);if(g){return wl(Vl(Ul(g),e.direction))}t(269,JSON.stringify(l.map(t=>t.origin.__key)))}function Ul(t){const e=function(t){let e=t;for(;dl(e);){const t=vl(e);if(!dl(t))break;e=t}return e}(t.getLatest()),{direction:n}=e;if(pr(e.origin))return al(e)?e:yl(e.origin,n,n);const r=e.getAdjacentCaret();return fl(r)&&pr(r.origin)?yl(r.origin,n,ol(n)):e}function $l(t){return al(t)&&t.offset!==ml(t.origin,t.direction)}function Vl(t,e){return t.direction===e?t:t.getFlipped()}function Yl(t,e){return t.direction===e?t:El(Vl(t.focus,e),Vl(t.anchor,e))}function ql(t,e,n){let r=Cl(t,"next");for(let t=0;t0||n.canBeEmpty()&&i(n,"last"))&&o.insert(e(n).splice(0,0,r))}return o}function Zl(t){return t}function tc(...t){return t}function ec(t,e){return[t,e]}function nc(t){return t}function rc(t,e){if(!e||t===e)return t;for(const n in e)if(t[n]!==e[n])return{...t,...e};return t}export{ds as $addUpdateTag,Ss as $applyNodeReplacement,Ll as $caretFromPoint,zl as $caretRangeFromSelection,Vs as $cloneWithProperties,Ys as $cloneWithPropertiesEphemeral,Ml as $comparePointCaretNext,Cs as $copyNode,Zs as $create,Xn as $createLineBreakNode,Wr as $createNodeSelection,Ui as $createParagraphNode,vr as $createPoint,Br as $createRangeSelection,jr as $createRangeSelectionFromDom,xr as $createTabNode,_r as $createTextNode,bl as $extendCaretToRange,tl as $findMatchingParent,vl as $getAdjacentChildCaret,rs as $getAdjacentNode,Hl as $getAdjacentSiblingOrParentSiblingCaret,Vl as $getCaretInDirection,El as $getCaretRange,Yl as $getCaretRangeInDirection,Mr as $getCharacterOffsets,Cl as $getChildCaret,ql as $getChildCaretAtIndex,Sl as $getChildCaretOrSelf,wl as $getCollapsedCaretRange,Fl as $getCommonAncestor,Al as $getCommonAncestorResultBranchOrder,js as $getEditor,Ao as $getNearestNodeFromDOMNode,ms as $getNearestRootOrShadowRoot,Eo as $getNodeByKey,ks as $getNodeByKeyOrThrow,Oo as $getNodeFromDOMNode,$r as $getPreviousSelection,Fo as $getRoot,Ur as $getSelection,pl as $getSiblingCaret,st as $getState,lt as $getStateChange,Zr as $getTextContent,ml as $getTextNodeOffset,yl as $getTextPointCaret,xl as $getTextPointCaretSlice,ft as $getWritableNodeState,gs as $hasAncestor,fs as $hasUpdateTag,Qr as $insertNodes,Kr as $isBlockElementNode,dl as $isChildCaret,Di as $isDecoratorNode,zi as $isEditorState,Mi as $isElementNode,$l as $isExtendableTextPointCaret,Ms as $isInShadowDOMContext,ys as $isInlineElementOrDecoratorNode,vo as $isLeafNode,Qn as $isLineBreakNode,ul as $isNodeCaret,Er as $isNodeSelection,$i as $isParagraphNode,br as $isRangeSelection,Li as $isRootNode,xs as $isRootOrShadowRoot,fl as $isSiblingCaret,Cr as $isTabNode,pr as $isTextNode,al as $isTextPointCaret,Nl as $isTextPointCaretSlice,yo as $isTokenOrSegmented,po as $isTokenOrTab,es as $nodesOfType,Ul as $normalizeCaret,St as $normalizeSelection__EXPERIMENTAL,hs as $onUpdate,xi as $parseSerializedNode,Jl as $removeTextFromCaretRange,Bl as $rewindSiblingCaret,Qo as $selectAll,bo as $setCompositionKey,Il as $setPointFromCaret,Io as $setSelection,Rl as $setSelectionFromCaretRange,ct as $setState,Ql as $splitAtPointCaretNext,Fs as $splitNode,Kl as $updateRangeSelectionFromCaretRange,Wi as ArtificialNode__DO_NOT_USE,le as BEFORE_INPUT_COMMAND,Xe as BLUR_COMMAND,qe as CAN_REDO_COMMAND,He as CAN_UNDO_COMMAND,Ve as CLEAR_EDITOR_COMMAND,Ye as CLEAR_HISTORY_COMMAND,se as CLICK_COMMAND,Un as COLLABORATION_TAG,Gi as COMMAND_PRIORITY_CRITICAL,Vi as COMMAND_PRIORITY_EDITOR,Hi as COMMAND_PRIORITY_HIGH,Yi as COMMAND_PRIORITY_LOW,qi as COMMAND_PRIORITY_NORMAL,ue as COMPOSITION_END_COMMAND,ae as COMPOSITION_START_COMMAND,ge as CONTROLLED_TEXT_INSERTION_COMMAND,Je as COPY_COMMAND,Ue as CUT_COMMAND,fe as DELETE_CHARACTER_COMMAND,me as DELETE_LINE_COMMAND,ye as DELETE_WORD_COMMAND,je as DRAGEND_COMMAND,We as DRAGOVER_COMMAND,Be as DRAGSTART_COMMAND,Ke as DROP_COMMAND,Pi as DecoratorNode,Oi as ElementNode,Ge as FOCUS_COMMAND,ze as FORMAT_ELEMENT_COMMAND,xe as FORMAT_TEXT_COMMAND,Bn as HISTORIC_TAG,jn as HISTORY_MERGE_TAG,Wn as HISTORY_PUSH_TAG,Ie as INDENT_CONTENT_COMMAND,ce as INPUT_COMMAND,de as INSERT_LINE_BREAK_COMMAND,he as INSERT_PARAGRAPH_COMMAND,Le as INSERT_TAB_COMMAND,Ws as INTERNAL_$isBlock,N as IS_ALL_FORMATTING,y as IS_BOLD,S as IS_CODE,T as IS_HIGHLIGHT,m as IS_ITALIC,x as IS_STRIKETHROUGH,v as IS_SUBSCRIPT,k as IS_SUPERSCRIPT,C as IS_UNDERLINE,Ee as KEY_ARROW_DOWN_COMMAND,Ne as KEY_ARROW_LEFT_COMMAND,ke as KEY_ARROW_RIGHT_COMMAND,we as KEY_ARROW_UP_COMMAND,Ae as KEY_BACKSPACE_COMMAND,De as KEY_DELETE_COMMAND,ve as KEY_DOWN_COMMAND,Oe as KEY_ENTER_COMMAND,Pe as KEY_ESCAPE_COMMAND,Qe as KEY_MODIFIER_COMMAND,Me as KEY_SPACE_COMMAND,Fe as KEY_TAB_COMMAND,Hn as LineBreakNode,Te as MOVE_TO_END,be as MOVE_TO_START,$ as NODE_STATE_KEY,Re as OUTDENT_CONTENT_COMMAND,_e as PASTE_COMMAND,Jn as PASTE_TAG,ji as ParagraphNode,Se as REDO_COMMAND,pe as REMOVE_TEXT_COMMAND,Fi as RootNode,ie as SELECTION_CHANGE_COMMAND,oe as SELECTION_INSERT_CLIPBOARD_NODES_COMMAND,$e as SELECT_ALL_COMMAND,$n as SKIP_COLLAB_TAG,Yn as SKIP_DOM_SELECTION_TAG,Vn as SKIP_SCROLL_INTO_VIEW_TAG,qn as SKIP_SELECTION_FOCUS_TAG,z as TEXT_TYPE_TO_FORMAT,mr as TabNode,sr as TextNode,Ce as UNDO_COMMAND,In as buildImportMap,tc as configExtension,re as createCommand,Zi as createEditor,at as createSharedNodeState,ot as createState,ec as declarePeerDependency,Zl as defineExtension,ol as flipDirection,us as getDOMOwnerDocument,ws as getDOMSelection,Es as getDOMSelectionForEditor,bs as getDOMSelectionFromShadowRoot,Ds as getDOMSelectionFromTarget,Co as getDOMTextNode,As as getDocumentFromElement,go as getEditorPropertyFromDOMNode,ho as getNearestEditorFromDOMNode,so as getRegisteredNode,oo as getRegisteredNodeOrThrow,Os as getShadowRootOrDocument,Qs as getStaticNodeConfig,_o as getTextDirection,Qi as getTransformSetFromKlass,ps as getWindow,Bs as isBlockDomNode,ai as isCurrentlyReadOnlyMode,xo as isDOMDocumentNode,Rs as isDOMNode,mo as isDOMTextNode,Gs as isDOMUnmanaged,Ks as isDocumentFragment,Yo as isExactShortcutMatch,Ls as isHTMLAnchorElement,Is as isHTMLElement,zs as isInlineDomNode,fo as isLexicalEditor,Vo as isModifierMatch,ao as isSelectionCapturedInDecoratorInput,uo as isSelectionWithinEditor,cs as isShadowRoot,Ol as makeStepwiseIterator,To as removeFromParent,io as resetRandomKey,nc as safeCast,Hs as setDOMUnmanaged,qs as setNodeIndentFromDOM,rc as shallowMergeConfig}; +diff --git a/node_modules/lexical/LexicalCommands.d.ts b/node_modules/lexical/LexicalCommands.d.ts +index 43f6a74..5482aae 100644 +--- a/node_modules/lexical/LexicalCommands.d.ts ++++ b/node_modules/lexical/LexicalCommands.d.ts +@@ -28,6 +28,10 @@ export declare const SELECTION_INSERT_CLIPBOARD_NODES_COMMAND: LexicalCommand<{ + selection: BaseSelection; + }>; + export declare const CLICK_COMMAND: LexicalCommand; ++export declare const BEFORE_INPUT_COMMAND: LexicalCommand; ++export declare const INPUT_COMMAND: LexicalCommand; ++export declare const COMPOSITION_START_COMMAND: LexicalCommand; ++export declare const COMPOSITION_END_COMMAND: LexicalCommand; + /** + * Dispatched to delete a character, the payload will be `true` if the deletion + * is backwards (backspace or delete on macOS) and `false` if forwards +diff --git a/node_modules/lexical/LexicalEvents.d.ts b/node_modules/lexical/LexicalEvents.d.ts +index b49c07d..efe267a 100644 +--- a/node_modules/lexical/LexicalEvents.d.ts ++++ b/node_modules/lexical/LexicalEvents.d.ts +@@ -7,6 +7,7 @@ + */ + import type { LexicalEditor } from './LexicalEditor'; + import type { NodeKey } from './LexicalNode'; ++export declare function registerDefaultCommandHandlers(editor: LexicalEditor): void; + export type EventHandler = (event: Event, editor: LexicalEditor) => void; + export declare function addRootElementEvents(rootElement: HTMLElement, editor: LexicalEditor): void; + export declare function removeRootElementEvents(rootElement: HTMLElement): void; +diff --git a/node_modules/lexical/LexicalSelection.d.ts b/node_modules/lexical/LexicalSelection.d.ts +index 9936b6d..b6cdc88 100644 +--- a/node_modules/lexical/LexicalSelection.d.ts ++++ b/node_modules/lexical/LexicalSelection.d.ts +@@ -246,11 +246,12 @@ export declare class RangeSelection implements BaseSelection { + modify(alter: 'move' | 'extend', isBackward: boolean, granularity: 'character' | 'word' | 'lineboundary'): void; + /** + * Helper for handling forward character and word deletion that prevents element nodes +- * like a table, columns layout being destroyed ++ * like a table, columns layout being destroyed. Also prevents deletion into shadow roots. + * + * @param anchor the anchor + * @param anchorNode the anchor node in the selection + * @param isBackward whether or not selection is backwards ++ * @returns true if deletion should be prevented + */ + forwardDeletion(anchor: PointType, anchorNode: TextNode | ElementNode, isBackward: boolean): boolean; + /** +@@ -267,6 +268,26 @@ export declare class RangeSelection implements BaseSelection { + * @param isBackward whether or not the selection is backwards. + */ + deleteLine(isBackward: boolean): void; ++ /** ++ * Helper function to determine if a character is a word boundary (whitespace). ++ * @param char the character to check ++ * @returns true if the character is a word boundary ++ */ ++ private isWordBoundary; ++ /** ++ * Find the start of a word going backward from the given offset in text. ++ * @param text the text to search in ++ * @param offset the starting offset ++ * @returns the offset of the word start ++ */ ++ private findWordStart; ++ /** ++ * Find the end of a word going forward from the given offset in text. ++ * @param text the text to search in ++ * @param offset the starting offset ++ * @returns the offset of the word end ++ */ ++ private findWordEnd; + /** + * Performs one logical word deletion operation on the EditorState based on the current Selection. + * Handles different node types. +diff --git a/node_modules/lexical/LexicalUtils.d.ts b/node_modules/lexical/LexicalUtils.d.ts +index dc33bcb..cf1379c 100644 +--- a/node_modules/lexical/LexicalUtils.d.ts ++++ b/node_modules/lexical/LexicalUtils.d.ts +@@ -174,6 +174,17 @@ export declare function isFirefoxClipboardEvents(editor: LexicalEditor): boolean + export declare function dispatchCommand>(editor: LexicalEditor, command: TCommand, payload: CommandPayloadType): boolean; + export declare function $textContentRequiresDoubleLinebreakAtEnd(node: ElementNode): boolean; + export declare function getElementByKeyOrThrow(editor: LexicalEditor, key: NodeKey): HTMLElement; ++/** ++ * Type guard function that checks if a node is a ShadowRoot. This function performs ++ * runtime validation to safely narrow types and enable type-safe Shadow DOM operations. ++ * It checks both the nodeType and the presence of the 'host' property to distinguish ++ * ShadowRoot from regular DocumentFragment nodes. ++ * ++ * @param node - The Node to check (can be null) ++ * @returns True if the node is a ShadowRoot, false otherwise. When true, TypeScript ++ * will narrow the type to ShadowRoot for subsequent operations. ++ */ ++export declare function isShadowRoot(node: Node | null): node is ShadowRoot; + export declare function getParentElement(node: Node): HTMLElement | null; + export declare function getDOMOwnerDocument(target: EventTarget | null): Document | null; + export declare function scrollIntoViewIfNeeded(editor: LexicalEditor, selectionRect: DOMRect, rootElement: HTMLElement): void; +@@ -216,18 +227,126 @@ export declare function $getNodeByKeyOrThrow(key: NodeKey + export declare function removeDOMBlockCursorElement(blockCursorElement: HTMLElement, editor: LexicalEditor, rootElement: HTMLElement): void; + export declare function updateDOMBlockCursorElement(editor: LexicalEditor, rootElement: HTMLElement, nextSelection: null | BaseSelection): void; + /** +- * Returns the selection for the given window, or the global window if null. +- * Will return null if {@link CAN_USE_DOM} is false. ++ * Returns a Selection object from a ShadowRoot using the best available API. ++ * ++ * This function attempts to get selection from Shadow DOM contexts using modern ++ * getComposedRanges API when available. If the API is not supported or returns ++ * empty ranges, it falls back to the global window selection. ++ * ++ * **Selection Proxy:** ++ * When getComposedRanges returns valid ranges, this function creates a Selection proxy ++ * that properly handles text selection across Shadow DOM boundaries. The proxy ++ * provides all standard Selection methods while ensuring correct behavior with ++ * composed ranges. + * +- * @param targetWindow The window to get the selection from +- * @returns a Selection or null ++ * **Browser Support:** ++ * - Modern browsers with getComposedRanges: Full Shadow DOM selection support ++ * - Older browsers: Falls back to window.getSelection() ++ * ++ * @param shadowRoot - The ShadowRoot to get selection from ++ * @returns A Selection object (either a proxy with composed ranges or the global selection), ++ * or null if no selection is available + */ +-export declare function getDOMSelection(targetWindow: null | Window): null | Selection; ++export declare function getDOMSelectionFromShadowRoot(shadowRoot: ShadowRoot): null | Selection; + /** +- * Returns the selection for the defaultView of the ownerDocument of given EventTarget. ++ * Returns the selection for the given window, with Shadow DOM support. ++ * ++ * This function provides a unified API for getting selections in both regular DOM ++ * and Shadow DOM contexts. When a rootElement is provided, it checks if the element ++ * is within a Shadow DOM and uses the appropriate selection API. ++ * ++ * **Behavior:** ++ * - If CAN_USE_DOM is false: Returns null ++ * - If rootElement is in Shadow DOM: Uses getDOMSelectionFromShadowRoot ++ * - Otherwise: Returns window.getSelection() from the target or global window ++ * ++ * @param targetWindow - The window to get the selection from (defaults to global window if null) ++ * @param rootElement - Optional root element to check for Shadow DOM context ++ * @returns A Selection object appropriate for the context, or null if selection is unavailable ++ */ ++export declare function getDOMSelection(targetWindow: null | Window, rootElement?: HTMLElement | null): null | Selection; ++/** ++ * Creates a Selection-like proxy object that properly handles StaticRange objects ++ * from the getComposedRanges API for Shadow DOM compatibility. ++ * ++ * This function creates a proxy that: ++ * - Provides all standard Selection properties and methods ++ * - Correctly handles anchor/focus nodes from StaticRange data ++ * - Implements the `type` property ('None', 'Caret', or 'Range') ++ * - Converts StaticRange to Range objects in getRangeAt method ++ * - Delegates other methods to the base Selection object ++ * ++ * **Validation:** ++ * The function validates that composedRanges is a non-empty array with valid ++ * StaticRange objects before creating the proxy. If validation fails, it ++ * returns the base selection unchanged. ++ * ++ * @param baseSelection - The base Selection object to enhance ++ * @param composedRanges - Array of StaticRange objects from getComposedRanges ++ * @returns A proxy Selection object that correctly handles Shadow DOM ranges, ++ * or the base selection if composedRanges is invalid ++ */ ++export declare function createSelectionWithComposedRanges(baseSelection: Selection, composedRanges: StaticRange[]): Selection; ++export declare function getDOMSelectionForEditor(editor: LexicalEditor): null | Selection; ++/** ++ * Traverses up the DOM tree to find a ShadowRoot if the element is inside a shadow DOM. ++ * This function helps determine whether the given element is rendered within Shadow DOM ++ * encapsulation. ++ * ++ * @param element - The HTMLElement to start traversing from ++ * @returns The ShadowRoot if found, or Document if the element is not in shadow DOM ++ */ ++export declare function getShadowRootOrDocument(element: HTMLElement): ShadowRoot | Document; ++/** ++ * Checks if the Lexical editor is running within a Shadow DOM context. ++ * ++ * This function determines whether the editor's root element is contained within ++ * a ShadowRoot, which is essential for enabling Shadow DOM-specific functionality ++ * like specialized deletion commands and selection handling. ++ * ++ * @param editor - The Lexical editor instance to check ++ * @returns `true` if the editor is in Shadow DOM, `false` otherwise ++ */ ++export declare function $isInShadowDOMContext(editor: LexicalEditor): boolean; ++/** ++ * Gets the appropriate Document object for an element, accounting for shadow DOM. ++ * Returns the ownerDocument of the ShadowRoot if the element is in shadow DOM, ++ * otherwise returns the element's ownerDocument or the global document. ++ * ++ * @param element - The HTMLElement to get the document for ++ * @returns The Document object that should be used for DOM operations ++ */ ++export declare function getDocumentFromElement(element: null | HTMLElement): Document; ++/** ++ * Gets the currently active (focused) element, accounting for shadow DOM encapsulation. ++ * In shadow DOM, the activeElement is tracked separately within the ShadowRoot. ++ * Falls back to the document's activeElement if not in shadow DOM. ++ * ++ * @param rootElement - The root element to check for shadow DOM context ++ * @returns The currently active Element or null if no element is focused ++ */ ++export declare function getActiveElement(rootElement: HTMLElement): Element | null; ++/** ++ * Returns the selection for the defaultView of the ownerDocument of given EventTarget, ++ * with full Shadow DOM support. ++ * ++ * This function determines the appropriate selection context based on whether the ++ * EventTarget is within a Shadow DOM or regular DOM: ++ * ++ * **Shadow DOM Elements:** ++ * Uses getDOMSelectionFromShadowRoot to get a selection that properly handles ++ * Shadow DOM boundaries using the getComposedRanges API when available. ++ * ++ * **Regular DOM Elements:** ++ * Returns the standard window.getSelection() from the element's defaultView. ++ * ++ * **Edge Cases:** ++ * - Returns null for null EventTarget ++ * - Returns null for EventTargets without a valid defaultView ++ * - Handles non-HTML EventTargets gracefully + * +- * @param eventTarget The node to get the selection from +- * @returns a Selection or null ++ * @param eventTarget - The EventTarget (typically a DOM node) to get the selection from ++ * @returns A Selection object from the appropriate context or null if unavailable + */ + export declare function getDOMSelectionFromTarget(eventTarget: null | EventTarget): null | Selection; + export declare function $splitNode(node: ElementNode, offset: number): [ElementNode | null, ElementNode]; +diff --git a/node_modules/lexical/index.d.ts b/node_modules/lexical/index.d.ts +index 9268311..3022741 100644 +--- a/node_modules/lexical/index.d.ts ++++ b/node_modules/lexical/index.d.ts +@@ -8,7 +8,7 @@ + export type { BaseCaret, CaretDirection, CaretRange, CaretType, ChildCaret, CommonAncestorResult, CommonAncestorResultAncestor, CommonAncestorResultBranch, CommonAncestorResultDescendant, CommonAncestorResultSame, FlipDirection, NodeCaret, PointCaret, RootMode, SiblingCaret, StepwiseIteratorConfig, TextPointCaret, TextPointCaretSlice, TextPointCaretSliceTuple, } from './caret/LexicalCaret'; + export { $comparePointCaretNext, $extendCaretToRange, $getAdjacentChildCaret, $getCaretRange, $getChildCaret, $getChildCaretOrSelf, $getCollapsedCaretRange, $getCommonAncestor, $getCommonAncestorResultBranchOrder, $getSiblingCaret, $getTextNodeOffset, $getTextPointCaret, $getTextPointCaretSlice, $isChildCaret, $isNodeCaret, $isSiblingCaret, $isTextPointCaret, $isTextPointCaretSlice, flipDirection, makeStepwiseIterator, } from './caret/LexicalCaret'; + export { $caretFromPoint, $caretRangeFromSelection, $getAdjacentSiblingOrParentSiblingCaret, $getCaretInDirection, $getCaretRangeInDirection, $getChildCaretAtIndex, $isExtendableTextPointCaret, $normalizeCaret, $removeTextFromCaretRange, $rewindSiblingCaret, $setPointFromCaret, $setSelectionFromCaretRange, $splitAtPointCaretNext, $updateRangeSelectionFromCaretRange, type SplitAtPointCaretNextOptions, } from './caret/LexicalCaretUtils'; +-export { BLUR_COMMAND, CAN_REDO_COMMAND, CAN_UNDO_COMMAND, CLEAR_EDITOR_COMMAND, CLEAR_HISTORY_COMMAND, CLICK_COMMAND, CONTROLLED_TEXT_INSERTION_COMMAND, COPY_COMMAND, createCommand, CUT_COMMAND, DELETE_CHARACTER_COMMAND, DELETE_LINE_COMMAND, DELETE_WORD_COMMAND, DRAGEND_COMMAND, DRAGOVER_COMMAND, DRAGSTART_COMMAND, DROP_COMMAND, FOCUS_COMMAND, FORMAT_ELEMENT_COMMAND, FORMAT_TEXT_COMMAND, INDENT_CONTENT_COMMAND, INSERT_LINE_BREAK_COMMAND, INSERT_PARAGRAPH_COMMAND, INSERT_TAB_COMMAND, KEY_ARROW_DOWN_COMMAND, KEY_ARROW_LEFT_COMMAND, KEY_ARROW_RIGHT_COMMAND, KEY_ARROW_UP_COMMAND, KEY_BACKSPACE_COMMAND, KEY_DELETE_COMMAND, KEY_DOWN_COMMAND, KEY_ENTER_COMMAND, KEY_ESCAPE_COMMAND, KEY_MODIFIER_COMMAND, KEY_SPACE_COMMAND, KEY_TAB_COMMAND, MOVE_TO_END, MOVE_TO_START, OUTDENT_CONTENT_COMMAND, PASTE_COMMAND, type PasteCommandType, REDO_COMMAND, REMOVE_TEXT_COMMAND, SELECT_ALL_COMMAND, SELECTION_CHANGE_COMMAND, SELECTION_INSERT_CLIPBOARD_NODES_COMMAND, UNDO_COMMAND, } from './LexicalCommands'; ++export { BEFORE_INPUT_COMMAND, BLUR_COMMAND, CAN_REDO_COMMAND, CAN_UNDO_COMMAND, CLEAR_EDITOR_COMMAND, CLEAR_HISTORY_COMMAND, CLICK_COMMAND, COMPOSITION_END_COMMAND, COMPOSITION_START_COMMAND, CONTROLLED_TEXT_INSERTION_COMMAND, COPY_COMMAND, createCommand, CUT_COMMAND, DELETE_CHARACTER_COMMAND, DELETE_LINE_COMMAND, DELETE_WORD_COMMAND, DRAGEND_COMMAND, DRAGOVER_COMMAND, DRAGSTART_COMMAND, DROP_COMMAND, FOCUS_COMMAND, FORMAT_ELEMENT_COMMAND, FORMAT_TEXT_COMMAND, INDENT_CONTENT_COMMAND, INPUT_COMMAND, INSERT_LINE_BREAK_COMMAND, INSERT_PARAGRAPH_COMMAND, INSERT_TAB_COMMAND, KEY_ARROW_DOWN_COMMAND, KEY_ARROW_LEFT_COMMAND, KEY_ARROW_RIGHT_COMMAND, KEY_ARROW_UP_COMMAND, KEY_BACKSPACE_COMMAND, KEY_DELETE_COMMAND, KEY_DOWN_COMMAND, KEY_ENTER_COMMAND, KEY_ESCAPE_COMMAND, KEY_MODIFIER_COMMAND, KEY_SPACE_COMMAND, KEY_TAB_COMMAND, MOVE_TO_END, MOVE_TO_START, OUTDENT_CONTENT_COMMAND, PASTE_COMMAND, type PasteCommandType, REDO_COMMAND, REMOVE_TEXT_COMMAND, SELECT_ALL_COMMAND, SELECTION_CHANGE_COMMAND, SELECTION_INSERT_CLIPBOARD_NODES_COMMAND, UNDO_COMMAND, } from './LexicalCommands'; + export { IS_ALL_FORMATTING, IS_BOLD, IS_CODE, IS_HIGHLIGHT, IS_ITALIC, IS_STRIKETHROUGH, IS_SUBSCRIPT, IS_SUPERSCRIPT, IS_UNDERLINE, NODE_STATE_KEY, TEXT_TYPE_TO_FORMAT, } from './LexicalConstants'; + export type { CommandListener, CommandListenerPriority, CommandPayloadType, CreateEditorArgs, EditableListener, EditorConfig, EditorSetOptions, EditorThemeClasses, EditorThemeClassName, EditorUpdateOptions, HTMLConfig, Klass, KlassConstructor, LexicalCommand, LexicalEditor, LexicalNodeConfig, LexicalNodeReplacement, MutationListener, NodeMutation, RootListener, SerializedEditor, Spread, Transform, UpdateListener, UpdateListenerPayload, } from './LexicalEditor'; + export { COMMAND_PRIORITY_CRITICAL, COMMAND_PRIORITY_EDITOR, COMMAND_PRIORITY_HIGH, COMMAND_PRIORITY_LOW, COMMAND_PRIORITY_NORMAL, createEditor, getTransformSetFromKlass, } from './LexicalEditor'; +@@ -22,7 +22,7 @@ export { $normalizeSelection as $normalizeSelection__EXPERIMENTAL } from './Lexi + export type { BaseSelection, ElementPointType as ElementPoint, NodeSelection, Point, PointType, RangeSelection, TextPointType as TextPoint, } from './LexicalSelection'; + export { $createNodeSelection, $createPoint, $createRangeSelection, $createRangeSelectionFromDom, $getCharacterOffsets, $getPreviousSelection, $getSelection, $getTextContent, $insertNodes, $isBlockElementNode, $isNodeSelection, $isRangeSelection, } from './LexicalSelection'; + export { $parseSerializedNode, isCurrentlyReadOnlyMode } from './LexicalUpdates'; +-export { $addUpdateTag, $applyNodeReplacement, $cloneWithProperties, $cloneWithPropertiesEphemeral, $copyNode, $create, $findMatchingParent, $getAdjacentNode, $getEditor, $getNearestNodeFromDOMNode, $getNearestRootOrShadowRoot, $getNodeByKey, $getNodeByKeyOrThrow, $getNodeFromDOMNode, $getRoot, $hasAncestor, $hasUpdateTag, $isInlineElementOrDecoratorNode, $isLeafNode, $isRootOrShadowRoot, $isTokenOrSegmented, $isTokenOrTab, $nodesOfType, $onUpdate, $selectAll, $setCompositionKey, $setSelection, $splitNode, getDOMOwnerDocument, getDOMSelection, getDOMSelectionFromTarget, getDOMTextNode, getEditorPropertyFromDOMNode, getNearestEditorFromDOMNode, getRegisteredNode, getRegisteredNodeOrThrow, getStaticNodeConfig, getTextDirection, INTERNAL_$isBlock, isBlockDomNode, isDocumentFragment, isDOMDocumentNode, isDOMNode, isDOMTextNode, isDOMUnmanaged, isExactShortcutMatch, isHTMLAnchorElement, isHTMLElement, isInlineDomNode, isLexicalEditor, isModifierMatch, isSelectionCapturedInDecoratorInput, isSelectionWithinEditor, removeFromParent, resetRandomKey, setDOMUnmanaged, setNodeIndentFromDOM, } from './LexicalUtils'; ++export { $addUpdateTag, $applyNodeReplacement, $cloneWithProperties, $cloneWithPropertiesEphemeral, $copyNode, $create, $findMatchingParent, $getAdjacentNode, $getEditor, $getNearestNodeFromDOMNode, $getNearestRootOrShadowRoot, $getNodeByKey, $getNodeByKeyOrThrow, $getNodeFromDOMNode, $getRoot, $hasAncestor, $hasUpdateTag, $isInlineElementOrDecoratorNode, $isInShadowDOMContext, $isLeafNode, $isRootOrShadowRoot, $isTokenOrSegmented, $isTokenOrTab, $nodesOfType, $onUpdate, $selectAll, $setCompositionKey, $setSelection, $splitNode, getDocumentFromElement, getDOMOwnerDocument, getDOMSelection, getDOMSelectionForEditor, getDOMSelectionFromShadowRoot, getDOMSelectionFromTarget, getDOMTextNode, getEditorPropertyFromDOMNode, getNearestEditorFromDOMNode, getRegisteredNode, getRegisteredNodeOrThrow, getShadowRootOrDocument, getStaticNodeConfig, getTextDirection, getWindow, INTERNAL_$isBlock, isBlockDomNode, isDocumentFragment, isDOMDocumentNode, isDOMNode, isDOMTextNode, isDOMUnmanaged, isExactShortcutMatch, isHTMLAnchorElement, isHTMLElement, isInlineDomNode, isLexicalEditor, isModifierMatch, isSelectionCapturedInDecoratorInput, isSelectionWithinEditor, isShadowRoot, removeFromParent, resetRandomKey, setDOMUnmanaged, setNodeIndentFromDOM, } from './LexicalUtils'; + export { ArtificialNode__DO_NOT_USE } from './nodes/ArtificialNode'; + export { $isDecoratorNode, DecoratorNode } from './nodes/LexicalDecoratorNode'; + export type { ElementDOMSlot, ElementFormatType, SerializedElementNode, } from './nodes/LexicalElementNode'; diff --git a/src/components/accordion/accordion.tsx b/src/components/accordion/accordion.tsx index 81afc1a4..d3758ab7 100644 --- a/src/components/accordion/accordion.tsx +++ b/src/components/accordion/accordion.tsx @@ -7,7 +7,7 @@ import React, { } from 'react'; import { nanoid } from 'nanoid'; import { Plus, Minus, ChevronDown } from 'lucide-react'; -import { motion } from 'framer-motion'; +import { motion, AnimatePresence } from 'framer-motion'; import { callAll, cn } from '@/utilities/functions'; // Define common props to be shared by all components @@ -294,12 +294,13 @@ export const AccordionContent = ( { boxed: 'px-3 pb-4', }?.[ type ]; + // The outer region stays in the DOM so the trigger's aria-controls always + // references an existing element, but the children unmount while the + // panel is collapsed. Keeping collapsed content mounted is expensive for + // consumers that put heavy children (e.g. editors) in many panels: they + // all mount up front and re-render on every state change. return ( - -
{ children }
-
+ + { isOpen && ( + +
+ { children } +
+
+ ) } +
+
); }; diff --git a/src/components/datepicker/datepicker-component.tsx b/src/components/datepicker/datepicker-component.tsx index 83fcc9ba..46c73a12 100644 --- a/src/components/datepicker/datepicker-component.tsx +++ b/src/components/datepicker/datepicker-component.tsx @@ -7,10 +7,25 @@ import { type CustomComponents, type OnSelectHandler, } from 'react-day-picker'; -import { format, isAfter, isBefore, isEqual, subMonths } from 'date-fns'; +import { + format, + isAfter, + isBefore, + isEqual, + isSameDay, + setHours, + setMinutes, + startOfDay, + subMonths, +} from 'date-fns'; import { cn } from '@/utilities/functions'; import Button from '../button'; -import { currentTimeDot, formatWeekdayName, generateYearRange } from './utils'; +import { + currentTimeDot, + formatWeekdayName, + generateYearRange, + mergeDateTime, +} from './utils'; export type TDateRange = { from: Date | undefined; to: Date | undefined }; @@ -56,6 +71,13 @@ export interface DatePickerProps { numberOfMonths?: number; /** Footer content to be displayed at the bottom of the date picker. */ footer?: ReactNode; + /** + * Show time selection inputs below the calendar grid. + * Applies to `single` and `range` modes only; ignored for `multiple`. + * + * @default false + */ + enableTimeSelection?: boolean; /** Additional props to be passed to the date picker. */ [key: string]: unknown; } @@ -99,6 +121,7 @@ const DatePickerComponent = ( { variant = 'normal', alignment = 'horizontal', numberOfMonths, + enableTimeSelection = false, disabled, ...props }: DatePickerProps ) => { @@ -106,6 +129,7 @@ const DatePickerComponent = ( { const isFooter = React.isValidElement( props.footer ) || typeof props.footer === 'function'; + const hasTimeSelection = enableTimeSelection && mode !== 'multiple'; const [ showMonthSelect, setShowMonthSelect ] = useState( false ); const [ showYearSelect, setShowYearSelect ] = useState( false ); // New state for year selection const [ selectedYear, setSelectedYear ] = useState( new Date().getFullYear() ); @@ -452,33 +476,65 @@ const DatePickerComponent = ( { > = ( selectedDate, trigger ) => { if ( mode === 'range' ) { const currentSelectedValue = selectedDates as TDateRange; + const isSameSelectedDate = ( date: Date | undefined ) => + !! date && + ( enableTimeSelection + ? isSameDay( trigger, date ) + : isEqual( trigger, date ) ); + const withPreservedTime = ( date: Date, source: Date | undefined ) => + enableTimeSelection ? mergeDateTime( date, source ) : date; if ( ( ! currentSelectedValue?.from && ! currentSelectedValue?.to ) || ( currentSelectedValue?.from && currentSelectedValue?.to ) ) { if ( - ( currentSelectedValue.from && - isEqual( trigger, currentSelectedValue?.from ) ) || - ( currentSelectedValue.to && - isEqual( trigger, currentSelectedValue?.to ) ) + isSameSelectedDate( currentSelectedValue?.from ) || + isSameSelectedDate( currentSelectedValue?.to ) ) { setSelectedDates( { from: undefined, to: undefined } ); return; } - setSelectedDates( { from: trigger, to: undefined } ); + setSelectedDates( { + from: withPreservedTime( + trigger, + currentSelectedValue?.from + ), + to: undefined, + } ); return; } if ( currentSelectedValue?.from && ! currentSelectedValue?.to ) { - if ( trigger < currentSelectedValue.from ) { + const isTriggerBeforeFrom = enableTimeSelection + ? isBefore( trigger, startOfDay( currentSelectedValue.from ) ) + : trigger < currentSelectedValue.from; + if ( isTriggerBeforeFrom ) { setSelectedDates( { - from: trigger, + from: withPreservedTime( + trigger, + currentSelectedValue.from + ), to: currentSelectedValue.from, } ); return; } + let rangeEndDate = withPreservedTime( + trigger, + currentSelectedValue.to + ); + // Same-day completion: keep the end from landing before a + // start that already carries a later time. + if ( + enableTimeSelection && + isBefore( rangeEndDate, currentSelectedValue.from ) + ) { + rangeEndDate = mergeDateTime( + rangeEndDate, + currentSelectedValue.from + ); + } setSelectedDates( { from: currentSelectedValue.from, - to: trigger, + to: rangeEndDate, } ); return; } @@ -502,10 +558,126 @@ const DatePickerComponent = ( { setSelectedDates( [ ...( selectedDates as Date[] ), trigger ] ); } } else if ( mode === 'single' ) { + if ( + enableTimeSelection && + selectedDate instanceof Date && + selectedDates instanceof Date + ) { + setSelectedDates( mergeDateTime( selectedDate, selectedDates ) ); + return; + } setSelectedDates( selectedDate as Date ); } }; + const handleTimeChange = ( + event: React.ChangeEvent, + target: 'single' | 'from' | 'to' + ) => { + const { value } = event.target; + if ( ! value ) { + return; + } + if ( target === 'single' ) { + if ( ! ( selectedDates instanceof Date ) ) { + return; + } + const [ hours, minutes ] = value.split( ':' ).map( Number ); + setSelectedDates( + setMinutes( setHours( selectedDates, hours ), minutes ) + ); + return; + } + const currentRange = selectedDates as TDateRange; + if ( ! currentRange?.[ target ] ) { + return; + } + const [ hours, minutes ] = value.split( ':' ).map( Number ); + const updatedDate = setMinutes( + setHours( currentRange[ target ]!, hours ), + minutes + ); + const updatedRange = { + ...currentRange, + [ target ]: updatedDate, + }; + // Keep the range valid: align the other endpoint's time when the + // edited time would put the start after the end on the same day. + const counterpart = target === 'from' ? 'to' : 'from'; + if ( + updatedRange.from && + updatedRange.to && + isAfter( updatedRange.from, updatedRange.to ) + ) { + updatedRange[ counterpart ] = mergeDateTime( + updatedRange[ counterpart ]!, + updatedDate + ); + } + setSelectedDates( updatedRange ); + }; + + const renderTimeInput = ( + target: 'single' | 'from' | 'to', + date: Date | undefined, + label: string + ) => ( +
+ + { label } + + handleTimeChange( event, target ) } + aria-label={ label } + /> +
+ ); + + const timeSection = hasTimeSelection ? ( +
+ { mode === 'single' ? ( + renderTimeInput( + 'single', + selectedDates as Date | undefined, + 'Time' + ) + ) : ( + <> + { renderTimeInput( + 'from', + ( selectedDates as TDateRange )?.from, + 'Start time' + ) } + { renderTimeInput( + 'to', + ( selectedDates as TDateRange )?.to, + 'End time' + ) } + + ) } +
+ ) : null; + const monthsClassName = cn( 'relative bg-background-primary shadow-datepicker-wrapper', width, @@ -519,7 +691,9 @@ const DatePickerComponent = ( { variant === 'dualdate' ? 'rounded-tr-md rounded-tl-md border border-solid border-border-subtle' : '', - isFooter ? 'rounded-b-none' : 'rounded-bl-md rounded-br-md' + isFooter || hasTimeSelection + ? 'rounded-b-none' + : 'rounded-bl-md rounded-br-md' ); return ( @@ -644,6 +818,16 @@ const DatePickerComponent = ( { /* eslint-disable @typescript-eslint/no-explicit-any */ { ...( ( mode === 'range' ? { required: false } : {} ) as any ) } { ...props } + footer={ + hasTimeSelection ? ( + <> + { timeSection } + { props.footer } + + ) : ( + ( props.footer as ReactNode ) + ) + } onDayMouseEnter={ ( _, __, event ) => { if ( mode !== 'range' ) { return; diff --git a/src/components/datepicker/datepicker.stories.tsx b/src/components/datepicker/datepicker.stories.tsx index fcff0903..8ac200f2 100644 --- a/src/components/datepicker/datepicker.stories.tsx +++ b/src/components/datepicker/datepicker.stories.tsx @@ -1,4 +1,6 @@ import { + addMonths, + format, startOfToday, startOfYesterday, startOfWeek, @@ -10,6 +12,8 @@ import { } from 'date-fns'; import DatePicker from './datepicker'; import type { Meta, StoryFn } from '@storybook/react-vite'; +import { expect, fireEvent, fn, userEvent, within } from 'storybook/test'; +import { PlayFunc } from '@/utilities/ts-helper'; const meta: Meta = { title: 'Atoms/DatePicker', @@ -34,17 +38,347 @@ const meta: Meta = { control: { type: 'select' }, options: [ 'normal', 'dualdate', 'presets' ], }, + enableTimeSelection: { + control: { type: 'boolean' }, + }, }, } satisfies Meta; export default meta; type Story = StoryFn; +type PlayFunction = PlayFunc; const Template: Story = ( args ) => ( ); +// Find the enabled calendar button for a day of the given month (defaults to the current month). +const getDayButton = ( + canvasElement: HTMLElement, + day: number, + monthDate: Date = new Date() +) => { + const dayString = `${ format( monthDate, 'yyyy-MM' ) }-${ String( + day + ).padStart( 2, '0' ) }`; + return canvasElement.querySelector( + `button[data-day="${ dayString }"]:not([disabled])` + ) as HTMLButtonElement; +}; + +const singleTimeSelectionTest: PlayFunction = async ( { + canvasElement, + args, +} ) => { + const canvas = within( canvasElement ); + const timeInput = canvas.getByLabelText( 'Time' ) as HTMLInputElement; + // No date selected yet — input is disabled and empty. + await expect( timeInput ).toBeDisabled(); + await expect( timeInput ).toHaveValue( '' ); + + // Selecting a date enables the input at midnight. + await userEvent.click( getDayButton( canvasElement, 15 ) ); + await expect( timeInput ).toBeEnabled(); + await expect( timeInput ).toHaveValue( '00:00' ); + + // Setting a time merges it into the selected date. + await fireEvent.change( timeInput, { target: { value: '14:30' } } ); + await expect( timeInput ).toHaveValue( '14:30' ); + + // Picking another date preserves the chosen time. + await userEvent.click( getDayButton( canvasElement, 18 ) ); + await expect( timeInput ).toHaveValue( '14:30' ); + const onDateSelect = args.onDateSelect as ReturnType; + const lastSelected = onDateSelect.mock.calls.at( -1 )?.[ 0 ] as Date; + await expect( lastSelected.getDate() ).toBe( 18 ); + await expect( lastSelected.getHours() ).toBe( 14 ); + await expect( lastSelected.getMinutes() ).toBe( 30 ); + + // Clearing the native input is a no-op. + await fireEvent.change( timeInput, { target: { value: '' } } ); + await expect( timeInput ).toHaveValue( '14:30' ); + + // The Apply payload carries the chosen time. + await userEvent.click( canvas.getByRole( 'button', { name: 'Apply' } ) ); + const onApply = args.onApply as ReturnType; + const applied = onApply.mock.calls.at( -1 )?.[ 0 ] as Date; + await expect( applied.getHours() ).toBe( 14 ); + await expect( applied.getMinutes() ).toBe( 30 ); + + // Deselecting the date disables and empties the input. + await userEvent.click( getDayButton( canvasElement, 18 ) ); + await expect( timeInput ).toBeDisabled(); + await expect( timeInput ).toHaveValue( '' ); +}; + +const rangeTimeSelectionTest: PlayFunction = async ( { + canvasElement, + args, +} ) => { + const canvas = within( canvasElement ); + const startInput = canvas.getByLabelText( + 'Start time' + ) as HTMLInputElement; + const endInput = canvas.getByLabelText( 'End time' ) as HTMLInputElement; + // No range selected yet — both inputs are disabled. + await expect( startInput ).toBeDisabled(); + await expect( endInput ).toBeDisabled(); + + // Starting a range enables only the start input. + await userEvent.click( getDayButton( canvasElement, 10 ) ); + await expect( startInput ).toBeEnabled(); + await expect( startInput ).toHaveValue( '00:00' ); + await expect( endInput ).toBeDisabled(); + + await fireEvent.change( startInput, { target: { value: '09:15' } } ); + await expect( startInput ).toHaveValue( '09:15' ); + + // Completing the range keeps the chosen start time. + await userEvent.click( getDayButton( canvasElement, 20 ) ); + await expect( startInput ).toHaveValue( '09:15' ); + await expect( endInput ).toBeEnabled(); + await expect( endInput ).toHaveValue( '00:00' ); + + await fireEvent.change( endInput, { target: { value: '18:45' } } ); + await expect( endInput ).toHaveValue( '18:45' ); + + // The Apply payload carries both times. + await userEvent.click( canvas.getByRole( 'button', { name: 'Apply' } ) ); + const onApply = args.onApply as ReturnType; + const appliedRange = onApply.mock.calls.at( -1 )?.[ 0 ] as { + from: Date; + to: Date; + }; + await expect( appliedRange.from.getHours() ).toBe( 9 ); + await expect( appliedRange.from.getMinutes() ).toBe( 15 ); + await expect( appliedRange.to.getHours() ).toBe( 18 ); + await expect( appliedRange.to.getMinutes() ).toBe( 45 ); + + // Starting a new range carries the previous start time. + await userEvent.click( getDayButton( canvasElement, 5 ) ); + await expect( startInput ).toHaveValue( '09:15' ); + await expect( endInput ).toBeDisabled(); + + // Same-day completion clamps the end so it never lands before the start. + await userEvent.click( getDayButton( canvasElement, 5 ) ); + await expect( startInput ).toHaveValue( '09:15' ); + await expect( endInput ).toHaveValue( '09:15' ); + + // Editing a time that would invert the range realigns the other endpoint. + await fireEvent.change( endInput, { target: { value: '06:00' } } ); + await expect( endInput ).toHaveValue( '06:00' ); + await expect( startInput ).toHaveValue( '06:00' ); + + // Clicking the selected day again deselects, even with a non-midnight time. + await userEvent.click( getDayButton( canvasElement, 5 ) ); + await expect( startInput ).toBeDisabled(); + await expect( endInput ).toBeDisabled(); + + // Clicking an earlier day swaps the range endpoints. + await userEvent.click( getDayButton( canvasElement, 20 ) ); + await userEvent.click( getDayButton( canvasElement, 12 ) ); + const onDateSelect = args.onDateSelect as ReturnType; + const lastRange = onDateSelect.mock.calls.at( -1 )?.[ 0 ] as { + from: Date; + to: Date; + }; + await expect( lastRange.from.getDate() ).toBe( 12 ); + await expect( lastRange.to.getDate() ).toBe( 20 ); +}; + +const multipleTimeSelectionTest: PlayFunction = async ( { + canvasElement, + args, +} ) => { + const canvas = within( canvasElement ); + // The flag is ignored for multiple — no time inputs are rendered. + await expect( canvas.queryByLabelText( 'Time' ) ).toBeNull(); + await expect( canvas.queryByLabelText( 'Start time' ) ).toBeNull(); + await expect( canvas.queryByLabelText( 'End time' ) ).toBeNull(); + + // Multiple selection still works as before. + await userEvent.click( getDayButton( canvasElement, 15 ) ); + await userEvent.click( getDayButton( canvasElement, 18 ) ); + const onDateSelect = args.onDateSelect as ReturnType; + const lastSelected = onDateSelect.mock.calls.at( -1 )?.[ 0 ] as Date[]; + await expect( lastSelected ).toHaveLength( 2 ); +}; + +// Regression tests: with enableTimeSelection off, the previous behavior +// must be unchanged and no time inputs may render. +const singleRegressionTest: PlayFunction = async ( { + canvasElement, + args, +} ) => { + const canvas = within( canvasElement ); + await expect( + canvasElement.querySelector( 'input[type="time"]' ) + ).toBeNull(); + + const onDateSelect = args.onDateSelect as ReturnType; + // Selecting a date reports it at midnight. + await userEvent.click( getDayButton( canvasElement, 15 ) ); + const selected = onDateSelect.mock.calls.at( -1 )?.[ 0 ] as Date; + await expect( selected.getDate() ).toBe( 15 ); + await expect( selected.getHours() ).toBe( 0 ); + await expect( selected.getMinutes() ).toBe( 0 ); + + // Re-clicking the selected date deselects it. + await userEvent.click( getDayButton( canvasElement, 15 ) ); + await expect( onDateSelect.mock.calls.at( -1 )?.[ 0 ] ).toBeUndefined(); + + // Apply and Cancel callbacks still fire with the expected payloads. + await userEvent.click( getDayButton( canvasElement, 18 ) ); + await userEvent.click( canvas.getByRole( 'button', { name: 'Apply' } ) ); + const onApply = args.onApply as ReturnType; + const applied = onApply.mock.calls.at( -1 )?.[ 0 ] as Date; + await expect( applied.getDate() ).toBe( 18 ); + await userEvent.click( canvas.getByRole( 'button', { name: 'Cancel' } ) ); + await expect( args.onCancel ).toHaveBeenCalled(); +}; + +const rangeRegressionTest: PlayFunction = async ( { + canvasElement, + args, +} ) => { + const canvas = within( canvasElement ); + await expect( + canvasElement.querySelector( 'input[type="time"]' ) + ).toBeNull(); + + const onDateSelect = args.onDateSelect as ReturnType; + const lastRange = () => + onDateSelect.mock.calls.at( -1 )?.[ 0 ] as { + from: Date | undefined; + to: Date | undefined; + }; + + // Starting a range sets only the start date. + await userEvent.click( getDayButton( canvasElement, 10 ) ); + await expect( lastRange().from?.getDate() ).toBe( 10 ); + await expect( lastRange().to ).toBeUndefined(); + + // A later click completes the range. + await userEvent.click( getDayButton( canvasElement, 20 ) ); + await expect( lastRange().from?.getDate() ).toBe( 10 ); + await expect( lastRange().to?.getDate() ).toBe( 20 ); + + // Clicking the start date of a complete range deselects it. + await userEvent.click( getDayButton( canvasElement, 10 ) ); + await expect( lastRange().from ).toBeUndefined(); + await expect( lastRange().to ).toBeUndefined(); + + // Clicking an earlier day than the start swaps the endpoints. + await userEvent.click( getDayButton( canvasElement, 20 ) ); + await userEvent.click( getDayButton( canvasElement, 12 ) ); + await expect( lastRange().from?.getDate() ).toBe( 12 ); + await expect( lastRange().to?.getDate() ).toBe( 20 ); + + // Clicking the end date of a complete range deselects it. + await userEvent.click( getDayButton( canvasElement, 20 ) ); + await expect( lastRange().from ).toBeUndefined(); + + // Clicking the same day twice creates a same-day range. + await userEvent.click( getDayButton( canvasElement, 15 ) ); + await userEvent.click( getDayButton( canvasElement, 15 ) ); + await expect( lastRange().from?.getDate() ).toBe( 15 ); + await expect( lastRange().to?.getDate() ).toBe( 15 ); + + // The Apply payload stays at midnight. + await userEvent.click( canvas.getByRole( 'button', { name: 'Apply' } ) ); + const onApply = args.onApply as ReturnType; + const applied = onApply.mock.calls.at( -1 )?.[ 0 ] as { + from: Date; + to: Date; + }; + await expect( applied.from.getHours() ).toBe( 0 ); + await expect( applied.to.getHours() ).toBe( 0 ); + + await userEvent.click( canvas.getByRole( 'button', { name: 'Cancel' } ) ); + await expect( args.onCancel ).toHaveBeenCalled(); +}; + +const multipleRegressionTest: PlayFunction = async ( { + canvasElement, + args, +} ) => { + const canvas = within( canvasElement ); + await expect( + canvasElement.querySelector( 'input[type="time"]' ) + ).toBeNull(); + + const onDateSelect = args.onDateSelect as ReturnType; + // Selecting dates accumulates them. + await userEvent.click( getDayButton( canvasElement, 15 ) ); + await userEvent.click( getDayButton( canvasElement, 18 ) ); + await expect( onDateSelect.mock.calls.at( -1 )?.[ 0 ] ).toHaveLength( 2 ); + + // Re-clicking a selected date removes it. + await userEvent.click( getDayButton( canvasElement, 15 ) ); + const remaining = onDateSelect.mock.calls.at( -1 )?.[ 0 ] as Date[]; + await expect( remaining ).toHaveLength( 1 ); + await expect( remaining[ 0 ].getDate() ).toBe( 18 ); + + // The Apply payload is the array of selected dates. + await userEvent.click( canvas.getByRole( 'button', { name: 'Apply' } ) ); + const onApply = args.onApply as ReturnType; + await expect( onApply.mock.calls.at( -1 )?.[ 0 ] ).toHaveLength( 1 ); +}; + +const dualDateRegressionTest: PlayFunction = async ( { + canvasElement, + args, +} ) => { + await expect( + canvasElement.querySelector( 'input[type="time"]' ) + ).toBeNull(); + + // A range can span the two displayed months. + await userEvent.click( getDayButton( canvasElement, 25 ) ); + await userEvent.click( + getDayButton( canvasElement, 5, addMonths( new Date(), 1 ) ) + ); + const onDateSelect = args.onDateSelect as ReturnType; + const lastRange = onDateSelect.mock.calls.at( -1 )?.[ 0 ] as { + from: Date; + to: Date; + }; + await expect( lastRange.from.getDate() ).toBe( 25 ); + await expect( lastRange.to.getDate() ).toBe( 5 ); + await expect( lastRange.to.getMonth() ).toBe( + addMonths( new Date(), 1 ).getMonth() + ); +}; + +const presetsRegressionTest: PlayFunction = async ( { + canvasElement, + args, +} ) => { + const canvas = within( canvasElement ); + await expect( + canvasElement.querySelector( 'input[type="time"]' ) + ).toBeNull(); + + const onApply = args.onApply as ReturnType; + // The initial `selected` value flows through to Apply. + await userEvent.click( canvas.getByRole( 'button', { name: 'Apply' } ) ); + let applied = onApply.mock.calls.at( -1 )?.[ 0 ] as { + from: Date; + to: Date; + }; + await expect( applied.from.getTime() ).toBe( + startOfMonth( new Date() ).getTime() + ); + + // Clicking a preset updates the selection. + await userEvent.click( canvas.getByRole( 'button', { name: 'Today' } ) ); + await userEvent.click( canvas.getByRole( 'button', { name: 'Apply' } ) ); + applied = onApply.mock.calls.at( -1 )?.[ 0 ] as { from: Date; to: Date }; + await expect( applied.from.getTime() ).toBe( startOfToday().getTime() ); + await expect( applied.to.getTime() ).toBe( startOfToday().getTime() ); +}; + export const Default = Template.bind( {} ); Default.args = { selectionType: 'single', @@ -52,16 +386,11 @@ Default.args = { applyButtonText: 'Apply', cancelButtonText: 'Cancel', showOutsideDays: true, - onApply: () => { - //code - }, - onCancel: () => { - //code - }, - onDateSelect: () => { - //code - }, + onApply: fn(), + onCancel: fn(), + onDateSelect: fn(), }; +Default.play = singleRegressionTest; export const Range = Template.bind( {} ); Range.args = { @@ -70,16 +399,11 @@ Range.args = { applyButtonText: 'Apply', cancelButtonText: 'Cancel', showOutsideDays: true, - onApply: () => { - //code - }, - onCancel: () => { - //code - }, - onDateSelect: () => { - //code - }, + onApply: fn(), + onCancel: fn(), + onDateSelect: fn(), }; +Range.play = rangeRegressionTest; export const Multiple = Template.bind( {} ); Multiple.args = { @@ -88,16 +412,54 @@ Multiple.args = { applyButtonText: 'Apply', cancelButtonText: 'Cancel', showOutsideDays: true, - onApply: () => { - //code - }, - onCancel: () => { - //code - }, - onDateSelect: () => { - //code - }, + onApply: fn(), + onCancel: fn(), + onDateSelect: fn(), }; +Multiple.play = multipleRegressionTest; + +export const SingleWithTimeSelection = Template.bind( {} ); +SingleWithTimeSelection.args = { + selectionType: 'single', + variant: 'normal', + enableTimeSelection: true, + applyButtonText: 'Apply', + cancelButtonText: 'Cancel', + showOutsideDays: true, + onApply: fn(), + onCancel: fn(), + onDateSelect: fn(), +}; +SingleWithTimeSelection.play = singleTimeSelectionTest; + +export const RangeWithTimeSelection = Template.bind( {} ); +RangeWithTimeSelection.args = { + selectionType: 'range', + variant: 'dualdate', + enableTimeSelection: true, + applyButtonText: 'Apply', + cancelButtonText: 'Cancel', + showOutsideDays: true, + onApply: fn(), + onCancel: fn(), + onDateSelect: fn(), +}; +RangeWithTimeSelection.play = rangeTimeSelectionTest; + +// enableTimeSelection is intentionally ignored for the multiple selection type. +export const MultipleWithTimeSelection = Template.bind( {} ); +MultipleWithTimeSelection.args = { + selectionType: 'multiple', + variant: 'normal', + enableTimeSelection: true, + applyButtonText: 'Apply', + cancelButtonText: 'Cancel', + showOutsideDays: true, + onApply: fn(), + onCancel: fn(), + onDateSelect: fn(), +}; +MultipleWithTimeSelection.play = multipleTimeSelectionTest; export const DualDate = Template.bind( {} ); DualDate.args = { @@ -106,16 +468,11 @@ DualDate.args = { applyButtonText: 'Apply', cancelButtonText: 'Cancel', showOutsideDays: true, - onApply: () => { - //code - }, - onCancel: () => { - //code - }, - onDateSelect: () => { - //code - }, + onApply: fn(), + onCancel: fn(), + onDateSelect: fn(), }; +DualDate.play = dualDateRegressionTest; export const WithPresets = Template.bind( {} ); WithPresets.args = { @@ -167,13 +524,8 @@ WithPresets.args = { from: startOfMonth( new Date() ), to: endOfMonth( new Date() ), }, - onApply: () => { - //code - }, - onCancel: () => { - //code - }, - onDateSelect: () => { - //code - }, + onApply: fn(), + onCancel: fn(), + onDateSelect: fn(), }; +WithPresets.play = presetsRegressionTest; diff --git a/src/components/datepicker/datepicker.tsx b/src/components/datepicker/datepicker.tsx index 6ce51699..78b9abe8 100644 --- a/src/components/datepicker/datepicker.tsx +++ b/src/components/datepicker/datepicker.tsx @@ -36,6 +36,13 @@ export interface DatePickerProps { showOutsideDays?: boolean; /** Show or hide the footer. */ isFooter?: boolean; + /** + * Show time selection inputs below the calendar grid. + * Applies to `single` and `range` selection types only; ignored for `multiple`. + * + * @default false + */ + enableTimeSelection?: boolean; /** Selected date value. */ selected?: Date | Date[] | TDateRange | undefined; /** @@ -61,6 +68,7 @@ const DatePicker = ( { cancelButtonText = 'Cancel', showOutsideDays = true, isFooter = true, + enableTimeSelection = false, selected, disabled, ...props @@ -166,6 +174,7 @@ const DatePicker = ( { mode={ selectionType } variant={ variant } width="w-[18.5rem]" + enableTimeSelection={ enableTimeSelection } selectedDates={ selectedDates } showOutsideDays={ showOutsideDays } setSelectedDates={ @@ -199,6 +208,7 @@ const DatePicker = ( { mode={ selectionType } numberOfMonths={ 2 } alignment="horizontal" + enableTimeSelection={ enableTimeSelection } selectedDates={ selectedDates } setSelectedDates={ handleSelect as ( @@ -256,6 +266,7 @@ const DatePicker = ( { { export default App; ``` +### Datepicker with Time Selection +```jsx +import DatePicker from '@bsf/force-ui'; + +const App = () => { + return ( + console.log(selectedDates)} // from/to carry the chosen time + /> + ); +}; + +export default App; +``` + ### Datepicker with onDateSelect This will select the date on click of date. diff --git a/src/components/datepicker/utils.tsx b/src/components/datepicker/utils.tsx index dcf04e0c..252c2721 100644 --- a/src/components/datepicker/utils.tsx +++ b/src/components/datepicker/utils.tsx @@ -1,4 +1,4 @@ -import { format } from 'date-fns'; +import { format, getHours, getMinutes, setHours, setMinutes } from 'date-fns'; export const currentTimeDot = () => { return ( @@ -14,6 +14,16 @@ export const generateYearRange = ( start: number, count = 24 ) => { return Array.from( { length: count }, ( _, i ) => start + i ); }; +export const mergeDateTime = ( date: Date, timeSource: Date | undefined ) => { + if ( ! timeSource ) { + return date; + } + return setMinutes( + setHours( date, getHours( timeSource ) ), + getMinutes( timeSource ) + ); +}; + export const getDefaultSelectedValue = ( type: string ) => { if ( type === 'multiple' ) { return []; diff --git a/src/components/editor-input/editor-input.stories.tsx b/src/components/editor-input/editor-input.stories.tsx index 9fc8e7df..a51536c8 100644 --- a/src/components/editor-input/editor-input.stories.tsx +++ b/src/components/editor-input/editor-input.stories.tsx @@ -1,5 +1,44 @@ import EditorInput from './editor-input'; import type { Meta, StoryFn } from '@storybook/react-vite'; +import { useEffect, useRef, type ReactNode } from 'react'; +import { createRoot, type Root } from 'react-dom/client'; + +// Renders its children inside an open Shadow DOM root, the way a real consumer +// mounts the editor in a web component: a SEPARATE React root created on the +// shadow root via `createRoot(...).render()`. This is important for testing — +// unlike `createPortal`, a nested root keeps React's event delegation inside +// the shadow tree, so shadow-DOM event bugs actually reproduce here. Document +// stylesheets are cloned in so the editor is styled correctly. +const ShadowDom = ( { children }: { children: ReactNode } ) => { + const hostRef = useRef( null ); + const rootRef = useRef( null ); + + useEffect( () => { + const host = hostRef.current; + if ( ! host ) { + return; + } + const shadow = + host.shadowRoot ?? host.attachShadow( { mode: 'open' } ); + document + .querySelectorAll( 'style, link[rel="stylesheet"]' ) + .forEach( ( node ) => + shadow.appendChild( node.cloneNode( true ) ) + ); + const mountPoint = document.createElement( 'div' ); + shadow.appendChild( mountPoint ); + rootRef.current = createRoot( mountPoint ); + rootRef.current.render( children ); + return () => { + const root = rootRef.current; + rootRef.current = null; + // Defer unmount to avoid React's "synchronous unmount during render". + setTimeout( () => root?.unmount(), 0 ); + }; + }, [ children ] ); + + return
; +}; const meta: Meta = { title: 'Atoms/EditorInput', @@ -72,3 +111,18 @@ Large.args = { options, onChange: ( editorState ) => editorState.toJSON(), }; + +// Renders the editor inside a Shadow DOM to verify it works across the shadow +// boundary (fix from facebook/lexical PR #7790). +export const InsideShadowDom: Story = ( args ) => ( + + + +); +InsideShadowDom.args = { + size: 'md', + autoSpaceAfterMention: false, + autoFocus: false, + options, + onChange: ( editorState ) => editorState.toJSON(), +}; diff --git a/src/components/editor-input/mention-plugin/lexical-typeahead-menu.tsx b/src/components/editor-input/mention-plugin/lexical-typeahead-menu.tsx new file mode 100644 index 00000000..98599cc5 --- /dev/null +++ b/src/components/editor-input/mention-plugin/lexical-typeahead-menu.tsx @@ -0,0 +1,772 @@ +/** + * A custom port of `@lexical/react`'s LexicalTypeaheadMenuPlugin. + * + * Lexical 0.38 removed the `menuRenderFn` prop from the published + * `LexicalTypeaheadMenuPlugin`, so it always renders its own built-in menu. + * This component restores the `menuRenderFn` contract (as it existed in 0.31) + * so the mention plugin can keep rendering its custom `EditorCombobox` and + * honour the public `menuComponent` / `menuItemComponent` props. + * + * The trigger-matching, node-splitting, positioning and keyboard behaviour are + * ported faithfully from lexical 0.38's source; only the final render is + * delegated to the supplied `menuRenderFn`. Helpers that lexical still exports + * (`MenuOption`, `useDynamicPositioning`) are reused rather than re-copied. + */ +import { useLexicalComposerContext } from '@lexical/react/LexicalComposerContext'; +import { + MenuOption, + useDynamicPositioning, +} from '@lexical/react/LexicalTypeaheadMenuPlugin'; +import { mergeRegister } from '@lexical/utils'; +import { + $getSelection, + $isRangeSelection, + $isTextNode, + COMMAND_PRIORITY_LOW, + createCommand, + getDOMSelectionForEditor, + KEY_ARROW_DOWN_COMMAND, + KEY_ARROW_UP_COMMAND, + KEY_ENTER_COMMAND, + KEY_ESCAPE_COMMAND, + KEY_TAB_COMMAND, + type CommandListenerPriority, + type LexicalCommand, + type LexicalEditor, + type RangeSelection, + type TextNode, +} from 'lexical'; +import { + startTransition, + useCallback, + useEffect, + useLayoutEffect, + useRef, + useState, + type MutableRefObject, + type ReactNode, +} from 'react'; + +const CAN_USE_DOM = + typeof window !== 'undefined' && + typeof window.document !== 'undefined' && + typeof window.document.createElement !== 'undefined'; + +const useLayoutEffectImpl = CAN_USE_DOM ? useLayoutEffect : useEffect; + +export type MenuTextMatch = { + leadOffset: number; + matchingString: string; + replaceableString: string; +}; + +export type MenuResolution = { + match?: MenuTextMatch; + getRect: () => DOMRect; +}; + +export type TriggerFn = ( + text: string, + editor: LexicalEditor +) => MenuTextMatch | null; + +export type MenuRenderFn< TOption extends MenuOption > = ( + anchorElementRef: MutableRefObject< HTMLElement | null >, + itemProps: { + selectedIndex: number | null; + selectOptionAndCleanUp: ( option: TOption ) => void; + setHighlightedIndex: ( index: number ) => void; + }, + matchingString: string | null +) => ReactNode; + +const SCROLL_TYPEAHEAD_OPTION_INTO_VIEW_COMMAND: LexicalCommand< { + index: number; + option: MenuOption; +} > = createCommand( 'SCROLL_TYPEAHEAD_OPTION_INTO_VIEW_COMMAND' ); + +// Compute the next/previous highlighted index, wrapping at the list bounds. +function getNextSelectedIndex( + selectedIndex: number | null, + length: number +): number { + if ( selectedIndex === null ) { + return 0; + } + return selectedIndex !== length - 1 ? selectedIndex + 1 : 0; +} + +function getPrevSelectedIndex( + selectedIndex: number | null, + length: number +): number { + if ( selectedIndex === null ) { + return length - 1; + } + return selectedIndex !== 0 ? selectedIndex - 1 : length - 1; +} + +const scrollIntoViewIfNeeded = ( target: HTMLElement ) => { + // Scroll the highlighted option into view within its own scroll container + // (the menu has a max-height + overflow). The previous implementation + // looked up `#typeahead-menu` on `document`, which is null inside a Shadow + // DOM and made it bail before scrolling — so keyboard navigation could not + // reveal options below the fold. Scrolling the target directly works in + // both light and shadow DOM. + target.scrollIntoView( { block: 'nearest', inline: 'nearest' } ); +}; + +// Walk backwards along user input and forward through entity title to try +// and replace more of the user's text with entity. +function getFullMatchOffset( + documentText: string, + entryText: string, + offset: number +): number { + let triggerOffset = offset; + for ( let i = triggerOffset; i <= entryText.length; i++ ) { + if ( documentText.slice( -i ) === entryText.substring( 0, i ) ) { + triggerOffset = i; + } + } + return triggerOffset; +} + +// Split Lexical TextNode and return a new TextNode only containing matched text. +function $splitNodeContainingQuery( match: MenuTextMatch ): TextNode | null { + const selection = $getSelection(); + if ( ! $isRangeSelection( selection ) || ! selection.isCollapsed() ) { + return null; + } + const anchor = selection.anchor; + if ( anchor.type !== 'text' ) { + return null; + } + const anchorNode = anchor.getNode(); + if ( ! anchorNode.isSimpleText() ) { + return null; + } + const selectionOffset = anchor.offset; + const textContent = anchorNode + .getTextContent() + .slice( 0, selectionOffset ); + const characterOffset = match.replaceableString.length; + const queryOffset = getFullMatchOffset( + textContent, + match.matchingString, + characterOffset + ); + const startOffset = selectionOffset - queryOffset; + if ( startOffset < 0 ) { + return null; + } + let newNode; + if ( startOffset === 0 ) { + [ newNode ] = anchorNode.splitText( selectionOffset ); + } else { + [ , newNode ] = anchorNode.splitText( startOffset, selectionOffset ); + } + return newNode; +} + +function getTextUpToAnchor( selection: RangeSelection ): string | null { + const anchor = selection.anchor; + if ( anchor.type !== 'text' ) { + return null; + } + const anchorNode = anchor.getNode(); + if ( ! anchorNode.isSimpleText() ) { + return null; + } + const anchorOffset = anchor.offset; + return anchorNode.getTextContent().slice( 0, anchorOffset ); +} + +function tryToPositionRange( + leadOffset: number, + range: Range, + editor: LexicalEditor +): boolean { + const domSelection = getDOMSelectionForEditor( editor ); + if ( domSelection === null || ! domSelection.isCollapsed ) { + return false; + } + const anchorNode = domSelection.anchorNode; + const startOffset = leadOffset; + const endOffset = domSelection.anchorOffset; + if ( anchorNode === null || endOffset === null ) { + return false; + } + try { + range.setStart( anchorNode, startOffset ); + range.setEnd( anchorNode, endOffset ); + } catch { + return false; + } + return true; +} + +function getQueryTextForSearch( editor: LexicalEditor ): string | null { + let text: string | null = null; + editor.getEditorState().read( () => { + const selection = $getSelection(); + if ( ! $isRangeSelection( selection ) ) { + return; + } + text = getTextUpToAnchor( selection ); + } ); + return text; +} + +function isSelectionOnEntityBoundary( + editor: LexicalEditor, + offset: number +): boolean { + if ( offset !== 0 ) { + return false; + } + return editor.getEditorState().read( () => { + const selection = $getSelection(); + if ( $isRangeSelection( selection ) ) { + const anchor = selection.anchor; + const anchorNode = anchor.getNode(); + const prevSibling = anchorNode.getPreviousSibling(); + return ( + $isTextNode( prevSibling ) && prevSibling.isTextEntity() + ); + } + return false; + } ); +} + +function setContainerDivAttributes( + containerDiv: HTMLElement, + className?: string +) { + if ( className !== undefined ) { + containerDiv.className = className; + } + containerDiv.setAttribute( 'aria-label', 'Typeahead menu' ); + containerDiv.setAttribute( 'role', 'listbox' ); + containerDiv.style.display = 'block'; + containerDiv.style.position = 'absolute'; +} + +function useMenuAnchorRef( + resolution: MenuResolution | null, + setResolution: ( r: MenuResolution | null ) => void, + className?: string, + parent: HTMLElement | undefined = CAN_USE_DOM ? document.body : undefined, + shouldIncludePageYOffset = true +): MutableRefObject< HTMLElement | null > { + const [ editor ] = useLexicalComposerContext(); + const anchorElementRef = useRef< HTMLElement | null >( null ); + // Create the anchor element lazily, only once a menu actually has to be + // shown. Creating and appending it eagerly on every mount (as lexical + // 0.38 does) appends/removes a
on document.body for every editor + // instance, forcing style recalcs on heavy pages — very visible when a + // consumer mounts many editors or remounts them while typing. The element + // is created during render (lazy ref init) but only appended in + // positionMenu(), which runs from an effect. + if ( resolution !== null && anchorElementRef.current === null && CAN_USE_DOM ) { + anchorElementRef.current = document.createElement( 'div' ); + } + const positionMenu = useCallback( () => { + if ( anchorElementRef.current === null || parent === undefined ) { + return; + } + anchorElementRef.current.style.top = + anchorElementRef.current.style.bottom; + const rootElement = editor.getRootElement(); + const containerDiv = anchorElementRef.current; + const menuEle = containerDiv.firstChild as HTMLElement | null; + if ( rootElement !== null && resolution !== null ) { + const { left, top, width, height } = resolution.getRect(); + const anchorHeight = anchorElementRef.current.offsetHeight; + containerDiv.style.top = `${ + top + + anchorHeight + + 3 + + ( shouldIncludePageYOffset ? window.pageYOffset : 0 ) + }px`; + containerDiv.style.left = `${ left + window.pageXOffset }px`; + containerDiv.style.height = `${ height }px`; + containerDiv.style.width = `${ width }px`; + if ( menuEle !== null ) { + menuEle.style.top = `${ top }`; + const menuRect = menuEle.getBoundingClientRect(); + const menuHeight = menuRect.height; + const menuWidth = menuRect.width; + const rootElementRect = rootElement.getBoundingClientRect(); + if ( left + menuWidth > rootElementRect.right ) { + containerDiv.style.left = `${ + rootElementRect.right - menuWidth + window.pageXOffset + }px`; + } + if ( + ( top + menuHeight > window.innerHeight || + top + menuHeight > rootElementRect.bottom ) && + top - rootElementRect.top > menuHeight + height + ) { + containerDiv.style.top = `${ + top - + menuHeight - + height + + ( shouldIncludePageYOffset ? window.pageYOffset : 0 ) + }px`; + } + } + if ( ! containerDiv.isConnected ) { + setContainerDivAttributes( containerDiv, className ); + parent.append( containerDiv ); + } + containerDiv.setAttribute( 'id', 'typeahead-menu' ); + rootElement.setAttribute( 'aria-controls', 'typeahead-menu' ); + } + }, [ + editor, + resolution, + shouldIncludePageYOffset, + className, + parent, + ] ); + + useEffect( () => { + const rootElement = editor.getRootElement(); + if ( resolution !== null ) { + positionMenu(); + } + return () => { + if ( rootElement !== null ) { + rootElement.removeAttribute( 'aria-controls' ); + } + const containerDiv = anchorElementRef.current; + if ( containerDiv !== null && containerDiv.isConnected ) { + containerDiv.remove(); + containerDiv.removeAttribute( 'id' ); + } + }; + }, [ editor, positionMenu, resolution ] ); + + const onVisibilityChange = useCallback( + ( isInView: boolean ) => { + if ( resolution !== null ) { + if ( ! isInView ) { + setResolution( null ); + } + } + }, + [ resolution, setResolution ] + ); + + useDynamicPositioning( + resolution, + anchorElementRef.current, + positionMenu, + onVisibilityChange + ); + + return anchorElementRef; +} + +type LexicalMenuProps< TOption extends MenuOption > = { + close: () => void; + editor: LexicalEditor; + anchorElementRef: MutableRefObject< HTMLElement | null >; + resolution: MenuResolution; + options: Array< TOption >; + menuRenderFn: MenuRenderFn< TOption >; + onSelectOption: ( + option: TOption, + textNodeContainingQuery: TextNode | null, + closeMenu: () => void, + matchingString: string + ) => void; + shouldSplitNodeWithQuery?: boolean; + commandPriority?: CommandListenerPriority; + preselectFirstItem?: boolean; +}; + +function LexicalMenu< TOption extends MenuOption >( { + close, + editor, + anchorElementRef, + resolution, + options, + menuRenderFn, + onSelectOption, + shouldSplitNodeWithQuery = false, + commandPriority = COMMAND_PRIORITY_LOW, + preselectFirstItem = true, +}: LexicalMenuProps< TOption > ): ReactNode { + const [ rawSelectedIndex, setHighlightedIndex ] = useState< + number | null + >( null ); + const selectedIndex = + rawSelectedIndex !== null + ? Math.min( options.length - 1, rawSelectedIndex ) + : null; + const matchingString = + ( resolution.match && resolution.match.matchingString ) || null; + + useEffect( () => { + if ( preselectFirstItem ) { + setHighlightedIndex( 0 ); + } + }, [ matchingString, preselectFirstItem ] ); + + const selectOptionAndCleanUp = useCallback( + ( selectedEntry: TOption ) => { + editor.update( () => { + const textNodeContainingQuery = + resolution.match && shouldSplitNodeWithQuery + ? $splitNodeContainingQuery( resolution.match ) + : null; + onSelectOption( + selectedEntry, + textNodeContainingQuery, + close, + resolution.match ? resolution.match.matchingString : '' + ); + } ); + }, + [ + editor, + shouldSplitNodeWithQuery, + resolution.match, + onSelectOption, + close, + ] + ); + + const updateSelectedIndex = useCallback( + ( index: number ) => { + const rootElem = editor.getRootElement(); + if ( rootElem !== null ) { + rootElem.setAttribute( + 'aria-activedescendant', + 'typeahead-item-' + index + ); + setHighlightedIndex( index ); + } + }, + [ editor ] + ); + + useEffect( () => { + return () => { + const rootElem = editor.getRootElement(); + if ( rootElem !== null ) { + rootElem.removeAttribute( 'aria-activedescendant' ); + } + }; + }, [ editor ] ); + + useLayoutEffectImpl( () => { + if ( options === null ) { + setHighlightedIndex( null ); + } else if ( selectedIndex === null && preselectFirstItem ) { + updateSelectedIndex( 0 ); + } + }, [ options, selectedIndex, updateSelectedIndex, preselectFirstItem ] ); + + useEffect( () => { + return mergeRegister( + editor.registerCommand( + SCROLL_TYPEAHEAD_OPTION_INTO_VIEW_COMMAND, + ( { option } ) => { + if ( option.ref && option.ref.current !== null ) { + scrollIntoViewIfNeeded( option.ref.current ); + return true; + } + return false; + }, + commandPriority + ) + ); + }, [ editor, updateSelectedIndex, commandPriority ] ); + + useEffect( () => { + return mergeRegister( + editor.registerCommand( + KEY_ARROW_DOWN_COMMAND, + ( payload ) => { + const event = payload; + if ( options !== null && options.length ) { + const newSelectedIndex = getNextSelectedIndex( + selectedIndex, + options.length + ); + updateSelectedIndex( newSelectedIndex ); + const option = options[ newSelectedIndex ]; + if ( ! option ) { + updateSelectedIndex( -1 ); + event.preventDefault(); + event.stopImmediatePropagation(); + return true; + } + if ( option.ref && option.ref.current ) { + editor.dispatchCommand( + SCROLL_TYPEAHEAD_OPTION_INTO_VIEW_COMMAND, + { index: newSelectedIndex, option } + ); + } + event.preventDefault(); + event.stopImmediatePropagation(); + } + return true; + }, + commandPriority + ), + editor.registerCommand( + KEY_ARROW_UP_COMMAND, + ( payload ) => { + const event = payload; + if ( options !== null && options.length ) { + const newSelectedIndex = getPrevSelectedIndex( + selectedIndex, + options.length + ); + updateSelectedIndex( newSelectedIndex ); + const option = options[ newSelectedIndex ]; + if ( ! option ) { + updateSelectedIndex( -1 ); + event.preventDefault(); + event.stopImmediatePropagation(); + return true; + } + if ( option.ref && option.ref.current ) { + scrollIntoViewIfNeeded( option.ref.current ); + } + event.preventDefault(); + event.stopImmediatePropagation(); + } + return true; + }, + commandPriority + ), + editor.registerCommand( + KEY_ESCAPE_COMMAND, + ( payload ) => { + const event = payload; + event.preventDefault(); + event.stopImmediatePropagation(); + close(); + return true; + }, + commandPriority + ), + editor.registerCommand( + KEY_TAB_COMMAND, + ( payload ) => { + const event = payload; + if ( + options === null || + selectedIndex === null || + ! options[ selectedIndex ] + ) { + return false; + } + event.preventDefault(); + event.stopImmediatePropagation(); + selectOptionAndCleanUp( options[ selectedIndex ] ); + return true; + }, + commandPriority + ), + editor.registerCommand( + KEY_ENTER_COMMAND, + ( event ) => { + if ( + options === null || + selectedIndex === null || + ! options[ selectedIndex ] + ) { + return false; + } + if ( event !== null ) { + event.preventDefault(); + event.stopImmediatePropagation(); + } + selectOptionAndCleanUp( options[ selectedIndex ] ); + return true; + }, + commandPriority + ) + ); + }, [ + selectOptionAndCleanUp, + close, + editor, + options, + selectedIndex, + updateSelectedIndex, + commandPriority, + ] ); + + return menuRenderFn( + anchorElementRef, + { selectedIndex, selectOptionAndCleanUp, setHighlightedIndex }, + matchingString + ); +} + +export type TypeaheadMenuPluginProps< TOption extends MenuOption > = { + onQueryChange: ( matchingString: string | null ) => void; + onSelectOption: ( + option: TOption, + textNodeContainingQuery: TextNode | null, + closeMenu: () => void, + matchingString: string + ) => void; + options: Array< TOption >; + menuRenderFn: MenuRenderFn< TOption >; + triggerFn: TriggerFn; + onOpen?: ( resolution: MenuResolution ) => void; + onClose?: () => void; + anchorClassName?: string; + commandPriority?: CommandListenerPriority; + parent?: HTMLElement; + preselectFirstItem?: boolean; + ignoreEntityBoundary?: boolean; +}; + +export function LexicalTypeaheadMenuPlugin< TOption extends MenuOption >( { + options, + onQueryChange, + onSelectOption, + onOpen, + onClose, + menuRenderFn, + triggerFn, + anchorClassName, + commandPriority = COMMAND_PRIORITY_LOW, + parent, + preselectFirstItem = true, + ignoreEntityBoundary = false, +}: TypeaheadMenuPluginProps< TOption > ): ReactNode { + const [ editor ] = useLexicalComposerContext(); + const [ resolution, setResolution ] = useState< MenuResolution | null >( + null + ); + const anchorElementRef = useMenuAnchorRef( + resolution, + setResolution, + anchorClassName, + parent + ); + + const closeTypeahead = useCallback( () => { + setResolution( null ); + if ( onClose !== undefined && resolution !== null ) { + onClose(); + } + }, [ onClose, resolution ] ); + + const openTypeahead = useCallback( + ( res: MenuResolution ) => { + setResolution( res ); + if ( onOpen !== undefined && resolution === null ) { + onOpen( res ); + } + }, + [ onOpen, resolution ] + ); + + useEffect( () => { + const updateListener = () => { + editor.getEditorState().read( () => { + if ( ! editor.isEditable() ) { + closeTypeahead(); + return; + } + if ( editor.isComposing() ) { + return; + } + const editorWindow = + ( editor._window as Window | null ) || window; + const range = editorWindow.document.createRange(); + const selection = $getSelection(); + const text = getQueryTextForSearch( editor ); + if ( + ! $isRangeSelection( selection ) || + ! selection.isCollapsed() || + text === null || + range === null + ) { + closeTypeahead(); + return; + } + const match = triggerFn( text, editor ); + onQueryChange( match ? match.matchingString : null ); + if ( + match !== null && + ( ignoreEntityBoundary || + ! isSelectionOnEntityBoundary( + editor, + match.leadOffset + ) ) + ) { + const isRangePositioned = tryToPositionRange( + match.leadOffset, + range, + editor + ); + if ( isRangePositioned ) { + startTransition( () => + openTypeahead( { + getRect: () => + range.getBoundingClientRect(), + match, + } ) + ); + return; + } + } + closeTypeahead(); + } ); + }; + const removeUpdateListener = + editor.registerUpdateListener( updateListener ); + return () => { + removeUpdateListener(); + }; + }, [ + editor, + triggerFn, + onQueryChange, + resolution, + closeTypeahead, + openTypeahead, + ignoreEntityBoundary, + ] ); + + useEffect( + () => + editor.registerEditableListener( ( isEditable ) => { + if ( ! isEditable ) { + closeTypeahead(); + } + } ), + [ editor, closeTypeahead ] + ); + + return resolution === null || + editor === null || + anchorElementRef.current === null ? null : ( + + ); +} + +export { MenuOption }; diff --git a/src/components/editor-input/mention-plugin/mention-option-item.ts b/src/components/editor-input/mention-plugin/mention-option-item.ts index 172574f5..0081dab5 100644 --- a/src/components/editor-input/mention-plugin/mention-option-item.ts +++ b/src/components/editor-input/mention-plugin/mention-option-item.ts @@ -1,35 +1,24 @@ -// class OptionItem { -// data; -// ref = { current: null }; - -// constructor( data ) { -// this.data = data; -// } -// } - -// export default OptionItem; - import { MenuOption } from '@lexical/react/LexicalTypeaheadMenuPlugin'; -import React from 'react'; import { type TOptionItem } from '../editor-input'; -class OptionItem implements MenuOption { +class OptionItem extends MenuOption { data: TOptionItem; - key: TOptionItem extends Record - ? keyof TOptionItem - : string; - ref: React.RefObject; - setRefElement: ( element: HTMLLIElement ) => void; - constructor( public initData: TOptionItem ) { - this.key = ''; + constructor( + initData: TOptionItem, + by: keyof TOptionItem | string = 'name', + index?: number + ) { + const label = + typeof initData === 'string' + ? initData + : String( initData?.[ by as keyof TOptionItem ] ?? '' ); + // Each option needs a unique, stable key. Lexical's menu keys both the + // rendered list items and its internal ref/scroll map by this value, so + // duplicate keys break keyboard navigation, highlighting and selection. + // The index disambiguates options that share the same label. + super( index === undefined ? label : `${ label }-${ index }` ); this.data = initData; - this.ref = { current: null }; - - this.setRefElement = ( element: HTMLLIElement ) => { - ( this.ref as React.MutableRefObject ).current = - element; - }; } } diff --git a/src/components/editor-input/mention-plugin/mention-plugin.tsx b/src/components/editor-input/mention-plugin/mention-plugin.tsx index ab0cf29e..191aee9f 100644 --- a/src/components/editor-input/mention-plugin/mention-plugin.tsx +++ b/src/components/editor-input/mention-plugin/mention-plugin.tsx @@ -6,11 +6,11 @@ import React, { useRef, } from 'react'; import { useLexicalComposerContext } from '@lexical/react/LexicalComposerContext'; +import { type MenuOption } from '@lexical/react/LexicalTypeaheadMenuPlugin'; import { LexicalTypeaheadMenuPlugin, type TypeaheadMenuPluginProps, - type MenuOption, -} from '@lexical/react/LexicalTypeaheadMenuPlugin'; +} from './lexical-typeahead-menu'; import { $createMentionNode, $isMentionNode } from './mention-node'; import OptionItem from './mention-option-item'; import useMentionLookupService from './mention-hooks'; @@ -78,64 +78,71 @@ const MentionPlugin = ( { const autoSpaceTempOff = useRef( false ); const menuRef = useRef( null ); - // Define PUNCTUATION and other necessary variables inside the component - const PUNCTUATION = - '\\.,\\+\\*\\?\\$\\@\\|#{}\\(\\)\\^\\-\\[\\]\\\\/!%\'"~=<>_:;'; - const TRIGGERS = [ trigger ].join( '' ); // Use the trigger prop dynamically + // The match regexes only depend on the trigger, so build them (and the + // matcher) once per trigger instead of on every render — this runs on the + // editor's per-keystroke render path. + const checkForAtSignMentions = useMemo( () => { + const PUNCTUATION = + '\\.,\\+\\*\\?\\$\\@\\|#{}\\(\\)\\^\\-\\[\\]\\\\/!%\'"~=<>_:;'; - const VALID_CHARS = '[^' + TRIGGERS + PUNCTUATION + '\\s]'; + const TRIGGERS = [ trigger ].join( '' ); // Use the trigger prop dynamically - const VALID_JOINS = - '(?:' + - '\\.[ |$]|' + // E.g. "r. " in "Mr. Smith" - ' |' + // E.g. " " in "Josh Duck" - '[' + - PUNCTUATION + - ']|' + // E.g. "-' in "Salier-Hellendag" - ')'; + const VALID_CHARS = '[^' + TRIGGERS + PUNCTUATION + '\\s]'; - const LENGTH_LIMIT = 75; + const VALID_JOINS = + '(?:' + + '\\.[ |$]|' + // E.g. "r. " in "Mr. Smith" + ' |' + // E.g. " " in "Josh Duck" + '[' + + PUNCTUATION + + ']|' + // E.g. "-' in "Salier-Hellendag" + ')'; - const AtSignMentionsRegex = new RegExp( - `(^|\\s|\\()([${ TRIGGERS }]((?:${ VALID_CHARS }${ VALID_JOINS }){0,${ LENGTH_LIMIT }}))$` - ); + const LENGTH_LIMIT = 75; - // 50 is the longest alias length limit - const ALIAS_LENGTH_LIMIT = 50; + const AtSignMentionsRegex = new RegExp( + `(^|\\s|\\()([${ TRIGGERS }]((?:${ VALID_CHARS }${ VALID_JOINS }){0,${ LENGTH_LIMIT }}))$` + ); - // Regex used to match alias - const AtSignMentionsRegexAliasRegex = new RegExp( - `(^|\\s|\\()([${ TRIGGERS }]((?:${ VALID_CHARS }){0,${ ALIAS_LENGTH_LIMIT }}))$` - ); + // 50 is the longest alias length limit + const ALIAS_LENGTH_LIMIT = 50; - // Define checkForAtSignMentions function inside the component where it has access to the regex - const checkForAtSignMentions = ( text: string ) => { - let match = AtSignMentionsRegex.exec( text ); + // Regex used to match alias + const AtSignMentionsRegexAliasRegex = new RegExp( + `(^|\\s|\\()([${ TRIGGERS }]((?:${ VALID_CHARS }){0,${ ALIAS_LENGTH_LIMIT }}))$` + ); - if ( match === null ) { - match = AtSignMentionsRegexAliasRegex.exec( text ); - } - if ( match !== null ) { - // The strategy ignores leading whitespace but we need to know its - // length to add it to the leadOffset - const maybeLeadingWhitespace = match[ 1 ]; - - const matchingString = match[ 3 ]; - if ( matchingString.length >= 0 ) { - return { - leadOffset: match.index + maybeLeadingWhitespace.length, - matchingString, - replaceableString: match[ 2 ], - }; + return ( text: string ) => { + let match = AtSignMentionsRegex.exec( text ); + + if ( match === null ) { + match = AtSignMentionsRegexAliasRegex.exec( text ); } - } - return null; - }; + if ( match !== null ) { + // The strategy ignores leading whitespace but we need to know its + // length to add it to the leadOffset + const maybeLeadingWhitespace = match[ 1 ]; + + const matchingString = match[ 3 ]; + if ( matchingString.length >= 0 ) { + return { + leadOffset: match.index + maybeLeadingWhitespace.length, + matchingString, + replaceableString: match[ 2 ], + }; + } + } + return null; + }; + }, [ trigger ] ); const [ editor ] = useLexicalComposerContext(); const [ queryString, setQueryString ] = useState( null ); const [ isMenuOpen, setIsMenuOpen ] = useState( false ); + const [ menuParent, setMenuParent ] = useState( + undefined + ); // Use the hook to get lookup results const results = useMentionLookupService( optionsArray, queryString, by ); @@ -163,8 +170,10 @@ const MentionPlugin = ( { ); const options = useMemo( () => { - return results.map( ( result ) => new OptionItem( result ) ); - }, [ editor, results ] ); + return results.map( + ( result, index ) => new OptionItem( result, by, index ) + ); + }, [ results, by ] ); const handleAutoSpaceAfterMention = useCallback< CommandListener @@ -258,6 +267,32 @@ const MentionPlugin = ( { ); }, [ editor, handleAutoSpaceAfterMention ] ); + // When the editor is mounted inside a Shadow DOM, portal the typeahead menu + // into the same shadow root so the editor's (shadow-scoped) styles reach it. + // By default the menu is appended to document.body, where those styles never + // apply, leaving an unstyled list (visible bullets, no dropdown chrome). In + // regular light DOM we keep the default (undefined -> document.body). + useEffect( () => { + if ( ! editor ) { + return; + } + const updateMenuParent = () => { + const rootNode = editor.getRootElement()?.getRootNode(); + const nextParent = + rootNode instanceof ShadowRoot + ? ( rootNode as unknown as HTMLElement ) + : undefined; + // Functional update so an unchanged parent (the common case — the + // root listener also fires on registration) bails out instead of + // scheduling an extra commit. + setMenuParent( ( prev ) => + prev === nextParent ? prev : nextParent + ); + }; + updateMenuParent(); + return editor.registerRootListener( updateMenuParent ); + }, [ editor ] ); + // Set the floating reference to the editor input. useEffect( () => { if ( ! editor ) { @@ -285,17 +320,20 @@ const MentionPlugin = ( { } const handleOutsideClick = ( event: MouseEvent ) => { - const target = event.target as Node; const editorRoot = editor.getRootElement(); const floatingElement = refs.floating.current; - // Check if click is outside editor and dropdown menu - if ( - editorRoot && - ! editorRoot.contains( target ) && - floatingElement && - ! floatingElement.contains( target ) - ) { + // In a Shadow DOM, `event.target` on a document-level listener is + // retargeted to the shadow host, so `contains()` would report a + // click inside the menu as being outside it. Use the composed path, + // which crosses the shadow boundary, to find the real target. + const path = event.composedPath(); + const isInsideEditor = + !! editorRoot && path.includes( editorRoot ); + const isInsideMenu = + !! floatingElement && path.includes( floatingElement ); + + if ( ! isInsideEditor && ! isInsideMenu ) { setIsMenuOpen( false ); setQueryString( null ); } @@ -309,8 +347,14 @@ const MentionPlugin = ( { const floatingElement = refs.floating.current; if ( editorRoot ) { - const doc = editorRoot.ownerDocument; - const activeElement = doc.activeElement; + // In a Shadow DOM, `document.activeElement` resolves to the + // shadow host, not the focused element inside the tree, so + // read `activeElement` from the shadow root when present. + const rootNode = editorRoot.getRootNode(); + const activeElement = + rootNode instanceof ShadowRoot + ? rootNode.activeElement + : editorRoot.ownerDocument.activeElement; if ( floatingElement && @@ -348,6 +392,7 @@ const MentionPlugin = ( { onSelectOption={ onSelectOption } triggerFn={ checkForAtSignMentions } // Use the locally defined function options={ options } + parent={ menuParent } menuRenderFn={ ( anchorElementRef, { selectedIndex, selectOptionAndCleanUp, setHighlightedIndex } @@ -368,19 +413,40 @@ const MentionPlugin = ( { refs.setFloating( node ); menuRef.current = node; } } + // Prevent the contenteditable from blurring when the + // pointer lands anywhere in the menu (items or the + // surrounding padding). Without this the editor loses its + // selection and the mention can't be inserted — most + // visibly inside a Shadow DOM. + onMouseDown={ ( event: React.MouseEvent ) => + event.preventDefault() + } style={ { position: strategy, top: y ?? 0, - left: -2, - width: 'calc(100% + 4px)', + // Match the editor's width exactly: 100% of the + // editor wrapper, with border-box so the menu's own + // padding/border don't make it wider than the editor. + left: 0, + width: '100%', + boxSizing: 'border-box', } } > { options.map( ( option, index ) => ( + } size={ size } selected={ index === selectedIndex } + // Keep the editor's selection while clicking an + // option; without this the contenteditable blurs + // on mousedown and the query text node is gone by + // the time the mention is inserted. + onMouseDown={ ( event ) => + event.preventDefault() + } onMouseEnter={ () => { setHighlightedIndex( index ); } } diff --git a/src/components/line-chart/line-chart.tsx b/src/components/line-chart/line-chart.tsx index 982b8323..47dbc449 100644 --- a/src/components/line-chart/line-chart.tsx +++ b/src/components/line-chart/line-chart.tsx @@ -31,6 +31,9 @@ interface LineChartProps { /** An array of strings representing the keys to access data in each data object. Used for identifying different data series. */ dataKeys: string[]; + /** An object mapping data keys to display labels used as series names in the tooltip. Useful for translated or custom labels. E.g. `{ impressions: 'Impressionen' }`. Falls back to the data key when no label is provided. */ + seriesLabels?: Record; + /** An array of color objects that determine the stroke colors for each data series in the chart. */ colors?: Color[]; @@ -128,6 +131,7 @@ interface LineChartProps { const LineChart = ( { data, dataKeys = [], + seriesLabels, colors = [], showXAxis = false, showYAxis = false, @@ -261,6 +265,7 @@ const LineChart = ( { key={ key } type="monotone" dataKey={ key } + name={ seriesLabels?.[ key ] } stroke={ appliedColors[ index ].stroke } fill={ appliedColors[ index ].stroke } strokeWidth={ 2 } diff --git a/src/components/textarea/textarea.stories.tsx b/src/components/textarea/textarea.stories.tsx index 8e55b822..1af56557 100644 --- a/src/components/textarea/textarea.stories.tsx +++ b/src/components/textarea/textarea.stories.tsx @@ -12,6 +12,15 @@ const meta: Meta = { size: { control: 'select', }, + autoResize: { + control: 'boolean', + }, + minHeight: { + control: 'text', + }, + maxHeight: { + control: 'text', + }, }, }; @@ -60,3 +69,29 @@ Large.args = { error: false, defaultValue: 'Large TextArea', }; + +// Auto-resize TextArea Example +export const AutoResize = Template.bind( {} ); +AutoResize.args = { + size: 'md', + disabled: false, + error: false, + autoResize: true, + minHeight: 80, + maxHeight: 200, + defaultValue: + 'This textarea grows as you type. Try adding more lines of text to see the auto-resize in action.', +}; + +// Min/Max Height (no auto-resize) Example +export const WithMinMaxHeight = Template.bind( {} ); +WithMinMaxHeight.args = { + size: 'md', + disabled: false, + error: false, + autoResize: false, + minHeight: 120, + maxHeight: 240, + defaultValue: + 'Fixed height range — drag the corner grip to resize between minHeight and maxHeight.', +}; diff --git a/src/components/textarea/textarea.tsx b/src/components/textarea/textarea.tsx index 769e43f6..b09cf81b 100644 --- a/src/components/textarea/textarea.tsx +++ b/src/components/textarea/textarea.tsx @@ -1,6 +1,17 @@ -import { useState, useCallback, useMemo, forwardRef } from 'react'; +import { + useState, + useCallback, + useMemo, + useRef, + useLayoutEffect, + forwardRef, +} from 'react'; import { nanoid } from 'nanoid'; import { cn } from '@/utilities/functions'; +import { mergeRefs } from '@/components/toaster/utils'; + +const toCssSize = ( v: number | string | undefined ) => + typeof v === 'number' ? `${ v }px` : v; export interface TextAreaProps { /** ID of the textarea element. */ @@ -21,6 +32,12 @@ export interface TextAreaProps { error?: boolean; /** Callback triggered when the field is invalid. */ onError?: () => void; + /** When true, the textarea height auto-adjusts to fit its content. */ + autoResize?: boolean; + /** Minimum height of the textarea. Accepts a number (px) or any CSS length string (e.g. '10rem'). Applied regardless of autoResize. */ + minHeight?: number | string; + /** Maximum height of the textarea. When auto-resize reaches this value, the textarea becomes scrollable. Accepts a number (px) or any CSS length string. Applied regardless of autoResize. Defaults to 160px. */ + maxHeight?: number | string; } export const TextAreaComponent = ( @@ -34,10 +51,19 @@ export const TextAreaComponent = ( onChange = () => {}, error = false, onError = () => {}, + autoResize = false, + minHeight, + maxHeight = 160, + style: callerStyle, ...props - }: TextAreaProps, + }: TextAreaProps & + Omit< + React.TextareaHTMLAttributes, + 'size' | 'onChange' + >, ref: React.ForwardedRef ) => { + const internalRef = useRef( null ); const inputId = useMemo( () => id || `input-textarea-${ nanoid() }`, [ id ] ); const isControlled = useMemo( () => typeof value !== 'undefined', [ value ] ); const [ inputValue, setInputValue ] = useState( defaultValue ); @@ -47,6 +73,18 @@ export const TextAreaComponent = ( [ isControlled, value, inputValue ] ); + useLayoutEffect( () => { + if ( ! autoResize ) { + return; + } + const el = internalRef.current; + if ( ! el ) { + return; + } + el.style.height = 'auto'; + el.style.height = `${ el.scrollHeight }px`; + }, [ autoResize, getValue(), minHeight, maxHeight ] ); + const handleChange = ( event: React.ChangeEvent ) => { if ( disabled ) { return; @@ -83,9 +121,19 @@ export const TextAreaComponent = ( ? 'border-border-disabled bg-field-background-disabled cursor-not-allowed text-text-disabled' : ''; + const computedStyle: React.CSSProperties = { + ...( callerStyle ?? {} ), + minHeight: toCssSize( minHeight ), + maxHeight: toCssSize( maxHeight ), + ...( autoResize && { + resize: 'none', + overflow: maxHeight !== null ? 'auto' : 'hidden', + } ), + }; + return (