autoblogger 0.2.25 → 0.2.27

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/ui.mjs CHANGED
@@ -7219,7 +7219,7 @@ var TiptapEditor_exports = {};
7219
7219
  __export(TiptapEditor_exports, {
7220
7220
  TiptapEditor: () => TiptapEditor
7221
7221
  });
7222
- import { useEffect as useEffect12, useMemo as useMemo4, useRef as useRef9, useCallback as useCallback10 } from "react";
7222
+ import { useEffect as useEffect12, useMemo as useMemo4, useRef as useRef9 } from "react";
7223
7223
  import { useEditor, EditorContent } from "@tiptap/react";
7224
7224
  import StarterKit from "@tiptap/starter-kit";
7225
7225
  import Placeholder from "@tiptap/extension-placeholder";
@@ -7405,43 +7405,69 @@ function TiptapEditor({
7405
7405
  }
7406
7406
  }
7407
7407
  }, [editor, content]);
7408
- const savedSelectionRef = useRef9(null);
7409
7408
  const containerRef = useRef9(null);
7410
- const handleTouchStart = useCallback10(() => {
7411
- if (!editor) return;
7412
- const { from, to, empty } = editor.state.selection;
7413
- if (!empty) {
7414
- savedSelectionRef.current = { from, to };
7415
- }
7416
- }, [editor]);
7417
- const handleTouchEnd = useCallback10(() => {
7418
- if (!editor || !savedSelectionRef.current) return;
7419
- const { empty } = editor.state.selection;
7420
- if (empty && savedSelectionRef.current) {
7421
- const { from, to } = savedSelectionRef.current;
7422
- requestAnimationFrame(() => {
7423
- if (editor && !editor.isDestroyed) {
7424
- try {
7425
- const docSize = editor.state.doc.content.size;
7426
- if (from <= docSize && to <= docSize) {
7427
- editor.commands.setTextSelection({ from, to });
7428
- }
7429
- } catch {
7430
- }
7409
+ useEffect12(() => {
7410
+ if (!editor?.view) return;
7411
+ const editorDom = editor.view.dom;
7412
+ let swipeState = null;
7413
+ const findListItem = (element) => {
7414
+ while (element && element !== editorDom) {
7415
+ if (element.tagName === "LI") {
7416
+ return element;
7431
7417
  }
7432
- });
7433
- }
7434
- savedSelectionRef.current = null;
7418
+ element = element.parentElement;
7419
+ }
7420
+ return null;
7421
+ };
7422
+ const handleTouchStart = (e) => {
7423
+ const touch = e.touches[0];
7424
+ const target = e.target;
7425
+ const listItem = findListItem(target);
7426
+ swipeState = {
7427
+ startX: touch.clientX,
7428
+ startY: touch.clientY,
7429
+ startTime: Date.now(),
7430
+ handled: false,
7431
+ listItemElement: listItem
7432
+ };
7433
+ };
7434
+ const handleTouchMove = (e) => {
7435
+ if (!swipeState || swipeState.handled) return;
7436
+ if (!swipeState.listItemElement) return;
7437
+ const touch = e.touches[0];
7438
+ const deltaX = touch.clientX - swipeState.startX;
7439
+ const deltaY = touch.clientY - swipeState.startY;
7440
+ const elapsed = Date.now() - swipeState.startTime;
7441
+ const absX = Math.abs(deltaX);
7442
+ const absY = Math.abs(deltaY);
7443
+ const isHorizontalSwipe = absX > 30 && absX > absY * 1.2 && elapsed < 500;
7444
+ if (!isHorizontalSwipe) return;
7445
+ swipeState.handled = true;
7446
+ e.preventDefault();
7447
+ try {
7448
+ const pos = editor.view.posAtDOM(swipeState.listItemElement, 0);
7449
+ editor.commands.setTextSelection(pos);
7450
+ } catch {
7451
+ }
7452
+ if (deltaX > 0) {
7453
+ editor.chain().focus().sinkListItem("listItem").run();
7454
+ } else {
7455
+ editor.chain().focus().liftListItem("listItem").run();
7456
+ }
7457
+ };
7458
+ const handleTouchEnd = () => {
7459
+ swipeState = null;
7460
+ };
7461
+ editorDom.addEventListener("touchstart", handleTouchStart, { passive: true });
7462
+ editorDom.addEventListener("touchmove", handleTouchMove, { passive: false });
7463
+ editorDom.addEventListener("touchend", handleTouchEnd, { passive: true });
7464
+ return () => {
7465
+ editorDom.removeEventListener("touchstart", handleTouchStart);
7466
+ editorDom.removeEventListener("touchmove", handleTouchMove);
7467
+ editorDom.removeEventListener("touchend", handleTouchEnd);
7468
+ };
7435
7469
  }, [editor]);
7436
- return /* @__PURE__ */ jsx24(
7437
- "div",
7438
- {
7439
- ref: containerRef,
7440
- onTouchStart: handleTouchStart,
7441
- onTouchEnd: handleTouchEnd,
7442
- children: /* @__PURE__ */ jsx24(EditorContent, { editor })
7443
- }
7444
- );
7470
+ return /* @__PURE__ */ jsx24("div", { ref: containerRef, children: /* @__PURE__ */ jsx24(EditorContent, { editor }) });
7445
7471
  }
7446
7472
  var PLACEHOLDER_STYLE_ID, DEFAULT_PROSE_CLASSES, StyledHeading, CustomStrike, CustomBulletList, CustomOrderedList, CustomCode, CustomBlockquote, CustomCodeBlock;
7447
7473
  var init_TiptapEditor = __esm({
@@ -14081,6 +14107,7 @@ function Toaster({ ...props }) {
14081
14107
  }
14082
14108
 
14083
14109
  // src/ui/dashboard.tsx
14110
+ import { toast as toast2 } from "sonner";
14084
14111
  import { Fragment as Fragment17, jsx as jsx44, jsxs as jsxs29 } from "react/jsx-runtime";
14085
14112
  var ChatPanel2 = lazy2(
14086
14113
  () => Promise.resolve().then(() => (init_ChatPanel(), ChatPanel_exports)).then((m) => ({ default: m.ChatPanel }))
@@ -14102,7 +14129,20 @@ function AutobloggerDashboard({
14102
14129
  }) {
14103
14130
  const resolvedChatApiPath = chatApiPath || `${apiBasePath}/ai/chat`;
14104
14131
  const resolvedHistoryApiPath = historyApiPath || `${apiBasePath}/chat/history`;
14105
- return /* @__PURE__ */ jsx44(ThemeProvider, { className: "h-dvh bg-background text-foreground flex flex-col overscroll-none", children: /* @__PURE__ */ jsx44(
14132
+ useEffect26(() => {
14133
+ const viewportMeta = document.querySelector('meta[name="viewport"]');
14134
+ if (viewportMeta) {
14135
+ const originalContent = viewportMeta.getAttribute("content") || "";
14136
+ if (!originalContent.includes("user-scalable")) {
14137
+ const newContent = originalContent + ", user-scalable=no, maximum-scale=1";
14138
+ viewportMeta.setAttribute("content", newContent);
14139
+ return () => {
14140
+ viewportMeta.setAttribute("content", originalContent);
14141
+ };
14142
+ }
14143
+ }
14144
+ }, []);
14145
+ return /* @__PURE__ */ jsx44(ThemeProvider, { className: "h-dvh bg-background text-foreground flex flex-col overscroll-none touch-manipulation", children: /* @__PURE__ */ jsx44(
14106
14146
  ChatProvider,
14107
14147
  {
14108
14148
  apiBasePath,
@@ -14152,7 +14192,13 @@ function DashboardLayout({
14152
14192
  }, [isEditorPage, editorState?.content, setEssayContext]);
14153
14193
  useDashboardKeyboard({
14154
14194
  basePath,
14155
- onToggleView: onToggleView ? () => onToggleView(currentPath, editorSlug) : void 0,
14195
+ onToggleView: onToggleView ? () => {
14196
+ if (isEditorPage && editorState?.status === "draft") {
14197
+ toast2.info("This essay is still a draft. Publish it to view the live page.");
14198
+ return;
14199
+ }
14200
+ onToggleView(currentPath, editorSlug);
14201
+ } : void 0,
14156
14202
  onToggleSettings: () => {
14157
14203
  if (currentPath.startsWith("/settings")) navigate("/");
14158
14204
  else navigate("/settings");