@editorcn/editor 0.5.1 → 0.5.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.js CHANGED
@@ -1006,6 +1006,7 @@ var BubbleMenu = ({ editor }) => {
1006
1006
  return /* @__PURE__ */ jsx19(
1007
1007
  TiptapBubbleMenu,
1008
1008
  {
1009
+ className: "z-50",
1009
1010
  editor,
1010
1011
  options: { offset: 8, placement: "top" },
1011
1012
  shouldShow,
@@ -1102,6 +1103,7 @@ var RichTextEditorControl = forwardRef12(
1102
1103
  return props.title ? /* @__PURE__ */ jsx20(RichTextEditorTooltip, { id: props.id, label: props.title, children: toggle }) : toggle;
1103
1104
  }
1104
1105
  );
1106
+ RichTextEditorControl.displayName = "RichTextEditorControl";
1105
1107
  var resolveIsActive = (editor, config) => {
1106
1108
  if (!editor || !config) {
1107
1109
  return false;
@@ -3121,7 +3123,7 @@ var Content = ({
3121
3123
  // src/rte-controls-group.tsx
3122
3124
  import { useContext as useContext3 } from "react";
3123
3125
  import { jsx as jsx29 } from "react/jsx-runtime";
3124
- var SEPARATOR = "[.rte-controls-group+&]:before:w-px [.rte-controls-group+&]:before:shrink-0 [.rte-controls-group+&]:before:bg-border [.rte-controls-group+&]:before:content-['']";
3126
+ var SEPARATOR = "[.rte-controls-group+&]:before:w-px [.rte-controls-group+&]:before:shrink-0 [.rte-controls-group+&]:before:bg-border [.rte-controls-group+&]:before:content-[''] [.rte-controls-group+&]:data-line-start:before:invisible";
3125
3127
  var BUTTON = "[&>button]:border-none [&>button]:bg-transparent [&>button]:transition-[background-color,color] [&>button]:duration-150 [&>button]:ease-[ease-out] [&>button:focus-visible]:outline-2 [&>button:focus-visible]:outline-offset-1 [&>button:focus-visible]:outline-ring/50 [&>button:focus-visible]:outline-solid";
3126
3128
  var variantClasses = {
3127
3129
  compact: `${SEPARATOR} [.rte-controls-group+&]:before:mx-0.5 [.rte-controls-group+&]:before:h-3.5 ${BUTTON} [&>button]:h-7 [&>button]:min-w-7 [&>button]:rounded-sm [&>button]:text-muted-foreground [&>button:hover]:bg-muted [&>button:hover]:text-foreground [&>button[aria-pressed=true]]:bg-muted [&>button[aria-pressed=true]]:text-foreground [&>button[data-state=on]]:bg-muted [&>button[data-state=on]]:text-foreground`,
@@ -3254,7 +3256,50 @@ var Footer = ({
3254
3256
  };
3255
3257
 
3256
3258
  // src/rte-toolbar.tsx
3259
+ import { useLayoutEffect, useRef as useRef6 } from "react";
3257
3260
  import { jsx as jsx31 } from "react/jsx-runtime";
3261
+ var GROUPS = ":scope > .rte-controls-group";
3262
+ var useMarkLineStarts = (enabled) => {
3263
+ const ref = useRef6(null);
3264
+ useLayoutEffect(() => {
3265
+ const toolbar = ref.current;
3266
+ if (!enabled || !toolbar || typeof ResizeObserver === "undefined") {
3267
+ return;
3268
+ }
3269
+ const mark = () => {
3270
+ let previous = null;
3271
+ for (const group of toolbar.querySelectorAll(GROUPS)) {
3272
+ if (group.getClientRects().length === 0) {
3273
+ continue;
3274
+ }
3275
+ const rect = group.getBoundingClientRect();
3276
+ const startsLine = previous !== null && rect.top >= previous.bottom - 1;
3277
+ group.toggleAttribute("data-line-start", startsLine);
3278
+ previous = rect;
3279
+ }
3280
+ };
3281
+ const resize = new ResizeObserver(mark);
3282
+ const observeAll = () => {
3283
+ resize.disconnect();
3284
+ resize.observe(toolbar);
3285
+ for (const group of toolbar.querySelectorAll(GROUPS)) {
3286
+ resize.observe(group);
3287
+ }
3288
+ };
3289
+ const mutation = new MutationObserver(() => {
3290
+ observeAll();
3291
+ mark();
3292
+ });
3293
+ mutation.observe(toolbar, { childList: true });
3294
+ observeAll();
3295
+ mark();
3296
+ return () => {
3297
+ resize.disconnect();
3298
+ mutation.disconnect();
3299
+ };
3300
+ }, [enabled]);
3301
+ return ref;
3302
+ };
3258
3303
  var Toolbar = ({
3259
3304
  children,
3260
3305
  className,
@@ -3262,12 +3307,14 @@ var Toolbar = ({
3262
3307
  stickyOffset = 0
3263
3308
  }) => {
3264
3309
  const { variant, editable } = useRichTextEditorContext();
3310
+ const ref = useMarkLineStarts(editable);
3265
3311
  if (!editable) {
3266
3312
  return null;
3267
3313
  }
3268
3314
  return /* @__PURE__ */ jsx31(
3269
3315
  "div",
3270
3316
  {
3317
+ ref,
3271
3318
  className: cn(
3272
3319
  "rte-toolbar top-[var(--rte-sticky-offset,0px)] z-1 flex flex-wrap items-center justify-center gap-1 rounded-ss-[calc(var(--radius)+3px)] rounded-se-[calc(var(--radius)+3px)] border-b border-(--rte-hairline) bg-(--rte-strip) px-2 py-1.5 [transition:background-color_150ms_ease-out]",
3273
3320
  "[@media(max-width:640px)]:justify-start [@media(max-width:640px)]:flex-nowrap [@media(max-width:640px)]:overflow-x-auto [@media(max-width:640px)]:[--rte-toolbar-fade-end:1.5rem] [@media(max-width:640px)]:[-ms-overflow-style:none] [@media(max-width:640px)]:[-webkit-overflow-scrolling:touch] [@media(max-width:640px)]:[mask-image:linear-gradient(to_right,transparent,black_var(--rte-toolbar-fade-start),black_calc(100%-var(--rte-toolbar-fade-end)),transparent)] [@media(max-width:640px)]:[scrollbar-width:none] [@media(max-width:640px)]:[&::-webkit-scrollbar]:hidden [@media(max-width:640px)]:supports-[animation-timeline:scroll()]:[--rte-toolbar-fade-end:0px] [@media(max-width:640px)]:supports-[animation-timeline:scroll()]:animate-rte-toolbar-fade [@media(max-width:640px)]:supports-[animation-timeline:scroll()]:[animation-timeline:scroll(self_inline)]",