@contentful/field-editor-rich-text 3.0.0-next.0 → 3.0.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/CHANGELOG.md +690 -0
- package/LICENSE +21 -0
- package/README.md +25 -3
- package/dist/ContentfulEditorProvider.d.ts +6 -5
- package/dist/RichTextEditor.d.ts +2 -3
- package/dist/SdkProvider.d.ts +1 -1
- package/dist/Toolbar/{EmbedEntityWidget.d.ts → components/EmbedEntityWidget.d.ts} +1 -2
- package/dist/{plugins/EmbeddedEntity/index.d.ts → Toolbar/components/EmbeddedEntityDropdownButton.d.ts} +1 -2
- package/dist/Toolbar/{StickyToolbarWrapper.d.ts → components/StickyToolbarWrapper.d.ts} +0 -0
- package/dist/Toolbar/index.d.ts +0 -1
- package/dist/dialogs/HypelinkDialog/HyperlinkDialog.d.ts +3 -3
- package/dist/dialogs/renderRichTextDialog.d.ts +0 -1
- package/dist/field-editor-rich-text.cjs.development.js +6503 -4337
- package/dist/field-editor-rich-text.cjs.development.js.map +1 -1
- package/dist/field-editor-rich-text.cjs.production.min.js +1 -1
- package/dist/field-editor-rich-text.cjs.production.min.js.map +1 -1
- package/dist/field-editor-rich-text.esm.js +6485 -4319
- package/dist/field-editor-rich-text.esm.js.map +1 -1
- package/dist/helpers/editor.d.ts +21 -23
- package/dist/helpers/environment.d.ts +2 -1
- package/dist/helpers/extractNodes.d.ts +6 -0
- package/dist/helpers/removeInternalMarks.d.ts +1 -0
- package/dist/helpers/sanitizeIncomingSlateDoc.d.ts +6 -0
- package/dist/helpers/transformers.d.ts +8 -0
- package/dist/helpers/validations.d.ts +1 -1
- package/dist/plugins/Break/createExitBreakPlugin.d.ts +2 -0
- package/dist/plugins/Break/createResetNodePlugin.d.ts +2 -0
- package/dist/plugins/Break/createSoftBreakPlugin.d.ts +2 -0
- package/dist/plugins/Break/index.d.ts +5 -0
- package/dist/plugins/CommandPalette/components/CommandList.d.ts +7 -0
- package/dist/plugins/CommandPalette/components/CommandList.styles.d.ts +13 -0
- package/dist/plugins/CommandPalette/components/CommandPrompt.d.ts +2 -0
- package/dist/plugins/CommandPalette/constants.d.ts +1 -0
- package/dist/plugins/CommandPalette/createCommandPalettePlugin.d.ts +13 -0
- package/dist/plugins/CommandPalette/hooks/useCommandList.d.ts +4 -0
- package/dist/plugins/CommandPalette/index.d.ts +1 -0
- package/dist/plugins/CommandPalette/onKeyDown.d.ts +3 -0
- package/dist/plugins/CommandPalette/useCommands.d.ts +14 -0
- package/dist/plugins/CommandPalette/utils/createInlineEntryNode.d.ts +16 -0
- package/dist/plugins/CommandPalette/utils/fetchAssets.d.ts +8 -0
- package/dist/plugins/CommandPalette/utils/fetchEntries.d.ts +9 -0
- package/dist/plugins/CommandPalette/utils/insertBlock.d.ts +1 -0
- package/dist/plugins/CommandPalette/utils/trimLeadingSlash.d.ts +7 -0
- package/dist/plugins/DragAndDrop/index.d.ts +2 -2
- package/dist/plugins/EmbeddedEntityBlock/LinkedEntityBlock.d.ts +3 -2
- package/dist/plugins/EmbeddedEntityBlock/ToolbarIcon.d.ts +1 -4
- package/dist/plugins/EmbeddedEntityBlock/Util.d.ts +2 -1
- package/dist/plugins/EmbeddedEntityBlock/index.d.ts +3 -9
- package/dist/plugins/EmbeddedEntityInline/FetchingWrappedInlineEntryCard.d.ts +1 -0
- package/dist/plugins/EmbeddedEntityInline/index.d.ts +3 -6
- package/dist/plugins/Heading/components/Heading.d.ts +10 -0
- package/dist/plugins/Heading/components/ToolbarHeadingButton.d.ts +4 -0
- package/dist/plugins/Heading/createHeadingPlugin.d.ts +2 -0
- package/dist/plugins/Heading/index.d.ts +2 -20
- package/dist/plugins/Hr/index.d.ts +3 -5
- package/dist/plugins/Hyperlink/HyperlinkModal.d.ts +6 -6
- package/dist/plugins/Hyperlink/components/EntityHyperlink.d.ts +9 -0
- package/dist/plugins/Hyperlink/components/ToolbarHyperlinkButton.d.ts +5 -0
- package/dist/plugins/Hyperlink/components/UrlHyperlink.d.ts +9 -0
- package/dist/plugins/Hyperlink/components/styles.d.ts +4 -0
- package/dist/plugins/Hyperlink/createHyperlinkPlugin.d.ts +3 -0
- package/dist/plugins/Hyperlink/index.d.ts +2 -12
- package/dist/plugins/Hyperlink/useEntityInfo.d.ts +16 -0
- package/dist/plugins/Hyperlink/utils.d.ts +5 -0
- package/dist/plugins/List/components/List.d.ts +3 -0
- package/dist/plugins/List/components/ListItem.d.ts +2 -0
- package/dist/plugins/List/components/ToolbarListButton.d.ts +4 -0
- package/dist/plugins/List/createListPlugin.d.ts +2 -0
- package/dist/plugins/List/index.d.ts +2 -15
- package/dist/plugins/List/insertListBreak.d.ts +2 -0
- package/dist/plugins/List/insertListFragment.d.ts +3 -0
- package/dist/plugins/List/onKeyDownList.d.ts +7 -0
- package/dist/plugins/List/transforms/deleteBackwardList.d.ts +2 -0
- package/dist/plugins/List/transforms/insertListItem.d.ts +5 -0
- package/dist/plugins/List/transforms/moveListItemDown.d.ts +11 -0
- package/dist/plugins/List/transforms/moveListItems.d.ts +10 -0
- package/dist/plugins/List/transforms/toggleList.d.ts +4 -0
- package/dist/plugins/List/transforms/unwrapList.d.ts +5 -0
- package/dist/plugins/List/utils.d.ts +15 -0
- package/dist/plugins/List/withList.d.ts +4 -0
- package/dist/plugins/Marks/Bold.d.ts +11 -0
- package/dist/plugins/Marks/Code.d.ts +11 -0
- package/dist/plugins/Marks/Italic.d.ts +11 -0
- package/dist/plugins/Marks/Underline.d.ts +11 -0
- package/dist/plugins/Marks/components/MarkToolbarButton.d.ts +13 -0
- package/dist/plugins/Marks/helpers.d.ts +4 -0
- package/dist/plugins/Marks/index.d.ts +2 -0
- package/dist/plugins/Normalizer/baseRules.d.ts +2 -0
- package/dist/plugins/Normalizer/createNormalizerPlugin.d.ts +2 -0
- package/dist/plugins/Normalizer/index.d.ts +2 -0
- package/dist/plugins/Normalizer/types.d.ts +40 -0
- package/dist/plugins/Normalizer/utils.d.ts +8 -0
- package/dist/plugins/Normalizer/withNormalizer.d.ts +2 -0
- package/dist/plugins/Paragraph/Paragraph.d.ts +2 -0
- package/dist/plugins/Paragraph/createParagraphPlugin.d.ts +2 -0
- package/dist/plugins/Paragraph/index.d.ts +1 -7
- package/dist/plugins/Paragraph/utils.d.ts +2 -0
- package/dist/plugins/PasteHTML/createPasteHTMLPlugin.d.ts +8 -0
- package/dist/plugins/PasteHTML/index.d.ts +1 -0
- package/dist/plugins/PasteHTML/utils/sanitizeHTML.d.ts +1 -0
- package/dist/plugins/PasteHTML/utils/sanitizeSheets.d.ts +4 -0
- package/dist/plugins/Quote/components/Quote.d.ts +2 -0
- package/dist/plugins/Quote/components/ToolbarQuoteButton.d.ts +4 -0
- package/dist/plugins/Quote/createQuotePlugin.d.ts +2 -0
- package/dist/plugins/Quote/index.d.ts +2 -13
- package/dist/plugins/Quote/shouldResetQuote.d.ts +8 -0
- package/dist/plugins/Quote/toggleQuote.d.ts +5 -0
- package/dist/plugins/Quote/withQuote.d.ts +3 -0
- package/dist/plugins/SelectOnBackspace/createSelectOnBackspacePlugin.d.ts +2 -0
- package/dist/plugins/SelectOnBackspace/index.d.ts +1 -0
- package/dist/plugins/Table/actions/addColumn.d.ts +3 -3
- package/dist/plugins/Table/actions/addRow.d.ts +3 -3
- package/dist/plugins/Table/actions/setHeader.d.ts +2 -2
- package/dist/plugins/Table/components/Cell.d.ts +2 -0
- package/dist/plugins/Table/components/HeaderCell.d.ts +2 -0
- package/dist/plugins/Table/components/Row.d.ts +2 -0
- package/dist/plugins/Table/components/Table.d.ts +2 -0
- package/dist/plugins/Table/components/TableActions.d.ts +4 -0
- package/dist/plugins/Table/components/ToolbarButton.d.ts +4 -0
- package/dist/plugins/Table/createTablePlugin.d.ts +2 -0
- package/dist/plugins/Table/helpers.d.ts +16 -4
- package/dist/plugins/Table/index.d.ts +2 -189
- package/dist/plugins/Table/insertTableFragment.d.ts +3 -0
- package/dist/plugins/Table/onKeyDownTable.d.ts +3 -0
- package/dist/plugins/Table/tableTracking.d.ts +4 -0
- package/dist/plugins/Text/createTextPlugin.d.ts +2 -0
- package/dist/plugins/Text/index.d.ts +1 -0
- package/dist/plugins/Tracking/createTrackingPlugin.d.ts +11 -0
- package/dist/plugins/Tracking/index.d.ts +1 -0
- package/dist/plugins/Tracking/utils.d.ts +2 -0
- package/dist/plugins/TrailingParagraph/index.d.ts +2 -1
- package/dist/plugins/Voids/createVoidsPlugin.d.ts +2 -0
- package/dist/plugins/Voids/index.d.ts +1 -0
- package/dist/plugins/Voids/transformVoid.d.ts +6 -0
- package/dist/plugins/index.d.ts +6 -0
- package/dist/plugins/links-tracking.d.ts +6 -0
- package/dist/plugins/shared/FetchingWrappedAssetCard.d.ts +1 -11
- package/dist/plugins/shared/FetchingWrappedEntryCard.d.ts +4 -4
- package/dist/plugins/shared/ToolbarButton.d.ts +0 -1
- package/dist/prepareDocument.d.ts +20 -0
- package/dist/test-utils/assertOutput.d.ts +7 -0
- package/dist/test-utils/createEditor.d.ts +13 -0
- package/dist/test-utils/index.d.ts +4 -0
- package/dist/test-utils/jsx.d.ts +28 -0
- package/dist/test-utils/mockPlugin.d.ts +2 -0
- package/dist/test-utils/randomId.d.ts +4 -0
- package/dist/test-utils/setEmptyDataAttribute.d.ts +6 -0
- package/dist/test-utils/validation.d.ts +1 -0
- package/dist/types.d.ts +34 -9
- package/dist/useOnValueChanged.d.ts +8 -0
- package/package.json +34 -29
- package/dist/TrackingProvider.d.ts +0 -11
- package/dist/helpers/deserializer.d.ts +0 -3
- package/dist/helpers/sanitizeSlateDoc.d.ts +0 -18
- package/dist/helpers/truncate.d.ts +0 -1
- package/dist/plugins/Bold/index.d.ts +0 -12
- package/dist/plugins/Code/index.d.ts +0 -12
- package/dist/plugins/CommandPalette/CommandPanel/InViewport/InViewport.d.ts +0 -37
- package/dist/plugins/Hyperlink/EntryAssetTooltip.d.ts +0 -10
- package/dist/plugins/InsertBeforeFirstVoidBlock/index.d.ts +0 -2
- package/dist/plugins/Italic/index.d.ts +0 -12
- package/dist/plugins/List/getListInsertFragment.d.ts +0 -6
- package/dist/plugins/NewLine/index.d.ts +0 -2
- package/dist/plugins/Paste/index.d.ts +0 -2
- package/dist/plugins/Paste/sanitizers/helpers.d.ts +0 -7
- package/dist/plugins/Paste/sanitizers/index.d.ts +0 -3
- package/dist/plugins/Paste/sanitizers/removeComments.d.ts +0 -2
- package/dist/plugins/Paste/sanitizers/sanitizeEntityBlocks.d.ts +0 -6
- package/dist/plugins/Paste/sanitizers/sanitizeTables.d.ts +0 -2
- package/dist/plugins/Table/TableActions.d.ts +0 -5
- package/dist/plugins/Underline/index.d.ts +0 -12
- package/dist/plugins/shared/EntityStatusIcon.d.ts +0 -8
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './createTextPlugin';
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { RichTextPlugin } from '../../types';
|
|
2
|
+
export declare type RichTextTrackingActionName = 'edit' | 'insert' | 'remove' | 'mark' | 'unmark' | 'insertTable' | 'insertTableRow' | 'insertTableColumn' | 'removeTable' | 'removeTableRow' | 'removeTableColumn' | 'paste' | 'invalidTablePaste' | 'cancelCreateHyperlinkDialog' | 'cancelEditHyperlinkDialog' | 'linkRendered' | 'openCreateHyperlinkDialog' | 'openEditHyperlinkDialog' | 'unlinkHyperlinks' | 'openCreateEmbedDialog' | 'cancelCreateEmbedDialog' | 'openRichTextCommandPalette' | 'cancelRichTextCommandPalette';
|
|
3
|
+
export declare type RichTextTrackingActionHandler = (name: RichTextTrackingActionName, data: Record<string, unknown>) => unknown;
|
|
4
|
+
export interface TrackingPluginActions {
|
|
5
|
+
onViewportAction: (actionName: RichTextTrackingActionName, data?: Record<string, unknown>) => ReturnType<RichTextTrackingActionHandler>;
|
|
6
|
+
onShortcutAction: (actionName: RichTextTrackingActionName, data?: Record<string, unknown>) => ReturnType<RichTextTrackingActionHandler>;
|
|
7
|
+
onToolbarAction: (actionName: RichTextTrackingActionName, data?: Record<string, unknown>) => ReturnType<RichTextTrackingActionHandler>;
|
|
8
|
+
onCommandPaletteAction: (actionName: RichTextTrackingActionName, data?: Record<string, unknown>) => ReturnType<RichTextTrackingActionHandler>;
|
|
9
|
+
}
|
|
10
|
+
export declare function getPastingSource(data: DataTransfer): "Google Docs" | "Google Spreadsheets" | "Microsoft Excel" | "Microsoft Word" | "Microsoft Word Online" | "Apple Notes" | "Slack" | "Unknown";
|
|
11
|
+
export declare const createTrackingPlugin: (onAction: RichTextTrackingActionHandler) => RichTextPlugin;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './createTrackingPlugin';
|
|
@@ -1 +1,2 @@
|
|
|
1
|
-
|
|
1
|
+
import { RichTextPlugin } from '../../types';
|
|
2
|
+
export declare const createTrailingParagraphPlugin: () => RichTextPlugin;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './createVoidsPlugin';
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { FieldExtensionSDK } from '@contentful/app-sdk';
|
|
2
|
+
import { PlateProps } from '@udecode/plate-core';
|
|
3
|
+
import { RichTextPlugin } from '../types';
|
|
4
|
+
import { RichTextTrackingActionHandler } from './Tracking';
|
|
5
|
+
export declare const getPlugins: (sdk: FieldExtensionSDK, onAction: RichTextTrackingActionHandler) => RichTextPlugin[];
|
|
6
|
+
export declare const disableCorePlugins: PlateProps['disableCorePlugins'];
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import React, { ComponentProps } from 'react';
|
|
2
|
+
declare type WithEntityFetchProps = {
|
|
3
|
+
onEntityFetchComplete: VoidFunction;
|
|
4
|
+
} & JSX.IntrinsicAttributes;
|
|
5
|
+
export declare function withLinkTracking(Component: React.ComponentType<WithEntityFetchProps>): (props: ComponentProps<typeof Component>) => JSX.Element;
|
|
6
|
+
export {};
|
|
@@ -1,6 +1,4 @@
|
|
|
1
|
-
/// <reference types="react" />
|
|
2
1
|
import { FieldExtensionSDK } from '@contentful/app-sdk';
|
|
3
|
-
import { File } from '@contentful/field-editor-shared';
|
|
4
2
|
interface FetchingWrappedAssetCardProps {
|
|
5
3
|
assetId: string;
|
|
6
4
|
isDisabled: boolean;
|
|
@@ -9,15 +7,7 @@ interface FetchingWrappedAssetCardProps {
|
|
|
9
7
|
onEdit?: () => void;
|
|
10
8
|
onRemove?: () => unknown;
|
|
11
9
|
sdk: FieldExtensionSDK;
|
|
10
|
+
onEntityFetchComplete?: VoidFunction;
|
|
12
11
|
}
|
|
13
|
-
export declare function renderAssetInfo(props: {
|
|
14
|
-
entityFile: File;
|
|
15
|
-
}): ("" | JSX.Element)[];
|
|
16
|
-
export declare function renderActions(props: {
|
|
17
|
-
onEdit?: () => void;
|
|
18
|
-
onRemove?: () => void;
|
|
19
|
-
isDisabled: boolean;
|
|
20
|
-
entityFile?: File;
|
|
21
|
-
}): (JSX.Element | null)[];
|
|
22
12
|
export declare function FetchingWrappedAssetCard(props: FetchingWrappedAssetCardProps): JSX.Element;
|
|
23
13
|
export {};
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
/// <reference types="react" />
|
|
2
1
|
import { FieldExtensionSDK } from '@contentful/app-sdk';
|
|
3
2
|
interface FetchingWrappedEntryCardProps {
|
|
4
3
|
entryId: string;
|
|
@@ -6,8 +5,9 @@ interface FetchingWrappedEntryCardProps {
|
|
|
6
5
|
isSelected: boolean;
|
|
7
6
|
locale: string;
|
|
8
7
|
sdk: FieldExtensionSDK;
|
|
9
|
-
|
|
10
|
-
|
|
8
|
+
onEntityFetchComplete?: VoidFunction;
|
|
9
|
+
onEdit?: VoidFunction;
|
|
10
|
+
onRemove?: VoidFunction;
|
|
11
11
|
}
|
|
12
|
-
export declare
|
|
12
|
+
export declare const FetchingWrappedEntryCard: (props: FetchingWrappedEntryCardProps) => JSX.Element;
|
|
13
13
|
export {};
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { Document } from '@contentful/rich-text-types';
|
|
2
|
+
import { CreatePlateEditorOptions } from '@udecode/plate-core';
|
|
3
|
+
import { Descendant, Editor, Node } from 'slate';
|
|
4
|
+
import { RichTextEditor } from 'types';
|
|
5
|
+
/**
|
|
6
|
+
* For legacy reasons, a document may not have any content at all
|
|
7
|
+
* e.g:
|
|
8
|
+
*
|
|
9
|
+
* {nodeType: document, data: {}, content: []}
|
|
10
|
+
*
|
|
11
|
+
* Rendering such document will break the Slate editor
|
|
12
|
+
*/
|
|
13
|
+
export declare const hasContent: (doc?: Document | undefined) => boolean;
|
|
14
|
+
export declare const setEditorContent: (editor: Editor, nodes?: Node[] | undefined) => void;
|
|
15
|
+
/**
|
|
16
|
+
* Converts a Contentful rich text document to the corresponding slate editor
|
|
17
|
+
* value
|
|
18
|
+
*/
|
|
19
|
+
export declare const documentToEditorValue: (doc: any) => import("types").TextOrCustomElement[];
|
|
20
|
+
export declare const normalizeEditorValue: (value: Descendant[], options?: Omit<CreatePlateEditorOptions<RichTextEditor>, "id" | "editor"> | undefined) => Descendant[] & any[];
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { FieldExtensionSDK } from '@contentful/app-sdk';
|
|
2
|
+
import { RichTextTrackingActionHandler } from '../plugins/Tracking';
|
|
3
|
+
import { RichTextEditor, RichTextPlugin } from '../types';
|
|
4
|
+
export declare const normalize: (editor: RichTextEditor) => void;
|
|
5
|
+
export declare const createTestEditor: (options: {
|
|
6
|
+
input?: any;
|
|
7
|
+
sdk?: FieldExtensionSDK;
|
|
8
|
+
trackingHandler?: RichTextTrackingActionHandler;
|
|
9
|
+
plugins?: RichTextPlugin[];
|
|
10
|
+
}) => {
|
|
11
|
+
editor: import("@udecode/plate-core").PlateEditor<RichTextEditor>;
|
|
12
|
+
normalize: () => void;
|
|
13
|
+
};
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Mapping for JSX => Slate Node types
|
|
3
|
+
*
|
|
4
|
+
* Add items as needed. Don't forget to adjust hyperscript.d.ts
|
|
5
|
+
*/
|
|
6
|
+
export declare const jsx: <S extends "element" | "editor" | "selection" | "text" | "anchor" | "focus" | "cursor" | "fragment">(tagName: S, attributes?: Object | undefined, ...children: any[]) => ReturnType<({
|
|
7
|
+
anchor: typeof import("slate-hyperscript/dist/creators").createAnchor;
|
|
8
|
+
cursor: typeof import("slate-hyperscript/dist/creators").createCursor;
|
|
9
|
+
editor: (tagName: string, attributes: {
|
|
10
|
+
[key: string]: any;
|
|
11
|
+
}, children: any[]) => import("slate").BaseEditor;
|
|
12
|
+
element: typeof import("slate-hyperscript/dist/creators").createElement;
|
|
13
|
+
focus: typeof import("slate-hyperscript/dist/creators").createFocus;
|
|
14
|
+
fragment: typeof import("slate-hyperscript/dist/creators").createFragment;
|
|
15
|
+
selection: typeof import("slate-hyperscript/dist/creators").createSelection;
|
|
16
|
+
text: typeof import("slate-hyperscript/dist/creators").createText;
|
|
17
|
+
} | {
|
|
18
|
+
anchor: typeof import("slate-hyperscript/dist/creators").createAnchor;
|
|
19
|
+
cursor: typeof import("slate-hyperscript/dist/creators").createCursor;
|
|
20
|
+
editor: (tagName: string, attributes: {
|
|
21
|
+
[key: string]: any;
|
|
22
|
+
}, children: any[]) => import("slate").BaseEditor;
|
|
23
|
+
element: typeof import("slate-hyperscript/dist/creators").createElement;
|
|
24
|
+
focus: typeof import("slate-hyperscript/dist/creators").createFocus;
|
|
25
|
+
fragment: typeof import("slate-hyperscript/dist/creators").createFragment;
|
|
26
|
+
selection: typeof import("slate-hyperscript/dist/creators").createSelection;
|
|
27
|
+
text: typeof import("slate-hyperscript/dist/creators").createText;
|
|
28
|
+
})[S]>;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function validateRichTextDocument(document: any): never[];
|
package/dist/types.d.ts
CHANGED
|
@@ -1,10 +1,17 @@
|
|
|
1
|
-
|
|
2
|
-
import {
|
|
3
|
-
import { RenderElementProps
|
|
4
|
-
|
|
1
|
+
import { MARKS } from '@contentful/rich-text-types';
|
|
2
|
+
import { PlateEditor, PlatePlugin } from '@udecode/plate-core';
|
|
3
|
+
import { RenderElementProps } from 'slate-react';
|
|
4
|
+
import type { SoftBreakRule, ExitBreakRule, ResetNodePluginRule } from './plugins/Break';
|
|
5
|
+
import type { NormalizerRule } from './plugins/Normalizer';
|
|
6
|
+
import { TrackingPluginActions } from './plugins/Tracking';
|
|
7
|
+
export declare type CustomText = {
|
|
5
8
|
text: string;
|
|
9
|
+
[MARKS.BOLD]?: boolean;
|
|
10
|
+
[MARKS.CODE]?: boolean;
|
|
11
|
+
[MARKS.ITALIC]?: boolean;
|
|
12
|
+
[MARKS.UNDERLINE]?: boolean;
|
|
6
13
|
};
|
|
7
|
-
export declare type TextOrCustomElement = CustomElement |
|
|
14
|
+
export declare type TextOrCustomElement = CustomElement | CustomText;
|
|
8
15
|
export declare type CustomElement<T = unknown> = {
|
|
9
16
|
type: string;
|
|
10
17
|
children: TextOrCustomElement[];
|
|
@@ -14,12 +21,30 @@ export declare type CustomElement<T = unknown> = {
|
|
|
14
21
|
export declare type CustomRenderElementProps<T = any, O = any> = Omit<RenderElementProps, 'element'> & {
|
|
15
22
|
element: CustomElement<T>;
|
|
16
23
|
} & O;
|
|
17
|
-
export interface CustomPluginOptions extends Omit<PlatePluginOptions, 'component'> {
|
|
18
|
-
component?: React.FunctionComponent<CustomRenderElementProps> | React.FunctionComponent<RenderLeafProps>;
|
|
19
|
-
}
|
|
20
|
-
export declare type CustomSlatePluginOptions = Record<string, CustomPluginOptions>;
|
|
21
24
|
declare module 'slate' {
|
|
22
25
|
interface CustomTypes {
|
|
23
26
|
Element: CustomElement;
|
|
27
|
+
Text: CustomText;
|
|
24
28
|
}
|
|
25
29
|
}
|
|
30
|
+
export interface RichTextPlugin extends PlatePlugin<RichTextEditor> {
|
|
31
|
+
/**
|
|
32
|
+
* @see createSoftBreakPlugin
|
|
33
|
+
*/
|
|
34
|
+
softBreak?: SoftBreakRule[];
|
|
35
|
+
/**
|
|
36
|
+
* @see createExitBreakPlugin
|
|
37
|
+
*/
|
|
38
|
+
exitBreak?: ExitBreakRule[];
|
|
39
|
+
/**
|
|
40
|
+
* @see createResetNodePlugin
|
|
41
|
+
*/
|
|
42
|
+
resetNode?: ResetNodePluginRule[];
|
|
43
|
+
/**
|
|
44
|
+
* @see createNormalizerPlugin
|
|
45
|
+
*/
|
|
46
|
+
normalizer?: NormalizerRule[];
|
|
47
|
+
}
|
|
48
|
+
export interface RichTextEditor extends PlateEditor {
|
|
49
|
+
tracking: TrackingPluginActions;
|
|
50
|
+
}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { Document } from '@contentful/rich-text-types';
|
|
2
|
+
export declare type OnValueChangedProps = {
|
|
3
|
+
editorId: string;
|
|
4
|
+
handler?: (value: Document) => unknown;
|
|
5
|
+
skip?: boolean;
|
|
6
|
+
onSkip?: VoidFunction;
|
|
7
|
+
};
|
|
8
|
+
export declare const useOnValueChanged: ({ editorId, handler, skip, onSkip }: OnValueChangedProps) => (value: unknown) => void;
|
package/package.json
CHANGED
|
@@ -1,9 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@contentful/field-editor-rich-text",
|
|
3
|
-
"version": "3.0.0
|
|
4
|
-
"publishConfig": {
|
|
5
|
-
"tag": "next"
|
|
6
|
-
},
|
|
3
|
+
"version": "3.0.0",
|
|
7
4
|
"source": "./src/index.tsx",
|
|
8
5
|
"main": "./dist/index.js",
|
|
9
6
|
"module": "dist/field-editor-rich-text.esm.js",
|
|
@@ -27,34 +24,38 @@
|
|
|
27
24
|
"prepublishOnly": "yarn build"
|
|
28
25
|
},
|
|
29
26
|
"dependencies": {
|
|
30
|
-
"@contentful/
|
|
31
|
-
"@contentful/
|
|
32
|
-
"@contentful/f36-
|
|
33
|
-
"@contentful/f36-
|
|
34
|
-
"@contentful/
|
|
35
|
-
"@contentful/field-editor-
|
|
36
|
-
"@contentful/
|
|
37
|
-
"@contentful/rich-text-
|
|
38
|
-
"@
|
|
39
|
-
"@
|
|
40
|
-
"@udecode/plate-
|
|
41
|
-
"@udecode/plate-
|
|
42
|
-
"@udecode/plate-
|
|
43
|
-
"@udecode/plate-list": "^
|
|
44
|
-
"@udecode/plate-paragraph": "^
|
|
45
|
-
"@udecode/plate-
|
|
46
|
-
"@udecode/plate-
|
|
27
|
+
"@contentful/app-sdk": "^4.6.0",
|
|
28
|
+
"@contentful/contentful-slatejs-adapter": "^15.13.1",
|
|
29
|
+
"@contentful/f36-components": "^4.0.33",
|
|
30
|
+
"@contentful/f36-icons": "^4.1.1",
|
|
31
|
+
"@contentful/f36-tokens": "^4.0.0",
|
|
32
|
+
"@contentful/field-editor-reference": "^5.0.0",
|
|
33
|
+
"@contentful/field-editor-shared": "^1.1.3",
|
|
34
|
+
"@contentful/rich-text-plain-text-renderer": "^15.12.1",
|
|
35
|
+
"@contentful/rich-text-types": "^15.12.1",
|
|
36
|
+
"@popperjs/core": "^2.11.5",
|
|
37
|
+
"@udecode/plate-basic-marks": "^10.4.0",
|
|
38
|
+
"@udecode/plate-break": "^10.4.0",
|
|
39
|
+
"@udecode/plate-core": "^10.4.0",
|
|
40
|
+
"@udecode/plate-list": "^10.4.0",
|
|
41
|
+
"@udecode/plate-paragraph": "^10.4.0",
|
|
42
|
+
"@udecode/plate-reset-node": "^10.4.0",
|
|
43
|
+
"@udecode/plate-select": "^10.4.0",
|
|
44
|
+
"@udecode/plate-serializer-docx": "^10.4.0",
|
|
45
|
+
"@udecode/plate-table": "^10.4.0",
|
|
46
|
+
"@udecode/plate-trailing-block": "^10.4.0",
|
|
47
47
|
"fast-deep-equal": "^3.1.3",
|
|
48
|
-
"
|
|
49
|
-
"
|
|
48
|
+
"is-hotkey": "^0.2.0",
|
|
49
|
+
"is-plain-obj": "^3.0.0",
|
|
50
|
+
"react-popper": "^2.3.0",
|
|
51
|
+
"slate": "^0.80.0",
|
|
50
52
|
"slate-history": "^0.66.0",
|
|
51
53
|
"slate-hyperscript": "^0.67.0",
|
|
52
|
-
"slate-react": "^0.
|
|
54
|
+
"slate-react": "^0.80.0"
|
|
53
55
|
},
|
|
54
56
|
"peerDependencies": {
|
|
55
57
|
"react": ">=16.14.0",
|
|
56
|
-
"react-dom": ">=16.14.0"
|
|
57
|
-
"slate": "^0.66.1"
|
|
58
|
+
"react-dom": ">=16.14.0"
|
|
58
59
|
},
|
|
59
60
|
"devDependencies": {
|
|
60
61
|
"@babel/core": "^7.9.6",
|
|
@@ -65,7 +66,11 @@
|
|
|
65
66
|
"@babel/plugin-transform-runtime": "^7.9.6",
|
|
66
67
|
"@babel/preset-env": "7.12.11",
|
|
67
68
|
"@babel/preset-react": "7.13.13",
|
|
68
|
-
"@contentful/field-editor-test-utils": "^1.
|
|
69
|
-
"@contentful/rich-text-react-renderer": "^15.
|
|
70
|
-
|
|
69
|
+
"@contentful/field-editor-test-utils": "^1.2.2",
|
|
70
|
+
"@contentful/rich-text-react-renderer": "^15.11.0",
|
|
71
|
+
"@types/is-hotkey": "^0.1.6",
|
|
72
|
+
"@udecode/plate-test-utils": "^3.2.0",
|
|
73
|
+
"react": ">=16.14.0"
|
|
74
|
+
},
|
|
75
|
+
"gitHead": "fc3ddd9d677de177af838ea8676d954ffa0c9563"
|
|
71
76
|
}
|
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
import * as React from 'react';
|
|
2
|
-
export declare type RichTextTrackingActionName = 'insertTable' | 'insertTableRow' | 'insertTableColumn' | 'removeTable' | 'removeTableRow' | 'removeTableColumn' | 'paste';
|
|
3
|
-
export declare type RichTextTrackingActionHandler = (name: RichTextTrackingActionName, data: Record<string, unknown>) => unknown;
|
|
4
|
-
interface TrackingProviderProps {
|
|
5
|
-
onAction: RichTextTrackingActionHandler;
|
|
6
|
-
}
|
|
7
|
-
export interface TrackingProvider {
|
|
8
|
-
onViewportAction: (actionName: RichTextTrackingActionName, data?: Record<string, unknown>) => ReturnType<TrackingProviderProps['onAction']>;
|
|
9
|
-
}
|
|
10
|
-
export declare const TrackingProvider: React.FC<TrackingProviderProps>, useTrackingContext: any;
|
|
11
|
-
export {};
|
|
@@ -1,3 +0,0 @@
|
|
|
1
|
-
import { Deserialize, GetNodeDeserializerRule } from '@udecode/plate-core';
|
|
2
|
-
export declare function deserializeLeaf(type: string, rules: GetNodeDeserializerRule[]): Deserialize;
|
|
3
|
-
export declare function deserializeElement(type: string, rules: GetNodeDeserializerRule[]): Deserialize;
|
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
import { BLOCKS, INLINES, Text } from '@contentful/rich-text-types';
|
|
2
|
-
import { TextOrCustomElement } from 'types';
|
|
3
|
-
declare type NodeType = BLOCKS | INLINES | Text['nodeType'];
|
|
4
|
-
/**
|
|
5
|
-
* Ensures "orphaned" text node elements (those without a parent capable of
|
|
6
|
-
* validly rendering a text child node) are wrapped with a suitable parent
|
|
7
|
-
* element to prevent failures on the validation layer.
|
|
8
|
-
*
|
|
9
|
-
* It is commonplace for third party plugins (including udecode) to reconcile
|
|
10
|
-
* deletion events by inserting such nodes into their schema. This
|
|
11
|
-
* subprocedure is intended as a guard against such cases.
|
|
12
|
-
*/
|
|
13
|
-
export declare function sanitizeSlateDoc(nodes?: TextOrCustomElement[], parentNodeType?: NodeType): TextOrCustomElement[];
|
|
14
|
-
/**
|
|
15
|
-
* Ensures incoming void nodes have a child leaf text element.
|
|
16
|
-
*/
|
|
17
|
-
export declare function sanitizeIncomingSlateDoc(nodes?: TextOrCustomElement[]): TextOrCustomElement[];
|
|
18
|
-
export {};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export declare function truncate(str: any, length: any): any;
|
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
/// <reference types="react" />
|
|
2
|
-
import * as Slate from 'slate-react';
|
|
3
|
-
import { PlatePlugin } from '@udecode/plate-core';
|
|
4
|
-
import { CustomSlatePluginOptions } from 'types';
|
|
5
|
-
interface ToolbarBoldButtonProps {
|
|
6
|
-
isDisabled?: boolean;
|
|
7
|
-
}
|
|
8
|
-
export declare function ToolbarBoldButton(props: ToolbarBoldButtonProps): JSX.Element | null;
|
|
9
|
-
export declare function Bold(props: Slate.RenderLeafProps): JSX.Element;
|
|
10
|
-
export declare function createBoldPlugin(): PlatePlugin;
|
|
11
|
-
export declare const withBoldOptions: CustomSlatePluginOptions;
|
|
12
|
-
export {};
|
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
/// <reference types="react" />
|
|
2
|
-
import * as Slate from 'slate-react';
|
|
3
|
-
import { PlatePlugin } from '@udecode/plate-core';
|
|
4
|
-
import { CustomSlatePluginOptions } from 'types';
|
|
5
|
-
interface ToolbarCodeButtonProps {
|
|
6
|
-
isDisabled?: boolean;
|
|
7
|
-
}
|
|
8
|
-
export declare function ToolbarCodeButton(props: ToolbarCodeButtonProps): JSX.Element | null;
|
|
9
|
-
export declare function Code(props: Slate.RenderLeafProps): JSX.Element;
|
|
10
|
-
export declare function createCodePlugin(): PlatePlugin;
|
|
11
|
-
export declare const withCodeOptions: CustomSlatePluginOptions;
|
|
12
|
-
export {};
|
|
@@ -1,37 +0,0 @@
|
|
|
1
|
-
export class InViewport extends React.Component<any, any, any> {
|
|
2
|
-
static defaultProps: {
|
|
3
|
-
testId: string;
|
|
4
|
-
offset: number;
|
|
5
|
-
};
|
|
6
|
-
constructor(props: any);
|
|
7
|
-
constructor(props: any, context: any);
|
|
8
|
-
tGetDomPosition: any;
|
|
9
|
-
nodeRef: any;
|
|
10
|
-
lastOverflowAt: any;
|
|
11
|
-
tOnOverflowTop: (...args: any[]) => any;
|
|
12
|
-
tOnOverflowBottom: (...args: any[]) => any;
|
|
13
|
-
tOnOverflowRight: (...args: any[]) => any;
|
|
14
|
-
tOnOverflowLeft: (...args: any[]) => any;
|
|
15
|
-
getDomPosition: () => void;
|
|
16
|
-
bindEventListeners: () => void;
|
|
17
|
-
handleOverflow: ({ top, left, bottom, right }: {
|
|
18
|
-
top: any;
|
|
19
|
-
left: any;
|
|
20
|
-
bottom: any;
|
|
21
|
-
right: any;
|
|
22
|
-
}, windowWidth: any, windowHeight: any) => void;
|
|
23
|
-
}
|
|
24
|
-
export namespace InViewport {
|
|
25
|
-
export namespace propTypes {
|
|
26
|
-
export const offset: PropTypes.Requireable<number>;
|
|
27
|
-
export const onOverflowTop: PropTypes.Requireable<(...args: any[]) => any>;
|
|
28
|
-
export const onOverflowRight: PropTypes.Requireable<(...args: any[]) => any>;
|
|
29
|
-
export const onOverflowBottom: PropTypes.Requireable<(...args: any[]) => any>;
|
|
30
|
-
export const onOverflowLeft: PropTypes.Requireable<(...args: any[]) => any>;
|
|
31
|
-
export const className: PropTypes.Requireable<string>;
|
|
32
|
-
export const children: PropTypes.Requireable<any>;
|
|
33
|
-
export const testId: PropTypes.Requireable<string>;
|
|
34
|
-
}
|
|
35
|
-
}
|
|
36
|
-
import React from "react";
|
|
37
|
-
import PropTypes from "prop-types";
|
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
/// <reference types="react" />
|
|
2
|
-
import { ContentEntityType as EntityType } from '@contentful/field-editor-reference/dist/types';
|
|
3
|
-
import { FieldExtensionSDK } from '@contentful/field-editor-shared';
|
|
4
|
-
interface EntryAssetTooltipProps {
|
|
5
|
-
id: string;
|
|
6
|
-
type: EntityType;
|
|
7
|
-
sdk: FieldExtensionSDK;
|
|
8
|
-
}
|
|
9
|
-
export declare function EntryAssetTooltip({ id, type, sdk }: EntryAssetTooltipProps): JSX.Element;
|
|
10
|
-
export {};
|
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
/// <reference types="react" />
|
|
2
|
-
import * as Slate from 'slate-react';
|
|
3
|
-
import { PlatePlugin } from '@udecode/plate-core';
|
|
4
|
-
import { CustomSlatePluginOptions } from '../../types';
|
|
5
|
-
interface ToolbarItalicButtonProps {
|
|
6
|
-
isDisabled?: boolean;
|
|
7
|
-
}
|
|
8
|
-
export declare function ToolbarItalicButton(props: ToolbarItalicButtonProps): JSX.Element | null;
|
|
9
|
-
export declare function Italic(props: Slate.RenderLeafProps): JSX.Element;
|
|
10
|
-
export declare function createItalicPlugin(): PlatePlugin;
|
|
11
|
-
export declare const withItalicOptions: CustomSlatePluginOptions;
|
|
12
|
-
export {};
|
|
@@ -1,6 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* A copy of Plate's list plugin with a few adjustments
|
|
3
|
-
* to fix pasting text inside lists.
|
|
4
|
-
*/
|
|
5
|
-
import { PlateEditor, TDescendant } from '@udecode/plate-core';
|
|
6
|
-
export declare const getListInsertFragment: (editor: PlateEditor) => (fragment: TDescendant[]) => void;
|
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
import { PlateEditor } from '@udecode/plate-core';
|
|
2
|
-
export declare type SanitizerTuple = [Document, PlateEditor];
|
|
3
|
-
declare type Predicate = (node: ChildNode) => boolean;
|
|
4
|
-
export declare const isHTMLElement: (node: ChildNode) => node is HTMLElement;
|
|
5
|
-
export declare const removeChildNodes: (node: ChildNode, predicate?: Predicate) => void;
|
|
6
|
-
export declare const removeChildNodesUsingPredicate: (predicate: Predicate) => (nodeList: NodeList) => Node[];
|
|
7
|
-
export {};
|
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
/// <reference types="react" />
|
|
2
|
-
import * as Slate from 'slate-react';
|
|
3
|
-
import { PlatePlugin } from '@udecode/plate-core';
|
|
4
|
-
import { CustomSlatePluginOptions } from 'types';
|
|
5
|
-
interface ToolbarUnderlineButtonProps {
|
|
6
|
-
isDisabled?: boolean;
|
|
7
|
-
}
|
|
8
|
-
export declare function ToolbarUnderlineButton(props: ToolbarUnderlineButtonProps): JSX.Element | null;
|
|
9
|
-
export declare function Underline(props: Slate.RenderLeafProps): JSX.Element;
|
|
10
|
-
export declare function createUnderlinePlugin(): PlatePlugin;
|
|
11
|
-
export declare const withUnderlineOptions: CustomSlatePluginOptions;
|
|
12
|
-
export {};
|
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
/// <reference types="react" />
|
|
2
|
-
import { Entry, Asset } from '@contentful/field-editor-shared';
|
|
3
|
-
interface EntityStatusIconProps {
|
|
4
|
-
entity: Entry | Asset;
|
|
5
|
-
entityType: 'Entry' | 'Asset';
|
|
6
|
-
}
|
|
7
|
-
export declare function EntityStatusIcon({ entity, entityType }: EntityStatusIconProps): JSX.Element;
|
|
8
|
-
export {};
|