@tnkrai/tnkr-editor 0.2.9 → 0.3.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.
@@ -1 +1 @@
1
- {"version":3,"file":"floating-element.d.ts","sourceRoot":"","sources":["../../../../../core/components/tiptap-ui-utils/floating-element/floating-element.tsx"],"names":[],"mappings":"AAEA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAA;AAC9B,OAAO,EAAE,KAAK,MAAM,EAAE,MAAM,eAAe,CAAA;AAC3C,OAAO,EAKL,KAAK,kBAAkB,EACxB,MAAM,oBAAoB,CAAA;AAgB3B,MAAM,WAAW,oBACf,SAAQ,KAAK,CAAC,cAAc,CAAC,cAAc,CAAC;IAC5C;;OAEG;IACH,MAAM,CAAC,EAAE,MAAM,GAAG,IAAI,CAAA;IACtB;;;OAGG;IACH,UAAU,CAAC,EAAE,OAAO,CAAA;IACpB;;OAEG;IACH,eAAe,CAAC,EAAE,OAAO,CAAC,kBAAkB,CAAC,CAAA;IAC7C;;;OAGG;IACH,MAAM,CAAC,EAAE,MAAM,CAAA;IACf;;OAEG;IACH,YAAY,CAAC,EAAE,CAAC,IAAI,EAAE,OAAO,KAAK,IAAI,CAAA;IACtC;;;OAGG;IACH,YAAY,CAAC,EAAE,CAAC,IAAI,EAAE,OAAO,GAAG,IAAI,KAAK,IAAI,CAAA;IAC7C;;;OAGG;IACH,qBAAqB,CAAC,EAAE,CAAC,MAAM,EAAE,MAAM,KAAK,OAAO,GAAG,IAAI,CAAA;IAC1D;;;OAGG;IACH,cAAc,CAAC,EAAE,OAAO,CAAA;IACxB;;;OAGG;IACH,aAAa,CAAC,EAAE,OAAO,CAAA;CACxB;AAED;;;GAGG;AACH,eAAO,MAAM,eAAe,6FAoQ3B,CAAA"}
1
+ {"version":3,"file":"floating-element.d.ts","sourceRoot":"","sources":["../../../../../core/components/tiptap-ui-utils/floating-element/floating-element.tsx"],"names":[],"mappings":"AAEA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAC/B,OAAO,EAAE,KAAK,MAAM,EAAE,MAAM,eAAe,CAAC;AAC5C,OAAO,EAKL,KAAK,kBAAkB,EACxB,MAAM,oBAAoB,CAAC;AAgB5B,MAAM,WAAW,oBACf,SAAQ,KAAK,CAAC,cAAc,CAAC,cAAc,CAAC;IAC5C;;OAEG;IACH,MAAM,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IACvB;;;OAGG;IACH,UAAU,CAAC,EAAE,OAAO,CAAC;IACrB;;OAEG;IACH,eAAe,CAAC,EAAE,OAAO,CAAC,kBAAkB,CAAC,CAAC;IAC9C;;;OAGG;IACH,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB;;OAEG;IACH,YAAY,CAAC,EAAE,CAAC,IAAI,EAAE,OAAO,KAAK,IAAI,CAAC;IACvC;;;OAGG;IACH,YAAY,CAAC,EAAE,CAAC,IAAI,EAAE,OAAO,GAAG,IAAI,KAAK,IAAI,CAAC;IAC9C;;;OAGG;IACH,qBAAqB,CAAC,EAAE,CAAC,MAAM,EAAE,MAAM,KAAK,OAAO,GAAG,IAAI,CAAC;IAC3D;;;OAGG;IACH,cAAc,CAAC,EAAE,OAAO,CAAC;IACzB;;;OAGG;IACH,aAAa,CAAC,EAAE,OAAO,CAAC;CACzB;AAED;;;GAGG;AACH,eAAO,MAAM,eAAe,6FA+O3B,CAAC"}
@@ -1 +1 @@
1
- {"version":3,"file":"use-floating-toolbar-visibility.d.ts","sourceRoot":"","sources":["../../../core/hooks/use-floating-toolbar-visibility.ts"],"names":[],"mappings":"AACA,OAAO,EAAmB,KAAK,MAAM,EAAE,MAAM,eAAe,CAAA;AAG5D,eAAO,MAAM,kBAAkB,wBAAwB,CAAA;AAEvD;;;;;;;;GAQG;AACH,wBAAgB,4BAA4B,CAAC,MAAM,EAAE;IACnD,MAAM,EAAE,MAAM,GAAG,IAAI,CAAA;IACrB,gBAAgB,EAAE,CAChB,MAAM,EAAE,MAAM,EACd,SAAS,EAAE,MAAM,CAAC,OAAO,CAAC,CAAC,WAAW,CAAC,KACpC,OAAO,CAAA;IACZ,aAAa,CAAC,EAAE,OAAO,CAAA;CACxB;;EA2GA;AAED;;;;GAIG;AACH,eAAO,MAAM,yBAAyB,GAAI,QAAQ,MAAM,EAAE,KAAK,MAAM,SAQpE,CAAA;AAED;;;GAGG;AACH,eAAO,MAAM,sBAAsB,GAAI,QAAQ,MAAM,SAGpD,CAAA"}
1
+ {"version":3,"file":"use-floating-toolbar-visibility.d.ts","sourceRoot":"","sources":["../../../core/hooks/use-floating-toolbar-visibility.ts"],"names":[],"mappings":"AACA,OAAO,EAAmB,KAAK,MAAM,EAAE,MAAM,eAAe,CAAA;AAG5D,eAAO,MAAM,kBAAkB,wBAAwB,CAAA;AAEvD;;;;;;;;GAQG;AACH,wBAAgB,4BAA4B,CAAC,MAAM,EAAE;IACnD,MAAM,EAAE,MAAM,GAAG,IAAI,CAAA;IACrB,gBAAgB,EAAE,CAChB,MAAM,EAAE,MAAM,EACd,SAAS,EAAE,MAAM,CAAC,OAAO,CAAC,CAAC,WAAW,CAAC,KACpC,OAAO,CAAA;IACZ,aAAa,CAAC,EAAE,OAAO,CAAA;CACxB;;EA+EA;AAED;;;;GAIG;AACH,eAAO,MAAM,yBAAyB,GAAI,QAAQ,MAAM,EAAE,KAAK,MAAM,SAQpE,CAAA;AAED;;;GAGG;AACH,eAAO,MAAM,sBAAsB,GAAI,QAAQ,MAAM,SAGpD,CAAA"}
package/dist/index.cjs CHANGED
@@ -54856,19 +54856,12 @@ function useFloatingToolbarVisibility(params) {
54856
54856
  const handleSelectionUpdate = () => {
54857
54857
  const { selection } = editor.state;
54858
54858
  const valid = isSelectionValid(editor, selection);
54859
- // Clear hide flag when selection becomes invalid naturally
54860
- if (!valid && !react.isNodeSelection(selection)) {
54861
- hideRef.current = false;
54862
- }
54863
54859
  if (extraHideWhen || (react.isNodeSelection(selection) && hideRef.current)) {
54864
54860
  setShouldShow(false);
54865
54861
  return;
54866
54862
  }
54867
54863
  setShouldShow(valid);
54868
54864
  // Clear hide flag when we successfully show toolbar with valid selection
54869
- if (valid && !react.isNodeSelection(selection)) {
54870
- hideRef.current = false;
54871
- }
54872
54865
  };
54873
54866
  handleSelectionUpdate();
54874
54867
  editor.on("selectionUpdate", handleSelectionUpdate);
@@ -54877,26 +54870,6 @@ function useFloatingToolbarVisibility(params) {
54877
54870
  };
54878
54871
  }, [editor, extraHideWhen, isSelectionValid]);
