@lofcz/platejs-utils 52.3.6 → 53.1.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import * as _platejs_core0 from "@platejs/core";
|
|
2
|
-
import { InsertExitBreakOptions, OverrideEditor, PluginConfig } from "@platejs/core";
|
|
2
|
+
import { InsertExitBreakOptions, OverrideEditor, PluginConfig, SlateEditor } from "@platejs/core";
|
|
3
3
|
import { Descendant, Path, QueryNodeOptions, TElement, TText } from "@platejs/slate";
|
|
4
4
|
import { UnknownObject } from "@udecode/utils";
|
|
5
5
|
|
|
@@ -25,6 +25,9 @@ declare const NODES: {
|
|
|
25
25
|
readonly equation: "equation";
|
|
26
26
|
readonly excalidraw: "excalidraw";
|
|
27
27
|
readonly file: "file";
|
|
28
|
+
readonly footnoteDefinition: "footnoteDefinition";
|
|
29
|
+
readonly footnoteInput: "footnoteInput";
|
|
30
|
+
readonly footnoteReference: "footnoteReference";
|
|
28
31
|
readonly h1: "h1";
|
|
29
32
|
readonly h2: "h2";
|
|
30
33
|
readonly h3: "h3";
|
|
@@ -146,6 +149,9 @@ declare const KEYS: {
|
|
|
146
149
|
readonly equation: "equation";
|
|
147
150
|
readonly excalidraw: "excalidraw";
|
|
148
151
|
readonly file: "file";
|
|
152
|
+
readonly footnoteDefinition: "footnoteDefinition";
|
|
153
|
+
readonly footnoteInput: "footnoteInput";
|
|
154
|
+
readonly footnoteReference: "footnoteReference";
|
|
149
155
|
readonly h1: "h1";
|
|
150
156
|
readonly h2: "h2";
|
|
151
157
|
readonly h3: "h3";
|
|
@@ -218,6 +224,7 @@ interface TColumnGroupElement extends TElement {
|
|
|
218
224
|
}
|
|
219
225
|
interface TDateElement extends TElement {
|
|
220
226
|
date?: string;
|
|
227
|
+
rawDate?: string;
|
|
221
228
|
}
|
|
222
229
|
interface TEquationElement extends TElement {
|
|
223
230
|
texExpression: string;
|
|
@@ -292,6 +299,8 @@ type TMediaProps = {
|
|
|
292
299
|
isUpload?: boolean;
|
|
293
300
|
name?: string;
|
|
294
301
|
placeholderId?: string;
|
|
302
|
+
provider?: string;
|
|
303
|
+
sourceUrl?: string;
|
|
295
304
|
};
|
|
296
305
|
type TMediaElement = TElement & TMediaProps;
|
|
297
306
|
type TCaptionProps = {
|
|
@@ -501,7 +510,19 @@ declare const SingleBlockPlugin: _platejs_core0.SlatePlugin<_platejs_core0.Plugi
|
|
|
501
510
|
declare const SingleLinePlugin: _platejs_core0.SlatePlugin<_platejs_core0.PluginConfig<"singleLine", {}, {}, {}, {}>>;
|
|
502
511
|
//#endregion
|
|
503
512
|
//#region src/lib/plugins/trailing-block/TrailingBlockPlugin.d.ts
|
|
513
|
+
type TrailingBlockInsertOptions = {
|
|
514
|
+
at: Path;
|
|
515
|
+
insert: () => void;
|
|
516
|
+
type: string;
|
|
517
|
+
};
|
|
504
518
|
type TrailingBlockConfig = PluginConfig<'trailingBlock', {
|
|
519
|
+
/**
|
|
520
|
+
* Customize how the trailing block is inserted.
|
|
521
|
+
*
|
|
522
|
+
* Useful when another plugin needs to wrap the insertion, such as
|
|
523
|
+
* disabling suggestions during normalization-generated inserts.
|
|
524
|
+
*/
|
|
525
|
+
insert?: (editor: SlateEditor, options: TrailingBlockInsertOptions) => void;
|
|
505
526
|
/** Level where the trailing node should be, the first level being 0. */
|
|
506
527
|
level?: number;
|
|
507
528
|
/** Type of the trailing block */
|
|
@@ -511,6 +532,13 @@ type TrailingBlockConfig = PluginConfig<'trailingBlock', {
|
|
|
511
532
|
declare const TrailingBlockPlugin: _platejs_core0.SlatePlugin<PluginConfig<"trailingBlock", {
|
|
512
533
|
type: string;
|
|
513
534
|
} & {
|
|
535
|
+
/**
|
|
536
|
+
* Customize how the trailing block is inserted.
|
|
537
|
+
*
|
|
538
|
+
* Useful when another plugin needs to wrap the insertion, such as
|
|
539
|
+
* disabling suggestions during normalization-generated inserts.
|
|
540
|
+
*/
|
|
541
|
+
insert?: (editor: SlateEditor, options: TrailingBlockInsertOptions) => void;
|
|
514
542
|
/** Level where the trailing node should be, the first level being 0. */
|
|
515
543
|
level?: number;
|
|
516
544
|
/** Type of the trailing block */
|
|
@@ -524,4 +552,4 @@ declare const TrailingBlockPlugin: _platejs_core0.SlatePlugin<PluginConfig<"trai
|
|
|
524
552
|
*/
|
|
525
553
|
declare const withTrailingBlock: OverrideEditor<TrailingBlockConfig>;
|
|
526
554
|
//#endregion
|
|
527
|
-
export { EmptyText, ExitBreakPlugin, KEYS, NODES, NodeKey, NormalizeTypesConfig, NormalizeTypesPlugin, PlainText, PlateKey, STYLE_KEYS, SingleBlockPlugin, SingleLinePlugin, StyleKey, TAudioElement, TBasicMarks, TCalloutElement, TCaptionElement, TCaptionProps, TCodeBlockElement, TCodeSyntaxLeaf, TColumnElement, TColumnGroupElement, TComboboxInputElement, TCommentText, TDateElement, TEquationElement, TFileElement, TFontMarks, TIdElement, TIdProps, TImageElement, TIndentElement, TIndentProps, TInlineSuggestionData, TInsertSuggestionData, TLineHeightProps, TLinkElement, TListElement, TListProps, TMediaElement, TMediaEmbedElement, TMediaProps, TMentionElement, TNodeMap, TPlaceholderElement, TRemoveSuggestionData, TResizableElement, TResizableProps, TSuggestionData, TSuggestionElement, TSuggestionProps, TSuggestionText, TTableCellBorder, TTableCellElement, TTableElement, TTableRowElement, TTagElement, TTagProps, TTextAlignProps, TUpdateSuggestionData, TVideoElement, TrailingBlockConfig, TrailingBlockPlugin, withNormalizeTypes, withTrailingBlock };
|
|
555
|
+
export { EmptyText, ExitBreakPlugin, KEYS, NODES, NodeKey, NormalizeTypesConfig, NormalizeTypesPlugin, PlainText, PlateKey, STYLE_KEYS, SingleBlockPlugin, SingleLinePlugin, StyleKey, TAudioElement, TBasicMarks, TCalloutElement, TCaptionElement, TCaptionProps, TCodeBlockElement, TCodeSyntaxLeaf, TColumnElement, TColumnGroupElement, TComboboxInputElement, TCommentText, TDateElement, TEquationElement, TFileElement, TFontMarks, TIdElement, TIdProps, TImageElement, TIndentElement, TIndentProps, TInlineSuggestionData, TInsertSuggestionData, TLineHeightProps, TLinkElement, TListElement, TListProps, TMediaElement, TMediaEmbedElement, TMediaProps, TMentionElement, TNodeMap, TPlaceholderElement, TRemoveSuggestionData, TResizableElement, TResizableProps, TSuggestionData, TSuggestionElement, TSuggestionProps, TSuggestionText, TTableCellBorder, TTableCellElement, TTableElement, TTableRowElement, TTagElement, TTagProps, TTextAlignProps, TUpdateSuggestionData, TVideoElement, TrailingBlockConfig, TrailingBlockInsertOptions, TrailingBlockPlugin, withNormalizeTypes, withTrailingBlock };
|
package/dist/index.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { n as NODES, r as STYLE_KEYS, t as KEYS } from "./plate-keys-
|
|
1
|
+
import { n as NODES, r as STYLE_KEYS, t as KEYS } from "./plate-keys-CN1p7z_o.js";
|
|
2
2
|
import { createSlatePlugin, createTSlatePlugin } from "@platejs/core";
|
|
3
3
|
import { ElementApi, NodeApi, PathApi, TextApi, queryNode } from "@platejs/slate";
|
|
4
4
|
|
|
@@ -117,13 +117,22 @@ const SingleLinePlugin = createSlatePlugin({
|
|
|
117
117
|
* editor has .
|
|
118
118
|
*/
|
|
119
119
|
const withTrailingBlock = ({ editor, getOptions, tf: { normalizeNode } }) => ({ transforms: { normalizeNode([currentNode, currentPath]) {
|
|
120
|
-
const { level, type, ...query } = getOptions();
|
|
120
|
+
const { insert, level, type, ...query } = getOptions();
|
|
121
|
+
const trailingType = type ?? editor.getType(KEYS.p);
|
|
121
122
|
if (currentPath.length === 0) {
|
|
122
123
|
const lastChild = editor.api.last([], { level });
|
|
123
124
|
const lastChildNode = lastChild?.[0];
|
|
124
|
-
if (!lastChildNode || lastChildNode.type !==
|
|
125
|
+
if (!lastChildNode || lastChildNode.type !== trailingType && queryNode(lastChild, query)) {
|
|
125
126
|
const at = lastChild ? PathApi.next(lastChild[1]) : [0];
|
|
126
|
-
|
|
127
|
+
const insertTrailingBlock = () => {
|
|
128
|
+
editor.tf.insertNodes(editor.api.create.block({ type: trailingType }, at), { at });
|
|
129
|
+
};
|
|
130
|
+
if (insert) insert(editor, {
|
|
131
|
+
at,
|
|
132
|
+
insert: insertTrailingBlock,
|
|
133
|
+
type: trailingType
|
|
134
|
+
});
|
|
135
|
+
else insertTrailingBlock();
|
|
127
136
|
return;
|
|
128
137
|
}
|
|
129
138
|
}
|
package/dist/react/index.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { t as KEYS } from "../plate-keys-
|
|
1
|
+
import { t as KEYS } from "../plate-keys-CN1p7z_o.js";
|
|
2
2
|
import { getContainerTypes } from "@platejs/core";
|
|
3
3
|
import { c } from "react-compiler-runtime";
|
|
4
4
|
import { createTPlatePlugin, useEditorComposing, useEditorReadOnly, useEditorRef, useEditorSelector, useFocused, usePluginOption } from "@platejs/core/react";
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@lofcz/platejs-utils",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "53.1.1",
|
|
4
4
|
"description": "Plate utils",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"plate",
|
|
@@ -32,8 +32,8 @@
|
|
|
32
32
|
"clsx": "^2.1.1",
|
|
33
33
|
"lodash": "^4.17.21",
|
|
34
34
|
"react-compiler-runtime": "^1.0.0",
|
|
35
|
-
"@platejs/core": "npm:@lofcz/platejs-core@
|
|
36
|
-
"@platejs/slate": "npm:@lofcz/platejs-slate@
|
|
35
|
+
"@platejs/core": "npm:@lofcz/platejs-core@53.1.1",
|
|
36
|
+
"@platejs/slate": "npm:@lofcz/platejs-slate@53.1.1",
|
|
37
37
|
"@udecode/react-utils": "npm:@lofcz/udecode-react-utils@52.3.4",
|
|
38
38
|
"@udecode/utils": "npm:@lofcz/udecode-utils@52.3.4"
|
|
39
39
|
},
|