hazo_ui 6.7.0 → 6.8.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/CHANGE_LOG.md +55 -0
- package/dist/index.cjs +28 -8
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +16 -1
- package/dist/index.d.ts +16 -1
- package/dist/index.js +28 -8
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.d.cts
CHANGED
|
@@ -565,6 +565,11 @@ interface CommandItem$1 {
|
|
|
565
565
|
icon?: React$1.ReactNode;
|
|
566
566
|
/** Optional group name for categorizing commands in the dropdown */
|
|
567
567
|
group?: string;
|
|
568
|
+
/**
|
|
569
|
+
* Text inserted instead of a pill, for prefixes configured with
|
|
570
|
+
* `insert_as_text`. Defaults to `action`. Ignored by pill prefixes.
|
|
571
|
+
*/
|
|
572
|
+
insert_text?: string;
|
|
568
573
|
}
|
|
569
574
|
/**
|
|
570
575
|
* Configuration for a prefix trigger character
|
|
@@ -578,6 +583,14 @@ interface PrefixConfig {
|
|
|
578
583
|
allow_free_text?: boolean;
|
|
579
584
|
/** Custom color styling for this prefix's pills */
|
|
580
585
|
color?: PrefixColor;
|
|
586
|
+
/**
|
|
587
|
+
* Insert the picked command as plain, editable text instead of a pill, and
|
|
588
|
+
* drop the trigger character with it. For `/`-style snippet menus, where the
|
|
589
|
+
* menu is a way to discover and type something rather than a reference to an
|
|
590
|
+
* entity — the inserted characters must survive as text (e.g. a formula's
|
|
591
|
+
* `SUM(`), and no `InsertedCommand` is reported for them.
|
|
592
|
+
*/
|
|
593
|
+
insert_as_text?: boolean;
|
|
581
594
|
}
|
|
582
595
|
/**
|
|
583
596
|
* Represents a command that has been inserted into the text
|
|
@@ -867,6 +880,8 @@ type PrefixConfigForParsing = {
|
|
|
867
880
|
action_label: string;
|
|
868
881
|
}[];
|
|
869
882
|
color?: PrefixColor;
|
|
883
|
+
/** Text prefixes never produce pills, so they are skipped when parsing. */
|
|
884
|
+
insert_as_text?: boolean;
|
|
870
885
|
};
|
|
871
886
|
/**
|
|
872
887
|
* Utility to parse plain text with commands into structured format
|
|
@@ -875,7 +890,7 @@ type PrefixConfigForParsing = {
|
|
|
875
890
|
* @param prefixes - Prefix configurations to detect
|
|
876
891
|
* @returns Parsed commands with positions
|
|
877
892
|
*/
|
|
878
|
-
declare const parse_commands_from_text: (text: string,
|
|
893
|
+
declare const parse_commands_from_text: (text: string, all_prefixes: PrefixConfigForParsing[]) => {
|
|
879
894
|
action: string;
|
|
880
895
|
action_label: string;
|
|
881
896
|
prefix: string;
|
package/dist/index.d.ts
CHANGED
|
@@ -565,6 +565,11 @@ interface CommandItem$1 {
|
|
|
565
565
|
icon?: React$1.ReactNode;
|
|
566
566
|
/** Optional group name for categorizing commands in the dropdown */
|
|
567
567
|
group?: string;
|
|
568
|
+
/**
|
|
569
|
+
* Text inserted instead of a pill, for prefixes configured with
|
|
570
|
+
* `insert_as_text`. Defaults to `action`. Ignored by pill prefixes.
|
|
571
|
+
*/
|
|
572
|
+
insert_text?: string;
|
|
568
573
|
}
|
|
569
574
|
/**
|
|
570
575
|
* Configuration for a prefix trigger character
|
|
@@ -578,6 +583,14 @@ interface PrefixConfig {
|
|
|
578
583
|
allow_free_text?: boolean;
|
|
579
584
|
/** Custom color styling for this prefix's pills */
|
|
580
585
|
color?: PrefixColor;
|
|
586
|
+
/**
|
|
587
|
+
* Insert the picked command as plain, editable text instead of a pill, and
|
|
588
|
+
* drop the trigger character with it. For `/`-style snippet menus, where the
|
|
589
|
+
* menu is a way to discover and type something rather than a reference to an
|
|
590
|
+
* entity — the inserted characters must survive as text (e.g. a formula's
|
|
591
|
+
* `SUM(`), and no `InsertedCommand` is reported for them.
|
|
592
|
+
*/
|
|
593
|
+
insert_as_text?: boolean;
|
|
581
594
|
}
|
|
582
595
|
/**
|
|
583
596
|
* Represents a command that has been inserted into the text
|
|
@@ -867,6 +880,8 @@ type PrefixConfigForParsing = {
|
|
|
867
880
|
action_label: string;
|
|
868
881
|
}[];
|
|
869
882
|
color?: PrefixColor;
|
|
883
|
+
/** Text prefixes never produce pills, so they are skipped when parsing. */
|
|
884
|
+
insert_as_text?: boolean;
|
|
870
885
|
};
|
|
871
886
|
/**
|
|
872
887
|
* Utility to parse plain text with commands into structured format
|
|
@@ -875,7 +890,7 @@ type PrefixConfigForParsing = {
|
|
|
875
890
|
* @param prefixes - Prefix configurations to detect
|
|
876
891
|
* @returns Parsed commands with positions
|
|
877
892
|
*/
|
|
878
|
-
declare const parse_commands_from_text: (text: string,
|
|
893
|
+
declare const parse_commands_from_text: (text: string, all_prefixes: PrefixConfigForParsing[]) => {
|
|
879
894
|
action: string;
|
|
880
895
|
action_label: string;
|
|
881
896
|
prefix: string;
|
package/dist/index.js
CHANGED
|
@@ -5585,6 +5585,9 @@ var insert_command_at_position = (editor, command, prefix, range, variant = "def
|
|
|
5585
5585
|
color: color2
|
|
5586
5586
|
}).run();
|
|
5587
5587
|
};
|
|
5588
|
+
var insert_text_at_position = (editor, command, range) => {
|
|
5589
|
+
editor.chain().focus().deleteRange(range).insertContent(command.insert_text ?? command.action).run();
|
|
5590
|
+
};
|
|
5588
5591
|
var get_variant_classes2 = (variant = "default") => {
|
|
5589
5592
|
switch (variant) {
|
|
5590
5593
|
case "outline":
|
|
@@ -5787,7 +5790,9 @@ var CommandPopover = ({
|
|
|
5787
5790
|
CommandPopover.displayName = "CommandPopover";
|
|
5788
5791
|
|
|
5789
5792
|
// src/components/hazo_ui_command/index.tsx
|
|
5790
|
-
var parse_commands_from_text = (text,
|
|
5793
|
+
var parse_commands_from_text = (text, all_prefixes) => {
|
|
5794
|
+
const prefixes = all_prefixes.filter((p) => !p.insert_as_text);
|
|
5795
|
+
if (prefixes.length === 0) return [];
|
|
5791
5796
|
const result = [];
|
|
5792
5797
|
const action_to_label = /* @__PURE__ */ new Map();
|
|
5793
5798
|
for (const prefix_config of prefixes) {
|
|
@@ -6097,13 +6102,18 @@ var HazoUiTextbox = ({
|
|
|
6097
6102
|
}
|
|
6098
6103
|
}, [suggestion_state, editor]);
|
|
6099
6104
|
React27.useEffect(() => {
|
|
6100
|
-
if (is_controlled
|
|
6101
|
-
|
|
6102
|
-
|
|
6103
|
-
|
|
6104
|
-
|
|
6105
|
-
|
|
6106
|
-
|
|
6105
|
+
if (!is_controlled || !editor || editor.isFocused) return;
|
|
6106
|
+
if (value === editor.getText()) return;
|
|
6107
|
+
let cancelled = false;
|
|
6108
|
+
queueMicrotask(() => {
|
|
6109
|
+
if (cancelled || editor.isDestroyed || editor.isFocused) return;
|
|
6110
|
+
if (value === editor.getText()) return;
|
|
6111
|
+
const content = text_to_tiptap_content(value || "", prefixes, pill_variant);
|
|
6112
|
+
editor.commands.setContent(content, { emitUpdate: false });
|
|
6113
|
+
});
|
|
6114
|
+
return () => {
|
|
6115
|
+
cancelled = true;
|
|
6116
|
+
};
|
|
6107
6117
|
}, [value, editor, is_controlled, prefixes, pill_variant]);
|
|
6108
6118
|
React27.useEffect(() => {
|
|
6109
6119
|
if (editor) {
|
|
@@ -6115,6 +6125,11 @@ var HazoUiTextbox = ({
|
|
|
6115
6125
|
if (!editor || !suggestion_state) return;
|
|
6116
6126
|
const prefix_config = prefixes.find((p) => p.char === suggestion_state.prefix);
|
|
6117
6127
|
const prefix_color = prefix_config?.color;
|
|
6128
|
+
if (prefix_config?.insert_as_text) {
|
|
6129
|
+
insert_text_at_position(editor, command, suggestion_state.range);
|
|
6130
|
+
set_suggestion_state(null);
|
|
6131
|
+
return;
|
|
6132
|
+
}
|
|
6118
6133
|
insert_command_at_position(
|
|
6119
6134
|
editor,
|
|
6120
6135
|
command,
|
|
@@ -6665,6 +6680,11 @@ var HazoUiTextarea = ({
|
|
|
6665
6680
|
if (!editor || !suggestion_state) return;
|
|
6666
6681
|
const prefix_config = prefixes.find((p) => p.char === suggestion_state.prefix);
|
|
6667
6682
|
const prefix_color = prefix_config?.color;
|
|
6683
|
+
if (prefix_config?.insert_as_text) {
|
|
6684
|
+
insert_text_at_position(editor, command, suggestion_state.range);
|
|
6685
|
+
set_suggestion_state(null);
|
|
6686
|
+
return;
|
|
6687
|
+
}
|
|
6668
6688
|
insert_command_at_position(
|
|
6669
6689
|
editor,
|
|
6670
6690
|
command,
|