54879
54872
  // --- Focus events to reset hide state
54880
- React__namespace.useEffect(() => {
54881
- if (!editor)
54882
- return;
54883
- const handleFocus = () => {
54884
- // Reset hide flag when editor gains focus
54885
- // This ensures clean state for new user interactions
54886
- hideRef.current = false;
54887
- };
54888
- const handleBlur = () => {
54889
- // Clear should show when editor loses focus
54890
- setShouldShow(false);
54891
- };
54892
- const editorDom = editor.view.dom;
54893
- editorDom.addEventListener("focus", handleFocus);
54894
- editorDom.addEventListener("blur", handleBlur);
54895
- return () => {
54896
- editorDom.removeEventListener("focus", handleFocus);
54897
- editorDom.removeEventListener("blur", handleBlur);
54898
- };
54899
- }, [editor]);
54900
54873
  return { shouldShow };
54901
54874
  }
54902
54875
  /**
@@ -72652,7 +72625,7 @@ const FloatingElement = React__namespace.forwardRef((_a, forwardedRef) => {
72652
72625
  handleOpenChange(false);
72653
72626
  }
72654
72627
  }, [editor, getBoundingClientRect, handleOpenChange, shouldShow]);
72655
- const debouncedUpdateSelectionState = React__namespace.useCallback(() => {
72628
+ React__namespace.useCallback(() => {
72656
72629
  // Use RAF to ensure this runs after all synchronous selection updates
72657
72630
  requestAnimationFrame(() => {
72658
72631
  updateSelectionState();
@@ -72718,27 +72691,13 @@ const FloatingElement = React__namespace.forwardRef((_a, forwardedRef) => {
72718
72691
  if (!editor)
72719
72692
  return;
72720
72693
  const handleMouseUp = (event) => {
72721
- const target = event.target;
72722
- if (!target)
72723
- return;
72724
- // Check if click was outside the editor
72725
- const isWithinEditor = isElementWithinEditor(editor, target);
72726
- const floatingElement = floatingElementRef.current;
72727
- const isWithinFloatingElement = floatingElement &&
72728
- (floatingElement === target || floatingElement.contains(target));
72729
- if (!isWithinEditor && !isWithinFloatingElement) {
72730
- // Clicked outside - immediately hide
72731
- handleOpenChange(false);
72732
- return;
72733
- }
72734
- // For clicks within editor, use debounced update to avoid race conditions
72735
- debouncedUpdateSelectionState();
72694
+ updateSelectionState();
72736
72695
  };
72737
72696
  editor.view.root.addEventListener("mouseup", handleMouseUp);
72738
72697
  return () => {
72739
72698
  editor.view.root.removeEventListener("mouseup", handleMouseUp);
72740
72699
  };
72741
- }, [editor, debouncedUpdateSelectionState, handleOpenChange]);
72700
+ }, [editor, updateSelectionState]);
72742
72701
  React__namespace.useEffect(() => {
72743
72702
  if (!editor)
72744
72703
  return;
@@ -72746,18 +72705,13 @@ const FloatingElement = React__namespace.forwardRef((_a, forwardedRef) => {
72746
72705
  if (open)
72747
72706
  updateSelectionState();
72748
72707
  };
72749
- const handleSelectionUpdate = () => {
72750
- // Use immediate update for selection changes (keyboard, programmatic)
72751
- // This ensures quick response to valid selection changes
72752
- updateSelectionState();
72753
- };
72754
- editor.on("selectionUpdate", handleSelectionUpdate);
72708
+ editor.on("selectionUpdate", updateSelectionState);
72755
72709
  window.addEventListener("resize", updateIfOpen);
72756
72710
  if (updateOnScroll) {
72757
72711
  editor.view.root.addEventListener("scroll", updateIfOpen, true);
72758
72712
  }
72759
72713
  return () => {
72760
- editor.off("selectionUpdate", handleSelectionUpdate);
72714
+ editor.off("selectionUpdate", updateSelectionState);
72761
72715
  window.removeEventListener("resize", updateIfOpen);
72762
72716
  if (updateOnScroll) {
72763
72717
  editor.view.root.removeEventListener("scroll", updateIfOpen, true);
@@ -77426,7 +77380,7 @@ const CustomPage = ({ pageParent, pageTitle, pageId, pageType = "documentation",
77426
77380
  // Pass editor-related props
77427
77381
  initialData: editorContent, onEditorChange: handleEditorChange, onSave: onSave, editMode: isEditMode, onUploadImage: onUploadImage }) }));
77428
77382
  }
77429
- return (jsxRuntimeExports.jsx("div", { className: `relative h-full overflow-auto w-full flex flex-col mx-auto ${className}`, style: style, children: jsxRuntimeExports.jsxs("div", { className: "flex-1 prose prose-invert max-w-none px-8", children: [jsxRuntimeExports.jsx("header", { className: "text-[#AA423A] font-semibold text-sm uppercase tracking-wide mb-4", style: { marginLeft: '2rem' }, children: pageParent }), jsxRuntimeExports.jsx(TnkrEditor, Object.assign({ content: editorContent, onChange: handleEditorChange, readOnly: !isEditMode, pageTitle: pageTitle, pageId: pageId, onUploadImage: onUploadImage, placeholder: isEditMode ? "Start writing your content..." : "", minHeight: 600, whatsNextGoToPage: goToPage, whatsNextPages: pages, showWhatsNext: true }, editorProps), `${pageId}`)] }) }));
77383
+ return (jsxRuntimeExports.jsx("div", { className: `relative h-full overflow-auto w-full flex flex-col mx-auto ${className}`, style: style, children: jsxRuntimeExports.jsxs("div", { className: "flex-1 prose prose-invert max-w-none px-8", children: [jsxRuntimeExports.jsx("header", { className: "text-[#AA423A] font-semibold text-sm uppercase tracking-wide mb-4 mt-4", style: { marginLeft: '2rem' }, children: pageParent }), jsxRuntimeExports.jsx(TnkrEditor, Object.assign({ content: editorContent, onChange: handleEditorChange, readOnly: !isEditMode, pageTitle: pageTitle, pageId: pageId, onUploadImage: onUploadImage, placeholder: isEditMode ? "Start writing your content..." : "", minHeight: 600, whatsNextGoToPage: goToPage, whatsNextPages: pages, showWhatsNext: true }, editorProps), `${pageId}`)] }) }));
77430
77384
  };
77431
77385
 
77432
77386
  const PreviewCategoryItem = ({ category, level, selectedId, onSelect, onToggleExpand, }) => {