@comet/cms-admin 9.0.0-beta.3 → 9.0.0-beta.5
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/lib/blocks/PixelImageBlock.d.ts.map +1 -1
- package/lib/blocks/PixelImageBlock.fragment.d.ts +2 -0
- package/lib/blocks/PixelImageBlock.fragment.d.ts.map +1 -0
- package/lib/blocks/PixelImageBlock.fragment.generated.d.ts +20 -0
- package/lib/blocks/PixelImageBlock.fragment.generated.d.ts.map +1 -0
- package/lib/blocks/PixelImageBlock.fragment.generated.js +5 -0
- package/lib/blocks/PixelImageBlock.fragment.js +4 -0
- package/lib/blocks/PixelImageBlock.js +3 -2
- package/lib/blocks/__stories__/BlockInFinalForm.stories.js +53 -0
- package/lib/blocks/__stories__/RichTextBlock.stories.js +53 -0
- package/lib/blocks/createLinkBlock.d.ts.map +1 -1
- package/lib/blocks/createLinkBlock.js +50 -1
- package/lib/blocks/createRichTextBlock.d.ts.map +1 -1
- package/lib/blocks/createRichTextBlock.js +56 -20
- package/lib/blocks/createSeoBlock.d.ts.map +1 -1
- package/lib/blocks/createSeoBlock.js +6 -4
- package/lib/blocks/createTextLinkBlock.d.ts.map +1 -1
- package/lib/blocks/createTextLinkBlock.js +36 -1
- package/lib/blocks/factories/createBlocksBlock.d.ts.map +1 -1
- package/lib/blocks/factories/createBlocksBlock.js +70 -13
- package/lib/blocks/factories/createColumnsBlock.d.ts.map +1 -1
- package/lib/blocks/factories/createColumnsBlock.js +56 -6
- package/lib/blocks/factories/createListBlock.d.ts.map +1 -1
- package/lib/blocks/factories/createListBlock.js +56 -6
- package/lib/blocks/factories/createOneOfBlock.d.ts.map +1 -1
- package/lib/blocks/factories/createOneOfBlock.js +62 -5
- package/lib/blocks/factories/createOptionalBlock.d.ts.map +1 -1
- package/lib/blocks/factories/createOptionalBlock.js +38 -1
- package/lib/blocks/helpers/__stories__/createCompositeBlockSelectField.stories.js +106 -0
- package/lib/blocks/helpers/composeBlocks/composeBlocks.d.ts.map +1 -1
- package/lib/blocks/helpers/composeBlocks/composeBlocks.js +52 -16
- package/lib/blocks/helpers/composeBlocks/createCompositeBlockField.d.ts +2 -1
- package/lib/blocks/helpers/composeBlocks/createCompositeBlockField.d.ts.map +1 -1
- package/lib/blocks/helpers/composeBlocks/createCompositeBlockField.js +4 -2
- package/lib/blocks/helpers/composeBlocks/createSettingsBlock.d.ts +2 -1
- package/lib/blocks/helpers/composeBlocks/createSettingsBlock.d.ts.map +1 -1
- package/lib/blocks/helpers/composeBlocks/createSettingsBlock.js +5 -1
- package/lib/blocks/helpers/createBlockSkeleton.js +15 -1
- package/lib/blocks/helpers/createCompositeBlockTextField.d.ts +2 -1
- package/lib/blocks/helpers/createCompositeBlockTextField.d.ts.map +1 -1
- package/lib/blocks/helpers/createCompositeBlockTextField.js +20 -2
- package/lib/blocks/table/TableBlockGrid.d.ts.map +1 -1
- package/lib/blocks/table/TableBlockGrid.js +3 -1
- package/lib/blocks/table/utils/column.d.ts +16 -21
- package/lib/blocks/table/utils/column.d.ts.map +1 -1
- package/lib/blocks/table/utils/column.js +0 -11
- package/lib/blocks/table/utils/getClipboardValueForSchema.d.ts +1 -1
- package/lib/blocks/table/utils/getClipboardValueForSchema.d.ts.map +1 -1
- package/lib/blocks/table/utils/row.d.ts +3 -18
- package/lib/blocks/table/utils/row.d.ts.map +1 -1
- package/lib/blocks/table/utils/row.js +1 -1
- package/lib/blocks/table/utils/rteSchema.d.ts +1 -5
- package/lib/blocks/table/utils/rteSchema.d.ts.map +1 -1
- package/lib/blocks/tipTap/BlockStyleContext.d.ts +3 -0
- package/lib/blocks/tipTap/BlockStyleContext.d.ts.map +1 -0
- package/lib/blocks/tipTap/BlockStyleContext.js +2 -0
- package/lib/blocks/tipTap/InlineStyleContext.d.ts +3 -0
- package/lib/blocks/tipTap/InlineStyleContext.d.ts.map +1 -0
- package/lib/blocks/tipTap/InlineStyleContext.js +2 -0
- package/lib/blocks/tipTap/TipTapLinkDialog.d.ts +10 -0
- package/lib/blocks/tipTap/TipTapLinkDialog.d.ts.map +1 -0
- package/lib/blocks/tipTap/TipTapLinkDialog.js +105 -0
- package/lib/blocks/tipTap/TipTapToolbar.d.ts +13 -0
- package/lib/blocks/tipTap/TipTapToolbar.d.ts.map +1 -0
- package/lib/blocks/tipTap/TipTapToolbar.js +666 -0
- package/lib/blocks/tipTap/__stories__/TipTapRichTextBlock.stories.js +1841 -0
- package/lib/blocks/tipTap/createTipTapRichTextBlock.d.ts +61 -0
- package/lib/blocks/tipTap/createTipTapRichTextBlock.d.ts.map +1 -0
- package/lib/blocks/tipTap/createTipTapRichTextBlock.js +424 -0
- package/lib/blocks/tipTap/extensions/BlockStyleHeading.d.ts +2 -0
- package/lib/blocks/tipTap/extensions/BlockStyleHeading.d.ts.map +1 -0
- package/lib/blocks/tipTap/extensions/BlockStyleHeading.js +57 -0
- package/lib/blocks/tipTap/extensions/BlockStyleParagraph.d.ts +2 -0
- package/lib/blocks/tipTap/extensions/BlockStyleParagraph.d.ts.map +1 -0
- package/lib/blocks/tipTap/extensions/BlockStyleParagraph.js +56 -0
- package/lib/blocks/tipTap/extensions/CmsLink.d.ts +13 -0
- package/lib/blocks/tipTap/extensions/CmsLink.d.ts.map +1 -0
- package/lib/blocks/tipTap/extensions/CmsLink.js +42 -0
- package/lib/blocks/tipTap/extensions/InlineStyleMark.d.ts +13 -0
- package/lib/blocks/tipTap/extensions/InlineStyleMark.d.ts.map +1 -0
- package/lib/blocks/tipTap/extensions/InlineStyleMark.js +71 -0
- package/lib/blocks/tipTap/extensions/NonBreakingSpace.d.ts +10 -0
- package/lib/blocks/tipTap/extensions/NonBreakingSpace.d.ts.map +1 -0
- package/lib/blocks/tipTap/extensions/NonBreakingSpace.js +57 -0
- package/lib/blocks/tipTap/extensions/Placeholder.d.ts +10 -0
- package/lib/blocks/tipTap/extensions/Placeholder.d.ts.map +1 -0
- package/lib/blocks/tipTap/extensions/Placeholder.js +78 -0
- package/lib/blocks/tipTap/extensions/SoftHyphen.d.ts +10 -0
- package/lib/blocks/tipTap/extensions/SoftHyphen.d.ts.map +1 -0
- package/lib/blocks/tipTap/extensions/SoftHyphen.js +51 -0
- package/lib/blocks/tipTap/listLevelMaxHelpers.d.ts +6 -0
- package/lib/blocks/tipTap/listLevelMaxHelpers.d.ts.map +1 -0
- package/lib/blocks/tipTap/listLevelMaxHelpers.js +108 -0
- package/lib/blocks/types.d.ts +7 -0
- package/lib/blocks/types.d.ts.map +1 -1
- package/lib/builds/PublisherPage.js +2 -2
- package/lib/builds/StartBuildsDialog.d.ts.map +1 -1
- package/lib/builds/StartBuildsDialog.js +1 -1
- package/lib/common/__stories__/MasterMenuInMasterLayout.stories.js +87 -0
- package/lib/config/CometConfigContext.d.ts +8 -1
- package/lib/config/CometConfigContext.d.ts.map +1 -1
- package/lib/config/CometConfigContext.js +9 -5
- package/lib/contentScope/__stories__/ContentScopeProvider.stories.js +85 -0
- package/lib/contentScope/__stories__/ContentScopeSelect.stories.js +655 -0
- package/lib/contentScope/noContentScopeFallback/__stories__/NoContentScopeFallback.stories.js +7 -0
- package/lib/cronJobs/CronJobsGrid.js +1 -1
- package/lib/cronJobs/JobsGrid.js +1 -1
- package/lib/dam/DamTable.d.ts +5 -1
- package/lib/dam/DamTable.d.ts.map +1 -1
- package/lib/dam/DamTable.js +5 -1
- package/lib/dam/DataGrid/FolderDataGrid.d.ts +1 -1
- package/lib/dam/DataGrid/FolderDataGrid.d.ts.map +1 -1
- package/lib/dam/DataGrid/FolderDataGrid.js +58 -47
- package/lib/dam/DataGrid/selection/DamSelectionContext.d.ts +7 -4
- package/lib/dam/DataGrid/selection/DamSelectionContext.d.ts.map +1 -1
- package/lib/dam/DataGrid/selection/DamSelectionContext.js +11 -3
- package/lib/dam/FileForm/EditFile.d.ts.map +1 -1
- package/lib/dam/FileForm/EditFile.js +5 -2
- package/lib/dam/mediaAlternatives/MediaAlternativesGrid.d.ts.map +1 -1
- package/lib/dam/mediaAlternatives/MediaAlternativesGrid.js +1 -1
- package/lib/dashboard/widgets/LatestBuildsDashboardWidget.js +1 -1
- package/lib/dashboard/widgets/LatestContentUpdatesDashboardWidget.d.ts +1 -1
- package/lib/dashboard/widgets/LatestContentUpdatesDashboardWidget.d.ts.map +1 -1
- package/lib/dashboard/widgets/LatestContentUpdatesDashboardWidget.js +1 -1
- package/lib/dashboard/widgets/__stories__/DashboardWidgetRoot.stories.js +82 -0
- package/lib/dataGrid/DataGrid.d.ts +3 -0
- package/lib/dataGrid/DataGrid.d.ts.map +1 -0
- package/lib/dataGrid/DataGrid.js +19 -0
- package/lib/dependencies/DependenciesList.d.ts.map +1 -1
- package/lib/dependencies/DependenciesList.js +1 -1
- package/lib/dependencies/DependentsList.d.ts.map +1 -1
- package/lib/dependencies/DependentsList.js +1 -1
- package/lib/form/file/FileField.d.ts +15 -12
- package/lib/form/file/FileField.d.ts.map +1 -1
- package/lib/form/file/FileField.gql.d.ts +2 -0
- package/lib/form/file/FileField.gql.d.ts.map +1 -1
- package/lib/form/file/FileField.gql.generated.d.ts +40 -0
- package/lib/form/file/FileField.gql.generated.d.ts.map +1 -1
- package/lib/form/file/FileField.gql.generated.js +2 -1
- package/lib/form/file/FileField.gql.js +6 -3
- package/lib/form/file/FileField.js +170 -86
- package/lib/form/file/FileFieldMenu.d.ts +17 -0
- package/lib/form/file/FileFieldMenu.d.ts.map +1 -0
- package/lib/form/file/FileFieldMenu.js +91 -0
- package/lib/form/file/FileFieldRow.d.ts +12 -0
- package/lib/form/file/FileFieldRow.d.ts.map +1 -0
- package/lib/form/file/FileFieldRow.js +96 -0
- package/lib/form/file/__stories__/FileUploadField.stories.js +351 -0
- package/lib/form/file/chooseFile/BaseChooseDamFileDialog.d.ts +20 -0
- package/lib/form/file/chooseFile/BaseChooseDamFileDialog.d.ts.map +1 -0
- package/lib/form/file/chooseFile/BaseChooseDamFileDialog.js +106 -0
- package/lib/form/file/chooseFile/ChooseDamFileDialog.d.ts.map +1 -1
- package/lib/form/file/chooseFile/ChooseDamFileDialog.js +34 -89
- package/lib/form/file/chooseFile/ChooseDamFilesDialog.d.ts +9 -0
- package/lib/form/file/chooseFile/ChooseDamFilesDialog.d.ts.map +1 -0
- package/lib/form/file/chooseFile/ChooseDamFilesDialog.js +117 -0
- package/lib/graphql.generated.d.ts +19 -1
- package/lib/graphql.generated.d.ts.map +1 -1
- package/lib/index.d.ts +10 -1
- package/lib/index.d.ts.map +1 -1
- package/lib/index.js +7 -0
- package/lib/pages/createEditPageNode.d.ts.map +1 -1
- package/lib/pages/createEditPageNode.js +1 -12
- package/lib/pages/createUsePage.d.ts +1 -0
- package/lib/pages/createUsePage.d.ts.map +1 -1
- package/lib/pages/createUsePage.js +135 -6
- package/lib/pages/pageTree/PageActions.d.ts.map +1 -1
- package/lib/pages/pageTree/PageActions.js +21 -3
- package/lib/pages/pageTree/findAvailableSlug.d.ts +11 -0
- package/lib/pages/pageTree/findAvailableSlug.d.ts.map +1 -0
- package/lib/pages/pageTree/findAvailableSlug.generated.d.ts +16 -0
- package/lib/pages/pageTree/findAvailableSlug.generated.d.ts.map +1 -0
- package/lib/pages/pageTree/findAvailableSlug.generated.js +5 -0
- package/lib/pages/pageTree/findAvailableSlug.js +62 -0
- package/lib/pages/pageTree/transformToSlug.d.ts +2 -0
- package/lib/pages/pageTree/transformToSlug.d.ts.map +1 -0
- package/lib/pages/pageTree/transformToSlug.js +12 -0
- package/lib/pages/pageTree/useCopyPastePages/sendPages.d.ts.map +1 -1
- package/lib/pages/pageTree/useCopyPastePages/sendPages.generated.d.ts +0 -10
- package/lib/pages/pageTree/useCopyPastePages/sendPages.generated.d.ts.map +1 -1
- package/lib/pages/pageTree/useCopyPastePages/sendPages.generated.js +0 -1
- package/lib/pages/pageTree/useCopyPastePages/sendPages.js +19 -40
- package/lib/pages/pageTree/useCopyPastePages.d.ts.map +1 -1
- package/lib/pages/pageTree/useCopyPastePages.js +1 -1
- package/lib/pages/pageTree/{useCopyPastePages/ProgressDialog.d.ts → useProgressDialog.d.ts} +1 -1
- package/lib/pages/pageTree/useProgressDialog.d.ts.map +1 -0
- package/lib/pages/pageTree/useTranslatePagesAction.d.ts +16 -0
- package/lib/pages/pageTree/useTranslatePagesAction.d.ts.map +1 -0
- package/lib/pages/pageTree/useTranslatePagesAction.generated.d.ts +20 -0
- package/lib/pages/pageTree/useTranslatePagesAction.generated.d.ts.map +1 -0
- package/lib/pages/pageTree/useTranslatePagesAction.generated.js +5 -0
- package/lib/pages/pageTree/useTranslatePagesAction.js +339 -0
- package/lib/pages/pagesPage/PagesPageActionToolbar.d.ts.map +1 -1
- package/lib/pages/pagesPage/PagesPageActionToolbar.js +29 -2
- package/lib/pages/pagesPage/PagesPageActionToolbar.sc.d.ts +2 -2
- package/lib/redirects/RedirectsGrid.d.ts +1 -1
- package/lib/redirects/RedirectsGrid.d.ts.map +1 -1
- package/lib/redirects/RedirectsGrid.gql.d.ts +1 -0
- package/lib/redirects/RedirectsGrid.gql.d.ts.map +1 -1
- package/lib/redirects/RedirectsGrid.gql.generated.d.ts +8 -0
- package/lib/redirects/RedirectsGrid.gql.generated.d.ts.map +1 -1
- package/lib/redirects/RedirectsGrid.gql.generated.js +2 -1
- package/lib/redirects/RedirectsGrid.gql.js +3 -2
- package/lib/redirects/RedirectsGrid.js +107 -15
- package/lib/translation/AzureAiTranslatorProvider.d.ts +1 -1
- package/lib/translation/AzureAiTranslatorProvider.d.ts.map +1 -1
- package/lib/translation/AzureAiTranslatorProvider.generated.d.ts +8 -0
- package/lib/translation/AzureAiTranslatorProvider.generated.d.ts.map +1 -1
- package/lib/translation/AzureAiTranslatorProvider.generated.js +2 -1
- package/lib/translation/AzureAiTranslatorProvider.js +31 -2
- package/lib/translation/TranslatableInterface.d.ts +4 -0
- package/lib/translation/TranslatableInterface.d.ts.map +1 -0
- package/lib/translation/TranslatableInterface.js +1 -0
- package/lib/translation/TranslateContentMenuItem.d.ts +7 -0
- package/lib/translation/TranslateContentMenuItem.d.ts.map +1 -0
- package/lib/translation/TranslateContentMenuItem.js +99 -0
- package/lib/translation/createDocumentTranslationMethods.d.ts +4 -0
- package/lib/translation/createDocumentTranslationMethods.d.ts.map +1 -0
- package/lib/translation/createDocumentTranslationMethods.js +62 -0
- package/lib/userPermissions/UserGrid.d.ts +1 -1
- package/lib/userPermissions/UserGrid.d.ts.map +1 -1
- package/lib/userPermissions/UserGrid.js +2 -2
- package/lib/userPermissions/user/permissions/ContentScopeGrid.d.ts.map +1 -1
- package/lib/userPermissions/user/permissions/ContentScopeGrid.js +1 -1
- package/lib/userPermissions/user/permissions/OverrideContentScopesDialog.js +1 -1
- package/lib/userPermissions/user/permissions/PermissionGrid.d.ts.map +1 -1
- package/lib/userPermissions/user/permissions/PermissionGrid.js +1 -1
- package/lib/userPermissions/user/permissions/selectScopesDialogContent/SelectScopesDialogContent.d.ts.map +1 -1
- package/lib/userPermissions/user/permissions/selectScopesDialogContent/SelectScopesDialogContent.js +1 -1
- package/lib/validation/validateJson.d.ts +2 -0
- package/lib/validation/validateJson.d.ts.map +1 -0
- package/lib/validation/validateJson.js +15 -0
- package/lib/warnings/LatestWarningsDashboardWidget.js +1 -1
- package/lib/warnings/WarningsGrid.d.ts.map +1 -1
- package/lib/warnings/WarningsGrid.js +1 -1
- package/package.json +36 -26
- package/lib/dashboard/__stories__/DateTime.stories.d.ts +0 -7
- package/lib/dashboard/__stories__/DateTime.stories.d.ts.map +0 -1
- package/lib/pages/pageTree/useCopyPastePages/ProgressDialog.d.ts.map +0 -1
- /package/lib/pages/pageTree/{useCopyPastePages/ProgressDialog.js → useProgressDialog.js} +0 -0
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
import { type JSONContent } from "@tiptap/react";
|
|
2
|
+
import type { ComponentType, HTMLAttributes, ReactNode } from "react";
|
|
3
|
+
import { type BlockInterface, type LinkBlockInterface } from "../types";
|
|
4
|
+
export type TipTapSupports = "history" | "bold" | "italic" | "strike" | "sub" | "sup" | "heading" | "ordered-list" | "unordered-list" | "non-breaking-space" | "soft-hyphen" | "link";
|
|
5
|
+
export type TipTapBlockType = "paragraph" | "heading-1" | "heading-2" | "heading-3" | "heading-4" | "heading-5" | "heading-6" | "ordered-list" | "unordered-list";
|
|
6
|
+
export interface TipTapBlockStyle {
|
|
7
|
+
name: string;
|
|
8
|
+
label: ReactNode;
|
|
9
|
+
/**
|
|
10
|
+
* Limits the block style to the provided block types.
|
|
11
|
+
* If none is specified, the block style is allowed for all block types.
|
|
12
|
+
*/
|
|
13
|
+
appliesTo?: TipTapBlockType[];
|
|
14
|
+
element: ComponentType<HTMLAttributes<HTMLElement>>;
|
|
15
|
+
}
|
|
16
|
+
export interface TipTapInlineStyle {
|
|
17
|
+
name: string;
|
|
18
|
+
label: ReactNode;
|
|
19
|
+
/**
|
|
20
|
+
* Limits the inline style to the provided block types.
|
|
21
|
+
* If none is specified, the inline style is allowed for all block types.
|
|
22
|
+
*/
|
|
23
|
+
appliesTo?: TipTapBlockType[];
|
|
24
|
+
element: ComponentType<HTMLAttributes<HTMLElement>>;
|
|
25
|
+
}
|
|
26
|
+
export interface TipTapRichTextBlockState {
|
|
27
|
+
tipTapContent: JSONContent;
|
|
28
|
+
}
|
|
29
|
+
interface TipTapRichTextBlockData {
|
|
30
|
+
tipTapContent: JSONContent;
|
|
31
|
+
}
|
|
32
|
+
interface TipTapRichTextBlockInput {
|
|
33
|
+
tipTapContent: JSONContent;
|
|
34
|
+
}
|
|
35
|
+
export interface TipTapPlaceholder {
|
|
36
|
+
name: string;
|
|
37
|
+
label: ReactNode;
|
|
38
|
+
}
|
|
39
|
+
interface TipTapRichTextBlockFactoryOptions {
|
|
40
|
+
supports?: TipTapSupports[];
|
|
41
|
+
blockStyles?: TipTapBlockStyle[];
|
|
42
|
+
inlineStyles?: TipTapInlineStyle[];
|
|
43
|
+
placeholders?: TipTapPlaceholder[];
|
|
44
|
+
link?: BlockInterface & LinkBlockInterface;
|
|
45
|
+
/**
|
|
46
|
+
* Limits the maximum number of top-level blocks (paragraphs, headings, lists)
|
|
47
|
+
* that can be created in the editor.
|
|
48
|
+
*/
|
|
49
|
+
maxBlocks?: number;
|
|
50
|
+
/**
|
|
51
|
+
* Limits the maximum nesting depth of list items.
|
|
52
|
+
* A value of 1 means only a flat list (no nesting), 2 allows one level of sub-lists, etc.
|
|
53
|
+
*/
|
|
54
|
+
listLevelMax?: number;
|
|
55
|
+
}
|
|
56
|
+
/**
|
|
57
|
+
* @experimental
|
|
58
|
+
*/
|
|
59
|
+
export declare const createTipTapRichTextBlock: (options?: TipTapRichTextBlockFactoryOptions) => BlockInterface<TipTapRichTextBlockData, TipTapRichTextBlockState, TipTapRichTextBlockInput>;
|
|
60
|
+
export {};
|
|
61
|
+
//# sourceMappingURL=createTipTapRichTextBlock.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"createTipTapRichTextBlock.d.ts","sourceRoot":"","sources":["../../../src/blocks/tipTap/createTipTapRichTextBlock.tsx"],"names":[],"mappings":"AAKA,OAAO,EAAiB,KAAK,WAAW,EAAa,MAAM,eAAe,CAAC;AAE3E,OAAO,KAAK,EAAE,aAAa,EAAE,cAAc,EAAE,SAAS,EAAE,MAAM,OAAO,CAAC;AAItE,OAAO,EAAiB,KAAK,cAAc,EAAE,KAAK,kBAAkB,EAAE,MAAM,UAAU,CAAC;AAavF,MAAM,MAAM,cAAc,GACpB,SAAS,GACT,MAAM,GACN,QAAQ,GACR,QAAQ,GACR,KAAK,GACL,KAAK,GACL,SAAS,GACT,cAAc,GACd,gBAAgB,GAChB,oBAAoB,GACpB,aAAa,GACb,MAAM,CAAC;AAgBb,MAAM,MAAM,eAAe,GACrB,WAAW,GACX,WAAW,GACX,WAAW,GACX,WAAW,GACX,WAAW,GACX,WAAW,GACX,WAAW,GACX,cAAc,GACd,gBAAgB,CAAC;AAEvB,MAAM,WAAW,gBAAgB;IAC7B,IAAI,EAAE,MAAM,CAAC;IACb,KAAK,EAAE,SAAS,CAAC;IACjB;;;OAGG;IACH,SAAS,CAAC,EAAE,eAAe,EAAE,CAAC;IAC9B,OAAO,EAAE,aAAa,CAAC,cAAc,CAAC,WAAW,CAAC,CAAC,CAAC;CACvD;AAED,MAAM,WAAW,iBAAiB;IAC9B,IAAI,EAAE,MAAM,CAAC;IACb,KAAK,EAAE,SAAS,CAAC;IACjB;;;OAGG;IACH,SAAS,CAAC,EAAE,eAAe,EAAE,CAAC;IAC9B,OAAO,EAAE,aAAa,CAAC,cAAc,CAAC,WAAW,CAAC,CAAC,CAAC;CACvD;AAED,MAAM,WAAW,wBAAwB;IACrC,aAAa,EAAE,WAAW,CAAC;CAC9B;AAED,UAAU,uBAAuB;IAC7B,aAAa,EAAE,WAAW,CAAC;CAC9B;AAED,UAAU,wBAAwB;IAC9B,aAAa,EAAE,WAAW,CAAC;CAC9B;AAED,MAAM,WAAW,iBAAiB;IAC9B,IAAI,EAAE,MAAM,CAAC;IACb,KAAK,EAAE,SAAS,CAAC;CACpB;AAED,UAAU,iCAAiC;IACvC,QAAQ,CAAC,EAAE,cAAc,EAAE,CAAC;IAC5B,WAAW,CAAC,EAAE,gBAAgB,EAAE,CAAC;IACjC,YAAY,CAAC,EAAE,iBAAiB,EAAE,CAAC;IACnC,YAAY,CAAC,EAAE,iBAAiB,EAAE,CAAC;IACnC,IAAI,CAAC,EAAE,cAAc,GAAG,kBAAkB,CAAC;IAC3C;;;OAGG;IACH,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB;;;OAGG;IACH,YAAY,CAAC,EAAE,MAAM,CAAC;CACzB;AAuMD;;GAEG;AACH,eAAO,MAAM,yBAAyB,GAClC,UAAU,iCAAiC,KAC5C,cAAc,CAAC,uBAAuB,EAAE,wBAAwB,EAAE,wBAAwB,CAyF5F,CAAC"}
|
|
@@ -0,0 +1,424 @@
|
|
|
1
|
+
function _regenerator() { /*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/babel/babel/blob/main/packages/babel-helpers/LICENSE */ var e, t, r = "function" == typeof Symbol ? Symbol : {}, n = r.iterator || "@@iterator", o = r.toStringTag || "@@toStringTag"; function i(r, n, o, i) { var c = n && n.prototype instanceof Generator ? n : Generator, u = Object.create(c.prototype); return _regeneratorDefine2(u, "_invoke", function (r, n, o) { var i, c, u, f = 0, p = o || [], y = !1, G = { p: 0, n: 0, v: e, a: d, f: d.bind(e, 4), d: function d(t, r) { return i = t, c = 0, u = e, G.n = r, a; } }; function d(r, n) { for (c = r, u = n, t = 0; !y && f && !o && t < p.length; t++) { var o, i = p[t], d = G.p, l = i[2]; r > 3 ? (o = l === n) && (u = i[(c = i[4]) ? 5 : (c = 3, 3)], i[4] = i[5] = e) : i[0] <= d && ((o = r < 2 && d < i[1]) ? (c = 0, G.v = n, G.n = i[1]) : d < l && (o = r < 3 || i[0] > n || n > l) && (i[4] = r, i[5] = n, G.n = l, c = 0)); } if (o || r > 1) return a; throw y = !0, n; } return function (o, p, l) { if (f > 1) throw TypeError("Generator is already running"); for (y && 1 === p && d(p, l), c = p, u = l; (t = c < 2 ? e : u) || !y;) { i || (c ? c < 3 ? (c > 1 && (G.n = -1), d(c, u)) : G.n = u : G.v = u); try { if (f = 2, i) { if (c || (o = "next"), t = i[o]) { if (!(t = t.call(i, u))) throw TypeError("iterator result is not an object"); if (!t.done) return t; u = t.value, c < 2 && (c = 0); } else 1 === c && (t = i["return"]) && t.call(i), c < 2 && (u = TypeError("The iterator does not provide a '" + o + "' method"), c = 1); i = e; } else if ((t = (y = G.n < 0) ? u : r.call(n, G)) !== a) break; } catch (t) { i = e, c = 1, u = t; } finally { f = 1; } } return { value: t, done: y }; }; }(r, o, i), !0), u; } var a = {}; function Generator() {} function GeneratorFunction() {} function GeneratorFunctionPrototype() {} t = Object.getPrototypeOf; var c = [][n] ? t(t([][n]())) : (_regeneratorDefine2(t = {}, n, function () { return this; }), t), u = GeneratorFunctionPrototype.prototype = Generator.prototype = Object.create(c); function f(e) { return Object.setPrototypeOf ? Object.setPrototypeOf(e, GeneratorFunctionPrototype) : (e.__proto__ = GeneratorFunctionPrototype, _regeneratorDefine2(e, o, "GeneratorFunction")), e.prototype = Object.create(u), e; } return GeneratorFunction.prototype = GeneratorFunctionPrototype, _regeneratorDefine2(u, "constructor", GeneratorFunctionPrototype), _regeneratorDefine2(GeneratorFunctionPrototype, "constructor", GeneratorFunction), GeneratorFunction.displayName = "GeneratorFunction", _regeneratorDefine2(GeneratorFunctionPrototype, o, "GeneratorFunction"), _regeneratorDefine2(u), _regeneratorDefine2(u, o, "Generator"), _regeneratorDefine2(u, n, function () { return this; }), _regeneratorDefine2(u, "toString", function () { return "[object Generator]"; }), (_regenerator = function _regenerator() { return { w: i, m: f }; })(); }
|
|
2
|
+
function _regeneratorDefine2(e, r, n, t) { var i = Object.defineProperty; try { i({}, "", {}); } catch (e) { i = 0; } _regeneratorDefine2 = function _regeneratorDefine(e, r, n, t) { function o(r, n) { _regeneratorDefine2(e, r, function (e) { return this._invoke(r, n, e); }); } r ? i ? i(e, r, { value: n, enumerable: !t, configurable: !t, writable: !t }) : e[r] = n : (o("next", 0), o("throw", 1), o("return", 2)); }, _regeneratorDefine2(e, r, n, t); }
|
|
3
|
+
function _toConsumableArray(r) { return _arrayWithoutHoles(r) || _iterableToArray(r) || _unsupportedIterableToArray(r) || _nonIterableSpread(); }
|
|
4
|
+
function _nonIterableSpread() { throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
|
|
5
|
+
function _iterableToArray(r) { if ("undefined" != typeof Symbol && null != r[Symbol.iterator] || null != r["@@iterator"]) return Array.from(r); }
|
|
6
|
+
function _arrayWithoutHoles(r) { if (Array.isArray(r)) return _arrayLikeToArray(r); }
|
|
7
|
+
function asyncGeneratorStep(n, t, e, r, o, a, c) { try { var i = n[a](c), u = i.value; } catch (n) { return void e(n); } i.done ? t(u) : Promise.resolve(u).then(r, o); }
|
|
8
|
+
function _asyncToGenerator(n) { return function () { var t = this, e = arguments; return new Promise(function (r, o) { var a = n.apply(t, e); function _next(n) { asyncGeneratorStep(a, r, o, _next, _throw, "next", n); } function _throw(n) { asyncGeneratorStep(a, r, o, _next, _throw, "throw", n); } _next(void 0); }); }; }
|
|
9
|
+
function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
|
|
10
|
+
function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
|
|
11
|
+
function _defineProperty(e, r, t) { return (r = _toPropertyKey(r)) in e ? Object.defineProperty(e, r, { value: t, enumerable: !0, configurable: !0, writable: !0 }) : e[r] = t, e; }
|
|
12
|
+
function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : i + ""; }
|
|
13
|
+
function _toPrimitive(t, r) { if ("object" != _typeof(t) || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != _typeof(i)) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
|
|
14
|
+
function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); }
|
|
15
|
+
function _createForOfIteratorHelper(r, e) { var t = "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"]; if (!t) { if (Array.isArray(r) || (t = _unsupportedIterableToArray(r)) || e && r && "number" == typeof r.length) { t && (r = t); var _n = 0, F = function F() {}; return { s: F, n: function n() { return _n >= r.length ? { done: !0 } : { done: !1, value: r[_n++] }; }, e: function e(r) { throw r; }, f: F }; } throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } var o, a = !0, u = !1; return { s: function s() { t = t.call(r); }, n: function n() { var r = t.next(); return a = r.done, r; }, e: function e(r) { u = !0, o = r; }, f: function f() { try { a || null == t["return"] || t["return"](); } finally { if (u) throw o; } } }; }
|
|
16
|
+
function _unsupportedIterableToArray(r, a) { if (r) { if ("string" == typeof r) return _arrayLikeToArray(r, a); var t = {}.toString.call(r).slice(8, -1); return "Object" === t && r.constructor && (t = r.constructor.name), "Map" === t || "Set" === t ? Array.from(r) : "Arguments" === t || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t) ? _arrayLikeToArray(r, a) : void 0; } }
|
|
17
|
+
function _arrayLikeToArray(r, a) { (null == a || a > r.length) && (a = r.length); for (var e = 0, n = Array(a); e < a; e++) n[e] = r[e]; return n; }
|
|
18
|
+
import { greyPalette } from "@comet/admin";
|
|
19
|
+
import { Box } from "@mui/material";
|
|
20
|
+
import { Extension } from "@tiptap/core";
|
|
21
|
+
import Subscript from "@tiptap/extension-subscript";
|
|
22
|
+
import Superscript from "@tiptap/extension-superscript";
|
|
23
|
+
import { EditorContent, useEditor } from "@tiptap/react";
|
|
24
|
+
import StarterKit from "@tiptap/starter-kit";
|
|
25
|
+
import { FormattedMessage } from "react-intl";
|
|
26
|
+
import { createBlockSkeleton } from "../helpers/createBlockSkeleton";
|
|
27
|
+
import { BlockCategory } from "../types";
|
|
28
|
+
import { BlockStyleContext } from "./BlockStyleContext";
|
|
29
|
+
import { BlockStyleHeading } from "./extensions/BlockStyleHeading";
|
|
30
|
+
import { BlockStyleParagraph } from "./extensions/BlockStyleParagraph";
|
|
31
|
+
import { CmsLink } from "./extensions/CmsLink";
|
|
32
|
+
import { InlineStyleMark } from "./extensions/InlineStyleMark";
|
|
33
|
+
import { NonBreakingSpace } from "./extensions/NonBreakingSpace";
|
|
34
|
+
import { Placeholder } from "./extensions/Placeholder";
|
|
35
|
+
import { SoftHyphen } from "./extensions/SoftHyphen";
|
|
36
|
+
import { InlineStyleContext } from "./InlineStyleContext";
|
|
37
|
+
import { createListLevelMaxExtension, getListNestingDepthFromJson, trimListNesting } from "./listLevelMaxHelpers";
|
|
38
|
+
import { TipTapToolbar } from "./TipTapToolbar";
|
|
39
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
40
|
+
var defaultSupports = ["history", "heading", "bold", "italic", "strike", "sub", "sup", "ordered-list", "unordered-list", "non-breaking-space", "soft-hyphen"];
|
|
41
|
+
function getPlainTextFromContent(content) {
|
|
42
|
+
var text = "";
|
|
43
|
+
if (content.text) {
|
|
44
|
+
text += content.text;
|
|
45
|
+
}
|
|
46
|
+
if (content.content) {
|
|
47
|
+
var _iterator = _createForOfIteratorHelper(content.content),
|
|
48
|
+
_step;
|
|
49
|
+
try {
|
|
50
|
+
for (_iterator.s(); !(_step = _iterator.n()).done;) {
|
|
51
|
+
var child = _step.value;
|
|
52
|
+
text += getPlainTextFromContent(child);
|
|
53
|
+
}
|
|
54
|
+
} catch (err) {
|
|
55
|
+
_iterator.e(err);
|
|
56
|
+
} finally {
|
|
57
|
+
_iterator.f();
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
return text;
|
|
61
|
+
}
|
|
62
|
+
var emptyContent = {
|
|
63
|
+
type: "doc",
|
|
64
|
+
content: [{
|
|
65
|
+
type: "paragraph"
|
|
66
|
+
}]
|
|
67
|
+
};
|
|
68
|
+
var createMaxBlocksExtension = function createMaxBlocksExtension(maxBlocks) {
|
|
69
|
+
return Extension.create({
|
|
70
|
+
name: "maxBlocks",
|
|
71
|
+
addKeyboardShortcuts: function addKeyboardShortcuts() {
|
|
72
|
+
return {
|
|
73
|
+
Enter: function Enter(_ref) {
|
|
74
|
+
var editor = _ref.editor;
|
|
75
|
+
if (editor.state.doc.childCount >= maxBlocks) {
|
|
76
|
+
// Only block Enter when it would create a new block (not inside a list, etc.)
|
|
77
|
+
var $from = editor.state.selection.$from;
|
|
78
|
+
var isAtEndOfBlock = $from.parentOffset === $from.parent.content.size;
|
|
79
|
+
var parentDepth = $from.depth;
|
|
80
|
+
// If at end of a top-level block (depth 1) or would split a top-level block
|
|
81
|
+
if (parentDepth === 1 && isAtEndOfBlock) {
|
|
82
|
+
return true; // prevent
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
return false;
|
|
86
|
+
}
|
|
87
|
+
};
|
|
88
|
+
}
|
|
89
|
+
});
|
|
90
|
+
};
|
|
91
|
+
|
|
92
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
93
|
+
function mapLinkMarksData(content, fn) {
|
|
94
|
+
if (!content || _typeof(content) !== "object") {
|
|
95
|
+
return content;
|
|
96
|
+
}
|
|
97
|
+
var result = _objectSpread({}, content);
|
|
98
|
+
if (Array.isArray(result.marks)) {
|
|
99
|
+
result.marks = result.marks.map(function (mark) {
|
|
100
|
+
var _mark$attrs;
|
|
101
|
+
if (mark.type === "link" && (_mark$attrs = mark.attrs) !== null && _mark$attrs !== void 0 && _mark$attrs.data) {
|
|
102
|
+
return _objectSpread(_objectSpread({}, mark), {}, {
|
|
103
|
+
attrs: _objectSpread(_objectSpread({}, mark.attrs), {}, {
|
|
104
|
+
data: fn(mark.attrs.data)
|
|
105
|
+
})
|
|
106
|
+
});
|
|
107
|
+
}
|
|
108
|
+
return mark;
|
|
109
|
+
});
|
|
110
|
+
}
|
|
111
|
+
if (Array.isArray(result.content)) {
|
|
112
|
+
result.content = result.content.map(function (child) {
|
|
113
|
+
return mapLinkMarksData(child, fn);
|
|
114
|
+
});
|
|
115
|
+
}
|
|
116
|
+
return result;
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
120
|
+
function mapLinkMarksDataAsync(_x, _x2) {
|
|
121
|
+
return _mapLinkMarksDataAsync.apply(this, arguments);
|
|
122
|
+
}
|
|
123
|
+
function _mapLinkMarksDataAsync() {
|
|
124
|
+
_mapLinkMarksDataAsync = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee3(content, fn) {
|
|
125
|
+
var result;
|
|
126
|
+
return _regenerator().w(function (_context3) {
|
|
127
|
+
while (1) switch (_context3.n) {
|
|
128
|
+
case 0:
|
|
129
|
+
if (!(!content || _typeof(content) !== "object")) {
|
|
130
|
+
_context3.n = 1;
|
|
131
|
+
break;
|
|
132
|
+
}
|
|
133
|
+
return _context3.a(2, content);
|
|
134
|
+
case 1:
|
|
135
|
+
result = _objectSpread({}, content);
|
|
136
|
+
if (!Array.isArray(result.marks)) {
|
|
137
|
+
_context3.n = 3;
|
|
138
|
+
break;
|
|
139
|
+
}
|
|
140
|
+
_context3.n = 2;
|
|
141
|
+
return Promise.all(result.marks.map(/*#__PURE__*/function () {
|
|
142
|
+
var _ref9 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee2(mark) {
|
|
143
|
+
var _mark$attrs2;
|
|
144
|
+
var _t, _t2, _t3, _t4, _t5, _t6, _t7, _t8;
|
|
145
|
+
return _regenerator().w(function (_context2) {
|
|
146
|
+
while (1) switch (_context2.n) {
|
|
147
|
+
case 0:
|
|
148
|
+
if (!(mark.type === "link" && (_mark$attrs2 = mark.attrs) !== null && _mark$attrs2 !== void 0 && _mark$attrs2.data)) {
|
|
149
|
+
_context2.n = 2;
|
|
150
|
+
break;
|
|
151
|
+
}
|
|
152
|
+
_t = _objectSpread;
|
|
153
|
+
_t2 = _objectSpread({}, mark);
|
|
154
|
+
_t3 = {};
|
|
155
|
+
_t4 = _objectSpread;
|
|
156
|
+
_t5 = _objectSpread({}, mark.attrs);
|
|
157
|
+
_t6 = {};
|
|
158
|
+
_context2.n = 1;
|
|
159
|
+
return fn(mark.attrs.data);
|
|
160
|
+
case 1:
|
|
161
|
+
_t7 = _context2.v;
|
|
162
|
+
_t8 = _t4(_t5, _t6, {
|
|
163
|
+
data: _t7
|
|
164
|
+
});
|
|
165
|
+
return _context2.a(2, _t(_t2, _t3, {
|
|
166
|
+
attrs: _t8
|
|
167
|
+
}));
|
|
168
|
+
case 2:
|
|
169
|
+
return _context2.a(2, mark);
|
|
170
|
+
}
|
|
171
|
+
}, _callee2);
|
|
172
|
+
}));
|
|
173
|
+
return function (_x5) {
|
|
174
|
+
return _ref9.apply(this, arguments);
|
|
175
|
+
};
|
|
176
|
+
}()));
|
|
177
|
+
case 2:
|
|
178
|
+
result.marks = _context3.v;
|
|
179
|
+
case 3:
|
|
180
|
+
if (!Array.isArray(result.content)) {
|
|
181
|
+
_context3.n = 5;
|
|
182
|
+
break;
|
|
183
|
+
}
|
|
184
|
+
_context3.n = 4;
|
|
185
|
+
return Promise.all(result.content.map(function (child) {
|
|
186
|
+
return mapLinkMarksDataAsync(child, fn);
|
|
187
|
+
}));
|
|
188
|
+
case 4:
|
|
189
|
+
result.content = _context3.v;
|
|
190
|
+
case 5:
|
|
191
|
+
return _context3.a(2, result);
|
|
192
|
+
}
|
|
193
|
+
}, _callee3);
|
|
194
|
+
}));
|
|
195
|
+
return _mapLinkMarksDataAsync.apply(this, arguments);
|
|
196
|
+
}
|
|
197
|
+
var TipTapEditor = function TipTapEditor(_ref2) {
|
|
198
|
+
var state = _ref2.state,
|
|
199
|
+
updateState = _ref2.updateState,
|
|
200
|
+
supports = _ref2.supports,
|
|
201
|
+
blockStyles = _ref2.blockStyles,
|
|
202
|
+
inlineStyles = _ref2.inlineStyles,
|
|
203
|
+
placeholders = _ref2.placeholders,
|
|
204
|
+
linkBlock = _ref2.linkBlock,
|
|
205
|
+
maxBlocks = _ref2.maxBlocks,
|
|
206
|
+
listLevelMax = _ref2.listLevelMax;
|
|
207
|
+
var hasBlockStyles = blockStyles.length > 0;
|
|
208
|
+
var hasInlineStyles = inlineStyles.length > 0;
|
|
209
|
+
var hasLink = supports.includes("link") && !!linkBlock;
|
|
210
|
+
var hasPlaceholders = placeholders.length > 0;
|
|
211
|
+
var editor = useEditor({
|
|
212
|
+
extensions: [StarterKit.configure({
|
|
213
|
+
bold: supports.includes("bold") ? {} : false,
|
|
214
|
+
italic: supports.includes("italic") ? {} : false,
|
|
215
|
+
strike: supports.includes("strike") ? {} : false,
|
|
216
|
+
heading: supports.includes("heading") ? hasBlockStyles ? false : {} : false,
|
|
217
|
+
paragraph: hasBlockStyles ? false : undefined,
|
|
218
|
+
orderedList: supports.includes("ordered-list") ? {} : false,
|
|
219
|
+
bulletList: supports.includes("unordered-list") ? {} : false,
|
|
220
|
+
blockquote: false,
|
|
221
|
+
code: false,
|
|
222
|
+
codeBlock: false,
|
|
223
|
+
link: false
|
|
224
|
+
})].concat(_toConsumableArray(hasBlockStyles ? [BlockStyleParagraph] : []), _toConsumableArray(hasBlockStyles && supports.includes("heading") ? [BlockStyleHeading] : []), _toConsumableArray(hasInlineStyles ? [InlineStyleMark] : []), _toConsumableArray(supports.includes("sup") ? [Superscript] : []), _toConsumableArray(supports.includes("sub") ? [Subscript] : []), _toConsumableArray(supports.includes("non-breaking-space") ? [NonBreakingSpace] : []), _toConsumableArray(supports.includes("soft-hyphen") ? [SoftHyphen] : []), _toConsumableArray(hasPlaceholders ? [Placeholder] : []), _toConsumableArray(hasLink ? [CmsLink] : []), _toConsumableArray(maxBlocks !== undefined ? [createMaxBlocksExtension(maxBlocks)] : []), _toConsumableArray(listLevelMax !== undefined ? [createListLevelMaxExtension(listLevelMax)] : [])),
|
|
225
|
+
content: state.tipTapContent,
|
|
226
|
+
onUpdate: function onUpdate(_ref3) {
|
|
227
|
+
var editor = _ref3.editor;
|
|
228
|
+
if (maxBlocks !== undefined && editor.state.doc.childCount > maxBlocks) {
|
|
229
|
+
// Remove excess blocks (e.g. from paste)
|
|
230
|
+
var tr = editor.state.tr;
|
|
231
|
+
var doc = editor.state.doc;
|
|
232
|
+
// Find the resolved position after the maxBlocks-th child
|
|
233
|
+
var pos = 0;
|
|
234
|
+
for (var i = 0; i < maxBlocks; i++) {
|
|
235
|
+
pos += doc.child(i).nodeSize;
|
|
236
|
+
}
|
|
237
|
+
// In ProseMirror, doc content positions are offset by 1 (for the doc open token)
|
|
238
|
+
// Delete from after the last allowed block to end of doc content
|
|
239
|
+
tr["delete"](pos + 1, doc.content.size + 1);
|
|
240
|
+
editor.view.dispatch(tr);
|
|
241
|
+
return;
|
|
242
|
+
}
|
|
243
|
+
if (listLevelMax !== undefined) {
|
|
244
|
+
var json = editor.getJSON();
|
|
245
|
+
var currentDepth = getListNestingDepthFromJson(json);
|
|
246
|
+
if (currentDepth > listLevelMax) {
|
|
247
|
+
// Trim nested lists that exceed the limit (e.g. from paste)
|
|
248
|
+
var trimmed = trimListNesting(json, listLevelMax);
|
|
249
|
+
editor.commands.setContent(trimmed);
|
|
250
|
+
return;
|
|
251
|
+
}
|
|
252
|
+
}
|
|
253
|
+
updateState({
|
|
254
|
+
tipTapContent: editor.getJSON()
|
|
255
|
+
});
|
|
256
|
+
}
|
|
257
|
+
});
|
|
258
|
+
if (!editor) {
|
|
259
|
+
return null;
|
|
260
|
+
}
|
|
261
|
+
return /*#__PURE__*/_jsx(BlockStyleContext.Provider, {
|
|
262
|
+
value: blockStyles,
|
|
263
|
+
children: /*#__PURE__*/_jsx(InlineStyleContext.Provider, {
|
|
264
|
+
value: inlineStyles,
|
|
265
|
+
children: /*#__PURE__*/_jsxs(Box, {
|
|
266
|
+
sx: {
|
|
267
|
+
border: "1px solid ".concat(greyPalette[100]),
|
|
268
|
+
borderTopWidth: 0,
|
|
269
|
+
backgroundColor: "white",
|
|
270
|
+
borderRadius: "2px"
|
|
271
|
+
},
|
|
272
|
+
children: [/*#__PURE__*/_jsx(TipTapToolbar, {
|
|
273
|
+
editor: editor,
|
|
274
|
+
supports: supports,
|
|
275
|
+
blockStyles: blockStyles,
|
|
276
|
+
inlineStyles: inlineStyles,
|
|
277
|
+
placeholders: placeholders,
|
|
278
|
+
linkBlock: linkBlock,
|
|
279
|
+
listLevelMax: listLevelMax
|
|
280
|
+
}), /*#__PURE__*/_jsx(Box, {
|
|
281
|
+
sx: {
|
|
282
|
+
"& .tiptap": {
|
|
283
|
+
minHeight: 200,
|
|
284
|
+
p: "20px",
|
|
285
|
+
outline: "none"
|
|
286
|
+
}
|
|
287
|
+
},
|
|
288
|
+
children: /*#__PURE__*/_jsx(EditorContent, {
|
|
289
|
+
editor: editor
|
|
290
|
+
})
|
|
291
|
+
})]
|
|
292
|
+
})
|
|
293
|
+
})
|
|
294
|
+
});
|
|
295
|
+
};
|
|
296
|
+
|
|
297
|
+
/**
|
|
298
|
+
* @experimental
|
|
299
|
+
*/
|
|
300
|
+
export var createTipTapRichTextBlock = function createTipTapRichTextBlock(options) {
|
|
301
|
+
var _options$supports, _options$blockStyles, _options$inlineStyles, _options$placeholders;
|
|
302
|
+
var supports = (_options$supports = options === null || options === void 0 ? void 0 : options.supports) !== null && _options$supports !== void 0 ? _options$supports : defaultSupports;
|
|
303
|
+
var blockStyles = (_options$blockStyles = options === null || options === void 0 ? void 0 : options.blockStyles) !== null && _options$blockStyles !== void 0 ? _options$blockStyles : [];
|
|
304
|
+
var inlineStyles = (_options$inlineStyles = options === null || options === void 0 ? void 0 : options.inlineStyles) !== null && _options$inlineStyles !== void 0 ? _options$inlineStyles : [];
|
|
305
|
+
var placeholders = (_options$placeholders = options === null || options === void 0 ? void 0 : options.placeholders) !== null && _options$placeholders !== void 0 ? _options$placeholders : [];
|
|
306
|
+
var linkBlock = options === null || options === void 0 ? void 0 : options.link;
|
|
307
|
+
var maxBlocks = options === null || options === void 0 ? void 0 : options.maxBlocks;
|
|
308
|
+
var listLevelMax = options === null || options === void 0 ? void 0 : options.listLevelMax;
|
|
309
|
+
|
|
310
|
+
// Auto-enable link support when a link block is provided
|
|
311
|
+
if (linkBlock && !supports.includes("link")) {
|
|
312
|
+
supports = [].concat(_toConsumableArray(supports), ["link"]);
|
|
313
|
+
}
|
|
314
|
+
var TipTapRichTextBlock = _objectSpread(_objectSpread({}, createBlockSkeleton()), {}, {
|
|
315
|
+
name: "TipTapRichText",
|
|
316
|
+
displayName: /*#__PURE__*/_jsx(FormattedMessage, {
|
|
317
|
+
id: "comet.blocks.tipTapRichText",
|
|
318
|
+
defaultMessage: "Rich Text (TipTap)"
|
|
319
|
+
}),
|
|
320
|
+
defaultValues: function defaultValues() {
|
|
321
|
+
return {
|
|
322
|
+
tipTapContent: emptyContent
|
|
323
|
+
};
|
|
324
|
+
},
|
|
325
|
+
category: BlockCategory.TextAndContent,
|
|
326
|
+
input2State: function input2State(_ref4) {
|
|
327
|
+
var tipTapContent = _ref4.tipTapContent;
|
|
328
|
+
var content = tipTapContent !== null && tipTapContent !== void 0 ? tipTapContent : emptyContent;
|
|
329
|
+
if (linkBlock) {
|
|
330
|
+
content = mapLinkMarksData(content, function (data) {
|
|
331
|
+
return linkBlock.input2State(data);
|
|
332
|
+
});
|
|
333
|
+
}
|
|
334
|
+
return {
|
|
335
|
+
tipTapContent: content
|
|
336
|
+
};
|
|
337
|
+
},
|
|
338
|
+
state2Output: function state2Output(_ref5) {
|
|
339
|
+
var tipTapContent = _ref5.tipTapContent;
|
|
340
|
+
var content = tipTapContent;
|
|
341
|
+
if (linkBlock) {
|
|
342
|
+
content = mapLinkMarksData(content, function (data) {
|
|
343
|
+
return linkBlock.state2Output(data);
|
|
344
|
+
});
|
|
345
|
+
}
|
|
346
|
+
return {
|
|
347
|
+
tipTapContent: content
|
|
348
|
+
};
|
|
349
|
+
},
|
|
350
|
+
output2State: function () {
|
|
351
|
+
var _output2State = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee(_ref6, context) {
|
|
352
|
+
var tipTapContent, content;
|
|
353
|
+
return _regenerator().w(function (_context) {
|
|
354
|
+
while (1) switch (_context.n) {
|
|
355
|
+
case 0:
|
|
356
|
+
tipTapContent = _ref6.tipTapContent;
|
|
357
|
+
content = tipTapContent !== null && tipTapContent !== void 0 ? tipTapContent : emptyContent;
|
|
358
|
+
if (!linkBlock) {
|
|
359
|
+
_context.n = 2;
|
|
360
|
+
break;
|
|
361
|
+
}
|
|
362
|
+
_context.n = 1;
|
|
363
|
+
return mapLinkMarksDataAsync(content, function (data) {
|
|
364
|
+
return linkBlock.output2State(data, context);
|
|
365
|
+
});
|
|
366
|
+
case 1:
|
|
367
|
+
content = _context.v;
|
|
368
|
+
case 2:
|
|
369
|
+
return _context.a(2, {
|
|
370
|
+
tipTapContent: content
|
|
371
|
+
});
|
|
372
|
+
}
|
|
373
|
+
}, _callee);
|
|
374
|
+
}));
|
|
375
|
+
function output2State(_x3, _x4) {
|
|
376
|
+
return _output2State.apply(this, arguments);
|
|
377
|
+
}
|
|
378
|
+
return output2State;
|
|
379
|
+
}(),
|
|
380
|
+
createPreviewState: function createPreviewState(_ref7, previewCtx) {
|
|
381
|
+
var tipTapContent = _ref7.tipTapContent;
|
|
382
|
+
var content = tipTapContent;
|
|
383
|
+
if (linkBlock) {
|
|
384
|
+
content = mapLinkMarksData(content, function (data) {
|
|
385
|
+
return linkBlock.createPreviewState(data, previewCtx);
|
|
386
|
+
});
|
|
387
|
+
}
|
|
388
|
+
return {
|
|
389
|
+
tipTapContent: content,
|
|
390
|
+
adminMeta: {
|
|
391
|
+
route: previewCtx.parentUrl
|
|
392
|
+
}
|
|
393
|
+
};
|
|
394
|
+
},
|
|
395
|
+
AdminComponent: function AdminComponent(_ref8) {
|
|
396
|
+
var state = _ref8.state,
|
|
397
|
+
updateState = _ref8.updateState;
|
|
398
|
+
return /*#__PURE__*/_jsx(TipTapEditor, {
|
|
399
|
+
state: state,
|
|
400
|
+
updateState: updateState,
|
|
401
|
+
supports: supports,
|
|
402
|
+
blockStyles: blockStyles,
|
|
403
|
+
inlineStyles: inlineStyles,
|
|
404
|
+
placeholders: placeholders,
|
|
405
|
+
linkBlock: linkBlock,
|
|
406
|
+
maxBlocks: maxBlocks,
|
|
407
|
+
listLevelMax: listLevelMax
|
|
408
|
+
});
|
|
409
|
+
},
|
|
410
|
+
previewContent: function previewContent(state) {
|
|
411
|
+
var text = getPlainTextFromContent(state.tipTapContent);
|
|
412
|
+
var MAX_CHARS = 100;
|
|
413
|
+
return text.length > 0 ? [{
|
|
414
|
+
type: "text",
|
|
415
|
+
content: text.slice(0, MAX_CHARS)
|
|
416
|
+
}] : [];
|
|
417
|
+
},
|
|
418
|
+
extractTextContents: function extractTextContents(state) {
|
|
419
|
+
var text = getPlainTextFromContent(state.tipTapContent);
|
|
420
|
+
return text.length > 0 ? [text] : [];
|
|
421
|
+
}
|
|
422
|
+
});
|
|
423
|
+
return TipTapRichTextBlock;
|
|
424
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"BlockStyleHeading.d.ts","sourceRoot":"","sources":["../../../../src/blocks/tipTap/extensions/BlockStyleHeading.tsx"],"names":[],"mappings":"AA8BA,eAAO,MAAM,iBAAiB,sFAoB5B,CAAC"}
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); }
|
|
2
|
+
function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
|
|
3
|
+
function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
|
|
4
|
+
function _defineProperty(e, r, t) { return (r = _toPropertyKey(r)) in e ? Object.defineProperty(e, r, { value: t, enumerable: !0, configurable: !0, writable: !0 }) : e[r] = t, e; }
|
|
5
|
+
function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : i + ""; }
|
|
6
|
+
function _toPrimitive(t, r) { if ("object" != _typeof(t) || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != _typeof(i)) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
|
|
7
|
+
import Heading from "@tiptap/extension-heading";
|
|
8
|
+
import { NodeViewContent, NodeViewWrapper, ReactNodeViewRenderer } from "@tiptap/react";
|
|
9
|
+
import { useContext } from "react";
|
|
10
|
+
import { BlockStyleContext } from "../BlockStyleContext";
|
|
11
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
12
|
+
function BlockStyleHeadingView(_ref) {
|
|
13
|
+
var node = _ref.node;
|
|
14
|
+
var blockStyles = useContext(BlockStyleContext);
|
|
15
|
+
var styleName = node.attrs.blockStyle;
|
|
16
|
+
var config = styleName ? blockStyles.find(function (s) {
|
|
17
|
+
return s.name === styleName;
|
|
18
|
+
}) : undefined;
|
|
19
|
+
var tag = "h".concat(node.attrs.level);
|
|
20
|
+
if (config) {
|
|
21
|
+
var Element = config.element;
|
|
22
|
+
return /*#__PURE__*/_jsx(NodeViewWrapper, {
|
|
23
|
+
children: /*#__PURE__*/_jsx(Element, {
|
|
24
|
+
"data-block-style": styleName,
|
|
25
|
+
children: /*#__PURE__*/_jsx(NodeViewContent, {})
|
|
26
|
+
})
|
|
27
|
+
});
|
|
28
|
+
}
|
|
29
|
+
return /*#__PURE__*/_jsx(NodeViewWrapper, {
|
|
30
|
+
as: tag,
|
|
31
|
+
children: /*#__PURE__*/_jsx(NodeViewContent, {})
|
|
32
|
+
});
|
|
33
|
+
}
|
|
34
|
+
export var BlockStyleHeading = Heading.extend({
|
|
35
|
+
addAttributes: function addAttributes() {
|
|
36
|
+
var _this$parent;
|
|
37
|
+
return _objectSpread(_objectSpread({}, (_this$parent = this.parent) === null || _this$parent === void 0 ? void 0 : _this$parent.call(this)), {}, {
|
|
38
|
+
blockStyle: {
|
|
39
|
+
"default": null,
|
|
40
|
+
parseHTML: function parseHTML(element) {
|
|
41
|
+
return element.getAttribute("data-block-style");
|
|
42
|
+
},
|
|
43
|
+
renderHTML: function renderHTML(attributes) {
|
|
44
|
+
if (!attributes.blockStyle) {
|
|
45
|
+
return {};
|
|
46
|
+
}
|
|
47
|
+
return {
|
|
48
|
+
"data-block-style": attributes.blockStyle
|
|
49
|
+
};
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
});
|
|
53
|
+
},
|
|
54
|
+
addNodeView: function addNodeView() {
|
|
55
|
+
return ReactNodeViewRenderer(BlockStyleHeadingView);
|
|
56
|
+
}
|
|
57
|
+
});
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"BlockStyleParagraph.d.ts","sourceRoot":"","sources":["../../../../src/blocks/tipTap/extensions/BlockStyleParagraph.tsx"],"names":[],"mappings":"AA6BA,eAAO,MAAM,mBAAmB,0FAoB9B,CAAC"}
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); }
|
|
2
|
+
function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
|
|
3
|
+
function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
|
|
4
|
+
function _defineProperty(e, r, t) { return (r = _toPropertyKey(r)) in e ? Object.defineProperty(e, r, { value: t, enumerable: !0, configurable: !0, writable: !0 }) : e[r] = t, e; }
|
|
5
|
+
function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : i + ""; }
|
|
6
|
+
function _toPrimitive(t, r) { if ("object" != _typeof(t) || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != _typeof(i)) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
|
|
7
|
+
import Paragraph from "@tiptap/extension-paragraph";
|
|
8
|
+
import { NodeViewContent, NodeViewWrapper, ReactNodeViewRenderer } from "@tiptap/react";
|
|
9
|
+
import { useContext } from "react";
|
|
10
|
+
import { BlockStyleContext } from "../BlockStyleContext";
|
|
11
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
12
|
+
function BlockStyleParagraphView(_ref) {
|
|
13
|
+
var node = _ref.node;
|
|
14
|
+
var blockStyles = useContext(BlockStyleContext);
|
|
15
|
+
var styleName = node.attrs.blockStyle;
|
|
16
|
+
var config = styleName ? blockStyles.find(function (s) {
|
|
17
|
+
return s.name === styleName;
|
|
18
|
+
}) : undefined;
|
|
19
|
+
if (config) {
|
|
20
|
+
var Element = config.element;
|
|
21
|
+
return /*#__PURE__*/_jsx(NodeViewWrapper, {
|
|
22
|
+
children: /*#__PURE__*/_jsx(Element, {
|
|
23
|
+
"data-block-style": styleName,
|
|
24
|
+
children: /*#__PURE__*/_jsx(NodeViewContent, {})
|
|
25
|
+
})
|
|
26
|
+
});
|
|
27
|
+
}
|
|
28
|
+
return /*#__PURE__*/_jsx(NodeViewWrapper, {
|
|
29
|
+
as: "p",
|
|
30
|
+
children: /*#__PURE__*/_jsx(NodeViewContent, {})
|
|
31
|
+
});
|
|
32
|
+
}
|
|
33
|
+
export var BlockStyleParagraph = Paragraph.extend({
|
|
34
|
+
addAttributes: function addAttributes() {
|
|
35
|
+
var _this$parent;
|
|
36
|
+
return _objectSpread(_objectSpread({}, (_this$parent = this.parent) === null || _this$parent === void 0 ? void 0 : _this$parent.call(this)), {}, {
|
|
37
|
+
blockStyle: {
|
|
38
|
+
"default": null,
|
|
39
|
+
parseHTML: function parseHTML(element) {
|
|
40
|
+
return element.getAttribute("data-block-style");
|
|
41
|
+
},
|
|
42
|
+
renderHTML: function renderHTML(attributes) {
|
|
43
|
+
if (!attributes.blockStyle) {
|
|
44
|
+
return {};
|
|
45
|
+
}
|
|
46
|
+
return {
|
|
47
|
+
"data-block-style": attributes.blockStyle
|
|
48
|
+
};
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
});
|
|
52
|
+
},
|
|
53
|
+
addNodeView: function addNodeView() {
|
|
54
|
+
return ReactNodeViewRenderer(BlockStyleParagraphView);
|
|
55
|
+
}
|
|
56
|
+
});
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { Mark } from "@tiptap/core";
|
|
2
|
+
declare module "@tiptap/core" {
|
|
3
|
+
interface Commands<ReturnType> {
|
|
4
|
+
cmsLink: {
|
|
5
|
+
setCmsLink: (attrs: {
|
|
6
|
+
data: any;
|
|
7
|
+
}) => ReturnType;
|
|
8
|
+
unsetCmsLink: () => ReturnType;
|
|
9
|
+
};
|
|
10
|
+
}
|
|
11
|
+
}
|
|
12
|
+
export declare const CmsLink: Mark<any, any>;
|
|
13
|
+
//# sourceMappingURL=CmsLink.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"CmsLink.d.ts","sourceRoot":"","sources":["../../../../src/blocks/tipTap/extensions/CmsLink.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAmB,MAAM,cAAc,CAAC;AAErD,OAAO,QAAQ,cAAc,CAAC;IAC1B,UAAU,QAAQ,CAAC,UAAU;QACzB,OAAO,EAAE;YAEL,UAAU,EAAE,CAAC,KAAK,EAAE;gBAAE,IAAI,EAAE,GAAG,CAAA;aAAE,KAAK,UAAU,CAAC;YACjD,YAAY,EAAE,MAAM,UAAU,CAAC;SAClC,CAAC;KACL;CACJ;AAED,eAAO,MAAM,OAAO,gBAwClB,CAAC"}
|