@udecode/plate-indent
Advanced tools
Comparing version 24.2.0 to 24.3.0
@@ -0,11 +1,823 @@ | ||
import { Scope } from 'jotai/core/atom'; | ||
import React__default, { FC, ReactNode, KeyboardEvent, ClipboardEvent, CompositionEvent, FocusEvent, FormEvent, SyntheticEvent, MouseEvent, DragEvent, TouchEvent, PointerEvent, UIEvent, WheelEvent, AnimationEvent, TransitionEvent, CSSProperties, ForwardedRef } from 'react'; | ||
import { Value as Value$1, TEditor, THistoryEditor, TRange, TElement as TElement$1, EElement, EElementOrText, TText as TText$1, EText, TRenderLeafProps, ENodeEntry, TNodeEntry, RenderLeafFn } from '@udecode/slate'; | ||
import { AnyObject, WithRequired, UnknownObject } from '@udecode/utils'; | ||
import { TReactEditor } from '@udecode/slate-react'; | ||
import { Path, Range } from 'slate'; | ||
import { RenderElementProps } from 'slate-react'; | ||
import { EditableProps } from 'slate-react/dist/components/editable'; | ||
import { TElement as TElement$2, Value as Value$2, PlateEditor as PlateEditor$1, KeyboardHandlerReturnType, WithPlatePlugin as WithPlatePlugin$1, GetNodeEntriesOptions, UnhangRangeOptions, AnyObject as AnyObject$1 } from '@udecode/plate-common'; | ||
type SetRecord<O> = { | ||
[K in keyof O]: (scope?: Scope) => (value: O[K]) => void; | ||
}; | ||
/** | ||
* @file Automatically generated by barrelsby. | ||
* A unique id used as a provider scope. | ||
* Use it if you have multiple `Plate` in the same React tree. | ||
* @default PLATE_SCOPE | ||
*/ | ||
export * from './createIndentPlugin'; | ||
export * from './createTextIndentPlugin'; | ||
export * from './onKeyDownIndent'; | ||
export * from './types'; | ||
export * from './withIndent'; | ||
export * from './hooks/index'; | ||
export * from './transforms/index'; | ||
//# sourceMappingURL=index.d.ts.map | ||
type PlateId = string; | ||
type NoInfer<T> = [T][T extends any ? 0 : never]; | ||
type Nullable<T> = { | ||
[P in keyof T]: T[P] | null; | ||
}; | ||
/** | ||
* If true, the next handlers will be skipped. | ||
*/ | ||
type HandlerReturnType = boolean | void; | ||
type DOMHandlerReturnType<EV = {}> = (event: EV) => HandlerReturnType; | ||
type DOMHandler<P = PluginOptions, V extends Value$1 = Value$1, E extends PlateEditor<V> = PlateEditor<V>, EV = {}> = (editor: E, plugin: WithPlatePlugin<P, V, E>) => DOMHandlerReturnType<EV>; | ||
interface DOMHandlers<P = PluginOptions, V extends Value$1 = Value$1, E extends PlateEditor<V> = PlateEditor<V>> { | ||
onCopy?: DOMHandler<P, V, E, ClipboardEvent>; | ||
onCopyCapture?: DOMHandler<P, V, E, ClipboardEvent>; | ||
onCut?: DOMHandler<P, V, E, ClipboardEvent>; | ||
onCutCapture?: DOMHandler<P, V, E, ClipboardEvent>; | ||
onPaste?: DOMHandler<P, V, E, ClipboardEvent>; | ||
onPasteCapture?: DOMHandler<P, V, E, ClipboardEvent>; | ||
onCompositionEnd?: DOMHandler<P, V, E, CompositionEvent>; | ||
onCompositionEndCapture?: DOMHandler<P, V, E, CompositionEvent>; | ||
onCompositionStart?: DOMHandler<P, V, E, CompositionEvent>; | ||
onCompositionStartCapture?: DOMHandler<P, V, E, CompositionEvent>; | ||
onCompositionUpdate?: DOMHandler<P, V, E, CompositionEvent>; | ||
onCompositionUpdateCapture?: DOMHandler<P, V, E, CompositionEvent>; | ||
onFocus?: DOMHandler<P, V, E, FocusEvent>; | ||
onFocusCapture?: DOMHandler<P, V, E, FocusEvent>; | ||
onBlur?: DOMHandler<P, V, E, FocusEvent>; | ||
onBlurCapture?: DOMHandler<P, V, E, FocusEvent>; | ||
onDOMBeforeInput?: DOMHandler<P, V, E, Event>; | ||
onBeforeInput?: DOMHandler<P, V, E, FormEvent>; | ||
onBeforeInputCapture?: DOMHandler<P, V, E, FormEvent>; | ||
onInput?: DOMHandler<P, V, E, FormEvent>; | ||
onInputCapture?: DOMHandler<P, V, E, FormEvent>; | ||
onReset?: DOMHandler<P, V, E, FormEvent>; | ||
onResetCapture?: DOMHandler<P, V, E, FormEvent>; | ||
onSubmit?: DOMHandler<P, V, E, FormEvent>; | ||
onSubmitCapture?: DOMHandler<P, V, E, FormEvent>; | ||
onInvalid?: DOMHandler<P, V, E, FormEvent>; | ||
onInvalidCapture?: DOMHandler<P, V, E, FormEvent>; | ||
onLoad?: DOMHandler<P, V, E, SyntheticEvent>; | ||
onLoadCapture?: DOMHandler<P, V, E, SyntheticEvent>; | ||
onKeyDown?: DOMHandler<P, V, E, KeyboardEvent>; | ||
onKeyDownCapture?: DOMHandler<P, V, E, KeyboardEvent>; | ||
onKeyPress?: DOMHandler<P, V, E, KeyboardEvent>; | ||
onKeyPressCapture?: DOMHandler<P, V, E, KeyboardEvent>; | ||
onKeyUp?: DOMHandler<P, V, E, KeyboardEvent>; | ||
onKeyUpCapture?: DOMHandler<P, V, E, KeyboardEvent>; | ||
onAbort?: DOMHandler<P, V, E, SyntheticEvent>; | ||
onAbortCapture?: DOMHandler<P, V, E, SyntheticEvent>; | ||
onCanPlay?: DOMHandler<P, V, E, SyntheticEvent>; | ||
onCanPlayCapture?: DOMHandler<P, V, E, SyntheticEvent>; | ||
onCanPlayThrough?: DOMHandler<P, V, E, SyntheticEvent>; | ||
onCanPlayThroughCapture?: DOMHandler<P, V, E, SyntheticEvent>; | ||
onDurationChange?: DOMHandler<P, V, E, SyntheticEvent>; | ||
onDurationChangeCapture?: DOMHandler<P, V, E, SyntheticEvent>; | ||
onEmptied?: DOMHandler<P, V, E, SyntheticEvent>; | ||
onEmptiedCapture?: DOMHandler<P, V, E, SyntheticEvent>; | ||
onEncrypted?: DOMHandler<P, V, E, SyntheticEvent>; | ||
onEncryptedCapture?: DOMHandler<P, V, E, SyntheticEvent>; | ||
onEnded?: DOMHandler<P, V, E, SyntheticEvent>; | ||
onEndedCapture?: DOMHandler<P, V, E, SyntheticEvent>; | ||
onLoadedData?: DOMHandler<P, V, E, SyntheticEvent>; | ||
onLoadedDataCapture?: DOMHandler<P, V, E, SyntheticEvent>; | ||
onLoadedMetadata?: DOMHandler<P, V, E, SyntheticEvent>; | ||
onLoadedMetadataCapture?: DOMHandler<P, V, E, SyntheticEvent>; | ||
onLoadStart?: DOMHandler<P, V, E, SyntheticEvent>; | ||
onLoadStartCapture?: DOMHandler<P, V, E, SyntheticEvent>; | ||
onPause?: DOMHandler<P, V, E, SyntheticEvent>; | ||
onPauseCapture?: DOMHandler<P, V, E, SyntheticEvent>; | ||
onPlay?: DOMHandler<P, V, E, SyntheticEvent>; | ||
onPlayCapture?: DOMHandler<P, V, E, SyntheticEvent>; | ||
onPlaying?: DOMHandler<P, V, E, SyntheticEvent>; | ||
onPlayingCapture?: DOMHandler<P, V, E, SyntheticEvent>; | ||
onProgress?: DOMHandler<P, V, E, SyntheticEvent>; | ||
onProgressCapture?: DOMHandler<P, V, E, SyntheticEvent>; | ||
onRateChange?: DOMHandler<P, V, E, SyntheticEvent>; | ||
onRateChangeCapture?: DOMHandler<P, V, E, SyntheticEvent>; | ||
onSeeked?: DOMHandler<P, V, E, SyntheticEvent>; | ||
onSeekedCapture?: DOMHandler<P, V, E, SyntheticEvent>; | ||
onSeeking?: DOMHandler<P, V, E, SyntheticEvent>; | ||
onSeekingCapture?: DOMHandler<P, V, E, SyntheticEvent>; | ||
onStalled?: DOMHandler<P, V, E, SyntheticEvent>; | ||
onStalledCapture?: DOMHandler<P, V, E, SyntheticEvent>; | ||
onSuspend?: DOMHandler<P, V, E, SyntheticEvent>; | ||
onSuspendCapture?: DOMHandler<P, V, E, SyntheticEvent>; | ||
onTimeUpdate?: DOMHandler<P, V, E, SyntheticEvent>; | ||
onTimeUpdateCapture?: DOMHandler<P, V, E, SyntheticEvent>; | ||
onVolumeChange?: DOMHandler<P, V, E, SyntheticEvent>; | ||
onVolumeChangeCapture?: DOMHandler<P, V, E, SyntheticEvent>; | ||
onWaiting?: DOMHandler<P, V, E, SyntheticEvent>; | ||
onWaitingCapture?: DOMHandler<P, V, E, SyntheticEvent>; | ||
onAuxClick?: DOMHandler<P, V, E, MouseEvent>; | ||
onAuxClickCapture?: DOMHandler<P, V, E, MouseEvent>; | ||
onClick?: DOMHandler<P, V, E, MouseEvent>; | ||
onClickCapture?: DOMHandler<P, V, E, MouseEvent>; | ||
onContextMenu?: DOMHandler<P, V, E, MouseEvent>; | ||
onContextMenuCapture?: DOMHandler<P, V, E, MouseEvent>; | ||
onDoubleClick?: DOMHandler<P, V, E, MouseEvent>; | ||
onDoubleClickCapture?: DOMHandler<P, V, E, MouseEvent>; | ||
onDrag?: DOMHandler<P, V, E, DragEvent>; | ||
onDragCapture?: DOMHandler<P, V, E, DragEvent>; | ||
onDragEnd?: DOMHandler<P, V, E, DragEvent>; | ||
onDragEndCapture?: DOMHandler<P, V, E, DragEvent>; | ||
onDragEnter?: DOMHandler<P, V, E, DragEvent>; | ||
onDragEnterCapture?: DOMHandler<P, V, E, DragEvent>; | ||
onDragExit?: DOMHandler<P, V, E, DragEvent>; | ||
onDragExitCapture?: DOMHandler<P, V, E, DragEvent>; | ||
onDragLeave?: DOMHandler<P, V, E, DragEvent>; | ||
onDragLeaveCapture?: DOMHandler<P, V, E, DragEvent>; | ||
onDragOver?: DOMHandler<P, V, E, DragEvent>; | ||
onDragOverCapture?: DOMHandler<P, V, E, DragEvent>; | ||
onDragStart?: DOMHandler<P, V, E, DragEvent>; | ||
onDragStartCapture?: DOMHandler<P, V, E, DragEvent>; | ||
onDrop?: DOMHandler<P, V, E, DragEvent>; | ||
onDropCapture?: DOMHandler<P, V, E, DragEvent>; | ||
onMouseDown?: DOMHandler<P, V, E, MouseEvent>; | ||
onMouseDownCapture?: DOMHandler<P, V, E, MouseEvent>; | ||
onMouseEnter?: DOMHandler<P, V, E, MouseEvent>; | ||
onMouseLeave?: DOMHandler<P, V, E, MouseEvent>; | ||
onMouseMove?: DOMHandler<P, V, E, MouseEvent>; | ||
onMouseMoveCapture?: DOMHandler<P, V, E, MouseEvent>; | ||
onMouseOut?: DOMHandler<P, V, E, MouseEvent>; | ||
onMouseOutCapture?: DOMHandler<P, V, E, MouseEvent>; | ||
onMouseOver?: DOMHandler<P, V, E, MouseEvent>; | ||
onMouseOverCapture?: DOMHandler<P, V, E, MouseEvent>; | ||
onMouseUp?: DOMHandler<P, V, E, MouseEvent>; | ||
onMouseUpCapture?: DOMHandler<P, V, E, MouseEvent>; | ||
onSelect?: DOMHandler<P, V, E, SyntheticEvent>; | ||
onSelectCapture?: DOMHandler<P, V, E, SyntheticEvent>; | ||
onTouchCancel?: DOMHandler<P, V, E, TouchEvent>; | ||
onTouchCancelCapture?: DOMHandler<P, V, E, TouchEvent>; | ||
onTouchEnd?: DOMHandler<P, V, E, TouchEvent>; | ||
onTouchEndCapture?: DOMHandler<P, V, E, TouchEvent>; | ||
onTouchMove?: DOMHandler<P, V, E, TouchEvent>; | ||
onTouchMoveCapture?: DOMHandler<P, V, E, TouchEvent>; | ||
onTouchStart?: DOMHandler<P, V, E, TouchEvent>; | ||
onTouchStartCapture?: DOMHandler<P, V, E, TouchEvent>; | ||
onPointerDown?: DOMHandler<P, V, E, PointerEvent>; | ||
onPointerDownCapture?: DOMHandler<P, V, E, PointerEvent>; | ||
onPointerMove?: DOMHandler<P, V, E, PointerEvent>; | ||
onPointerMoveCapture?: DOMHandler<P, V, E, PointerEvent>; | ||
onPointerUp?: DOMHandler<P, V, E, PointerEvent>; | ||
onPointerUpCapture?: DOMHandler<P, V, E, PointerEvent>; | ||
onPointerCancel?: DOMHandler<P, V, E, PointerEvent>; | ||
onPointerCancelCapture?: DOMHandler<P, V, E, PointerEvent>; | ||
onPointerEnter?: DOMHandler<P, V, E, PointerEvent>; | ||
onPointerEnterCapture?: DOMHandler<P, V, E, PointerEvent>; | ||
onPointerLeave?: DOMHandler<P, V, E, PointerEvent>; | ||
onPointerLeaveCapture?: DOMHandler<P, V, E, PointerEvent>; | ||
onPointerOver?: DOMHandler<P, V, E, PointerEvent>; | ||
onPointerOverCapture?: DOMHandler<P, V, E, PointerEvent>; | ||
onPointerOut?: DOMHandler<P, V, E, PointerEvent>; | ||
onPointerOutCapture?: DOMHandler<P, V, E, PointerEvent>; | ||
onGotPointerCapture?: DOMHandler<P, V, E, PointerEvent>; | ||
onGotPointerCaptureCapture?: DOMHandler<P, V, E, PointerEvent>; | ||
onLostPointerCapture?: DOMHandler<P, V, E, PointerEvent>; | ||
onLostPointerCaptureCapture?: DOMHandler<P, V, E, PointerEvent>; | ||
onScroll?: DOMHandler<P, V, E, UIEvent>; | ||
onScrollCapture?: DOMHandler<P, V, E, UIEvent>; | ||
onWheel?: DOMHandler<P, V, E, WheelEvent>; | ||
onWheelCapture?: DOMHandler<P, V, E, WheelEvent>; | ||
onAnimationStart?: DOMHandler<P, V, E, AnimationEvent>; | ||
onAnimationStartCapture?: DOMHandler<P, V, E, AnimationEvent>; | ||
onAnimationEnd?: DOMHandler<P, V, E, AnimationEvent>; | ||
onAnimationEndCapture?: DOMHandler<P, V, E, AnimationEvent>; | ||
onAnimationIteration?: DOMHandler<P, V, E, AnimationEvent>; | ||
onAnimationIterationCapture?: DOMHandler<P, V, E, AnimationEvent>; | ||
onTransitionEnd?: DOMHandler<P, V, E, TransitionEvent>; | ||
onTransitionEndCapture?: DOMHandler<P, V, E, TransitionEvent>; | ||
} | ||
type DecorateEntry<V extends Value$1 = Value$1> = (entry: ENodeEntry<V>) => Range[] | undefined; | ||
/** | ||
* Property used by Plate to decorate editor ranges. | ||
* If the function returns undefined then no ranges are modified. | ||
* If the function returns an array the returned ranges are merged with the ranges called by other plugins. | ||
*/ | ||
type Decorate<P = PluginOptions, V extends Value$1 = Value$1, E extends PlateEditor<V> = PlateEditor<V>> = (editor: PlateEditor<V>, plugin: WithPlatePlugin<P, V, E>) => DecorateEntry<V>; | ||
type DeserializeHtml = { | ||
/** | ||
* List of HTML attribute names to store their values in `node.attributes`. | ||
*/ | ||
attributeNames?: string[]; | ||
/** | ||
* Deserialize an element. | ||
* Use this instead of plugin.isElement if you don't want the plugin to renderElement. | ||
* @default plugin.isElement | ||
*/ | ||
isElement?: boolean; | ||
/** | ||
* Deserialize a leaf. | ||
* Use this instead of plugin.isLeaf if you don't want the plugin to renderLeaf. | ||
* @default plugin.isLeaf | ||
*/ | ||
isLeaf?: boolean; | ||
/** | ||
* Deserialize html element to slate node. | ||
*/ | ||
getNode?: (element: HTMLElement, node: AnyObject) => AnyObject | undefined | void; | ||
query?: (element: HTMLElement) => boolean; | ||
rules?: { | ||
/** | ||
* Deserialize an element: | ||
* - if this option (string) is in the element attribute names. | ||
* - if this option (object) values match the element attributes. | ||
*/ | ||
validAttribute?: string | { | ||
[key: string]: string | string[]; | ||
}; | ||
/** | ||
* Valid element `className`. | ||
*/ | ||
validClassName?: string; | ||
/** | ||
* Valid element `nodeName`. | ||
* Set '*' to allow any node name. | ||
*/ | ||
validNodeName?: string | string[]; | ||
/** | ||
* Valid element style values. | ||
* Can be a list of string (only one match is needed). | ||
*/ | ||
validStyle?: Partial<Record<keyof CSSStyleDeclaration, string | string[] | undefined>>; | ||
}[]; | ||
/** | ||
* Whether or not to include deserialized children on this node | ||
*/ | ||
withoutChildren?: boolean; | ||
}; | ||
type TRenderElementProps<V extends Value$1 = Value$1, N extends TElement$1 = EElement<V>> = Omit<RenderElementProps, 'element'> & { | ||
element: N; | ||
}; | ||
type RenderElementFn = (props: TRenderElementProps) => React.ReactElement; | ||
/** | ||
* Element props passed by Plate | ||
*/ | ||
type PlateRenderElementProps<V extends Value$1 = Value$1, N extends TElement$1 = EElement<V>> = PlateRenderNodeProps<V> & TRenderElementProps<V, N>; | ||
interface InjectComponentProps<V extends Value$1 = Value$1> extends PlateRenderElementProps<V> { | ||
key: string; | ||
} | ||
type InjectComponentReturnType<V extends Value$1 = Value$1> = React__default.FC<PlateRenderElementProps<V>> | undefined; | ||
type InjectComponent<V extends Value$1 = Value$1> = (props: InjectComponentProps<V>) => InjectComponentReturnType; | ||
interface GetInjectPropsOptions<V extends Value$1 = Value$1> { | ||
/** | ||
* Existing className. | ||
*/ | ||
className?: string; | ||
/** | ||
* Style value or className key. | ||
*/ | ||
element?: EElement<V>; | ||
/** | ||
* Style value or className key. | ||
*/ | ||
text?: EText<V>; | ||
/** | ||
* Existing style. | ||
*/ | ||
style?: CSSProperties; | ||
} | ||
interface GetInjectPropsReturnType extends AnyObject { | ||
className?: string; | ||
style?: CSSProperties; | ||
} | ||
interface TransformOptions<V extends Value$1 = Value$1> extends GetInjectPropsOptions<V> { | ||
nodeValue?: any; | ||
value?: any; | ||
} | ||
interface InjectProps<V extends Value$1> { | ||
inject?: { | ||
/** | ||
* Properties used by Plate to inject props into any node `component`. | ||
*/ | ||
props?: { | ||
/** | ||
* Object whose keys are node values and values are classNames which will be extended. | ||
*/ | ||
classNames?: AnyObject; | ||
/** | ||
* Default node value. | ||
* The node key would be unset if the node value = defaultNodeValue. | ||
*/ | ||
defaultNodeValue?: any; | ||
/** | ||
* Node key to map to the styles. | ||
*/ | ||
nodeKey?: string; | ||
/** | ||
* Whether to inject the props. If true, overrides all other checks. | ||
*/ | ||
query?: (options: NonNullable<NonNullable<InjectProps<V>['inject']>['props']>, nodeProps: GetInjectPropsOptions<V>) => boolean; | ||
/** | ||
* Style key to override. | ||
* @default nodeKey | ||
*/ | ||
styleKey?: keyof CSSProperties; | ||
/** | ||
* Transform the className. | ||
* @default clsx(className, classNames[value]) | ||
*/ | ||
transformClassName?: (options: TransformOptions<V>) => any; | ||
/** | ||
* Transform the node value for the style or className. | ||
* @default nodeValue | ||
*/ | ||
transformNodeValue?: (options: TransformOptions<V>) => any; | ||
/** | ||
* Transform the injected props. | ||
*/ | ||
transformProps?: (options: TransformOptions<V>, props: GetInjectPropsReturnType) => AnyObject | undefined; | ||
/** | ||
* Transform the style. | ||
* @default { ...style, [styleKey]: value } | ||
*/ | ||
transformStyle?: (options: TransformOptions<V>) => CSSProperties; | ||
/** | ||
* List of supported node values. | ||
*/ | ||
validNodeValues?: any[]; | ||
/** | ||
* Node types required to inject the props. | ||
* @default [ELEMENT_DEFAULT] | ||
*/ | ||
validTypes?: string[]; | ||
}; | ||
}; | ||
} | ||
/** | ||
* Function called whenever a change occurs in the editor. | ||
* Return `false` to prevent calling the next plugin handler. | ||
* @see {@link SlatePropsOnChange} | ||
*/ | ||
type OnChange<P = PluginOptions, V extends Value$1 = Value$1, E extends PlateEditor<V> = PlateEditor<V>> = (editor: E, plugin: WithPlatePlugin<P, V, E>) => (value: V) => HandlerReturnType; | ||
/** | ||
* The plate plugin component. | ||
*/ | ||
type PlatePluginComponent<T = any> = React__default.FC<T>; | ||
type PlatePluginInsertDataOptions = { | ||
data: string; | ||
dataTransfer: DataTransfer; | ||
}; | ||
type PlatePluginInsertData<V extends Value$1 = Value$1> = { | ||
/** | ||
* Format to get data. Example data types are text/plain and text/uri-list. | ||
*/ | ||
format?: string; | ||
/** | ||
* Query to skip this plugin. | ||
*/ | ||
query?: (options: PlatePluginInsertDataOptions) => boolean; | ||
/** | ||
* Deserialize data to fragment | ||
*/ | ||
getFragment?: (options: PlatePluginInsertDataOptions) => EElementOrText<V>[] | undefined; | ||
/** | ||
* Function called on `editor.insertData` just before `editor.insertFragment`. | ||
* Default: if the block above the selection is empty and the first fragment node type is not inline, | ||
* set the selected node type to the first fragment node type. | ||
* @return if true, the next handlers will be skipped. | ||
*/ | ||
preInsert?: (fragment: EElementOrText<V>[], options: PlatePluginInsertDataOptions) => HandlerReturnType; | ||
/** | ||
* Transform the inserted data. | ||
*/ | ||
transformData?: (data: string, options: { | ||
dataTransfer: DataTransfer; | ||
}) => string; | ||
/** | ||
* Transform the fragment to insert. | ||
*/ | ||
transformFragment?: (fragment: EElementOrText<V>[], options: PlatePluginInsertDataOptions) => EElementOrText<V>[]; | ||
}; | ||
/** | ||
* Unique key to store the plugins by key. | ||
*/ | ||
type PluginKey = string; | ||
interface PlatePluginKey { | ||
/** | ||
* Property used by Plate to store the plugins by key in `editor.pluginsByKey`. | ||
*/ | ||
key?: PluginKey; | ||
} | ||
/** | ||
* Props object or function returning props object. | ||
*/ | ||
type PlatePluginProps<V extends Value$1 = Value$1> = AnyObject | ((props: PlateRenderElementProps<V> & PlateRenderLeafProps<V>) => AnyObject | undefined); | ||
/** | ||
* `EditableProps` are passed to the <Editable> component. | ||
*/ | ||
type TEditableProps = Omit<EditableProps, 'decorate' | 'renderElement' | 'renderLeaf'> & { | ||
decorate?: (entry: TNodeEntry) => Range[]; | ||
renderElement?: RenderElementFn; | ||
renderLeaf?: RenderLeafFn; | ||
}; | ||
type RenderAfterEditable = (editableProps: TEditableProps) => React.ReactElement | null; | ||
type SerializeHtml<V extends Value$1 = Value$1> = React__default.FC<PlateRenderElementProps<V> & PlateRenderLeafProps<V>>; | ||
/** | ||
* Plate plugin overriding the `editor` methods. | ||
* Naming convention is `with*`. | ||
*/ | ||
type WithOverride<P = PluginOptions, V extends Value$1 = Value$1, E extends PlateEditor<V> = PlateEditor<V>, EE extends E = E> = (editor: E, plugin: WithPlatePlugin<P, V, E>) => EE; | ||
/** | ||
* The `PlatePlugin` interface is a base interface for all plugins. | ||
*/ | ||
type PlatePlugin<P = PluginOptions, V extends Value$1 = Value$1, E extends PlateEditor<V> = PlateEditor<V>> = Required<PlatePluginKey> & { | ||
editor?: Nullable<{ | ||
/** | ||
* Properties used by the `insertData` core plugin to deserialize inserted data to a slate fragment. | ||
* The fragment will be inserted to the editor if not empty. | ||
*/ | ||
insertData?: PlatePluginInsertData<V>; | ||
}>; | ||
/** | ||
* Handlers called whenever the corresponding event occurs in the editor. | ||
* Event handlers can return a boolean flag to specify whether the event can be treated as being handled. | ||
* If it returns `true`, the next handlers will not be called. | ||
*/ | ||
handlers?: Nullable<DOMHandlers<P, V, E> & { | ||
/** | ||
* @see {@link OnChange} | ||
*/ | ||
onChange?: OnChange<P, V, E>; | ||
}>; | ||
/** | ||
* Inject into Plate. | ||
*/ | ||
inject?: Nullable<{ | ||
/** | ||
* Property used by Plate to inject a component above other plugins `component`. | ||
*/ | ||
aboveComponent?: InjectComponent<V>; | ||
/** | ||
* Property used by Plate to inject a component below other plugins `component`, i.e. above its `children`. | ||
*/ | ||
belowComponent?: InjectComponent<V>; | ||
/** | ||
* Property that can be used by a plugin to allow other plugins to inject code. | ||
* For example, if multiple plugins have defined | ||
* `inject.editor.insertData.transformData` for `key=KEY_DESERIALIZE_HTML`, | ||
* `insertData` plugin will call all of these `transformData` for `KEY_DESERIALIZE_HTML` plugin. | ||
* Differs from `overrideByKey` as this is not overriding any plugin. | ||
*/ | ||
pluginsByKey?: Record<PluginKey, Partial<PlatePlugin<PluginOptions, V, E>>>; | ||
}>; | ||
/** | ||
* Property used by Plate to render nodes of this `type` as elements, i.e. `renderElement`. | ||
*/ | ||
isElement?: boolean; | ||
/** | ||
* Property used by `inlineVoid` core plugin to set elements of this `type` as inline. | ||
*/ | ||
isInline?: boolean; | ||
/** | ||
* Property used by `isMarkableVoid` core plugin to set void elements of this `type` as markable. | ||
*/ | ||
isMarkableVoid?: boolean; | ||
/** | ||
* Property used by Plate to render nodes of this `type` as leaves, i.e. `renderLeaf`. | ||
*/ | ||
isLeaf?: boolean; | ||
/** | ||
* Property used by `inlineVoid` core plugin to set elements of this `type` as void. | ||
*/ | ||
isVoid?: boolean; | ||
/** | ||
* Property used by Plate to enable/disable the plugin. | ||
*/ | ||
enabled?: boolean; | ||
/** | ||
* Extended properties used by any plugin as options. | ||
*/ | ||
options?: P; | ||
/** | ||
* Property used by Plate to render a node by type. | ||
* It requires slate node properties to have a `type` property. | ||
* @default key | ||
*/ | ||
type?: string; | ||
} & InjectProps<V> & Nullable<{ | ||
/** | ||
* React component rendering a slate element or leaf. | ||
* @default DefaultElement | DefaultLeaf | ||
*/ | ||
component?: PlatePluginComponent; | ||
/** | ||
* @see {@link Decorate} | ||
*/ | ||
decorate?: Decorate<P, V, E>; | ||
/** | ||
* Properties used by the HTML deserializer core plugin for each HTML element. | ||
*/ | ||
deserializeHtml?: Nullable<DeserializeHtml>; | ||
/** | ||
* Normalize initial value before passing it into the editor. | ||
* @return normalized value | ||
*/ | ||
normalizeInitialValue?: (initialValue: V) => V; | ||
/** | ||
* Property used by Plate to deeply override plugins by key. | ||
*/ | ||
overrideByKey?: Record<PluginKey, Partial<PlatePlugin<PluginOptions, V, E>>>; | ||
/** | ||
* Recursive plugin support to allow having multiple plugins in a single plugin. | ||
* Plate eventually flattens all the plugins into the editor. | ||
*/ | ||
plugins?: PlatePlugin<PluginOptions, V, E>[]; | ||
/** | ||
* Property used by Plate to override node `component` props. | ||
* If function, its returning value will be shallow merged to the old props, with the old props as parameter. | ||
* If object, its value will be shallow merged to the old props. | ||
*/ | ||
props?: PlatePluginProps<V>; | ||
/** | ||
* Render a component above `Editable`. | ||
*/ | ||
renderAboveEditable?: FC<{ | ||
children: ReactNode; | ||
}>; | ||
/** | ||
* Render a component above `Slate`. | ||
*/ | ||
renderAboveSlate?: FC<{ | ||
children: ReactNode; | ||
}>; | ||
/** | ||
* Render a component after `Editable`. | ||
*/ | ||
renderAfterEditable?: RenderAfterEditable; | ||
/** | ||
* Render a component before `Editable`. | ||
*/ | ||
renderBeforeEditable?: RenderAfterEditable; | ||
/** | ||
* Property used by `serializeHtml` util to replace `renderElement` and `renderLeaf` when serializing a node of this `type`. | ||
*/ | ||
serializeHtml?: SerializeHtml<V>; | ||
/** | ||
* Recursive plugin merging. | ||
* Can be used to derive plugin fields from `editor` and `plugin`. | ||
* The returned value will be deeply merged to the plugin. | ||
*/ | ||
then?: (editor: E, plugin: WithPlatePlugin<P, V, E>) => Partial<PlatePlugin<P, V, E>> | void; | ||
/** | ||
* For internal use. Tracks if then has been replaced for recursive calls. | ||
*/ | ||
_thenReplaced?: number; | ||
/** | ||
* Hook called when the editor is initialized. | ||
*/ | ||
useHooks?: (editor: E, plugin: WithPlatePlugin<P, V, E>) => void; | ||
/** | ||
* Editor method overriders. | ||
*/ | ||
withOverrides?: WithOverride<P, V, E>; | ||
}>; | ||
type PluginOptions = AnyObject; | ||
type WithPlatePlugin<P = PluginOptions, V extends Value$1 = Value$1, E extends PlateEditor<V> = PlateEditor<V>> = WithRequired<PlatePlugin<P, V, E>, 'type' | 'options' | 'inject' | 'editor'>; | ||
type OverrideByKey<V extends Value$1 = Value$1, E extends PlateEditor<V> = PlateEditor<V>> = Record<PluginKey, Partial<PlatePlugin<{}, V, E>>>; | ||
type PlateStoreState<V extends Value$1 = Value$1, E extends PlateEditor<V> = PlateEditor<V>> = { | ||
/** | ||
* A unique id used as a provider scope. | ||
* Use it if you have multiple `Plate` in the same React tree. | ||
* @default PLATE_SCOPE | ||
*/ | ||
id: PlateId; | ||
/** | ||
* Slate editor reference. | ||
* @default pipe(createTEditor(), withPlate({ id, plugins, options, components })) | ||
*/ | ||
editor: E; | ||
/** | ||
* Plugins prop passed to `Plate`. | ||
*/ | ||
rawPlugins: PlatePlugin<PluginOptions, V, E>[]; | ||
readOnly: boolean; | ||
/** | ||
* Flattened plugins. | ||
*/ | ||
plugins: WithPlatePlugin<PluginOptions, V, E>[]; | ||
/** | ||
* Value of the editor. | ||
* @default [{ type: 'p', children: [{ text: '' }]}] | ||
*/ | ||
value: V; | ||
} & Nullable<{ | ||
/** | ||
* Whether `Editable` is rendered so slate DOM is resolvable. | ||
*/ | ||
isMounted: boolean; | ||
/** | ||
* Version incremented on each editor change. | ||
*/ | ||
versionEditor: number; | ||
/** | ||
* Version incremented on each editor.selection change. | ||
*/ | ||
versionSelection: number; | ||
/** | ||
* Version incremented when calling `redecorate`. | ||
* This is a dependency of the `decorate` function. | ||
*/ | ||
versionDecorate: number; | ||
/** | ||
* Controlled callback called when the editor state changes. | ||
*/ | ||
onChange: { | ||
fn: (value: V) => void; | ||
}; | ||
/** | ||
* Access the editor object using a React ref. | ||
*/ | ||
editorRef: { | ||
ref: ForwardedRef<E>; | ||
}; | ||
decorate: { | ||
fn: NonNullable<TEditableProps['decorate']>; | ||
}; | ||
renderElement: { | ||
fn: NonNullable<TEditableProps['renderElement']>; | ||
}; | ||
renderLeaf: { | ||
fn: NonNullable<TEditableProps['renderLeaf']>; | ||
}; | ||
}>; | ||
declare const EXPOSED_STORE_KEYS: (keyof PlateStoreState)[]; | ||
type PlateEditorMethods<V extends Value$1 = Value$1> = { | ||
reset: () => void; | ||
redecorate: () => void; | ||
plate: { | ||
set: { | ||
[K in (typeof EXPOSED_STORE_KEYS)[number]]: ReturnType<SetRecord<PlateStoreState<V>>[K]>; | ||
}; | ||
}; | ||
}; | ||
type PlateEditor<V extends Value$1 = Value$1> = TEditor<V> & THistoryEditor<V> & TReactEditor<V> & PlateEditorMethods<V> & { | ||
key: any; | ||
plugins: WithPlatePlugin<{}, V>[]; | ||
pluginsByKey: Record<PluginKey, WithPlatePlugin<{}, V>>; | ||
prevSelection: TRange | null; | ||
/** | ||
* Default block factory. | ||
* @default [{ type: getPluginType(editor, ELEMENT_DEFAULT), children: [{ text: '' }] }] | ||
*/ | ||
blockFactory: (node?: Partial<TElement$1>, path?: Path) => EElement<V>; | ||
/** | ||
* Editor children factory. | ||
* @default [editor.blockFactory()] | ||
*/ | ||
childrenFactory: () => V; | ||
currentKeyboardEvent: KeyboardEvent | null; | ||
}; | ||
/** | ||
* Node props passed by Plate | ||
*/ | ||
interface PlateRenderNodeProps<V extends Value$1, E extends PlateEditor<V> = PlateEditor<V>> { | ||
className?: string; | ||
editor: E; | ||
/** | ||
* @see {@link NodeProps} | ||
*/ | ||
nodeProps?: AnyObject; | ||
} | ||
/** | ||
* Leaf props passed by Plate | ||
*/ | ||
type PlateRenderLeafProps<V extends Value$1 = Value$1, N extends TText$1 = EText<V>> = PlateRenderNodeProps<V> & TRenderLeafProps<V, N>; | ||
/** | ||
* `Text` objects represent the nodes that contain the actual text content of a | ||
* Slate document along with any formatting properties. They are always leaf | ||
* nodes in the document tree as they cannot contain any children. | ||
*/ | ||
type TText = UnknownObject & { | ||
text: string; | ||
}; | ||
/** | ||
* `Element` objects are a type of node in a Slate document that contain other | ||
* element nodes or text nodes. They can be either "blocks" or "inlines" | ||
* depending on the Slate editor's configuration. | ||
*/ | ||
type TElement = UnknownObject & { | ||
children: TDescendant[]; | ||
type: string; | ||
}; | ||
/** | ||
* The `Descendant` union type represents nodes that are descendants in the | ||
* tree. It is returned as a convenience in certain cases to narrow a value | ||
* further than the more generic `Node` union. | ||
*/ | ||
type TDescendant = TElement | TText; | ||
type Value = TElement[]; | ||
interface TIndentElement extends TElement$2 { | ||
indent: number; | ||
} | ||
type IndentPlugin = { | ||
/** | ||
* Indentation offset used in `(offset * element.indent) + unit`. | ||
* @default 40 | ||
*/ | ||
offset?: number; | ||
/** | ||
* Indentation unit used in `(offset * element.indent) + unit`. | ||
* @default 'px' | ||
*/ | ||
unit?: string; | ||
/** | ||
* Maximum number of indentation. | ||
*/ | ||
indentMax?: number; | ||
}; | ||
declare const KEY_INDENT = "indent"; | ||
declare const createIndentPlugin: <OP = IndentPlugin, OV extends Value = Value, OE extends PlateEditor<OV> = PlateEditor<OV>>(override?: Partial<PlatePlugin<NoInfer<OP>, OV, OE>> | undefined, overrideByKey?: OverrideByKey<OV, OE> | undefined) => PlatePlugin<NoInfer<OP>, OV, OE>; | ||
declare const KEY_TEXT_INDENT = "textIndent"; | ||
declare const createTextIndentPlugin: <OP = IndentPlugin, OV extends Value = Value, OE extends PlateEditor<OV> = PlateEditor<OV>>(override?: Partial<PlatePlugin<NoInfer<OP>, OV, OE>> | undefined, overrideByKey?: OverrideByKey<OV, OE> | undefined) => PlatePlugin<NoInfer<OP>, OV, OE>; | ||
declare const onKeyDownIndent: <V extends Value$2 = Value$2, E extends PlateEditor$1<V> = PlateEditor$1<V>>(editor: E) => KeyboardHandlerReturnType; | ||
/** | ||
* - `node.indent` can not exceed `indentMax` | ||
* - `node.indent` is unset if `node.type` is not in `types` | ||
*/ | ||
declare const withIndent: <V extends Value$2 = Value$2, E extends PlateEditor$1<V> = PlateEditor$1<V>>(editor: E, { inject: { props: { validTypes } }, options: { indentMax }, }: WithPlatePlugin$1<IndentPlugin, V, E>) => E; | ||
declare const useIndentButton: () => { | ||
props: { | ||
onClick: (e: React.MouseEvent<HTMLButtonElement>) => void; | ||
}; | ||
}; | ||
declare const useOutdentButton: () => { | ||
props: { | ||
onClick: (e: React.MouseEvent<HTMLButtonElement>) => void; | ||
}; | ||
}; | ||
interface SetIndentOptions<V extends Value$2 = Value$2> { | ||
/** | ||
* 1 to indent | ||
* -1 to outdent | ||
* @default 1 | ||
*/ | ||
offset?: number; | ||
/** | ||
* getNodeEntries options | ||
*/ | ||
getNodesOptions?: GetNodeEntriesOptions<V> & UnhangRangeOptions; | ||
/** | ||
* Set other props than the indent one. | ||
* These will be unset if indent = 0. | ||
*/ | ||
setNodesProps?: ({ indent }: { | ||
indent: number; | ||
}) => AnyObject$1; | ||
/** | ||
* Nodes props to unset when indent = 0. | ||
*/ | ||
unsetNodesProps?: string[]; | ||
} | ||
/** | ||
* Add offset to the indentation of the selected blocks. | ||
*/ | ||
declare const setIndent: <V extends Value$2>(editor: PlateEditor$1<V>, { offset, getNodesOptions, setNodesProps, unsetNodesProps, }: SetIndentOptions<V>) => void; | ||
/** | ||
* Increase the indentation of the selected blocks. | ||
*/ | ||
declare const indent: <V extends Value$2>(editor: PlateEditor$1<V>, options?: SetIndentOptions<V> | undefined) => void; | ||
/** | ||
* Decrease the indentation of the selected blocks. | ||
*/ | ||
declare const outdent: <V extends Value$2>(editor: PlateEditor$1<V>, options?: SetIndentOptions<V> | undefined) => void; | ||
export { IndentPlugin, KEY_INDENT, KEY_TEXT_INDENT, SetIndentOptions, TIndentElement, createIndentPlugin, createTextIndentPlugin, indent, onKeyDownIndent, outdent, setIndent, useIndentButton, useOutdentButton, withIndent }; |
@@ -1,9 +0,60 @@ | ||
'use strict'; | ||
"use strict"; | ||
var __defProp = Object.defineProperty; | ||
var __getOwnPropDesc = Object.getOwnPropertyDescriptor; | ||
var __getOwnPropNames = Object.getOwnPropertyNames; | ||
var __getOwnPropSymbols = Object.getOwnPropertySymbols; | ||
var __hasOwnProp = Object.prototype.hasOwnProperty; | ||
var __propIsEnum = Object.prototype.propertyIsEnumerable; | ||
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value; | ||
var __spreadValues = (a, b) => { | ||
for (var prop in b || (b = {})) | ||
if (__hasOwnProp.call(b, prop)) | ||
__defNormalProp(a, prop, b[prop]); | ||
if (__getOwnPropSymbols) | ||
for (var prop of __getOwnPropSymbols(b)) { | ||
if (__propIsEnum.call(b, prop)) | ||
__defNormalProp(a, prop, b[prop]); | ||
} | ||
return a; | ||
}; | ||
var __export = (target, all) => { | ||
for (var name in all) | ||
__defProp(target, name, { get: all[name], enumerable: true }); | ||
}; | ||
var __copyProps = (to, from, except, desc) => { | ||
if (from && typeof from === "object" || typeof from === "function") { | ||
for (let key of __getOwnPropNames(from)) | ||
if (!__hasOwnProp.call(to, key) && key !== except) | ||
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable }); | ||
} | ||
return to; | ||
}; | ||
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod); | ||
var plateCommon = require('@udecode/plate-common'); | ||
// src/index.ts | ||
var src_exports = {}; | ||
__export(src_exports, { | ||
KEY_INDENT: () => KEY_INDENT, | ||
KEY_TEXT_INDENT: () => KEY_TEXT_INDENT, | ||
createIndentPlugin: () => createIndentPlugin, | ||
createTextIndentPlugin: () => createTextIndentPlugin, | ||
indent: () => indent, | ||
onKeyDownIndent: () => onKeyDownIndent, | ||
outdent: () => outdent, | ||
setIndent: () => setIndent, | ||
useIndentButton: () => useIndentButton, | ||
useOutdentButton: () => useOutdentButton, | ||
withIndent: () => withIndent | ||
}); | ||
module.exports = __toCommonJS(src_exports); | ||
/** | ||
* Add offset to the indentation of the selected blocks. | ||
*/ | ||
const setIndent = (editor, { | ||
// src/createIndentPlugin.ts | ||
var import_plate_common4 = require("@udecode/plate-common"); | ||
// src/onKeyDownIndent.ts | ||
var import_plate_common2 = require("@udecode/plate-common"); | ||
// src/transforms/setIndent.ts | ||
var import_plate_common = require("@udecode/plate-common"); | ||
var setIndent = (editor, { | ||
offset = 1, | ||
@@ -14,30 +65,20 @@ getNodesOptions, | ||
}) => { | ||
const { | ||
nodeKey | ||
} = plateCommon.getPluginInjectProps(editor, KEY_INDENT); | ||
const _nodes = plateCommon.getNodeEntries(editor, { | ||
const { nodeKey } = (0, import_plate_common.getPluginInjectProps)(editor, KEY_INDENT); | ||
const _nodes = (0, import_plate_common.getNodeEntries)(editor, __spreadValues({ | ||
block: true, | ||
mode: 'lowest', | ||
...getNodesOptions | ||
}); | ||
mode: "lowest" | ||
}, getNodesOptions)); | ||
const nodes = Array.from(_nodes); | ||
plateCommon.withoutNormalizing(editor, () => { | ||
(0, import_plate_common.withoutNormalizing)(editor, () => { | ||
nodes.forEach(([node, path]) => { | ||
var _ref, _setNodesProps; | ||
const blockIndent = (_ref = node[nodeKey]) !== null && _ref !== void 0 ? _ref : 0; | ||
var _a, _b; | ||
const blockIndent = (_a = node[nodeKey]) != null ? _a : 0; | ||
const newIndent = blockIndent + offset; | ||
const props = (_setNodesProps = setNodesProps === null || setNodesProps === void 0 ? void 0 : setNodesProps({ | ||
indent: newIndent | ||
})) !== null && _setNodesProps !== void 0 ? _setNodesProps : {}; | ||
const props = (_b = setNodesProps == null ? void 0 : setNodesProps({ indent: newIndent })) != null ? _b : {}; | ||
if (newIndent <= 0) { | ||
plateCommon.unsetNodes(editor, [nodeKey, ...unsetNodesProps], { | ||
(0, import_plate_common.unsetNodes)(editor, [nodeKey, ...unsetNodesProps], { | ||
at: path | ||
}); | ||
} else { | ||
plateCommon.setElements(editor, { | ||
[nodeKey]: newIndent, | ||
...props | ||
}, { | ||
at: path | ||
}); | ||
(0, import_plate_common.setElements)(editor, __spreadValues({ [nodeKey]: newIndent }, props), { at: path }); | ||
} | ||
@@ -48,29 +89,21 @@ }); | ||
/** | ||
* Increase the indentation of the selected blocks. | ||
*/ | ||
const indent = (editor, options) => { | ||
setIndent(editor, { | ||
offset: 1, | ||
...options | ||
}); | ||
// src/transforms/indent.ts | ||
var indent = (editor, options) => { | ||
setIndent(editor, __spreadValues({ offset: 1 }, options)); | ||
}; | ||
/** | ||
* Decrease the indentation of the selected blocks. | ||
*/ | ||
const outdent = (editor, options) => { | ||
setIndent(editor, { | ||
offset: -1, | ||
...options | ||
}); | ||
// src/transforms/outdent.ts | ||
var outdent = (editor, options) => { | ||
setIndent(editor, __spreadValues({ offset: -1 }, options)); | ||
}; | ||
const onKeyDownIndent = editor => e => { | ||
if (e.defaultPrevented) return; | ||
if (plateCommon.Hotkeys.isTab(editor, e)) { | ||
// src/onKeyDownIndent.ts | ||
var onKeyDownIndent = (editor) => (e) => { | ||
if (e.defaultPrevented) | ||
return; | ||
if (import_plate_common2.Hotkeys.isTab(editor, e)) { | ||
e.preventDefault(); | ||
indent(editor); | ||
} | ||
if (plateCommon.Hotkeys.isUntab(editor, e)) { | ||
if (import_plate_common2.Hotkeys.isUntab(editor, e)) { | ||
e.preventDefault(); | ||
@@ -81,38 +114,20 @@ outdent(editor); | ||
/** | ||
* - `node.indent` can not exceed `indentMax` | ||
* - `node.indent` is unset if `node.type` is not in `types` | ||
*/ | ||
const withIndent = (editor, { | ||
inject: { | ||
props: { | ||
validTypes | ||
} = {} | ||
}, | ||
options: { | ||
indentMax | ||
} | ||
// src/withIndent.ts | ||
var import_plate_common3 = require("@udecode/plate-common"); | ||
var withIndent = (editor, { | ||
inject: { props: { validTypes } = {} }, | ||
options: { indentMax } | ||
}) => { | ||
const { | ||
normalizeNode | ||
} = editor; | ||
const { normalizeNode } = editor; | ||
editor.normalizeNode = ([node, path]) => { | ||
const element = node; | ||
const { | ||
type | ||
} = element; | ||
const { type } = element; | ||
if (type) { | ||
if (validTypes.includes(type)) { | ||
if (indentMax && element.indent && element.indent > indentMax) { | ||
plateCommon.setElements(editor, { | ||
indent: indentMax | ||
}, { | ||
at: path | ||
}); | ||
(0, import_plate_common3.setElements)(editor, { indent: indentMax }, { at: path }); | ||
return; | ||
} | ||
} else if (element.indent) { | ||
plateCommon.unsetNodes(editor, 'indent', { | ||
at: path | ||
}); | ||
(0, import_plate_common3.unsetNodes)(editor, "indent", { at: path }); | ||
return; | ||
@@ -126,4 +141,5 @@ } | ||
const KEY_INDENT = 'indent'; | ||
const createIndentPlugin = plateCommon.createPluginFactory({ | ||
// src/createIndentPlugin.ts | ||
var KEY_INDENT = "indent"; | ||
var createIndentPlugin = (0, import_plate_common4.createPluginFactory)({ | ||
key: KEY_INDENT, | ||
@@ -136,18 +152,11 @@ withOverrides: withIndent, | ||
offset: 24, | ||
unit: 'px' | ||
unit: "px" | ||
}, | ||
then: (editor, { | ||
options: { | ||
offset, | ||
unit | ||
} = {} | ||
}) => ({ | ||
then: (editor, { options: { offset, unit } = {} }) => ({ | ||
inject: { | ||
props: { | ||
nodeKey: KEY_INDENT, | ||
styleKey: 'marginLeft', | ||
validTypes: [plateCommon.getPluginType(editor, plateCommon.ELEMENT_DEFAULT)], | ||
transformNodeValue: ({ | ||
nodeValue | ||
}) => nodeValue * offset + unit | ||
styleKey: "marginLeft", | ||
validTypes: [(0, import_plate_common4.getPluginType)(editor, import_plate_common4.ELEMENT_DEFAULT)], | ||
transformNodeValue: ({ nodeValue }) => nodeValue * offset + unit | ||
} | ||
@@ -158,23 +167,18 @@ } | ||
const KEY_TEXT_INDENT = 'textIndent'; | ||
const createTextIndentPlugin = plateCommon.createPluginFactory({ | ||
// src/createTextIndentPlugin.ts | ||
var import_plate_common5 = require("@udecode/plate-common"); | ||
var KEY_TEXT_INDENT = "textIndent"; | ||
var createTextIndentPlugin = (0, import_plate_common5.createPluginFactory)({ | ||
key: KEY_TEXT_INDENT, | ||
options: { | ||
offset: 24, | ||
unit: 'px' | ||
unit: "px" | ||
}, | ||
then: (editor, { | ||
options: { | ||
offset, | ||
unit | ||
} = {} | ||
}) => ({ | ||
then: (editor, { options: { offset, unit } = {} }) => ({ | ||
inject: { | ||
props: { | ||
nodeKey: KEY_TEXT_INDENT, | ||
styleKey: 'textIndent', | ||
validTypes: [plateCommon.getPluginType(editor, plateCommon.ELEMENT_DEFAULT)], | ||
transformNodeValue({ | ||
nodeValue | ||
}) { | ||
styleKey: "textIndent", | ||
validTypes: [(0, import_plate_common5.getPluginType)(editor, import_plate_common5.ELEMENT_DEFAULT)], | ||
transformNodeValue({ nodeValue }) { | ||
return nodeValue * offset + unit; | ||
@@ -187,11 +191,13 @@ } | ||
const useIndentButton = () => { | ||
const editor = plateCommon.useEditorRef(); | ||
// src/hooks/useIndentButton.ts | ||
var import_plate_common6 = require("@udecode/plate-common"); | ||
var useIndentButton = () => { | ||
const editor = (0, import_plate_common6.useEditorRef)(); | ||
return { | ||
props: { | ||
onClick: e => { | ||
onClick: (e) => { | ||
e.preventDefault(); | ||
e.stopPropagation(); | ||
indent(editor); | ||
plateCommon.focusEditor(editor); | ||
(0, import_plate_common6.focusEditor)(editor); | ||
} | ||
@@ -202,11 +208,13 @@ } | ||
const useOutdentButton = () => { | ||
const editor = plateCommon.useEditorRef(); | ||
// src/hooks/useOutdentButton.ts | ||
var import_plate_common7 = require("@udecode/plate-common"); | ||
var useOutdentButton = () => { | ||
const editor = (0, import_plate_common7.useEditorRef)(); | ||
return { | ||
props: { | ||
onClick: e => { | ||
onClick: (e) => { | ||
e.preventDefault(); | ||
e.stopPropagation(); | ||
outdent(editor); | ||
plateCommon.focusEditor(editor); | ||
(0, import_plate_common7.focusEditor)(editor); | ||
} | ||
@@ -216,14 +224,16 @@ } | ||
}; | ||
exports.KEY_INDENT = KEY_INDENT; | ||
exports.KEY_TEXT_INDENT = KEY_TEXT_INDENT; | ||
exports.createIndentPlugin = createIndentPlugin; | ||
exports.createTextIndentPlugin = createTextIndentPlugin; | ||
exports.indent = indent; | ||
exports.onKeyDownIndent = onKeyDownIndent; | ||
exports.outdent = outdent; | ||
exports.setIndent = setIndent; | ||
exports.useIndentButton = useIndentButton; | ||
exports.useOutdentButton = useOutdentButton; | ||
exports.withIndent = withIndent; | ||
//# sourceMappingURL=index.js.map | ||
// Annotate the CommonJS export names for ESM import in node: | ||
0 && (module.exports = { | ||
KEY_INDENT, | ||
KEY_TEXT_INDENT, | ||
createIndentPlugin, | ||
createTextIndentPlugin, | ||
indent, | ||
onKeyDownIndent, | ||
outdent, | ||
setIndent, | ||
useIndentButton, | ||
useOutdentButton, | ||
withIndent | ||
}); | ||
//# sourceMappingURL=index.js.map |
{ | ||
"name": "@udecode/plate-indent", | ||
"version": "24.2.0", | ||
"version": "24.3.0", | ||
"description": "Indent plugin for Plate", | ||
@@ -15,8 +15,17 @@ "license": "MIT", | ||
}, | ||
"sideEffects": false, | ||
"main": "dist/index.js", | ||
"module": "dist/index.es.js", | ||
"module": "dist/index.mjs", | ||
"types": "dist/index.d.ts", | ||
"files": [ | ||
"dist" | ||
"dist/**/*" | ||
], | ||
"types": "dist/index.d.ts", | ||
"exports": { | ||
".": { | ||
"types": "./dist/index.d.ts", | ||
"import": "./dist/index.mjs", | ||
"module": "./dist/index.mjs", | ||
"require": "./dist/index.js" | ||
} | ||
}, | ||
"scripts": { | ||
@@ -34,3 +43,3 @@ "build": "yarn p:build", | ||
"dependencies": { | ||
"@udecode/plate-common": "24.2.0" | ||
"@udecode/plate-common": "24.3.0" | ||
}, | ||
@@ -37,0 +46,0 @@ "peerDependencies": { |
Sorry, the diff of this file is not supported yet
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
99353
1201
8
1
+ Added@udecode/plate-common@24.3.0(transitive)
+ Added@udecode/plate-core@24.3.0(transitive)
+ Added@udecode/plate-utils@24.3.0(transitive)
+ Added@udecode/slate@24.3.0(transitive)
+ Added@udecode/slate-react@24.3.0(transitive)
+ Added@udecode/slate-utils@24.3.0(transitive)
+ Added@udecode/utils@24.3.0(transitive)
- Removed@udecode/plate-common@24.2.0(transitive)
- Removed@udecode/plate-core@24.0.2(transitive)
- Removed@udecode/plate-utils@24.2.0(transitive)
- Removed@udecode/slate@23.7.4(transitive)
- Removed@udecode/slate-react@24.0.0(transitive)
- Removed@udecode/slate-utils@24.2.0(transitive)
- Removed@udecode/utils@19.7.1(transitive)
Updated@udecode/plate-common@24.3.0