@blocknote/mantine 0.24.2 → 0.25.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/src/style.css CHANGED
@@ -127,6 +127,14 @@
127
127
  padding: 0;
128
128
  }
129
129
 
130
+ .bn-mantine .mantine-Tooltip-tooltip p:last-child {
131
+ white-space: pre-wrap;
132
+ }
133
+
134
+ .bn-mantine .mantine-Tooltip-tooltip p:first-child {
135
+ white-space: unset;
136
+ }
137
+
130
138
  /* UI element styling */
131
139
 
132
140
  /* Select styling */
@@ -495,14 +503,15 @@
495
503
 
496
504
  /* Table Handle styling */
497
505
  .bn-mantine .bn-table-handle,
498
- .bn-mantine .bn-extend-button {
506
+ .bn-mantine .bn-extend-button,
507
+ .bn-mantine .bn-table-cell-handle {
499
508
  align-items: center;
500
509
  background-color: var(--bn-colors-menu-background);
501
510
  border: var(--bn-border);
502
511
  border-radius: var(--bn-border-radius-small);
503
512
  box-shadow: var(--bn-shadow-light);
504
513
  color: var(--bn-colors-side-menu);
505
- cursor: pointer;
514
+ cursor: grab;
506
515
  display: flex;
507
516
  height: fit-content;
508
517
  justify-content: center;
@@ -510,14 +519,23 @@
510
519
  padding: 0;
511
520
  }
512
521
 
522
+ .bn-mantine .bn-table-cell-handle {
523
+ padding: 0 4px;
524
+ }
525
+
513
526
  .bn-mantine .bn-table-handle svg {
514
527
  margin-inline: -4px;
515
528
  }
516
529
 
530
+ .bn-mantine .bn-table-handle-not-draggable {
531
+ cursor: pointer;
532
+ }
533
+
517
534
  .bn-mantine .bn-table-handle:hover,
518
535
  .bn-mantine .bn-table-handle-dragging,
519
536
  .bn-mantine .bn-extend-button:hover,
520
- .bn-mantine .bn-extend-button-editing {
537
+ .bn-mantine .bn-extend-button-editing,
538
+ .bn-mantine .bn-table-cell-handle:hover {
521
539
  background-color: var(--bn-colors-hovered-background);
522
540
  }
523
541
 
@@ -536,7 +554,8 @@
536
554
  }
537
555
 
538
556
  /* Drag Handle & Table Handle Menu styling */
539
- .bn-mantine .bn-drag-handle-menu {
557
+ .bn-mantine .bn-drag-handle-menu,
558
+ .bn-mantine .bn-table-handle-menu {
540
559
  overflow: visible;
541
560
  }
542
561
 
@@ -564,3 +583,135 @@
564
583
  display: flex;
565
584
  justify-content: space-between;
566
585
  }
586
+
587
+ /* Comment styling */
588
+ .bn-mantine .bn-thread {
589
+ background-color: var(--bn-colors-menu-background);
590
+ border: var(--bn-border);
591
+ border-radius: var(--bn-border-radius-medium);
592
+ box-shadow: var(--bn-shadow-medium);
593
+ color: var(--bn-colors-menu-text);
594
+ overflow: visible;
595
+ }
596
+
597
+ .bn-mantine .bn-thread-comments {
598
+ border-bottom: var(--bn-border);
599
+ display: flex;
600
+ flex-direction: column;
601
+ gap: 1rem;
602
+ }
603
+
604
+ .bn-mantine .bn-thread-comment {
605
+ align-items: flex-start;
606
+ flex-direction: column;
607
+ gap: 0.25rem;
608
+ }
609
+
610
+ .bn-mantine .bn-thread-comment > .mantine-Group-root {
611
+ gap: 12px;
612
+ }
613
+
614
+ .bn-mantine .bn-thread-comment p {
615
+ color: var(--bn-colors-menu-text);
616
+ }
617
+
618
+ .bn-mantine .bn-comment-actions-wrapper {
619
+ width: 100%;
620
+ display: flex;
621
+ justify-content: flex-end;
622
+ }
623
+
624
+ /* Comment action toolbar styling */
625
+ .bn-mantine .bn-action-toolbar {
626
+ align-self: flex-end;
627
+ background-color: var(--bn-colors-menu-background);
628
+ border: var(--bn-border);
629
+ border-radius: var(--bn-border-radius-medium);
630
+ gap: 0;
631
+ padding: 2px;
632
+ }
633
+
634
+ .bn-action-toolbar .mantine-Button-root,
635
+ .bn-action-toolbar .mantine-ActionIcon-root {
636
+ background-color: var(--bn-colors-menu-background);
637
+ border: none;
638
+ border-radius: var(--bn-border-radius-small);
639
+ color: var(--bn-colors-menu-text);
640
+ }
641
+
642
+ .bn-action-toolbar .mantine-Button-root:hover,
643
+ .bn-action-toolbar .mantine-ActionIcon-root:hover {
644
+ background-color: var(--bn-colors-hovered-background);
645
+ border: none;
646
+ color: var(--bn-colors-hovered-text);
647
+ }
648
+
649
+ .bn-action-toolbar .mantine-Button-root[data-selected],
650
+ .bn-action-toolbar .mantine-ActionIcon-root[data-selected] {
651
+ background-color: var(--bn-colors-selected-background);
652
+ border: none;
653
+ color: var(--bn-colors-selected-text);
654
+ }
655
+
656
+ .bn-action-toolbar .mantine-Button-root[data-disabled],
657
+ .bn-action-toolbar .mantine-ActionIcon-root[data-disabled] {
658
+ background-color: var(--bn-colors-disabled-background);
659
+ border: none;
660
+ color: var(--bn-colors-disabled-text);
661
+ }
662
+
663
+ .bn-mantine .bn-action-toolbar .mantine-Menu-itemLabel {
664
+ font-size: 12px;
665
+ }
666
+
667
+ /* Badge styling */
668
+ .bn-mantine .bn-badge-group {
669
+ display: flex;
670
+ gap: 4px;
671
+ justify-content: flex-start;
672
+ width: 100%;
673
+ }
674
+
675
+ .bn-mantine .bn-badge {
676
+ flex-grow: 0;
677
+ }
678
+
679
+ .bn-mantine .bn-badge .mantine-Chip-label {
680
+ padding: 0 8px;
681
+ }
682
+
683
+ .bn-mantine .bn-badge .mantine-Chip-label:not([data-checked="true"]) {
684
+ background-color: var(--bn-colors-menu-background);
685
+ border: var(--bn-border);
686
+ color: var(--bn-colors-menu-text);
687
+ }
688
+
689
+ .bn-mantine .bn-badge .mantine-Chip-label:hover {
690
+ border: 1px solid var(--mantine-primary-color-filled-hover);
691
+ color: var(--mantine-primary-color-filled-hover);
692
+ }
693
+
694
+ .bn-mantine
695
+ .bn-badge
696
+ .mantine-Chip-label
697
+ > span:not(.mantine-Chip-iconWrapper) {
698
+ display: inline-flex;
699
+ gap: 4px;
700
+ }
701
+
702
+ .bn-mantine
703
+ .bn-badge
704
+ .mantine-Chip-label
705
+ > span:not(.mantine-Chip-iconWrapper)
706
+ > span {
707
+ align-items: center;
708
+ display: inline-flex;
709
+ justify-content: center;
710
+ }
711
+
712
+ /* We need to get rid of the checked icon - you can set the icon prop to an
713
+ empty element (<></>), but even so Mantine leaves extra space for the icon, so
714
+ we just don't display it in CSS instead. */
715
+ .bn-mantine .bn-badge .mantine-Chip-iconWrapper {
716
+ display: none;
717
+ }
@@ -1,4 +1,4 @@
1
- import { Group as MantineGroup } from "@mantine/core";
1
+ import { Flex } from "@mantine/core";
2
2
 
3
3
  import { assertEmpty } from "@blocknote/core";
4
4
  import { ComponentProps } from "@blocknote/react";
@@ -10,7 +10,14 @@ type ToolbarProps = ComponentProps["FormattingToolbar"]["Root"] &
10
10
 
11
11
  export const Toolbar = forwardRef<HTMLDivElement, ToolbarProps>(
12
12
  (props, ref) => {
13
- const { className, children, onMouseEnter, onMouseLeave, ...rest } = props;
13
+ const {
14
+ className,
15
+ children,
16
+ onMouseEnter,
17
+ onMouseLeave,
18
+ variant,
19
+ ...rest
20
+ } = props;
14
21
 
15
22
  assertEmpty(rest);
16
23
 
@@ -22,15 +29,16 @@ export const Toolbar = forwardRef<HTMLDivElement, ToolbarProps>(
22
29
  const combinedRef = mergeRefs(ref, focusRef, trapRef);
23
30
 
24
31
  return (
25
- <MantineGroup
32
+ <Flex
26
33
  className={className}
27
34
  ref={combinedRef}
28
35
  role="toolbar"
29
36
  // TODO: aria-label
30
37
  onMouseEnter={onMouseEnter}
31
- onMouseLeave={onMouseLeave}>
38
+ onMouseLeave={onMouseLeave}
39
+ gap={variant === "action-toolbar" ? 2 : undefined}>
32
40
  {children}
33
- </MantineGroup>
41
+ </Flex>
34
42
  );
35
43
  }
36
44
  );
@@ -8,16 +8,20 @@ import {
8
8
 
9
9
  import { assertEmpty, isSafari } from "@blocknote/core";
10
10
  import { ComponentProps } from "@blocknote/react";
11
- import { forwardRef } from "react";
11
+ import { forwardRef, useState } from "react";
12
12
 
13
13
  export const TooltipContent = (props: {
14
14
  mainTooltip: string;
15
15
  secondaryTooltip?: string;
16
16
  }) => (
17
17
  <MantineStack gap={0} className={"bn-tooltip"}>
18
- <MantineText size={"sm"}>{props.mainTooltip}</MantineText>
18
+ <MantineText size={"sm"} lineClamp={5}>
19
+ {props.mainTooltip}
20
+ </MantineText>
19
21
  {props.secondaryTooltip && (
20
- <MantineText size={"xs"}>{props.secondaryTooltip}</MantineText>
22
+ <MantineText size={"xs"} lineClamp={5}>
23
+ {props.secondaryTooltip}
24
+ </MantineText>
21
25
  )}
22
26
  </MantineStack>
23
27
  );
@@ -40,6 +44,7 @@ export const ToolbarButton = forwardRef<HTMLButtonElement, ToolbarButtonProps>(
40
44
  isDisabled,
41
45
  onClick,
42
46
  label,
47
+ variant,
43
48
  ...rest
44
49
  } = props;
45
50
 
@@ -47,8 +52,84 @@ export const ToolbarButton = forwardRef<HTMLButtonElement, ToolbarButtonProps>(
47
52
  // assertEmpty in this case is only used at typescript level, not runtime level
48
53
  assertEmpty(rest, false);
49
54
 
55
+ const [hideTooltip, setHideTooltip] = useState(false);
56
+
57
+ const button = children ? (
58
+ <MantineButton
59
+ aria-label={label}
60
+ className={className}
61
+ // Needed as Safari doesn't focus button elements on mouse down
62
+ // unlike other browsers.
63
+ onMouseDown={(e) => {
64
+ if (isSafari()) {
65
+ (e.currentTarget as HTMLButtonElement).focus();
66
+ }
67
+ }}
68
+ onClick={(event) => {
69
+ setHideTooltip(true);
70
+ onClick?.(event);
71
+ }}
72
+ // Mantine Menu.Target elements block mouseleave events for some reason,
73
+ // but pointerleave events work fine.
74
+ onPointerLeave={() => setHideTooltip(false)}
75
+ aria-pressed={isSelected}
76
+ data-selected={isSelected || undefined}
77
+ data-test={
78
+ mainTooltip
79
+ ? mainTooltip.slice(0, 1).toLowerCase() +
80
+ mainTooltip.replace(/\s+/g, "").slice(1)
81
+ : undefined
82
+ }
83
+ size={variant === "compact" ? "compact-xs" : "xs"}
84
+ disabled={isDisabled || false}
85
+ ref={ref}
86
+ {...rest}>
87
+ {children}
88
+ </MantineButton>
89
+ ) : (
90
+ <MantineActionIcon
91
+ className={className}
92
+ aria-label={label}
93
+ // Needed as Safari doesn't focus button elements on mouse down
94
+ // unlike other browsers.
95
+ onMouseDown={(e) => {
96
+ if (isSafari()) {
97
+ (e.currentTarget as HTMLButtonElement).focus();
98
+ }
99
+ }}
100
+ onClick={(event) => {
101
+ // We manually hide the tooltip onclick, because the click event
102
+ // might open a popover which would then show both the tooltip and the popover
103
+ // this is similar to default behavior of shadcn / radix
104
+ setHideTooltip(true);
105
+ onClick?.(event);
106
+ }}
107
+ // Mantine Menu.Target elements block mouseleave events for some reason,
108
+ // but pointerleave events work fine.
109
+ onPointerLeave={() => setHideTooltip(false)}
110
+ aria-pressed={isSelected}
111
+ data-selected={isSelected || undefined}
112
+ data-test={
113
+ mainTooltip
114
+ ? mainTooltip.slice(0, 1).toLowerCase() +
115
+ mainTooltip.replace(/\s+/g, "").slice(1)
116
+ : undefined
117
+ }
118
+ size={variant === "compact" ? 20 : 30}
119
+ disabled={isDisabled || false}
120
+ ref={ref}
121
+ {...rest}>
122
+ {icon}
123
+ </MantineActionIcon>
124
+ );
125
+
126
+ if (!mainTooltip) {
127
+ return button;
128
+ }
129
+
50
130
  return (
51
131
  <MantineTooltip
132
+ disabled={hideTooltip}
52
133
  withinPortal={false}
53
134
  label={
54
135
  <TooltipContent
@@ -56,56 +137,7 @@ export const ToolbarButton = forwardRef<HTMLButtonElement, ToolbarButtonProps>(
56
137
  secondaryTooltip={secondaryTooltip}
57
138
  />
58
139
  }>
59
- {/*Creates an ActionIcon instead of a Button if only an icon is provided as content.*/}
60
- {children ? (
61
- <MantineButton
62
- aria-label={label}
63
- className={className}
64
- // Needed as Safari doesn't focus button elements on mouse down
65
- // unlike other browsers.
66
- onMouseDown={(e) => {
67
- if (isSafari()) {
68
- (e.currentTarget as HTMLButtonElement).focus();
69
- }
70
- }}
71
- onClick={onClick}
72
- aria-pressed={isSelected}
73
- data-selected={isSelected || undefined}
74
- data-test={
75
- mainTooltip.slice(0, 1).toLowerCase() +
76
- mainTooltip.replace(/\s+/g, "").slice(1)
77
- }
78
- size={"xs"}
79
- disabled={isDisabled || false}
80
- ref={ref}
81
- {...rest}>
82
- {children}
83
- </MantineButton>
84
- ) : (
85
- <MantineActionIcon
86
- className={className}
87
- aria-label={label}
88
- // Needed as Safari doesn't focus button elements on mouse down
89
- // unlike other browsers.
90
- onMouseDown={(e) => {
91
- if (isSafari()) {
92
- (e.currentTarget as HTMLButtonElement).focus();
93
- }
94
- }}
95
- onClick={onClick}
96
- aria-pressed={isSelected}
97
- data-selected={isSelected || undefined}
98
- data-test={
99
- mainTooltip.slice(0, 1).toLowerCase() +
100
- mainTooltip.replace(/\s+/g, "").slice(1)
101
- }
102
- size={30}
103
- disabled={isDisabled || false}
104
- ref={ref}
105
- {...rest}>
106
- {icon}
107
- </MantineActionIcon>
108
- )}
140
+ {button}
109
141
  </MantineTooltip>
110
142
  );
111
143
  }
@@ -0,0 +1,15 @@
1
+ import { MouseEvent } from "react";
2
+ export declare const Badge: import("react").ForwardRefExoticComponent<{
3
+ className?: string | undefined;
4
+ text: string;
5
+ icon?: import("react").ReactNode;
6
+ isSelected?: boolean | undefined;
7
+ mainTooltip?: string | undefined;
8
+ secondaryTooltip?: string | undefined;
9
+ onClick?: ((event: MouseEvent<Element, globalThis.MouseEvent>) => void) | undefined;
10
+ onMouseEnter?: (() => void) | undefined;
11
+ } & import("react").RefAttributes<HTMLInputElement>>;
12
+ export declare const BadgeGroup: import("react").ForwardRefExoticComponent<{
13
+ className?: string | undefined;
14
+ children: import("react").ReactNode;
15
+ } & import("react").RefAttributes<HTMLDivElement>>;
@@ -0,0 +1,9 @@
1
+ /// <reference types="react" />
2
+ export declare const Card: import("react").ForwardRefExoticComponent<{
3
+ className?: string | undefined;
4
+ children?: import("react").ReactNode;
5
+ } & import("react").RefAttributes<HTMLDivElement>>;
6
+ export declare const CardSection: import("react").ForwardRefExoticComponent<{
7
+ className?: string | undefined;
8
+ children?: import("react").ReactNode;
9
+ } & import("react").RefAttributes<HTMLDivElement>>;
@@ -0,0 +1,9 @@
1
+ /// <reference types="react" />
2
+ export declare const Comment: import("react").ForwardRefExoticComponent<{
3
+ className?: string | undefined;
4
+ children?: import("react").ReactNode;
5
+ authorInfo: "loading" | import("@blocknote/core/types/src/comments").User;
6
+ timeString: string;
7
+ actions?: import("react").ReactNode;
8
+ showActions?: boolean | "hover" | undefined;
9
+ } & import("react").RefAttributes<HTMLDivElement>>;
@@ -0,0 +1,8 @@
1
+ /// <reference types="react" />
2
+ export declare const Editor: import("react").ForwardRefExoticComponent<{
3
+ className?: string | undefined;
4
+ editable: boolean;
5
+ editor: import("@blocknote/core").BlockNoteEditor<any, any, any>;
6
+ onFocus?: (() => void) | undefined;
7
+ onBlur?: (() => void) | undefined;
8
+ } & import("react").RefAttributes<HTMLDivElement>>;
@@ -0,0 +1,15 @@
1
+ /// <reference types="react" />
2
+ export declare const Button: import("react").ForwardRefExoticComponent<({
3
+ className?: string | undefined;
4
+ onClick?: ((e: import("react").MouseEvent<Element, MouseEvent>) => void) | undefined;
5
+ icon?: import("react").ReactNode;
6
+ onDragStart?: ((e: import("react").DragEvent<Element>) => void) | undefined;
7
+ onDragEnd?: ((e: import("react").DragEvent<Element>) => void) | undefined;
8
+ draggable?: boolean | undefined;
9
+ } & ({
10
+ children: import("react").ReactNode;
11
+ label?: string | undefined;
12
+ } | {
13
+ children?: undefined;
14
+ label: string;
15
+ })) & import("react").RefAttributes<HTMLButtonElement>>;
@@ -4,4 +4,5 @@ export declare const Toolbar: import("react").ForwardRefExoticComponent<{
4
4
  children?: import("react").ReactNode;
5
5
  onMouseEnter?: (() => void) | undefined;
6
6
  onMouseLeave?: (() => void) | undefined;
7
+ variant?: "default" | "action-toolbar" | undefined;
7
8
  } & import("react").RefAttributes<HTMLDivElement>>;
@@ -8,12 +8,13 @@ export declare const TooltipContent: (props: {
8
8
  */
9
9
  export declare const ToolbarButton: import("react").ForwardRefExoticComponent<({
10
10
  className?: string | undefined;
11
- mainTooltip: string;
11
+ mainTooltip?: string | undefined;
12
12
  secondaryTooltip?: string | undefined;
13
13
  icon?: import("react").ReactNode;
14
14
  onClick?: ((e: import("react").MouseEvent<Element, MouseEvent>) => void) | undefined;
15
15
  isSelected?: boolean | undefined;
16
16
  isDisabled?: boolean | undefined;
17
+ variant?: "default" | "compact" | undefined;
17
18
  } & ({
18
19
  children: import("react").ReactNode;
19
20
  label?: string | undefined;
@@ -1,2 +0,0 @@
1
- (function(b,s){typeof exports=="object"&&typeof module<"u"?s(exports,require("react/jsx-runtime"),require("@blocknote/core"),require("@blocknote/react"),require("@mantine/core"),require("react"),require("@mantine/hooks")):typeof define=="function"&&define.amd?define(["exports","react/jsx-runtime","@blocknote/core","@blocknote/react","@mantine/core","react","@mantine/hooks"],s):(b=typeof globalThis<"u"?globalThis:b||self,s(b["blocknote-mantine"]={},b.jsxRuntime,b.core,b.react,b.core$1,b.React,b.hooks))})(this,function(b,s,m,w,l,f,S){"use strict";const y=(e=>e&&typeof e=="object"&&"default"in e?e:{default:e})(f),N=(e,r,t=!1)=>{const n=[];function o(a,d="--bn"){for(const i in a){const c=i.replace(/([a-z])([A-Z])/g,"$1-$2").toLowerCase(),u=`${d}-${c}`;typeof a[i]!="object"?(typeof a[i]=="number"&&(a[i]=`${a[i]}px`),t?r.style.removeProperty(u):r.style.setProperty(u,a[i].toString())):o(a[i],u)}}return o(e),n},x=(e,r)=>N(e,r),z={colors:{editor:{text:void 0,background:void 0},menu:{text:void 0,background:void 0},tooltip:{text:void 0,background:void 0},hovered:{text:void 0,background:void 0},selected:{text:void 0,background:void 0},disabled:{text:void 0,background:void 0},shadow:void 0,border:void 0,sideMenu:void 0,highlights:{gray:{text:void 0,background:void 0},brown:{text:void 0,background:void 0},red:{text:void 0,background:void 0},orange:{text:void 0,background:void 0},yellow:{text:void 0,background:void 0},green:{text:void 0,background:void 0},blue:{text:void 0,background:void 0},purple:{text:void 0,background:void 0},pink:{text:void 0,background:void 0}}},borderRadius:void 0,fontFamily:void 0},P=e=>N(z,e,!0),G=f.forwardRef((e,r)=>{const{className:t,name:n,label:o,icon:a,value:d,autoFocus:i,placeholder:c,onKeyDown:u,onChange:g,onSubmit:h,...v}=e;return m.assertEmpty(v),s.jsx(l.TextInput,{size:"xs",className:t,ref:r,name:n,label:o,leftSection:a,value:d,autoFocus:i,"data-autofocus":i?"true":void 0,placeholder:c,onKeyDown:u,onChange:g,onSubmit:h})});var F={color:void 0,size:void 0,className:void 0,style:void 0,attr:void 0},O=y.default.createContext&&y.default.createContext(F),_=["attr","size","title"];function V(e,r){if(e==null)return{};var t=A(e,r),n,o;if(Object.getOwnPropertySymbols){var a=Object.getOwnPropertySymbols(e);for(o=0;o<a.length;o++)n=a[o],!(r.indexOf(n)>=0)&&Object.prototype.propertyIsEnumerable.call(e,n)&&(t[n]=e[n])}return t}function A(e,r){if(e==null)return{};var t={};for(var n in e)if(Object.prototype.hasOwnProperty.call(e,n)){if(r.indexOf(n)>=0)continue;t[n]=e[n]}return t}function T(){return T=Object.assign?Object.assign.bind():function(e){for(var r=1;r<arguments.length;r++){var t=arguments[r];for(var n in t)Object.prototype.hasOwnProperty.call(t,n)&&(e[n]=t[n])}return e},T.apply(this,arguments)}function D(e,r){var t=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);r&&(n=n.filter(function(o){return Object.getOwnPropertyDescriptor(e,o).enumerable})),t.push.apply(t,n)}return t}function k(e){for(var r=1;r<arguments.length;r++){var t=arguments[r]!=null?arguments[r]:{};r%2?D(Object(t),!0).forEach(function(n){q(e,n,t[n])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(t)):D(Object(t)).forEach(function(n){Object.defineProperty(e,n,Object.getOwnPropertyDescriptor(t,n))})}return e}function q(e,r,t){return r=H(r),r in e?Object.defineProperty(e,r,{value:t,enumerable:!0,configurable:!0,writable:!0}):e[r]=t,e}function H(e){var r=K(e,"string");return typeof r=="symbol"?r:r+""}function K(e,r){if(typeof e!="object"||!e)return e;var t=e[Symbol.toPrimitive];if(t!==void 0){var n=t.call(e,r||"default");if(typeof n!="object")return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return(r==="string"?String:Number)(e)}function I(e){return e&&e.map((r,t)=>y.default.createElement(r.tag,k({key:t},r.attr),I(r.child)))}function j(e){return r=>y.default.createElement(U,T({attr:k({},e.attr)},r),I(e.child))}function U(e){var r=t=>{var{attr:n,size:o,title:a}=e,d=V(e,_),i=o||t.size||"1em",c;return t.className&&(c=t.className),e.className&&(c=(c?c+" ":"")+e.className),y.default.createElement("svg",T({stroke:"currentColor",fill:"currentColor",strokeWidth:"0"},t.attr,n,d,{className:c,style:k(k({color:e.color||t.color},t.style),e.style),height:i,width:i,xmlns:"http://www.w3.org/2000/svg"}),a&&y.default.createElement("title",null,a),e.children)};return O!==void 0?y.default.createElement(O.Consumer,null,t=>r(t)):r(F)}function W(e){return j({tag:"svg",attr:{viewBox:"0 0 20 20",fill:"currentColor","aria-hidden":"true"},child:[{tag:"path",attr:{fillRule:"evenodd",d:"M5.293 7.293a1 1 0 011.414 0L10 10.586l3.293-3.293a1 1 0 111.414 1.414l-4 4a1 1 0 01-1.414 0l-4-4a1 1 0 010-1.414z",clipRule:"evenodd"},child:[]}]})(e)}function Z(e){return j({tag:"svg",attr:{viewBox:"0 0 20 20",fill:"currentColor","aria-hidden":"true"},child:[{tag:"path",attr:{fillRule:"evenodd",d:"M7.293 14.707a1 1 0 010-1.414L10.586 10 7.293 6.707a1 1 0 011.414-1.414l4 4a1 1 0 010 1.414l-4 4a1 1 0 01-1.414 0z",clipRule:"evenodd"},child:[]}]})(e)}const L=f.createContext(void 0),J=f.forwardRef((e,r)=>{const{children:t,onOpenChange:n,position:o,sub:a,...d}=e;m.assertEmpty(d);const[i,c]=f.useState(!1),u=f.useRef(null),g=f.useRef(),h=f.useCallback(()=>{g.current&&clearTimeout(g.current),g.current=setTimeout(()=>{c(!1)},250)},[]),v=f.useCallback(()=>{g.current&&clearTimeout(g.current),c(!0)},[]);return s.jsx(L.Provider,{value:{onMenuMouseOver:v,onMenuMouseLeave:h},children:s.jsx(l.Menu.Item,{className:"bn-menu-item bn-mt-sub-menu-item",ref:S.mergeRefs(r,u),onMouseOver:v,onMouseLeave:h,children:s.jsx(l.Menu,{portalProps:{target:u.current?u.current.parentElement:void 0},middlewares:{flip:!0,shift:!0,inline:!1,size:!0},trigger:"hover",opened:i,onClose:()=>n==null?void 0:n(!1),onOpen:()=>n==null?void 0:n(!0),position:o,children:t})})})}),Q=e=>{const{children:r,onOpenChange:t,position:n,sub:o,...a}=e;return m.assertEmpty(a),o?s.jsx(J,{...e}):s.jsx(l.Menu,{withinPortal:!1,middlewares:{flip:!0,shift:!0,inline:!1,size:!0},onClose:()=>t==null?void 0:t(!1),onOpen:()=>t==null?void 0:t(!0),position:n,children:r})},X=f.forwardRef((e,r)=>{const{className:t,children:n,icon:o,checked:a,subTrigger:d,onClick:i,...c}=e;return m.assertEmpty(c,!1),d?s.jsxs("div",{onClick:u=>{u.preventDefault(),u.stopPropagation()},ref:r,...c,children:[n,s.jsx(Z,{size:15})]}):s.jsx(l.Menu.Item,{className:t,ref:r,leftSection:o,rightSection:a?s.jsx(l.CheckIcon,{size:10}):a===!1?s.jsx("div",{className:"bn-tick-space"}):null,onClick:i,...c,children:n})}),Y=e=>{const{children:r,sub:t,...n}=e;return m.assertEmpty(n),s.jsx(l.Menu.Target,{children:r})},R=f.forwardRef((e,r)=>{const{className:t,children:n,sub:o,...a}=e;m.assertEmpty(a);const d=f.useContext(L);return s.jsx(l.Menu.Dropdown,{className:t,ref:r,onMouseOver:d==null?void 0:d.onMenuMouseOver,onMouseLeave:d==null?void 0:d.onMenuMouseLeave,children:n})}),$=f.forwardRef((e,r)=>{const{className:t,...n}=e;return m.assertEmpty(n),s.jsx(l.Menu.Divider,{className:t,ref:r})}),ee=f.forwardRef((e,r)=>{const{className:t,children:n,...o}=e;return m.assertEmpty(o),s.jsx(l.Menu.Label,{className:t,ref:r,children:n})}),te=f.forwardRef((e,r)=>{const{className:t,tabs:n,defaultOpenTab:o,openTab:a,setOpenTab:d,loading:i,...c}=e;return m.assertEmpty(c),s.jsx(l.Group,{className:t,ref:r,children:s.jsxs(l.Tabs,{value:a,defaultValue:o,onChange:d,children:[i&&s.jsx(l.LoadingOverlay,{visible:i}),s.jsx(l.Tabs.List,{children:n.map(u=>s.jsx(l.Tabs.Tab,{"data-test":`${u.name.toLowerCase()}-tab`,value:u.name,children:u.name},u.name))}),n.map(u=>s.jsx(l.Tabs.Panel,{value:u.name,children:u.tabPanel},u.name))]})})}),re=f.forwardRef((e,r)=>{const{className:t,children:n,onClick:o,label:a,...d}=e;return m.assertEmpty(d),s.jsx(l.Button,{size:"xs","aria-label":a,className:t,ref:r,onClick:o,...d,children:n})}),ne=f.forwardRef((e,r)=>{const{className:t,accept:n,value:o,placeholder:a,onChange:d,...i}=e;return m.assertEmpty(i),s.jsx(l.FileInput,{size:"xs",className:t,ref:r,accept:n,value:o,placeholder:a,onChange:d,...i})}),oe=f.forwardRef((e,r)=>{const{className:t,children:n,...o}=e;return m.assertEmpty(o),s.jsx("div",{className:t,ref:r,children:n})}),se=f.forwardRef((e,r)=>{const{className:t,value:n,placeholder:o,onKeyDown:a,onChange:d,...i}=e;return m.assertEmpty(i),s.jsx(l.TextInput,{size:"xs","data-test":"embed-input",className:t,ref:r,value:n,placeholder:o,onKeyDown:a,onChange:d})}),ae=e=>{const{children:r,opened:t,position:n,...o}=e;return m.assertEmpty(o),s.jsx(l.Popover,{withinPortal:!1,opened:t,position:n,children:r})},le=e=>{const{children:r,...t}=e;return m.assertEmpty(t),s.jsx(l.PopoverTarget,{children:r})},ie=f.forwardRef((e,r)=>{const{className:t,children:n,variant:o,...a}=e;return m.assertEmpty(a),s.jsx(l.PopoverDropdown,{className:t,ref:r,children:n})}),de=f.forwardRef((e,r)=>{const{className:t,children:n,...o}=e;return m.assertEmpty(o,!1),s.jsx(l.Group,{align:"center",gap:0,className:t,ref:r,...o,children:n})}),ue=f.forwardRef((e,r)=>{const{className:t,children:n,icon:o,onClick:a,onDragEnd:d,onDragStart:i,draggable:c,label:u,...g}=e;return m.assertEmpty(g,!1),o?s.jsx(l.ActionIcon,{size:24,className:t,ref:r,onClick:a,onDragEnd:d,onDragStart:i,draggable:c,"aria-label":u,...g,children:o}):s.jsx(l.Button,{className:t,ref:r,onClick:a,onDragEnd:d,onDragStart:i,draggable:c,"aria-label":u,...g,children:n})}),ce=f.forwardRef((e,r)=>{const{className:t,children:n,id:o,columns:a,...d}=e;return m.assertEmpty(d),s.jsx("div",{className:t,style:{gridTemplateColumns:`repeat(${a}, 1fr)`},ref:r,id:o,role:"grid",children:n})}),fe=f.forwardRef((e,r)=>{const{className:t,children:n,columns:o,...a}=e;return m.assertEmpty(a),s.jsx(l.Group,{className:t,style:{gridColumn:`1 / ${o+1}`},ref:r,children:s.jsx(l.Group,{className:"bn-mt-suggestion-menu-item-title",children:n})})}),me=f.forwardRef((e,r)=>{const{className:t,isSelected:n,onClick:o,item:a,id:d,...i}=e;m.assertEmpty(i);const c=f.useRef(null);return f.useEffect(()=>{if(!c.current||!n)return;const u=w.elementOverflow(c.current,document.querySelector(".bn-grid-suggestion-menu"));u==="top"?c.current.scrollIntoView(!0):u==="bottom"&&c.current.scrollIntoView(!1)},[n]),s.jsx("div",{className:t,ref:S.mergeRefs(r,c),id:d,role:"option",onClick:o,"aria-selected":n||void 0,children:a.icon})}),pe=f.forwardRef((e,r)=>{const{className:t,children:n,columns:o,...a}=e;return m.assertEmpty(a),s.jsx(l.Loader,{className:t,style:{gridColumn:`1 / ${o+1}`},type:"dots",ref:r})}),be=f.forwardRef((e,r)=>{const{className:t,children:n,id:o,...a}=e;return m.assertEmpty(a),s.jsx(l.Stack,{gap:0,className:t,ref:r,id:o,role:"listbox",children:n})}),ge=f.forwardRef((e,r)=>{const{className:t,children:n,...o}=e;return m.assertEmpty(o),s.jsx(l.Group,{className:t,ref:r,children:s.jsx(l.Group,{className:"bn-mt-suggestion-menu-item-title",children:n})})}),he=f.forwardRef((e,r)=>{const{className:t,isSelected:n,onClick:o,item:a,id:d,...i}=e;m.assertEmpty(i);const c=f.useRef(null);return f.useEffect(()=>{if(!c.current||!n)return;const u=w.elementOverflow(c.current,document.querySelector(".bn-suggestion-menu"));u==="top"?c.current.scrollIntoView(!0):u==="bottom"&&c.current.scrollIntoView(!1)},[n]),s.jsxs(l.Group,{gap:0,className:t,ref:S.mergeRefs(r,c),id:d,role:"option",onClick:o,"aria-selected":n||void 0,children:[a.icon&&s.jsx(l.Group,{className:"bn-mt-suggestion-menu-item-section","data-position":"left",children:a.icon}),s.jsxs(l.Stack,{gap:0,className:"bn-mt-suggestion-menu-item-body",children:[s.jsx(l.Text,{className:"bn-mt-suggestion-menu-item-title",children:a.title}),s.jsx(l.Text,{className:"bn-mt-suggestion-menu-item-subtitle",children:a.subtext})]}),a.badge&&s.jsx(l.Group,{"data-position":"right",className:"bn-mt-suggestion-menu-item-section",children:s.jsx(l.Badge,{size:"xs",children:a.badge})})]})}),ve=f.forwardRef((e,r)=>{const{className:t,children:n,...o}=e;return m.assertEmpty(o),s.jsx(l.Group,{className:t,ref:r,children:n})}),ye=f.forwardRef((e,r)=>{const{className:t,children:n,...o}=e;return m.assertEmpty(o),s.jsx(l.Loader,{className:t,type:"dots",ref:r})}),we=f.forwardRef((e,r)=>{const{children:t,className:n,onMouseDown:o,onClick:a,...d}=e;return m.assertEmpty(d,!1),s.jsx(l.Button,{className:n,ref:r,onMouseDown:o,onClick:a,...d,children:t})}),Se=f.forwardRef((e,r)=>{const{className:t,children:n,draggable:o,onDragStart:a,onDragEnd:d,style:i,label:c,...u}=e;return m.assertEmpty(u,!1),s.jsx(l.Button,{className:t,ref:r,"aria-label":c,draggable:o,onDragStart:a,onDragEnd:d,style:i,...u,children:n})}),C=f.forwardRef((e,r)=>{const{className:t,children:n,onMouseEnter:o,onMouseLeave:a,...d}=e;m.assertEmpty(d);const{ref:i,focused:c}=S.useFocusWithin(),u=S.useFocusTrap(c),g=S.mergeRefs(r,i,u);return s.jsx(l.Group,{className:t,ref:g,role:"toolbar",onMouseEnter:o,onMouseLeave:a,children:n})}),Te=e=>s.jsxs(l.Stack,{gap:0,className:"bn-tooltip",children:[s.jsx(l.Text,{size:"sm",children:e.mainTooltip}),e.secondaryTooltip&&s.jsx(l.Text,{size:"xs",children:e.secondaryTooltip})]}),M=f.forwardRef((e,r)=>{const{className:t,children:n,mainTooltip:o,secondaryTooltip:a,icon:d,isSelected:i,isDisabled:c,onClick:u,label:g,...h}=e;return m.assertEmpty(h,!1),s.jsx(l.Tooltip,{withinPortal:!1,label:s.jsx(Te,{mainTooltip:o,secondaryTooltip:a}),children:n?s.jsx(l.Button,{"aria-label":g,className:t,onMouseDown:v=>{m.isSafari()&&v.currentTarget.focus()},onClick:u,"aria-pressed":i,"data-selected":i||void 0,"data-test":o.slice(0,1).toLowerCase()+o.replace(/\s+/g,"").slice(1),size:"xs",disabled:c||!1,ref:r,...h,children:n}):s.jsx(l.ActionIcon,{className:t,"aria-label":g,onMouseDown:v=>{m.isSafari()&&v.currentTarget.focus()},onClick:u,"aria-pressed":i,"data-selected":i||void 0,"data-test":o.slice(0,1).toLowerCase()+o.replace(/\s+/g,"").slice(1),size:30,disabled:c||!1,ref:r,...h,children:d})})}),ke=f.forwardRef((e,r)=>{const{className:t,items:n,isDisabled:o,...a}=e;m.assertEmpty(a);const d=n.filter(i=>i.isSelected)[0];return d?s.jsxs(l.Menu,{withinPortal:!1,transitionProps:{exitDuration:0},disabled:o,middlewares:{flip:!0,shift:!0,inline:!1,size:!0},children:[s.jsx(l.Menu.Target,{children:s.jsx(l.Button,{onMouseDown:i=>{m.isSafari()&&i.currentTarget.focus()},leftSection:d.icon,rightSection:s.jsx(W,{}),size:"xs",variant:"subtle",disabled:o,children:d.text})}),s.jsx(l.Menu.Dropdown,{className:t,ref:r,children:n.map(i=>s.jsx(l.Menu.Item,{onClick:i.onClick,leftSection:i.icon,rightSection:i.isSelected?s.jsx(l.CheckIcon,{size:10,className:"bn-tick-icon"}):s.jsx("div",{className:"bn-tick-space"}),disabled:i.isDisabled,children:i.text},i.text))})]}):null}),B={FormattingToolbar:{Root:C,Button:M,Select:ke},FilePanel:{Root:te,Button:re,FileInput:ne,TabPanel:oe,TextInput:se},GridSuggestionMenu:{Root:ce,Item:me,EmptyItem:fe,Loader:pe},LinkToolbar:{Root:C,Button:M},SideMenu:{Root:de,Button:ue},SuggestionMenu:{Root:be,Item:he,EmptyItem:ge,Label:ve,Loader:ye},TableHandle:{Root:Se,ExtendButton:we},Generic:{Toolbar:{Root:C,Button:M},Form:{Root:e=>s.jsx("div",{children:e.children}),TextInput:G},Menu:{Root:Q,Trigger:Y,Dropdown:R,Divider:$,Label:ee,Item:X},Popover:{Root:ae,Trigger:le,Content:ie}}},xe={activeClassName:""},Ce=e=>{const{className:r,theme:t,...n}=e,o=w.useBlockNoteContext(),a=w.usePrefersColorScheme(),d=(o==null?void 0:o.colorSchemePreference)||a,i=f.useCallback(u=>{if(u&&(P(u),typeof t=="object")){if("light"in t&&"dark"in t){x(t[d==="dark"?"dark":"light"],u);return}x(t,u);return}},[d,t]),c=typeof t=="string"?t:d!=="no-preference"?d:"light";return s.jsx(w.ComponentsContext.Provider,{value:B,children:s.jsx(l.MantineProvider,{theme:xe,cssVariablesSelector:".bn-mantine",getRootElement:()=>{},children:s.jsx(w.BlockNoteViewRaw,{"data-mantine-color-scheme":c,className:m.mergeCSSClasses("bn-mantine",r||""),theme:typeof t=="object"?void 0:t,...n,ref:i})})})},p=["#FFFFFF","#EFEFEF","#CFCFCF","#AFAFAF","#7F7F7F","#3F3F3F","#1F1F1F","#161616","#0F0F0F","#000000"],E={colors:{editor:{text:p[5],background:p[0]},menu:{text:p[5],background:p[0]},tooltip:{text:p[5],background:p[1]},hovered:{text:p[5],background:p[1]},selected:{text:p[0],background:p[5]},disabled:{text:p[3],background:p[1]},shadow:p[2],border:p[1],sideMenu:p[2],highlights:m.COLORS_DEFAULT},borderRadius:6,fontFamily:'"Inter", "SF Pro Display", -apple-system, BlinkMacSystemFont, "Open Sans", "Segoe UI", "Roboto", "Oxygen", "Ubuntu", "Cantarell", "Fira Sans", "Droid Sans", "Helvetica Neue", sans-serif'},Me={colors:{editor:{text:p[2],background:p[6]},menu:{text:p[2],background:p[6]},tooltip:{text:p[2],background:p[7]},hovered:{text:p[2],background:p[7]},selected:{text:p[2],background:p[8]},disabled:{text:p[5],background:p[7]},shadow:p[8],border:p[7],sideMenu:p[4],highlights:m.COLORS_DARK_MODE_DEFAULT},borderRadius:E.borderRadius,fontFamily:E.fontFamily};b.BlockNoteView=Ce,b.applyBlockNoteCSSVariablesFromTheme=x,b.components=B,b.darkDefaultTheme=Me,b.defaultColorScheme=p,b.lightDefaultTheme=E,b.removeBlockNoteCSSVariables=P,Object.defineProperty(b,Symbol.toStringTag,{value:"Module"})});
2
- //# sourceMappingURL=blocknote-mantine.umd.cjs.map