hazo_ui 2.4.5 → 2.5.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/dist/index.cjs +101 -19
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +33 -15
- package/dist/index.d.ts +33 -15
- package/dist/index.js +101 -19
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.d.cts
CHANGED
|
@@ -170,6 +170,17 @@ declare const HazoUiRte: React.FC<HazoUiRteProps>;
|
|
|
170
170
|
* prefix-triggered command menus (e.g., @mentions, /commands, #tags).
|
|
171
171
|
*/
|
|
172
172
|
|
|
173
|
+
/**
|
|
174
|
+
* Custom color configuration for prefix styling
|
|
175
|
+
*/
|
|
176
|
+
interface PrefixColor {
|
|
177
|
+
/** Background color (e.g., "#E0F2FE", "hsl(200, 95%, 90%)") */
|
|
178
|
+
bg?: string;
|
|
179
|
+
/** Text/foreground color (e.g., "#0369A1", "hsl(200, 70%, 30%)") */
|
|
180
|
+
fg?: string;
|
|
181
|
+
/** Border color (e.g., "#7DD3FC", "hsl(200, 80%, 70%)") */
|
|
182
|
+
border?: string;
|
|
183
|
+
}
|
|
173
184
|
/**
|
|
174
185
|
* Individual command item that can be selected from the command menu
|
|
175
186
|
*/
|
|
@@ -195,6 +206,8 @@ interface PrefixConfig {
|
|
|
195
206
|
commands: CommandItem[];
|
|
196
207
|
/** Allow free text entries that don't match existing commands */
|
|
197
208
|
allow_free_text?: boolean;
|
|
209
|
+
/** Custom color styling for this prefix's pills */
|
|
210
|
+
color?: PrefixColor;
|
|
198
211
|
}
|
|
199
212
|
/**
|
|
200
213
|
* Represents a command that has been inserted into the text
|
|
@@ -251,6 +264,8 @@ interface CommandPopoverProps {
|
|
|
251
264
|
on_close: () => void;
|
|
252
265
|
/** Called when selection changes via keyboard */
|
|
253
266
|
on_selection_change: (index: number) => void;
|
|
267
|
+
/** Custom color for the prefix (shows color indicator dot) */
|
|
268
|
+
prefix_color?: PrefixColor;
|
|
254
269
|
}
|
|
255
270
|
/**
|
|
256
271
|
* Props for the command pill component
|
|
@@ -268,6 +283,8 @@ interface CommandPillProps {
|
|
|
268
283
|
selected?: boolean;
|
|
269
284
|
/** Pill style variant */
|
|
270
285
|
variant?: "default" | "outline" | "subtle";
|
|
286
|
+
/** Custom color styling (overrides variant when provided) */
|
|
287
|
+
color?: PrefixColor;
|
|
271
288
|
/** Called when the pill is clicked (to open edit popover) */
|
|
272
289
|
on_click?: () => void;
|
|
273
290
|
}
|
|
@@ -368,6 +385,7 @@ declare module "@tiptap/core" {
|
|
|
368
385
|
action: string;
|
|
369
386
|
action_label: string;
|
|
370
387
|
variant?: "default" | "outline" | "subtle";
|
|
388
|
+
color?: PrefixColor;
|
|
371
389
|
}) => ReturnType;
|
|
372
390
|
/**
|
|
373
391
|
* Update an existing command node by ID
|
|
@@ -452,24 +470,30 @@ declare const CommandPopover: React.FC<CommandPopoverProps>;
|
|
|
452
470
|
*/
|
|
453
471
|
|
|
454
472
|
/**
|
|
455
|
-
*
|
|
456
|
-
*
|
|
457
|
-
* @param text - Plain text with prefix + action format (e.g., "Hello @user_123")
|
|
458
|
-
* @param prefixes - Prefix configurations to detect
|
|
459
|
-
* @returns Parsed commands with positions
|
|
473
|
+
* Extended prefix configuration type for internal parsing
|
|
460
474
|
*/
|
|
461
|
-
|
|
475
|
+
type PrefixConfigForParsing = {
|
|
462
476
|
char: string;
|
|
463
477
|
commands: {
|
|
464
478
|
action: string;
|
|
465
479
|
action_label: string;
|
|
466
480
|
}[];
|
|
467
|
-
|
|
481
|
+
color?: PrefixColor;
|
|
482
|
+
};
|
|
483
|
+
/**
|
|
484
|
+
* Utility to parse plain text with commands into structured format
|
|
485
|
+
*
|
|
486
|
+
* @param text - Plain text with prefix + action format (e.g., "Hello @user_123")
|
|
487
|
+
* @param prefixes - Prefix configurations to detect
|
|
488
|
+
* @returns Parsed commands with positions
|
|
489
|
+
*/
|
|
490
|
+
declare const parse_commands_from_text: (text: string, prefixes: PrefixConfigForParsing[]) => {
|
|
468
491
|
action: string;
|
|
469
492
|
action_label: string;
|
|
470
493
|
prefix: string;
|
|
471
494
|
position: number;
|
|
472
495
|
length: number;
|
|
496
|
+
color?: PrefixColor;
|
|
473
497
|
}[];
|
|
474
498
|
/**
|
|
475
499
|
* Convert parsed commands to TipTap content structure
|
|
@@ -479,13 +503,7 @@ declare const parse_commands_from_text: (text: string, prefixes: {
|
|
|
479
503
|
* @param variant - Pill variant style
|
|
480
504
|
* @returns TipTap JSON content structure
|
|
481
505
|
*/
|
|
482
|
-
declare const text_to_tiptap_content: (text: string, prefixes:
|
|
483
|
-
char: string;
|
|
484
|
-
commands: {
|
|
485
|
-
action: string;
|
|
486
|
-
action_label: string;
|
|
487
|
-
}[];
|
|
488
|
-
}[], variant?: "default" | "outline" | "subtle") => Record<string, unknown>;
|
|
506
|
+
declare const text_to_tiptap_content: (text: string, prefixes: PrefixConfigForParsing[], variant?: "default" | "outline" | "subtle") => Record<string, unknown>;
|
|
489
507
|
|
|
490
508
|
/**
|
|
491
509
|
* HazoUiTextbox - Single-line Input with Command Support
|
|
@@ -511,4 +529,4 @@ declare const HazoUiTextbox: React.FC<HazoUiTextboxProps>;
|
|
|
511
529
|
*/
|
|
512
530
|
declare const HazoUiTextarea: React.FC<HazoUiTextareaProps>;
|
|
513
531
|
|
|
514
|
-
export { type BaseCommandInputProps, type CommandEditContext, type CommandItem, CommandNodeExtension, CommandPill, type CommandPillProps, CommandPopover, type CommandPopoverProps, type CommandTextOutput, type FilterConfig, type FilterField, HazoUiFlexInput, type HazoUiFlexInputProps, HazoUiFlexRadio, type HazoUiFlexRadioItem, type HazoUiFlexRadioProps, HazoUiMultiFilterDialog, HazoUiMultiSortDialog, HazoUiRte, type HazoUiRteProps, HazoUiTextarea, type HazoUiTextareaProps, HazoUiTextbox, type HazoUiTextboxProps, type InsertedCommand, type PrefixConfig, type RteAttachment, type RteOutput, type RteVariable, type SortConfig, type SortField, type SuggestionState, create_command_suggestion_extension, parse_commands_from_text, text_to_tiptap_content };
|
|
532
|
+
export { type BaseCommandInputProps, type CommandEditContext, type CommandItem, CommandNodeExtension, CommandPill, type CommandPillProps, CommandPopover, type CommandPopoverProps, type CommandTextOutput, type FilterConfig, type FilterField, HazoUiFlexInput, type HazoUiFlexInputProps, HazoUiFlexRadio, type HazoUiFlexRadioItem, type HazoUiFlexRadioProps, HazoUiMultiFilterDialog, HazoUiMultiSortDialog, HazoUiRte, type HazoUiRteProps, HazoUiTextarea, type HazoUiTextareaProps, HazoUiTextbox, type HazoUiTextboxProps, type InsertedCommand, type PrefixColor, type PrefixConfig, type RteAttachment, type RteOutput, type RteVariable, type SortConfig, type SortField, type SuggestionState, create_command_suggestion_extension, parse_commands_from_text, text_to_tiptap_content };
|
package/dist/index.d.ts
CHANGED
|
@@ -170,6 +170,17 @@ declare const HazoUiRte: React.FC<HazoUiRteProps>;
|
|
|
170
170
|
* prefix-triggered command menus (e.g., @mentions, /commands, #tags).
|
|
171
171
|
*/
|
|
172
172
|
|
|
173
|
+
/**
|
|
174
|
+
* Custom color configuration for prefix styling
|
|
175
|
+
*/
|
|
176
|
+
interface PrefixColor {
|
|
177
|
+
/** Background color (e.g., "#E0F2FE", "hsl(200, 95%, 90%)") */
|
|
178
|
+
bg?: string;
|
|
179
|
+
/** Text/foreground color (e.g., "#0369A1", "hsl(200, 70%, 30%)") */
|
|
180
|
+
fg?: string;
|
|
181
|
+
/** Border color (e.g., "#7DD3FC", "hsl(200, 80%, 70%)") */
|
|
182
|
+
border?: string;
|
|
183
|
+
}
|
|
173
184
|
/**
|
|
174
185
|
* Individual command item that can be selected from the command menu
|
|
175
186
|
*/
|
|
@@ -195,6 +206,8 @@ interface PrefixConfig {
|
|
|
195
206
|
commands: CommandItem[];
|
|
196
207
|
/** Allow free text entries that don't match existing commands */
|
|
197
208
|
allow_free_text?: boolean;
|
|
209
|
+
/** Custom color styling for this prefix's pills */
|
|
210
|
+
color?: PrefixColor;
|
|
198
211
|
}
|
|
199
212
|
/**
|
|
200
213
|
* Represents a command that has been inserted into the text
|
|
@@ -251,6 +264,8 @@ interface CommandPopoverProps {
|
|
|
251
264
|
on_close: () => void;
|
|
252
265
|
/** Called when selection changes via keyboard */
|
|
253
266
|
on_selection_change: (index: number) => void;
|
|
267
|
+
/** Custom color for the prefix (shows color indicator dot) */
|
|
268
|
+
prefix_color?: PrefixColor;
|
|
254
269
|
}
|
|
255
270
|
/**
|
|
256
271
|
* Props for the command pill component
|
|
@@ -268,6 +283,8 @@ interface CommandPillProps {
|
|
|
268
283
|
selected?: boolean;
|
|
269
284
|
/** Pill style variant */
|
|
270
285
|
variant?: "default" | "outline" | "subtle";
|
|
286
|
+
/** Custom color styling (overrides variant when provided) */
|
|
287
|
+
color?: PrefixColor;
|
|
271
288
|
/** Called when the pill is clicked (to open edit popover) */
|
|
272
289
|
on_click?: () => void;
|
|
273
290
|
}
|
|
@@ -368,6 +385,7 @@ declare module "@tiptap/core" {
|
|
|
368
385
|
action: string;
|
|
369
386
|
action_label: string;
|
|
370
387
|
variant?: "default" | "outline" | "subtle";
|
|
388
|
+
color?: PrefixColor;
|
|
371
389
|
}) => ReturnType;
|
|
372
390
|
/**
|
|
373
391
|
* Update an existing command node by ID
|
|
@@ -452,24 +470,30 @@ declare const CommandPopover: React.FC<CommandPopoverProps>;
|
|
|
452
470
|
*/
|
|
453
471
|
|
|
454
472
|
/**
|
|
455
|
-
*
|
|
456
|
-
*
|
|
457
|
-
* @param text - Plain text with prefix + action format (e.g., "Hello @user_123")
|
|
458
|
-
* @param prefixes - Prefix configurations to detect
|
|
459
|
-
* @returns Parsed commands with positions
|
|
473
|
+
* Extended prefix configuration type for internal parsing
|
|
460
474
|
*/
|
|
461
|
-
|
|
475
|
+
type PrefixConfigForParsing = {
|
|
462
476
|
char: string;
|
|
463
477
|
commands: {
|
|
464
478
|
action: string;
|
|
465
479
|
action_label: string;
|
|
466
480
|
}[];
|
|
467
|
-
|
|
481
|
+
color?: PrefixColor;
|
|
482
|
+
};
|
|
483
|
+
/**
|
|
484
|
+
* Utility to parse plain text with commands into structured format
|
|
485
|
+
*
|
|
486
|
+
* @param text - Plain text with prefix + action format (e.g., "Hello @user_123")
|
|
487
|
+
* @param prefixes - Prefix configurations to detect
|
|
488
|
+
* @returns Parsed commands with positions
|
|
489
|
+
*/
|
|
490
|
+
declare const parse_commands_from_text: (text: string, prefixes: PrefixConfigForParsing[]) => {
|
|
468
491
|
action: string;
|
|
469
492
|
action_label: string;
|
|
470
493
|
prefix: string;
|
|
471
494
|
position: number;
|
|
472
495
|
length: number;
|
|
496
|
+
color?: PrefixColor;
|
|
473
497
|
}[];
|
|
474
498
|
/**
|
|
475
499
|
* Convert parsed commands to TipTap content structure
|
|
@@ -479,13 +503,7 @@ declare const parse_commands_from_text: (text: string, prefixes: {
|
|
|
479
503
|
* @param variant - Pill variant style
|
|
480
504
|
* @returns TipTap JSON content structure
|
|
481
505
|
*/
|
|
482
|
-
declare const text_to_tiptap_content: (text: string, prefixes:
|
|
483
|
-
char: string;
|
|
484
|
-
commands: {
|
|
485
|
-
action: string;
|
|
486
|
-
action_label: string;
|
|
487
|
-
}[];
|
|
488
|
-
}[], variant?: "default" | "outline" | "subtle") => Record<string, unknown>;
|
|
506
|
+
declare const text_to_tiptap_content: (text: string, prefixes: PrefixConfigForParsing[], variant?: "default" | "outline" | "subtle") => Record<string, unknown>;
|
|
489
507
|
|
|
490
508
|
/**
|
|
491
509
|
* HazoUiTextbox - Single-line Input with Command Support
|
|
@@ -511,4 +529,4 @@ declare const HazoUiTextbox: React.FC<HazoUiTextboxProps>;
|
|
|
511
529
|
*/
|
|
512
530
|
declare const HazoUiTextarea: React.FC<HazoUiTextareaProps>;
|
|
513
531
|
|
|
514
|
-
export { type BaseCommandInputProps, type CommandEditContext, type CommandItem, CommandNodeExtension, CommandPill, type CommandPillProps, CommandPopover, type CommandPopoverProps, type CommandTextOutput, type FilterConfig, type FilterField, HazoUiFlexInput, type HazoUiFlexInputProps, HazoUiFlexRadio, type HazoUiFlexRadioItem, type HazoUiFlexRadioProps, HazoUiMultiFilterDialog, HazoUiMultiSortDialog, HazoUiRte, type HazoUiRteProps, HazoUiTextarea, type HazoUiTextareaProps, HazoUiTextbox, type HazoUiTextboxProps, type InsertedCommand, type PrefixConfig, type RteAttachment, type RteOutput, type RteVariable, type SortConfig, type SortField, type SuggestionState, create_command_suggestion_extension, parse_commands_from_text, text_to_tiptap_content };
|
|
532
|
+
export { type BaseCommandInputProps, type CommandEditContext, type CommandItem, CommandNodeExtension, CommandPill, type CommandPillProps, CommandPopover, type CommandPopoverProps, type CommandTextOutput, type FilterConfig, type FilterField, HazoUiFlexInput, type HazoUiFlexInputProps, HazoUiFlexRadio, type HazoUiFlexRadioItem, type HazoUiFlexRadioProps, HazoUiMultiFilterDialog, HazoUiMultiSortDialog, HazoUiRte, type HazoUiRteProps, HazoUiTextarea, type HazoUiTextareaProps, HazoUiTextbox, type HazoUiTextboxProps, type InsertedCommand, type PrefixColor, type PrefixConfig, type RteAttachment, type RteOutput, type RteVariable, type SortConfig, type SortField, type SuggestionState, create_command_suggestion_extension, parse_commands_from_text, text_to_tiptap_content };
|
package/dist/index.js
CHANGED
|
@@ -4279,8 +4279,21 @@ var get_variant_classes = (variant = "default") => {
|
|
|
4279
4279
|
return "bg-primary/10 text-primary border-primary/20";
|
|
4280
4280
|
}
|
|
4281
4281
|
};
|
|
4282
|
+
var get_custom_color_styles = (color_bg, color_fg, color_border) => {
|
|
4283
|
+
if (!color_bg && !color_fg && !color_border) {
|
|
4284
|
+
return {};
|
|
4285
|
+
}
|
|
4286
|
+
return {
|
|
4287
|
+
...color_bg && { backgroundColor: color_bg },
|
|
4288
|
+
...color_fg && { color: color_fg },
|
|
4289
|
+
...color_border && { borderColor: color_border }
|
|
4290
|
+
};
|
|
4291
|
+
};
|
|
4292
|
+
var has_custom_colors = (color_bg, color_fg, color_border) => {
|
|
4293
|
+
return Boolean(color_bg || color_fg || color_border);
|
|
4294
|
+
};
|
|
4282
4295
|
var CommandPillView = ({ node, selected, editor }) => {
|
|
4283
|
-
const { prefix, action, action_label, id, variant } = node.attrs;
|
|
4296
|
+
const { prefix, action, action_label, id, variant, color_bg, color_fg, color_border } = node.attrs;
|
|
4284
4297
|
const handle_click = () => {
|
|
4285
4298
|
const event = new CustomEvent("command-pill-click", {
|
|
4286
4299
|
detail: {
|
|
@@ -4294,6 +4307,8 @@ var CommandPillView = ({ node, selected, editor }) => {
|
|
|
4294
4307
|
});
|
|
4295
4308
|
document.dispatchEvent(event);
|
|
4296
4309
|
};
|
|
4310
|
+
const use_custom_colors = has_custom_colors(color_bg, color_fg, color_border);
|
|
4311
|
+
const custom_styles = get_custom_color_styles(color_bg, color_fg, color_border);
|
|
4297
4312
|
return /* @__PURE__ */ jsx(NodeViewWrapper, { as: "span", className: "inline", children: /* @__PURE__ */ jsxs(
|
|
4298
4313
|
"span",
|
|
4299
4314
|
{
|
|
@@ -4306,17 +4321,19 @@ var CommandPillView = ({ node, selected, editor }) => {
|
|
|
4306
4321
|
"border",
|
|
4307
4322
|
"cursor-pointer select-none",
|
|
4308
4323
|
"transition-all duration-150",
|
|
4309
|
-
|
|
4324
|
+
// Only apply variant classes if no custom colors
|
|
4325
|
+
!use_custom_colors && get_variant_classes(variant),
|
|
4310
4326
|
selected && "ring-2 ring-ring ring-offset-1",
|
|
4311
4327
|
"hover:opacity-80"
|
|
4312
4328
|
),
|
|
4329
|
+
style: custom_styles,
|
|
4313
4330
|
contentEditable: false,
|
|
4314
4331
|
"data-command-id": id,
|
|
4315
4332
|
"data-command-prefix": prefix,
|
|
4316
4333
|
"data-command-action": action,
|
|
4317
4334
|
onClick: handle_click,
|
|
4318
4335
|
children: [
|
|
4319
|
-
/* @__PURE__ */ jsx("span", { className: "text-muted-foreground opacity-70", children: prefix }),
|
|
4336
|
+
/* @__PURE__ */ jsx("span", { className: cn(!use_custom_colors && "text-muted-foreground opacity-70"), style: use_custom_colors ? { opacity: 0.7 } : void 0, children: prefix }),
|
|
4320
4337
|
/* @__PURE__ */ jsx("span", { children: action_label })
|
|
4321
4338
|
]
|
|
4322
4339
|
}
|
|
@@ -4368,6 +4385,27 @@ var CommandNodeExtension = Node.create({
|
|
|
4368
4385
|
renderHTML: (attributes) => ({
|
|
4369
4386
|
"data-command-variant": attributes.variant
|
|
4370
4387
|
})
|
|
4388
|
+
},
|
|
4389
|
+
color_bg: {
|
|
4390
|
+
default: null,
|
|
4391
|
+
parseHTML: (element) => element.getAttribute("data-command-color-bg"),
|
|
4392
|
+
renderHTML: (attributes) => ({
|
|
4393
|
+
"data-command-color-bg": attributes.color_bg
|
|
4394
|
+
})
|
|
4395
|
+
},
|
|
4396
|
+
color_fg: {
|
|
4397
|
+
default: null,
|
|
4398
|
+
parseHTML: (element) => element.getAttribute("data-command-color-fg"),
|
|
4399
|
+
renderHTML: (attributes) => ({
|
|
4400
|
+
"data-command-color-fg": attributes.color_fg
|
|
4401
|
+
})
|
|
4402
|
+
},
|
|
4403
|
+
color_border: {
|
|
4404
|
+
default: null,
|
|
4405
|
+
parseHTML: (element) => element.getAttribute("data-command-color-border"),
|
|
4406
|
+
renderHTML: (attributes) => ({
|
|
4407
|
+
"data-command-color-border": attributes.color_border
|
|
4408
|
+
})
|
|
4371
4409
|
}
|
|
4372
4410
|
};
|
|
4373
4411
|
},
|
|
@@ -4398,11 +4436,15 @@ var CommandNodeExtension = Node.create({
|
|
|
4398
4436
|
addCommands() {
|
|
4399
4437
|
return {
|
|
4400
4438
|
insertCommand: (attrs) => ({ commands }) => {
|
|
4439
|
+
const { color: color2, ...rest_attrs } = attrs;
|
|
4401
4440
|
return commands.insertContent({
|
|
4402
4441
|
type: this.name,
|
|
4403
4442
|
attrs: {
|
|
4404
|
-
...
|
|
4405
|
-
id: generate_command_id()
|
|
4443
|
+
...rest_attrs,
|
|
4444
|
+
id: generate_command_id(),
|
|
4445
|
+
...color2?.bg && { color_bg: color2.bg },
|
|
4446
|
+
...color2?.fg && { color_fg: color2.fg },
|
|
4447
|
+
...color2?.border && { color_border: color2.border }
|
|
4406
4448
|
}
|
|
4407
4449
|
});
|
|
4408
4450
|
},
|
|
@@ -4527,12 +4569,13 @@ var create_command_suggestion_extension = (config) => {
|
|
|
4527
4569
|
});
|
|
4528
4570
|
});
|
|
4529
4571
|
};
|
|
4530
|
-
var insert_command_at_position = (editor, command, prefix, range, variant = "default") => {
|
|
4572
|
+
var insert_command_at_position = (editor, command, prefix, range, variant = "default", color2) => {
|
|
4531
4573
|
editor.chain().focus().deleteRange(range).insertCommand({
|
|
4532
4574
|
prefix,
|
|
4533
4575
|
action: command.action,
|
|
4534
4576
|
action_label: command.action_label,
|
|
4535
|
-
variant
|
|
4577
|
+
variant,
|
|
4578
|
+
color: color2
|
|
4536
4579
|
}).run();
|
|
4537
4580
|
};
|
|
4538
4581
|
var get_variant_classes2 = (variant = "default") => {
|
|
@@ -4546,6 +4589,16 @@ var get_variant_classes2 = (variant = "default") => {
|
|
|
4546
4589
|
return "bg-primary/10 text-primary border-primary/20 hover:bg-primary/15";
|
|
4547
4590
|
}
|
|
4548
4591
|
};
|
|
4592
|
+
var get_custom_color_styles2 = (color2) => {
|
|
4593
|
+
if (!color2) {
|
|
4594
|
+
return {};
|
|
4595
|
+
}
|
|
4596
|
+
return {
|
|
4597
|
+
...color2.bg && { backgroundColor: color2.bg },
|
|
4598
|
+
...color2.fg && { color: color2.fg },
|
|
4599
|
+
...color2.border && { borderColor: color2.border }
|
|
4600
|
+
};
|
|
4601
|
+
};
|
|
4549
4602
|
var CommandPill = ({
|
|
4550
4603
|
prefix,
|
|
4551
4604
|
action,
|
|
@@ -4553,8 +4606,11 @@ var CommandPill = ({
|
|
|
4553
4606
|
id,
|
|
4554
4607
|
selected = false,
|
|
4555
4608
|
variant = "default",
|
|
4609
|
+
color: color2,
|
|
4556
4610
|
on_click
|
|
4557
4611
|
}) => {
|
|
4612
|
+
const use_custom_colors = Boolean(color2?.bg || color2?.fg || color2?.border);
|
|
4613
|
+
const custom_styles = get_custom_color_styles2(color2);
|
|
4558
4614
|
return /* @__PURE__ */ jsxs(
|
|
4559
4615
|
"span",
|
|
4560
4616
|
{
|
|
@@ -4566,10 +4622,12 @@ var CommandPill = ({
|
|
|
4566
4622
|
"text-sm font-medium",
|
|
4567
4623
|
"border",
|
|
4568
4624
|
"transition-all duration-150",
|
|
4569
|
-
|
|
4625
|
+
// Only apply variant classes if no custom colors
|
|
4626
|
+
!use_custom_colors && get_variant_classes2(variant),
|
|
4570
4627
|
selected && "ring-2 ring-ring ring-offset-1",
|
|
4571
4628
|
on_click && "cursor-pointer"
|
|
4572
4629
|
),
|
|
4630
|
+
style: custom_styles,
|
|
4573
4631
|
"data-command-id": id,
|
|
4574
4632
|
"data-command-prefix": prefix,
|
|
4575
4633
|
"data-command-action": action,
|
|
@@ -4583,7 +4641,7 @@ var CommandPill = ({
|
|
|
4583
4641
|
}
|
|
4584
4642
|
},
|
|
4585
4643
|
children: [
|
|
4586
|
-
/* @__PURE__ */ jsx("span", { className: "text-muted-foreground opacity-70", children: prefix }),
|
|
4644
|
+
/* @__PURE__ */ jsx("span", { className: cn(!use_custom_colors && "text-muted-foreground opacity-70"), style: use_custom_colors ? { opacity: 0.7 } : void 0, children: prefix }),
|
|
4587
4645
|
/* @__PURE__ */ jsx("span", { children: action_label })
|
|
4588
4646
|
]
|
|
4589
4647
|
}
|
|
@@ -4610,7 +4668,8 @@ var CommandPopover = ({
|
|
|
4610
4668
|
position,
|
|
4611
4669
|
on_select,
|
|
4612
4670
|
on_close,
|
|
4613
|
-
on_selection_change: _on_selection_change
|
|
4671
|
+
on_selection_change: _on_selection_change,
|
|
4672
|
+
prefix_color
|
|
4614
4673
|
}) => {
|
|
4615
4674
|
const container_ref = React27.useRef(null);
|
|
4616
4675
|
const grouped_commands = React27.useMemo(
|
|
@@ -4686,6 +4745,16 @@ var CommandPopover = ({
|
|
|
4686
4745
|
onSelect: () => on_select(cmd),
|
|
4687
4746
|
selected: flat_idx === selected_index,
|
|
4688
4747
|
children: /* @__PURE__ */ jsxs("div", { className: "flex items-center gap-2 w-full", children: [
|
|
4748
|
+
prefix_color && (prefix_color.bg || prefix_color.fg) && /* @__PURE__ */ jsx(
|
|
4749
|
+
"span",
|
|
4750
|
+
{
|
|
4751
|
+
className: "flex-shrink-0 w-2 h-2 rounded-full",
|
|
4752
|
+
style: {
|
|
4753
|
+
backgroundColor: prefix_color.bg || prefix_color.fg,
|
|
4754
|
+
border: prefix_color.border ? `1px solid ${prefix_color.border}` : void 0
|
|
4755
|
+
}
|
|
4756
|
+
}
|
|
4757
|
+
),
|
|
4689
4758
|
cmd.icon && /* @__PURE__ */ jsx("span", { className: "flex-shrink-0 text-muted-foreground", children: cmd.icon }),
|
|
4690
4759
|
/* @__PURE__ */ jsxs("div", { className: "flex-1 min-w-0", children: [
|
|
4691
4760
|
/* @__PURE__ */ jsxs("div", { className: "font-medium truncate", children: [
|
|
@@ -4718,7 +4787,8 @@ var parse_commands_from_text = (text, prefixes) => {
|
|
|
4718
4787
|
for (const cmd of prefix_config.commands) {
|
|
4719
4788
|
action_to_label.set(`${prefix_config.char}${cmd.action}`, {
|
|
4720
4789
|
label: cmd.action_label,
|
|
4721
|
-
prefix: prefix_config.char
|
|
4790
|
+
prefix: prefix_config.char,
|
|
4791
|
+
color: prefix_config.color
|
|
4722
4792
|
});
|
|
4723
4793
|
}
|
|
4724
4794
|
}
|
|
@@ -4737,7 +4807,8 @@ var parse_commands_from_text = (text, prefixes) => {
|
|
|
4737
4807
|
action_label: info.label,
|
|
4738
4808
|
prefix,
|
|
4739
4809
|
position: match.index,
|
|
4740
|
-
length: full_match.length
|
|
4810
|
+
length: full_match.length,
|
|
4811
|
+
color: info.color
|
|
4741
4812
|
});
|
|
4742
4813
|
}
|
|
4743
4814
|
}
|
|
@@ -4776,7 +4847,10 @@ var text_to_tiptap_content = (text, prefixes, variant = "default") => {
|
|
|
4776
4847
|
prefix: cmd.prefix,
|
|
4777
4848
|
action: cmd.action,
|
|
4778
4849
|
action_label: cmd.action_label,
|
|
4779
|
-
variant
|
|
4850
|
+
variant,
|
|
4851
|
+
...cmd.color?.bg && { color_bg: cmd.color.bg },
|
|
4852
|
+
...cmd.color?.fg && { color_fg: cmd.color.fg },
|
|
4853
|
+
...cmd.color?.border && { color_border: cmd.color.border }
|
|
4780
4854
|
}
|
|
4781
4855
|
});
|
|
4782
4856
|
last_end = cmd.position + cmd.length;
|
|
@@ -5019,19 +5093,22 @@ var HazoUiTextbox = ({
|
|
|
5019
5093
|
const handle_command_select = React27.useCallback(
|
|
5020
5094
|
(command) => {
|
|
5021
5095
|
if (!editor || !suggestion_state) return;
|
|
5096
|
+
const prefix_config = prefixes.find((p) => p.char === suggestion_state.prefix);
|
|
5097
|
+
const prefix_color = prefix_config?.color;
|
|
5022
5098
|
insert_command_at_position(
|
|
5023
5099
|
editor,
|
|
5024
5100
|
command,
|
|
5025
5101
|
suggestion_state.prefix,
|
|
5026
5102
|
suggestion_state.range,
|
|
5027
|
-
pill_variant
|
|
5103
|
+
pill_variant,
|
|
5104
|
+
prefix_color
|
|
5028
5105
|
);
|
|
5029
5106
|
if (on_command_insert) {
|
|
5030
5107
|
on_command_insert(command, suggestion_state.prefix);
|
|
5031
5108
|
}
|
|
5032
5109
|
set_suggestion_state(null);
|
|
5033
5110
|
},
|
|
5034
|
-
[editor, suggestion_state, pill_variant, on_command_insert]
|
|
5111
|
+
[editor, suggestion_state, pill_variant, on_command_insert, prefixes]
|
|
5035
5112
|
);
|
|
5036
5113
|
const handle_popover_close = React27.useCallback(() => {
|
|
5037
5114
|
set_suggestion_state(null);
|
|
@@ -5253,7 +5330,8 @@ var HazoUiTextbox = ({
|
|
|
5253
5330
|
},
|
|
5254
5331
|
on_select: handle_command_select,
|
|
5255
5332
|
on_close: handle_popover_close,
|
|
5256
|
-
on_selection_change: set_selected_index
|
|
5333
|
+
on_selection_change: set_selected_index,
|
|
5334
|
+
prefix_color: prefixes.find((p) => p.char === suggestion_state.prefix)?.color
|
|
5257
5335
|
}
|
|
5258
5336
|
),
|
|
5259
5337
|
edit_context && mounted && createPortal(
|
|
@@ -5559,19 +5637,22 @@ var HazoUiTextarea = ({
|
|
|
5559
5637
|
const handle_command_select = React27.useCallback(
|
|
5560
5638
|
(command) => {
|
|
5561
5639
|
if (!editor || !suggestion_state) return;
|
|
5640
|
+
const prefix_config = prefixes.find((p) => p.char === suggestion_state.prefix);
|
|
5641
|
+
const prefix_color = prefix_config?.color;
|
|
5562
5642
|
insert_command_at_position(
|
|
5563
5643
|
editor,
|
|
5564
5644
|
command,
|
|
5565
5645
|
suggestion_state.prefix,
|
|
5566
5646
|
suggestion_state.range,
|
|
5567
|
-
pill_variant
|
|
5647
|
+
pill_variant,
|
|
5648
|
+
prefix_color
|
|
5568
5649
|
);
|
|
5569
5650
|
if (on_command_insert) {
|
|
5570
5651
|
on_command_insert(command, suggestion_state.prefix);
|
|
5571
5652
|
}
|
|
5572
5653
|
set_suggestion_state(null);
|
|
5573
5654
|
},
|
|
5574
|
-
[editor, suggestion_state, pill_variant, on_command_insert]
|
|
5655
|
+
[editor, suggestion_state, pill_variant, on_command_insert, prefixes]
|
|
5575
5656
|
);
|
|
5576
5657
|
const handle_popover_close = React27.useCallback(() => {
|
|
5577
5658
|
set_suggestion_state(null);
|
|
@@ -5797,7 +5878,8 @@ var HazoUiTextarea = ({
|
|
|
5797
5878
|
},
|
|
5798
5879
|
on_select: handle_command_select,
|
|
5799
5880
|
on_close: handle_popover_close,
|
|
5800
|
-
on_selection_change: set_selected_index
|
|
5881
|
+
on_selection_change: set_selected_index,
|
|
5882
|
+
prefix_color: prefixes.find((p) => p.char === suggestion_state.prefix)?.color
|
|
5801
5883
|
}
|
|
5802
5884
|
),
|
|
5803
5885
|
edit_context && mounted && createPortal(
|