alinea 1.7.0 → 2.0.0-preview.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/.init/content/pages/welcome.json +1 -1
- package/dist/.init/src/app/(alinea)/api/cms/route.ts +8 -8
- package/dist/.init/src/cms.ts +45 -47
- package/dist/LICENSES.md +208 -560
- package/dist/adapter/core/cms.js +1 -1
- package/dist/adapter/core/handler.js +1 -1
- package/dist/adapter/core/preview.js +2 -2
- package/dist/adapter/core/previewContext.d.ts +1 -1
- package/dist/adapter/core/previewContext.js +1 -1
- package/dist/adapter/next/cms.d.ts +1 -1
- package/dist/adapter/next/cms.js +7 -7
- package/dist/adapter/next/context.js +1 -1
- package/dist/adapter/next/handler.d.ts +2 -4
- package/dist/adapter/next/handler.js +11 -5
- package/dist/adapter/next/previews.d.ts +2 -2
- package/dist/adapter/next/previews.js +13 -17
- package/dist/adapter/next/with-alinea.js +20 -10
- package/dist/adapter/vite/plugin.d.ts +2 -0
- package/dist/adapter/vite/plugin.js +66 -0
- package/dist/backend/Auth.js +1 -1
- package/dist/backend/HandleAction.d.ts +1 -0
- package/dist/backend/HandleAction.js +2 -1
- package/dist/backend/Handler.js +125 -17
- package/dist/backend/Previews.d.ts +2 -5
- package/dist/backend/api/BasicAuth.d.ts +2 -2
- package/dist/backend/api/BasicAuth.js +5 -3
- package/dist/backend/api/CreateBackend.d.ts +11 -2
- package/dist/backend/api/CreateBackend.js +45 -2502
- package/dist/backend/api/DatabaseApi.d.ts +8 -2
- package/dist/backend/api/DatabaseApi.js +252 -123
- package/dist/backend/api/GithubApi.d.ts +0 -4
- package/dist/backend/api/GithubApi.js +11 -7
- package/dist/backend/api/OAuth2.d.ts +3 -3
- package/dist/backend/api/OAuth2.js +36 -25
- package/dist/backend/api/S3Uploads.d.ts +32 -0
- package/dist/backend/api/S3Uploads.js +178 -0
- package/dist/backend/api/SupabaseUploads.d.ts +28 -0
- package/dist/backend/api/SupabaseUploads.js +41 -0
- package/dist/backend/api/UploadPaths.d.ts +7 -0
- package/dist/backend/api/UploadPaths.js +53 -0
- package/dist/backend/api/auth.d.ts +5 -0
- package/dist/backend/api/auth.js +15 -0
- package/dist/backend/api/database.d.ts +2 -0
- package/dist/backend/api/database.js +16 -0
- package/dist/backend/api/github.d.ts +3 -0
- package/dist/backend/api/github.js +10 -0
- package/dist/backend/api/uploads.d.ts +9 -0
- package/dist/backend/api/uploads.js +23 -0
- package/dist/backend/loader/JsonLoader.js +1 -1
- package/dist/backend/resolver/ParsePreview.js +2 -2
- package/dist/backend/router/NodeHandler.js +1 -1
- package/dist/backend/router/Router.js +32 -6
- package/dist/backend/store/GeneratedRelease.js +1 -1
- package/dist/backend/store/GeneratedSource.js +1 -1
- package/dist/backend/util/ExecGit.js +4 -4
- package/dist/backend/util/JWTPreviews.d.ts +3 -3
- package/dist/backend/util/JWTPreviews.js +19 -5
- package/dist/backend/util/JsonPatch.js +1 -1
- package/dist/backend/util/ORM.js +2 -2
- package/dist/backend/util/Syncable.js +2 -2
- package/dist/backend.d.ts +5 -0
- package/dist/backend.js +17 -0
- package/dist/bundled.d.ts +8233 -8178
- package/dist/chunks/chunk-53DZYORR.js +3705 -0
- package/dist/chunks/chunk-7ORQ7BYK.js +1187 -0
- package/dist/chunks/chunk-AC4U3IMS.js +205 -0
- package/dist/chunks/chunk-BYJRQTFR.js +57 -0
- package/dist/chunks/chunk-CQ52GEHY.js +39 -0
- package/dist/chunks/chunk-EQ3TDHYD.js +79 -0
- package/dist/chunks/chunk-F36YGSHN.js +335 -0
- package/dist/chunks/chunk-G6E35DMJ.js +1997 -0
- package/dist/chunks/chunk-I4GC3E65.js +170 -0
- package/dist/chunks/chunk-I4OYYAX5.js +63 -0
- package/dist/chunks/chunk-I7X64JTZ.js +10402 -0
- package/dist/chunks/chunk-IWN3T3FL.js +19493 -0
- package/dist/chunks/chunk-IYAQC63Y.js +1265 -0
- package/dist/chunks/chunk-JFROOUG6.js +6363 -0
- package/dist/chunks/chunk-LB3UYTOL.js +95 -0
- package/dist/chunks/chunk-LUBOGJCG.js +129 -0
- package/dist/chunks/chunk-NWQXN4SB.js +227 -0
- package/dist/chunks/chunk-RKDPDEF7.js +160 -0
- package/dist/chunks/chunk-SJBZFMQ2.js +2966 -0
- package/dist/chunks/chunk-STAJCW4Z.js +322 -0
- package/dist/chunks/chunk-TL7ZW6BX.js +17963 -0
- package/dist/chunks/chunk-U4VOHNR2.js +210 -0
- package/dist/chunks/chunk-U5Z2VE7Z.js +120 -0
- package/dist/chunks/chunk-X47OVDF3.js +1974 -0
- package/dist/chunks/chunk-Y7XOMJOC.js +791 -0
- package/dist/chunks/chunk-YK3OSMDM.js +5473 -0
- package/dist/chunks/crypto-UO2XRCJS.js +11 -0
- package/dist/cli/Generate.js +9 -4
- package/dist/cli/Init.js +1 -1
- package/dist/cli/Serve.d.ts +2 -2
- package/dist/cli/Serve.js +54 -100
- package/dist/cli/bin.js +85 -12
- package/dist/cli/build/BuildEmitter.js +1 -1
- package/dist/cli/build/BuildOptions.js +1 -1
- package/dist/cli/generate/CompileConfig.d.ts +1 -1
- package/dist/cli/generate/CompileConfig.js +1 -1
- package/dist/cli/generate/CopyStaticFiles.js +2 -1
- package/dist/cli/generate/DevDB.js +2 -8
- package/dist/cli/generate/FillCache.js +2 -2
- package/dist/cli/generate/GenerateDashboard.js +1 -1
- package/dist/cli/generate/LoadConfig.js +2 -3
- package/dist/cli/serve/CreateLocalServer.d.ts +1 -1
- package/dist/cli/serve/CreateLocalServer.js +81 -26
- package/dist/cli/serve/DevServer.d.ts +19 -0
- package/dist/cli/serve/DevServer.js +134 -0
- package/dist/cli/serve/GitHistory.d.ts +1 -2
- package/dist/cli/serve/GitHistory.js +15 -2
- package/dist/cli/serve/LiveReload.js +1 -1
- package/dist/cli/serve/LocalAuth.js +1 -1
- package/dist/cli/serve/MemoryDrafts.js +1 -1
- package/dist/cli/serve/StartServer.js +1 -1
- package/dist/cli/static/init/cms.js +45 -47
- package/dist/cli/static/init/next-handler.js +8 -8
- package/dist/cli/util/CommitMessage.js +1 -1
- package/dist/cli/util/CommitSha.js +1 -1
- package/dist/cli/util/Dirname.js +1 -1
- package/dist/cli/util/Emitter.js +1 -1
- package/dist/cli/util/EnsureEnv.js +1 -1
- package/dist/cli/util/EnsureLibs.js +1 -1
- package/dist/cli/util/EnsureNode.js +1 -1
- package/dist/cli/util/ExternalPlugin.js +595 -486
- package/dist/cli/util/FS.js +1 -1
- package/dist/cli/util/FindConfigFile.js +1 -1
- package/dist/cli/util/ForwardCommand.js +1 -1
- package/dist/cli/util/IgnorePlugin.js +1 -1
- package/dist/cli/util/PublicDefines.js +1 -1
- package/dist/cli/util/Report.js +1 -1
- package/dist/cli/util/ViewsPlugin.js +2 -2
- package/dist/cli/util/WarnPublicEnv.js +1 -1
- package/dist/cli/util/Watcher.js +1 -1
- package/dist/cloud/AuthResult.js +1 -1
- package/dist/cloud/CloudConfig.d.ts +1 -0
- package/dist/cloud/CloudConfig.js +2 -1
- package/dist/cloud/CloudRemote.d.ts +10 -4
- package/dist/cloud/CloudRemote.js +56 -9
- package/dist/components/Breadcrumbs.d.ts +3 -0
- package/dist/components/Breadcrumbs.js +42 -0
- package/dist/components/Button.d.ts +10 -0
- package/dist/components/Button.js +57 -0
- package/dist/components/Calendar.d.ts +3 -0
- package/dist/components/Calendar.js +94 -0
- package/dist/components/Checkbox.d.ts +9 -0
- package/dist/components/Checkbox.js +75 -0
- package/dist/components/CheckboxGroup.d.ts +6 -0
- package/dist/components/CheckboxGroup.js +45 -0
- package/dist/components/ColorSwatch.d.ts +2 -0
- package/dist/components/ColorSwatch.js +45 -0
- package/dist/components/ColorSwatchPicker.d.ts +3 -0
- package/dist/components/ColorSwatchPicker.js +66 -0
- package/dist/components/ComboBox.d.ts +13 -0
- package/dist/components/ComboBox.js +147 -0
- package/dist/components/DateField.d.ts +5 -0
- package/dist/components/DateField.js +61 -0
- package/dist/components/DatePicker.d.ts +5 -0
- package/dist/components/DatePicker.js +78 -0
- package/dist/components/DateRangePicker.d.ts +5 -0
- package/dist/components/DateRangePicker.js +95 -0
- package/dist/components/Dialog.d.ts +3 -0
- package/dist/components/Dialog.js +43 -0
- package/dist/components/Disclosure.d.ts +5 -0
- package/dist/components/Disclosure.js +106 -0
- package/dist/components/DropZone.d.ts +4 -0
- package/dist/components/DropZone.js +41 -0
- package/dist/components/FoldIcon.d.ts +6 -0
- package/dist/components/FoldIcon.js +31 -0
- package/dist/components/Icon.d.ts +7 -0
- package/dist/components/Icon.js +40 -0
- package/dist/components/Label.d.ts +48 -0
- package/dist/components/Label.js +210 -0
- package/dist/components/Link.d.ts +5 -0
- package/dist/components/Link.js +42 -0
- package/dist/components/List.d.ts +99 -0
- package/dist/components/List.js +397 -0
- package/dist/components/Menu.d.ts +16 -0
- package/dist/components/Menu.js +95 -0
- package/dist/components/Modal.d.ts +7 -0
- package/dist/components/Modal.js +58 -0
- package/dist/components/MultipleSelect.d.ts +25 -0
- package/dist/components/MultipleSelect.js +278 -0
- package/dist/components/NumberField.d.ts +6 -0
- package/dist/components/NumberField.js +90 -0
- package/dist/components/Popover.d.ts +6 -0
- package/dist/components/Popover.js +42 -0
- package/dist/components/ProgressCircle.d.ts +6 -0
- package/dist/components/ProgressCircle.js +96 -0
- package/dist/components/RadioGroup.d.ts +8 -0
- package/dist/components/RadioGroup.js +64 -0
- package/dist/components/SearchField.d.ts +8 -0
- package/dist/components/SearchField.js +86 -0
- package/dist/components/Select.d.ts +13 -0
- package/dist/components/Select.js +150 -0
- package/dist/components/Surface.d.ts +15 -0
- package/dist/components/Surface.js +53 -0
- package/dist/components/Switch.d.ts +5 -0
- package/dist/components/Switch.js +47 -0
- package/dist/components/Table.d.ts +14 -0
- package/dist/components/Table.js +147 -0
- package/dist/components/Tabs.d.ts +13 -0
- package/dist/components/Tabs.js +96 -0
- package/dist/components/TagGroup.d.ts +10 -0
- package/dist/components/TagGroup.js +81 -0
- package/dist/components/TextField.d.ts +13 -0
- package/dist/components/TextField.js +77 -0
- package/dist/components/TimeField.d.ts +5 -0
- package/dist/components/TimeField.js +55 -0
- package/dist/components/Toggle.d.ts +8 -0
- package/dist/components/Toggle.js +61 -0
- package/dist/components/Toolbar.d.ts +8 -0
- package/dist/components/Toolbar.js +80 -0
- package/dist/components/Tooltip.d.ts +7 -0
- package/dist/components/Tooltip.js +54 -0
- package/dist/components/Tree.d.ts +23 -0
- package/dist/components/Tree.js +130 -0
- package/dist/components.d.ts +38 -0
- package/dist/components.js +39 -0
- package/dist/config.js +1 -1
- package/dist/core/CMS.js +1 -1
- package/dist/core/Client.d.ts +11 -7
- package/dist/core/Client.js +53 -10
- package/dist/core/Config.d.ts +2 -0
- package/dist/core/Config.js +1 -3
- package/dist/core/Connection.d.ts +28 -9
- package/dist/core/Document.js +10 -8
- package/dist/core/Draft.js +1 -1
- package/dist/core/Entry.d.ts +6 -0
- package/dist/core/Entry.js +16 -1
- package/dist/core/EntryFields.d.ts +4 -0
- package/dist/core/EntryFields.js +4 -2
- package/dist/core/EntryRecord.js +1 -1
- package/dist/core/Expr.d.ts +1 -0
- package/dist/core/Expr.js +1 -1
- package/dist/core/Field.d.ts +46 -5
- package/dist/core/Field.js +56 -10
- package/dist/core/Graph.d.ts +6 -0
- package/dist/core/Graph.js +1 -1
- package/dist/core/HttpError.js +1 -1
- package/dist/core/Id.js +1 -1
- package/dist/core/Infer.d.ts +1 -1
- package/dist/core/Internal.js +6 -6
- package/dist/core/ListRow.d.ts +10 -0
- package/dist/core/ListRow.js +12 -0
- package/dist/core/Outcome.js +1 -1
- package/dist/core/Page.js +2 -2
- package/dist/core/Picker.d.ts +0 -2
- package/dist/core/Picker.js +1 -1
- package/dist/core/Reference.js +1 -1
- package/dist/core/Role.d.ts +3 -0
- package/dist/core/Role.js +7 -1
- package/dist/core/Root.d.ts +4 -0
- package/dist/core/Root.js +7 -2
- package/dist/core/Schema.d.ts +0 -2
- package/dist/core/Schema.js +2 -16
- package/dist/core/Scope.js +1 -1
- package/dist/core/Section.js +2 -2
- package/dist/core/TextDoc.d.ts +4 -0
- package/dist/core/TextDoc.js +3 -1
- package/dist/core/Tracker.d.ts +1 -6
- package/dist/core/Tracker.js +2 -12
- package/dist/core/Trigger.js +1 -1
- package/dist/core/Type.d.ts +15 -6
- package/dist/core/Type.js +108 -28
- package/dist/core/UnionRow.d.ts +11 -0
- package/dist/core/UnionRow.js +11 -0
- package/dist/core/User.d.ts +7 -1
- package/dist/core/User.js +1 -1
- package/dist/core/View.js +1 -1
- package/dist/core/Workspace.d.ts +4 -1
- package/dist/core/Workspace.js +1 -1
- package/dist/core/db/CommitRequest.d.ts +2 -0
- package/dist/core/db/CommitRequest.js +1 -1
- package/dist/core/db/EntryAliases.d.ts +2 -0
- package/dist/core/db/EntryAliases.js +28 -0
- package/dist/core/db/EntryDB.d.ts +2 -2
- package/dist/core/db/EntryDB.js +3 -3
- package/dist/core/db/EntryIndex.d.ts +7 -0
- package/dist/core/db/EntryIndex.js +168 -26
- package/dist/core/db/EntryReference.d.ts +44 -0
- package/dist/core/db/EntryReference.js +9 -0
- package/dist/core/db/EntryReferenceIndex.d.ts +21 -0
- package/dist/core/db/EntryReferenceIndex.js +131 -0
- package/dist/core/db/EntryResolver.d.ts +10 -7
- package/dist/core/db/EntryResolver.js +90 -35
- package/dist/core/db/EntryTransaction.d.ts +1 -1
- package/dist/core/db/EntryTransaction.js +395 -57
- package/dist/core/db/EntryUrlConflictError.d.ts +11 -0
- package/dist/core/db/EntryUrlConflictError.js +16 -0
- package/dist/core/db/IndexEvent.d.ts +5 -2
- package/dist/core/db/IndexEvent.js +2 -1
- package/dist/core/db/LinkResolver.d.ts +1 -1
- package/dist/core/db/LinkResolver.js +4 -1
- package/dist/core/db/LocalDB.d.ts +4 -2
- package/dist/core/db/LocalDB.js +8 -6
- package/dist/core/db/Mutation.d.ts +3 -3
- package/dist/core/db/Operation.d.ts +8 -3
- package/dist/core/db/Operation.js +67 -23
- package/dist/core/db/TestDB.d.ts +9 -1
- package/dist/core/db/TestDB.js +24 -1
- package/dist/core/db/WriteableGraph.d.ts +15 -4
- package/dist/core/db/WriteableGraph.js +14 -2
- package/dist/core/field/CreateField.d.ts +5 -4
- package/dist/core/field/CreateField.js +9 -5
- package/dist/core/field/ListField.d.ts +13 -4
- package/dist/core/field/ListField.js +146 -13
- package/dist/core/field/RecordField.d.ts +5 -3
- package/dist/core/field/RecordField.js +58 -2
- package/dist/core/field/RichTextField.d.ts +7 -2
- package/dist/core/field/RichTextField.js +325 -10
- package/dist/core/field/ScalarField.js +9 -7
- package/dist/core/field/UnionField.d.ts +2 -3
- package/dist/core/field/UnionField.js +61 -12
- package/dist/core/media/CreatePreview.browser.js +5 -5
- package/dist/core/media/CreatePreview.js +15 -10
- package/dist/core/media/IsImage.js +1 -1
- package/dist/core/media/MediaAltField.d.ts +9 -0
- package/dist/core/media/MediaAltField.js +17 -0
- package/dist/core/media/MediaLocation.d.ts +39 -0
- package/dist/core/media/MediaLocation.js +55 -2
- package/dist/core/media/MediaRoot.d.ts +2 -2
- package/dist/core/media/MediaRoot.js +12 -11
- package/dist/core/media/MediaTypes.d.ts +21 -15
- package/dist/core/media/MediaTypes.js +33 -16
- package/dist/core/media/Summary.d.ts +8 -8
- package/dist/core/media/Summary.js +1 -1
- package/dist/core/media/UploadLimits.d.ts +1 -0
- package/dist/core/media/UploadLimits.js +20 -0
- package/dist/core/pages/Snippet.js +1 -1
- package/dist/core/shape/ListShape.d.ts +1 -47
- package/dist/core/shape/ListShape.js +1 -224
- package/dist/core/source/CombinedSource.js +1 -1
- package/dist/core/source/FSSource.d.ts +3 -2
- package/dist/core/source/FSSource.js +25 -12
- package/dist/core/source/FilePatch.js +5 -2
- package/dist/core/source/GitDelta.js +1 -1
- package/dist/core/source/GitUtils.js +1 -1
- package/dist/core/source/GithubSource.d.ts +1 -0
- package/dist/core/source/GithubSource.js +17 -4
- package/dist/core/source/IndexedDBSource.js +23 -11
- package/dist/core/source/MemorySource.js +1 -1
- package/dist/core/source/ShaMismatchError.js +3 -1
- package/dist/core/source/Source.js +1 -1
- package/dist/core/source/SourceExport.js +3 -3
- package/dist/core/source/Tree.js +1 -1
- package/dist/core/source/Utils.js +2 -5
- package/dist/core/util/Anchors.d.ts +4 -0
- package/dist/core/util/Anchors.js +45 -0
- package/dist/core/util/ArrayBuffers.js +1 -1
- package/dist/core/util/Assert.js +1 -1
- package/dist/core/util/Async.js +1 -1
- package/dist/core/util/BufferToBase64.js +1 -1
- package/dist/core/util/Callable.js +1 -1
- package/dist/core/util/Checks.js +2 -2
- package/dist/core/util/CodeGen.js +3 -1
- package/dist/core/util/ContentHash.js +1 -1
- package/dist/core/util/Debounce.js +1 -1
- package/dist/core/util/DeepMap.d.ts +14 -0
- package/dist/core/util/DeepMap.js +75 -0
- package/dist/core/util/Encoding.js +1 -1
- package/dist/core/util/EntryFilenames.d.ts +0 -1
- package/dist/core/util/EntryFilenames.js +2 -6
- package/dist/core/util/EntryRows.js +1 -1
- package/dist/core/util/FractionalIndexing.js +1 -1
- package/dist/core/util/GetRandomColor.js +20 -20
- package/dist/core/util/Identifiers.js +1 -1
- package/dist/core/util/JWT.js +1 -1
- package/dist/core/util/Lazy.js +1 -1
- package/dist/core/util/LazyRecord.js +1 -1
- package/dist/core/util/Logger.js +2 -1
- package/dist/core/util/Objects.d.ts +1 -0
- package/dist/core/util/Objects.js +5 -1
- package/dist/core/util/Paths.js +2 -2
- package/dist/core/util/RowId.js +1 -1
- package/dist/core/util/Slugs.js +1 -1
- package/dist/core/util/Timer.js +1 -1
- package/dist/core/util/Types.js +1 -1
- package/dist/core/util/Urls.js +1 -1
- package/dist/core.d.ts +1 -0
- package/dist/core.js +2 -1
- package/dist/dashboard/App.css +319 -0
- package/dist/dashboard/App.d.ts +8 -8
- package/dist/dashboard/App.js +188 -142
- package/dist/dashboard/StoryProvider.d.ts +12 -0
- package/dist/dashboard/StoryProvider.js +82 -0
- package/dist/dashboard/ViewKeys.d.ts +26 -0
- package/dist/dashboard/ViewKeys.js +32 -0
- package/dist/dashboard/app/AccessDenied.d.ts +5 -0
- package/dist/dashboard/app/AccessDenied.js +53 -0
- package/dist/dashboard/app/ActivityStatus.d.ts +10 -0
- package/dist/dashboard/app/ActivityStatus.js +459 -0
- package/dist/dashboard/app/AlineaLogo.d.ts +4 -0
- package/dist/dashboard/app/AlineaLogo.js +26 -0
- package/dist/dashboard/app/AppShell.d.ts +4 -0
- package/dist/dashboard/app/AppShell.js +29 -0
- package/dist/dashboard/app/AuthView.d.ts +8 -0
- package/dist/dashboard/app/AuthView.js +111 -0
- package/dist/dashboard/app/Badge.d.ts +8 -0
- package/dist/dashboard/app/Badge.js +42 -0
- package/dist/dashboard/app/CompactField.d.ts +14 -0
- package/dist/dashboard/app/CompactField.js +178 -0
- package/dist/dashboard/app/DashboardErrorBoundary.d.ts +2 -0
- package/dist/dashboard/app/DashboardErrorBoundary.js +122 -0
- package/dist/dashboard/app/DashboardLayout.d.ts +18 -0
- package/dist/dashboard/app/DashboardLayout.js +88 -0
- package/dist/dashboard/app/DashboardMeta.d.ts +7 -0
- package/dist/dashboard/app/DashboardMeta.js +28 -0
- package/dist/dashboard/app/EditorBackButton.d.ts +5 -0
- package/dist/dashboard/app/EditorBackButton.js +33 -0
- package/dist/dashboard/app/EntryFields.d.ts +21 -0
- package/dist/dashboard/app/EntryFields.js +101 -0
- package/dist/dashboard/app/EntryHeader.d.ts +15 -0
- package/dist/dashboard/app/EntryHeader.js +452 -0
- package/dist/dashboard/app/EntryHeaderActions.d.ts +37 -0
- package/dist/dashboard/app/EntryHeaderActions.js +71 -0
- package/dist/dashboard/app/EntryReferences.d.ts +6 -0
- package/dist/dashboard/app/EntryReferences.js +209 -0
- package/dist/dashboard/app/EntrySidebar.d.ts +25 -0
- package/dist/dashboard/app/EntrySidebar.js +378 -0
- package/dist/dashboard/app/EntrySidebarPreview.d.ts +10 -0
- package/dist/dashboard/app/EntrySidebarPreview.js +260 -0
- package/dist/dashboard/app/EntrySidebarPreview.story.d.ts +1 -0
- package/dist/dashboard/app/EntrySidebarToggle.d.ts +6 -0
- package/dist/dashboard/app/EntrySidebarToggle.js +29 -0
- package/dist/dashboard/app/EntryTranslationBanner.d.ts +7 -0
- package/dist/dashboard/app/EntryTranslationBanner.js +60 -0
- package/dist/dashboard/app/Explorer.d.ts +41 -0
- package/dist/dashboard/app/Explorer.js +804 -0
- package/dist/dashboard/app/ExplorerCards.d.ts +12 -0
- package/dist/dashboard/app/ExplorerCards.js +389 -0
- package/dist/dashboard/app/ExplorerFileCard.d.ts +10 -0
- package/dist/dashboard/app/ExplorerFileCard.js +115 -0
- package/dist/dashboard/app/ExplorerList.d.ts +9 -0
- package/dist/dashboard/app/ExplorerList.js +165 -0
- package/dist/dashboard/app/ExplorerModal.d.ts +16 -0
- package/dist/dashboard/app/ExplorerModal.js +89 -0
- package/dist/dashboard/app/ExplorerPickerContent.d.ts +13 -0
- package/dist/dashboard/app/ExplorerPickerContent.js +114 -0
- package/dist/dashboard/app/ExplorerTable.d.ts +14 -0
- package/dist/dashboard/app/ExplorerTable.js +497 -0
- package/dist/dashboard/app/ExternalLinkPicker.d.ts +12 -0
- package/dist/dashboard/app/ExternalLinkPicker.js +97 -0
- package/dist/dashboard/app/ImagePicker.d.ts +6 -0
- package/dist/dashboard/app/ImagePicker.js +145 -0
- package/dist/dashboard/app/LinkPicker.d.ts +9 -0
- package/dist/dashboard/app/LinkPicker.js +317 -0
- package/dist/dashboard/app/LocaleMenu.d.ts +8 -0
- package/dist/dashboard/app/LocaleMenu.js +110 -0
- package/dist/dashboard/app/LogoShape.d.ts +8 -0
- package/dist/dashboard/app/LogoShape.js +60 -0
- package/dist/dashboard/app/SidebarTree.d.ts +37 -0
- package/dist/dashboard/app/SidebarTree.js +433 -0
- package/dist/dashboard/app/StatusBadge.d.ts +6 -0
- package/dist/dashboard/app/StatusBadge.js +26 -0
- package/dist/dashboard/app/ViewToggle.d.ts +7 -0
- package/dist/dashboard/app/ViewToggle.js +27 -0
- package/dist/dashboard/app/WorkspaceMenu.d.ts +24 -0
- package/dist/dashboard/app/WorkspaceMenu.js +264 -0
- package/dist/dashboard/app/WorkspaceMenu.stories.d.ts +5 -0
- package/dist/dashboard/app/WorkspaceRoots.d.ts +6 -0
- package/dist/dashboard/app/WorkspaceRoots.js +285 -0
- package/dist/dashboard/app/editor/FileEditor.d.ts +5 -0
- package/dist/dashboard/app/editor/FileEditor.js +190 -0
- package/dist/dashboard/app/editor/FilePreview.d.ts +13 -0
- package/dist/dashboard/app/editor/FilePreview.js +196 -0
- package/dist/dashboard/app/editor/MediaAltField.view.d.ts +5 -0
- package/dist/dashboard/app/editor/MediaAltField.view.js +98 -0
- package/dist/dashboard/app/modals/CreateEntry.d.ts +1 -0
- package/dist/dashboard/app/modals/CreateEntry.js +283 -0
- package/dist/dashboard/app/pages/EntryPage.d.ts +11 -0
- package/dist/dashboard/app/pages/EntryPage.js +354 -0
- package/dist/dashboard/app/pages/RootPage.d.ts +9 -0
- package/dist/dashboard/app/pages/RootPage.js +90 -0
- package/dist/dashboard/app/pages/UsersPage.d.ts +7 -0
- package/dist/dashboard/app/pages/UsersPage.js +552 -0
- package/dist/dashboard/app/ui/DashboardModal.d.ts +34 -0
- package/dist/dashboard/app/ui/DashboardModal.js +192 -0
- package/dist/dashboard/app/ui/Rail.d.ts +18 -0
- package/dist/dashboard/app/ui/Rail.js +41 -0
- package/dist/dashboard/app/ui/Sidebar.d.ts +15 -0
- package/dist/dashboard/app/ui/Sidebar.js +55 -0
- package/dist/dashboard/atoms/ReactiveNode.d.ts +41 -0
- package/dist/dashboard/atoms/ReactiveNode.js +248 -0
- package/dist/dashboard/atoms/activity.d.ts +48 -0
- package/dist/dashboard/atoms/activity.js +189 -0
- package/dist/dashboard/atoms/auth.d.ts +38 -0
- package/dist/dashboard/atoms/auth.js +106 -0
- package/dist/dashboard/atoms/config.d.ts +27 -0
- package/dist/dashboard/atoms/config.js +49 -0
- package/dist/dashboard/atoms/core.d.ts +15 -0
- package/dist/dashboard/atoms/core.js +37 -0
- package/dist/dashboard/atoms/create.d.ts +13 -0
- package/dist/dashboard/atoms/create.js +79 -0
- package/dist/dashboard/atoms/dashboard.d.ts +12 -0
- package/dist/dashboard/atoms/dashboard.js +71 -0
- package/dist/dashboard/atoms/editor.d.ts +80 -0
- package/dist/dashboard/atoms/editor.js +132 -0
- package/dist/dashboard/atoms/entry.d.ts +223 -0
- package/dist/dashboard/atoms/entry.js +609 -0
- package/dist/dashboard/atoms/explorer.d.ts +257 -0
- package/dist/dashboard/atoms/explorer.js +677 -0
- package/dist/dashboard/atoms/graph.d.ts +5 -0
- package/dist/dashboard/atoms/graph.js +62 -0
- package/dist/dashboard/atoms/link.d.ts +24 -0
- package/dist/dashboard/atoms/link.js +82 -0
- package/dist/dashboard/atoms/nav.d.ts +47 -0
- package/dist/dashboard/atoms/nav.js +220 -0
- package/dist/dashboard/atoms/preview.d.ts +4 -0
- package/dist/dashboard/atoms/preview.js +10 -0
- package/dist/dashboard/atoms/root.d.ts +88 -0
- package/dist/dashboard/atoms/root.js +444 -0
- package/dist/dashboard/atoms/upload.d.ts +9 -0
- package/dist/dashboard/atoms/upload.js +81 -0
- package/dist/dashboard/atoms/user.d.ts +9 -0
- package/dist/dashboard/atoms/user.js +75 -0
- package/dist/dashboard/atoms/utils.d.ts +17 -0
- package/dist/dashboard/atoms/utils.js +151 -0
- package/dist/dashboard/boot/ActivityEvent.d.ts +44 -0
- package/dist/dashboard/boot/ActivityEvent.js +14 -0
- package/dist/dashboard/boot/Boot.js +9 -5
- package/dist/dashboard/boot/BootDev.js +2 -1
- package/dist/dashboard/boot/BootProd.js +1 -1
- package/dist/dashboard/boot/DashboardWorker.d.ts +7 -7
- package/dist/dashboard/boot/DashboardWorker.js +370 -30
- package/dist/dashboard/boot/LoadWorker.js +6 -3
- package/dist/dashboard/boot/WorkerDB.d.ts +9 -2
- package/dist/dashboard/boot/WorkerDB.js +20 -3
- package/dist/dashboard/editor/UseField.d.ts +29 -10
- package/dist/dashboard/editor/UseField.js +27 -59
- package/dist/dashboard/fixture/cms.d.ts +116 -0
- package/dist/dashboard/fixture/cms.js +230 -0
- package/dist/dashboard/hook/UseEntryEditor.d.ts +25 -6
- package/dist/dashboard/hook/UseEntryEditor.js +34 -12
- package/dist/dashboard/hook/UseGraph.d.ts +3 -0
- package/dist/dashboard/hook/UseGraph.js +5 -5
- package/dist/dashboard/hook/UseLocale.d.ts +4 -1
- package/dist/dashboard/hook/UseLocale.js +5 -7
- package/dist/dashboard/hook/UseRoot.d.ts +7 -12
- package/dist/dashboard/hook/UseRoot.js +8 -5
- package/dist/dashboard/hook/UseWorkspace.d.ts +7 -9
- package/dist/dashboard/hook/UseWorkspace.js +5 -7
- package/dist/dashboard/hooks.d.ts +157 -0
- package/dist/dashboard/hooks.js +229 -0
- package/dist/dashboard/icons.d.ts +171 -0
- package/dist/dashboard/icons.js +2686 -0
- package/dist/dashboard/plugins/alineaFixturePlugin.d.ts +2 -0
- package/dist/dashboard/plugins/alineaFixturePlugin.js +200 -0
- package/dist/dashboard.d.ts +1 -2
- package/dist/dashboard.js +6 -2
- package/dist/edit.d.ts +1 -1
- package/dist/edit.js +2 -4
- package/dist/field/check/CheckField.js +3 -3
- package/dist/field/check/CheckField.view.d.ts +3 -3
- package/dist/field/check/CheckField.view.js +37 -84
- package/dist/field/code/CodeField.js +2 -2
- package/dist/field/code/CodeField.view.d.ts +21 -3
- package/dist/field/code/CodeField.view.js +177 -39
- package/dist/field/code/SimpleCodeEditor.d.ts +50 -0
- package/dist/field/code/SimpleCodeEditor.js +452 -0
- package/dist/field/date/DateField.js +3 -3
- package/dist/field/date/DateField.view.d.ts +3 -3
- package/dist/field/date/DateField.view.js +26 -26
- package/dist/field/hidden/HiddenField.js +2 -2
- package/dist/field/hidden/HiddenField.view.js +1 -1
- package/dist/field/json/JsonField.js +2 -2
- package/dist/field/json/JsonField.view.d.ts +4 -4
- package/dist/field/json/JsonField.view.js +53 -76
- package/dist/field/link/EntryLink.d.ts +9 -8
- package/dist/field/link/EntryLink.js +4 -2
- package/dist/field/link/FileLink.d.ts +5 -5
- package/dist/field/link/FileLink.js +7 -3
- package/dist/field/link/ImageLink.d.ts +4 -2
- package/dist/field/link/ImageLink.js +4 -1
- package/dist/field/link/Link.d.ts +1 -1
- package/dist/field/link/Link.js +1 -1
- package/dist/field/link/LinkEditor.d.ts +1 -1
- package/dist/field/link/LinkEditor.js +1 -1
- package/dist/field/link/LinkField.d.ts +5 -3
- package/dist/field/link/LinkField.js +56 -17
- package/dist/field/link/LinkField.stories.d.ts +11 -1
- package/dist/field/link/LinkField.view.d.ts +8 -10
- package/dist/field/link/LinkField.view.js +1444 -362
- package/dist/field/link/UrlLink.d.ts +2 -2
- package/dist/field/link/UrlLink.js +4 -2
- package/dist/field/list/ListField.d.ts +3 -3
- package/dist/field/list/ListField.js +5 -6
- package/dist/field/list/ListField.stories.d.ts +2 -1
- package/dist/field/list/ListField.view.d.ts +15 -7
- package/dist/field/list/ListField.view.js +888 -377
- package/dist/field/localiser/LocalisedField.view.d.ts +5 -0
- package/dist/field/localiser/LocalisedField.view.js +63 -0
- package/dist/field/localiser/LocalisedFieldTabs.d.ts +8 -0
- package/dist/field/localiser/LocalisedFieldTabs.js +38 -0
- package/dist/field/localiser/Localiser.d.ts +25 -0
- package/dist/field/localiser/Localiser.js +140 -0
- package/dist/field/localiser.d.ts +1 -0
- package/dist/field/localiser.js +2 -0
- package/dist/field/metadata/MetadataAliases.d.ts +20 -0
- package/dist/field/metadata/MetadataAliases.js +22 -0
- package/dist/field/metadata/MetadataField.d.ts +31 -8
- package/dist/field/metadata/MetadataField.js +127 -11
- package/dist/field/metadata/MetadataField.view.d.ts +11 -3
- package/dist/field/metadata/MetadataField.view.js +130 -96
- package/dist/field/number/NumberField.js +3 -3
- package/dist/field/number/NumberField.view.d.ts +3 -3
- package/dist/field/number/NumberField.view.js +22 -54
- package/dist/field/object/ObjectField.d.ts +1 -1
- package/dist/field/object/ObjectField.js +11 -4
- package/dist/field/object/ObjectField.view.d.ts +4 -4
- package/dist/field/object/ObjectField.view.js +28 -19
- package/dist/field/path/PathField.js +3 -3
- package/dist/field/path/PathField.view.d.ts +3 -3
- package/dist/field/path/PathField.view.js +33 -133
- package/dist/field/path/SlugField.d.ts +16 -0
- package/dist/field/path/SlugField.js +52 -0
- package/dist/field/richtext/Extensions.d.ts +1 -28
- package/dist/field/richtext/Extensions.js +2 -4146
- package/dist/field/richtext/PickTextAnchor.d.ts +19 -0
- package/dist/field/richtext/PickTextAnchor.js +99 -0
- package/dist/field/richtext/PickTextLink.d.ts +18 -17
- package/dist/field/richtext/PickTextLink.js +133 -88
- package/dist/field/richtext/ReferenceLink.d.ts +2 -0
- package/dist/field/richtext/ReferenceLink.js +13 -4
- package/dist/field/richtext/RichTextBlock.d.ts +11 -0
- package/dist/field/richtext/RichTextBlock.js +143 -0
- package/dist/field/richtext/RichTextBlockHost.d.ts +13 -0
- package/dist/field/richtext/RichTextBlockHost.js +56 -0
- package/dist/field/richtext/RichTextBlockValue.d.ts +5 -0
- package/dist/field/richtext/RichTextBlockValue.js +34 -0
- package/dist/field/richtext/RichTextBlocks.d.ts +16 -0
- package/dist/field/richtext/RichTextBlocks.js +40 -0
- package/dist/field/richtext/RichTextDocument.d.ts +4 -0
- package/dist/field/richtext/RichTextDocument.js +162 -0
- package/dist/field/richtext/RichTextExtensions.d.ts +67 -0
- package/dist/field/richtext/RichTextExtensions.js +8219 -0
- package/dist/field/richtext/RichTextField.d.ts +10 -3
- package/dist/field/richtext/RichTextField.js +13 -3
- package/dist/field/richtext/RichTextField.story.d.ts +8 -0
- package/dist/field/richtext/RichTextField.view.d.ts +11 -5
- package/dist/field/richtext/RichTextField.view.js +385 -2447
- package/dist/field/richtext/RichTextInsertMenu.d.ts +9 -0
- package/dist/field/richtext/RichTextInsertMenu.js +1014 -0
- package/dist/field/richtext/RichTextState.d.ts +6 -0
- package/dist/field/richtext/RichTextState.js +58 -0
- package/dist/field/richtext/RichTextToolbar.d.ts +9 -36
- package/dist/field/richtext/RichTextToolbar.js +206 -178
- package/dist/field/richtext/Toolbar.d.ts +111 -65
- package/dist/field/richtext/Toolbar.js +60 -45
- package/dist/field/richtext/extensions/Anchor.d.ts +19 -0
- package/dist/field/richtext/extensions/Anchor.js +94 -0
- package/dist/field/richtext/extensions/Link.d.ts +3 -13
- package/dist/field/richtext/extensions/Link.js +15 -37
- package/dist/field/richtext/extensions/Small.d.ts +1 -10
- package/dist/field/richtext/extensions/Small.js +7 -19
- package/dist/field/select/SelectField.d.ts +15 -4
- package/dist/field/select/SelectField.js +17 -2
- package/dist/field/select/SelectField.view.d.ts +7 -3
- package/dist/field/select/SelectField.view.js +112 -155
- package/dist/field/tabs/Tabs.js +3 -2
- package/dist/field/tabs/Tabs.view.d.ts +1 -6
- package/dist/field/tabs/Tabs.view.js +22 -29
- package/dist/field/text/TextField.js +8 -3
- package/dist/field/text/TextField.view.d.ts +2 -2
- package/dist/field/text/TextField.view.js +40 -60
- package/dist/field/time/TimeField.js +3 -3
- package/dist/field/time/TimeField.view.d.ts +3 -3
- package/dist/field/time/TimeField.view.js +30 -30
- package/dist/field/view/View.js +1 -1
- package/dist/field/views.d.ts +2 -0
- package/dist/field/views.js +65 -0
- package/dist/field.d.ts +1 -0
- package/dist/field.js +3 -1
- package/dist/index.css +7034 -3625
- package/dist/index.js +1 -1
- package/dist/inter-latin-500-normal-JSHNAZJU.woff2 +0 -0
- package/dist/inter-latin-ext-500-normal-5ARINTHO.woff2 +0 -0
- package/dist/next.cjs +19 -9
- package/dist/next.edge.js +1 -1
- package/dist/next.js +1 -1
- package/dist/picker/entry/EntryPicker.d.ts +9 -4
- package/dist/picker/entry/EntryPicker.js +97 -19
- package/dist/picker/entry/EntryReference.d.ts +4 -0
- package/dist/picker/entry/EntryReference.js +3 -1
- package/dist/picker/url/UrlPicker.js +2 -12
- package/dist/preview/ChunkCookieValue.js +1 -1
- package/dist/preview/PreviewCookies.js +1 -1
- package/dist/preview/PreviewMessage.js +1 -1
- package/dist/preview/PreviewPayload.js +237 -10
- package/dist/preview/RegisterPreview.js +1 -1
- package/dist/preview/react.js +10 -3
- package/dist/preview/widget.js +1 -1
- package/dist/query.d.ts +116 -92
- package/dist/query.js +7 -1
- package/dist/types.d.ts +1 -0
- package/dist/ui/Link.d.ts +6 -5
- package/dist/ui/Link.js +37 -13
- package/dist/ui/RichText.d.ts +37 -11
- package/dist/ui/RichText.js +81 -44
- package/dist/ui/Stack.d.ts +11 -22
- package/dist/ui/Stack.js +54 -67
- package/dist/ui/icons/IcAlignCenter.d.ts +4 -2
- package/dist/ui/icons/IcAlignCenter.js +6 -12
- package/dist/ui/icons/IcOutlineGridView.d.ts +3 -2
- package/dist/ui/icons/IcOutlineGridView.js +3 -11
- package/dist/ui/icons/IcOutlineSettings.d.ts +3 -2
- package/dist/ui/icons/IcOutlineSettings.js +3 -11
- package/dist/ui/icons/IcRoundAccountTree.d.ts +4 -2
- package/dist/ui/icons/IcRoundAccountTree.js +6 -22
- package/dist/ui/icons/IcRoundClose.d.ts +4 -2
- package/dist/ui/icons/IcRoundClose.js +6 -12
- package/dist/ui/icons/IcRoundCode.d.ts +4 -2
- package/dist/ui/icons/IcRoundCode.js +6 -12
- package/dist/ui/icons/IcRoundDateRange.d.ts +3 -2
- package/dist/ui/icons/IcRoundDateRange.js +3 -11
- package/dist/ui/icons/IcRoundDelete.d.ts +4 -2
- package/dist/ui/icons/IcRoundDelete.js +6 -12
- package/dist/ui/icons/IcRoundEdit.d.ts +4 -2
- package/dist/ui/icons/IcRoundEdit.js +6 -12
- package/dist/ui/icons/IcRoundFormatListNumbered.d.ts +3 -2
- package/dist/ui/icons/IcRoundFormatListNumbered.js +3 -11
- package/dist/ui/icons/IcRoundLink.d.ts +4 -2
- package/dist/ui/icons/IcRoundLink.js +6 -12
- package/dist/ui/icons/IcRoundOpenInNew.d.ts +4 -2
- package/dist/ui/icons/IcRoundOpenInNew.js +6 -12
- package/dist/ui/icons/IcRoundPanorama.d.ts +4 -2
- package/dist/ui/icons/IcRoundPanorama.js +6 -6
- package/dist/ui/icons/IcRoundRefresh.d.ts +3 -2
- package/dist/ui/icons/IcRoundRefresh.js +3 -11
- package/dist/ui/icons/IcRoundSave.d.ts +4 -2
- package/dist/ui/icons/IcRoundSave.js +6 -22
- package/dist/ui/icons/IcRoundSearch.d.ts +4 -2
- package/dist/ui/icons/IcRoundSearch.js +6 -12
- package/dist/ui/icons/IcRoundShare.d.ts +4 -2
- package/dist/ui/icons/IcRoundShare.js +6 -12
- package/dist/ui/icons/IcRoundSync.d.ts +4 -2
- package/dist/ui/icons/IcRoundSync.js +6 -22
- package/dist/ui/icons/MaterialSymbolsDatabase.d.ts +4 -2
- package/dist/ui/icons/MaterialSymbolsDatabase.js +6 -22
- package/dist/ui/icons/TableInsert.d.ts +4 -2
- package/dist/ui/icons/TableInsert.js +6 -12
- package/dist/ui/util/ImageBlurUrl.js +1 -1
- package/dist/ui.d.ts +0 -8
- package/dist/ui.js +0 -8
- package/package.json +49 -64
- package/dist/backend/router/Proxy.d.ts +0 -1
- package/dist/backend/router/Proxy.js +0 -32
- package/dist/chunks/chunk-2NTSADJL.js +0 -20
- package/dist/chunks/chunk-2STBQ2Y4.js +0 -166
- package/dist/chunks/chunk-2X5P2RZV.js +0 -94
- package/dist/chunks/chunk-3DIW62EI.js +0 -2900
- package/dist/chunks/chunk-3TNMMA3W.js +0 -249
- package/dist/chunks/chunk-467JA2PB.js +0 -29
- package/dist/chunks/chunk-5LTN67OE.js +0 -51
- package/dist/chunks/chunk-76QF5YTJ.js +0 -107
- package/dist/chunks/chunk-A5O3N2GS.js +0 -63
- package/dist/chunks/chunk-AICQFCVN.js +0 -19
- package/dist/chunks/chunk-AJJSW27C.js +0 -728
- package/dist/chunks/chunk-C53YJRET.js +0 -112
- package/dist/chunks/chunk-CKT37OYJ.js +0 -9
- package/dist/chunks/chunk-F2HHHLEQ.js +0 -72
- package/dist/chunks/chunk-FKWEJTSK.js +0 -16282
- package/dist/chunks/chunk-G2AFWRAD.js +0 -12
- package/dist/chunks/chunk-HSIHEWFC.js +0 -101
- package/dist/chunks/chunk-I26ZIF6Q.js +0 -360
- package/dist/chunks/chunk-JL5K3F7X.js +0 -1116
- package/dist/chunks/chunk-NZLE2WMY.js +0 -35
- package/dist/chunks/chunk-ORDS5C6Z.js +0 -83
- package/dist/chunks/chunk-PNILF4WM.js +0 -251
- package/dist/chunks/chunk-QUIANN6B.js +0 -8001
- package/dist/chunks/chunk-RSX2DILK.js +0 -335
- package/dist/chunks/chunk-SKF4L7JN.js +0 -401
- package/dist/chunks/chunk-SOTBYUJY.js +0 -120
- package/dist/chunks/chunk-TOJF2G3X.js +0 -96
- package/dist/chunks/chunk-TPUTTEHF.js +0 -3002
- package/dist/chunks/chunk-VUACWPFC.js +0 -892
- package/dist/chunks/chunk-WD7H5L2L.js +0 -168
- package/dist/chunks/chunk-WDCPVJJC.js +0 -341
- package/dist/chunks/chunk-WJ67RR7S.js +0 -554
- package/dist/chunks/chunk-WKC37UOZ.js +0 -143
- package/dist/chunks/chunk-WLKPH7JA.js +0 -2786
- package/dist/chunks/chunk-YWCPLD22.js +0 -2343
- package/dist/chunks/crypto-HZTUU327.js +0 -11
- package/dist/cloud/view/CloudAuth.browser.d.ts +0 -2
- package/dist/cloud/view/CloudAuth.browser.js +0 -111
- package/dist/cloud/view/CloudAuth.d.ts +0 -1
- package/dist/cloud/view/CloudAuth.js +0 -9
- package/dist/core/Doc.d.ts +0 -11
- package/dist/core/Doc.js +0 -44
- package/dist/core/Role.test.d.ts +0 -1
- package/dist/core/Shape.d.ts +0 -19
- package/dist/core/Trigger.test.d.ts +0 -1
- package/dist/core/Type.test.d.ts +0 -1
- package/dist/core/db/EntryIndex.test.d.ts +0 -1
- package/dist/core/db/EntryResolver.test.d.ts +0 -1
- package/dist/core/db/LocalDB.test.d.ts +0 -1
- package/dist/core/field/RichTextField.test.d.ts +0 -1
- package/dist/core/shape/ListShape.test.d.ts +0 -1
- package/dist/core/shape/RecordShape.d.ts +0 -26
- package/dist/core/shape/RecordShape.js +0 -102
- package/dist/core/shape/RecordShape.test.d.ts +0 -1
- package/dist/core/shape/RichTextShape.d.ts +0 -75
- package/dist/core/shape/RichTextShape.js +0 -435
- package/dist/core/shape/RichTextShape.test.d.ts +0 -1
- package/dist/core/shape/ScalarShape.d.ts +0 -20
- package/dist/core/shape/ScalarShape.js +0 -53
- package/dist/core/shape/ScalarShape.test.d.ts +0 -1
- package/dist/core/shape/UnionShape.d.ts +0 -34
- package/dist/core/shape/UnionShape.js +0 -141
- package/dist/core/shape/UnionShape.test.d.ts +0 -1
- package/dist/core/source/CombinedSource.test.d.ts +0 -1
- package/dist/core/source/FSSource.test.d.ts +0 -1
- package/dist/core/source/FilePatch.test.d.ts +0 -1
- package/dist/core/source/GitDelta.test.d.ts +0 -1
- package/dist/core/source/GitUtils.test.d.ts +0 -1
- package/dist/core/source/GithubSource.test.d.ts +0 -1
- package/dist/core/source/IndexedDBSource.test.d.ts +0 -1
- package/dist/core/source/MemorySource.test.d.ts +0 -1
- package/dist/core/source/SourceExport.test.d.ts +0 -1
- package/dist/core/source/Tree.test.d.ts +0 -1
- package/dist/core/source/Utils.test.d.ts +0 -1
- package/dist/core/util/CodeGen.test.d.ts +0 -1
- package/dist/core/util/EntryFilenames.test.d.ts +0 -1
- package/dist/core/util/JWT.test.d.ts +0 -1
- package/dist/core/util/Paths.test.d.ts +0 -1
- package/dist/core/util/Slugs.test.d.ts +0 -1
- package/dist/dashboard/DashboardNav.d.ts +0 -22
- package/dist/dashboard/DashboardNav.js +0 -44
- package/dist/dashboard/DashboardProvider.d.ts +0 -16
- package/dist/dashboard/DashboardProvider.js +0 -28
- package/dist/dashboard/Routes.d.ts +0 -111
- package/dist/dashboard/Routes.js +0 -78
- package/dist/dashboard/Welcome.d.ts +0 -1
- package/dist/dashboard/Welcome.js +0 -21
- package/dist/dashboard/atoms/DashboardAtoms.d.ts +0 -18
- package/dist/dashboard/atoms/DashboardAtoms.js +0 -86
- package/dist/dashboard/atoms/DbAtoms.d.ts +0 -5
- package/dist/dashboard/atoms/DbAtoms.js +0 -95
- package/dist/dashboard/atoms/Edits.d.ts +0 -31
- package/dist/dashboard/atoms/Edits.js +0 -93
- package/dist/dashboard/atoms/EntryAtoms.d.ts +0 -34
- package/dist/dashboard/atoms/EntryAtoms.js +0 -298
- package/dist/dashboard/atoms/EntryEditorAtoms.d.ts +0 -255
- package/dist/dashboard/atoms/EntryEditorAtoms.js +0 -629
- package/dist/dashboard/atoms/EntrySummaryAtoms.d.ts +0 -21
- package/dist/dashboard/atoms/EntrySummaryAtoms.js +0 -58
- package/dist/dashboard/atoms/ErrorAtoms.d.ts +0 -4
- package/dist/dashboard/atoms/ErrorAtoms.js +0 -18
- package/dist/dashboard/atoms/FormAtoms.d.ts +0 -56
- package/dist/dashboard/atoms/FormAtoms.js +0 -189
- package/dist/dashboard/atoms/LocationAtoms.d.ts +0 -25
- package/dist/dashboard/atoms/LocationAtoms.js +0 -104
- package/dist/dashboard/atoms/NavigationAtoms.d.ts +0 -38
- package/dist/dashboard/atoms/NavigationAtoms.js +0 -124
- package/dist/dashboard/atoms/PolicyAtom.d.ts +0 -6
- package/dist/dashboard/atoms/PolicyAtom.js +0 -29
- package/dist/dashboard/atoms/PreferencesAtoms.d.ts +0 -16
- package/dist/dashboard/atoms/PreferencesAtoms.js +0 -53
- package/dist/dashboard/atoms/RouterAtoms.d.ts +0 -78
- package/dist/dashboard/atoms/RouterAtoms.js +0 -161
- package/dist/dashboard/atoms/StyleAtoms.d.ts +0 -1
- package/dist/dashboard/atoms/StyleAtoms.js +0 -14
- package/dist/dashboard/atoms/YAtom.d.ts +0 -2
- package/dist/dashboard/atoms/YAtom.js +0 -24
- package/dist/dashboard/editor/DefaultViews.d.ts +0 -19
- package/dist/dashboard/editor/DefaultViews.js +0 -52
- package/dist/dashboard/editor/InputForm.d.ts +0 -26
- package/dist/dashboard/editor/InputForm.js +0 -53
- package/dist/dashboard/editor/ViewKeys.d.ts +0 -23
- package/dist/dashboard/editor/ViewKeys.js +0 -29
- package/dist/dashboard/hook/UseConfig.d.ts +0 -1
- package/dist/dashboard/hook/UseConfig.js +0 -12
- package/dist/dashboard/hook/UseDashboard.d.ts +0 -1
- package/dist/dashboard/hook/UseDashboard.js +0 -12
- package/dist/dashboard/hook/UseDb.d.ts +0 -2
- package/dist/dashboard/hook/UseDb.js +0 -14
- package/dist/dashboard/hook/UseDebounce.d.ts +0 -1
- package/dist/dashboard/hook/UseDebounce.js +0 -23
- package/dist/dashboard/hook/UseEntryLocation.d.ts +0 -1
- package/dist/dashboard/hook/UseEntryLocation.js +0 -12
- package/dist/dashboard/hook/UseEntrySummary.d.ts +0 -1
- package/dist/dashboard/hook/UseEntrySummary.js +0 -16
- package/dist/dashboard/hook/UseExplorer.d.ts +0 -14
- package/dist/dashboard/hook/UseExplorer.js +0 -13
- package/dist/dashboard/hook/UseFocusList.d.ts +0 -14
- package/dist/dashboard/hook/UseFocusList.js +0 -113
- package/dist/dashboard/hook/UseNav.d.ts +0 -10
- package/dist/dashboard/hook/UseNav.js +0 -12
- package/dist/dashboard/hook/UsePolicy.d.ts +0 -1
- package/dist/dashboard/hook/UsePolicy.js +0 -14
- package/dist/dashboard/hook/UsePreferences.d.ts +0 -6
- package/dist/dashboard/hook/UsePreferences.js +0 -30
- package/dist/dashboard/hook/UseSession.d.ts +0 -1
- package/dist/dashboard/hook/UseSession.js +0 -12
- package/dist/dashboard/hook/UseUploads.d.ts +0 -42
- package/dist/dashboard/hook/UseUploads.js +0 -91
- package/dist/dashboard/pages/ContentView.d.ts +0 -5
- package/dist/dashboard/pages/ContentView.js +0 -96
- package/dist/dashboard/util/Atoms.d.ts +0 -2
- package/dist/dashboard/util/Atoms.js +0 -21
- package/dist/dashboard/util/DebounceAtom.d.ts +0 -2
- package/dist/dashboard/util/DebounceAtom.js +0 -26
- package/dist/dashboard/util/HashRouter.d.ts +0 -1
- package/dist/dashboard/util/HashRouter.js +0 -2
- package/dist/dashboard/util/Head.d.ts +0 -2
- package/dist/dashboard/util/Head.js +0 -10
- package/dist/dashboard/util/KeepInView.d.ts +0 -2
- package/dist/dashboard/util/KeepInView.js +0 -19
- package/dist/dashboard/util/KeepPreviousData.d.ts +0 -9
- package/dist/dashboard/util/KeepPreviousData.js +0 -32
- package/dist/dashboard/util/Loader.d.ts +0 -17
- package/dist/dashboard/util/Loader.js +0 -31
- package/dist/dashboard/util/SuspenseBoundary.d.ts +0 -4
- package/dist/dashboard/util/SuspenseBoundary.js +0 -23
- package/dist/dashboard/util/WithResolvers.d.ts +0 -2
- package/dist/dashboard/util/WithResolvers.js +0 -16
- package/dist/dashboard/view/AlineaLogo.d.ts +0 -2
- package/dist/dashboard/view/AlineaLogo.js +0 -16
- package/dist/dashboard/view/Breadcrumbs.d.ts +0 -3
- package/dist/dashboard/view/Breadcrumbs.js +0 -33
- package/dist/dashboard/view/Create.d.ts +0 -13
- package/dist/dashboard/view/Create.js +0 -75
- package/dist/dashboard/view/EntryEdit.d.ts +0 -5
- package/dist/dashboard/view/EntryEdit.js +0 -222
- package/dist/dashboard/view/EntryTree.d.ts +0 -5
- package/dist/dashboard/view/EntryTree.js +0 -1463
- package/dist/dashboard/view/ErrorBoundary.d.ts +0 -6
- package/dist/dashboard/view/ErrorBoundary.js +0 -95
- package/dist/dashboard/view/IconButton.d.ts +0 -18
- package/dist/dashboard/view/IconButton.js +0 -51
- package/dist/dashboard/view/InputLabel.d.ts +0 -36
- package/dist/dashboard/view/InputLabel.js +0 -151
- package/dist/dashboard/view/MediaExplorer.d.ts +0 -7
- package/dist/dashboard/view/MediaExplorer.js +0 -121
- package/dist/dashboard/view/Modal.d.ts +0 -8
- package/dist/dashboard/view/Modal.js +0 -63
- package/dist/dashboard/view/PageHeader.d.ts +0 -5
- package/dist/dashboard/view/PageHeader.js +0 -26
- package/dist/dashboard/view/Preview.d.ts +0 -3
- package/dist/dashboard/view/Preview.js +0 -20
- package/dist/dashboard/view/RootOverview.d.ts +0 -5
- package/dist/dashboard/view/RootOverview.js +0 -46
- package/dist/dashboard/view/SearchBox.d.ts +0 -1
- package/dist/dashboard/view/SearchBox.js +0 -126
- package/dist/dashboard/view/Sidebar.d.ts +0 -21
- package/dist/dashboard/view/Sidebar.js +0 -312
- package/dist/dashboard/view/Toolbar.d.ts +0 -9
- package/dist/dashboard/view/Toolbar.js +0 -240
- package/dist/dashboard/view/Viewport.d.ts +0 -8
- package/dist/dashboard/view/Viewport.js +0 -69
- package/dist/dashboard/view/WorkspaceLabel.d.ts +0 -7
- package/dist/dashboard/view/WorkspaceLabel.js +0 -32
- package/dist/dashboard/view/diff/ChangeBox.d.ts +0 -14
- package/dist/dashboard/view/diff/ChangeBox.js +0 -36
- package/dist/dashboard/view/diff/DiffUtils.d.ts +0 -16
- package/dist/dashboard/view/diff/DiffUtils.js +0 -82
- package/dist/dashboard/view/diff/DiffUtils.test.d.ts +0 -1
- package/dist/dashboard/view/diff/EntryDiff.d.ts +0 -6
- package/dist/dashboard/view/diff/EntryDiff.js +0 -45
- package/dist/dashboard/view/diff/FieldDiff.d.ts +0 -10
- package/dist/dashboard/view/diff/FieldDiff.js +0 -51
- package/dist/dashboard/view/diff/FieldsDiff.d.ts +0 -7
- package/dist/dashboard/view/diff/FieldsDiff.js +0 -24
- package/dist/dashboard/view/diff/ListDiff.d.ts +0 -10
- package/dist/dashboard/view/diff/ListDiff.js +0 -32
- package/dist/dashboard/view/diff/RichTextDiff.d.ts +0 -11
- package/dist/dashboard/view/diff/RichTextDiff.js +0 -94
- package/dist/dashboard/view/diff/ScalarDiff.d.ts +0 -5
- package/dist/dashboard/view/diff/ScalarDiff.js +0 -1520
- package/dist/dashboard/view/entry/EditModeToggle.d.ts +0 -9
- package/dist/dashboard/view/entry/EditModeToggle.js +0 -51
- package/dist/dashboard/view/entry/EntryHeader.d.ts +0 -5
- package/dist/dashboard/view/entry/EntryHeader.js +0 -414
- package/dist/dashboard/view/entry/EntryHistory.d.ts +0 -2
- package/dist/dashboard/view/entry/EntryHistory.js +0 -78
- package/dist/dashboard/view/entry/EntryNotice.d.ts +0 -7
- package/dist/dashboard/view/entry/EntryNotice.js +0 -44
- package/dist/dashboard/view/entry/EntryPreview.d.ts +0 -10
- package/dist/dashboard/view/entry/EntryPreview.js +0 -44
- package/dist/dashboard/view/entry/EntrySummary.d.ts +0 -3
- package/dist/dashboard/view/entry/EntrySummary.js +0 -75
- package/dist/dashboard/view/entry/EntryTitle.d.ts +0 -7
- package/dist/dashboard/view/entry/EntryTitle.js +0 -64
- package/dist/dashboard/view/entry/FieldToolbar.d.ts +0 -11
- package/dist/dashboard/view/entry/FieldToolbar.js +0 -41
- package/dist/dashboard/view/entry/LangSwitch.d.ts +0 -7
- package/dist/dashboard/view/entry/LangSwitch.js +0 -110
- package/dist/dashboard/view/entry/NewEntry.d.ts +0 -4
- package/dist/dashboard/view/entry/NewEntry.js +0 -288
- package/dist/dashboard/view/entry/RootHeader.d.ts +0 -4
- package/dist/dashboard/view/entry/RootHeader.js +0 -61
- package/dist/dashboard/view/explorer/Explorer.d.ts +0 -24
- package/dist/dashboard/view/explorer/Explorer.js +0 -2230
- package/dist/dashboard/view/explorer/ExplorerItem.d.ts +0 -11
- package/dist/dashboard/view/explorer/ExplorerItem.js +0 -128
- package/dist/dashboard/view/explorer/ExplorerRow.d.ts +0 -15
- package/dist/dashboard/view/explorer/ExplorerRow.js +0 -73
- package/dist/dashboard/view/media/CardOverview.d.ts +0 -1
- package/dist/dashboard/view/media/CardOverview.js +0 -10
- package/dist/dashboard/view/media/FileEntry.d.ts +0 -6
- package/dist/dashboard/view/media/FileEntry.js +0 -223
- package/dist/dashboard/view/media/FileSummary.d.ts +0 -3
- package/dist/dashboard/view/media/FileSummary.js +0 -102
- package/dist/dashboard/view/media/FileUploadRow.d.ts +0 -2
- package/dist/dashboard/view/media/FileUploadRow.js +0 -53
- package/dist/dashboard/view/media/FileUploader.d.ts +0 -10
- package/dist/dashboard/view/media/FileUploader.js +0 -151
- package/dist/dashboard/view/media/MediaThumbnail.d.ts +0 -11
- package/dist/dashboard/view/media/MediaThumbnail.js +0 -55
- package/dist/dashboard/view/preview/BrowserPreview.d.ts +0 -12
- package/dist/dashboard/view/preview/BrowserPreview.js +0 -210
- package/dist/dashboard/view/sidebar/SidebarSettings.d.ts +0 -1
- package/dist/dashboard/view/sidebar/SidebarSettings.js +0 -192
- package/dist/field/check/CheckField.stories.d.ts +0 -5
- package/dist/field/code/CodeField.stories.d.ts +0 -5
- package/dist/field/date/DateField.stories.d.ts +0 -5
- package/dist/field/json/JsonField.stories.d.ts +0 -5
- package/dist/field/metadata/MetadataField.stories.d.ts +0 -5
- package/dist/field/number/NumberField.stories.d.ts +0 -5
- package/dist/field/object/ObjectField.stories.d.ts +0 -5
- package/dist/field/path/PathField.stories.d.ts +0 -5
- package/dist/field/richtext/RichText.stories.d.ts +0 -5
- package/dist/field/select/SelectField.stories.d.ts +0 -5
- package/dist/field/tabs/Tabs.stories.d.ts +0 -5
- package/dist/field/text/TextField.stories.d.ts +0 -5
- package/dist/field/time/TimeField.stories.d.ts +0 -5
- package/dist/picker/entry/EntryPicker.browser.d.ts +0 -7
- package/dist/picker/entry/EntryPicker.browser.js +0 -373
- package/dist/picker/entry/EntryPicker.stories.d.ts +0 -2
- package/dist/picker/entry/EntryPickerRow.d.ts +0 -5
- package/dist/picker/entry/EntryPickerRow.js +0 -24
- package/dist/picker/url/UrlPicker.browser.d.ts +0 -6
- package/dist/picker/url/UrlPicker.browser.js +0 -83
- package/dist/picker/url/UrlPicker.stories.d.ts +0 -5
- package/dist/picker/url/UrlPickerRow.d.ts +0 -5
- package/dist/picker/url/UrlPickerRow.js +0 -38
- package/dist/preview/ChunkCookieValue.test.d.ts +0 -1
- package/dist/preview/PreviewPayload.test.d.ts +0 -1
- package/dist/test/EntryFixture.d.ts +0 -30
- package/dist/test/EntryFixture.js +0 -91
- package/dist/test/broken-index.test.d.ts +0 -1
- package/dist/test/cms.d.ts +0 -17
- package/dist/test/cms.js +0 -38
- package/dist/test/drafts.test.d.ts +0 -1
- package/dist/test/example.d.ts +0 -137
- package/dist/test/example.js +0 -230
- package/dist/test/insert-order.test.d.ts +0 -1
- package/dist/test/links.test.d.ts +0 -1
- package/dist/test/locales.test.d.ts +0 -1
- package/dist/test/moves.test.d.ts +0 -1
- package/dist/test/mutate.test.d.ts +0 -1
- package/dist/test/query.test.d.ts +0 -1
- package/dist/test/renames.test.d.ts +0 -1
- package/dist/test/roles.test.d.ts +0 -1
- package/dist/test/schema/DemoHome.d.ts +0 -25
- package/dist/test/schema/DemoHome.js +0 -25
- package/dist/test/schema/DemoRecipe.d.ts +0 -14
- package/dist/test/schema/DemoRecipe.js +0 -22
- package/dist/test/schema/DemoRecipes.d.ts +0 -4
- package/dist/test/schema/DemoRecipes.js +0 -14
- package/dist/test/schema/index.d.ts +0 -3
- package/dist/test/schema/index.js +0 -4
- package/dist/test/seeding.test.d.ts +0 -1
- package/dist/test/shared.test.d.ts +0 -1
- package/dist/test/status.test.d.ts +0 -1
- package/dist/test/uploads.test.d.ts +0 -1
- package/dist/ui/AppBar.d.ts +0 -14
- package/dist/ui/AppBar.js +0 -68
- package/dist/ui/Avatar.d.ts +0 -6
- package/dist/ui/Avatar.js +0 -33
- package/dist/ui/Badge.d.ts +0 -9
- package/dist/ui/Badge.js +0 -44
- package/dist/ui/Button.d.ts +0 -9
- package/dist/ui/Button.js +0 -57
- package/dist/ui/Button.stories.d.ts +0 -6
- package/dist/ui/Chip.d.ts +0 -8
- package/dist/ui/Chip.js +0 -46
- package/dist/ui/DropdownMenu.d.ts +0 -12
- package/dist/ui/DropdownMenu.js +0 -415
- package/dist/ui/Ellipsis.d.ts +0 -2
- package/dist/ui/Ellipsis.js +0 -33
- package/dist/ui/ErrorMessage.d.ts +0 -4
- package/dist/ui/ErrorMessage.js +0 -17
- package/dist/ui/Icon.d.ts +0 -9
- package/dist/ui/Icon.js +0 -41
- package/dist/ui/Lift.d.ts +0 -3
- package/dist/ui/Lift.js +0 -22
- package/dist/ui/Loader.d.ts +0 -8
- package/dist/ui/Loader.js +0 -32
- package/dist/ui/Main.d.ts +0 -12
- package/dist/ui/Main.js +0 -56
- package/dist/ui/Pane.d.ts +0 -9
- package/dist/ui/Pane.js +0 -132
- package/dist/ui/PopoverMenu.d.ts +0 -12
- package/dist/ui/PopoverMenu.js +0 -418
- package/dist/ui/Property.d.ts +0 -1
- package/dist/ui/Property.js +0 -7
- package/dist/ui/Sink.d.ts +0 -9
- package/dist/ui/Sink.js +0 -49
- package/dist/ui/Statusbar.d.ts +0 -15
- package/dist/ui/Statusbar.js +0 -54
- package/dist/ui/Tabs.d.ts +0 -11
- package/dist/ui/Tabs.js +0 -293
- package/dist/ui/TextLabel.d.ts +0 -5
- package/dist/ui/TextLabel.js +0 -10
- package/dist/ui/Typo.d.ts +0 -35
- package/dist/ui/Typo.js +0 -28
- package/dist/ui/UIStory.d.ts +0 -8
- package/dist/ui/branding/FavIcon.d.ts +0 -5
- package/dist/ui/branding/FavIcon.js +0 -56
- package/dist/ui/branding/LogoShape.d.ts +0 -6
- package/dist/ui/branding/LogoShape.js +0 -52
- package/dist/ui/hook/UseAutoHide.d.ts +0 -8
- package/dist/ui/hook/UseAutoHide.js +0 -43
- package/dist/ui/hook/UseColorScheme.d.ts +0 -4
- package/dist/ui/hook/UseColorScheme.js +0 -13
- package/dist/ui/hook/UseContrastColor.d.ts +0 -1
- package/dist/ui/hook/UseContrastColor.js +0 -12
- package/dist/ui/hook/UseElementSize.d.ts +0 -6
- package/dist/ui/hook/UseElementSize.js +0 -52
- package/dist/ui/hook/UseForceUpdate.d.ts +0 -1
- package/dist/ui/hook/UseForceUpdate.js +0 -11
- package/dist/ui/hook/UseHash.d.ts +0 -1
- package/dist/ui/hook/UseHash.js +0 -24
- package/dist/ui/hook/UseInitialEffect.d.ts +0 -2
- package/dist/ui/hook/UseInitialEffect.js +0 -15
- package/dist/ui/hook/UseLocalStorage.d.ts +0 -1
- package/dist/ui/hook/UseLocalStorage.js +0 -36
- package/dist/ui/hook/UseNonInitialEffect.d.ts +0 -2
- package/dist/ui/hook/UseNonInitialEffect.js +0 -17
- package/dist/ui/hook/UseTrigger.d.ts +0 -7
- package/dist/ui/hook/UseTrigger.js +0 -29
- package/dist/ui/icons/IcAlignJustify.d.ts +0 -3
- package/dist/ui/icons/IcAlignJustify.js +0 -18
- package/dist/ui/icons/IcAlignLeft.d.ts +0 -2
- package/dist/ui/icons/IcAlignLeft.js +0 -16
- package/dist/ui/icons/IcAlignRight.d.ts +0 -2
- package/dist/ui/icons/IcAlignRight.js +0 -16
- package/dist/ui/icons/IcBaselineAccountCircle.d.ts +0 -2
- package/dist/ui/icons/IcBaselineAccountCircle.js +0 -26
- package/dist/ui/icons/IcBaselineContentCopy.d.ts +0 -2
- package/dist/ui/icons/IcBaselineContentCopy.js +0 -26
- package/dist/ui/icons/IcBaselineContentPasteGo.d.ts +0 -2
- package/dist/ui/icons/IcBaselineContentPasteGo.js +0 -35
- package/dist/ui/icons/IcBaselineDesktopMac.d.ts +0 -2
- package/dist/ui/icons/IcBaselineDesktopMac.js +0 -16
- package/dist/ui/icons/IcBaselineErrorOutline.d.ts +0 -2
- package/dist/ui/icons/IcBaselineErrorOutline.js +0 -26
- package/dist/ui/icons/IcBaselinePause.d.ts +0 -2
- package/dist/ui/icons/IcBaselinePause.js +0 -20
- package/dist/ui/icons/IcBaselinePhoneIphone.d.ts +0 -2
- package/dist/ui/icons/IcBaselinePhoneIphone.js +0 -16
- package/dist/ui/icons/IcBaselineWifiTethering.d.ts +0 -2
- package/dist/ui/icons/IcBaselineWifiTethering.js +0 -26
- package/dist/ui/icons/IcOutlineArchive.d.ts +0 -2
- package/dist/ui/icons/IcOutlineArchive.js +0 -26
- package/dist/ui/icons/IcOutlineArrowCircleRight.d.ts +0 -2
- package/dist/ui/icons/IcOutlineArrowCircleRight.js +0 -16
- package/dist/ui/icons/IcOutlineAvTimer.d.ts +0 -2
- package/dist/ui/icons/IcOutlineAvTimer.js +0 -26
- package/dist/ui/icons/IcOutlineCloudUpload.d.ts +0 -2
- package/dist/ui/icons/IcOutlineCloudUpload.js +0 -26
- package/dist/ui/icons/IcOutlineDarkMode.d.ts +0 -2
- package/dist/ui/icons/IcOutlineDarkMode.js +0 -16
- package/dist/ui/icons/IcOutlineDescription.d.ts +0 -2
- package/dist/ui/icons/IcOutlineDescription.js +0 -26
- package/dist/ui/icons/IcOutlineDrafts.d.ts +0 -2
- package/dist/ui/icons/IcOutlineDrafts.js +0 -26
- package/dist/ui/icons/IcOutlineFolder.d.ts +0 -2
- package/dist/ui/icons/IcOutlineFolder.js +0 -26
- package/dist/ui/icons/IcOutlineInsertDriveFile.d.ts +0 -2
- package/dist/ui/icons/IcOutlineInsertDriveFile.js +0 -26
- package/dist/ui/icons/IcOutlineKeyboardTab.d.ts +0 -2
- package/dist/ui/icons/IcOutlineKeyboardTab.js +0 -26
- package/dist/ui/icons/IcOutlineLightMode.d.ts +0 -2
- package/dist/ui/icons/IcOutlineLightMode.js +0 -16
- package/dist/ui/icons/IcOutlineList.d.ts +0 -3
- package/dist/ui/icons/IcOutlineList.js +0 -18
- package/dist/ui/icons/IcOutlineLock.d.ts +0 -2
- package/dist/ui/icons/IcOutlineLock.js +0 -26
- package/dist/ui/icons/IcOutlineMoreHoriz.d.ts +0 -3
- package/dist/ui/icons/IcOutlineMoreHoriz.js +0 -18
- package/dist/ui/icons/IcOutlinePreview.d.ts +0 -2
- package/dist/ui/icons/IcOutlinePreview.js +0 -16
- package/dist/ui/icons/IcOutlineRemoveRedEye.d.ts +0 -2
- package/dist/ui/icons/IcOutlineRemoveRedEye.js +0 -26
- package/dist/ui/icons/IcOutlineScreenshot.d.ts +0 -2
- package/dist/ui/icons/IcOutlineScreenshot.js +0 -16
- package/dist/ui/icons/IcOutlineTableRows.d.ts +0 -2
- package/dist/ui/icons/IcOutlineTableRows.js +0 -26
- package/dist/ui/icons/IcRoundAdd.d.ts +0 -2
- package/dist/ui/icons/IcRoundAdd.js +0 -16
- package/dist/ui/icons/IcRoundAddCircle.d.ts +0 -3
- package/dist/ui/icons/IcRoundAddCircle.js +0 -18
- package/dist/ui/icons/IcRoundAddCircleOutline.d.ts +0 -2
- package/dist/ui/icons/IcRoundAddCircleOutline.js +0 -16
- package/dist/ui/icons/IcRoundArchive.d.ts +0 -2
- package/dist/ui/icons/IcRoundArchive.js +0 -16
- package/dist/ui/icons/IcRoundArrowBack.d.ts +0 -2
- package/dist/ui/icons/IcRoundArrowBack.js +0 -16
- package/dist/ui/icons/IcRoundArrowDownward.d.ts +0 -2
- package/dist/ui/icons/IcRoundArrowDownward.js +0 -26
- package/dist/ui/icons/IcRoundArrowDropDown.d.ts +0 -3
- package/dist/ui/icons/IcRoundArrowDropDown.js +0 -18
- package/dist/ui/icons/IcRoundArrowDropDownCircle.d.ts +0 -3
- package/dist/ui/icons/IcRoundArrowDropDownCircle.js +0 -18
- package/dist/ui/icons/IcRoundArrowDropUp.d.ts +0 -3
- package/dist/ui/icons/IcRoundArrowDropUp.js +0 -18
- package/dist/ui/icons/IcRoundArrowForward.d.ts +0 -2
- package/dist/ui/icons/IcRoundArrowForward.js +0 -16
- package/dist/ui/icons/IcRoundArrowUpward.d.ts +0 -2
- package/dist/ui/icons/IcRoundArrowUpward.js +0 -26
- package/dist/ui/icons/IcRoundAttachFile.d.ts +0 -2
- package/dist/ui/icons/IcRoundAttachFile.js +0 -10
- package/dist/ui/icons/IcRoundCheck.d.ts +0 -2
- package/dist/ui/icons/IcRoundCheck.js +0 -16
- package/dist/ui/icons/IcRoundCheckBox.d.ts +0 -2
- package/dist/ui/icons/IcRoundCheckBox.js +0 -16
- package/dist/ui/icons/IcRoundCheckBoxOutlineBlank.d.ts +0 -2
- package/dist/ui/icons/IcRoundCheckBoxOutlineBlank.js +0 -16
- package/dist/ui/icons/IcRoundChevronRight.d.ts +0 -2
- package/dist/ui/icons/IcRoundChevronRight.js +0 -26
- package/dist/ui/icons/IcRoundDescription.d.ts +0 -2
- package/dist/ui/icons/IcRoundDescription.js +0 -26
- package/dist/ui/icons/IcRoundDragHandle.d.ts +0 -3
- package/dist/ui/icons/IcRoundDragHandle.js +0 -18
- package/dist/ui/icons/IcRoundExitToApp.d.ts +0 -2
- package/dist/ui/icons/IcRoundExitToApp.js +0 -26
- package/dist/ui/icons/IcRoundFeed.d.ts +0 -2
- package/dist/ui/icons/IcRoundFeed.js +0 -16
- package/dist/ui/icons/IcRoundFormatBold.d.ts +0 -3
- package/dist/ui/icons/IcRoundFormatBold.js +0 -18
- package/dist/ui/icons/IcRoundFormatClear.d.ts +0 -3
- package/dist/ui/icons/IcRoundFormatClear.js +0 -18
- package/dist/ui/icons/IcRoundFormatItalic.d.ts +0 -3
- package/dist/ui/icons/IcRoundFormatItalic.js +0 -18
- package/dist/ui/icons/IcRoundFormatListBulleted.d.ts +0 -3
- package/dist/ui/icons/IcRoundFormatListBulleted.js +0 -18
- package/dist/ui/icons/IcRoundFormatPaint.d.ts +0 -2
- package/dist/ui/icons/IcRoundFormatPaint.js +0 -10
- package/dist/ui/icons/IcRoundHamburger.d.ts +0 -3
- package/dist/ui/icons/IcRoundHamburger.js +0 -18
- package/dist/ui/icons/IcRoundHdrStrong.d.ts +0 -3
- package/dist/ui/icons/IcRoundHdrStrong.js +0 -18
- package/dist/ui/icons/IcRoundHorizontalRule.d.ts +0 -3
- package/dist/ui/icons/IcRoundHorizontalRule.js +0 -19
- package/dist/ui/icons/IcRoundInsertDriveFile.d.ts +0 -2
- package/dist/ui/icons/IcRoundInsertDriveFile.js +0 -16
- package/dist/ui/icons/IcRoundKeyboardArrowDown.d.ts +0 -2
- package/dist/ui/icons/IcRoundKeyboardArrowDown.js +0 -16
- package/dist/ui/icons/IcRoundKeyboardArrowLeft.d.ts +0 -3
- package/dist/ui/icons/IcRoundKeyboardArrowLeft.js +0 -18
- package/dist/ui/icons/IcRoundKeyboardArrowRight.d.ts +0 -2
- package/dist/ui/icons/IcRoundKeyboardArrowRight.js +0 -16
- package/dist/ui/icons/IcRoundKeyboardArrowUp.d.ts +0 -2
- package/dist/ui/icons/IcRoundKeyboardArrowUp.js +0 -16
- package/dist/ui/icons/IcRoundLanguage.d.ts +0 -2
- package/dist/ui/icons/IcRoundLanguage.js +0 -16
- package/dist/ui/icons/IcRoundLastPage.d.ts +0 -2
- package/dist/ui/icons/IcRoundLastPage.js +0 -26
- package/dist/ui/icons/IcRoundLock.d.ts +0 -3
- package/dist/ui/icons/IcRoundLock.js +0 -18
- package/dist/ui/icons/IcRoundMenu.d.ts +0 -2
- package/dist/ui/icons/IcRoundMenu.js +0 -16
- package/dist/ui/icons/IcRoundMoreHoriz.d.ts +0 -2
- package/dist/ui/icons/IcRoundMoreHoriz.js +0 -16
- package/dist/ui/icons/IcRoundMoreVert.d.ts +0 -2
- package/dist/ui/icons/IcRoundMoreVert.js +0 -26
- package/dist/ui/icons/IcRoundNorthEast.d.ts +0 -2
- package/dist/ui/icons/IcRoundNorthEast.js +0 -16
- package/dist/ui/icons/IcRoundNotes.d.ts +0 -2
- package/dist/ui/icons/IcRoundNotes.js +0 -16
- package/dist/ui/icons/IcRoundNumbers.d.ts +0 -2
- package/dist/ui/icons/IcRoundNumbers.js +0 -16
- package/dist/ui/icons/IcRoundPermMedia.d.ts +0 -2
- package/dist/ui/icons/IcRoundPermMedia.js +0 -25
- package/dist/ui/icons/IcRoundPublish.d.ts +0 -2
- package/dist/ui/icons/IcRoundPublish.js +0 -16
- package/dist/ui/icons/IcRoundPublishedWithChanges.d.ts +0 -2
- package/dist/ui/icons/IcRoundPublishedWithChanges.js +0 -26
- package/dist/ui/icons/IcRoundQuote.d.ts +0 -2
- package/dist/ui/icons/IcRoundQuote.js +0 -16
- package/dist/ui/icons/IcRoundRedo.d.ts +0 -3
- package/dist/ui/icons/IcRoundRedo.js +0 -18
- package/dist/ui/icons/IcRoundRemoveCircleOutline.d.ts +0 -2
- package/dist/ui/icons/IcRoundRemoveCircleOutline.js +0 -16
- package/dist/ui/icons/IcRoundRotateLeft.d.ts +0 -2
- package/dist/ui/icons/IcRoundRotateLeft.js +0 -16
- package/dist/ui/icons/IcRoundSend.d.ts +0 -2
- package/dist/ui/icons/IcRoundSend.js +0 -26
- package/dist/ui/icons/IcRoundSouthWest.d.ts +0 -2
- package/dist/ui/icons/IcRoundSouthWest.js +0 -16
- package/dist/ui/icons/IcRoundSubscript.d.ts +0 -2
- package/dist/ui/icons/IcRoundSubscript.js +0 -26
- package/dist/ui/icons/IcRoundSuperscript.d.ts +0 -2
- package/dist/ui/icons/IcRoundSuperscript.js +0 -26
- package/dist/ui/icons/IcRoundTabletMac.d.ts +0 -2
- package/dist/ui/icons/IcRoundTabletMac.js +0 -16
- package/dist/ui/icons/IcRoundTextFields.d.ts +0 -2
- package/dist/ui/icons/IcRoundTextFields.js +0 -16
- package/dist/ui/icons/IcRoundTranslate.d.ts +0 -2
- package/dist/ui/icons/IcRoundTranslate.js +0 -26
- package/dist/ui/icons/IcRoundUndo.d.ts +0 -3
- package/dist/ui/icons/IcRoundUndo.js +0 -18
- package/dist/ui/icons/IcRoundUnfoldLess.d.ts +0 -2
- package/dist/ui/icons/IcRoundUnfoldLess.js +0 -26
- package/dist/ui/icons/IcRoundUnfoldMore.d.ts +0 -2
- package/dist/ui/icons/IcRoundUnfoldMore.js +0 -16
- package/dist/ui/icons/IcRoundUploadFile.d.ts +0 -3
- package/dist/ui/icons/IcRoundUploadFile.js +0 -18
- package/dist/ui/icons/IcRoundVisibilityOff.d.ts +0 -2
- package/dist/ui/icons/IcRoundVisibilityOff.js +0 -16
- package/dist/ui/icons/IcRoundWarning.d.ts +0 -2
- package/dist/ui/icons/IcRoundWarning.js +0 -16
- package/dist/ui/icons/IcSharpBrightnessMedium.d.ts +0 -2
- package/dist/ui/icons/IcSharpBrightnessMedium.js +0 -16
- package/dist/ui/icons/IcSharpVerticalAlignCenter.d.ts +0 -2
- package/dist/ui/icons/IcSharpVerticalAlignCenter.js +0 -16
- package/dist/ui/icons/IcTwotoneDescription.d.ts +0 -2
- package/dist/ui/icons/IcTwotoneDescription.js +0 -37
- package/dist/ui/icons/IcTwotoneFolder.d.ts +0 -2
- package/dist/ui/icons/IcTwotoneFolder.js +0 -37
- package/dist/ui/icons/IcTwotoneInsertDriveFile.d.ts +0 -2
- package/dist/ui/icons/IcTwotoneInsertDriveFile.js +0 -30
- package/dist/ui/icons/MdiGithub.d.ts +0 -3
- package/dist/ui/icons/MdiGithub.js +0 -18
- package/dist/ui/icons/MdiSourceBranch.d.ts +0 -2
- package/dist/ui/icons/MdiSourceBranch.js +0 -16
- package/dist/ui/icons/MdiTwitterCircle.d.ts +0 -2
- package/dist/ui/icons/MdiTwitterCircle.js +0 -26
- package/dist/ui/icons/MiLayers.d.ts +0 -3
- package/dist/ui/icons/MiLayers.js +0 -16
- package/dist/ui/icons/PhGlobe.d.ts +0 -2
- package/dist/ui/icons/PhGlobe.js +0 -26
- package/dist/ui/icons/RiFlashlightFill.d.ts +0 -2
- package/dist/ui/icons/RiFlashlightFill.js +0 -10
- package/dist/ui/icons/TableDelete.d.ts +0 -2
- package/dist/ui/icons/TableDelete.js +0 -25
- package/dist/ui/icons/TableDeleteColumn.d.ts +0 -2
- package/dist/ui/icons/TableDeleteColumn.js +0 -16
- package/dist/ui/icons/TableDeleteRow.d.ts +0 -2
- package/dist/ui/icons/TableDeleteRow.js +0 -16
- package/dist/ui/icons/TableHeaderCell.d.ts +0 -2
- package/dist/ui/icons/TableHeaderCell.js +0 -16
- package/dist/ui/icons/TableHeaderColumn.d.ts +0 -2
- package/dist/ui/icons/TableHeaderColumn.js +0 -16
- package/dist/ui/icons/TableHeaderRow.d.ts +0 -2
- package/dist/ui/icons/TableHeaderRow.js +0 -16
- package/dist/ui/icons/TableInsertColumnAfter.d.ts +0 -2
- package/dist/ui/icons/TableInsertColumnAfter.js +0 -16
- package/dist/ui/icons/TableInsertColumnBefore.d.ts +0 -2
- package/dist/ui/icons/TableInsertColumnBefore.js +0 -16
- package/dist/ui/icons/TableInsertRowAfter.d.ts +0 -2
- package/dist/ui/icons/TableInsertRowAfter.js +0 -16
- package/dist/ui/icons/TableInsertRowBefore.d.ts +0 -2
- package/dist/ui/icons/TableInsertRowBefore.js +0 -16
- package/dist/ui/icons/TableMergeCells.d.ts +0 -2
- package/dist/ui/icons/TableMergeCells.js +0 -16
- package/dist/ui/icons/TableSplitCell.d.ts +0 -2
- package/dist/ui/icons/TableSplitCell.js +0 -16
- package/dist/ui/util/ContrastColor.d.ts +0 -1
- package/dist/ui/util/ContrastColor.js +0 -17
- package/dist/ui/util/CreateTypo.d.ts +0 -62
- package/dist/ui/util/CreateTypo.js +0 -119
- package/dist/ui/util/Elevation.d.ts +0 -12
- package/dist/ui/util/Elevation.js +0 -20
- package/dist/ui/util/PropsWithAs.d.ts +0 -12
- package/dist/ui/util/PropsWithAs.js +0 -10
- package/dist/ui/util/Slots.d.ts +0 -11
- package/dist/ui/util/Slots.js +0 -50
- package/dist/ui/util/TextareaAutosize.d.ts +0 -2
- package/dist/ui/util/TextareaAutosize.js +0 -40
- package/dist/ui/util/Units.d.ts +0 -1
- package/dist/ui/util/Units.js +0 -7
- package/dist/ui/util/UseId.d.ts +0 -1
- package/dist/ui/util/UseId.js +0 -11
- package/dist/yjs.d.ts +0 -1
- package/dist/yjs.js +0 -206
- /package/dist/{core/Shape.js → chunks/chunk-NUFRM6SI.js} +0 -0
- /package/dist/{backend/Handler.test.d.ts → dashboard/app/EntrySidebarPreview.spec.d.ts} +0 -0
- /package/dist/{backend/router/Router.test.d.ts → dashboard/app/WorkspaceMenu.spec.d.ts} +0 -0
- /package/dist/{cli/Init.test.d.ts → field/link/LinkField.spec.d.ts} +0 -0
- /package/dist/{cli/util/CommitMessage.test.d.ts → field/list/ListField.spec.d.ts} +0 -0
- /package/dist/{core/Config.test.d.ts → field/richtext/RichTextField.spec.d.ts} +0 -0
|
@@ -0,0 +1,3705 @@
|
|
|
1
|
+
import {
|
|
2
|
+
Decoration,
|
|
3
|
+
DecorationSet,
|
|
4
|
+
Extension,
|
|
5
|
+
Fragment,
|
|
6
|
+
NodeSelection,
|
|
7
|
+
Plugin,
|
|
8
|
+
PluginKey,
|
|
9
|
+
Selection,
|
|
10
|
+
SelectionRange,
|
|
11
|
+
Slice,
|
|
12
|
+
TextSelection,
|
|
13
|
+
Transform,
|
|
14
|
+
getText,
|
|
15
|
+
getTextSerializersFromSchema,
|
|
16
|
+
keydownHandler,
|
|
17
|
+
posToDOMRect
|
|
18
|
+
} from "./chunk-TL7ZW6BX.js";
|
|
19
|
+
|
|
20
|
+
// node_modules/@floating-ui/utils/dist/floating-ui.utils.mjs
|
|
21
|
+
var sides = ["top", "right", "bottom", "left"];
|
|
22
|
+
var alignments = ["start", "end"];
|
|
23
|
+
var placements = /* @__PURE__ */ sides.reduce((acc, side) => acc.concat(side, side + "-" + alignments[0], side + "-" + alignments[1]), []);
|
|
24
|
+
var min = Math.min;
|
|
25
|
+
var max = Math.max;
|
|
26
|
+
var round = Math.round;
|
|
27
|
+
var createCoords = (v) => ({
|
|
28
|
+
x: v,
|
|
29
|
+
y: v
|
|
30
|
+
});
|
|
31
|
+
var oppositeSideMap = {
|
|
32
|
+
left: "right",
|
|
33
|
+
right: "left",
|
|
34
|
+
bottom: "top",
|
|
35
|
+
top: "bottom"
|
|
36
|
+
};
|
|
37
|
+
function clamp(start, value, end) {
|
|
38
|
+
return max(start, min(value, end));
|
|
39
|
+
}
|
|
40
|
+
function evaluate(value, param) {
|
|
41
|
+
return typeof value === "function" ? value(param) : value;
|
|
42
|
+
}
|
|
43
|
+
function getSide(placement) {
|
|
44
|
+
return placement.split("-")[0];
|
|
45
|
+
}
|
|
46
|
+
function getAlignment(placement) {
|
|
47
|
+
return placement.split("-")[1];
|
|
48
|
+
}
|
|
49
|
+
function getOppositeAxis(axis) {
|
|
50
|
+
return axis === "x" ? "y" : "x";
|
|
51
|
+
}
|
|
52
|
+
function getAxisLength(axis) {
|
|
53
|
+
return axis === "y" ? "height" : "width";
|
|
54
|
+
}
|
|
55
|
+
function getSideAxis(placement) {
|
|
56
|
+
const firstChar = placement[0];
|
|
57
|
+
return firstChar === "t" || firstChar === "b" ? "y" : "x";
|
|
58
|
+
}
|
|
59
|
+
function getAlignmentAxis(placement) {
|
|
60
|
+
return getOppositeAxis(getSideAxis(placement));
|
|
61
|
+
}
|
|
62
|
+
function getAlignmentSides(placement, rects, rtl) {
|
|
63
|
+
if (rtl === void 0) {
|
|
64
|
+
rtl = false;
|
|
65
|
+
}
|
|
66
|
+
const alignment = getAlignment(placement);
|
|
67
|
+
const alignmentAxis = getAlignmentAxis(placement);
|
|
68
|
+
const length = getAxisLength(alignmentAxis);
|
|
69
|
+
let mainAlignmentSide = alignmentAxis === "x" ? alignment === (rtl ? "end" : "start") ? "right" : "left" : alignment === "start" ? "bottom" : "top";
|
|
70
|
+
if (rects.reference[length] > rects.floating[length]) {
|
|
71
|
+
mainAlignmentSide = getOppositePlacement(mainAlignmentSide);
|
|
72
|
+
}
|
|
73
|
+
return [mainAlignmentSide, getOppositePlacement(mainAlignmentSide)];
|
|
74
|
+
}
|
|
75
|
+
function getExpandedPlacements(placement) {
|
|
76
|
+
const oppositePlacement = getOppositePlacement(placement);
|
|
77
|
+
return [getOppositeAlignmentPlacement(placement), oppositePlacement, getOppositeAlignmentPlacement(oppositePlacement)];
|
|
78
|
+
}
|
|
79
|
+
function getOppositeAlignmentPlacement(placement) {
|
|
80
|
+
return placement.includes("start") ? placement.replace("start", "end") : placement.replace("end", "start");
|
|
81
|
+
}
|
|
82
|
+
var lrPlacement = ["left", "right"];
|
|
83
|
+
var rlPlacement = ["right", "left"];
|
|
84
|
+
var tbPlacement = ["top", "bottom"];
|
|
85
|
+
var btPlacement = ["bottom", "top"];
|
|
86
|
+
function getSideList(side, isStart, rtl) {
|
|
87
|
+
switch (side) {
|
|
88
|
+
case "top":
|
|
89
|
+
case "bottom":
|
|
90
|
+
if (rtl) return isStart ? rlPlacement : lrPlacement;
|
|
91
|
+
return isStart ? lrPlacement : rlPlacement;
|
|
92
|
+
case "left":
|
|
93
|
+
case "right":
|
|
94
|
+
return isStart ? tbPlacement : btPlacement;
|
|
95
|
+
default:
|
|
96
|
+
return [];
|
|
97
|
+
}
|
|
98
|
+
}
|
|
99
|
+
function getOppositeAxisPlacements(placement, flipAlignment, direction, rtl) {
|
|
100
|
+
const alignment = getAlignment(placement);
|
|
101
|
+
let list = getSideList(getSide(placement), direction === "start", rtl);
|
|
102
|
+
if (alignment) {
|
|
103
|
+
list = list.map((side) => side + "-" + alignment);
|
|
104
|
+
if (flipAlignment) {
|
|
105
|
+
list = list.concat(list.map(getOppositeAlignmentPlacement));
|
|
106
|
+
}
|
|
107
|
+
}
|
|
108
|
+
return list;
|
|
109
|
+
}
|
|
110
|
+
function getOppositePlacement(placement) {
|
|
111
|
+
const side = getSide(placement);
|
|
112
|
+
return oppositeSideMap[side] + placement.slice(side.length);
|
|
113
|
+
}
|
|
114
|
+
function expandPaddingObject(padding) {
|
|
115
|
+
var _padding$top, _padding$right, _padding$bottom, _padding$left;
|
|
116
|
+
return {
|
|
117
|
+
top: (_padding$top = padding.top) != null ? _padding$top : 0,
|
|
118
|
+
right: (_padding$right = padding.right) != null ? _padding$right : 0,
|
|
119
|
+
bottom: (_padding$bottom = padding.bottom) != null ? _padding$bottom : 0,
|
|
120
|
+
left: (_padding$left = padding.left) != null ? _padding$left : 0
|
|
121
|
+
};
|
|
122
|
+
}
|
|
123
|
+
function getPaddingObject(padding) {
|
|
124
|
+
return typeof padding !== "number" ? expandPaddingObject(padding) : {
|
|
125
|
+
top: padding,
|
|
126
|
+
right: padding,
|
|
127
|
+
bottom: padding,
|
|
128
|
+
left: padding
|
|
129
|
+
};
|
|
130
|
+
}
|
|
131
|
+
function rectToClientRect(rect) {
|
|
132
|
+
const {
|
|
133
|
+
x,
|
|
134
|
+
y,
|
|
135
|
+
width,
|
|
136
|
+
height
|
|
137
|
+
} = rect;
|
|
138
|
+
return {
|
|
139
|
+
width,
|
|
140
|
+
height,
|
|
141
|
+
top: y,
|
|
142
|
+
left: x,
|
|
143
|
+
right: x + width,
|
|
144
|
+
bottom: y + height,
|
|
145
|
+
x,
|
|
146
|
+
y
|
|
147
|
+
};
|
|
148
|
+
}
|
|
149
|
+
|
|
150
|
+
// node_modules/@floating-ui/core/dist/floating-ui.core.mjs
|
|
151
|
+
function computeCoordsFromPlacement(_ref, placement, rtl) {
|
|
152
|
+
let {
|
|
153
|
+
reference,
|
|
154
|
+
floating
|
|
155
|
+
} = _ref;
|
|
156
|
+
const sideAxis = getSideAxis(placement);
|
|
157
|
+
const alignmentAxis = getAlignmentAxis(placement);
|
|
158
|
+
const alignLength = getAxisLength(alignmentAxis);
|
|
159
|
+
const side = getSide(placement);
|
|
160
|
+
const isVertical = sideAxis === "y";
|
|
161
|
+
const commonX = reference.x + reference.width / 2 - floating.width / 2;
|
|
162
|
+
const commonY = reference.y + reference.height / 2 - floating.height / 2;
|
|
163
|
+
const commonAlign = reference[alignLength] / 2 - floating[alignLength] / 2;
|
|
164
|
+
let coords;
|
|
165
|
+
switch (side) {
|
|
166
|
+
case "top":
|
|
167
|
+
coords = {
|
|
168
|
+
x: commonX,
|
|
169
|
+
y: reference.y - floating.height
|
|
170
|
+
};
|
|
171
|
+
break;
|
|
172
|
+
case "bottom":
|
|
173
|
+
coords = {
|
|
174
|
+
x: commonX,
|
|
175
|
+
y: reference.y + reference.height
|
|
176
|
+
};
|
|
177
|
+
break;
|
|
178
|
+
case "right":
|
|
179
|
+
coords = {
|
|
180
|
+
x: reference.x + reference.width,
|
|
181
|
+
y: commonY
|
|
182
|
+
};
|
|
183
|
+
break;
|
|
184
|
+
case "left":
|
|
185
|
+
coords = {
|
|
186
|
+
x: reference.x - floating.width,
|
|
187
|
+
y: commonY
|
|
188
|
+
};
|
|
189
|
+
break;
|
|
190
|
+
default:
|
|
191
|
+
coords = {
|
|
192
|
+
x: reference.x,
|
|
193
|
+
y: reference.y
|
|
194
|
+
};
|
|
195
|
+
}
|
|
196
|
+
const alignment = getAlignment(placement);
|
|
197
|
+
if (alignment) {
|
|
198
|
+
coords[alignmentAxis] += commonAlign * (alignment === "end" ? 1 : -1) * (rtl && isVertical ? -1 : 1);
|
|
199
|
+
}
|
|
200
|
+
return coords;
|
|
201
|
+
}
|
|
202
|
+
async function detectOverflow(state, options) {
|
|
203
|
+
var _await$platform$isEle;
|
|
204
|
+
if (options === void 0) {
|
|
205
|
+
options = {};
|
|
206
|
+
}
|
|
207
|
+
const {
|
|
208
|
+
x,
|
|
209
|
+
y,
|
|
210
|
+
platform: platform2,
|
|
211
|
+
rects,
|
|
212
|
+
elements,
|
|
213
|
+
strategy
|
|
214
|
+
} = state;
|
|
215
|
+
const {
|
|
216
|
+
boundary = "clippingAncestors",
|
|
217
|
+
rootBoundary = "viewport",
|
|
218
|
+
elementContext = "floating",
|
|
219
|
+
altBoundary = false,
|
|
220
|
+
padding = 0
|
|
221
|
+
} = evaluate(options, state);
|
|
222
|
+
const paddingObject = getPaddingObject(padding);
|
|
223
|
+
const altContext = elementContext === "floating" ? "reference" : "floating";
|
|
224
|
+
const element = elements[altBoundary ? altContext : elementContext];
|
|
225
|
+
const clippingClientRect = rectToClientRect(await platform2.getClippingRect({
|
|
226
|
+
element: ((_await$platform$isEle = await (platform2.isElement == null ? void 0 : platform2.isElement(element))) != null ? _await$platform$isEle : true) ? element : element.contextElement || await (platform2.getDocumentElement == null ? void 0 : platform2.getDocumentElement(elements.floating)),
|
|
227
|
+
boundary,
|
|
228
|
+
rootBoundary,
|
|
229
|
+
strategy
|
|
230
|
+
}));
|
|
231
|
+
const rect = elementContext === "floating" ? {
|
|
232
|
+
x,
|
|
233
|
+
y,
|
|
234
|
+
width: rects.floating.width,
|
|
235
|
+
height: rects.floating.height
|
|
236
|
+
} : rects.reference;
|
|
237
|
+
const offsetParent = await (platform2.getOffsetParent == null ? void 0 : platform2.getOffsetParent(elements.floating));
|
|
238
|
+
const offsetScale = await (platform2.isElement == null ? void 0 : platform2.isElement(offsetParent)) && await (platform2.getScale == null ? void 0 : platform2.getScale(offsetParent)) || {
|
|
239
|
+
x: 1,
|
|
240
|
+
y: 1
|
|
241
|
+
};
|
|
242
|
+
const elementClientRect = rectToClientRect(platform2.convertOffsetParentRelativeRectToViewportRelativeRect ? await platform2.convertOffsetParentRelativeRectToViewportRelativeRect({
|
|
243
|
+
elements,
|
|
244
|
+
rect,
|
|
245
|
+
offsetParent,
|
|
246
|
+
strategy
|
|
247
|
+
}) : rect);
|
|
248
|
+
return {
|
|
249
|
+
top: (clippingClientRect.top - elementClientRect.top + paddingObject.top) / offsetScale.y,
|
|
250
|
+
bottom: (elementClientRect.bottom - clippingClientRect.bottom + paddingObject.bottom) / offsetScale.y,
|
|
251
|
+
left: (clippingClientRect.left - elementClientRect.left + paddingObject.left) / offsetScale.x,
|
|
252
|
+
right: (elementClientRect.right - clippingClientRect.right + paddingObject.right) / offsetScale.x
|
|
253
|
+
};
|
|
254
|
+
}
|
|
255
|
+
var MAX_RESET_COUNT = 50;
|
|
256
|
+
var computePosition = async (reference, floating, config) => {
|
|
257
|
+
const {
|
|
258
|
+
placement = "bottom",
|
|
259
|
+
strategy = "absolute",
|
|
260
|
+
middleware = [],
|
|
261
|
+
platform: platform2
|
|
262
|
+
} = config;
|
|
263
|
+
const platformWithDetectOverflow = platform2.detectOverflow ? platform2 : {
|
|
264
|
+
...platform2,
|
|
265
|
+
detectOverflow
|
|
266
|
+
};
|
|
267
|
+
const rtl = await (platform2.isRTL == null ? void 0 : platform2.isRTL(floating));
|
|
268
|
+
let rects = await platform2.getElementRects({
|
|
269
|
+
reference,
|
|
270
|
+
floating,
|
|
271
|
+
strategy
|
|
272
|
+
});
|
|
273
|
+
let {
|
|
274
|
+
x,
|
|
275
|
+
y
|
|
276
|
+
} = computeCoordsFromPlacement(rects, placement, rtl);
|
|
277
|
+
let statefulPlacement = placement;
|
|
278
|
+
let resetCount = 0;
|
|
279
|
+
const middlewareData = {};
|
|
280
|
+
for (let i = 0; i < middleware.length; i++) {
|
|
281
|
+
const currentMiddleware = middleware[i];
|
|
282
|
+
if (!currentMiddleware) {
|
|
283
|
+
continue;
|
|
284
|
+
}
|
|
285
|
+
const {
|
|
286
|
+
name,
|
|
287
|
+
fn
|
|
288
|
+
} = currentMiddleware;
|
|
289
|
+
const {
|
|
290
|
+
x: nextX,
|
|
291
|
+
y: nextY,
|
|
292
|
+
data,
|
|
293
|
+
reset
|
|
294
|
+
} = await fn({
|
|
295
|
+
x,
|
|
296
|
+
y,
|
|
297
|
+
initialPlacement: placement,
|
|
298
|
+
placement: statefulPlacement,
|
|
299
|
+
strategy,
|
|
300
|
+
middlewareData,
|
|
301
|
+
rects,
|
|
302
|
+
platform: platformWithDetectOverflow,
|
|
303
|
+
elements: {
|
|
304
|
+
reference,
|
|
305
|
+
floating
|
|
306
|
+
}
|
|
307
|
+
});
|
|
308
|
+
x = nextX != null ? nextX : x;
|
|
309
|
+
y = nextY != null ? nextY : y;
|
|
310
|
+
middlewareData[name] = {
|
|
311
|
+
...middlewareData[name],
|
|
312
|
+
...data
|
|
313
|
+
};
|
|
314
|
+
if (reset && resetCount < MAX_RESET_COUNT) {
|
|
315
|
+
resetCount++;
|
|
316
|
+
if (typeof reset === "object") {
|
|
317
|
+
if (reset.placement) {
|
|
318
|
+
statefulPlacement = reset.placement;
|
|
319
|
+
}
|
|
320
|
+
if (reset.rects) {
|
|
321
|
+
rects = reset.rects === true ? await platform2.getElementRects({
|
|
322
|
+
reference,
|
|
323
|
+
floating,
|
|
324
|
+
strategy
|
|
325
|
+
}) : reset.rects;
|
|
326
|
+
}
|
|
327
|
+
({
|
|
328
|
+
x,
|
|
329
|
+
y
|
|
330
|
+
} = computeCoordsFromPlacement(rects, statefulPlacement, rtl));
|
|
331
|
+
}
|
|
332
|
+
i = -1;
|
|
333
|
+
}
|
|
334
|
+
}
|
|
335
|
+
return {
|
|
336
|
+
x,
|
|
337
|
+
y,
|
|
338
|
+
placement: statefulPlacement,
|
|
339
|
+
strategy,
|
|
340
|
+
middlewareData
|
|
341
|
+
};
|
|
342
|
+
};
|
|
343
|
+
var arrow = (options) => ({
|
|
344
|
+
name: "arrow",
|
|
345
|
+
options,
|
|
346
|
+
async fn(state) {
|
|
347
|
+
const {
|
|
348
|
+
x,
|
|
349
|
+
y,
|
|
350
|
+
placement,
|
|
351
|
+
rects,
|
|
352
|
+
platform: platform2,
|
|
353
|
+
elements,
|
|
354
|
+
middlewareData
|
|
355
|
+
} = state;
|
|
356
|
+
const {
|
|
357
|
+
element,
|
|
358
|
+
padding = 0
|
|
359
|
+
} = evaluate(options, state) || {};
|
|
360
|
+
if (element == null) {
|
|
361
|
+
return {};
|
|
362
|
+
}
|
|
363
|
+
const paddingObject = getPaddingObject(padding);
|
|
364
|
+
const coords = {
|
|
365
|
+
x,
|
|
366
|
+
y
|
|
367
|
+
};
|
|
368
|
+
const axis = getAlignmentAxis(placement);
|
|
369
|
+
const length = getAxisLength(axis);
|
|
370
|
+
const arrowDimensions = await platform2.getDimensions(element);
|
|
371
|
+
const isYAxis = axis === "y";
|
|
372
|
+
const minProp = isYAxis ? "top" : "left";
|
|
373
|
+
const maxProp = isYAxis ? "bottom" : "right";
|
|
374
|
+
const clientProp = isYAxis ? "clientHeight" : "clientWidth";
|
|
375
|
+
const endDiff = rects.reference[length] + rects.reference[axis] - coords[axis] - rects.floating[length];
|
|
376
|
+
const startDiff = coords[axis] - rects.reference[axis];
|
|
377
|
+
const arrowOffsetParent = await (platform2.getOffsetParent == null ? void 0 : platform2.getOffsetParent(element));
|
|
378
|
+
let clientSize = arrowOffsetParent ? arrowOffsetParent[clientProp] : 0;
|
|
379
|
+
if (!clientSize || !await (platform2.isElement == null ? void 0 : platform2.isElement(arrowOffsetParent))) {
|
|
380
|
+
clientSize = elements.floating[clientProp] || rects.floating[length];
|
|
381
|
+
}
|
|
382
|
+
const centerToReference = endDiff / 2 - startDiff / 2;
|
|
383
|
+
const largestPossiblePadding = clientSize / 2 - arrowDimensions[length] / 2 - 1;
|
|
384
|
+
const minPadding = min(paddingObject[minProp], largestPossiblePadding);
|
|
385
|
+
const maxPadding = min(paddingObject[maxProp], largestPossiblePadding);
|
|
386
|
+
const max2 = clientSize - arrowDimensions[length] - maxPadding;
|
|
387
|
+
const center = clientSize / 2 - arrowDimensions[length] / 2 + centerToReference;
|
|
388
|
+
const offset3 = clamp(minPadding, center, max2);
|
|
389
|
+
const shouldAddOffset = !middlewareData.arrow && getAlignment(placement) != null && center !== offset3 && rects.reference[length] / 2 - (center < minPadding ? minPadding : maxPadding) - arrowDimensions[length] / 2 < 0;
|
|
390
|
+
const alignmentOffset = shouldAddOffset ? center < minPadding ? center - minPadding : center - max2 : 0;
|
|
391
|
+
return {
|
|
392
|
+
[axis]: coords[axis] + alignmentOffset,
|
|
393
|
+
data: {
|
|
394
|
+
[axis]: offset3,
|
|
395
|
+
centerOffset: center - offset3 - alignmentOffset,
|
|
396
|
+
...shouldAddOffset && {
|
|
397
|
+
alignmentOffset
|
|
398
|
+
}
|
|
399
|
+
},
|
|
400
|
+
reset: shouldAddOffset
|
|
401
|
+
};
|
|
402
|
+
}
|
|
403
|
+
});
|
|
404
|
+
function getPlacementList(alignment, autoAlignment, allowedPlacements) {
|
|
405
|
+
const allowedPlacementsSortedByAlignment = alignment ? [...allowedPlacements.filter((placement) => getAlignment(placement) === alignment), ...allowedPlacements.filter((placement) => getAlignment(placement) !== alignment)] : allowedPlacements.filter((placement) => getSide(placement) === placement);
|
|
406
|
+
return allowedPlacementsSortedByAlignment.filter((placement) => {
|
|
407
|
+
if (alignment) {
|
|
408
|
+
return getAlignment(placement) === alignment || (autoAlignment ? getOppositeAlignmentPlacement(placement) !== placement : false);
|
|
409
|
+
}
|
|
410
|
+
return true;
|
|
411
|
+
});
|
|
412
|
+
}
|
|
413
|
+
var autoPlacement = function(options) {
|
|
414
|
+
if (options === void 0) {
|
|
415
|
+
options = {};
|
|
416
|
+
}
|
|
417
|
+
return {
|
|
418
|
+
name: "autoPlacement",
|
|
419
|
+
options,
|
|
420
|
+
async fn(state) {
|
|
421
|
+
var _middlewareData$autoP, _middlewareData$autoP2, _placementsThatFitOnE;
|
|
422
|
+
const {
|
|
423
|
+
rects,
|
|
424
|
+
middlewareData,
|
|
425
|
+
placement,
|
|
426
|
+
platform: platform2,
|
|
427
|
+
elements
|
|
428
|
+
} = state;
|
|
429
|
+
const {
|
|
430
|
+
crossAxis = false,
|
|
431
|
+
alignment,
|
|
432
|
+
allowedPlacements = placements,
|
|
433
|
+
autoAlignment = true,
|
|
434
|
+
...detectOverflowOptions
|
|
435
|
+
} = evaluate(options, state);
|
|
436
|
+
const placements$1 = alignment !== void 0 || allowedPlacements === placements ? getPlacementList(alignment || null, autoAlignment, allowedPlacements) : allowedPlacements;
|
|
437
|
+
const currentIndex = ((_middlewareData$autoP = middlewareData.autoPlacement) == null ? void 0 : _middlewareData$autoP.index) || 0;
|
|
438
|
+
const currentPlacement = placements$1[currentIndex];
|
|
439
|
+
if (currentPlacement == null) {
|
|
440
|
+
return {};
|
|
441
|
+
}
|
|
442
|
+
if (placement !== currentPlacement) {
|
|
443
|
+
return {
|
|
444
|
+
reset: {
|
|
445
|
+
placement: placements$1[0]
|
|
446
|
+
}
|
|
447
|
+
};
|
|
448
|
+
}
|
|
449
|
+
const overflow = await platform2.detectOverflow(state, detectOverflowOptions);
|
|
450
|
+
const alignmentSides = getAlignmentSides(currentPlacement, rects, await (platform2.isRTL == null ? void 0 : platform2.isRTL(elements.floating)));
|
|
451
|
+
const currentOverflows = [overflow[getSide(currentPlacement)], overflow[alignmentSides[0]], overflow[alignmentSides[1]]];
|
|
452
|
+
const allOverflows = [...((_middlewareData$autoP2 = middlewareData.autoPlacement) == null ? void 0 : _middlewareData$autoP2.overflows) || [], {
|
|
453
|
+
placement: currentPlacement,
|
|
454
|
+
overflows: currentOverflows
|
|
455
|
+
}];
|
|
456
|
+
const nextPlacement = placements$1[currentIndex + 1];
|
|
457
|
+
if (nextPlacement) {
|
|
458
|
+
return {
|
|
459
|
+
data: {
|
|
460
|
+
index: currentIndex + 1,
|
|
461
|
+
overflows: allOverflows
|
|
462
|
+
},
|
|
463
|
+
reset: {
|
|
464
|
+
placement: nextPlacement
|
|
465
|
+
}
|
|
466
|
+
};
|
|
467
|
+
}
|
|
468
|
+
const placementsSortedByMostSpace = allOverflows.map((d) => {
|
|
469
|
+
const alignment2 = getAlignment(d.placement);
|
|
470
|
+
return [d.placement, alignment2 && crossAxis ? (
|
|
471
|
+
// Check along the mainAxis and main crossAxis side.
|
|
472
|
+
d.overflows.slice(0, 2).reduce((acc, v) => acc + v, 0)
|
|
473
|
+
) : (
|
|
474
|
+
// Check only the mainAxis.
|
|
475
|
+
d.overflows[0]
|
|
476
|
+
), d.overflows];
|
|
477
|
+
}).sort((a, b) => a[1] - b[1]);
|
|
478
|
+
const placementsThatFitOnEachSide = placementsSortedByMostSpace.filter((d) => d[2].slice(
|
|
479
|
+
0,
|
|
480
|
+
// Aligned placements should not check their opposite crossAxis
|
|
481
|
+
// side.
|
|
482
|
+
getAlignment(d[0]) ? 2 : 3
|
|
483
|
+
).every((v) => v <= 0));
|
|
484
|
+
const resetPlacement = ((_placementsThatFitOnE = placementsThatFitOnEachSide[0]) == null ? void 0 : _placementsThatFitOnE[0]) || placementsSortedByMostSpace[0][0];
|
|
485
|
+
if (resetPlacement !== placement) {
|
|
486
|
+
return {
|
|
487
|
+
data: {
|
|
488
|
+
index: currentIndex + 1,
|
|
489
|
+
overflows: allOverflows
|
|
490
|
+
},
|
|
491
|
+
reset: {
|
|
492
|
+
placement: resetPlacement
|
|
493
|
+
}
|
|
494
|
+
};
|
|
495
|
+
}
|
|
496
|
+
return {};
|
|
497
|
+
}
|
|
498
|
+
};
|
|
499
|
+
};
|
|
500
|
+
var flip = function(options) {
|
|
501
|
+
if (options === void 0) {
|
|
502
|
+
options = {};
|
|
503
|
+
}
|
|
504
|
+
return {
|
|
505
|
+
name: "flip",
|
|
506
|
+
options,
|
|
507
|
+
async fn(state) {
|
|
508
|
+
var _middlewareData$arrow, _middlewareData$flip;
|
|
509
|
+
const {
|
|
510
|
+
placement,
|
|
511
|
+
middlewareData,
|
|
512
|
+
rects,
|
|
513
|
+
initialPlacement,
|
|
514
|
+
platform: platform2,
|
|
515
|
+
elements
|
|
516
|
+
} = state;
|
|
517
|
+
const {
|
|
518
|
+
mainAxis: checkMainAxis = true,
|
|
519
|
+
crossAxis: checkCrossAxis = true,
|
|
520
|
+
fallbackPlacements: specifiedFallbackPlacements,
|
|
521
|
+
fallbackStrategy = "bestFit",
|
|
522
|
+
fallbackAxisSideDirection = "none",
|
|
523
|
+
flipAlignment = true,
|
|
524
|
+
...detectOverflowOptions
|
|
525
|
+
} = evaluate(options, state);
|
|
526
|
+
if ((_middlewareData$arrow = middlewareData.arrow) != null && _middlewareData$arrow.alignmentOffset) {
|
|
527
|
+
return {};
|
|
528
|
+
}
|
|
529
|
+
const side = getSide(placement);
|
|
530
|
+
const initialSideAxis = getSideAxis(initialPlacement);
|
|
531
|
+
const isBasePlacement = getSide(initialPlacement) === initialPlacement;
|
|
532
|
+
const rtl = await (platform2.isRTL == null ? void 0 : platform2.isRTL(elements.floating));
|
|
533
|
+
const fallbackPlacements = specifiedFallbackPlacements || (isBasePlacement || !flipAlignment ? [getOppositePlacement(initialPlacement)] : getExpandedPlacements(initialPlacement));
|
|
534
|
+
const hasFallbackAxisSideDirection = fallbackAxisSideDirection !== "none";
|
|
535
|
+
if (!specifiedFallbackPlacements && hasFallbackAxisSideDirection) {
|
|
536
|
+
fallbackPlacements.push(...getOppositeAxisPlacements(initialPlacement, flipAlignment, fallbackAxisSideDirection, rtl));
|
|
537
|
+
}
|
|
538
|
+
const placements2 = [initialPlacement, ...fallbackPlacements];
|
|
539
|
+
const overflow = await platform2.detectOverflow(state, detectOverflowOptions);
|
|
540
|
+
const overflows = [];
|
|
541
|
+
let overflowsData = ((_middlewareData$flip = middlewareData.flip) == null ? void 0 : _middlewareData$flip.overflows) || [];
|
|
542
|
+
if (checkMainAxis) {
|
|
543
|
+
overflows.push(overflow[side]);
|
|
544
|
+
}
|
|
545
|
+
if (checkCrossAxis) {
|
|
546
|
+
const sides2 = getAlignmentSides(placement, rects, rtl);
|
|
547
|
+
overflows.push(overflow[sides2[0]], overflow[sides2[1]]);
|
|
548
|
+
}
|
|
549
|
+
overflowsData = [...overflowsData, {
|
|
550
|
+
placement,
|
|
551
|
+
overflows
|
|
552
|
+
}];
|
|
553
|
+
if (!overflows.every((side2) => side2 <= 0)) {
|
|
554
|
+
var _middlewareData$flip2, _overflowsData$filter;
|
|
555
|
+
const nextIndex = (((_middlewareData$flip2 = middlewareData.flip) == null ? void 0 : _middlewareData$flip2.index) || 0) + 1;
|
|
556
|
+
const nextPlacement = placements2[nextIndex];
|
|
557
|
+
if (nextPlacement) {
|
|
558
|
+
const ignoreCrossAxisOverflow = checkCrossAxis === "alignment" ? initialSideAxis !== getSideAxis(nextPlacement) : false;
|
|
559
|
+
if (!ignoreCrossAxisOverflow || // We leave the current main axis only if every placement on that axis
|
|
560
|
+
// overflows the main axis.
|
|
561
|
+
overflowsData.every((d) => getSideAxis(d.placement) === initialSideAxis ? d.overflows[0] > 0 : true)) {
|
|
562
|
+
return {
|
|
563
|
+
data: {
|
|
564
|
+
index: nextIndex,
|
|
565
|
+
overflows: overflowsData
|
|
566
|
+
},
|
|
567
|
+
reset: {
|
|
568
|
+
placement: nextPlacement
|
|
569
|
+
}
|
|
570
|
+
};
|
|
571
|
+
}
|
|
572
|
+
}
|
|
573
|
+
let resetPlacement = (_overflowsData$filter = overflowsData.filter((d) => d.overflows[0] <= 0).sort((a, b) => a.overflows[1] - b.overflows[1])[0]) == null ? void 0 : _overflowsData$filter.placement;
|
|
574
|
+
if (!resetPlacement) {
|
|
575
|
+
switch (fallbackStrategy) {
|
|
576
|
+
case "bestFit": {
|
|
577
|
+
var _overflowsData$filter2;
|
|
578
|
+
const placement2 = (_overflowsData$filter2 = overflowsData.filter((d) => {
|
|
579
|
+
if (hasFallbackAxisSideDirection) {
|
|
580
|
+
const currentSideAxis = getSideAxis(d.placement);
|
|
581
|
+
return currentSideAxis === initialSideAxis || // Create a bias to the `y` side axis due to horizontal
|
|
582
|
+
// reading directions favoring greater width.
|
|
583
|
+
currentSideAxis === "y";
|
|
584
|
+
}
|
|
585
|
+
return true;
|
|
586
|
+
}).map((d) => [d.placement, d.overflows.filter((overflow2) => overflow2 > 0).reduce((acc, overflow2) => acc + overflow2, 0)]).sort((a, b) => a[1] - b[1])[0]) == null ? void 0 : _overflowsData$filter2[0];
|
|
587
|
+
if (placement2) {
|
|
588
|
+
resetPlacement = placement2;
|
|
589
|
+
}
|
|
590
|
+
break;
|
|
591
|
+
}
|
|
592
|
+
case "initialPlacement":
|
|
593
|
+
resetPlacement = initialPlacement;
|
|
594
|
+
break;
|
|
595
|
+
}
|
|
596
|
+
}
|
|
597
|
+
if (placement !== resetPlacement) {
|
|
598
|
+
return {
|
|
599
|
+
reset: {
|
|
600
|
+
placement: resetPlacement
|
|
601
|
+
}
|
|
602
|
+
};
|
|
603
|
+
}
|
|
604
|
+
}
|
|
605
|
+
return {};
|
|
606
|
+
}
|
|
607
|
+
};
|
|
608
|
+
};
|
|
609
|
+
function getSideOffsets(overflow, rect) {
|
|
610
|
+
return {
|
|
611
|
+
top: overflow.top - rect.height,
|
|
612
|
+
right: overflow.right - rect.width,
|
|
613
|
+
bottom: overflow.bottom - rect.height,
|
|
614
|
+
left: overflow.left - rect.width
|
|
615
|
+
};
|
|
616
|
+
}
|
|
617
|
+
function isAnySideFullyClipped(overflow) {
|
|
618
|
+
return sides.some((side) => overflow[side] >= 0);
|
|
619
|
+
}
|
|
620
|
+
var hide = function(options) {
|
|
621
|
+
if (options === void 0) {
|
|
622
|
+
options = {};
|
|
623
|
+
}
|
|
624
|
+
return {
|
|
625
|
+
name: "hide",
|
|
626
|
+
options,
|
|
627
|
+
async fn(state) {
|
|
628
|
+
const {
|
|
629
|
+
rects,
|
|
630
|
+
platform: platform2
|
|
631
|
+
} = state;
|
|
632
|
+
const {
|
|
633
|
+
strategy = "referenceHidden",
|
|
634
|
+
...detectOverflowOptions
|
|
635
|
+
} = evaluate(options, state);
|
|
636
|
+
switch (strategy) {
|
|
637
|
+
case "referenceHidden": {
|
|
638
|
+
const overflow = await platform2.detectOverflow(state, {
|
|
639
|
+
...detectOverflowOptions,
|
|
640
|
+
elementContext: "reference"
|
|
641
|
+
});
|
|
642
|
+
const offsets = getSideOffsets(overflow, rects.reference);
|
|
643
|
+
return {
|
|
644
|
+
data: {
|
|
645
|
+
referenceHiddenOffsets: offsets,
|
|
646
|
+
referenceHidden: isAnySideFullyClipped(offsets)
|
|
647
|
+
}
|
|
648
|
+
};
|
|
649
|
+
}
|
|
650
|
+
case "escaped": {
|
|
651
|
+
const overflow = await platform2.detectOverflow(state, {
|
|
652
|
+
...detectOverflowOptions,
|
|
653
|
+
altBoundary: true
|
|
654
|
+
});
|
|
655
|
+
const offsets = getSideOffsets(overflow, rects.floating);
|
|
656
|
+
return {
|
|
657
|
+
data: {
|
|
658
|
+
escapedOffsets: offsets,
|
|
659
|
+
escaped: isAnySideFullyClipped(offsets)
|
|
660
|
+
}
|
|
661
|
+
};
|
|
662
|
+
}
|
|
663
|
+
default: {
|
|
664
|
+
return {};
|
|
665
|
+
}
|
|
666
|
+
}
|
|
667
|
+
}
|
|
668
|
+
};
|
|
669
|
+
};
|
|
670
|
+
function getBoundingRect(rects) {
|
|
671
|
+
const minX = min(...rects.map((rect) => rect.left));
|
|
672
|
+
const minY = min(...rects.map((rect) => rect.top));
|
|
673
|
+
const maxX = max(...rects.map((rect) => rect.right));
|
|
674
|
+
const maxY = max(...rects.map((rect) => rect.bottom));
|
|
675
|
+
return {
|
|
676
|
+
x: minX,
|
|
677
|
+
y: minY,
|
|
678
|
+
width: maxX - minX,
|
|
679
|
+
height: maxY - minY
|
|
680
|
+
};
|
|
681
|
+
}
|
|
682
|
+
function getRectsByLine(rects) {
|
|
683
|
+
const sortedRects = rects.slice().sort((a, b) => a.y - b.y);
|
|
684
|
+
const groups = [];
|
|
685
|
+
let prevRect = null;
|
|
686
|
+
for (let i = 0; i < sortedRects.length; i++) {
|
|
687
|
+
const rect = sortedRects[i];
|
|
688
|
+
if (!prevRect || rect.y - prevRect.y > prevRect.height / 2) {
|
|
689
|
+
groups.push([rect]);
|
|
690
|
+
} else {
|
|
691
|
+
groups[groups.length - 1].push(rect);
|
|
692
|
+
}
|
|
693
|
+
prevRect = rect;
|
|
694
|
+
}
|
|
695
|
+
return groups.map((rect) => rectToClientRect(getBoundingRect(rect)));
|
|
696
|
+
}
|
|
697
|
+
var inline = function(options) {
|
|
698
|
+
if (options === void 0) {
|
|
699
|
+
options = {};
|
|
700
|
+
}
|
|
701
|
+
return {
|
|
702
|
+
name: "inline",
|
|
703
|
+
options,
|
|
704
|
+
async fn(state) {
|
|
705
|
+
const {
|
|
706
|
+
placement,
|
|
707
|
+
elements,
|
|
708
|
+
rects,
|
|
709
|
+
platform: platform2,
|
|
710
|
+
strategy
|
|
711
|
+
} = state;
|
|
712
|
+
const {
|
|
713
|
+
padding = 2,
|
|
714
|
+
x,
|
|
715
|
+
y
|
|
716
|
+
} = evaluate(options, state);
|
|
717
|
+
const nativeClientRects = Array.from(await (platform2.getClientRects == null ? void 0 : platform2.getClientRects(elements.reference)) || []);
|
|
718
|
+
if (!nativeClientRects.length) {
|
|
719
|
+
return {};
|
|
720
|
+
}
|
|
721
|
+
const clientRects = getRectsByLine(nativeClientRects);
|
|
722
|
+
const fallback = rectToClientRect(getBoundingRect(nativeClientRects));
|
|
723
|
+
const paddingObject = getPaddingObject(padding);
|
|
724
|
+
function getBoundingClientRect2() {
|
|
725
|
+
if (clientRects.length === 2 && (clientRects[0].left > clientRects[1].right || clientRects[1].left > clientRects[0].right) && x != null && y != null) {
|
|
726
|
+
return clientRects.find((rect) => x > rect.left - paddingObject.left && x < rect.right + paddingObject.right && y > rect.top - paddingObject.top && y < rect.bottom + paddingObject.bottom) || fallback;
|
|
727
|
+
}
|
|
728
|
+
if (clientRects.length >= 2) {
|
|
729
|
+
if (getSideAxis(placement) === "y") {
|
|
730
|
+
const firstRect = clientRects[0];
|
|
731
|
+
const lastRect = clientRects[clientRects.length - 1];
|
|
732
|
+
const isTop = getSide(placement) === "top";
|
|
733
|
+
const top2 = firstRect.top;
|
|
734
|
+
const bottom2 = lastRect.bottom;
|
|
735
|
+
const left = isTop ? firstRect.left : lastRect.left;
|
|
736
|
+
const right = isTop ? firstRect.right : lastRect.right;
|
|
737
|
+
return rectToClientRect({
|
|
738
|
+
x: left,
|
|
739
|
+
y: top2,
|
|
740
|
+
width: right - left,
|
|
741
|
+
height: bottom2 - top2
|
|
742
|
+
});
|
|
743
|
+
}
|
|
744
|
+
const isLeftSide = getSide(placement) === "left";
|
|
745
|
+
const maxRight = max(...clientRects.map((rect) => rect.right));
|
|
746
|
+
const minLeft = min(...clientRects.map((rect) => rect.left));
|
|
747
|
+
const measureRects = clientRects.filter((rect) => isLeftSide ? rect.left === minLeft : rect.right === maxRight);
|
|
748
|
+
const top = measureRects[0].top;
|
|
749
|
+
const bottom = measureRects[measureRects.length - 1].bottom;
|
|
750
|
+
return rectToClientRect({
|
|
751
|
+
x: minLeft,
|
|
752
|
+
y: top,
|
|
753
|
+
width: maxRight - minLeft,
|
|
754
|
+
height: bottom - top
|
|
755
|
+
});
|
|
756
|
+
}
|
|
757
|
+
return fallback;
|
|
758
|
+
}
|
|
759
|
+
const resetRects = await platform2.getElementRects({
|
|
760
|
+
reference: {
|
|
761
|
+
getBoundingClientRect: getBoundingClientRect2
|
|
762
|
+
},
|
|
763
|
+
floating: elements.floating,
|
|
764
|
+
strategy
|
|
765
|
+
});
|
|
766
|
+
if (rects.reference.x !== resetRects.reference.x || rects.reference.y !== resetRects.reference.y || rects.reference.width !== resetRects.reference.width || rects.reference.height !== resetRects.reference.height) {
|
|
767
|
+
return {
|
|
768
|
+
reset: {
|
|
769
|
+
rects: resetRects
|
|
770
|
+
}
|
|
771
|
+
};
|
|
772
|
+
}
|
|
773
|
+
return {};
|
|
774
|
+
}
|
|
775
|
+
};
|
|
776
|
+
};
|
|
777
|
+
var originSides = /* @__PURE__ */ new Set(["left", "top"]);
|
|
778
|
+
async function convertValueToCoords(state, options) {
|
|
779
|
+
const {
|
|
780
|
+
placement,
|
|
781
|
+
platform: platform2,
|
|
782
|
+
elements
|
|
783
|
+
} = state;
|
|
784
|
+
const rtl = await (platform2.isRTL == null ? void 0 : platform2.isRTL(elements.floating));
|
|
785
|
+
const side = getSide(placement);
|
|
786
|
+
const alignment = getAlignment(placement);
|
|
787
|
+
const isVertical = getSideAxis(placement) === "y";
|
|
788
|
+
const mainAxisMulti = originSides.has(side) ? -1 : 1;
|
|
789
|
+
const crossAxisMulti = rtl && isVertical ? -1 : 1;
|
|
790
|
+
const rawValue = evaluate(options, state);
|
|
791
|
+
let {
|
|
792
|
+
mainAxis,
|
|
793
|
+
crossAxis,
|
|
794
|
+
alignmentAxis
|
|
795
|
+
} = typeof rawValue === "number" ? {
|
|
796
|
+
mainAxis: rawValue,
|
|
797
|
+
crossAxis: 0,
|
|
798
|
+
alignmentAxis: null
|
|
799
|
+
} : {
|
|
800
|
+
mainAxis: rawValue.mainAxis || 0,
|
|
801
|
+
crossAxis: rawValue.crossAxis || 0,
|
|
802
|
+
alignmentAxis: rawValue.alignmentAxis
|
|
803
|
+
};
|
|
804
|
+
if (alignment && typeof alignmentAxis === "number") {
|
|
805
|
+
crossAxis = alignment === "end" ? alignmentAxis * -1 : alignmentAxis;
|
|
806
|
+
}
|
|
807
|
+
return isVertical ? {
|
|
808
|
+
x: crossAxis * crossAxisMulti,
|
|
809
|
+
y: mainAxis * mainAxisMulti
|
|
810
|
+
} : {
|
|
811
|
+
x: mainAxis * mainAxisMulti,
|
|
812
|
+
y: crossAxis * crossAxisMulti
|
|
813
|
+
};
|
|
814
|
+
}
|
|
815
|
+
var offset = function(options) {
|
|
816
|
+
if (options === void 0) {
|
|
817
|
+
options = 0;
|
|
818
|
+
}
|
|
819
|
+
return {
|
|
820
|
+
name: "offset",
|
|
821
|
+
options,
|
|
822
|
+
async fn(state) {
|
|
823
|
+
var _middlewareData$offse, _middlewareData$arrow;
|
|
824
|
+
const {
|
|
825
|
+
x,
|
|
826
|
+
y,
|
|
827
|
+
placement,
|
|
828
|
+
middlewareData
|
|
829
|
+
} = state;
|
|
830
|
+
const diffCoords = await convertValueToCoords(state, options);
|
|
831
|
+
if (placement === ((_middlewareData$offse = middlewareData.offset) == null ? void 0 : _middlewareData$offse.placement) && (_middlewareData$arrow = middlewareData.arrow) != null && _middlewareData$arrow.alignmentOffset) {
|
|
832
|
+
return {};
|
|
833
|
+
}
|
|
834
|
+
return {
|
|
835
|
+
x: x + diffCoords.x,
|
|
836
|
+
y: y + diffCoords.y,
|
|
837
|
+
data: {
|
|
838
|
+
...diffCoords,
|
|
839
|
+
placement
|
|
840
|
+
}
|
|
841
|
+
};
|
|
842
|
+
}
|
|
843
|
+
};
|
|
844
|
+
};
|
|
845
|
+
var shift = function(options) {
|
|
846
|
+
if (options === void 0) {
|
|
847
|
+
options = {};
|
|
848
|
+
}
|
|
849
|
+
return {
|
|
850
|
+
name: "shift",
|
|
851
|
+
options,
|
|
852
|
+
async fn(state) {
|
|
853
|
+
const {
|
|
854
|
+
x,
|
|
855
|
+
y,
|
|
856
|
+
placement,
|
|
857
|
+
platform: platform2
|
|
858
|
+
} = state;
|
|
859
|
+
const {
|
|
860
|
+
mainAxis: checkMainAxis = true,
|
|
861
|
+
crossAxis: checkCrossAxis = false,
|
|
862
|
+
limiter = {
|
|
863
|
+
fn: (_ref) => {
|
|
864
|
+
let {
|
|
865
|
+
x: x2,
|
|
866
|
+
y: y2
|
|
867
|
+
} = _ref;
|
|
868
|
+
return {
|
|
869
|
+
x: x2,
|
|
870
|
+
y: y2
|
|
871
|
+
};
|
|
872
|
+
}
|
|
873
|
+
},
|
|
874
|
+
...detectOverflowOptions
|
|
875
|
+
} = evaluate(options, state);
|
|
876
|
+
const coords = {
|
|
877
|
+
x,
|
|
878
|
+
y
|
|
879
|
+
};
|
|
880
|
+
const overflow = await platform2.detectOverflow(state, detectOverflowOptions);
|
|
881
|
+
const crossAxis = getSideAxis(placement);
|
|
882
|
+
const mainAxis = getOppositeAxis(crossAxis);
|
|
883
|
+
let mainAxisCoord = coords[mainAxis];
|
|
884
|
+
let crossAxisCoord = coords[crossAxis];
|
|
885
|
+
const clampCoord = (axis, coord) => clamp(coord + overflow[axis === "y" ? "top" : "left"], coord, coord - overflow[axis === "y" ? "bottom" : "right"]);
|
|
886
|
+
if (checkMainAxis) {
|
|
887
|
+
mainAxisCoord = clampCoord(mainAxis, mainAxisCoord);
|
|
888
|
+
}
|
|
889
|
+
if (checkCrossAxis) {
|
|
890
|
+
crossAxisCoord = clampCoord(crossAxis, crossAxisCoord);
|
|
891
|
+
}
|
|
892
|
+
const limitedCoords = limiter.fn({
|
|
893
|
+
...state,
|
|
894
|
+
[mainAxis]: mainAxisCoord,
|
|
895
|
+
[crossAxis]: crossAxisCoord
|
|
896
|
+
});
|
|
897
|
+
return {
|
|
898
|
+
...limitedCoords,
|
|
899
|
+
data: {
|
|
900
|
+
x: limitedCoords.x - x,
|
|
901
|
+
y: limitedCoords.y - y,
|
|
902
|
+
enabled: {
|
|
903
|
+
[mainAxis]: checkMainAxis,
|
|
904
|
+
[crossAxis]: checkCrossAxis
|
|
905
|
+
}
|
|
906
|
+
}
|
|
907
|
+
};
|
|
908
|
+
}
|
|
909
|
+
};
|
|
910
|
+
};
|
|
911
|
+
var size = function(options) {
|
|
912
|
+
if (options === void 0) {
|
|
913
|
+
options = {};
|
|
914
|
+
}
|
|
915
|
+
return {
|
|
916
|
+
name: "size",
|
|
917
|
+
options,
|
|
918
|
+
async fn(state) {
|
|
919
|
+
const {
|
|
920
|
+
placement,
|
|
921
|
+
rects,
|
|
922
|
+
platform: platform2,
|
|
923
|
+
elements
|
|
924
|
+
} = state;
|
|
925
|
+
const {
|
|
926
|
+
apply = () => {
|
|
927
|
+
},
|
|
928
|
+
...detectOverflowOptions
|
|
929
|
+
} = evaluate(options, state);
|
|
930
|
+
const overflow = await platform2.detectOverflow(state, detectOverflowOptions);
|
|
931
|
+
const side = getSide(placement);
|
|
932
|
+
const alignment = getAlignment(placement);
|
|
933
|
+
const isYAxis = getSideAxis(placement) === "y";
|
|
934
|
+
const {
|
|
935
|
+
width,
|
|
936
|
+
height
|
|
937
|
+
} = rects.floating;
|
|
938
|
+
let heightSide;
|
|
939
|
+
let widthSide;
|
|
940
|
+
if (side === "top" || side === "bottom") {
|
|
941
|
+
heightSide = side;
|
|
942
|
+
widthSide = alignment === (await (platform2.isRTL == null ? void 0 : platform2.isRTL(elements.floating)) ? "start" : "end") ? "left" : "right";
|
|
943
|
+
} else {
|
|
944
|
+
widthSide = side;
|
|
945
|
+
heightSide = alignment === "end" ? "top" : "bottom";
|
|
946
|
+
}
|
|
947
|
+
const maximumClippingHeight = height - overflow.top - overflow.bottom;
|
|
948
|
+
const maximumClippingWidth = width - overflow.left - overflow.right;
|
|
949
|
+
const overflowAvailableHeight = min(height - overflow[heightSide], maximumClippingHeight);
|
|
950
|
+
const overflowAvailableWidth = min(width - overflow[widthSide], maximumClippingWidth);
|
|
951
|
+
const shiftData = state.middlewareData.shift;
|
|
952
|
+
const noShift = !shiftData;
|
|
953
|
+
let availableHeight = overflowAvailableHeight;
|
|
954
|
+
let availableWidth = overflowAvailableWidth;
|
|
955
|
+
if (shiftData != null && shiftData.enabled.x) {
|
|
956
|
+
availableWidth = maximumClippingWidth;
|
|
957
|
+
}
|
|
958
|
+
if (shiftData != null && shiftData.enabled.y) {
|
|
959
|
+
availableHeight = maximumClippingHeight;
|
|
960
|
+
}
|
|
961
|
+
if (noShift && !alignment) {
|
|
962
|
+
if (isYAxis) {
|
|
963
|
+
availableWidth = width - 2 * max(overflow.left, overflow.right);
|
|
964
|
+
} else {
|
|
965
|
+
availableHeight = height - 2 * max(overflow.top, overflow.bottom);
|
|
966
|
+
}
|
|
967
|
+
}
|
|
968
|
+
await apply({
|
|
969
|
+
...state,
|
|
970
|
+
availableWidth,
|
|
971
|
+
availableHeight
|
|
972
|
+
});
|
|
973
|
+
const nextDimensions = await platform2.getDimensions(elements.floating);
|
|
974
|
+
if (width !== nextDimensions.width || height !== nextDimensions.height) {
|
|
975
|
+
return {
|
|
976
|
+
reset: {
|
|
977
|
+
rects: true
|
|
978
|
+
}
|
|
979
|
+
};
|
|
980
|
+
}
|
|
981
|
+
return {};
|
|
982
|
+
}
|
|
983
|
+
};
|
|
984
|
+
};
|
|
985
|
+
|
|
986
|
+
// node_modules/@floating-ui/utils/dist/floating-ui.utils.dom.mjs
|
|
987
|
+
function hasWindow() {
|
|
988
|
+
return typeof window !== "undefined";
|
|
989
|
+
}
|
|
990
|
+
function getNodeName(node) {
|
|
991
|
+
if (isNode(node)) {
|
|
992
|
+
return (node.nodeName || "").toLowerCase();
|
|
993
|
+
}
|
|
994
|
+
return "#document";
|
|
995
|
+
}
|
|
996
|
+
function getWindow(node) {
|
|
997
|
+
var _node$ownerDocument;
|
|
998
|
+
return (node == null || (_node$ownerDocument = node.ownerDocument) == null ? void 0 : _node$ownerDocument.defaultView) || window;
|
|
999
|
+
}
|
|
1000
|
+
function getDocumentElement(node) {
|
|
1001
|
+
var _ref;
|
|
1002
|
+
return (_ref = (isNode(node) ? node.ownerDocument : node.document) || window.document) == null ? void 0 : _ref.documentElement;
|
|
1003
|
+
}
|
|
1004
|
+
function isNode(value) {
|
|
1005
|
+
if (!hasWindow()) {
|
|
1006
|
+
return false;
|
|
1007
|
+
}
|
|
1008
|
+
return value instanceof Node || value instanceof getWindow(value).Node;
|
|
1009
|
+
}
|
|
1010
|
+
function isElement(value) {
|
|
1011
|
+
if (!hasWindow()) {
|
|
1012
|
+
return false;
|
|
1013
|
+
}
|
|
1014
|
+
return value instanceof Element || value instanceof getWindow(value).Element;
|
|
1015
|
+
}
|
|
1016
|
+
function isHTMLElement(value) {
|
|
1017
|
+
if (!hasWindow()) {
|
|
1018
|
+
return false;
|
|
1019
|
+
}
|
|
1020
|
+
return value instanceof HTMLElement || value instanceof getWindow(value).HTMLElement;
|
|
1021
|
+
}
|
|
1022
|
+
function isShadowRoot(value) {
|
|
1023
|
+
if (!hasWindow() || typeof ShadowRoot === "undefined") {
|
|
1024
|
+
return false;
|
|
1025
|
+
}
|
|
1026
|
+
return value instanceof ShadowRoot || value instanceof getWindow(value).ShadowRoot;
|
|
1027
|
+
}
|
|
1028
|
+
function isOverflowElement(element) {
|
|
1029
|
+
const {
|
|
1030
|
+
overflow,
|
|
1031
|
+
overflowX,
|
|
1032
|
+
overflowY,
|
|
1033
|
+
display
|
|
1034
|
+
} = getComputedStyle2(element);
|
|
1035
|
+
return /auto|scroll|overlay|hidden|clip/.test(overflow + overflowY + overflowX) && display !== "inline" && display !== "contents";
|
|
1036
|
+
}
|
|
1037
|
+
function isTableElement(element) {
|
|
1038
|
+
return /^(table|td|th)$/.test(getNodeName(element));
|
|
1039
|
+
}
|
|
1040
|
+
function isTopLayer(element) {
|
|
1041
|
+
try {
|
|
1042
|
+
if (element.matches(":popover-open")) {
|
|
1043
|
+
return true;
|
|
1044
|
+
}
|
|
1045
|
+
} catch (_e) {
|
|
1046
|
+
}
|
|
1047
|
+
try {
|
|
1048
|
+
return element.matches(":modal");
|
|
1049
|
+
} catch (_e) {
|
|
1050
|
+
return false;
|
|
1051
|
+
}
|
|
1052
|
+
}
|
|
1053
|
+
var willChangeRe = /transform|translate|scale|rotate|perspective|filter/;
|
|
1054
|
+
var containRe = /paint|layout|strict|content/;
|
|
1055
|
+
var isNotNone = (value) => !!value && value !== "none";
|
|
1056
|
+
var isWebKitValue;
|
|
1057
|
+
function isContainingBlock(elementOrCss) {
|
|
1058
|
+
const css = isElement(elementOrCss) ? getComputedStyle2(elementOrCss) : elementOrCss;
|
|
1059
|
+
return isNotNone(css.transform) || isNotNone(css.translate) || isNotNone(css.scale) || isNotNone(css.rotate) || isNotNone(css.perspective) || !isWebKit() && (isNotNone(css.backdropFilter) || isNotNone(css.filter)) || willChangeRe.test(css.willChange || "") || containRe.test(css.contain || "");
|
|
1060
|
+
}
|
|
1061
|
+
function getContainingBlock(element) {
|
|
1062
|
+
let currentNode = getParentNode(element);
|
|
1063
|
+
while (isHTMLElement(currentNode) && !isLastTraversableNode(currentNode)) {
|
|
1064
|
+
if (isContainingBlock(currentNode)) {
|
|
1065
|
+
return currentNode;
|
|
1066
|
+
} else if (isTopLayer(currentNode)) {
|
|
1067
|
+
return null;
|
|
1068
|
+
}
|
|
1069
|
+
currentNode = getParentNode(currentNode);
|
|
1070
|
+
}
|
|
1071
|
+
return null;
|
|
1072
|
+
}
|
|
1073
|
+
function isWebKit() {
|
|
1074
|
+
if (isWebKitValue == null) {
|
|
1075
|
+
isWebKitValue = typeof CSS !== "undefined" && CSS.supports && CSS.supports("-webkit-backdrop-filter", "none");
|
|
1076
|
+
}
|
|
1077
|
+
return isWebKitValue;
|
|
1078
|
+
}
|
|
1079
|
+
function isLastTraversableNode(node) {
|
|
1080
|
+
return /^(html|body|#document)$/.test(getNodeName(node));
|
|
1081
|
+
}
|
|
1082
|
+
function getComputedStyle2(element) {
|
|
1083
|
+
return getWindow(element).getComputedStyle(element);
|
|
1084
|
+
}
|
|
1085
|
+
function getNodeScroll(element) {
|
|
1086
|
+
if (isElement(element)) {
|
|
1087
|
+
return {
|
|
1088
|
+
scrollLeft: element.scrollLeft,
|
|
1089
|
+
scrollTop: element.scrollTop
|
|
1090
|
+
};
|
|
1091
|
+
}
|
|
1092
|
+
return {
|
|
1093
|
+
scrollLeft: element.scrollX,
|
|
1094
|
+
scrollTop: element.scrollY
|
|
1095
|
+
};
|
|
1096
|
+
}
|
|
1097
|
+
function getParentNode(node) {
|
|
1098
|
+
if (getNodeName(node) === "html") {
|
|
1099
|
+
return node;
|
|
1100
|
+
}
|
|
1101
|
+
const result = (
|
|
1102
|
+
// Step into the shadow DOM of the parent of a slotted node.
|
|
1103
|
+
node.assignedSlot || // DOM Element detected.
|
|
1104
|
+
node.parentNode || // ShadowRoot detected.
|
|
1105
|
+
isShadowRoot(node) && node.host || // Fallback.
|
|
1106
|
+
getDocumentElement(node)
|
|
1107
|
+
);
|
|
1108
|
+
return isShadowRoot(result) ? result.host : result;
|
|
1109
|
+
}
|
|
1110
|
+
function getNearestOverflowAncestor(node) {
|
|
1111
|
+
const parentNode = getParentNode(node);
|
|
1112
|
+
if (isLastTraversableNode(parentNode)) {
|
|
1113
|
+
return (node.ownerDocument || node).body;
|
|
1114
|
+
}
|
|
1115
|
+
if (isHTMLElement(parentNode) && isOverflowElement(parentNode)) {
|
|
1116
|
+
return parentNode;
|
|
1117
|
+
}
|
|
1118
|
+
return getNearestOverflowAncestor(parentNode);
|
|
1119
|
+
}
|
|
1120
|
+
function getOverflowAncestors(node, list, traverseIframes) {
|
|
1121
|
+
var _node$ownerDocument2;
|
|
1122
|
+
if (list === void 0) {
|
|
1123
|
+
list = [];
|
|
1124
|
+
}
|
|
1125
|
+
if (traverseIframes === void 0) {
|
|
1126
|
+
traverseIframes = true;
|
|
1127
|
+
}
|
|
1128
|
+
const scrollableAncestor = getNearestOverflowAncestor(node);
|
|
1129
|
+
const isBody = scrollableAncestor === ((_node$ownerDocument2 = node.ownerDocument) == null ? void 0 : _node$ownerDocument2.body);
|
|
1130
|
+
const win = getWindow(scrollableAncestor);
|
|
1131
|
+
if (isBody) {
|
|
1132
|
+
const frameElement = getFrameElement(win);
|
|
1133
|
+
return list.concat(win, win.visualViewport || [], isOverflowElement(scrollableAncestor) ? scrollableAncestor : [], frameElement && traverseIframes ? getOverflowAncestors(frameElement) : []);
|
|
1134
|
+
} else {
|
|
1135
|
+
return list.concat(scrollableAncestor, getOverflowAncestors(scrollableAncestor, [], traverseIframes));
|
|
1136
|
+
}
|
|
1137
|
+
}
|
|
1138
|
+
function getFrameElement(win) {
|
|
1139
|
+
return win.parent && Object.getPrototypeOf(win.parent) ? win.frameElement : null;
|
|
1140
|
+
}
|
|
1141
|
+
|
|
1142
|
+
// node_modules/@floating-ui/dom/dist/floating-ui.dom.mjs
|
|
1143
|
+
function getCssDimensions(element) {
|
|
1144
|
+
const css = getComputedStyle2(element);
|
|
1145
|
+
let width = parseFloat(css.width) || 0;
|
|
1146
|
+
let height = parseFloat(css.height) || 0;
|
|
1147
|
+
const hasOffset = isHTMLElement(element);
|
|
1148
|
+
const offsetWidth = hasOffset ? element.offsetWidth : width;
|
|
1149
|
+
const offsetHeight = hasOffset ? element.offsetHeight : height;
|
|
1150
|
+
const shouldFallback = round(width) !== offsetWidth || round(height) !== offsetHeight;
|
|
1151
|
+
if (shouldFallback) {
|
|
1152
|
+
width = offsetWidth;
|
|
1153
|
+
height = offsetHeight;
|
|
1154
|
+
}
|
|
1155
|
+
return {
|
|
1156
|
+
width,
|
|
1157
|
+
height,
|
|
1158
|
+
$: shouldFallback
|
|
1159
|
+
};
|
|
1160
|
+
}
|
|
1161
|
+
function unwrapElement(element) {
|
|
1162
|
+
return !isElement(element) ? element.contextElement : element;
|
|
1163
|
+
}
|
|
1164
|
+
function getScale(element) {
|
|
1165
|
+
const domElement = unwrapElement(element);
|
|
1166
|
+
if (!isHTMLElement(domElement)) {
|
|
1167
|
+
return createCoords(1);
|
|
1168
|
+
}
|
|
1169
|
+
const rect = domElement.getBoundingClientRect();
|
|
1170
|
+
const {
|
|
1171
|
+
width,
|
|
1172
|
+
height,
|
|
1173
|
+
$
|
|
1174
|
+
} = getCssDimensions(domElement);
|
|
1175
|
+
let x = ($ ? round(rect.width) : rect.width) / width;
|
|
1176
|
+
let y = ($ ? round(rect.height) : rect.height) / height;
|
|
1177
|
+
if (!x || !Number.isFinite(x)) {
|
|
1178
|
+
x = 1;
|
|
1179
|
+
}
|
|
1180
|
+
if (!y || !Number.isFinite(y)) {
|
|
1181
|
+
y = 1;
|
|
1182
|
+
}
|
|
1183
|
+
return {
|
|
1184
|
+
x,
|
|
1185
|
+
y
|
|
1186
|
+
};
|
|
1187
|
+
}
|
|
1188
|
+
var noOffsets = /* @__PURE__ */ createCoords(0);
|
|
1189
|
+
function getVisualOffsets(element) {
|
|
1190
|
+
const win = getWindow(element);
|
|
1191
|
+
if (!isWebKit() || !win.visualViewport) {
|
|
1192
|
+
return noOffsets;
|
|
1193
|
+
}
|
|
1194
|
+
return {
|
|
1195
|
+
x: win.visualViewport.offsetLeft,
|
|
1196
|
+
y: win.visualViewport.offsetTop
|
|
1197
|
+
};
|
|
1198
|
+
}
|
|
1199
|
+
function shouldAddVisualOffsets(element, isFixed, floatingOffsetParent) {
|
|
1200
|
+
if (isFixed === void 0) {
|
|
1201
|
+
isFixed = false;
|
|
1202
|
+
}
|
|
1203
|
+
return !!floatingOffsetParent && isFixed && floatingOffsetParent === getWindow(element);
|
|
1204
|
+
}
|
|
1205
|
+
function getBoundingClientRect(element, includeScale, isFixedStrategy, offsetParent) {
|
|
1206
|
+
if (includeScale === void 0) {
|
|
1207
|
+
includeScale = false;
|
|
1208
|
+
}
|
|
1209
|
+
if (isFixedStrategy === void 0) {
|
|
1210
|
+
isFixedStrategy = false;
|
|
1211
|
+
}
|
|
1212
|
+
const clientRect = element.getBoundingClientRect();
|
|
1213
|
+
const domElement = unwrapElement(element);
|
|
1214
|
+
let scale = createCoords(1);
|
|
1215
|
+
if (includeScale) {
|
|
1216
|
+
if (offsetParent) {
|
|
1217
|
+
if (isElement(offsetParent)) {
|
|
1218
|
+
scale = getScale(offsetParent);
|
|
1219
|
+
}
|
|
1220
|
+
} else {
|
|
1221
|
+
scale = getScale(element);
|
|
1222
|
+
}
|
|
1223
|
+
}
|
|
1224
|
+
const visualOffsets = shouldAddVisualOffsets(domElement, isFixedStrategy, offsetParent) ? getVisualOffsets(domElement) : createCoords(0);
|
|
1225
|
+
let x = (clientRect.left + visualOffsets.x) / scale.x;
|
|
1226
|
+
let y = (clientRect.top + visualOffsets.y) / scale.y;
|
|
1227
|
+
let width = clientRect.width / scale.x;
|
|
1228
|
+
let height = clientRect.height / scale.y;
|
|
1229
|
+
if (domElement && offsetParent) {
|
|
1230
|
+
const win = getWindow(domElement);
|
|
1231
|
+
const offsetWin = isElement(offsetParent) ? getWindow(offsetParent) : offsetParent;
|
|
1232
|
+
let currentWin = win;
|
|
1233
|
+
let currentIFrame = getFrameElement(currentWin);
|
|
1234
|
+
while (currentIFrame && offsetWin !== currentWin) {
|
|
1235
|
+
const iframeScale = getScale(currentIFrame);
|
|
1236
|
+
const iframeRect = currentIFrame.getBoundingClientRect();
|
|
1237
|
+
const css = getComputedStyle2(currentIFrame);
|
|
1238
|
+
const left = iframeRect.left + (currentIFrame.clientLeft + parseFloat(css.paddingLeft)) * iframeScale.x;
|
|
1239
|
+
const top = iframeRect.top + (currentIFrame.clientTop + parseFloat(css.paddingTop)) * iframeScale.y;
|
|
1240
|
+
x *= iframeScale.x;
|
|
1241
|
+
y *= iframeScale.y;
|
|
1242
|
+
width *= iframeScale.x;
|
|
1243
|
+
height *= iframeScale.y;
|
|
1244
|
+
x += left;
|
|
1245
|
+
y += top;
|
|
1246
|
+
currentWin = getWindow(currentIFrame);
|
|
1247
|
+
currentIFrame = getFrameElement(currentWin);
|
|
1248
|
+
}
|
|
1249
|
+
}
|
|
1250
|
+
return rectToClientRect({
|
|
1251
|
+
width,
|
|
1252
|
+
height,
|
|
1253
|
+
x,
|
|
1254
|
+
y
|
|
1255
|
+
});
|
|
1256
|
+
}
|
|
1257
|
+
function getWindowScrollBarX(element, rect) {
|
|
1258
|
+
const leftScroll = getNodeScroll(element).scrollLeft;
|
|
1259
|
+
if (!rect) {
|
|
1260
|
+
return getBoundingClientRect(getDocumentElement(element)).left + leftScroll;
|
|
1261
|
+
}
|
|
1262
|
+
return rect.left + leftScroll;
|
|
1263
|
+
}
|
|
1264
|
+
function getHTMLOffset(documentElement, scroll) {
|
|
1265
|
+
const htmlRect = documentElement.getBoundingClientRect();
|
|
1266
|
+
const x = htmlRect.left + scroll.scrollLeft - getWindowScrollBarX(documentElement, htmlRect);
|
|
1267
|
+
const y = htmlRect.top + scroll.scrollTop;
|
|
1268
|
+
return {
|
|
1269
|
+
x,
|
|
1270
|
+
y
|
|
1271
|
+
};
|
|
1272
|
+
}
|
|
1273
|
+
function convertOffsetParentRelativeRectToViewportRelativeRect(_ref) {
|
|
1274
|
+
let {
|
|
1275
|
+
elements,
|
|
1276
|
+
rect,
|
|
1277
|
+
offsetParent,
|
|
1278
|
+
strategy
|
|
1279
|
+
} = _ref;
|
|
1280
|
+
const isFixed = strategy === "fixed";
|
|
1281
|
+
const documentElement = getDocumentElement(offsetParent);
|
|
1282
|
+
const topLayer = elements ? isTopLayer(elements.floating) : false;
|
|
1283
|
+
if (offsetParent === documentElement || topLayer && isFixed) {
|
|
1284
|
+
return rect;
|
|
1285
|
+
}
|
|
1286
|
+
let scroll = {
|
|
1287
|
+
scrollLeft: 0,
|
|
1288
|
+
scrollTop: 0
|
|
1289
|
+
};
|
|
1290
|
+
let scale = createCoords(1);
|
|
1291
|
+
const offsets = createCoords(0);
|
|
1292
|
+
const isOffsetParentAnElement = isHTMLElement(offsetParent);
|
|
1293
|
+
if (isOffsetParentAnElement || !isFixed) {
|
|
1294
|
+
if (getNodeName(offsetParent) !== "body" || isOverflowElement(documentElement)) {
|
|
1295
|
+
scroll = getNodeScroll(offsetParent);
|
|
1296
|
+
}
|
|
1297
|
+
if (isOffsetParentAnElement) {
|
|
1298
|
+
const offsetRect = getBoundingClientRect(offsetParent);
|
|
1299
|
+
scale = getScale(offsetParent);
|
|
1300
|
+
offsets.x = offsetRect.x + offsetParent.clientLeft;
|
|
1301
|
+
offsets.y = offsetRect.y + offsetParent.clientTop;
|
|
1302
|
+
}
|
|
1303
|
+
}
|
|
1304
|
+
const htmlOffset = documentElement && !isOffsetParentAnElement && !isFixed ? getHTMLOffset(documentElement, scroll) : createCoords(0);
|
|
1305
|
+
return {
|
|
1306
|
+
width: rect.width * scale.x,
|
|
1307
|
+
height: rect.height * scale.y,
|
|
1308
|
+
x: rect.x * scale.x - scroll.scrollLeft * scale.x + offsets.x + htmlOffset.x,
|
|
1309
|
+
y: rect.y * scale.y - scroll.scrollTop * scale.y + offsets.y + htmlOffset.y
|
|
1310
|
+
};
|
|
1311
|
+
}
|
|
1312
|
+
function getClientRects(element) {
|
|
1313
|
+
return element.getClientRects ? Array.from(element.getClientRects()) : [];
|
|
1314
|
+
}
|
|
1315
|
+
function getDocumentRect(html) {
|
|
1316
|
+
const scroll = getNodeScroll(html);
|
|
1317
|
+
const body = html.ownerDocument.body;
|
|
1318
|
+
const width = max(html.scrollWidth, html.clientWidth, body.scrollWidth, body.clientWidth);
|
|
1319
|
+
const height = max(html.scrollHeight, html.clientHeight, body.scrollHeight, body.clientHeight);
|
|
1320
|
+
let x = -scroll.scrollLeft + getWindowScrollBarX(html);
|
|
1321
|
+
const y = -scroll.scrollTop;
|
|
1322
|
+
if (getComputedStyle2(body).direction === "rtl") {
|
|
1323
|
+
x += max(html.clientWidth, body.clientWidth) - width;
|
|
1324
|
+
}
|
|
1325
|
+
return {
|
|
1326
|
+
width,
|
|
1327
|
+
height,
|
|
1328
|
+
x,
|
|
1329
|
+
y
|
|
1330
|
+
};
|
|
1331
|
+
}
|
|
1332
|
+
var SCROLLBAR_MAX = 25;
|
|
1333
|
+
function getViewportRect(element, strategy, rootBoundary) {
|
|
1334
|
+
if (rootBoundary === void 0) {
|
|
1335
|
+
rootBoundary = "viewport";
|
|
1336
|
+
}
|
|
1337
|
+
const isLayoutViewport = rootBoundary === "layoutViewport";
|
|
1338
|
+
const win = getWindow(element);
|
|
1339
|
+
const html = getDocumentElement(element);
|
|
1340
|
+
const visualViewport = win.visualViewport;
|
|
1341
|
+
let width = html.clientWidth;
|
|
1342
|
+
let height = html.clientHeight;
|
|
1343
|
+
let x = 0;
|
|
1344
|
+
let y = 0;
|
|
1345
|
+
if (visualViewport) {
|
|
1346
|
+
const layoutRelativeClientCoords = !isWebKit() || strategy === "fixed";
|
|
1347
|
+
if (isLayoutViewport) {
|
|
1348
|
+
if (!layoutRelativeClientCoords) {
|
|
1349
|
+
x = -visualViewport.offsetLeft;
|
|
1350
|
+
y = -visualViewport.offsetTop;
|
|
1351
|
+
}
|
|
1352
|
+
} else {
|
|
1353
|
+
width = visualViewport.width;
|
|
1354
|
+
height = visualViewport.height;
|
|
1355
|
+
if (layoutRelativeClientCoords) {
|
|
1356
|
+
x = visualViewport.offsetLeft;
|
|
1357
|
+
y = visualViewport.offsetTop;
|
|
1358
|
+
}
|
|
1359
|
+
}
|
|
1360
|
+
}
|
|
1361
|
+
const windowScrollbarX = getWindowScrollBarX(html);
|
|
1362
|
+
if (windowScrollbarX <= 0) {
|
|
1363
|
+
const doc = html.ownerDocument;
|
|
1364
|
+
const body = doc.body;
|
|
1365
|
+
const bodyStyles = getComputedStyle(body);
|
|
1366
|
+
const bodyMarginInline = doc.compatMode === "CSS1Compat" ? parseFloat(bodyStyles.marginLeft) + parseFloat(bodyStyles.marginRight) || 0 : 0;
|
|
1367
|
+
const reservedWidth = Math.abs(html.clientWidth - body.clientWidth - bodyMarginInline);
|
|
1368
|
+
const gutter = getComputedStyle(html).scrollbarGutter === "stable both-edges" ? reservedWidth / 2 : reservedWidth;
|
|
1369
|
+
if (gutter <= SCROLLBAR_MAX) {
|
|
1370
|
+
width -= gutter;
|
|
1371
|
+
}
|
|
1372
|
+
}
|
|
1373
|
+
return {
|
|
1374
|
+
width,
|
|
1375
|
+
height,
|
|
1376
|
+
x,
|
|
1377
|
+
y
|
|
1378
|
+
};
|
|
1379
|
+
}
|
|
1380
|
+
function getInnerBoundingClientRect(element, strategy) {
|
|
1381
|
+
const clientRect = getBoundingClientRect(element, true, strategy === "fixed");
|
|
1382
|
+
const top = clientRect.top + element.clientTop;
|
|
1383
|
+
const left = clientRect.left + element.clientLeft;
|
|
1384
|
+
const scale = getScale(element);
|
|
1385
|
+
const width = element.clientWidth * scale.x;
|
|
1386
|
+
const height = element.clientHeight * scale.y;
|
|
1387
|
+
const x = left * scale.x;
|
|
1388
|
+
const y = top * scale.y;
|
|
1389
|
+
return {
|
|
1390
|
+
width,
|
|
1391
|
+
height,
|
|
1392
|
+
x,
|
|
1393
|
+
y
|
|
1394
|
+
};
|
|
1395
|
+
}
|
|
1396
|
+
function getClientRectFromClippingAncestor(element, clippingAncestor, strategy) {
|
|
1397
|
+
let rect;
|
|
1398
|
+
if (clippingAncestor === "viewport" || clippingAncestor === "layoutViewport") {
|
|
1399
|
+
rect = getViewportRect(element, strategy, clippingAncestor);
|
|
1400
|
+
} else if (clippingAncestor === "document") {
|
|
1401
|
+
rect = getDocumentRect(getDocumentElement(element));
|
|
1402
|
+
} else if (isElement(clippingAncestor)) {
|
|
1403
|
+
rect = getInnerBoundingClientRect(clippingAncestor, strategy);
|
|
1404
|
+
} else {
|
|
1405
|
+
const visualOffsets = getVisualOffsets(element);
|
|
1406
|
+
rect = {
|
|
1407
|
+
x: clippingAncestor.x - visualOffsets.x,
|
|
1408
|
+
y: clippingAncestor.y - visualOffsets.y,
|
|
1409
|
+
width: clippingAncestor.width,
|
|
1410
|
+
height: clippingAncestor.height
|
|
1411
|
+
};
|
|
1412
|
+
}
|
|
1413
|
+
return rectToClientRect(rect);
|
|
1414
|
+
}
|
|
1415
|
+
function getClippingElementAncestors(element, cache) {
|
|
1416
|
+
const cachedResult = cache.get(element);
|
|
1417
|
+
if (cachedResult) {
|
|
1418
|
+
return cachedResult;
|
|
1419
|
+
}
|
|
1420
|
+
let result = getOverflowAncestors(element, [], false).filter((el) => isElement(el) && getNodeName(el) !== "body");
|
|
1421
|
+
let lastKeptComputedStyle = null;
|
|
1422
|
+
const elementIsFixed = getComputedStyle2(element).position === "fixed";
|
|
1423
|
+
let currentNode = elementIsFixed ? getParentNode(element) : element;
|
|
1424
|
+
while (isElement(currentNode) && !isLastTraversableNode(currentNode)) {
|
|
1425
|
+
const computedStyle = getComputedStyle2(currentNode);
|
|
1426
|
+
const currentNodeIsContaining = isContainingBlock(currentNode);
|
|
1427
|
+
const lastPosition = lastKeptComputedStyle ? lastKeptComputedStyle.position : elementIsFixed ? "fixed" : "";
|
|
1428
|
+
const shouldDropCurrentNode = !currentNodeIsContaining && (lastPosition === "fixed" || lastPosition === "absolute" && computedStyle.position === "static");
|
|
1429
|
+
if (shouldDropCurrentNode) {
|
|
1430
|
+
result = result.filter((ancestor) => ancestor !== currentNode);
|
|
1431
|
+
} else {
|
|
1432
|
+
lastKeptComputedStyle = computedStyle;
|
|
1433
|
+
}
|
|
1434
|
+
currentNode = getParentNode(currentNode);
|
|
1435
|
+
}
|
|
1436
|
+
cache.set(element, result);
|
|
1437
|
+
return result;
|
|
1438
|
+
}
|
|
1439
|
+
function getClippingRect(_ref) {
|
|
1440
|
+
let {
|
|
1441
|
+
element,
|
|
1442
|
+
boundary,
|
|
1443
|
+
rootBoundary,
|
|
1444
|
+
strategy
|
|
1445
|
+
} = _ref;
|
|
1446
|
+
const elementClippingAncestors = boundary === "clippingAncestors" ? isTopLayer(element) ? [] : getClippingElementAncestors(element, this._c) : [].concat(boundary);
|
|
1447
|
+
const clippingAncestors = [...elementClippingAncestors, rootBoundary];
|
|
1448
|
+
const firstRect = getClientRectFromClippingAncestor(element, clippingAncestors[0], strategy);
|
|
1449
|
+
let top = firstRect.top;
|
|
1450
|
+
let right = firstRect.right;
|
|
1451
|
+
let bottom = firstRect.bottom;
|
|
1452
|
+
let left = firstRect.left;
|
|
1453
|
+
for (let i = 1; i < clippingAncestors.length; i++) {
|
|
1454
|
+
const rect = getClientRectFromClippingAncestor(element, clippingAncestors[i], strategy);
|
|
1455
|
+
top = max(rect.top, top);
|
|
1456
|
+
right = min(rect.right, right);
|
|
1457
|
+
bottom = min(rect.bottom, bottom);
|
|
1458
|
+
left = max(rect.left, left);
|
|
1459
|
+
}
|
|
1460
|
+
return {
|
|
1461
|
+
width: right - left,
|
|
1462
|
+
height: bottom - top,
|
|
1463
|
+
x: left,
|
|
1464
|
+
y: top
|
|
1465
|
+
};
|
|
1466
|
+
}
|
|
1467
|
+
function getDimensions(element) {
|
|
1468
|
+
const {
|
|
1469
|
+
width,
|
|
1470
|
+
height
|
|
1471
|
+
} = getCssDimensions(element);
|
|
1472
|
+
return {
|
|
1473
|
+
width,
|
|
1474
|
+
height
|
|
1475
|
+
};
|
|
1476
|
+
}
|
|
1477
|
+
function getRectRelativeToOffsetParent(element, offsetParent, strategy) {
|
|
1478
|
+
const isOffsetParentAnElement = isHTMLElement(offsetParent);
|
|
1479
|
+
const documentElement = getDocumentElement(offsetParent);
|
|
1480
|
+
const isFixed = strategy === "fixed";
|
|
1481
|
+
const rect = getBoundingClientRect(element, true, isFixed, offsetParent);
|
|
1482
|
+
let scroll = {
|
|
1483
|
+
scrollLeft: 0,
|
|
1484
|
+
scrollTop: 0
|
|
1485
|
+
};
|
|
1486
|
+
const offsets = createCoords(0);
|
|
1487
|
+
if (isOffsetParentAnElement || !isFixed) {
|
|
1488
|
+
if (getNodeName(offsetParent) !== "body" || isOverflowElement(documentElement)) {
|
|
1489
|
+
scroll = getNodeScroll(offsetParent);
|
|
1490
|
+
}
|
|
1491
|
+
if (isOffsetParentAnElement) {
|
|
1492
|
+
const offsetRect = getBoundingClientRect(offsetParent, true, isFixed, offsetParent);
|
|
1493
|
+
offsets.x = offsetRect.x + offsetParent.clientLeft;
|
|
1494
|
+
offsets.y = offsetRect.y + offsetParent.clientTop;
|
|
1495
|
+
}
|
|
1496
|
+
}
|
|
1497
|
+
if (!isOffsetParentAnElement && documentElement) {
|
|
1498
|
+
offsets.x = getWindowScrollBarX(documentElement);
|
|
1499
|
+
}
|
|
1500
|
+
const htmlOffset = documentElement && !isOffsetParentAnElement && !isFixed ? getHTMLOffset(documentElement, scroll) : createCoords(0);
|
|
1501
|
+
const x = rect.left + scroll.scrollLeft - offsets.x - htmlOffset.x;
|
|
1502
|
+
const y = rect.top + scroll.scrollTop - offsets.y - htmlOffset.y;
|
|
1503
|
+
return {
|
|
1504
|
+
x,
|
|
1505
|
+
y,
|
|
1506
|
+
width: rect.width,
|
|
1507
|
+
height: rect.height
|
|
1508
|
+
};
|
|
1509
|
+
}
|
|
1510
|
+
function isStaticPositioned(element) {
|
|
1511
|
+
return getComputedStyle2(element).position === "static";
|
|
1512
|
+
}
|
|
1513
|
+
function getTrueOffsetParent(element, polyfill) {
|
|
1514
|
+
if (!isHTMLElement(element) || getComputedStyle2(element).position === "fixed") {
|
|
1515
|
+
return null;
|
|
1516
|
+
}
|
|
1517
|
+
if (polyfill) {
|
|
1518
|
+
return polyfill(element);
|
|
1519
|
+
}
|
|
1520
|
+
let rawOffsetParent = element.offsetParent;
|
|
1521
|
+
if (getDocumentElement(element) === rawOffsetParent) {
|
|
1522
|
+
rawOffsetParent = rawOffsetParent.ownerDocument.body;
|
|
1523
|
+
}
|
|
1524
|
+
return rawOffsetParent;
|
|
1525
|
+
}
|
|
1526
|
+
function getOffsetParent(element, polyfill) {
|
|
1527
|
+
const win = getWindow(element);
|
|
1528
|
+
if (isTopLayer(element)) {
|
|
1529
|
+
return win;
|
|
1530
|
+
}
|
|
1531
|
+
if (!isHTMLElement(element)) {
|
|
1532
|
+
let svgOffsetParent = getParentNode(element);
|
|
1533
|
+
while (svgOffsetParent && !isLastTraversableNode(svgOffsetParent)) {
|
|
1534
|
+
if (isElement(svgOffsetParent) && !isStaticPositioned(svgOffsetParent)) {
|
|
1535
|
+
return svgOffsetParent;
|
|
1536
|
+
}
|
|
1537
|
+
svgOffsetParent = getParentNode(svgOffsetParent);
|
|
1538
|
+
}
|
|
1539
|
+
return win;
|
|
1540
|
+
}
|
|
1541
|
+
let offsetParent = getTrueOffsetParent(element, polyfill);
|
|
1542
|
+
while (offsetParent && isTableElement(offsetParent) && isStaticPositioned(offsetParent)) {
|
|
1543
|
+
offsetParent = getTrueOffsetParent(offsetParent, polyfill);
|
|
1544
|
+
}
|
|
1545
|
+
if (offsetParent && isLastTraversableNode(offsetParent) && isStaticPositioned(offsetParent) && !isContainingBlock(offsetParent)) {
|
|
1546
|
+
return win;
|
|
1547
|
+
}
|
|
1548
|
+
return offsetParent || getContainingBlock(element) || win;
|
|
1549
|
+
}
|
|
1550
|
+
var getElementRects = async function(data) {
|
|
1551
|
+
const getOffsetParentFn = this.getOffsetParent || getOffsetParent;
|
|
1552
|
+
const getDimensionsFn = this.getDimensions;
|
|
1553
|
+
const floatingDimensions = await getDimensionsFn(data.floating);
|
|
1554
|
+
return {
|
|
1555
|
+
reference: getRectRelativeToOffsetParent(data.reference, await getOffsetParentFn(data.floating), data.strategy),
|
|
1556
|
+
floating: {
|
|
1557
|
+
x: 0,
|
|
1558
|
+
y: 0,
|
|
1559
|
+
width: floatingDimensions.width,
|
|
1560
|
+
height: floatingDimensions.height
|
|
1561
|
+
}
|
|
1562
|
+
};
|
|
1563
|
+
};
|
|
1564
|
+
function isRTL(element) {
|
|
1565
|
+
return getComputedStyle2(element).direction === "rtl";
|
|
1566
|
+
}
|
|
1567
|
+
var platform = {
|
|
1568
|
+
convertOffsetParentRelativeRectToViewportRelativeRect,
|
|
1569
|
+
getDocumentElement,
|
|
1570
|
+
getClippingRect,
|
|
1571
|
+
getOffsetParent,
|
|
1572
|
+
getElementRects,
|
|
1573
|
+
getClientRects,
|
|
1574
|
+
getDimensions,
|
|
1575
|
+
getScale,
|
|
1576
|
+
isElement,
|
|
1577
|
+
isRTL
|
|
1578
|
+
};
|
|
1579
|
+
var offset2 = offset;
|
|
1580
|
+
var autoPlacement2 = autoPlacement;
|
|
1581
|
+
var shift2 = shift;
|
|
1582
|
+
var flip2 = flip;
|
|
1583
|
+
var size2 = size;
|
|
1584
|
+
var hide2 = hide;
|
|
1585
|
+
var arrow2 = arrow;
|
|
1586
|
+
var inline2 = inline;
|
|
1587
|
+
var computePosition2 = (reference, floating, options) => {
|
|
1588
|
+
const cache = /* @__PURE__ */ new Map();
|
|
1589
|
+
const mergedOptions = options != null ? options : {};
|
|
1590
|
+
const platformWithCache = {
|
|
1591
|
+
...platform,
|
|
1592
|
+
...mergedOptions.platform,
|
|
1593
|
+
_c: cache
|
|
1594
|
+
};
|
|
1595
|
+
return computePosition(reference, floating, {
|
|
1596
|
+
...mergedOptions,
|
|
1597
|
+
platform: platformWithCache
|
|
1598
|
+
});
|
|
1599
|
+
};
|
|
1600
|
+
|
|
1601
|
+
// node_modules/@tiptap/extension-floating-menu/dist/index.js
|
|
1602
|
+
var FloatingMenuView = class {
|
|
1603
|
+
constructor({
|
|
1604
|
+
editor,
|
|
1605
|
+
element,
|
|
1606
|
+
view,
|
|
1607
|
+
pluginKey = "floatingMenu",
|
|
1608
|
+
updateDelay = 250,
|
|
1609
|
+
resizeDelay = 60,
|
|
1610
|
+
options,
|
|
1611
|
+
appendTo,
|
|
1612
|
+
shouldShow
|
|
1613
|
+
}) {
|
|
1614
|
+
this.preventHide = false;
|
|
1615
|
+
this.isVisible = false;
|
|
1616
|
+
this.scrollTarget = window;
|
|
1617
|
+
this.shouldShow = ({ view: view2, state }) => {
|
|
1618
|
+
const { selection } = state;
|
|
1619
|
+
const { $anchor, empty } = selection;
|
|
1620
|
+
const isRootDepth = $anchor.depth === 1;
|
|
1621
|
+
const isEmptyTextBlock = $anchor.parent.isTextblock && !$anchor.parent.type.spec.code && !$anchor.parent.textContent && $anchor.parent.childCount === 0 && !this.getTextContent($anchor.parent);
|
|
1622
|
+
if (!view2.hasFocus() || !empty || !isRootDepth || !isEmptyTextBlock || !this.editor.isEditable) {
|
|
1623
|
+
return false;
|
|
1624
|
+
}
|
|
1625
|
+
return true;
|
|
1626
|
+
};
|
|
1627
|
+
this.floatingUIOptions = {
|
|
1628
|
+
strategy: "absolute",
|
|
1629
|
+
placement: "right",
|
|
1630
|
+
offset: 8,
|
|
1631
|
+
flip: {},
|
|
1632
|
+
shift: {},
|
|
1633
|
+
arrow: false,
|
|
1634
|
+
size: false,
|
|
1635
|
+
autoPlacement: false,
|
|
1636
|
+
hide: false,
|
|
1637
|
+
inline: false
|
|
1638
|
+
};
|
|
1639
|
+
this.updateHandler = (view2, selectionChanged, docChanged, oldState) => {
|
|
1640
|
+
const { composing } = view2;
|
|
1641
|
+
const isSame = !selectionChanged && !docChanged;
|
|
1642
|
+
if (composing || isSame) {
|
|
1643
|
+
return;
|
|
1644
|
+
}
|
|
1645
|
+
const shouldShow2 = this.getShouldShow(oldState);
|
|
1646
|
+
if (!shouldShow2) {
|
|
1647
|
+
this.hide();
|
|
1648
|
+
return;
|
|
1649
|
+
}
|
|
1650
|
+
this.updatePosition();
|
|
1651
|
+
this.show();
|
|
1652
|
+
};
|
|
1653
|
+
this.mousedownHandler = () => {
|
|
1654
|
+
this.preventHide = true;
|
|
1655
|
+
};
|
|
1656
|
+
this.focusHandler = () => {
|
|
1657
|
+
setTimeout(() => this.update(this.editor.view));
|
|
1658
|
+
};
|
|
1659
|
+
this.blurHandler = ({ event }) => {
|
|
1660
|
+
var _a2;
|
|
1661
|
+
if (this.preventHide) {
|
|
1662
|
+
this.preventHide = false;
|
|
1663
|
+
return;
|
|
1664
|
+
}
|
|
1665
|
+
if ((event == null ? void 0 : event.relatedTarget) && ((_a2 = this.element.parentNode) == null ? void 0 : _a2.contains(event.relatedTarget))) {
|
|
1666
|
+
return;
|
|
1667
|
+
}
|
|
1668
|
+
if ((event == null ? void 0 : event.relatedTarget) === this.editor.view.dom) {
|
|
1669
|
+
return;
|
|
1670
|
+
}
|
|
1671
|
+
this.hide();
|
|
1672
|
+
};
|
|
1673
|
+
this.transactionHandler = ({ transaction: tr }) => {
|
|
1674
|
+
const meta = tr.getMeta(this.pluginKey);
|
|
1675
|
+
if (meta === "updatePosition") {
|
|
1676
|
+
this.updatePosition();
|
|
1677
|
+
} else if (meta && typeof meta === "object" && meta.type === "updateOptions") {
|
|
1678
|
+
this.updateOptions(meta.options);
|
|
1679
|
+
} else if (meta === "hide") {
|
|
1680
|
+
this.hide();
|
|
1681
|
+
} else if (meta === "show") {
|
|
1682
|
+
this.updatePosition();
|
|
1683
|
+
this.show();
|
|
1684
|
+
}
|
|
1685
|
+
};
|
|
1686
|
+
this.resizeHandler = () => {
|
|
1687
|
+
if (this.resizeDebounceTimer) {
|
|
1688
|
+
clearTimeout(this.resizeDebounceTimer);
|
|
1689
|
+
}
|
|
1690
|
+
this.resizeDebounceTimer = window.setTimeout(() => {
|
|
1691
|
+
this.updatePosition();
|
|
1692
|
+
}, this.resizeDelay);
|
|
1693
|
+
};
|
|
1694
|
+
var _a;
|
|
1695
|
+
this.editor = editor;
|
|
1696
|
+
this.element = element;
|
|
1697
|
+
this.view = view;
|
|
1698
|
+
this.pluginKey = pluginKey;
|
|
1699
|
+
this.updateDelay = updateDelay;
|
|
1700
|
+
this.resizeDelay = resizeDelay;
|
|
1701
|
+
this.appendTo = appendTo;
|
|
1702
|
+
this.scrollTarget = (_a = options == null ? void 0 : options.scrollTarget) != null ? _a : window;
|
|
1703
|
+
this.floatingUIOptions = {
|
|
1704
|
+
...this.floatingUIOptions,
|
|
1705
|
+
...options
|
|
1706
|
+
};
|
|
1707
|
+
this.element.tabIndex = 0;
|
|
1708
|
+
if (shouldShow) {
|
|
1709
|
+
this.shouldShow = shouldShow;
|
|
1710
|
+
}
|
|
1711
|
+
this.element.addEventListener("mousedown", this.mousedownHandler, { capture: true });
|
|
1712
|
+
this.editor.on("focus", this.focusHandler);
|
|
1713
|
+
this.editor.on("blur", this.blurHandler);
|
|
1714
|
+
this.editor.on("transaction", this.transactionHandler);
|
|
1715
|
+
window.addEventListener("resize", this.resizeHandler);
|
|
1716
|
+
this.scrollTarget.addEventListener("scroll", this.resizeHandler);
|
|
1717
|
+
this.update(view, view.state);
|
|
1718
|
+
if (this.getShouldShow()) {
|
|
1719
|
+
this.show();
|
|
1720
|
+
this.updatePosition();
|
|
1721
|
+
}
|
|
1722
|
+
}
|
|
1723
|
+
getTextContent(node) {
|
|
1724
|
+
return getText(node, { textSerializers: getTextSerializersFromSchema(this.editor.schema) });
|
|
1725
|
+
}
|
|
1726
|
+
get middlewares() {
|
|
1727
|
+
const middlewares = [];
|
|
1728
|
+
if (this.floatingUIOptions.flip) {
|
|
1729
|
+
middlewares.push(
|
|
1730
|
+
flip2(
|
|
1731
|
+
typeof this.floatingUIOptions.flip !== "boolean" ? this.floatingUIOptions.flip : void 0
|
|
1732
|
+
)
|
|
1733
|
+
);
|
|
1734
|
+
}
|
|
1735
|
+
if (this.floatingUIOptions.shift) {
|
|
1736
|
+
middlewares.push(
|
|
1737
|
+
shift2(
|
|
1738
|
+
typeof this.floatingUIOptions.shift !== "boolean" ? this.floatingUIOptions.shift : void 0
|
|
1739
|
+
)
|
|
1740
|
+
);
|
|
1741
|
+
}
|
|
1742
|
+
if (this.floatingUIOptions.offset) {
|
|
1743
|
+
middlewares.push(
|
|
1744
|
+
offset2(
|
|
1745
|
+
typeof this.floatingUIOptions.offset !== "boolean" ? this.floatingUIOptions.offset : void 0
|
|
1746
|
+
)
|
|
1747
|
+
);
|
|
1748
|
+
}
|
|
1749
|
+
if (this.floatingUIOptions.arrow) {
|
|
1750
|
+
middlewares.push(arrow2(this.floatingUIOptions.arrow));
|
|
1751
|
+
}
|
|
1752
|
+
if (this.floatingUIOptions.size) {
|
|
1753
|
+
middlewares.push(
|
|
1754
|
+
size2(
|
|
1755
|
+
typeof this.floatingUIOptions.size !== "boolean" ? this.floatingUIOptions.size : void 0
|
|
1756
|
+
)
|
|
1757
|
+
);
|
|
1758
|
+
}
|
|
1759
|
+
if (this.floatingUIOptions.autoPlacement) {
|
|
1760
|
+
middlewares.push(
|
|
1761
|
+
autoPlacement2(
|
|
1762
|
+
typeof this.floatingUIOptions.autoPlacement !== "boolean" ? this.floatingUIOptions.autoPlacement : void 0
|
|
1763
|
+
)
|
|
1764
|
+
);
|
|
1765
|
+
}
|
|
1766
|
+
if (this.floatingUIOptions.hide) {
|
|
1767
|
+
middlewares.push(
|
|
1768
|
+
hide2(
|
|
1769
|
+
typeof this.floatingUIOptions.hide !== "boolean" ? this.floatingUIOptions.hide : void 0
|
|
1770
|
+
)
|
|
1771
|
+
);
|
|
1772
|
+
}
|
|
1773
|
+
if (this.floatingUIOptions.inline) {
|
|
1774
|
+
middlewares.push(
|
|
1775
|
+
inline2(
|
|
1776
|
+
typeof this.floatingUIOptions.inline !== "boolean" ? this.floatingUIOptions.inline : void 0
|
|
1777
|
+
)
|
|
1778
|
+
);
|
|
1779
|
+
}
|
|
1780
|
+
return middlewares;
|
|
1781
|
+
}
|
|
1782
|
+
getShouldShow(oldState) {
|
|
1783
|
+
var _a;
|
|
1784
|
+
const { state } = this.view;
|
|
1785
|
+
const { selection } = state;
|
|
1786
|
+
const { ranges } = selection;
|
|
1787
|
+
const from = Math.min(...ranges.map((range) => range.$from.pos));
|
|
1788
|
+
const to = Math.max(...ranges.map((range) => range.$to.pos));
|
|
1789
|
+
const shouldShow = (_a = this.shouldShow) == null ? void 0 : _a.call(this, {
|
|
1790
|
+
editor: this.editor,
|
|
1791
|
+
view: this.view,
|
|
1792
|
+
state,
|
|
1793
|
+
oldState,
|
|
1794
|
+
from,
|
|
1795
|
+
to
|
|
1796
|
+
});
|
|
1797
|
+
return shouldShow;
|
|
1798
|
+
}
|
|
1799
|
+
updateOptions(newProps) {
|
|
1800
|
+
var _a;
|
|
1801
|
+
if (newProps.updateDelay !== void 0) {
|
|
1802
|
+
this.updateDelay = newProps.updateDelay;
|
|
1803
|
+
}
|
|
1804
|
+
if (newProps.resizeDelay !== void 0) {
|
|
1805
|
+
this.resizeDelay = newProps.resizeDelay;
|
|
1806
|
+
}
|
|
1807
|
+
if (newProps.appendTo !== void 0) {
|
|
1808
|
+
this.appendTo = newProps.appendTo;
|
|
1809
|
+
}
|
|
1810
|
+
if (newProps.shouldShow !== void 0) {
|
|
1811
|
+
if (newProps.shouldShow) {
|
|
1812
|
+
this.shouldShow = newProps.shouldShow;
|
|
1813
|
+
}
|
|
1814
|
+
}
|
|
1815
|
+
if (newProps.options !== void 0) {
|
|
1816
|
+
const newScrollTarget = (_a = newProps.options.scrollTarget) != null ? _a : window;
|
|
1817
|
+
if (newScrollTarget !== this.scrollTarget) {
|
|
1818
|
+
this.scrollTarget.removeEventListener("scroll", this.resizeHandler);
|
|
1819
|
+
this.scrollTarget = newScrollTarget;
|
|
1820
|
+
this.scrollTarget.addEventListener("scroll", this.resizeHandler);
|
|
1821
|
+
}
|
|
1822
|
+
this.floatingUIOptions = {
|
|
1823
|
+
...this.floatingUIOptions,
|
|
1824
|
+
...newProps.options
|
|
1825
|
+
};
|
|
1826
|
+
}
|
|
1827
|
+
}
|
|
1828
|
+
updatePosition() {
|
|
1829
|
+
var _a, _b;
|
|
1830
|
+
if (!((_b = (_a = this.view) == null ? void 0 : _a.dom) == null ? void 0 : _b.parentNode)) {
|
|
1831
|
+
return;
|
|
1832
|
+
}
|
|
1833
|
+
const { selection } = this.editor.state;
|
|
1834
|
+
const domRect = posToDOMRect(this.view, selection.from, selection.to);
|
|
1835
|
+
const virtualElement = {
|
|
1836
|
+
getBoundingClientRect: () => domRect,
|
|
1837
|
+
getClientRects: () => [domRect]
|
|
1838
|
+
};
|
|
1839
|
+
computePosition2(virtualElement, this.element, {
|
|
1840
|
+
placement: this.floatingUIOptions.placement,
|
|
1841
|
+
strategy: this.floatingUIOptions.strategy,
|
|
1842
|
+
middleware: this.middlewares
|
|
1843
|
+
}).then(({ x, y, strategy, middlewareData }) => {
|
|
1844
|
+
var _a2, _b2;
|
|
1845
|
+
if (((_a2 = middlewareData.hide) == null ? void 0 : _a2.referenceHidden) || ((_b2 = middlewareData.hide) == null ? void 0 : _b2.escaped)) {
|
|
1846
|
+
this.element.style.visibility = "hidden";
|
|
1847
|
+
return;
|
|
1848
|
+
}
|
|
1849
|
+
this.element.style.visibility = "visible";
|
|
1850
|
+
this.element.style.width = "max-content";
|
|
1851
|
+
this.element.style.position = strategy;
|
|
1852
|
+
this.element.style.left = `${x}px`;
|
|
1853
|
+
this.element.style.top = `${y}px`;
|
|
1854
|
+
if (this.isVisible && this.floatingUIOptions.onUpdate) {
|
|
1855
|
+
this.floatingUIOptions.onUpdate();
|
|
1856
|
+
}
|
|
1857
|
+
});
|
|
1858
|
+
}
|
|
1859
|
+
update(view, oldState) {
|
|
1860
|
+
const selectionChanged = !(oldState == null ? void 0 : oldState.selection.eq(view.state.selection));
|
|
1861
|
+
const docChanged = !(oldState == null ? void 0 : oldState.doc.eq(view.state.doc));
|
|
1862
|
+
this.updateHandler(view, selectionChanged, docChanged, oldState);
|
|
1863
|
+
}
|
|
1864
|
+
show() {
|
|
1865
|
+
var _a;
|
|
1866
|
+
if (this.isVisible) {
|
|
1867
|
+
return;
|
|
1868
|
+
}
|
|
1869
|
+
this.element.style.visibility = "visible";
|
|
1870
|
+
this.element.style.opacity = "1";
|
|
1871
|
+
const appendToElement = typeof this.appendTo === "function" ? this.appendTo() : this.appendTo;
|
|
1872
|
+
(_a = appendToElement != null ? appendToElement : this.view.dom.parentElement) == null ? void 0 : _a.appendChild(this.element);
|
|
1873
|
+
if (this.floatingUIOptions.onShow) {
|
|
1874
|
+
this.floatingUIOptions.onShow();
|
|
1875
|
+
}
|
|
1876
|
+
this.isVisible = true;
|
|
1877
|
+
}
|
|
1878
|
+
hide() {
|
|
1879
|
+
if (!this.isVisible) {
|
|
1880
|
+
return;
|
|
1881
|
+
}
|
|
1882
|
+
this.element.style.visibility = "hidden";
|
|
1883
|
+
this.element.style.opacity = "0";
|
|
1884
|
+
this.element.remove();
|
|
1885
|
+
if (this.floatingUIOptions.onHide) {
|
|
1886
|
+
this.floatingUIOptions.onHide();
|
|
1887
|
+
}
|
|
1888
|
+
this.isVisible = false;
|
|
1889
|
+
}
|
|
1890
|
+
destroy() {
|
|
1891
|
+
this.hide();
|
|
1892
|
+
this.element.removeEventListener("mousedown", this.mousedownHandler, { capture: true });
|
|
1893
|
+
window.removeEventListener("resize", this.resizeHandler);
|
|
1894
|
+
this.scrollTarget.removeEventListener("scroll", this.resizeHandler);
|
|
1895
|
+
this.editor.off("focus", this.focusHandler);
|
|
1896
|
+
this.editor.off("blur", this.blurHandler);
|
|
1897
|
+
this.editor.off("transaction", this.transactionHandler);
|
|
1898
|
+
if (this.floatingUIOptions.onDestroy) {
|
|
1899
|
+
this.floatingUIOptions.onDestroy();
|
|
1900
|
+
}
|
|
1901
|
+
}
|
|
1902
|
+
};
|
|
1903
|
+
var FloatingMenuPlugin = (options) => {
|
|
1904
|
+
return new Plugin({
|
|
1905
|
+
key: typeof options.pluginKey === "string" ? new PluginKey(options.pluginKey) : options.pluginKey,
|
|
1906
|
+
view: (view) => new FloatingMenuView({ view, ...options })
|
|
1907
|
+
});
|
|
1908
|
+
};
|
|
1909
|
+
var FloatingMenu = Extension.create({
|
|
1910
|
+
name: "floatingMenu",
|
|
1911
|
+
addOptions() {
|
|
1912
|
+
return {
|
|
1913
|
+
element: null,
|
|
1914
|
+
options: {},
|
|
1915
|
+
pluginKey: "floatingMenu",
|
|
1916
|
+
updateDelay: void 0,
|
|
1917
|
+
resizeDelay: void 0,
|
|
1918
|
+
appendTo: void 0,
|
|
1919
|
+
shouldShow: null
|
|
1920
|
+
};
|
|
1921
|
+
},
|
|
1922
|
+
addCommands() {
|
|
1923
|
+
return {
|
|
1924
|
+
updateFloatingMenuPosition: () => ({ tr, dispatch }) => {
|
|
1925
|
+
if (dispatch) {
|
|
1926
|
+
tr.setMeta(this.options.pluginKey, "updatePosition");
|
|
1927
|
+
}
|
|
1928
|
+
return true;
|
|
1929
|
+
}
|
|
1930
|
+
};
|
|
1931
|
+
},
|
|
1932
|
+
addProseMirrorPlugins() {
|
|
1933
|
+
if (!this.options.element) {
|
|
1934
|
+
return [];
|
|
1935
|
+
}
|
|
1936
|
+
return [
|
|
1937
|
+
FloatingMenuPlugin({
|
|
1938
|
+
pluginKey: this.options.pluginKey,
|
|
1939
|
+
editor: this.editor,
|
|
1940
|
+
element: this.options.element,
|
|
1941
|
+
updateDelay: this.options.updateDelay,
|
|
1942
|
+
resizeDelay: this.options.resizeDelay,
|
|
1943
|
+
options: this.options.options,
|
|
1944
|
+
appendTo: this.options.appendTo,
|
|
1945
|
+
shouldShow: this.options.shouldShow
|
|
1946
|
+
})
|
|
1947
|
+
];
|
|
1948
|
+
}
|
|
1949
|
+
});
|
|
1950
|
+
var index_default = FloatingMenu;
|
|
1951
|
+
|
|
1952
|
+
// node_modules/prosemirror-tables/dist/index.js
|
|
1953
|
+
var readFromCache;
|
|
1954
|
+
var addToCache;
|
|
1955
|
+
if (typeof WeakMap != "undefined") {
|
|
1956
|
+
let cache = /* @__PURE__ */ new WeakMap();
|
|
1957
|
+
readFromCache = (key) => cache.get(key);
|
|
1958
|
+
addToCache = (key, value) => {
|
|
1959
|
+
cache.set(key, value);
|
|
1960
|
+
return value;
|
|
1961
|
+
};
|
|
1962
|
+
} else {
|
|
1963
|
+
const cache = [];
|
|
1964
|
+
const cacheSize = 10;
|
|
1965
|
+
let cachePos = 0;
|
|
1966
|
+
readFromCache = (key) => {
|
|
1967
|
+
for (let i = 0; i < cache.length; i += 2) if (cache[i] == key) return cache[i + 1];
|
|
1968
|
+
};
|
|
1969
|
+
addToCache = (key, value) => {
|
|
1970
|
+
if (cachePos == cacheSize) cachePos = 0;
|
|
1971
|
+
cache[cachePos++] = key;
|
|
1972
|
+
return cache[cachePos++] = value;
|
|
1973
|
+
};
|
|
1974
|
+
}
|
|
1975
|
+
var TableMap = class {
|
|
1976
|
+
constructor(width, height, map, problems) {
|
|
1977
|
+
this.width = width;
|
|
1978
|
+
this.height = height;
|
|
1979
|
+
this.map = map;
|
|
1980
|
+
this.problems = problems;
|
|
1981
|
+
}
|
|
1982
|
+
findCell(pos) {
|
|
1983
|
+
for (let i = 0; i < this.map.length; i++) {
|
|
1984
|
+
const curPos = this.map[i];
|
|
1985
|
+
if (curPos != pos) continue;
|
|
1986
|
+
const left = i % this.width;
|
|
1987
|
+
const top = i / this.width | 0;
|
|
1988
|
+
let right = left + 1;
|
|
1989
|
+
let bottom = top + 1;
|
|
1990
|
+
for (let j = 1; right < this.width && this.map[i + j] == curPos; j++) right++;
|
|
1991
|
+
for (let j = 1; bottom < this.height && this.map[i + this.width * j] == curPos; j++) bottom++;
|
|
1992
|
+
return {
|
|
1993
|
+
left,
|
|
1994
|
+
top,
|
|
1995
|
+
right,
|
|
1996
|
+
bottom
|
|
1997
|
+
};
|
|
1998
|
+
}
|
|
1999
|
+
throw new RangeError(`No cell with offset ${pos} found`);
|
|
2000
|
+
}
|
|
2001
|
+
colCount(pos) {
|
|
2002
|
+
for (let i = 0; i < this.map.length; i++) if (this.map[i] == pos) return i % this.width;
|
|
2003
|
+
throw new RangeError(`No cell with offset ${pos} found`);
|
|
2004
|
+
}
|
|
2005
|
+
nextCell(pos, axis, dir) {
|
|
2006
|
+
const { left, right, top, bottom } = this.findCell(pos);
|
|
2007
|
+
if (axis == "horiz") {
|
|
2008
|
+
if (dir < 0 ? left == 0 : right == this.width) return null;
|
|
2009
|
+
return this.map[top * this.width + (dir < 0 ? left - 1 : right)];
|
|
2010
|
+
} else {
|
|
2011
|
+
if (dir < 0 ? top == 0 : bottom == this.height) return null;
|
|
2012
|
+
return this.map[left + this.width * (dir < 0 ? top - 1 : bottom)];
|
|
2013
|
+
}
|
|
2014
|
+
}
|
|
2015
|
+
rectBetween(a, b) {
|
|
2016
|
+
const { left: leftA, right: rightA, top: topA, bottom: bottomA } = this.findCell(a);
|
|
2017
|
+
const { left: leftB, right: rightB, top: topB, bottom: bottomB } = this.findCell(b);
|
|
2018
|
+
return {
|
|
2019
|
+
left: Math.min(leftA, leftB),
|
|
2020
|
+
top: Math.min(topA, topB),
|
|
2021
|
+
right: Math.max(rightA, rightB),
|
|
2022
|
+
bottom: Math.max(bottomA, bottomB)
|
|
2023
|
+
};
|
|
2024
|
+
}
|
|
2025
|
+
cellsInRect(rect) {
|
|
2026
|
+
const result = [];
|
|
2027
|
+
const seen = {};
|
|
2028
|
+
for (let row = rect.top; row < rect.bottom; row++) for (let col = rect.left; col < rect.right; col++) {
|
|
2029
|
+
const index = row * this.width + col;
|
|
2030
|
+
const pos = this.map[index];
|
|
2031
|
+
if (seen[pos]) continue;
|
|
2032
|
+
seen[pos] = true;
|
|
2033
|
+
if (col == rect.left && col && this.map[index - 1] == pos || row == rect.top && row && this.map[index - this.width] == pos) continue;
|
|
2034
|
+
result.push(pos);
|
|
2035
|
+
}
|
|
2036
|
+
return result;
|
|
2037
|
+
}
|
|
2038
|
+
positionAt(row, col, table) {
|
|
2039
|
+
for (let i = 0, rowStart = 0; ; i++) {
|
|
2040
|
+
const rowEnd = rowStart + table.child(i).nodeSize;
|
|
2041
|
+
if (i == row) {
|
|
2042
|
+
let index = col + row * this.width;
|
|
2043
|
+
const rowEndIndex = (row + 1) * this.width;
|
|
2044
|
+
while (index < rowEndIndex && this.map[index] < rowStart) index++;
|
|
2045
|
+
return index == rowEndIndex ? rowEnd - 1 : this.map[index];
|
|
2046
|
+
}
|
|
2047
|
+
rowStart = rowEnd;
|
|
2048
|
+
}
|
|
2049
|
+
}
|
|
2050
|
+
static get(table) {
|
|
2051
|
+
return readFromCache(table) || addToCache(table, computeMap(table));
|
|
2052
|
+
}
|
|
2053
|
+
};
|
|
2054
|
+
function computeMap(table) {
|
|
2055
|
+
if (table.type.spec.tableRole != "table") throw new RangeError("Not a table node: " + table.type.name);
|
|
2056
|
+
const width = findWidth(table), height = table.childCount;
|
|
2057
|
+
const map = [];
|
|
2058
|
+
let mapPos = 0;
|
|
2059
|
+
let problems = null;
|
|
2060
|
+
const colWidths = [];
|
|
2061
|
+
for (let i = 0, e = width * height; i < e; i++) map[i] = 0;
|
|
2062
|
+
for (let row = 0, pos = 0; row < height; row++) {
|
|
2063
|
+
const rowNode = table.child(row);
|
|
2064
|
+
pos++;
|
|
2065
|
+
for (let i = 0; ; i++) {
|
|
2066
|
+
while (mapPos < map.length && map[mapPos] != 0) mapPos++;
|
|
2067
|
+
if (i == rowNode.childCount) break;
|
|
2068
|
+
const cellNode = rowNode.child(i);
|
|
2069
|
+
const { colspan, rowspan, colwidth } = cellNode.attrs;
|
|
2070
|
+
for (let h = 0; h < rowspan; h++) {
|
|
2071
|
+
if (h + row >= height) {
|
|
2072
|
+
(problems || (problems = [])).push({
|
|
2073
|
+
type: "overlong_rowspan",
|
|
2074
|
+
pos,
|
|
2075
|
+
n: rowspan - h
|
|
2076
|
+
});
|
|
2077
|
+
break;
|
|
2078
|
+
}
|
|
2079
|
+
const start = mapPos + h * width;
|
|
2080
|
+
for (let w = 0; w < colspan; w++) {
|
|
2081
|
+
if (map[start + w] == 0) map[start + w] = pos;
|
|
2082
|
+
else (problems || (problems = [])).push({
|
|
2083
|
+
type: "collision",
|
|
2084
|
+
row,
|
|
2085
|
+
pos,
|
|
2086
|
+
n: colspan - w
|
|
2087
|
+
});
|
|
2088
|
+
const colW = colwidth && colwidth[w];
|
|
2089
|
+
if (colW) {
|
|
2090
|
+
const widthIndex = (start + w) % width * 2, prev = colWidths[widthIndex];
|
|
2091
|
+
if (prev == null || prev != colW && colWidths[widthIndex + 1] == 1) {
|
|
2092
|
+
colWidths[widthIndex] = colW;
|
|
2093
|
+
colWidths[widthIndex + 1] = 1;
|
|
2094
|
+
} else if (prev == colW) colWidths[widthIndex + 1]++;
|
|
2095
|
+
}
|
|
2096
|
+
}
|
|
2097
|
+
}
|
|
2098
|
+
mapPos += colspan;
|
|
2099
|
+
pos += cellNode.nodeSize;
|
|
2100
|
+
}
|
|
2101
|
+
const expectedPos = (row + 1) * width;
|
|
2102
|
+
let missing = 0;
|
|
2103
|
+
while (mapPos < expectedPos) if (map[mapPos++] == 0) missing++;
|
|
2104
|
+
if (missing) (problems || (problems = [])).push({
|
|
2105
|
+
type: "missing",
|
|
2106
|
+
row,
|
|
2107
|
+
n: missing
|
|
2108
|
+
});
|
|
2109
|
+
pos++;
|
|
2110
|
+
}
|
|
2111
|
+
if (width === 0 || height === 0) (problems || (problems = [])).push({ type: "zero_sized" });
|
|
2112
|
+
const tableMap = new TableMap(width, height, map, problems);
|
|
2113
|
+
let badWidths = false;
|
|
2114
|
+
for (let i = 0; !badWidths && i < colWidths.length; i += 2) if (colWidths[i] != null && colWidths[i + 1] < height) badWidths = true;
|
|
2115
|
+
if (badWidths) findBadColWidths(tableMap, colWidths, table);
|
|
2116
|
+
return tableMap;
|
|
2117
|
+
}
|
|
2118
|
+
function findWidth(table) {
|
|
2119
|
+
let width = -1;
|
|
2120
|
+
let hasRowSpan = false;
|
|
2121
|
+
for (let row = 0; row < table.childCount; row++) {
|
|
2122
|
+
const rowNode = table.child(row);
|
|
2123
|
+
let rowWidth = 0;
|
|
2124
|
+
if (hasRowSpan) for (let j = 0; j < row; j++) {
|
|
2125
|
+
const prevRow = table.child(j);
|
|
2126
|
+
for (let i = 0; i < prevRow.childCount; i++) {
|
|
2127
|
+
const cell = prevRow.child(i);
|
|
2128
|
+
if (j + cell.attrs.rowspan > row) rowWidth += cell.attrs.colspan;
|
|
2129
|
+
}
|
|
2130
|
+
}
|
|
2131
|
+
for (let i = 0; i < rowNode.childCount; i++) {
|
|
2132
|
+
const cell = rowNode.child(i);
|
|
2133
|
+
rowWidth += cell.attrs.colspan;
|
|
2134
|
+
if (cell.attrs.rowspan > 1) hasRowSpan = true;
|
|
2135
|
+
}
|
|
2136
|
+
if (width == -1) width = rowWidth;
|
|
2137
|
+
else if (width != rowWidth) width = Math.max(width, rowWidth);
|
|
2138
|
+
}
|
|
2139
|
+
return width;
|
|
2140
|
+
}
|
|
2141
|
+
function findBadColWidths(map, colWidths, table) {
|
|
2142
|
+
if (!map.problems) map.problems = [];
|
|
2143
|
+
const seen = {};
|
|
2144
|
+
for (let i = 0; i < map.map.length; i++) {
|
|
2145
|
+
const pos = map.map[i];
|
|
2146
|
+
if (seen[pos]) continue;
|
|
2147
|
+
seen[pos] = true;
|
|
2148
|
+
const node = table.nodeAt(pos);
|
|
2149
|
+
if (!node) throw new RangeError(`No cell with offset ${pos} found`);
|
|
2150
|
+
let updated = null;
|
|
2151
|
+
const attrs = node.attrs;
|
|
2152
|
+
for (let j = 0; j < attrs.colspan; j++) {
|
|
2153
|
+
const colWidth = colWidths[(i + j) % map.width * 2];
|
|
2154
|
+
if (colWidth != null && (!attrs.colwidth || attrs.colwidth[j] != colWidth)) (updated || (updated = freshColWidth(attrs)))[j] = colWidth;
|
|
2155
|
+
}
|
|
2156
|
+
if (updated) map.problems.unshift({
|
|
2157
|
+
type: "colwidth mismatch",
|
|
2158
|
+
pos,
|
|
2159
|
+
colwidth: updated
|
|
2160
|
+
});
|
|
2161
|
+
}
|
|
2162
|
+
}
|
|
2163
|
+
function freshColWidth(attrs) {
|
|
2164
|
+
if (attrs.colwidth) return attrs.colwidth.slice();
|
|
2165
|
+
const result = [];
|
|
2166
|
+
for (let i = 0; i < attrs.colspan; i++) result.push(0);
|
|
2167
|
+
return result;
|
|
2168
|
+
}
|
|
2169
|
+
function tableNodeTypes(schema) {
|
|
2170
|
+
let result = schema.cached.tableNodeTypes;
|
|
2171
|
+
if (!result) {
|
|
2172
|
+
result = schema.cached.tableNodeTypes = {};
|
|
2173
|
+
for (const name in schema.nodes) {
|
|
2174
|
+
const type = schema.nodes[name], role = type.spec.tableRole;
|
|
2175
|
+
if (role) result[role] = type;
|
|
2176
|
+
}
|
|
2177
|
+
}
|
|
2178
|
+
return result;
|
|
2179
|
+
}
|
|
2180
|
+
var tableEditingKey = new PluginKey("selectingCells");
|
|
2181
|
+
function cellAround($pos) {
|
|
2182
|
+
for (let d = $pos.depth - 1; d > 0; d--) if ($pos.node(d).type.spec.tableRole == "row") return $pos.node(0).resolve($pos.before(d + 1));
|
|
2183
|
+
return null;
|
|
2184
|
+
}
|
|
2185
|
+
function cellWrapping($pos) {
|
|
2186
|
+
for (let d = $pos.depth; d > 0; d--) {
|
|
2187
|
+
const role = $pos.node(d).type.spec.tableRole;
|
|
2188
|
+
if (role === "cell" || role === "header_cell") return $pos.node(d);
|
|
2189
|
+
}
|
|
2190
|
+
return null;
|
|
2191
|
+
}
|
|
2192
|
+
function isInTable(state) {
|
|
2193
|
+
const $head = state.selection.$head;
|
|
2194
|
+
for (let d = $head.depth; d > 0; d--) if ($head.node(d).type.spec.tableRole == "row") return true;
|
|
2195
|
+
return false;
|
|
2196
|
+
}
|
|
2197
|
+
function selectionCell(state) {
|
|
2198
|
+
const sel = state.selection;
|
|
2199
|
+
if ("$anchorCell" in sel && sel.$anchorCell) return sel.$anchorCell.pos > sel.$headCell.pos ? sel.$anchorCell : sel.$headCell;
|
|
2200
|
+
else if ("node" in sel && sel.node && sel.node.type.spec.tableRole == "cell") return sel.$anchor;
|
|
2201
|
+
const $cell = cellAround(sel.$head) || cellNear(sel.$head);
|
|
2202
|
+
if ($cell) return $cell;
|
|
2203
|
+
throw new RangeError(`No cell found around position ${sel.head}`);
|
|
2204
|
+
}
|
|
2205
|
+
function cellNear($pos) {
|
|
2206
|
+
for (let after = $pos.nodeAfter, pos = $pos.pos; after; after = after.firstChild, pos++) {
|
|
2207
|
+
const role = after.type.spec.tableRole;
|
|
2208
|
+
if (role == "cell" || role == "header_cell") return $pos.doc.resolve(pos);
|
|
2209
|
+
}
|
|
2210
|
+
for (let before = $pos.nodeBefore, pos = $pos.pos; before; before = before.lastChild, pos--) {
|
|
2211
|
+
const role = before.type.spec.tableRole;
|
|
2212
|
+
if (role == "cell" || role == "header_cell") return $pos.doc.resolve(pos - before.nodeSize);
|
|
2213
|
+
}
|
|
2214
|
+
}
|
|
2215
|
+
function pointsAtCell($pos) {
|
|
2216
|
+
return $pos.parent.type.spec.tableRole == "row" && !!$pos.nodeAfter;
|
|
2217
|
+
}
|
|
2218
|
+
function moveCellForward($pos) {
|
|
2219
|
+
return $pos.node(0).resolve($pos.pos + $pos.nodeAfter.nodeSize);
|
|
2220
|
+
}
|
|
2221
|
+
function inSameTable($cellA, $cellB) {
|
|
2222
|
+
return $cellA.depth == $cellB.depth && $cellA.pos >= $cellB.start(-1) && $cellA.pos <= $cellB.end(-1);
|
|
2223
|
+
}
|
|
2224
|
+
function nextCell($pos, axis, dir) {
|
|
2225
|
+
const table = $pos.node(-1);
|
|
2226
|
+
const map = TableMap.get(table);
|
|
2227
|
+
const tableStart = $pos.start(-1);
|
|
2228
|
+
const moved = map.nextCell($pos.pos - tableStart, axis, dir);
|
|
2229
|
+
return moved == null ? null : $pos.node(0).resolve(tableStart + moved);
|
|
2230
|
+
}
|
|
2231
|
+
function removeColSpan(attrs, pos, n = 1) {
|
|
2232
|
+
const result = {
|
|
2233
|
+
...attrs,
|
|
2234
|
+
colspan: attrs.colspan - n
|
|
2235
|
+
};
|
|
2236
|
+
if (result.colwidth) {
|
|
2237
|
+
result.colwidth = result.colwidth.slice();
|
|
2238
|
+
result.colwidth.splice(pos, n);
|
|
2239
|
+
if (!result.colwidth.some((w) => w > 0)) result.colwidth = null;
|
|
2240
|
+
}
|
|
2241
|
+
return result;
|
|
2242
|
+
}
|
|
2243
|
+
function addColSpan(attrs, pos, n = 1) {
|
|
2244
|
+
const result = {
|
|
2245
|
+
...attrs,
|
|
2246
|
+
colspan: attrs.colspan + n
|
|
2247
|
+
};
|
|
2248
|
+
if (result.colwidth) {
|
|
2249
|
+
result.colwidth = result.colwidth.slice();
|
|
2250
|
+
for (let i = 0; i < n; i++) result.colwidth.splice(pos, 0, 0);
|
|
2251
|
+
}
|
|
2252
|
+
return result;
|
|
2253
|
+
}
|
|
2254
|
+
function columnIsHeader(map, table, col) {
|
|
2255
|
+
const headerCell = tableNodeTypes(table.type.schema).header_cell;
|
|
2256
|
+
for (let row = 0; row < map.height; row++) if (table.nodeAt(map.map[col + row * map.width]).type != headerCell) return false;
|
|
2257
|
+
return true;
|
|
2258
|
+
}
|
|
2259
|
+
var CellSelection = class CellSelection2 extends Selection {
|
|
2260
|
+
constructor($anchorCell, $headCell = $anchorCell) {
|
|
2261
|
+
const table = $anchorCell.node(-1);
|
|
2262
|
+
const map = TableMap.get(table);
|
|
2263
|
+
const tableStart = $anchorCell.start(-1);
|
|
2264
|
+
const rect = map.rectBetween($anchorCell.pos - tableStart, $headCell.pos - tableStart);
|
|
2265
|
+
const doc = $anchorCell.node(0);
|
|
2266
|
+
const cells = map.cellsInRect(rect).filter((p) => p != $headCell.pos - tableStart);
|
|
2267
|
+
cells.unshift($headCell.pos - tableStart);
|
|
2268
|
+
const ranges = cells.map((pos) => {
|
|
2269
|
+
const cell = table.nodeAt(pos);
|
|
2270
|
+
if (!cell) throw new RangeError(`No cell with offset ${pos} found`);
|
|
2271
|
+
const from = tableStart + pos + 1;
|
|
2272
|
+
return new SelectionRange(doc.resolve(from), doc.resolve(from + cell.content.size));
|
|
2273
|
+
});
|
|
2274
|
+
super(ranges[0].$from, ranges[0].$to, ranges);
|
|
2275
|
+
this.$anchorCell = $anchorCell;
|
|
2276
|
+
this.$headCell = $headCell;
|
|
2277
|
+
}
|
|
2278
|
+
map(doc, mapping) {
|
|
2279
|
+
const $anchorCell = doc.resolve(mapping.map(this.$anchorCell.pos));
|
|
2280
|
+
const $headCell = doc.resolve(mapping.map(this.$headCell.pos));
|
|
2281
|
+
if (pointsAtCell($anchorCell) && pointsAtCell($headCell) && inSameTable($anchorCell, $headCell)) {
|
|
2282
|
+
const tableChanged = this.$anchorCell.node(-1) != $anchorCell.node(-1);
|
|
2283
|
+
if (tableChanged && this.isRowSelection()) return CellSelection2.rowSelection($anchorCell, $headCell);
|
|
2284
|
+
else if (tableChanged && this.isColSelection()) return CellSelection2.colSelection($anchorCell, $headCell);
|
|
2285
|
+
else return new CellSelection2($anchorCell, $headCell);
|
|
2286
|
+
}
|
|
2287
|
+
return TextSelection.between($anchorCell, $headCell);
|
|
2288
|
+
}
|
|
2289
|
+
content() {
|
|
2290
|
+
const table = this.$anchorCell.node(-1);
|
|
2291
|
+
const map = TableMap.get(table);
|
|
2292
|
+
const tableStart = this.$anchorCell.start(-1);
|
|
2293
|
+
const rect = map.rectBetween(this.$anchorCell.pos - tableStart, this.$headCell.pos - tableStart);
|
|
2294
|
+
const seen = {};
|
|
2295
|
+
const rows = [];
|
|
2296
|
+
for (let row = rect.top; row < rect.bottom; row++) {
|
|
2297
|
+
const rowContent = [];
|
|
2298
|
+
for (let index = row * map.width + rect.left, col = rect.left; col < rect.right; col++, index++) {
|
|
2299
|
+
const pos = map.map[index];
|
|
2300
|
+
if (seen[pos]) continue;
|
|
2301
|
+
seen[pos] = true;
|
|
2302
|
+
const cellRect = map.findCell(pos);
|
|
2303
|
+
let cell = table.nodeAt(pos);
|
|
2304
|
+
if (!cell) throw new RangeError(`No cell with offset ${pos} found`);
|
|
2305
|
+
const extraLeft = rect.left - cellRect.left;
|
|
2306
|
+
const extraRight = cellRect.right - rect.right;
|
|
2307
|
+
if (extraLeft > 0 || extraRight > 0) {
|
|
2308
|
+
let attrs = cell.attrs;
|
|
2309
|
+
if (extraLeft > 0) attrs = removeColSpan(attrs, 0, extraLeft);
|
|
2310
|
+
if (extraRight > 0) attrs = removeColSpan(attrs, attrs.colspan - extraRight, extraRight);
|
|
2311
|
+
if (cellRect.left < rect.left) {
|
|
2312
|
+
cell = cell.type.createAndFill(attrs);
|
|
2313
|
+
if (!cell) throw new RangeError(`Could not create cell with attrs ${JSON.stringify(attrs)}`);
|
|
2314
|
+
} else cell = cell.type.create(attrs, cell.content);
|
|
2315
|
+
}
|
|
2316
|
+
if (cellRect.top < rect.top || cellRect.bottom > rect.bottom) {
|
|
2317
|
+
const attrs = {
|
|
2318
|
+
...cell.attrs,
|
|
2319
|
+
rowspan: Math.min(cellRect.bottom, rect.bottom) - Math.max(cellRect.top, rect.top)
|
|
2320
|
+
};
|
|
2321
|
+
if (cellRect.top < rect.top) cell = cell.type.createAndFill(attrs);
|
|
2322
|
+
else cell = cell.type.create(attrs, cell.content);
|
|
2323
|
+
}
|
|
2324
|
+
rowContent.push(cell);
|
|
2325
|
+
}
|
|
2326
|
+
rows.push(table.child(row).copy(Fragment.from(rowContent)));
|
|
2327
|
+
}
|
|
2328
|
+
const fragment = this.isColSelection() && this.isRowSelection() ? table : rows;
|
|
2329
|
+
return new Slice(Fragment.from(fragment), 1, 1);
|
|
2330
|
+
}
|
|
2331
|
+
replace(tr, content = Slice.empty) {
|
|
2332
|
+
const mapFrom = tr.steps.length, ranges = this.ranges;
|
|
2333
|
+
for (let i = 0; i < ranges.length; i++) {
|
|
2334
|
+
const { $from, $to } = ranges[i], mapping = tr.mapping.slice(mapFrom);
|
|
2335
|
+
tr.replace(mapping.map($from.pos), mapping.map($to.pos), i ? Slice.empty : content);
|
|
2336
|
+
}
|
|
2337
|
+
const sel = Selection.findFrom(tr.doc.resolve(tr.mapping.slice(mapFrom).map(this.to)), -1);
|
|
2338
|
+
if (sel) tr.setSelection(sel);
|
|
2339
|
+
}
|
|
2340
|
+
replaceWith(tr, node) {
|
|
2341
|
+
this.replace(tr, new Slice(Fragment.from(node), 0, 0));
|
|
2342
|
+
}
|
|
2343
|
+
forEachCell(f) {
|
|
2344
|
+
const table = this.$anchorCell.node(-1);
|
|
2345
|
+
const map = TableMap.get(table);
|
|
2346
|
+
const tableStart = this.$anchorCell.start(-1);
|
|
2347
|
+
const cells = map.cellsInRect(map.rectBetween(this.$anchorCell.pos - tableStart, this.$headCell.pos - tableStart));
|
|
2348
|
+
for (let i = 0; i < cells.length; i++) f(table.nodeAt(cells[i]), tableStart + cells[i]);
|
|
2349
|
+
}
|
|
2350
|
+
isColSelection() {
|
|
2351
|
+
const anchorTop = this.$anchorCell.index(-1);
|
|
2352
|
+
const headTop = this.$headCell.index(-1);
|
|
2353
|
+
if (Math.min(anchorTop, headTop) > 0) return false;
|
|
2354
|
+
const anchorBottom = anchorTop + this.$anchorCell.nodeAfter.attrs.rowspan;
|
|
2355
|
+
const headBottom = headTop + this.$headCell.nodeAfter.attrs.rowspan;
|
|
2356
|
+
return Math.max(anchorBottom, headBottom) == this.$headCell.node(-1).childCount;
|
|
2357
|
+
}
|
|
2358
|
+
static colSelection($anchorCell, $headCell = $anchorCell) {
|
|
2359
|
+
const table = $anchorCell.node(-1);
|
|
2360
|
+
const map = TableMap.get(table);
|
|
2361
|
+
const tableStart = $anchorCell.start(-1);
|
|
2362
|
+
const anchorRect = map.findCell($anchorCell.pos - tableStart);
|
|
2363
|
+
const headRect = map.findCell($headCell.pos - tableStart);
|
|
2364
|
+
const doc = $anchorCell.node(0);
|
|
2365
|
+
if (anchorRect.top <= headRect.top) {
|
|
2366
|
+
if (anchorRect.top > 0) $anchorCell = doc.resolve(tableStart + map.map[anchorRect.left]);
|
|
2367
|
+
if (headRect.bottom < map.height) $headCell = doc.resolve(tableStart + map.map[map.width * (map.height - 1) + headRect.right - 1]);
|
|
2368
|
+
} else {
|
|
2369
|
+
if (headRect.top > 0) $headCell = doc.resolve(tableStart + map.map[headRect.left]);
|
|
2370
|
+
if (anchorRect.bottom < map.height) $anchorCell = doc.resolve(tableStart + map.map[map.width * (map.height - 1) + anchorRect.right - 1]);
|
|
2371
|
+
}
|
|
2372
|
+
return new CellSelection2($anchorCell, $headCell);
|
|
2373
|
+
}
|
|
2374
|
+
isRowSelection() {
|
|
2375
|
+
const table = this.$anchorCell.node(-1);
|
|
2376
|
+
const map = TableMap.get(table);
|
|
2377
|
+
const tableStart = this.$anchorCell.start(-1);
|
|
2378
|
+
const anchorLeft = map.colCount(this.$anchorCell.pos - tableStart);
|
|
2379
|
+
const headLeft = map.colCount(this.$headCell.pos - tableStart);
|
|
2380
|
+
if (Math.min(anchorLeft, headLeft) > 0) return false;
|
|
2381
|
+
const anchorRight = anchorLeft + this.$anchorCell.nodeAfter.attrs.colspan;
|
|
2382
|
+
const headRight = headLeft + this.$headCell.nodeAfter.attrs.colspan;
|
|
2383
|
+
return Math.max(anchorRight, headRight) == map.width;
|
|
2384
|
+
}
|
|
2385
|
+
eq(other) {
|
|
2386
|
+
return other instanceof CellSelection2 && other.$anchorCell.pos == this.$anchorCell.pos && other.$headCell.pos == this.$headCell.pos;
|
|
2387
|
+
}
|
|
2388
|
+
static rowSelection($anchorCell, $headCell = $anchorCell) {
|
|
2389
|
+
const table = $anchorCell.node(-1);
|
|
2390
|
+
const map = TableMap.get(table);
|
|
2391
|
+
const tableStart = $anchorCell.start(-1);
|
|
2392
|
+
const anchorRect = map.findCell($anchorCell.pos - tableStart);
|
|
2393
|
+
const headRect = map.findCell($headCell.pos - tableStart);
|
|
2394
|
+
const doc = $anchorCell.node(0);
|
|
2395
|
+
if (anchorRect.left <= headRect.left) {
|
|
2396
|
+
if (anchorRect.left > 0) $anchorCell = doc.resolve(tableStart + map.map[anchorRect.top * map.width]);
|
|
2397
|
+
if (headRect.right < map.width) $headCell = doc.resolve(tableStart + map.map[map.width * (headRect.top + 1) - 1]);
|
|
2398
|
+
} else {
|
|
2399
|
+
if (headRect.left > 0) $headCell = doc.resolve(tableStart + map.map[headRect.top * map.width]);
|
|
2400
|
+
if (anchorRect.right < map.width) $anchorCell = doc.resolve(tableStart + map.map[map.width * (anchorRect.top + 1) - 1]);
|
|
2401
|
+
}
|
|
2402
|
+
return new CellSelection2($anchorCell, $headCell);
|
|
2403
|
+
}
|
|
2404
|
+
toJSON() {
|
|
2405
|
+
return {
|
|
2406
|
+
type: "cell",
|
|
2407
|
+
anchor: this.$anchorCell.pos,
|
|
2408
|
+
head: this.$headCell.pos
|
|
2409
|
+
};
|
|
2410
|
+
}
|
|
2411
|
+
static fromJSON(doc, json) {
|
|
2412
|
+
return new CellSelection2(doc.resolve(json.anchor), doc.resolve(json.head));
|
|
2413
|
+
}
|
|
2414
|
+
static create(doc, anchorCell, headCell = anchorCell) {
|
|
2415
|
+
return new CellSelection2(doc.resolve(anchorCell), doc.resolve(headCell));
|
|
2416
|
+
}
|
|
2417
|
+
getBookmark() {
|
|
2418
|
+
return new CellBookmark(this.$anchorCell.pos, this.$headCell.pos);
|
|
2419
|
+
}
|
|
2420
|
+
};
|
|
2421
|
+
CellSelection.prototype.visible = false;
|
|
2422
|
+
Selection.jsonID("cell", CellSelection);
|
|
2423
|
+
var CellBookmark = class CellBookmark2 {
|
|
2424
|
+
constructor(anchor, head) {
|
|
2425
|
+
this.anchor = anchor;
|
|
2426
|
+
this.head = head;
|
|
2427
|
+
}
|
|
2428
|
+
map(mapping) {
|
|
2429
|
+
return new CellBookmark2(mapping.map(this.anchor), mapping.map(this.head));
|
|
2430
|
+
}
|
|
2431
|
+
resolve(doc) {
|
|
2432
|
+
const $anchorCell = doc.resolve(this.anchor), $headCell = doc.resolve(this.head);
|
|
2433
|
+
if ($anchorCell.parent.type.spec.tableRole == "row" && $headCell.parent.type.spec.tableRole == "row" && $anchorCell.index() < $anchorCell.parent.childCount && $headCell.index() < $headCell.parent.childCount && inSameTable($anchorCell, $headCell)) return new CellSelection($anchorCell, $headCell);
|
|
2434
|
+
else return Selection.near($headCell, 1);
|
|
2435
|
+
}
|
|
2436
|
+
};
|
|
2437
|
+
function drawCellSelection(state) {
|
|
2438
|
+
if (!(state.selection instanceof CellSelection)) return null;
|
|
2439
|
+
const cells = [];
|
|
2440
|
+
state.selection.forEachCell((node, pos) => {
|
|
2441
|
+
cells.push(Decoration.node(pos, pos + node.nodeSize, { class: "selectedCell" }));
|
|
2442
|
+
});
|
|
2443
|
+
return DecorationSet.create(state.doc, cells);
|
|
2444
|
+
}
|
|
2445
|
+
function isCellBoundarySelection({ $from, $to }) {
|
|
2446
|
+
if ($from.pos == $to.pos || $from.pos < $to.pos - 6) return false;
|
|
2447
|
+
let afterFrom = $from.pos;
|
|
2448
|
+
let beforeTo = $to.pos;
|
|
2449
|
+
let depth = $from.depth;
|
|
2450
|
+
for (; depth >= 0; depth--, afterFrom++) if ($from.after(depth + 1) < $from.end(depth)) break;
|
|
2451
|
+
for (let d = $to.depth; d >= 0; d--, beforeTo--) if ($to.before(d + 1) > $to.start(d)) break;
|
|
2452
|
+
return afterFrom == beforeTo && /row|table/.test($from.node(depth).type.spec.tableRole);
|
|
2453
|
+
}
|
|
2454
|
+
function isTextSelectionAcrossCells({ $from, $to }) {
|
|
2455
|
+
let fromCellBoundaryNode;
|
|
2456
|
+
let toCellBoundaryNode;
|
|
2457
|
+
for (let i = $from.depth; i > 0; i--) {
|
|
2458
|
+
const node = $from.node(i);
|
|
2459
|
+
if (node.type.spec.tableRole === "cell" || node.type.spec.tableRole === "header_cell") {
|
|
2460
|
+
fromCellBoundaryNode = node;
|
|
2461
|
+
break;
|
|
2462
|
+
}
|
|
2463
|
+
}
|
|
2464
|
+
for (let i = $to.depth; i > 0; i--) {
|
|
2465
|
+
const node = $to.node(i);
|
|
2466
|
+
if (node.type.spec.tableRole === "cell" || node.type.spec.tableRole === "header_cell") {
|
|
2467
|
+
toCellBoundaryNode = node;
|
|
2468
|
+
break;
|
|
2469
|
+
}
|
|
2470
|
+
}
|
|
2471
|
+
return fromCellBoundaryNode !== toCellBoundaryNode && $to.parentOffset === 0;
|
|
2472
|
+
}
|
|
2473
|
+
function normalizeSelection(state, tr, allowTableNodeSelection) {
|
|
2474
|
+
const sel = (tr || state).selection;
|
|
2475
|
+
const doc = (tr || state).doc;
|
|
2476
|
+
let normalize;
|
|
2477
|
+
let role;
|
|
2478
|
+
if (sel instanceof NodeSelection && (role = sel.node.type.spec.tableRole)) {
|
|
2479
|
+
if (role == "cell" || role == "header_cell") normalize = CellSelection.create(doc, sel.from);
|
|
2480
|
+
else if (role == "row") {
|
|
2481
|
+
const $cell = doc.resolve(sel.from + 1);
|
|
2482
|
+
normalize = CellSelection.rowSelection($cell, $cell);
|
|
2483
|
+
} else if (!allowTableNodeSelection) {
|
|
2484
|
+
const map = TableMap.get(sel.node);
|
|
2485
|
+
const start = sel.from + 1;
|
|
2486
|
+
const lastCell = start + map.map[map.width * map.height - 1];
|
|
2487
|
+
normalize = CellSelection.create(doc, start + 1, lastCell);
|
|
2488
|
+
}
|
|
2489
|
+
} else if (sel instanceof TextSelection && isCellBoundarySelection(sel)) normalize = TextSelection.create(doc, sel.from);
|
|
2490
|
+
else if (sel instanceof TextSelection && isTextSelectionAcrossCells(sel)) normalize = TextSelection.create(doc, sel.$from.start(), sel.$from.end());
|
|
2491
|
+
if (normalize) (tr || (tr = state.tr)).setSelection(normalize);
|
|
2492
|
+
return tr;
|
|
2493
|
+
}
|
|
2494
|
+
var fixTablesKey = new PluginKey("fix-tables");
|
|
2495
|
+
function changedDescendants(old, cur, offset3, f) {
|
|
2496
|
+
const oldSize = old.childCount, curSize = cur.childCount;
|
|
2497
|
+
outer: for (let i = 0, j = 0; i < curSize; i++) {
|
|
2498
|
+
const child = cur.child(i);
|
|
2499
|
+
for (let scan = j, e = Math.min(oldSize, i + 3); scan < e; scan++) if (old.child(scan) == child) {
|
|
2500
|
+
j = scan + 1;
|
|
2501
|
+
offset3 += child.nodeSize;
|
|
2502
|
+
continue outer;
|
|
2503
|
+
}
|
|
2504
|
+
f(child, offset3);
|
|
2505
|
+
if (j < oldSize && old.child(j).sameMarkup(child)) changedDescendants(old.child(j), child, offset3 + 1, f);
|
|
2506
|
+
else child.nodesBetween(0, child.content.size, f, offset3 + 1);
|
|
2507
|
+
offset3 += child.nodeSize;
|
|
2508
|
+
}
|
|
2509
|
+
}
|
|
2510
|
+
function fixTables(state, oldState) {
|
|
2511
|
+
let tr;
|
|
2512
|
+
const check = (node, pos) => {
|
|
2513
|
+
if (node.type.spec.tableRole == "table") tr = fixTable(state, node, pos, tr);
|
|
2514
|
+
};
|
|
2515
|
+
if (!oldState) state.doc.descendants(check);
|
|
2516
|
+
else if (oldState.doc != state.doc) changedDescendants(oldState.doc, state.doc, 0, check);
|
|
2517
|
+
return tr;
|
|
2518
|
+
}
|
|
2519
|
+
function fixTable(state, table, tablePos, tr) {
|
|
2520
|
+
const map = TableMap.get(table);
|
|
2521
|
+
if (!map.problems) return tr;
|
|
2522
|
+
if (!tr) tr = state.tr;
|
|
2523
|
+
const mustAdd = [];
|
|
2524
|
+
for (let i = 0; i < map.height; i++) mustAdd.push(0);
|
|
2525
|
+
for (let i = 0; i < map.problems.length; i++) {
|
|
2526
|
+
const prob = map.problems[i];
|
|
2527
|
+
if (prob.type == "collision") {
|
|
2528
|
+
const cell = table.nodeAt(prob.pos);
|
|
2529
|
+
if (!cell) continue;
|
|
2530
|
+
const attrs = cell.attrs;
|
|
2531
|
+
for (let j = 0; j < attrs.rowspan; j++) mustAdd[prob.row + j] += prob.n;
|
|
2532
|
+
tr.setNodeMarkup(tr.mapping.map(tablePos + 1 + prob.pos), null, removeColSpan(attrs, attrs.colspan - prob.n, prob.n));
|
|
2533
|
+
} else if (prob.type == "missing") mustAdd[prob.row] += prob.n;
|
|
2534
|
+
else if (prob.type == "overlong_rowspan") {
|
|
2535
|
+
const cell = table.nodeAt(prob.pos);
|
|
2536
|
+
if (!cell) continue;
|
|
2537
|
+
tr.setNodeMarkup(tr.mapping.map(tablePos + 1 + prob.pos), null, {
|
|
2538
|
+
...cell.attrs,
|
|
2539
|
+
rowspan: cell.attrs.rowspan - prob.n
|
|
2540
|
+
});
|
|
2541
|
+
} else if (prob.type == "colwidth mismatch") {
|
|
2542
|
+
const cell = table.nodeAt(prob.pos);
|
|
2543
|
+
if (!cell) continue;
|
|
2544
|
+
tr.setNodeMarkup(tr.mapping.map(tablePos + 1 + prob.pos), null, {
|
|
2545
|
+
...cell.attrs,
|
|
2546
|
+
colwidth: prob.colwidth
|
|
2547
|
+
});
|
|
2548
|
+
} else if (prob.type == "zero_sized") {
|
|
2549
|
+
const pos = tr.mapping.map(tablePos);
|
|
2550
|
+
tr.delete(pos, pos + table.nodeSize);
|
|
2551
|
+
}
|
|
2552
|
+
}
|
|
2553
|
+
let first, last;
|
|
2554
|
+
for (let i = 0; i < mustAdd.length; i++) if (mustAdd[i]) {
|
|
2555
|
+
if (first == null) first = i;
|
|
2556
|
+
last = i;
|
|
2557
|
+
}
|
|
2558
|
+
for (let i = 0, pos = tablePos + 1; i < map.height; i++) {
|
|
2559
|
+
const row = table.child(i);
|
|
2560
|
+
const end = pos + row.nodeSize;
|
|
2561
|
+
const add = mustAdd[i];
|
|
2562
|
+
if (add > 0) {
|
|
2563
|
+
let role = "cell";
|
|
2564
|
+
if (row.firstChild) role = row.firstChild.type.spec.tableRole;
|
|
2565
|
+
const nodes = [];
|
|
2566
|
+
for (let j = 0; j < add; j++) {
|
|
2567
|
+
const node = tableNodeTypes(state.schema)[role].createAndFill();
|
|
2568
|
+
if (node) nodes.push(node);
|
|
2569
|
+
}
|
|
2570
|
+
const side = (i == 0 || first == i - 1) && last == i ? pos + 1 : end - 1;
|
|
2571
|
+
tr.insert(tr.mapping.map(side), nodes);
|
|
2572
|
+
}
|
|
2573
|
+
pos = end;
|
|
2574
|
+
}
|
|
2575
|
+
return tr.setMeta(fixTablesKey, { fixTables: true });
|
|
2576
|
+
}
|
|
2577
|
+
function selectedRect(state) {
|
|
2578
|
+
const sel = state.selection;
|
|
2579
|
+
const $pos = selectionCell(state);
|
|
2580
|
+
const table = $pos.node(-1);
|
|
2581
|
+
const tableStart = $pos.start(-1);
|
|
2582
|
+
const map = TableMap.get(table);
|
|
2583
|
+
return {
|
|
2584
|
+
...sel instanceof CellSelection ? map.rectBetween(sel.$anchorCell.pos - tableStart, sel.$headCell.pos - tableStart) : map.findCell($pos.pos - tableStart),
|
|
2585
|
+
tableStart,
|
|
2586
|
+
map,
|
|
2587
|
+
table
|
|
2588
|
+
};
|
|
2589
|
+
}
|
|
2590
|
+
function addColumn(tr, { map, tableStart, table }, col) {
|
|
2591
|
+
let refColumn = col > 0 ? -1 : 0;
|
|
2592
|
+
if (columnIsHeader(map, table, col + refColumn)) refColumn = col == 0 || col == map.width ? null : 0;
|
|
2593
|
+
for (let row = 0; row < map.height; row++) {
|
|
2594
|
+
const index = row * map.width + col;
|
|
2595
|
+
if (col > 0 && col < map.width && map.map[index - 1] == map.map[index]) {
|
|
2596
|
+
const pos = map.map[index];
|
|
2597
|
+
const cell = table.nodeAt(pos);
|
|
2598
|
+
tr.setNodeMarkup(tr.mapping.map(tableStart + pos), null, addColSpan(cell.attrs, col - map.colCount(pos)));
|
|
2599
|
+
row += cell.attrs.rowspan - 1;
|
|
2600
|
+
} else {
|
|
2601
|
+
const type = refColumn == null ? tableNodeTypes(table.type.schema).cell : table.nodeAt(map.map[index + refColumn]).type;
|
|
2602
|
+
const pos = map.positionAt(row, col, table);
|
|
2603
|
+
tr.insert(tr.mapping.map(tableStart + pos), type.createAndFill());
|
|
2604
|
+
}
|
|
2605
|
+
}
|
|
2606
|
+
return tr;
|
|
2607
|
+
}
|
|
2608
|
+
function addColumnBefore(state, dispatch) {
|
|
2609
|
+
if (!isInTable(state)) return false;
|
|
2610
|
+
if (dispatch) {
|
|
2611
|
+
const rect = selectedRect(state);
|
|
2612
|
+
dispatch(addColumn(state.tr, rect, rect.left));
|
|
2613
|
+
}
|
|
2614
|
+
return true;
|
|
2615
|
+
}
|
|
2616
|
+
function addColumnAfter(state, dispatch) {
|
|
2617
|
+
if (!isInTable(state)) return false;
|
|
2618
|
+
if (dispatch) {
|
|
2619
|
+
const rect = selectedRect(state);
|
|
2620
|
+
dispatch(addColumn(state.tr, rect, rect.right));
|
|
2621
|
+
}
|
|
2622
|
+
return true;
|
|
2623
|
+
}
|
|
2624
|
+
function removeColumn(tr, { map, table, tableStart }, col) {
|
|
2625
|
+
const mapStart = tr.mapping.maps.length;
|
|
2626
|
+
for (let row = 0; row < map.height; ) {
|
|
2627
|
+
const index = row * map.width + col;
|
|
2628
|
+
const pos = map.map[index];
|
|
2629
|
+
const cell = table.nodeAt(pos);
|
|
2630
|
+
const attrs = cell.attrs;
|
|
2631
|
+
if (col > 0 && map.map[index - 1] == pos || col < map.width - 1 && map.map[index + 1] == pos) tr.setNodeMarkup(tr.mapping.slice(mapStart).map(tableStart + pos), null, removeColSpan(attrs, col - map.colCount(pos)));
|
|
2632
|
+
else {
|
|
2633
|
+
const start = tr.mapping.slice(mapStart).map(tableStart + pos);
|
|
2634
|
+
tr.delete(start, start + cell.nodeSize);
|
|
2635
|
+
}
|
|
2636
|
+
row += attrs.rowspan;
|
|
2637
|
+
}
|
|
2638
|
+
}
|
|
2639
|
+
function deleteColumn(state, dispatch) {
|
|
2640
|
+
if (!isInTable(state)) return false;
|
|
2641
|
+
if (dispatch) {
|
|
2642
|
+
const rect = selectedRect(state);
|
|
2643
|
+
const tr = state.tr;
|
|
2644
|
+
if (rect.left == 0 && rect.right == rect.map.width) return false;
|
|
2645
|
+
for (let i = rect.right - 1; ; i--) {
|
|
2646
|
+
removeColumn(tr, rect, i);
|
|
2647
|
+
if (i == rect.left) break;
|
|
2648
|
+
const table = rect.tableStart ? tr.doc.nodeAt(rect.tableStart - 1) : tr.doc;
|
|
2649
|
+
if (!table) throw new RangeError("No table found");
|
|
2650
|
+
rect.table = table;
|
|
2651
|
+
rect.map = TableMap.get(table);
|
|
2652
|
+
}
|
|
2653
|
+
dispatch(tr);
|
|
2654
|
+
}
|
|
2655
|
+
return true;
|
|
2656
|
+
}
|
|
2657
|
+
function rowIsHeader(map, table, row) {
|
|
2658
|
+
var _table$nodeAt;
|
|
2659
|
+
const headerCell = tableNodeTypes(table.type.schema).header_cell;
|
|
2660
|
+
for (let col = 0; col < map.width; col++) if (((_table$nodeAt = table.nodeAt(map.map[col + row * map.width])) === null || _table$nodeAt === void 0 ? void 0 : _table$nodeAt.type) != headerCell) return false;
|
|
2661
|
+
return true;
|
|
2662
|
+
}
|
|
2663
|
+
function addRow(tr, { map, tableStart, table }, row) {
|
|
2664
|
+
let rowPos = tableStart;
|
|
2665
|
+
for (let i = 0; i < row; i++) rowPos += table.child(i).nodeSize;
|
|
2666
|
+
const cells = [];
|
|
2667
|
+
let refRow = row > 0 ? -1 : 0;
|
|
2668
|
+
if (rowIsHeader(map, table, row + refRow)) refRow = row == 0 || row == map.height ? null : 0;
|
|
2669
|
+
for (let col = 0, index = map.width * row; col < map.width; col++, index++) if (row > 0 && row < map.height && map.map[index] == map.map[index - map.width]) {
|
|
2670
|
+
const pos = map.map[index];
|
|
2671
|
+
const attrs = table.nodeAt(pos).attrs;
|
|
2672
|
+
tr.setNodeMarkup(tableStart + pos, null, {
|
|
2673
|
+
...attrs,
|
|
2674
|
+
rowspan: attrs.rowspan + 1
|
|
2675
|
+
});
|
|
2676
|
+
col += attrs.colspan - 1;
|
|
2677
|
+
} else {
|
|
2678
|
+
var _table$nodeAt2;
|
|
2679
|
+
const type = refRow == null ? tableNodeTypes(table.type.schema).cell : (_table$nodeAt2 = table.nodeAt(map.map[index + refRow * map.width])) === null || _table$nodeAt2 === void 0 ? void 0 : _table$nodeAt2.type;
|
|
2680
|
+
const node = type === null || type === void 0 ? void 0 : type.createAndFill();
|
|
2681
|
+
if (node) cells.push(node);
|
|
2682
|
+
}
|
|
2683
|
+
tr.insert(rowPos, tableNodeTypes(table.type.schema).row.create(null, cells));
|
|
2684
|
+
return tr;
|
|
2685
|
+
}
|
|
2686
|
+
function addRowBefore(state, dispatch) {
|
|
2687
|
+
if (!isInTable(state)) return false;
|
|
2688
|
+
if (dispatch) {
|
|
2689
|
+
const rect = selectedRect(state);
|
|
2690
|
+
dispatch(addRow(state.tr, rect, rect.top));
|
|
2691
|
+
}
|
|
2692
|
+
return true;
|
|
2693
|
+
}
|
|
2694
|
+
function addRowAfter(state, dispatch) {
|
|
2695
|
+
if (!isInTable(state)) return false;
|
|
2696
|
+
if (dispatch) {
|
|
2697
|
+
const rect = selectedRect(state);
|
|
2698
|
+
dispatch(addRow(state.tr, rect, rect.bottom));
|
|
2699
|
+
}
|
|
2700
|
+
return true;
|
|
2701
|
+
}
|
|
2702
|
+
function removeRow(tr, { map, table, tableStart }, row) {
|
|
2703
|
+
let rowPos = 0;
|
|
2704
|
+
for (let i = 0; i < row; i++) rowPos += table.child(i).nodeSize;
|
|
2705
|
+
const nextRow = rowPos + table.child(row).nodeSize;
|
|
2706
|
+
const mapFrom = tr.mapping.maps.length;
|
|
2707
|
+
tr.delete(rowPos + tableStart, nextRow + tableStart);
|
|
2708
|
+
const seen = /* @__PURE__ */ new Set();
|
|
2709
|
+
for (let col = 0, index = row * map.width; col < map.width; col++, index++) {
|
|
2710
|
+
const pos = map.map[index];
|
|
2711
|
+
if (seen.has(pos)) continue;
|
|
2712
|
+
seen.add(pos);
|
|
2713
|
+
if (row > 0 && pos == map.map[index - map.width]) {
|
|
2714
|
+
const attrs = table.nodeAt(pos).attrs;
|
|
2715
|
+
tr.setNodeMarkup(tr.mapping.slice(mapFrom).map(pos + tableStart), null, {
|
|
2716
|
+
...attrs,
|
|
2717
|
+
rowspan: attrs.rowspan - 1
|
|
2718
|
+
});
|
|
2719
|
+
col += attrs.colspan - 1;
|
|
2720
|
+
} else if (row < map.height && pos == map.map[index + map.width]) {
|
|
2721
|
+
const cell = table.nodeAt(pos);
|
|
2722
|
+
const attrs = cell.attrs;
|
|
2723
|
+
const copy = cell.type.create({
|
|
2724
|
+
...attrs,
|
|
2725
|
+
rowspan: cell.attrs.rowspan - 1
|
|
2726
|
+
}, cell.content);
|
|
2727
|
+
const newPos = map.positionAt(row + 1, col, table);
|
|
2728
|
+
tr.insert(tr.mapping.slice(mapFrom).map(tableStart + newPos), copy);
|
|
2729
|
+
col += attrs.colspan - 1;
|
|
2730
|
+
}
|
|
2731
|
+
}
|
|
2732
|
+
}
|
|
2733
|
+
function deleteRow(state, dispatch) {
|
|
2734
|
+
if (!isInTable(state)) return false;
|
|
2735
|
+
if (dispatch) {
|
|
2736
|
+
const rect = selectedRect(state), tr = state.tr;
|
|
2737
|
+
if (rect.top == 0 && rect.bottom == rect.map.height) return false;
|
|
2738
|
+
for (let i = rect.bottom - 1; ; i--) {
|
|
2739
|
+
removeRow(tr, rect, i);
|
|
2740
|
+
if (i == rect.top) break;
|
|
2741
|
+
const table = rect.tableStart ? tr.doc.nodeAt(rect.tableStart - 1) : tr.doc;
|
|
2742
|
+
if (!table) throw new RangeError("No table found");
|
|
2743
|
+
rect.table = table;
|
|
2744
|
+
rect.map = TableMap.get(rect.table);
|
|
2745
|
+
}
|
|
2746
|
+
dispatch(tr);
|
|
2747
|
+
}
|
|
2748
|
+
return true;
|
|
2749
|
+
}
|
|
2750
|
+
function isEmpty(cell) {
|
|
2751
|
+
const c = cell.content;
|
|
2752
|
+
return c.childCount == 1 && c.child(0).isTextblock && c.child(0).childCount == 0;
|
|
2753
|
+
}
|
|
2754
|
+
function cellsOverlapRectangle({ width, height, map }, rect) {
|
|
2755
|
+
let indexTop = rect.top * width + rect.left, indexLeft = indexTop;
|
|
2756
|
+
let indexBottom = (rect.bottom - 1) * width + rect.left, indexRight = indexTop + (rect.right - rect.left - 1);
|
|
2757
|
+
for (let i = rect.top; i < rect.bottom; i++) {
|
|
2758
|
+
if (rect.left > 0 && map[indexLeft] == map[indexLeft - 1] || rect.right < width && map[indexRight] == map[indexRight + 1]) return true;
|
|
2759
|
+
indexLeft += width;
|
|
2760
|
+
indexRight += width;
|
|
2761
|
+
}
|
|
2762
|
+
for (let i = rect.left; i < rect.right; i++) {
|
|
2763
|
+
if (rect.top > 0 && map[indexTop] == map[indexTop - width] || rect.bottom < height && map[indexBottom] == map[indexBottom + width]) return true;
|
|
2764
|
+
indexTop++;
|
|
2765
|
+
indexBottom++;
|
|
2766
|
+
}
|
|
2767
|
+
return false;
|
|
2768
|
+
}
|
|
2769
|
+
function mergeCells(state, dispatch) {
|
|
2770
|
+
const sel = state.selection;
|
|
2771
|
+
if (!(sel instanceof CellSelection) || sel.$anchorCell.pos == sel.$headCell.pos) return false;
|
|
2772
|
+
const rect = selectedRect(state), { map } = rect;
|
|
2773
|
+
if (cellsOverlapRectangle(map, rect)) return false;
|
|
2774
|
+
if (dispatch) {
|
|
2775
|
+
const tr = state.tr;
|
|
2776
|
+
const seen = {};
|
|
2777
|
+
let content = Fragment.empty;
|
|
2778
|
+
let mergedPos;
|
|
2779
|
+
let mergedCell;
|
|
2780
|
+
for (let row = rect.top; row < rect.bottom; row++) for (let col = rect.left; col < rect.right; col++) {
|
|
2781
|
+
const cellPos = map.map[row * map.width + col];
|
|
2782
|
+
const cell = rect.table.nodeAt(cellPos);
|
|
2783
|
+
if (seen[cellPos] || !cell) continue;
|
|
2784
|
+
seen[cellPos] = true;
|
|
2785
|
+
if (mergedPos == null) {
|
|
2786
|
+
mergedPos = cellPos;
|
|
2787
|
+
mergedCell = cell;
|
|
2788
|
+
} else {
|
|
2789
|
+
if (!isEmpty(cell)) content = content.append(cell.content);
|
|
2790
|
+
const mapped = tr.mapping.map(cellPos + rect.tableStart);
|
|
2791
|
+
tr.delete(mapped, mapped + cell.nodeSize);
|
|
2792
|
+
}
|
|
2793
|
+
}
|
|
2794
|
+
if (mergedPos == null || mergedCell == null) return true;
|
|
2795
|
+
tr.setNodeMarkup(mergedPos + rect.tableStart, null, {
|
|
2796
|
+
...addColSpan(mergedCell.attrs, mergedCell.attrs.colspan, rect.right - rect.left - mergedCell.attrs.colspan),
|
|
2797
|
+
rowspan: rect.bottom - rect.top
|
|
2798
|
+
});
|
|
2799
|
+
if (content.size > 0) {
|
|
2800
|
+
const end = mergedPos + 1 + mergedCell.content.size;
|
|
2801
|
+
const start = isEmpty(mergedCell) ? mergedPos + 1 : end;
|
|
2802
|
+
tr.replaceWith(start + rect.tableStart, end + rect.tableStart, content);
|
|
2803
|
+
}
|
|
2804
|
+
tr.setSelection(new CellSelection(tr.doc.resolve(mergedPos + rect.tableStart)));
|
|
2805
|
+
dispatch(tr);
|
|
2806
|
+
}
|
|
2807
|
+
return true;
|
|
2808
|
+
}
|
|
2809
|
+
function splitCell(state, dispatch) {
|
|
2810
|
+
const nodeTypes = tableNodeTypes(state.schema);
|
|
2811
|
+
return splitCellWithType(({ node }) => {
|
|
2812
|
+
return nodeTypes[node.type.spec.tableRole];
|
|
2813
|
+
})(state, dispatch);
|
|
2814
|
+
}
|
|
2815
|
+
function splitCellWithType(getCellType) {
|
|
2816
|
+
return (state, dispatch) => {
|
|
2817
|
+
const sel = state.selection;
|
|
2818
|
+
let cellNode;
|
|
2819
|
+
let cellPos;
|
|
2820
|
+
if (!(sel instanceof CellSelection)) {
|
|
2821
|
+
var _cellAround;
|
|
2822
|
+
cellNode = cellWrapping(sel.$from);
|
|
2823
|
+
if (!cellNode) return false;
|
|
2824
|
+
cellPos = (_cellAround = cellAround(sel.$from)) === null || _cellAround === void 0 ? void 0 : _cellAround.pos;
|
|
2825
|
+
} else {
|
|
2826
|
+
if (sel.$anchorCell.pos != sel.$headCell.pos) return false;
|
|
2827
|
+
cellNode = sel.$anchorCell.nodeAfter;
|
|
2828
|
+
cellPos = sel.$anchorCell.pos;
|
|
2829
|
+
}
|
|
2830
|
+
if (cellNode == null || cellPos == null) return false;
|
|
2831
|
+
if (cellNode.attrs.colspan == 1 && cellNode.attrs.rowspan == 1) return false;
|
|
2832
|
+
if (dispatch) {
|
|
2833
|
+
let baseAttrs = cellNode.attrs;
|
|
2834
|
+
const attrs = [];
|
|
2835
|
+
const colwidth = baseAttrs.colwidth;
|
|
2836
|
+
if (baseAttrs.rowspan > 1) baseAttrs = {
|
|
2837
|
+
...baseAttrs,
|
|
2838
|
+
rowspan: 1
|
|
2839
|
+
};
|
|
2840
|
+
if (baseAttrs.colspan > 1) baseAttrs = {
|
|
2841
|
+
...baseAttrs,
|
|
2842
|
+
colspan: 1
|
|
2843
|
+
};
|
|
2844
|
+
const rect = selectedRect(state), tr = state.tr;
|
|
2845
|
+
for (let i = 0; i < rect.right - rect.left; i++) attrs.push(colwidth ? {
|
|
2846
|
+
...baseAttrs,
|
|
2847
|
+
colwidth: colwidth && colwidth[i] ? [colwidth[i]] : null
|
|
2848
|
+
} : baseAttrs);
|
|
2849
|
+
let lastCell;
|
|
2850
|
+
for (let row = rect.top; row < rect.bottom; row++) {
|
|
2851
|
+
let pos = rect.map.positionAt(row, rect.left, rect.table);
|
|
2852
|
+
if (row == rect.top) pos += cellNode.nodeSize;
|
|
2853
|
+
for (let col = rect.left, i = 0; col < rect.right; col++, i++) {
|
|
2854
|
+
if (col == rect.left && row == rect.top) continue;
|
|
2855
|
+
tr.insert(lastCell = tr.mapping.map(pos + rect.tableStart, 1), getCellType({
|
|
2856
|
+
node: cellNode,
|
|
2857
|
+
row,
|
|
2858
|
+
col
|
|
2859
|
+
}).createAndFill(attrs[i]));
|
|
2860
|
+
}
|
|
2861
|
+
}
|
|
2862
|
+
tr.setNodeMarkup(cellPos, getCellType({
|
|
2863
|
+
node: cellNode,
|
|
2864
|
+
row: rect.top,
|
|
2865
|
+
col: rect.left
|
|
2866
|
+
}), attrs[0]);
|
|
2867
|
+
if (sel instanceof CellSelection) tr.setSelection(new CellSelection(tr.doc.resolve(sel.$anchorCell.pos), lastCell ? tr.doc.resolve(lastCell) : void 0));
|
|
2868
|
+
dispatch(tr);
|
|
2869
|
+
}
|
|
2870
|
+
return true;
|
|
2871
|
+
};
|
|
2872
|
+
}
|
|
2873
|
+
function setCellAttr(name, value) {
|
|
2874
|
+
return function(state, dispatch) {
|
|
2875
|
+
if (!isInTable(state)) return false;
|
|
2876
|
+
const $cell = selectionCell(state);
|
|
2877
|
+
if ($cell.nodeAfter.attrs[name] === value) return false;
|
|
2878
|
+
if (dispatch) {
|
|
2879
|
+
const tr = state.tr;
|
|
2880
|
+
if (state.selection instanceof CellSelection) state.selection.forEachCell((node, pos) => {
|
|
2881
|
+
if (node.attrs[name] !== value) tr.setNodeMarkup(pos, null, {
|
|
2882
|
+
...node.attrs,
|
|
2883
|
+
[name]: value
|
|
2884
|
+
});
|
|
2885
|
+
});
|
|
2886
|
+
else tr.setNodeMarkup($cell.pos, null, {
|
|
2887
|
+
...$cell.nodeAfter.attrs,
|
|
2888
|
+
[name]: value
|
|
2889
|
+
});
|
|
2890
|
+
dispatch(tr);
|
|
2891
|
+
}
|
|
2892
|
+
return true;
|
|
2893
|
+
};
|
|
2894
|
+
}
|
|
2895
|
+
function deprecated_toggleHeader(type) {
|
|
2896
|
+
return function(state, dispatch) {
|
|
2897
|
+
if (!isInTable(state)) return false;
|
|
2898
|
+
if (dispatch) {
|
|
2899
|
+
const types = tableNodeTypes(state.schema);
|
|
2900
|
+
const rect = selectedRect(state), tr = state.tr;
|
|
2901
|
+
const cells = rect.map.cellsInRect(type == "column" ? {
|
|
2902
|
+
left: rect.left,
|
|
2903
|
+
top: 0,
|
|
2904
|
+
right: rect.right,
|
|
2905
|
+
bottom: rect.map.height
|
|
2906
|
+
} : type == "row" ? {
|
|
2907
|
+
left: 0,
|
|
2908
|
+
top: rect.top,
|
|
2909
|
+
right: rect.map.width,
|
|
2910
|
+
bottom: rect.bottom
|
|
2911
|
+
} : rect);
|
|
2912
|
+
const nodes = cells.map((pos) => rect.table.nodeAt(pos));
|
|
2913
|
+
for (let i = 0; i < cells.length; i++) if (nodes[i].type == types.header_cell) tr.setNodeMarkup(rect.tableStart + cells[i], types.cell, nodes[i].attrs);
|
|
2914
|
+
if (tr.steps.length === 0) for (let i = 0; i < cells.length; i++) tr.setNodeMarkup(rect.tableStart + cells[i], types.header_cell, nodes[i].attrs);
|
|
2915
|
+
dispatch(tr);
|
|
2916
|
+
}
|
|
2917
|
+
return true;
|
|
2918
|
+
};
|
|
2919
|
+
}
|
|
2920
|
+
function isHeaderEnabledByType(type, rect, types) {
|
|
2921
|
+
const cellPositions = rect.map.cellsInRect({
|
|
2922
|
+
left: 0,
|
|
2923
|
+
top: 0,
|
|
2924
|
+
right: type == "row" ? rect.map.width : 1,
|
|
2925
|
+
bottom: type == "column" ? rect.map.height : 1
|
|
2926
|
+
});
|
|
2927
|
+
for (let i = 0; i < cellPositions.length; i++) {
|
|
2928
|
+
const cell = rect.table.nodeAt(cellPositions[i]);
|
|
2929
|
+
if (cell && cell.type !== types.header_cell) return false;
|
|
2930
|
+
}
|
|
2931
|
+
return true;
|
|
2932
|
+
}
|
|
2933
|
+
function toggleHeader(type, options) {
|
|
2934
|
+
options = options || { useDeprecatedLogic: false };
|
|
2935
|
+
if (options.useDeprecatedLogic) return deprecated_toggleHeader(type);
|
|
2936
|
+
return function(state, dispatch) {
|
|
2937
|
+
if (!isInTable(state)) return false;
|
|
2938
|
+
if (dispatch) {
|
|
2939
|
+
const types = tableNodeTypes(state.schema);
|
|
2940
|
+
const rect = selectedRect(state), tr = state.tr;
|
|
2941
|
+
const isHeaderRowEnabled = isHeaderEnabledByType("row", rect, types);
|
|
2942
|
+
const isHeaderColumnEnabled = isHeaderEnabledByType("column", rect, types);
|
|
2943
|
+
const selectionStartsAt = (type === "column" ? isHeaderRowEnabled : type === "row" ? isHeaderColumnEnabled : false) ? 1 : 0;
|
|
2944
|
+
const cellsRect = type == "column" ? {
|
|
2945
|
+
left: 0,
|
|
2946
|
+
top: selectionStartsAt,
|
|
2947
|
+
right: 1,
|
|
2948
|
+
bottom: rect.map.height
|
|
2949
|
+
} : type == "row" ? {
|
|
2950
|
+
left: selectionStartsAt,
|
|
2951
|
+
top: 0,
|
|
2952
|
+
right: rect.map.width,
|
|
2953
|
+
bottom: 1
|
|
2954
|
+
} : rect;
|
|
2955
|
+
const newType = type == "column" ? isHeaderColumnEnabled ? types.cell : types.header_cell : type == "row" ? isHeaderRowEnabled ? types.cell : types.header_cell : types.cell;
|
|
2956
|
+
rect.map.cellsInRect(cellsRect).forEach((relativeCellPos) => {
|
|
2957
|
+
const cellPos = relativeCellPos + rect.tableStart;
|
|
2958
|
+
const cell = tr.doc.nodeAt(cellPos);
|
|
2959
|
+
if (cell) tr.setNodeMarkup(cellPos, newType, cell.attrs);
|
|
2960
|
+
});
|
|
2961
|
+
dispatch(tr);
|
|
2962
|
+
}
|
|
2963
|
+
return true;
|
|
2964
|
+
};
|
|
2965
|
+
}
|
|
2966
|
+
var toggleHeaderRow = toggleHeader("row", { useDeprecatedLogic: true });
|
|
2967
|
+
var toggleHeaderColumn = toggleHeader("column", { useDeprecatedLogic: true });
|
|
2968
|
+
var toggleHeaderCell = toggleHeader("cell", { useDeprecatedLogic: true });
|
|
2969
|
+
function findNextCell($cell, dir) {
|
|
2970
|
+
if (dir < 0) {
|
|
2971
|
+
const before = $cell.nodeBefore;
|
|
2972
|
+
if (before) return $cell.pos - before.nodeSize;
|
|
2973
|
+
for (let row = $cell.index(-1) - 1, rowEnd = $cell.before(); row >= 0; row--) {
|
|
2974
|
+
const rowNode = $cell.node(-1).child(row);
|
|
2975
|
+
const lastChild = rowNode.lastChild;
|
|
2976
|
+
if (lastChild) return rowEnd - 1 - lastChild.nodeSize;
|
|
2977
|
+
rowEnd -= rowNode.nodeSize;
|
|
2978
|
+
}
|
|
2979
|
+
} else {
|
|
2980
|
+
if ($cell.index() < $cell.parent.childCount - 1) return $cell.pos + $cell.nodeAfter.nodeSize;
|
|
2981
|
+
const table = $cell.node(-1);
|
|
2982
|
+
for (let row = $cell.indexAfter(-1), rowStart = $cell.after(); row < table.childCount; row++) {
|
|
2983
|
+
const rowNode = table.child(row);
|
|
2984
|
+
if (rowNode.childCount) return rowStart + 1;
|
|
2985
|
+
rowStart += rowNode.nodeSize;
|
|
2986
|
+
}
|
|
2987
|
+
}
|
|
2988
|
+
return null;
|
|
2989
|
+
}
|
|
2990
|
+
function goToNextCell(direction) {
|
|
2991
|
+
return function(state, dispatch) {
|
|
2992
|
+
if (!isInTable(state)) return false;
|
|
2993
|
+
const cell = findNextCell(selectionCell(state), direction);
|
|
2994
|
+
if (cell == null) return false;
|
|
2995
|
+
if (dispatch) {
|
|
2996
|
+
const $cell = state.doc.resolve(cell);
|
|
2997
|
+
dispatch(state.tr.setSelection(TextSelection.between($cell, moveCellForward($cell))).scrollIntoView());
|
|
2998
|
+
}
|
|
2999
|
+
return true;
|
|
3000
|
+
};
|
|
3001
|
+
}
|
|
3002
|
+
function deleteTable(state, dispatch) {
|
|
3003
|
+
const $pos = state.selection.$anchor;
|
|
3004
|
+
for (let d = $pos.depth; d > 0; d--) if ($pos.node(d).type.spec.tableRole == "table") {
|
|
3005
|
+
if (dispatch) dispatch(state.tr.delete($pos.before(d), $pos.after(d)).scrollIntoView());
|
|
3006
|
+
return true;
|
|
3007
|
+
}
|
|
3008
|
+
return false;
|
|
3009
|
+
}
|
|
3010
|
+
function deleteCellSelection(state, dispatch) {
|
|
3011
|
+
const sel = state.selection;
|
|
3012
|
+
if (!(sel instanceof CellSelection)) return false;
|
|
3013
|
+
if (dispatch) {
|
|
3014
|
+
const tr = state.tr;
|
|
3015
|
+
const baseContent = tableNodeTypes(state.schema).cell.createAndFill().content;
|
|
3016
|
+
sel.forEachCell((cell, pos) => {
|
|
3017
|
+
if (!cell.content.eq(baseContent)) tr.replace(tr.mapping.map(pos + 1), tr.mapping.map(pos + cell.nodeSize - 1), new Slice(baseContent, 0, 0));
|
|
3018
|
+
});
|
|
3019
|
+
if (tr.docChanged) dispatch(tr);
|
|
3020
|
+
}
|
|
3021
|
+
return true;
|
|
3022
|
+
}
|
|
3023
|
+
function pastedCells(slice) {
|
|
3024
|
+
if (slice.size === 0) return null;
|
|
3025
|
+
let { content, openStart, openEnd } = slice;
|
|
3026
|
+
while (content.childCount == 1 && (openStart > 0 && openEnd > 0 || content.child(0).type.spec.tableRole == "table")) {
|
|
3027
|
+
openStart--;
|
|
3028
|
+
openEnd--;
|
|
3029
|
+
content = content.child(0).content;
|
|
3030
|
+
}
|
|
3031
|
+
const first = content.child(0);
|
|
3032
|
+
const role = first.type.spec.tableRole;
|
|
3033
|
+
const schema = first.type.schema, rows = [];
|
|
3034
|
+
if (role == "row") for (let i = 0; i < content.childCount; i++) {
|
|
3035
|
+
let cells = content.child(i).content;
|
|
3036
|
+
const left = i ? 0 : Math.max(0, openStart - 1);
|
|
3037
|
+
const right = i < content.childCount - 1 ? 0 : Math.max(0, openEnd - 1);
|
|
3038
|
+
if (left || right) cells = fitSlice(tableNodeTypes(schema).row, new Slice(cells, left, right)).content;
|
|
3039
|
+
rows.push(cells);
|
|
3040
|
+
}
|
|
3041
|
+
else if (role == "cell" || role == "header_cell") rows.push(openStart || openEnd ? fitSlice(tableNodeTypes(schema).row, new Slice(content, openStart, openEnd)).content : content);
|
|
3042
|
+
else return null;
|
|
3043
|
+
return ensureRectangular(schema, rows);
|
|
3044
|
+
}
|
|
3045
|
+
function ensureRectangular(schema, rows) {
|
|
3046
|
+
const widths = [];
|
|
3047
|
+
for (let i = 0; i < rows.length; i++) {
|
|
3048
|
+
const row = rows[i];
|
|
3049
|
+
for (let j = row.childCount - 1; j >= 0; j--) {
|
|
3050
|
+
const { rowspan, colspan } = row.child(j).attrs;
|
|
3051
|
+
for (let r = i; r < i + rowspan; r++) widths[r] = (widths[r] || 0) + colspan;
|
|
3052
|
+
}
|
|
3053
|
+
}
|
|
3054
|
+
let width = 0;
|
|
3055
|
+
for (let r = 0; r < widths.length; r++) width = Math.max(width, widths[r]);
|
|
3056
|
+
for (let r = 0; r < widths.length; r++) {
|
|
3057
|
+
if (r >= rows.length) rows.push(Fragment.empty);
|
|
3058
|
+
if (widths[r] < width) {
|
|
3059
|
+
const empty = tableNodeTypes(schema).cell.createAndFill();
|
|
3060
|
+
const cells = [];
|
|
3061
|
+
for (let i = widths[r]; i < width; i++) cells.push(empty);
|
|
3062
|
+
rows[r] = rows[r].append(Fragment.from(cells));
|
|
3063
|
+
}
|
|
3064
|
+
}
|
|
3065
|
+
return {
|
|
3066
|
+
height: rows.length,
|
|
3067
|
+
width,
|
|
3068
|
+
rows
|
|
3069
|
+
};
|
|
3070
|
+
}
|
|
3071
|
+
function fitSlice(nodeType, slice) {
|
|
3072
|
+
const node = nodeType.createAndFill();
|
|
3073
|
+
return new Transform(node).replace(0, node.content.size, slice).doc;
|
|
3074
|
+
}
|
|
3075
|
+
function clipCells({ width, height, rows }, newWidth, newHeight) {
|
|
3076
|
+
if (width != newWidth) {
|
|
3077
|
+
const added = [];
|
|
3078
|
+
const newRows = [];
|
|
3079
|
+
for (let row = 0; row < rows.length; row++) {
|
|
3080
|
+
const frag = rows[row], cells = [];
|
|
3081
|
+
for (let col = added[row] || 0, i = 0; col < newWidth; i++) {
|
|
3082
|
+
let cell = frag.child(i % frag.childCount);
|
|
3083
|
+
if (col + cell.attrs.colspan > newWidth) cell = cell.type.createChecked(removeColSpan(cell.attrs, cell.attrs.colspan, col + cell.attrs.colspan - newWidth), cell.content);
|
|
3084
|
+
cells.push(cell);
|
|
3085
|
+
col += cell.attrs.colspan;
|
|
3086
|
+
for (let j = 1; j < cell.attrs.rowspan; j++) added[row + j] = (added[row + j] || 0) + cell.attrs.colspan;
|
|
3087
|
+
}
|
|
3088
|
+
newRows.push(Fragment.from(cells));
|
|
3089
|
+
}
|
|
3090
|
+
rows = newRows;
|
|
3091
|
+
width = newWidth;
|
|
3092
|
+
}
|
|
3093
|
+
if (height != newHeight) {
|
|
3094
|
+
const newRows = [];
|
|
3095
|
+
for (let row = 0, i = 0; row < newHeight; row++, i++) {
|
|
3096
|
+
const cells = [], source = rows[i % height];
|
|
3097
|
+
for (let j = 0; j < source.childCount; j++) {
|
|
3098
|
+
let cell = source.child(j);
|
|
3099
|
+
if (row + cell.attrs.rowspan > newHeight) cell = cell.type.create({
|
|
3100
|
+
...cell.attrs,
|
|
3101
|
+
rowspan: Math.max(1, newHeight - cell.attrs.rowspan)
|
|
3102
|
+
}, cell.content);
|
|
3103
|
+
cells.push(cell);
|
|
3104
|
+
}
|
|
3105
|
+
newRows.push(Fragment.from(cells));
|
|
3106
|
+
}
|
|
3107
|
+
rows = newRows;
|
|
3108
|
+
height = newHeight;
|
|
3109
|
+
}
|
|
3110
|
+
return {
|
|
3111
|
+
width,
|
|
3112
|
+
height,
|
|
3113
|
+
rows
|
|
3114
|
+
};
|
|
3115
|
+
}
|
|
3116
|
+
function growTable(tr, map, table, start, width, height, mapFrom) {
|
|
3117
|
+
const schema = tr.doc.type.schema;
|
|
3118
|
+
const types = tableNodeTypes(schema);
|
|
3119
|
+
let empty;
|
|
3120
|
+
let emptyHead;
|
|
3121
|
+
if (width > map.width) for (let row = 0, rowEnd = 0; row < map.height; row++) {
|
|
3122
|
+
const rowNode = table.child(row);
|
|
3123
|
+
rowEnd += rowNode.nodeSize;
|
|
3124
|
+
const cells = [];
|
|
3125
|
+
let add;
|
|
3126
|
+
if (rowNode.lastChild == null || rowNode.lastChild.type == types.cell) add = empty || (empty = types.cell.createAndFill());
|
|
3127
|
+
else add = emptyHead || (emptyHead = types.header_cell.createAndFill());
|
|
3128
|
+
for (let i = map.width; i < width; i++) cells.push(add);
|
|
3129
|
+
tr.insert(tr.mapping.slice(mapFrom).map(rowEnd - 1 + start), cells);
|
|
3130
|
+
}
|
|
3131
|
+
if (height > map.height) {
|
|
3132
|
+
const cells = [];
|
|
3133
|
+
for (let i = 0, start$1 = (map.height - 1) * map.width; i < Math.max(map.width, width); i++) {
|
|
3134
|
+
const header = i >= map.width ? false : table.nodeAt(map.map[start$1 + i]).type == types.header_cell;
|
|
3135
|
+
cells.push(header ? emptyHead || (emptyHead = types.header_cell.createAndFill()) : empty || (empty = types.cell.createAndFill()));
|
|
3136
|
+
}
|
|
3137
|
+
const emptyRow = types.row.create(null, Fragment.from(cells)), rows = [];
|
|
3138
|
+
for (let i = map.height; i < height; i++) rows.push(emptyRow);
|
|
3139
|
+
tr.insert(tr.mapping.slice(mapFrom).map(start + table.nodeSize - 2), rows);
|
|
3140
|
+
}
|
|
3141
|
+
return !!(empty || emptyHead);
|
|
3142
|
+
}
|
|
3143
|
+
function isolateHorizontal(tr, map, table, start, left, right, top, mapFrom) {
|
|
3144
|
+
if (top == 0 || top == map.height) return false;
|
|
3145
|
+
let found = false;
|
|
3146
|
+
for (let col = left; col < right; col++) {
|
|
3147
|
+
const index = top * map.width + col, pos = map.map[index];
|
|
3148
|
+
if (map.map[index - map.width] == pos) {
|
|
3149
|
+
found = true;
|
|
3150
|
+
const cell = table.nodeAt(pos);
|
|
3151
|
+
const { top: cellTop, left: cellLeft } = map.findCell(pos);
|
|
3152
|
+
tr.setNodeMarkup(tr.mapping.slice(mapFrom).map(pos + start), null, {
|
|
3153
|
+
...cell.attrs,
|
|
3154
|
+
rowspan: top - cellTop
|
|
3155
|
+
});
|
|
3156
|
+
tr.insert(tr.mapping.slice(mapFrom).map(map.positionAt(top, cellLeft, table)), cell.type.createAndFill({
|
|
3157
|
+
...cell.attrs,
|
|
3158
|
+
rowspan: cellTop + cell.attrs.rowspan - top
|
|
3159
|
+
}));
|
|
3160
|
+
col += cell.attrs.colspan - 1;
|
|
3161
|
+
}
|
|
3162
|
+
}
|
|
3163
|
+
return found;
|
|
3164
|
+
}
|
|
3165
|
+
function isolateVertical(tr, map, table, start, top, bottom, left, mapFrom) {
|
|
3166
|
+
if (left == 0 || left == map.width) return false;
|
|
3167
|
+
let found = false;
|
|
3168
|
+
for (let row = top; row < bottom; row++) {
|
|
3169
|
+
const index = row * map.width + left, pos = map.map[index];
|
|
3170
|
+
if (map.map[index - 1] == pos) {
|
|
3171
|
+
found = true;
|
|
3172
|
+
const cell = table.nodeAt(pos);
|
|
3173
|
+
const cellLeft = map.colCount(pos);
|
|
3174
|
+
const updatePos = tr.mapping.slice(mapFrom).map(pos + start);
|
|
3175
|
+
tr.setNodeMarkup(updatePos, null, removeColSpan(cell.attrs, left - cellLeft, cell.attrs.colspan - (left - cellLeft)));
|
|
3176
|
+
tr.insert(updatePos + cell.nodeSize, cell.type.createAndFill(removeColSpan(cell.attrs, 0, left - cellLeft)));
|
|
3177
|
+
row += cell.attrs.rowspan - 1;
|
|
3178
|
+
}
|
|
3179
|
+
}
|
|
3180
|
+
return found;
|
|
3181
|
+
}
|
|
3182
|
+
function insertCells(state, dispatch, tableStart, rect, cells) {
|
|
3183
|
+
let table = tableStart ? state.doc.nodeAt(tableStart - 1) : state.doc;
|
|
3184
|
+
if (!table) throw new Error("No table found");
|
|
3185
|
+
let map = TableMap.get(table);
|
|
3186
|
+
const { top, left } = rect;
|
|
3187
|
+
const right = left + cells.width, bottom = top + cells.height;
|
|
3188
|
+
const tr = state.tr;
|
|
3189
|
+
let mapFrom = 0;
|
|
3190
|
+
function recomp() {
|
|
3191
|
+
table = tableStart ? tr.doc.nodeAt(tableStart - 1) : tr.doc;
|
|
3192
|
+
if (!table) throw new Error("No table found");
|
|
3193
|
+
map = TableMap.get(table);
|
|
3194
|
+
mapFrom = tr.mapping.maps.length;
|
|
3195
|
+
}
|
|
3196
|
+
if (growTable(tr, map, table, tableStart, right, bottom, mapFrom)) recomp();
|
|
3197
|
+
if (isolateHorizontal(tr, map, table, tableStart, left, right, top, mapFrom)) recomp();
|
|
3198
|
+
if (isolateHorizontal(tr, map, table, tableStart, left, right, bottom, mapFrom)) recomp();
|
|
3199
|
+
if (isolateVertical(tr, map, table, tableStart, top, bottom, left, mapFrom)) recomp();
|
|
3200
|
+
if (isolateVertical(tr, map, table, tableStart, top, bottom, right, mapFrom)) recomp();
|
|
3201
|
+
for (let row = top; row < bottom; row++) {
|
|
3202
|
+
const from = map.positionAt(row, left, table), to = map.positionAt(row, right, table);
|
|
3203
|
+
tr.replace(tr.mapping.slice(mapFrom).map(from + tableStart), tr.mapping.slice(mapFrom).map(to + tableStart), new Slice(cells.rows[row - top], 0, 0));
|
|
3204
|
+
}
|
|
3205
|
+
recomp();
|
|
3206
|
+
tr.setSelection(new CellSelection(tr.doc.resolve(tableStart + map.positionAt(top, left, table)), tr.doc.resolve(tableStart + map.positionAt(bottom - 1, right - 1, table))));
|
|
3207
|
+
dispatch(tr);
|
|
3208
|
+
}
|
|
3209
|
+
var handleKeyDown = keydownHandler({
|
|
3210
|
+
ArrowLeft: arrow3("horiz", -1),
|
|
3211
|
+
ArrowRight: arrow3("horiz", 1),
|
|
3212
|
+
ArrowUp: arrow3("vert", -1),
|
|
3213
|
+
ArrowDown: arrow3("vert", 1),
|
|
3214
|
+
"Shift-ArrowLeft": shiftArrow("horiz", -1),
|
|
3215
|
+
"Shift-ArrowRight": shiftArrow("horiz", 1),
|
|
3216
|
+
"Shift-ArrowUp": shiftArrow("vert", -1),
|
|
3217
|
+
"Shift-ArrowDown": shiftArrow("vert", 1),
|
|
3218
|
+
Backspace: deleteCellSelection,
|
|
3219
|
+
"Mod-Backspace": deleteCellSelection,
|
|
3220
|
+
Delete: deleteCellSelection,
|
|
3221
|
+
"Mod-Delete": deleteCellSelection
|
|
3222
|
+
});
|
|
3223
|
+
function maybeSetSelection(state, dispatch, selection) {
|
|
3224
|
+
if (selection.eq(state.selection)) return false;
|
|
3225
|
+
if (dispatch) dispatch(state.tr.setSelection(selection).scrollIntoView());
|
|
3226
|
+
return true;
|
|
3227
|
+
}
|
|
3228
|
+
function arrow3(axis, dir) {
|
|
3229
|
+
return (state, dispatch, view) => {
|
|
3230
|
+
if (!view) return false;
|
|
3231
|
+
const sel = state.selection;
|
|
3232
|
+
if (sel instanceof CellSelection) return maybeSetSelection(state, dispatch, Selection.near(sel.$headCell, dir));
|
|
3233
|
+
if (axis != "horiz" && !sel.empty) return false;
|
|
3234
|
+
const end = atEndOfCell(view, axis, dir);
|
|
3235
|
+
if (end == null) return false;
|
|
3236
|
+
if (axis == "horiz") return maybeSetSelection(state, dispatch, Selection.near(state.doc.resolve(sel.head + dir), dir));
|
|
3237
|
+
else {
|
|
3238
|
+
const $cell = state.doc.resolve(end);
|
|
3239
|
+
const $next = nextCell($cell, axis, dir);
|
|
3240
|
+
let newSel;
|
|
3241
|
+
if ($next) newSel = Selection.near($next, 1);
|
|
3242
|
+
else if (dir < 0) newSel = Selection.near(state.doc.resolve($cell.before(-1)), -1);
|
|
3243
|
+
else newSel = Selection.near(state.doc.resolve($cell.after(-1)), 1);
|
|
3244
|
+
return maybeSetSelection(state, dispatch, newSel);
|
|
3245
|
+
}
|
|
3246
|
+
};
|
|
3247
|
+
}
|
|
3248
|
+
function shiftArrow(axis, dir) {
|
|
3249
|
+
return (state, dispatch, view) => {
|
|
3250
|
+
if (!view) return false;
|
|
3251
|
+
const sel = state.selection;
|
|
3252
|
+
let cellSel;
|
|
3253
|
+
if (sel instanceof CellSelection) cellSel = sel;
|
|
3254
|
+
else {
|
|
3255
|
+
const end = atEndOfCell(view, axis, dir);
|
|
3256
|
+
if (end == null) return false;
|
|
3257
|
+
cellSel = new CellSelection(state.doc.resolve(end));
|
|
3258
|
+
}
|
|
3259
|
+
const $head = nextCell(cellSel.$headCell, axis, dir);
|
|
3260
|
+
if (!$head) return false;
|
|
3261
|
+
return maybeSetSelection(state, dispatch, new CellSelection(cellSel.$anchorCell, $head));
|
|
3262
|
+
};
|
|
3263
|
+
}
|
|
3264
|
+
function handleTripleClick(view, pos) {
|
|
3265
|
+
const doc = view.state.doc, $cell = cellAround(doc.resolve(pos));
|
|
3266
|
+
if (!$cell) return false;
|
|
3267
|
+
view.dispatch(view.state.tr.setSelection(new CellSelection($cell)));
|
|
3268
|
+
return true;
|
|
3269
|
+
}
|
|
3270
|
+
function handlePaste(view, _, slice) {
|
|
3271
|
+
if (!isInTable(view.state)) return false;
|
|
3272
|
+
let cells = pastedCells(slice);
|
|
3273
|
+
const sel = view.state.selection;
|
|
3274
|
+
if (sel instanceof CellSelection) {
|
|
3275
|
+
if (!cells) cells = {
|
|
3276
|
+
width: 1,
|
|
3277
|
+
height: 1,
|
|
3278
|
+
rows: [Fragment.from(fitSlice(tableNodeTypes(view.state.schema).cell, slice))]
|
|
3279
|
+
};
|
|
3280
|
+
const table = sel.$anchorCell.node(-1);
|
|
3281
|
+
const start = sel.$anchorCell.start(-1);
|
|
3282
|
+
const rect = TableMap.get(table).rectBetween(sel.$anchorCell.pos - start, sel.$headCell.pos - start);
|
|
3283
|
+
cells = clipCells(cells, rect.right - rect.left, rect.bottom - rect.top);
|
|
3284
|
+
insertCells(view.state, view.dispatch, start, rect, cells);
|
|
3285
|
+
return true;
|
|
3286
|
+
} else if (cells) {
|
|
3287
|
+
const $cell = selectionCell(view.state);
|
|
3288
|
+
const start = $cell.start(-1);
|
|
3289
|
+
insertCells(view.state, view.dispatch, start, TableMap.get($cell.node(-1)).findCell($cell.pos - start), cells);
|
|
3290
|
+
return true;
|
|
3291
|
+
} else return false;
|
|
3292
|
+
}
|
|
3293
|
+
function handleMouseDown$1(view, startEvent) {
|
|
3294
|
+
var _cellUnderMouse;
|
|
3295
|
+
if (startEvent.button != 0) return;
|
|
3296
|
+
if (startEvent.ctrlKey || startEvent.metaKey) return;
|
|
3297
|
+
const startDOMCell = domInCell(view, startEvent.target);
|
|
3298
|
+
let $anchor;
|
|
3299
|
+
if (startEvent.shiftKey && view.state.selection instanceof CellSelection) {
|
|
3300
|
+
setCellSelection(view.state.selection.$anchorCell, startEvent);
|
|
3301
|
+
startEvent.preventDefault();
|
|
3302
|
+
} else if (startEvent.shiftKey && startDOMCell && ($anchor = cellAround(view.state.selection.$anchor)) != null && ((_cellUnderMouse = cellUnderMouse(view, startEvent)) === null || _cellUnderMouse === void 0 ? void 0 : _cellUnderMouse.pos) != $anchor.pos) {
|
|
3303
|
+
setCellSelection($anchor, startEvent);
|
|
3304
|
+
startEvent.preventDefault();
|
|
3305
|
+
} else if (!startDOMCell) return;
|
|
3306
|
+
function setCellSelection($anchor$1, event) {
|
|
3307
|
+
let $head = cellUnderMouse(view, event);
|
|
3308
|
+
const starting = tableEditingKey.getState(view.state) == null;
|
|
3309
|
+
if (!$head || !inSameTable($anchor$1, $head)) if (starting) $head = $anchor$1;
|
|
3310
|
+
else return;
|
|
3311
|
+
const selection = new CellSelection($anchor$1, $head);
|
|
3312
|
+
if (starting || !view.state.selection.eq(selection)) {
|
|
3313
|
+
const tr = view.state.tr.setSelection(selection);
|
|
3314
|
+
if (starting) tr.setMeta(tableEditingKey, $anchor$1.pos);
|
|
3315
|
+
view.dispatch(tr);
|
|
3316
|
+
}
|
|
3317
|
+
}
|
|
3318
|
+
function stop() {
|
|
3319
|
+
view.root.removeEventListener("mouseup", stop);
|
|
3320
|
+
view.root.removeEventListener("dragstart", stop);
|
|
3321
|
+
view.root.removeEventListener("mousemove", move);
|
|
3322
|
+
if (tableEditingKey.getState(view.state) != null) view.dispatch(view.state.tr.setMeta(tableEditingKey, -1));
|
|
3323
|
+
}
|
|
3324
|
+
function move(_event) {
|
|
3325
|
+
const event = _event;
|
|
3326
|
+
const anchor = tableEditingKey.getState(view.state);
|
|
3327
|
+
let $anchor$1;
|
|
3328
|
+
if (anchor != null) $anchor$1 = view.state.doc.resolve(anchor);
|
|
3329
|
+
else if (domInCell(view, event.target) != startDOMCell) {
|
|
3330
|
+
$anchor$1 = cellUnderMouse(view, startEvent);
|
|
3331
|
+
if (!$anchor$1) return stop();
|
|
3332
|
+
}
|
|
3333
|
+
if ($anchor$1) setCellSelection($anchor$1, event);
|
|
3334
|
+
}
|
|
3335
|
+
view.root.addEventListener("mouseup", stop);
|
|
3336
|
+
view.root.addEventListener("dragstart", stop);
|
|
3337
|
+
view.root.addEventListener("mousemove", move);
|
|
3338
|
+
}
|
|
3339
|
+
function atEndOfCell(view, axis, dir) {
|
|
3340
|
+
if (!(view.state.selection instanceof TextSelection)) return null;
|
|
3341
|
+
const { $head } = view.state.selection;
|
|
3342
|
+
for (let d = $head.depth - 1; d >= 0; d--) {
|
|
3343
|
+
const parent = $head.node(d);
|
|
3344
|
+
if ((dir < 0 ? $head.index(d) : $head.indexAfter(d)) != (dir < 0 ? 0 : parent.childCount)) return null;
|
|
3345
|
+
if (parent.type.spec.tableRole == "cell" || parent.type.spec.tableRole == "header_cell") {
|
|
3346
|
+
const cellPos = $head.before(d);
|
|
3347
|
+
const dirStr = axis == "vert" ? dir > 0 ? "down" : "up" : dir > 0 ? "right" : "left";
|
|
3348
|
+
return view.endOfTextblock(dirStr) ? cellPos : null;
|
|
3349
|
+
}
|
|
3350
|
+
}
|
|
3351
|
+
return null;
|
|
3352
|
+
}
|
|
3353
|
+
function domInCell(view, dom) {
|
|
3354
|
+
for (; dom && dom != view.dom; dom = dom.parentNode) if (dom.nodeName == "TD" || dom.nodeName == "TH") return dom;
|
|
3355
|
+
return null;
|
|
3356
|
+
}
|
|
3357
|
+
function cellUnderMouse(view, event) {
|
|
3358
|
+
const mousePos = view.posAtCoords({
|
|
3359
|
+
left: event.clientX,
|
|
3360
|
+
top: event.clientY
|
|
3361
|
+
});
|
|
3362
|
+
if (!mousePos) return null;
|
|
3363
|
+
let { inside, pos } = mousePos;
|
|
3364
|
+
return inside >= 0 && cellAround(view.state.doc.resolve(inside)) || cellAround(view.state.doc.resolve(pos));
|
|
3365
|
+
}
|
|
3366
|
+
var TableView = class {
|
|
3367
|
+
constructor(node, defaultCellMinWidth) {
|
|
3368
|
+
this.node = node;
|
|
3369
|
+
this.defaultCellMinWidth = defaultCellMinWidth;
|
|
3370
|
+
this.dom = document.createElement("div");
|
|
3371
|
+
this.dom.className = "tableWrapper";
|
|
3372
|
+
this.table = this.dom.appendChild(document.createElement("table"));
|
|
3373
|
+
this.table.style.setProperty("--default-cell-min-width", `${defaultCellMinWidth}px`);
|
|
3374
|
+
this.colgroup = this.table.appendChild(document.createElement("colgroup"));
|
|
3375
|
+
updateColumnsOnResize(node, this.colgroup, this.table, defaultCellMinWidth);
|
|
3376
|
+
this.contentDOM = this.table.appendChild(document.createElement("tbody"));
|
|
3377
|
+
}
|
|
3378
|
+
update(node) {
|
|
3379
|
+
if (node.type != this.node.type) return false;
|
|
3380
|
+
this.node = node;
|
|
3381
|
+
updateColumnsOnResize(node, this.colgroup, this.table, this.defaultCellMinWidth);
|
|
3382
|
+
return true;
|
|
3383
|
+
}
|
|
3384
|
+
ignoreMutation(record) {
|
|
3385
|
+
return record.type == "attributes" && (record.target == this.table || this.colgroup.contains(record.target));
|
|
3386
|
+
}
|
|
3387
|
+
};
|
|
3388
|
+
function updateColumnsOnResize(node, colgroup, table, defaultCellMinWidth, overrideCol, overrideValue) {
|
|
3389
|
+
let totalWidth = 0;
|
|
3390
|
+
let fixedWidth = true;
|
|
3391
|
+
let nextDOM = colgroup.firstChild;
|
|
3392
|
+
const row = node.firstChild;
|
|
3393
|
+
if (!row) return;
|
|
3394
|
+
for (let i = 0, col = 0; i < row.childCount; i++) {
|
|
3395
|
+
const { colspan, colwidth } = row.child(i).attrs;
|
|
3396
|
+
for (let j = 0; j < colspan; j++, col++) {
|
|
3397
|
+
const hasWidth = overrideCol == col ? overrideValue : colwidth && colwidth[j];
|
|
3398
|
+
const cssWidth = hasWidth ? hasWidth + "px" : "";
|
|
3399
|
+
totalWidth += hasWidth || defaultCellMinWidth;
|
|
3400
|
+
if (!hasWidth) fixedWidth = false;
|
|
3401
|
+
if (!nextDOM) {
|
|
3402
|
+
const col$1 = document.createElement("col");
|
|
3403
|
+
col$1.style.width = cssWidth;
|
|
3404
|
+
colgroup.appendChild(col$1);
|
|
3405
|
+
} else {
|
|
3406
|
+
if (nextDOM.style.width != cssWidth) nextDOM.style.width = cssWidth;
|
|
3407
|
+
nextDOM = nextDOM.nextSibling;
|
|
3408
|
+
}
|
|
3409
|
+
}
|
|
3410
|
+
}
|
|
3411
|
+
while (nextDOM) {
|
|
3412
|
+
var _nextDOM$parentNode;
|
|
3413
|
+
const after = nextDOM.nextSibling;
|
|
3414
|
+
(_nextDOM$parentNode = nextDOM.parentNode) === null || _nextDOM$parentNode === void 0 || _nextDOM$parentNode.removeChild(nextDOM);
|
|
3415
|
+
nextDOM = after;
|
|
3416
|
+
}
|
|
3417
|
+
if (fixedWidth) {
|
|
3418
|
+
table.style.width = totalWidth + "px";
|
|
3419
|
+
table.style.minWidth = "";
|
|
3420
|
+
} else {
|
|
3421
|
+
table.style.width = "";
|
|
3422
|
+
table.style.minWidth = totalWidth + "px";
|
|
3423
|
+
}
|
|
3424
|
+
}
|
|
3425
|
+
var columnResizingPluginKey = new PluginKey("tableColumnResizing");
|
|
3426
|
+
function columnResizing({ handleWidth = 5, cellMinWidth = 25, defaultCellMinWidth = 100, View = TableView, lastColumnResizable = true } = {}) {
|
|
3427
|
+
const plugin = new Plugin({
|
|
3428
|
+
key: columnResizingPluginKey,
|
|
3429
|
+
state: {
|
|
3430
|
+
init(_, state) {
|
|
3431
|
+
var _plugin$spec;
|
|
3432
|
+
const nodeViews = (_plugin$spec = plugin.spec) === null || _plugin$spec === void 0 || (_plugin$spec = _plugin$spec.props) === null || _plugin$spec === void 0 ? void 0 : _plugin$spec.nodeViews;
|
|
3433
|
+
const tableName = tableNodeTypes(state.schema).table.name;
|
|
3434
|
+
if (View && nodeViews) nodeViews[tableName] = (node, view) => {
|
|
3435
|
+
return new View(node, defaultCellMinWidth, view);
|
|
3436
|
+
};
|
|
3437
|
+
return new ResizeState(-1, false);
|
|
3438
|
+
},
|
|
3439
|
+
apply(tr, prev) {
|
|
3440
|
+
return prev.apply(tr);
|
|
3441
|
+
}
|
|
3442
|
+
},
|
|
3443
|
+
props: {
|
|
3444
|
+
attributes: (state) => {
|
|
3445
|
+
const pluginState = columnResizingPluginKey.getState(state);
|
|
3446
|
+
return pluginState && pluginState.activeHandle > -1 ? { class: "resize-cursor" } : {};
|
|
3447
|
+
},
|
|
3448
|
+
handleDOMEvents: {
|
|
3449
|
+
mousemove: (view, event) => {
|
|
3450
|
+
handleMouseMove(view, event, handleWidth, lastColumnResizable);
|
|
3451
|
+
},
|
|
3452
|
+
mouseleave: (view) => {
|
|
3453
|
+
handleMouseLeave(view);
|
|
3454
|
+
},
|
|
3455
|
+
mousedown: (view, event) => {
|
|
3456
|
+
handleMouseDown(view, event, cellMinWidth, defaultCellMinWidth);
|
|
3457
|
+
}
|
|
3458
|
+
},
|
|
3459
|
+
decorations: (state) => {
|
|
3460
|
+
const pluginState = columnResizingPluginKey.getState(state);
|
|
3461
|
+
if (pluginState && pluginState.activeHandle > -1) return handleDecorations(state, pluginState.activeHandle);
|
|
3462
|
+
},
|
|
3463
|
+
nodeViews: {}
|
|
3464
|
+
}
|
|
3465
|
+
});
|
|
3466
|
+
return plugin;
|
|
3467
|
+
}
|
|
3468
|
+
var ResizeState = class ResizeState2 {
|
|
3469
|
+
constructor(activeHandle, dragging) {
|
|
3470
|
+
this.activeHandle = activeHandle;
|
|
3471
|
+
this.dragging = dragging;
|
|
3472
|
+
}
|
|
3473
|
+
apply(tr) {
|
|
3474
|
+
const state = this;
|
|
3475
|
+
const action = tr.getMeta(columnResizingPluginKey);
|
|
3476
|
+
if (action && action.setHandle != null) return new ResizeState2(action.setHandle, false);
|
|
3477
|
+
if (action && action.setDragging !== void 0) return new ResizeState2(state.activeHandle, action.setDragging);
|
|
3478
|
+
if (state.activeHandle > -1 && tr.docChanged) {
|
|
3479
|
+
let handle = tr.mapping.map(state.activeHandle, -1);
|
|
3480
|
+
if (!pointsAtCell(tr.doc.resolve(handle))) handle = -1;
|
|
3481
|
+
return new ResizeState2(handle, state.dragging);
|
|
3482
|
+
}
|
|
3483
|
+
return state;
|
|
3484
|
+
}
|
|
3485
|
+
};
|
|
3486
|
+
function handleMouseMove(view, event, handleWidth, lastColumnResizable) {
|
|
3487
|
+
if (!view.editable) return;
|
|
3488
|
+
const pluginState = columnResizingPluginKey.getState(view.state);
|
|
3489
|
+
if (!pluginState) return;
|
|
3490
|
+
if (!pluginState.dragging) {
|
|
3491
|
+
const target = domCellAround(event.target);
|
|
3492
|
+
let cell = -1;
|
|
3493
|
+
if (target) {
|
|
3494
|
+
const { left, right } = target.getBoundingClientRect();
|
|
3495
|
+
if (event.clientX - left <= handleWidth) cell = edgeCell(view, event, "left", handleWidth);
|
|
3496
|
+
else if (right - event.clientX <= handleWidth) cell = edgeCell(view, event, "right", handleWidth);
|
|
3497
|
+
}
|
|
3498
|
+
if (cell != pluginState.activeHandle) {
|
|
3499
|
+
if (!lastColumnResizable && cell !== -1) {
|
|
3500
|
+
const $cell = view.state.doc.resolve(cell);
|
|
3501
|
+
const table = $cell.node(-1);
|
|
3502
|
+
const map = TableMap.get(table);
|
|
3503
|
+
const tableStart = $cell.start(-1);
|
|
3504
|
+
if (map.colCount($cell.pos - tableStart) + $cell.nodeAfter.attrs.colspan - 1 == map.width - 1) return;
|
|
3505
|
+
}
|
|
3506
|
+
updateHandle(view, cell);
|
|
3507
|
+
}
|
|
3508
|
+
}
|
|
3509
|
+
}
|
|
3510
|
+
function handleMouseLeave(view) {
|
|
3511
|
+
if (!view.editable) return;
|
|
3512
|
+
const pluginState = columnResizingPluginKey.getState(view.state);
|
|
3513
|
+
if (pluginState && pluginState.activeHandle > -1 && !pluginState.dragging) updateHandle(view, -1);
|
|
3514
|
+
}
|
|
3515
|
+
function handleMouseDown(view, event, cellMinWidth, defaultCellMinWidth) {
|
|
3516
|
+
var _view$dom$ownerDocume;
|
|
3517
|
+
if (!view.editable) return false;
|
|
3518
|
+
const win = (_view$dom$ownerDocume = view.dom.ownerDocument.defaultView) !== null && _view$dom$ownerDocume !== void 0 ? _view$dom$ownerDocume : window;
|
|
3519
|
+
const pluginState = columnResizingPluginKey.getState(view.state);
|
|
3520
|
+
if (!pluginState || pluginState.activeHandle == -1 || pluginState.dragging) return false;
|
|
3521
|
+
const cell = view.state.doc.nodeAt(pluginState.activeHandle);
|
|
3522
|
+
const width = currentColWidth(view, pluginState.activeHandle, cell.attrs);
|
|
3523
|
+
view.dispatch(view.state.tr.setMeta(columnResizingPluginKey, { setDragging: {
|
|
3524
|
+
startX: event.clientX,
|
|
3525
|
+
startWidth: width
|
|
3526
|
+
} }));
|
|
3527
|
+
function finish(event$1) {
|
|
3528
|
+
win.removeEventListener("mouseup", finish);
|
|
3529
|
+
win.removeEventListener("mousemove", move);
|
|
3530
|
+
const pluginState$1 = columnResizingPluginKey.getState(view.state);
|
|
3531
|
+
if (pluginState$1 === null || pluginState$1 === void 0 ? void 0 : pluginState$1.dragging) {
|
|
3532
|
+
updateColumnWidth(view, pluginState$1.activeHandle, draggedWidth(pluginState$1.dragging, event$1, cellMinWidth));
|
|
3533
|
+
view.dispatch(view.state.tr.setMeta(columnResizingPluginKey, { setDragging: null }));
|
|
3534
|
+
}
|
|
3535
|
+
}
|
|
3536
|
+
function move(event$1) {
|
|
3537
|
+
if (!event$1.which) return finish(event$1);
|
|
3538
|
+
const pluginState$1 = columnResizingPluginKey.getState(view.state);
|
|
3539
|
+
if (!pluginState$1) return;
|
|
3540
|
+
if (pluginState$1.dragging) {
|
|
3541
|
+
const dragged = draggedWidth(pluginState$1.dragging, event$1, cellMinWidth);
|
|
3542
|
+
displayColumnWidth(view, pluginState$1.activeHandle, dragged, defaultCellMinWidth);
|
|
3543
|
+
}
|
|
3544
|
+
}
|
|
3545
|
+
displayColumnWidth(view, pluginState.activeHandle, width, defaultCellMinWidth);
|
|
3546
|
+
win.addEventListener("mouseup", finish);
|
|
3547
|
+
win.addEventListener("mousemove", move);
|
|
3548
|
+
event.preventDefault();
|
|
3549
|
+
return true;
|
|
3550
|
+
}
|
|
3551
|
+
function currentColWidth(view, cellPos, { colspan, colwidth }) {
|
|
3552
|
+
const width = colwidth && colwidth[colwidth.length - 1];
|
|
3553
|
+
if (width) return width;
|
|
3554
|
+
const dom = view.domAtPos(cellPos);
|
|
3555
|
+
let domWidth = dom.node.childNodes[dom.offset].offsetWidth, parts = colspan;
|
|
3556
|
+
if (colwidth) {
|
|
3557
|
+
for (let i = 0; i < colspan; i++) if (colwidth[i]) {
|
|
3558
|
+
domWidth -= colwidth[i];
|
|
3559
|
+
parts--;
|
|
3560
|
+
}
|
|
3561
|
+
}
|
|
3562
|
+
return domWidth / parts;
|
|
3563
|
+
}
|
|
3564
|
+
function domCellAround(target) {
|
|
3565
|
+
while (target && target.nodeName != "TD" && target.nodeName != "TH") target = target.classList && target.classList.contains("ProseMirror") ? null : target.parentNode;
|
|
3566
|
+
return target;
|
|
3567
|
+
}
|
|
3568
|
+
function edgeCell(view, event, side, handleWidth) {
|
|
3569
|
+
const offset3 = side == "right" ? -handleWidth : handleWidth;
|
|
3570
|
+
const found = view.posAtCoords({
|
|
3571
|
+
left: event.clientX + offset3,
|
|
3572
|
+
top: event.clientY
|
|
3573
|
+
});
|
|
3574
|
+
if (!found) return -1;
|
|
3575
|
+
const { pos } = found;
|
|
3576
|
+
const $cell = cellAround(view.state.doc.resolve(pos));
|
|
3577
|
+
if (!$cell) return -1;
|
|
3578
|
+
if (side == "right") return $cell.pos;
|
|
3579
|
+
const map = TableMap.get($cell.node(-1)), start = $cell.start(-1);
|
|
3580
|
+
const index = map.map.indexOf($cell.pos - start);
|
|
3581
|
+
return index % map.width == 0 ? -1 : start + map.map[index - 1];
|
|
3582
|
+
}
|
|
3583
|
+
function draggedWidth(dragging, event, resizeMinWidth) {
|
|
3584
|
+
const offset3 = event.clientX - dragging.startX;
|
|
3585
|
+
return Math.max(resizeMinWidth, dragging.startWidth + offset3);
|
|
3586
|
+
}
|
|
3587
|
+
function updateHandle(view, value) {
|
|
3588
|
+
view.dispatch(view.state.tr.setMeta(columnResizingPluginKey, { setHandle: value }));
|
|
3589
|
+
}
|
|
3590
|
+
function updateColumnWidth(view, cell, width) {
|
|
3591
|
+
const $cell = view.state.doc.resolve(cell);
|
|
3592
|
+
const table = $cell.node(-1), map = TableMap.get(table), start = $cell.start(-1);
|
|
3593
|
+
const col = map.colCount($cell.pos - start) + $cell.nodeAfter.attrs.colspan - 1;
|
|
3594
|
+
const tr = view.state.tr;
|
|
3595
|
+
for (let row = 0; row < map.height; row++) {
|
|
3596
|
+
const mapIndex = row * map.width + col;
|
|
3597
|
+
if (row && map.map[mapIndex] == map.map[mapIndex - map.width]) continue;
|
|
3598
|
+
const pos = map.map[mapIndex];
|
|
3599
|
+
const attrs = table.nodeAt(pos).attrs;
|
|
3600
|
+
const index = attrs.colspan == 1 ? 0 : col - map.colCount(pos);
|
|
3601
|
+
if (attrs.colwidth && attrs.colwidth[index] == width) continue;
|
|
3602
|
+
const colwidth = attrs.colwidth ? attrs.colwidth.slice() : zeroes(attrs.colspan);
|
|
3603
|
+
colwidth[index] = width;
|
|
3604
|
+
tr.setNodeMarkup(start + pos, null, {
|
|
3605
|
+
...attrs,
|
|
3606
|
+
colwidth
|
|
3607
|
+
});
|
|
3608
|
+
}
|
|
3609
|
+
if (tr.docChanged) view.dispatch(tr);
|
|
3610
|
+
}
|
|
3611
|
+
function displayColumnWidth(view, cell, width, defaultCellMinWidth) {
|
|
3612
|
+
const $cell = view.state.doc.resolve(cell);
|
|
3613
|
+
const table = $cell.node(-1), start = $cell.start(-1);
|
|
3614
|
+
const col = TableMap.get(table).colCount($cell.pos - start) + $cell.nodeAfter.attrs.colspan - 1;
|
|
3615
|
+
let dom = view.domAtPos($cell.start(-1)).node;
|
|
3616
|
+
while (dom && dom.nodeName != "TABLE") dom = dom.parentNode;
|
|
3617
|
+
if (!dom) return;
|
|
3618
|
+
updateColumnsOnResize(table, dom.firstChild, dom, defaultCellMinWidth, col, width);
|
|
3619
|
+
}
|
|
3620
|
+
function zeroes(n) {
|
|
3621
|
+
return Array(n).fill(0);
|
|
3622
|
+
}
|
|
3623
|
+
function handleDecorations(state, cell) {
|
|
3624
|
+
const decorations = [];
|
|
3625
|
+
const $cell = state.doc.resolve(cell);
|
|
3626
|
+
const table = $cell.node(-1);
|
|
3627
|
+
if (!table) return DecorationSet.empty;
|
|
3628
|
+
const map = TableMap.get(table);
|
|
3629
|
+
const start = $cell.start(-1);
|
|
3630
|
+
const col = map.colCount($cell.pos - start) + $cell.nodeAfter.attrs.colspan - 1;
|
|
3631
|
+
for (let row = 0; row < map.height; row++) {
|
|
3632
|
+
const index = col + row * map.width;
|
|
3633
|
+
if ((col == map.width - 1 || map.map[index] != map.map[index + 1]) && (row == 0 || map.map[index] != map.map[index - map.width])) {
|
|
3634
|
+
var _columnResizingPlugin;
|
|
3635
|
+
const cellPos = map.map[index];
|
|
3636
|
+
const pos = start + cellPos + table.nodeAt(cellPos).nodeSize - 1;
|
|
3637
|
+
const dom = document.createElement("div");
|
|
3638
|
+
dom.className = "column-resize-handle";
|
|
3639
|
+
if ((_columnResizingPlugin = columnResizingPluginKey.getState(state)) === null || _columnResizingPlugin === void 0 ? void 0 : _columnResizingPlugin.dragging) decorations.push(Decoration.node(start + cellPos, start + cellPos + table.nodeAt(cellPos).nodeSize, { class: "column-resize-dragging" }));
|
|
3640
|
+
decorations.push(Decoration.widget(pos, dom));
|
|
3641
|
+
}
|
|
3642
|
+
}
|
|
3643
|
+
return DecorationSet.create(state.doc, decorations);
|
|
3644
|
+
}
|
|
3645
|
+
function tableEditing({ allowTableNodeSelection = false } = {}) {
|
|
3646
|
+
return new Plugin({
|
|
3647
|
+
key: tableEditingKey,
|
|
3648
|
+
state: {
|
|
3649
|
+
init() {
|
|
3650
|
+
return null;
|
|
3651
|
+
},
|
|
3652
|
+
apply(tr, cur) {
|
|
3653
|
+
const set = tr.getMeta(tableEditingKey);
|
|
3654
|
+
if (set != null) return set == -1 ? null : set;
|
|
3655
|
+
if (cur == null || !tr.docChanged) return cur;
|
|
3656
|
+
const { deleted, pos } = tr.mapping.mapResult(cur);
|
|
3657
|
+
return deleted ? null : pos;
|
|
3658
|
+
}
|
|
3659
|
+
},
|
|
3660
|
+
props: {
|
|
3661
|
+
decorations: drawCellSelection,
|
|
3662
|
+
handleDOMEvents: { mousedown: handleMouseDown$1 },
|
|
3663
|
+
createSelectionBetween(view) {
|
|
3664
|
+
return tableEditingKey.getState(view.state) != null ? view.state.selection : null;
|
|
3665
|
+
},
|
|
3666
|
+
handleTripleClick,
|
|
3667
|
+
handleKeyDown,
|
|
3668
|
+
handlePaste
|
|
3669
|
+
},
|
|
3670
|
+
appendTransaction(_, oldState, state) {
|
|
3671
|
+
return normalizeSelection(state, fixTables(state, oldState), allowTableNodeSelection);
|
|
3672
|
+
}
|
|
3673
|
+
});
|
|
3674
|
+
}
|
|
3675
|
+
|
|
3676
|
+
export {
|
|
3677
|
+
offset2 as offset,
|
|
3678
|
+
autoPlacement2 as autoPlacement,
|
|
3679
|
+
shift2 as shift,
|
|
3680
|
+
flip2 as flip,
|
|
3681
|
+
size2 as size,
|
|
3682
|
+
hide2 as hide,
|
|
3683
|
+
arrow2 as arrow,
|
|
3684
|
+
inline2 as inline,
|
|
3685
|
+
computePosition2 as computePosition,
|
|
3686
|
+
FloatingMenuPlugin,
|
|
3687
|
+
index_default,
|
|
3688
|
+
CellSelection,
|
|
3689
|
+
fixTables,
|
|
3690
|
+
addColumnBefore,
|
|
3691
|
+
addColumnAfter,
|
|
3692
|
+
deleteColumn,
|
|
3693
|
+
addRowBefore,
|
|
3694
|
+
addRowAfter,
|
|
3695
|
+
deleteRow,
|
|
3696
|
+
mergeCells,
|
|
3697
|
+
splitCell,
|
|
3698
|
+
setCellAttr,
|
|
3699
|
+
toggleHeader,
|
|
3700
|
+
toggleHeaderCell,
|
|
3701
|
+
goToNextCell,
|
|
3702
|
+
deleteTable,
|
|
3703
|
+
columnResizing,
|
|
3704
|
+
tableEditing
|
|
3705
|
+
};
|