@lofcz/platejs-utils 52.3.4

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.js ADDED
@@ -0,0 +1,143 @@
1
+ import { n as NODES, r as STYLE_KEYS, t as KEYS } from "./plate-keys-C2YNmTqZ.js";
2
+ import { createSlatePlugin, createTSlatePlugin } from "@platejs/core";
3
+ import { ElementApi, NodeApi, PathApi, TextApi, queryNode } from "@platejs/slate";
4
+
5
+ //#region src/lib/plugins/ExitBreakPlugin.ts
6
+ /**
7
+ * Insert soft break following configurable rules. Each rule specifies a hotkey
8
+ * and query options.
9
+ */
10
+ const ExitBreakPlugin = createSlatePlugin({
11
+ key: KEYS.exitBreak,
12
+ editOnly: true
13
+ }).extendTransforms(({ editor }) => ({
14
+ insert: (options) => editor.tf.insertExitBreak(options),
15
+ insertBefore: (options) => editor.tf.insertExitBreak({
16
+ ...options,
17
+ reverse: true
18
+ })
19
+ }));
20
+
21
+ //#endregion
22
+ //#region src/lib/plugins/normalize-types/withNormalizeTypes.ts
23
+ const withNormalizeTypes = ({ editor, getOptions, tf: { normalizeNode } }) => ({ transforms: { normalizeNode([currentNode, currentPath]) {
24
+ const { rules, onError } = getOptions();
25
+ if (currentPath.length === 0) {
26
+ if (rules.some(({ path, strictType, type }) => {
27
+ const node = NodeApi.get(editor, path);
28
+ if (node) {
29
+ if (strictType && ElementApi.isElement(node) && node.type !== strictType) {
30
+ const { children, ...props } = editor.api.create.block({ type: strictType });
31
+ editor.tf.setNodes(props, { at: path });
32
+ return true;
33
+ }
34
+ } else try {
35
+ editor.tf.insertNodes(editor.api.create.block({ type: strictType ?? type }), { at: path });
36
+ return true;
37
+ } catch (error) {
38
+ onError?.(error);
39
+ }
40
+ return false;
41
+ })) return;
42
+ }
43
+ return normalizeNode([currentNode, currentPath]);
44
+ } } });
45
+
46
+ //#endregion
47
+ //#region src/lib/plugins/normalize-types/NormalizeTypesPlugin.ts
48
+ /** @see {@link withNormalizeTypes} */
49
+ const NormalizeTypesPlugin = createTSlatePlugin({
50
+ key: KEYS.normalizeTypes,
51
+ options: { rules: [] }
52
+ }).overrideEditor(withNormalizeTypes);
53
+
54
+ //#endregion
55
+ //#region src/lib/plugins/single-block/SingleBlockPlugin.ts
56
+ /** Forces editor to only have one block. */
57
+ const SingleBlockPlugin = createSlatePlugin({
58
+ key: KEYS.singleBlock,
59
+ override: { enabled: { [KEYS.trailingBlock]: false } }
60
+ }).overrideEditor(({ editor, tf: { normalizeNode } }) => ({ transforms: {
61
+ insertBreak() {
62
+ editor.tf.insertSoftBreak();
63
+ },
64
+ normalizeNode(entry) {
65
+ const [_node, path] = entry;
66
+ if (path.length === 0 && editor.children.length > 1) {
67
+ editor.tf.withoutNormalizing(() => {
68
+ while (editor.children.length > 1) {
69
+ editor.tf.insertText("\n", { at: editor.api.start([1]) });
70
+ editor.tf.mergeNodes({
71
+ at: [1],
72
+ match: (_, path$1) => path$1.length === 1
73
+ });
74
+ }
75
+ });
76
+ return;
77
+ }
78
+ normalizeNode(entry);
79
+ }
80
+ } }));
81
+
82
+ //#endregion
83
+ //#region src/lib/plugins/single-block/SingleLinePlugin.ts
84
+ /** Forces editor to only have one line. */
85
+ const SingleLinePlugin = createSlatePlugin({
86
+ key: KEYS.singleLine,
87
+ override: { enabled: { [KEYS.trailingBlock]: false } }
88
+ }).overrideEditor(({ editor, tf: { normalizeNode } }) => ({ transforms: {
89
+ insertBreak() {},
90
+ insertSoftBreak() {},
91
+ normalizeNode(entry) {
92
+ const [node, path] = entry;
93
+ if (TextApi.isText(node)) {
94
+ const filteredText = node.text.replace(/[\r\n\u2028\u2029]/g, "");
95
+ if (filteredText !== node.text) {
96
+ editor.tf.insertText(filteredText, { at: path });
97
+ return;
98
+ }
99
+ }
100
+ if (path.length === 0 && editor.children.length > 1) {
101
+ editor.tf.withoutNormalizing(() => {
102
+ while (editor.children.length > 1) editor.tf.mergeNodes({
103
+ at: [1],
104
+ match: (_, path$1) => path$1.length === 1
105
+ });
106
+ });
107
+ return;
108
+ }
109
+ normalizeNode(entry);
110
+ }
111
+ } }));
112
+
113
+ //#endregion
114
+ //#region src/lib/plugins/trailing-block/withTrailingBlock.ts
115
+ /**
116
+ * Add a trailing block when the last node type is not `type` and when the
117
+ * editor has .
118
+ */
119
+ const withTrailingBlock = ({ editor, getOptions, tf: { normalizeNode } }) => ({ transforms: { normalizeNode([currentNode, currentPath]) {
120
+ const { level, type, ...query } = getOptions();
121
+ if (currentPath.length === 0) {
122
+ const lastChild = editor.api.last([], { level });
123
+ const lastChildNode = lastChild?.[0];
124
+ if (!lastChildNode || lastChildNode.type !== type && queryNode(lastChild, query)) {
125
+ const at = lastChild ? PathApi.next(lastChild[1]) : [0];
126
+ editor.tf.insertNodes(editor.api.create.block({ type }, at), { at });
127
+ return;
128
+ }
129
+ }
130
+ return normalizeNode([currentNode, currentPath]);
131
+ } } });
132
+
133
+ //#endregion
134
+ //#region src/lib/plugins/trailing-block/TrailingBlockPlugin.ts
135
+ /** @see {@link withTrailingBlock} */
136
+ const TrailingBlockPlugin = createTSlatePlugin({
137
+ key: KEYS.trailingBlock,
138
+ options: { level: 0 }
139
+ }).overrideEditor(withTrailingBlock).extend(({ editor }) => ({ options: { type: editor.getType(KEYS.p) } }));
140
+
141
+ //#endregion
142
+ export { ExitBreakPlugin, KEYS, NODES, NormalizeTypesPlugin, STYLE_KEYS, SingleBlockPlugin, SingleLinePlugin, TrailingBlockPlugin, withNormalizeTypes, withTrailingBlock };
143
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","names":["createSlatePlugin","InsertExitBreakOptions","KEYS","ExitBreakPlugin","key","exitBreak","editOnly","extendTransforms","editor","insert","options","Omit","tf","insertExitBreak","insertBefore","reverse","OverrideEditor","ElementApi","NodeApi","TElement","NormalizeTypesConfig","withNormalizeTypes","editor","getOptions","tf","normalizeNode","transforms","currentNode","currentPath","rules","onError","length","endCurrentNormalizationPass","some","path","strictType","type","node","get","isElement","children","props","api","create","block","setNodes","at","insertNodes","error","createTSlatePlugin","PluginConfig","Path","KEYS","withNormalizeTypes","NormalizeTypesConfig","rules","Rule","onError","err","path","strictType","type","NormalizeTypesPlugin","key","normalizeTypes","options","overrideEditor","createSlatePlugin","KEYS","SingleBlockPlugin","key","singleBlock","override","enabled","trailingBlock","overrideEditor","editor","tf","normalizeNode","transforms","insertBreak","insertSoftBreak","entry","_node","path","length","children","withoutNormalizing","insertText","at","api","start","mergeNodes","match","_","createSlatePlugin","TextApi","KEYS","SingleLinePlugin","key","singleLine","override","enabled","trailingBlock","overrideEditor","editor","tf","normalizeNode","transforms","insertBreak","insertSoftBreak","entry","node","path","isText","filteredText","text","replace","insertText","at","length","children","withoutNormalizing","mergeNodes","match","_","OverrideEditor","PathApi","queryNode","TrailingBlockConfig","withTrailingBlock","editor","getOptions","tf","normalizeNode","transforms","currentNode","currentPath","level","type","query","length","lastChild","api","last","lastChildNode","at","next","insertNodes","create","block","createTSlatePlugin","PluginConfig","QueryNodeOptions","KEYS","withTrailingBlock","TrailingBlockConfig","level","type","TrailingBlockPlugin","key","trailingBlock","options","overrideEditor","extend","editor","getType","p"],"sources":["../src/lib/plugins/ExitBreakPlugin.ts","../src/lib/plugins/normalize-types/withNormalizeTypes.ts","../src/lib/plugins/normalize-types/NormalizeTypesPlugin.ts","../src/lib/plugins/single-block/SingleBlockPlugin.ts","../src/lib/plugins/single-block/SingleLinePlugin.ts","../src/lib/plugins/trailing-block/withTrailingBlock.ts","../src/lib/plugins/trailing-block/TrailingBlockPlugin.ts"],"sourcesContent":["import { createSlatePlugin, type InsertExitBreakOptions } from '@platejs/core';\n\nimport { KEYS } from '../plate-keys';\n\n/**\n * Insert soft break following configurable rules. Each rule specifies a hotkey\n * and query options.\n */\nexport const ExitBreakPlugin = createSlatePlugin({\n key: KEYS.exitBreak,\n editOnly: true,\n}).extendTransforms(({ editor }) => ({\n insert: (options: Omit<InsertExitBreakOptions, 'reverse'>) =>\n editor.tf.insertExitBreak(options),\n insertBefore: (options: Omit<InsertExitBreakOptions, 'reverse'>) =>\n editor.tf.insertExitBreak({ ...options, reverse: true }),\n}));\n","import type { OverrideEditor } from '@platejs/core';\n\nimport { ElementApi, NodeApi, type TElement } from '@platejs/slate';\n\nimport type { NormalizeTypesConfig } from './NormalizeTypesPlugin';\n\nexport const withNormalizeTypes: OverrideEditor<NormalizeTypesConfig> = ({\n editor,\n getOptions,\n tf: { normalizeNode },\n}) => ({\n transforms: {\n normalizeNode([currentNode, currentPath]) {\n const { rules, onError } = getOptions();\n\n if (currentPath.length === 0) {\n const endCurrentNormalizationPass = rules!.some(\n ({ path, strictType, type }) => {\n const node = NodeApi.get<TElement>(editor, path);\n\n if (node) {\n if (\n strictType &&\n ElementApi.isElement(node) &&\n node.type !== strictType\n ) {\n const { children, ...props } = editor.api.create.block({\n type: strictType,\n });\n editor.tf.setNodes(props, {\n at: path,\n });\n\n return true;\n }\n } else {\n try {\n editor.tf.insertNodes(\n editor.api.create.block({ type: strictType ?? type! }),\n { at: path }\n );\n\n return true;\n } catch (error) {\n onError?.(error);\n }\n }\n\n return false;\n }\n );\n\n if (endCurrentNormalizationPass) {\n return;\n }\n }\n\n return normalizeNode([currentNode, currentPath]);\n },\n },\n});\n","import { createTSlatePlugin, type PluginConfig } from '@platejs/core';\nimport type { Path } from '@platejs/slate';\n\nimport { KEYS } from '../../plate-keys';\nimport { withNormalizeTypes } from './withNormalizeTypes';\n\nexport type NormalizeTypesConfig = PluginConfig<\n 'normalizeTypes',\n {\n /**\n * Set of rules for the types. For each rule, provide a `path` and either\n * `strictType` or `type`. If there is no node existing at `path`: insert a\n * node with `strictType`. If there is a node existing at `path` but its\n * type is not `strictType` or `type`: set the node type to `strictType` or\n * `type`.\n */\n rules?: Rule[];\n onError?: (err: any) => void;\n }\n>;\n\ntype Rule = {\n /** Path where the rule applies */\n path: Path;\n /** Force the type of the node at the given path */\n strictType?: string;\n /** Type of the inserted node at the given path if `strictType` is not provided */\n type?: string;\n};\n\n/** @see {@link withNormalizeTypes} */\nexport const NormalizeTypesPlugin = createTSlatePlugin<NormalizeTypesConfig>({\n key: KEYS.normalizeTypes,\n options: {\n rules: [],\n },\n}).overrideEditor(withNormalizeTypes);\n","import { createSlatePlugin } from '@platejs/core';\n\nimport { KEYS } from '../../plate-keys';\n\n/** Forces editor to only have one block. */\nexport const SingleBlockPlugin = createSlatePlugin({\n key: KEYS.singleBlock,\n override: {\n enabled: {\n [KEYS.trailingBlock]: false,\n },\n },\n}).overrideEditor(({ editor, tf: { normalizeNode } }) => ({\n transforms: {\n insertBreak() {\n editor.tf.insertSoftBreak();\n },\n\n normalizeNode(entry) {\n const [_node, path] = entry;\n\n if (path.length === 0 && editor.children.length > 1) {\n editor.tf.withoutNormalizing(() => {\n // Merge all subsequent blocks into the first block\n while (editor.children.length > 1) {\n editor.tf.insertText('\\n', { at: editor.api.start([1]) });\n editor.tf.mergeNodes({\n at: [1],\n match: (_, path) => path.length === 1,\n });\n }\n });\n\n return;\n }\n\n normalizeNode(entry);\n },\n },\n}));\n","import { createSlatePlugin } from '@platejs/core';\n\nimport { TextApi } from '@platejs/slate';\nimport { KEYS } from '../../plate-keys';\n\n/** Forces editor to only have one line. */\nexport const SingleLinePlugin = createSlatePlugin({\n key: KEYS.singleLine,\n override: {\n enabled: {\n [KEYS.trailingBlock]: false,\n },\n },\n}).overrideEditor(({ editor, tf: { normalizeNode } }) => ({\n transforms: {\n insertBreak() {\n return;\n },\n\n insertSoftBreak() {\n return;\n },\n\n normalizeNode(entry) {\n const [node, path] = entry;\n\n // Filter out line break characters from text nodes\n if (TextApi.isText(node)) {\n const filteredText = node.text.replace(/[\\r\\n\\u2028\\u2029]/g, '');\n if (filteredText !== node.text) {\n editor.tf.insertText(filteredText, { at: path });\n return;\n }\n }\n\n if (path.length === 0 && editor.children.length > 1) {\n editor.tf.withoutNormalizing(() => {\n // Merge all subsequent blocks into the first block\n while (editor.children.length > 1) {\n editor.tf.mergeNodes({\n at: [1],\n match: (_, path) => path.length === 1,\n });\n }\n });\n\n return;\n }\n\n normalizeNode(entry);\n },\n },\n}));\n","import type { OverrideEditor } from '@platejs/core';\n\nimport { PathApi, queryNode } from '@platejs/slate';\n\nimport type { TrailingBlockConfig } from './TrailingBlockPlugin';\n\n/**\n * Add a trailing block when the last node type is not `type` and when the\n * editor has .\n */\nexport const withTrailingBlock: OverrideEditor<TrailingBlockConfig> = ({\n editor,\n getOptions,\n tf: { normalizeNode },\n}) => ({\n transforms: {\n normalizeNode([currentNode, currentPath]) {\n const { level, type, ...query } = getOptions();\n\n if (currentPath.length === 0) {\n const lastChild = editor.api.last([], { level });\n const lastChildNode = lastChild?.[0];\n\n if (\n !lastChildNode ||\n (lastChildNode.type !== type && queryNode(lastChild, query))\n ) {\n const at = lastChild ? PathApi.next(lastChild[1]) : [0];\n\n editor.tf.insertNodes(editor.api.create.block({ type }, at), { at });\n\n return;\n }\n }\n\n return normalizeNode([currentNode, currentPath]);\n },\n },\n});\n","import { createTSlatePlugin, type PluginConfig } from '@platejs/core';\nimport type { QueryNodeOptions } from '@platejs/slate';\n\nimport { KEYS } from '../../plate-keys';\nimport { withTrailingBlock } from './withTrailingBlock';\n\nexport type TrailingBlockConfig = PluginConfig<\n 'trailingBlock',\n {\n /** Level where the trailing node should be, the first level being 0. */\n level?: number;\n /** Type of the trailing block */\n type?: string;\n } & QueryNodeOptions\n>;\n\n/** @see {@link withTrailingBlock} */\nexport const TrailingBlockPlugin = createTSlatePlugin<TrailingBlockConfig>({\n key: KEYS.trailingBlock,\n options: {\n level: 0,\n },\n})\n .overrideEditor(withTrailingBlock)\n .extend(({ editor }) => ({\n options: {\n type: editor.getType(KEYS.p),\n },\n }));\n"],"mappings":";;;;;;;;;AAQA,MAAaG,kBAAkBH,kBAAkB;CAC/CI,KAAKF,KAAKG;CACVC,UAAU;CACX,CAAC,CAACC,kBAAkB,EAAEC,cAAc;CACnCC,SAASC,YACPF,OAAOI,GAAGC,gBAAgBH,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AExB,EACD,EAAE;;;;;;;;AC1CH,MAAamB,qBAA0D,EACrEC,QACAC,YACAC,IAAI,EAAEC,uBACD,EACLC,YAAY,EACVD,cAAc,CAACE,aAAaC,cAAc;CACxC,MAAM,EAAEC,OAAOC,MAAM,GAAGC,UAAUR,YAAY;AAE9C,KAAIK,YAAYI,WAAW,GAAG;EAC5B,MAAMC,YAAYX,OAAOY,IAAIC,KAAK,EAAE,EAAE,EAAEN,OAAO,CAAC;EAChD,MAAMO,gBAAgBH,YAAY;AAElC,MACE,CAACG,iBACAA,cAAcN,SAASA,QAAQX,UAAUc,WAAWF,MAAO,EAC5D;GACA,MAAMM,KAAKJ,YAAYf,QAAQoB,KAAKL,UAAU,GAAG,GAAG,CAAC,EAAE;AAEvDX,UAAOE,GAAGe,YAAYjB,OAAOY,IAAIM,OAAOC,MAAM,EAAEX,MAAM,EAAEO,GAAG,EAAE,EAAEA,IAAI,CAAC;AAEpE;;;AAIJ,QAAOZ,cAAc,CAACE,aAAaC,YAAY,CAAC;GAEpD,EACD;;;;;ACrBD,MAAasB,sBAAsBR,mBAAwC;CACzES,KAAKN,KAAKO;CACVC,SAAS,EACPL,OAAO,GACT;CACD,CAAC,CACCM,eAAeR,kBAAkB,CACjCS,QAAQ,EAAEC,cAAc,EACvBH,SAAS,EACPJ,MAAMO,OAAOC,QAAQZ,KAAKa,EAAC,EAC7B,EACD,EAAE"}
@@ -0,0 +1,127 @@
1
+ //#region src/lib/plate-keys.ts
2
+ const NODES = {
3
+ a: "a",
4
+ ai: "ai",
5
+ aiChat: "aiChat",
6
+ audio: "audio",
7
+ blockquote: "blockquote",
8
+ bold: "bold",
9
+ callout: "callout",
10
+ code: "code",
11
+ codeBlock: "code_block",
12
+ codeDrawing: "code_drawing",
13
+ codeLine: "code_line",
14
+ codeSyntax: "code_syntax",
15
+ column: "column",
16
+ columnGroup: "column_group",
17
+ comment: "comment",
18
+ date: "date",
19
+ emojiInput: "emoji_input",
20
+ equation: "equation",
21
+ excalidraw: "excalidraw",
22
+ file: "file",
23
+ h1: "h1",
24
+ h2: "h2",
25
+ h3: "h3",
26
+ h4: "h4",
27
+ h5: "h5",
28
+ h6: "h6",
29
+ highlight: "highlight",
30
+ hr: "hr",
31
+ img: "img",
32
+ inlineEquation: "inline_equation",
33
+ italic: "italic",
34
+ kbd: "kbd",
35
+ li: "li",
36
+ lic: "lic",
37
+ link: "a",
38
+ listTodoClassic: "action_item",
39
+ mediaEmbed: "media_embed",
40
+ mention: "mention",
41
+ mentionInput: "mention_input",
42
+ olClassic: "ol",
43
+ p: "p",
44
+ searchHighlight: "search_highlight",
45
+ slashInput: "slash_input",
46
+ strikethrough: "strikethrough",
47
+ sub: "subscript",
48
+ suggestion: "suggestion",
49
+ sup: "superscript",
50
+ table: "table",
51
+ tag: "tag",
52
+ taskList: "taskList",
53
+ td: "td",
54
+ th: "th",
55
+ toc: "toc",
56
+ toggle: "toggle",
57
+ tr: "tr",
58
+ ulClassic: "ul",
59
+ underline: "underline",
60
+ video: "video"
61
+ };
62
+ const STYLE_KEYS = {
63
+ backgroundColor: "backgroundColor",
64
+ color: "color",
65
+ fontFamily: "fontFamily",
66
+ fontSize: "fontSize",
67
+ fontWeight: "fontWeight",
68
+ indent: "indent",
69
+ lineHeight: "lineHeight",
70
+ listType: "listStyleType",
71
+ textAlign: "textAlign",
72
+ textIndent: "textIndent"
73
+ };
74
+ const KEYS = {
75
+ ...NODES,
76
+ ...STYLE_KEYS,
77
+ autoformat: "autoformat",
78
+ blockMenu: "blockMenu",
79
+ blockPlaceholder: "blockPlaceholder",
80
+ blockSelection: "blockSelection",
81
+ caption: "caption",
82
+ copilot: "copilot",
83
+ csv: "csv",
84
+ cursorOverlay: "cursorOverlay",
85
+ delete: "delete",
86
+ dnd: "dnd",
87
+ docx: "docx",
88
+ emoji: "emoji",
89
+ exitBreak: "exitBreak",
90
+ heading: [
91
+ "h1",
92
+ "h2",
93
+ "h3",
94
+ "h4",
95
+ "h5",
96
+ "h6"
97
+ ],
98
+ html: "html",
99
+ juice: "juice",
100
+ list: "list",
101
+ listChecked: "checked",
102
+ listClassic: "listClassic",
103
+ listRestart: "listRestart",
104
+ listRestartPolite: "listRestartPolite",
105
+ listStart: "listStart",
106
+ listTodo: "todo",
107
+ markdown: "markdown",
108
+ nodeId: "nodeId",
109
+ normalizeTypes: "normalizeTypes",
110
+ ol: "decimal",
111
+ placeholder: "placeholder",
112
+ playwright: "playwright",
113
+ removeEmptyNodes: "removeEmptyNodes",
114
+ resetNode: "resetNode",
115
+ singleBlock: "singleBlock",
116
+ singleLine: "singleLine",
117
+ slashCommand: "slash_command",
118
+ softBreak: "softBreak",
119
+ tabbable: "tabbable",
120
+ trailingBlock: "trailingBlock",
121
+ ul: "disc",
122
+ yjs: "yjs"
123
+ };
124
+
125
+ //#endregion
126
+ export { NODES as n, STYLE_KEYS as r, KEYS as t };
127
+ //# sourceMappingURL=plate-keys-C2YNmTqZ.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"plate-keys-C2YNmTqZ.js","names":["NODES","a","ai","aiChat","audio","blockquote","bold","callout","code","codeBlock","codeDrawing","codeLine","codeSyntax","column","columnGroup","comment","date","emojiInput","equation","excalidraw","file","h1","h2","h3","h4","h5","h6","highlight","hr","img","inlineEquation","italic","kbd","li","lic","link","listTodoClassic","mediaEmbed","mention","mentionInput","olClassic","p","searchHighlight","slashInput","strikethrough","sub","suggestion","sup","table","tag","taskList","td","th","toc","toggle","tr","ulClassic","underline","video","const","STYLE_KEYS","backgroundColor","color","fontFamily","fontSize","fontWeight","indent","lineHeight","listType","textAlign","textIndent","KEYS","autoformat","blockMenu","blockPlaceholder","blockSelection","caption","copilot","csv","cursorOverlay","delete","dnd","docx","emoji","exitBreak","heading","html","juice","list","listChecked","listClassic","listRestart","listRestartPolite","listStart","listTodo","markdown","nodeId","normalizeTypes","ol","placeholder","playwright","removeEmptyNodes","resetNode","singleBlock","singleLine","slashCommand","softBreak","tabbable","trailingBlock","ul","yjs","NodeKey","StyleKey","PlateKey"],"sources":["../src/lib/plate-keys.ts"],"sourcesContent":["export const NODES = {\n a: 'a',\n ai: 'ai',\n aiChat: 'aiChat',\n audio: 'audio',\n blockquote: 'blockquote',\n bold: 'bold',\n callout: 'callout',\n code: 'code',\n codeBlock: 'code_block',\n codeDrawing: 'code_drawing',\n codeLine: 'code_line',\n codeSyntax: 'code_syntax',\n column: 'column',\n columnGroup: 'column_group',\n comment: 'comment',\n date: 'date',\n emojiInput: 'emoji_input',\n equation: 'equation',\n excalidraw: 'excalidraw',\n file: 'file',\n h1: 'h1',\n h2: 'h2',\n h3: 'h3',\n h4: 'h4',\n h5: 'h5',\n h6: 'h6',\n highlight: 'highlight',\n hr: 'hr',\n img: 'img',\n inlineEquation: 'inline_equation',\n italic: 'italic',\n kbd: 'kbd',\n li: 'li',\n lic: 'lic',\n link: 'a',\n listTodoClassic: 'action_item',\n mediaEmbed: 'media_embed',\n mention: 'mention',\n mentionInput: 'mention_input',\n olClassic: 'ol',\n p: 'p',\n searchHighlight: 'search_highlight',\n slashInput: 'slash_input',\n strikethrough: 'strikethrough',\n sub: 'subscript',\n suggestion: 'suggestion',\n sup: 'superscript',\n table: 'table',\n tag: 'tag',\n taskList: 'taskList',\n td: 'td',\n th: 'th',\n toc: 'toc',\n toggle: 'toggle',\n tr: 'tr',\n ulClassic: 'ul',\n underline: 'underline',\n video: 'video',\n} as const;\n\nexport const STYLE_KEYS = {\n backgroundColor: 'backgroundColor',\n color: 'color',\n fontFamily: 'fontFamily',\n fontSize: 'fontSize',\n fontWeight: 'fontWeight',\n indent: 'indent',\n lineHeight: 'lineHeight',\n listType: 'listStyleType',\n textAlign: 'textAlign',\n textIndent: 'textIndent',\n} as const;\n\nexport const KEYS = {\n ...NODES,\n ...STYLE_KEYS,\n autoformat: 'autoformat',\n blockMenu: 'blockMenu',\n blockPlaceholder: 'blockPlaceholder',\n blockSelection: 'blockSelection',\n caption: 'caption',\n copilot: 'copilot',\n csv: 'csv',\n cursorOverlay: 'cursorOverlay',\n delete: 'delete',\n dnd: 'dnd',\n docx: 'docx',\n emoji: 'emoji',\n exitBreak: 'exitBreak',\n heading: ['h1', 'h2', 'h3', 'h4', 'h5', 'h6'] as string[],\n html: 'html',\n juice: 'juice',\n list: 'list',\n listChecked: 'checked',\n listClassic: 'listClassic',\n listRestart: 'listRestart',\n listRestartPolite: 'listRestartPolite',\n listStart: 'listStart',\n listTodo: 'todo',\n markdown: 'markdown',\n nodeId: 'nodeId',\n normalizeTypes: 'normalizeTypes',\n ol: 'decimal',\n placeholder: 'placeholder',\n playwright: 'playwright',\n removeEmptyNodes: 'removeEmptyNodes',\n resetNode: 'resetNode',\n singleBlock: 'singleBlock',\n singleLine: 'singleLine',\n slashCommand: 'slash_command',\n softBreak: 'softBreak',\n tabbable: 'tabbable',\n trailingBlock: 'trailingBlock',\n ul: 'disc',\n yjs: 'yjs',\n} as const;\n\nexport type NodeKey = (typeof NODES)[keyof typeof NODES];\nexport type StyleKey = (typeof STYLE_KEYS)[keyof typeof STYLE_KEYS];\nexport type PlateKey = (typeof KEYS)[keyof typeof KEYS];\n"],"mappings":";AAAA,MAAaA,QAAQ;CACnBC,GAAG;CACHC,IAAI;CACJC,QAAQ;CACRC,OAAO;CACPC,YAAY;CACZC,MAAM;CACNC,SAAS;CACTC,MAAM;CACNC,WAAW;CACXC,aAAa;CACbC,UAAU;CACVC,YAAY;CACZC,QAAQ;CACRC,aAAa;CACbC,SAAS;CACTC,MAAM;CACNC,YAAY;CACZC,UAAU;CACVC,YAAY;CACZC,MAAM;CACNC,IAAI;CACJC,IAAI;CACJC,IAAI;CACJC,IAAI;CACJC,IAAI;CACJC,IAAI;CACJC,WAAW;CACXC,IAAI;CACJC,KAAK;CACLC,gBAAgB;CAChBC,QAAQ;CACRC,KAAK;CACLC,IAAI;CACJC,KAAK;CACLC,MAAM;CACNC,iBAAiB;CACjBC,YAAY;CACZC,SAAS;CACTC,cAAc;CACdC,WAAW;CACXC,GAAG;CACHC,iBAAiB;CACjBC,YAAY;CACZC,eAAe;CACfC,KAAK;CACLC,YAAY;CACZC,KAAK;CACLC,OAAO;CACPC,KAAK;CACLC,UAAU;CACVC,IAAI;CACJC,IAAI;CACJC,KAAK;CACLC,QAAQ;CACRC,IAAI;CACJC,WAAW;CACXC,WAAW;CACXC,OAAO;CACR;AAED,MAAaE,aAAa;CACxBC,iBAAiB;CACjBC,OAAO;CACPC,YAAY;CACZC,UAAU;CACVC,YAAY;CACZC,QAAQ;CACRC,YAAY;CACZC,UAAU;CACVC,WAAW;CACXC,YAAY;CACb;AAED,MAAaC,OAAO;CAClB,GAAGvE;CACH,GAAG4D;CACHY,YAAY;CACZC,WAAW;CACXC,kBAAkB;CAClBC,gBAAgB;CAChBC,SAAS;CACTC,SAAS;CACTC,KAAK;CACLC,eAAe;CACfC,QAAQ;CACRC,KAAK;CACLC,MAAM;CACNC,OAAO;CACPC,WAAW;CACXC,SAAS;EAAC;EAAM;EAAM;EAAM;EAAM;EAAM;EAAK;CAC7CC,MAAM;CACNC,OAAO;CACPC,MAAM;CACNC,aAAa;CACbC,aAAa;CACbC,aAAa;CACbC,mBAAmB;CACnBC,WAAW;CACXC,UAAU;CACVC,UAAU;CACVC,QAAQ;CACRC,gBAAgB;CAChBC,IAAI;CACJC,aAAa;CACbC,YAAY;CACZC,kBAAkB;CAClBC,WAAW;CACXC,aAAa;CACbC,YAAY;CACZC,cAAc;CACdC,WAAW;CACXC,UAAU;CACVC,eAAe;CACfC,IAAI;CACJC,KAAK;CACN"}
@@ -0,0 +1,107 @@
1
+ import { PluginConfig } from "@platejs/core";
2
+ import * as _platejs_slate0 from "@platejs/slate";
3
+ import { EditorPropOptions, Path, TElement } from "@platejs/slate";
4
+ import * as _platejs_core_react0 from "@platejs/core/react";
5
+ import { PlatePluginContext } from "@platejs/core/react";
6
+
7
+ //#region src/react/hooks/useEditorString.d.ts
8
+ declare const useEditorString: () => string;
9
+ //#endregion
10
+ //#region src/react/hooks/useFormInputProps.d.ts
11
+ type InputProps = {
12
+ /**
13
+ * Should we activate the onKeyDownCapture handler to preventDefault when the
14
+ * user presses enter?
15
+ */
16
+ preventDefaultOnEnterKeydown?: boolean;
17
+ };
18
+ /**
19
+ * Hook to allow the user to spread a set of predefined props to the Div wrapper
20
+ * of an Input element
21
+ *
22
+ * @param param0 An options object which can be expanded to add further
23
+ * functionality
24
+ * @returns A props object which can be spread onto the element
25
+ */
26
+ declare const useFormInputProps: (options?: InputProps) => {
27
+ props: {
28
+ onKeyDownCapture?: undefined;
29
+ };
30
+ } | {
31
+ props: {
32
+ onKeyDownCapture: ((e: React.KeyboardEvent<HTMLDivElement>) => void) | undefined;
33
+ };
34
+ };
35
+ //#endregion
36
+ //#region src/react/hooks/useMarkToolbarButton.d.ts
37
+ declare const useMarkToolbarButtonState: ({
38
+ clear,
39
+ nodeType
40
+ }: {
41
+ nodeType: string;
42
+ clear?: string[] | string;
43
+ }) => {
44
+ clear: string | string[] | undefined;
45
+ nodeType: string;
46
+ pressed: boolean;
47
+ };
48
+ declare const useMarkToolbarButton: (state: ReturnType<typeof useMarkToolbarButtonState>) => {
49
+ props: {
50
+ pressed: boolean;
51
+ onClick: () => void;
52
+ onMouseDown: (e: React.MouseEvent<HTMLButtonElement>) => void;
53
+ };
54
+ };
55
+ //#endregion
56
+ //#region src/react/hooks/useRemoveNodeButton.d.ts
57
+ declare const useRemoveNodeButton: ({
58
+ element
59
+ }: {
60
+ element: TElement;
61
+ }) => {
62
+ props: {
63
+ onClick: () => void;
64
+ onMouseDown: (e: React.MouseEvent<HTMLButtonElement>) => void;
65
+ };
66
+ };
67
+ //#endregion
68
+ //#region src/react/hooks/useSelection.d.ts
69
+ declare function useSelectionCollapsed(): boolean;
70
+ declare function useSelectionExpanded(): boolean;
71
+ declare function useSelectionWithinBlock(): boolean;
72
+ declare function useSelectionAcrossBlocks(): boolean;
73
+ //#endregion
74
+ //#region src/react/hooks/useSelectionFragment.d.ts
75
+ declare const useSelectionFragment: () => _platejs_slate0.ElementOrTextIn<_platejs_slate0.Value>[];
76
+ declare const useSelectionFragmentProp: (options?: Omit<EditorPropOptions, "nodes">) => string | undefined;
77
+ //#endregion
78
+ //#region src/react/plugins/BlockPlaceholderPlugin.d.ts
79
+ type BlockPlaceholderConfig = PluginConfig<'blockPlaceholder', {
80
+ _target: {
81
+ node: TElement;
82
+ placeholder: string;
83
+ } | null;
84
+ placeholders: Record<string, string>;
85
+ query: (context: PlatePluginContext<BlockPlaceholderConfig> & {
86
+ node: TElement;
87
+ path: Path;
88
+ }) => boolean;
89
+ className?: string;
90
+ }>;
91
+ declare const BlockPlaceholderPlugin: _platejs_core_react0.PlatePlugin<PluginConfig<"blockPlaceholder", {
92
+ _target: {
93
+ node: TElement;
94
+ placeholder: string;
95
+ } | null;
96
+ placeholders: Record<string, string>;
97
+ query: (context: PlatePluginContext<BlockPlaceholderConfig> & {
98
+ node: TElement;
99
+ path: Path;
100
+ }) => boolean;
101
+ className?: string;
102
+ }, {}, {}, {
103
+ placeholder: (node: TElement) => string | undefined;
104
+ }>>;
105
+ //#endregion
106
+ export { BlockPlaceholderConfig, BlockPlaceholderPlugin, useEditorString, useFormInputProps, useMarkToolbarButton, useMarkToolbarButtonState, useRemoveNodeButton, useSelectionAcrossBlocks, useSelectionCollapsed, useSelectionExpanded, useSelectionFragment, useSelectionFragmentProp, useSelectionWithinBlock };
107
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","names":[],"sources":["../../src/react/hooks/useEditorString.ts","../../src/react/hooks/useFormInputProps.ts","../../src/react/hooks/useMarkToolbarButton.ts","../../src/react/hooks/useRemoveNodeButton.ts","../../src/react/hooks/useSelection.ts","../../src/react/hooks/useSelectionFragment.ts","../../src/react/plugins/BlockPlaceholderPlugin.tsx"],"sourcesContent":[],"mappings":";;;;;;;cAEa;;;KCFR,UAAA;;;;;;;ADEL;;;;;ACcA;;;AAmCoB,cAnCP,iBAmCO,EAAA,CAAA,OAAA,CAAA,EAnC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