hazo_ui 2.4.4 → 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 +110 -27
- 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 +110 -27
- package/dist/index.js.map +1 -1
- package/dist/styles.css +21 -2
- 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
|
@@ -302,7 +302,7 @@ var CommandGroup = React27.forwardRef(({ className, heading, children, ...props
|
|
|
302
302
|
}
|
|
303
303
|
));
|
|
304
304
|
CommandGroup.displayName = "CommandGroup";
|
|
305
|
-
var CommandItem = React27.forwardRef(({ className, onSelect, value, style, ...props }, ref) => {
|
|
305
|
+
var CommandItem = React27.forwardRef(({ className, onSelect, value, selected, style, ...props }, ref) => {
|
|
306
306
|
const handleClick = () => {
|
|
307
307
|
if (onSelect && value) {
|
|
308
308
|
onSelect(value);
|
|
@@ -315,13 +315,16 @@ var CommandItem = React27.forwardRef(({ className, onSelect, value, style, ...pr
|
|
|
315
315
|
className: cn(
|
|
316
316
|
"cls_command_item",
|
|
317
317
|
"relative flex cursor-pointer select-none items-center rounded-sm px-2 py-1.5 text-sm outline-none hover:bg-accent hover:text-accent-foreground aria-selected:bg-accent aria-selected:text-accent-foreground data-[disabled]:pointer-events-none data-[disabled]:opacity-50",
|
|
318
|
+
// When selected, apply accent background and ensure all text is visible
|
|
319
|
+
selected && "bg-accent text-accent-foreground [&_.text-muted-foreground]:text-accent-foreground/70",
|
|
318
320
|
className
|
|
319
321
|
),
|
|
320
|
-
style: {
|
|
321
|
-
//
|
|
322
|
-
backgroundColor: "
|
|
322
|
+
style: selected ? {
|
|
323
|
+
// Explicit inline styles as fallback for consumers with non-HSL CSS variables
|
|
324
|
+
backgroundColor: "var(--accent, #f1f5f9)",
|
|
325
|
+
color: "var(--accent-foreground, #0f172a)",
|
|
323
326
|
...style
|
|
324
|
-
},
|
|
327
|
+
} : style,
|
|
325
328
|
onClick: handleClick,
|
|
326
329
|
...props
|
|
327
330
|
}
|
|
@@ -4276,8 +4279,21 @@ var get_variant_classes = (variant = "default") => {
|
|
|
4276
4279
|
return "bg-primary/10 text-primary border-primary/20";
|
|
4277
4280
|
}
|
|
4278
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
|
+
};
|
|
4279
4295
|
var CommandPillView = ({ node, selected, editor }) => {
|
|
4280
|
-
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;
|
|
4281
4297
|
const handle_click = () => {
|
|
4282
4298
|
const event = new CustomEvent("command-pill-click", {
|
|
4283
4299
|
detail: {
|
|
@@ -4291,6 +4307,8 @@ var CommandPillView = ({ node, selected, editor }) => {
|
|
|
4291
4307
|
});
|
|
4292
4308
|
document.dispatchEvent(event);
|
|
4293
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);
|
|
4294
4312
|
return /* @__PURE__ */ jsx(NodeViewWrapper, { as: "span", className: "inline", children: /* @__PURE__ */ jsxs(
|
|
4295
4313
|
"span",
|
|
4296
4314
|
{
|
|
@@ -4303,17 +4321,19 @@ var CommandPillView = ({ node, selected, editor }) => {
|
|
|
4303
4321
|
"border",
|
|
4304
4322
|
"cursor-pointer select-none",
|
|
4305
4323
|
"transition-all duration-150",
|
|
4306
|
-
|
|
4324
|
+
// Only apply variant classes if no custom colors
|
|
4325
|
+
!use_custom_colors && get_variant_classes(variant),
|
|
4307
4326
|
selected && "ring-2 ring-ring ring-offset-1",
|
|
4308
4327
|
"hover:opacity-80"
|
|
4309
4328
|
),
|
|
4329
|
+
style: custom_styles,
|
|
4310
4330
|
contentEditable: false,
|
|
4311
4331
|
"data-command-id": id,
|
|
4312
4332
|
"data-command-prefix": prefix,
|
|
4313
4333
|
"data-command-action": action,
|
|
4314
4334
|
onClick: handle_click,
|
|
4315
4335
|
children: [
|
|
4316
|
-
/* @__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 }),
|
|
4317
4337
|
/* @__PURE__ */ jsx("span", { children: action_label })
|
|
4318
4338
|
]
|
|
4319
4339
|
}
|
|
@@ -4365,6 +4385,27 @@ var CommandNodeExtension = Node.create({
|
|
|
4365
4385
|
renderHTML: (attributes) => ({
|
|
4366
4386
|
"data-command-variant": attributes.variant
|
|
4367
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
|
+
})
|
|
4368
4409
|
}
|
|
4369
4410
|
};
|
|
4370
4411
|
},
|
|
@@ -4395,11 +4436,15 @@ var CommandNodeExtension = Node.create({
|
|
|
4395
4436
|
addCommands() {
|
|
4396
4437
|
return {
|
|
4397
4438
|
insertCommand: (attrs) => ({ commands }) => {
|
|
4439
|
+
const { color: color2, ...rest_attrs } = attrs;
|
|
4398
4440
|
return commands.insertContent({
|
|
4399
4441
|
type: this.name,
|
|
4400
4442
|
attrs: {
|
|
4401
|
-
...
|
|
4402
|
-
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 }
|
|
4403
4448
|
}
|
|
4404
4449
|
});
|
|
4405
4450
|
},
|
|
@@ -4524,12 +4569,13 @@ var create_command_suggestion_extension = (config) => {
|
|
|
4524
4569
|
});
|
|
4525
4570
|
});
|
|
4526
4571
|
};
|
|
4527
|
-
var insert_command_at_position = (editor, command, prefix, range, variant = "default") => {
|
|
4572
|
+
var insert_command_at_position = (editor, command, prefix, range, variant = "default", color2) => {
|
|
4528
4573
|
editor.chain().focus().deleteRange(range).insertCommand({
|
|
4529
4574
|
prefix,
|
|
4530
4575
|
action: command.action,
|
|
4531
4576
|
action_label: command.action_label,
|
|
4532
|
-
variant
|
|
4577
|
+
variant,
|
|
4578
|
+
color: color2
|
|
4533
4579
|
}).run();
|
|
4534
4580
|
};
|
|
4535
4581
|
var get_variant_classes2 = (variant = "default") => {
|
|
@@ -4543,6 +4589,16 @@ var get_variant_classes2 = (variant = "default") => {
|
|
|
4543
4589
|
return "bg-primary/10 text-primary border-primary/20 hover:bg-primary/15";
|
|
4544
4590
|
}
|
|
4545
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
|
+
};
|
|
4546
4602
|
var CommandPill = ({
|
|
4547
4603
|
prefix,
|
|
4548
4604
|
action,
|
|
@@ -4550,8 +4606,11 @@ var CommandPill = ({
|
|
|
4550
4606
|
id,
|
|
4551
4607
|
selected = false,
|
|
4552
4608
|
variant = "default",
|
|
4609
|
+
color: color2,
|
|
4553
4610
|
on_click
|
|
4554
4611
|
}) => {
|
|
4612
|
+
const use_custom_colors = Boolean(color2?.bg || color2?.fg || color2?.border);
|
|
4613
|
+
const custom_styles = get_custom_color_styles2(color2);
|
|
4555
4614
|
return /* @__PURE__ */ jsxs(
|
|
4556
4615
|
"span",
|
|
4557
4616
|
{
|
|
@@ -4563,10 +4622,12 @@ var CommandPill = ({
|
|
|
4563
4622
|
"text-sm font-medium",
|
|
4564
4623
|
"border",
|
|
4565
4624
|
"transition-all duration-150",
|
|
4566
|
-
|
|
4625
|
+
// Only apply variant classes if no custom colors
|
|
4626
|
+
!use_custom_colors && get_variant_classes2(variant),
|
|
4567
4627
|
selected && "ring-2 ring-ring ring-offset-1",
|
|
4568
4628
|
on_click && "cursor-pointer"
|
|
4569
4629
|
),
|
|
4630
|
+
style: custom_styles,
|
|
4570
4631
|
"data-command-id": id,
|
|
4571
4632
|
"data-command-prefix": prefix,
|
|
4572
4633
|
"data-command-action": action,
|
|
@@ -4580,7 +4641,7 @@ var CommandPill = ({
|
|
|
4580
4641
|
}
|
|
4581
4642
|
},
|
|
4582
4643
|
children: [
|
|
4583
|
-
/* @__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 }),
|
|
4584
4645
|
/* @__PURE__ */ jsx("span", { children: action_label })
|
|
4585
4646
|
]
|
|
4586
4647
|
}
|
|
@@ -4607,7 +4668,8 @@ var CommandPopover = ({
|
|
|
4607
4668
|
position,
|
|
4608
4669
|
on_select,
|
|
4609
4670
|
on_close,
|
|
4610
|
-
on_selection_change: _on_selection_change
|
|
4671
|
+
on_selection_change: _on_selection_change,
|
|
4672
|
+
prefix_color
|
|
4611
4673
|
}) => {
|
|
4612
4674
|
const container_ref = React27.useRef(null);
|
|
4613
4675
|
const grouped_commands = React27.useMemo(
|
|
@@ -4681,10 +4743,18 @@ var CommandPopover = ({
|
|
|
4681
4743
|
{
|
|
4682
4744
|
value: cmd.action,
|
|
4683
4745
|
onSelect: () => on_select(cmd),
|
|
4684
|
-
|
|
4685
|
-
flat_idx === selected_index && "bg-accent"
|
|
4686
|
-
),
|
|
4746
|
+
selected: flat_idx === selected_index,
|
|
4687
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
|
+
),
|
|
4688
4758
|
cmd.icon && /* @__PURE__ */ jsx("span", { className: "flex-shrink-0 text-muted-foreground", children: cmd.icon }),
|
|
4689
4759
|
/* @__PURE__ */ jsxs("div", { className: "flex-1 min-w-0", children: [
|
|
4690
4760
|
/* @__PURE__ */ jsxs("div", { className: "font-medium truncate", children: [
|
|
@@ -4717,7 +4787,8 @@ var parse_commands_from_text = (text, prefixes) => {
|
|
|
4717
4787
|
for (const cmd of prefix_config.commands) {
|
|
4718
4788
|
action_to_label.set(`${prefix_config.char}${cmd.action}`, {
|
|
4719
4789
|
label: cmd.action_label,
|
|
4720
|
-
prefix: prefix_config.char
|
|
4790
|
+
prefix: prefix_config.char,
|
|
4791
|
+
color: prefix_config.color
|
|
4721
4792
|
});
|
|
4722
4793
|
}
|
|
4723
4794
|
}
|
|
@@ -4736,7 +4807,8 @@ var parse_commands_from_text = (text, prefixes) => {
|
|
|
4736
4807
|
action_label: info.label,
|
|
4737
4808
|
prefix,
|
|
4738
4809
|
position: match.index,
|
|
4739
|
-
length: full_match.length
|
|
4810
|
+
length: full_match.length,
|
|
4811
|
+
color: info.color
|
|
4740
4812
|
});
|
|
4741
4813
|
}
|
|
4742
4814
|
}
|
|
@@ -4775,7 +4847,10 @@ var text_to_tiptap_content = (text, prefixes, variant = "default") => {
|
|
|
4775
4847
|
prefix: cmd.prefix,
|
|
4776
4848
|
action: cmd.action,
|
|
4777
4849
|
action_label: cmd.action_label,
|
|
4778
|
-
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 }
|
|
4779
4854
|
}
|
|
4780
4855
|
});
|
|
4781
4856
|
last_end = cmd.position + cmd.length;
|
|
@@ -5018,19 +5093,22 @@ var HazoUiTextbox = ({
|
|
|
5018
5093
|
const handle_command_select = React27.useCallback(
|
|
5019
5094
|
(command) => {
|
|
5020
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;
|
|
5021
5098
|
insert_command_at_position(
|
|
5022
5099
|
editor,
|
|
5023
5100
|
command,
|
|
5024
5101
|
suggestion_state.prefix,
|
|
5025
5102
|
suggestion_state.range,
|
|
5026
|
-
pill_variant
|
|
5103
|
+
pill_variant,
|
|
5104
|
+
prefix_color
|
|
5027
5105
|
);
|
|
5028
5106
|
if (on_command_insert) {
|
|
5029
5107
|
on_command_insert(command, suggestion_state.prefix);
|
|
5030
5108
|
}
|
|
5031
5109
|
set_suggestion_state(null);
|
|
5032
5110
|
},
|
|
5033
|
-
[editor, suggestion_state, pill_variant, on_command_insert]
|
|
5111
|
+
[editor, suggestion_state, pill_variant, on_command_insert, prefixes]
|
|
5034
5112
|
);
|
|
5035
5113
|
const handle_popover_close = React27.useCallback(() => {
|
|
5036
5114
|
set_suggestion_state(null);
|
|
@@ -5252,7 +5330,8 @@ var HazoUiTextbox = ({
|
|
|
5252
5330
|
},
|
|
5253
5331
|
on_select: handle_command_select,
|
|
5254
5332
|
on_close: handle_popover_close,
|
|
5255
|
-
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
|
|
5256
5335
|
}
|
|
5257
5336
|
),
|
|
5258
5337
|
edit_context && mounted && createPortal(
|
|
@@ -5558,19 +5637,22 @@ var HazoUiTextarea = ({
|
|
|
5558
5637
|
const handle_command_select = React27.useCallback(
|
|
5559
5638
|
(command) => {
|
|
5560
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;
|
|
5561
5642
|
insert_command_at_position(
|
|
5562
5643
|
editor,
|
|
5563
5644
|
command,
|
|
5564
5645
|
suggestion_state.prefix,
|
|
5565
5646
|
suggestion_state.range,
|
|
5566
|
-
pill_variant
|
|
5647
|
+
pill_variant,
|
|
5648
|
+
prefix_color
|
|
5567
5649
|
);
|
|
5568
5650
|
if (on_command_insert) {
|
|
5569
5651
|
on_command_insert(command, suggestion_state.prefix);
|
|
5570
5652
|
}
|
|
5571
5653
|
set_suggestion_state(null);
|
|
5572
5654
|
},
|
|
5573
|
-
[editor, suggestion_state, pill_variant, on_command_insert]
|
|
5655
|
+
[editor, suggestion_state, pill_variant, on_command_insert, prefixes]
|
|
5574
5656
|
);
|
|
5575
5657
|
const handle_popover_close = React27.useCallback(() => {
|
|
5576
5658
|
set_suggestion_state(null);
|
|
@@ -5796,7 +5878,8 @@ var HazoUiTextarea = ({
|
|
|
5796
5878
|
},
|
|
5797
5879
|
on_select: handle_command_select,
|
|
5798
5880
|
on_close: handle_popover_close,
|
|
5799
|
-
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
|
|
5800
5883
|
}
|
|
5801
5884
|
),
|
|
5802
5885
|
edit_context && mounted && createPortal(
|