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.js CHANGED
@@ -7416,43 +7416,69 @@ function TiptapEditor({
7416
7416
  }
7417
7417
  }
7418
7418
  }, [editor, content]);
7419
- const savedSelectionRef = (0, import_react18.useRef)(null);
7420
7419
  const containerRef = (0, import_react18.useRef)(null);
7421
- const handleTouchStart = (0, import_react18.useCallback)(() => {
7422
- if (!editor) return;
7423
- const { from, to, empty } = editor.state.selection;
7424
- if (!empty) {
7425
- savedSelectionRef.current = { from, to };
7426
- }
7427
- }, [editor]);
7428
- const handleTouchEnd = (0, import_react18.useCallback)(() => {
7429
- if (!editor || !savedSelectionRef.current) return;
7430
- const { empty } = editor.state.selection;
7431
- if (empty && savedSelectionRef.current) {
7432
- const { from, to } = savedSelectionRef.current;
7433
- requestAnimationFrame(() => {
7434
- if (editor && !editor.isDestroyed) {
7435
- try {
7436
- const docSize = editor.state.doc.content.size;
7437
- if (from <= docSize && to <= docSize) {
7438
- editor.commands.setTextSelection({ from, to });
7439
- }
7440
- } catch {
7441
- }
7420
+ (0, import_react18.useEffect)(() => {
7421
+ if (!editor?.view) return;
7422
+ const editorDom = editor.view.dom;
7423
+ let swipeState = null;
7424
+ const findListItem = (element) => {
7425
+ while (element && element !== editorDom) {
7426
+ if (element.tagName === "LI") {
7427
+ return element;
7442
7428
  }
7443
- });
7444
- }
7445
- savedSelectionRef.current = null;
7429
+ element = element.parentElement;
7430
+ }
7431
+ return null;
7432
+ };
7433
+ const handleTouchStart = (e) => {
7434
+ const touch = e.touches[0];
7435
+ const target = e.target;
7436
+ const listItem = findListItem(target);
7437
+ swipeState = {
7438
+ startX: touch.clientX,
7439
+ startY: touch.clientY,
7440
+ startTime: Date.now(),
7441
+ handled: false,
7442
+ listItemElement: listItem
7443
+ };
7444
+ };
7445
+ const handleTouchMove = (e) => {
7446
+ if (!swipeState || swipeState.handled) return;
7447
+ if (!swipeState.listItemElement) return;
7448
+ const touch = e.touches[0];
7449
+ const deltaX = touch.clientX - swipeState.startX;
7450
+ const deltaY = touch.clientY - swipeState.startY;
7451
+ const elapsed = Date.now() - swipeState.startTime;
7452
+ const absX = Math.abs(deltaX);
7453
+ const absY = Math.abs(deltaY);
7454
+ const isHorizontalSwipe = absX > 30 && absX > absY * 1.2 && elapsed < 500;
7455
+ if (!isHorizontalSwipe) return;
7456
+ swipeState.handled = true;
7457
+ e.preventDefault();
7458
+ try {
7459
+ const pos = editor.view.posAtDOM(swipeState.listItemElement, 0);
7460
+ editor.commands.setTextSelection(pos);
7461
+ } catch {
7462
+ }
7463
+ if (deltaX > 0) {
7464
+ editor.chain().focus().sinkListItem("listItem").run();
7465
+ } else {
7466
+ editor.chain().focus().liftListItem("listItem").run();
7467
+ }
7468
+ };
7469
+ const handleTouchEnd = () => {
7470
+ swipeState = null;
7471
+ };
7472
+ editorDom.addEventListener("touchstart", handleTouchStart, { passive: true });
7473
+ editorDom.addEventListener("touchmove", handleTouchMove, { passive: false });
7474
+ editorDom.addEventListener("touchend", handleTouchEnd, { passive: true });
7475
+ return () => {
7476
+ editorDom.removeEventListener("touchstart", handleTouchStart);
7477
+ editorDom.removeEventListener("touchmove", handleTouchMove);
7478
+ editorDom.removeEventListener("touchend", handleTouchEnd);
7479
+ };
7446
7480
  }, [editor]);
7447
- return /* @__PURE__ */ (0, import_jsx_runtime25.jsx)(
7448
- "div",
7449
- {
7450
- ref: containerRef,
7451
- onTouchStart: handleTouchStart,
7452
- onTouchEnd: handleTouchEnd,
7453
- children: /* @__PURE__ */ (0, import_jsx_runtime25.jsx)(import_react19.EditorContent, { editor })
7454
- }
7455
- );
7481
+ return /* @__PURE__ */ (0, import_jsx_runtime25.jsx)("div", { ref: containerRef, children: /* @__PURE__ */ (0, import_jsx_runtime25.jsx)(import_react19.EditorContent, { editor }) });
7456
7482
  }
7457
7483
  var import_react18, import_react19, import_starter_kit, import_extension_placeholder, import_extension_link, import_extension_image, import_extension_strike, import_extension_underline, import_jsx_runtime25, PLACEHOLDER_STYLE_ID, DEFAULT_PROSE_CLASSES, StyledHeading, CustomStrike, CustomBulletList, CustomOrderedList, CustomCode, CustomBlockquote, CustomCodeBlock;
7458
7484
  var init_TiptapEditor = __esm({
@@ -14137,6 +14163,7 @@ function Toaster({ ...props }) {
14137
14163
  }
14138
14164
 
14139
14165
  // src/ui/dashboard.tsx
14166
+ var import_sonner3 = require("sonner");
14140
14167
  var import_jsx_runtime45 = require("react/jsx-runtime");
14141
14168
  var ChatPanel2 = (0, import_react35.lazy)(
14142
14169
  () => Promise.resolve().then(() => (init_ChatPanel(), ChatPanel_exports)).then((m) => ({ default: m.ChatPanel }))
@@ -14158,7 +14185,20 @@ function AutobloggerDashboard({
14158
14185
  }) {
14159
14186
  const resolvedChatApiPath = chatApiPath || `${apiBasePath}/ai/chat`;
14160
14187
  const resolvedHistoryApiPath = historyApiPath || `${apiBasePath}/chat/history`;
14161
- return /* @__PURE__ */ (0, import_jsx_runtime45.jsx)(ThemeProvider, { className: "h-dvh bg-background text-foreground flex flex-col overscroll-none", children: /* @__PURE__ */ (0, import_jsx_runtime45.jsx)(
14188
+ (0, import_react35.useEffect)(() => {
14189
+ const viewportMeta = document.querySelector('meta[name="viewport"]');
14190
+ if (viewportMeta) {
14191
+ const originalContent = viewportMeta.getAttribute("content") || "";
14192
+ if (!originalContent.includes("user-scalable")) {
14193
+ const newContent = originalContent + ", user-scalable=no, maximum-scale=1";
14194
+ viewportMeta.setAttribute("content", newContent);
14195
+ return () => {
14196
+ viewportMeta.setAttribute("content", originalContent);
14197
+ };
14198
+ }
14199
+ }
14200
+ }, []);
14201
+ return /* @__PURE__ */ (0, import_jsx_runtime45.jsx)(ThemeProvider, { className: "h-dvh bg-background text-foreground flex flex-col overscroll-none touch-manipulation", children: /* @__PURE__ */ (0, import_jsx_runtime45.jsx)(
14162
14202
  ChatProvider,
14163
14203
  {
14164
14204
  apiBasePath,
@@ -14208,7 +14248,13 @@ function DashboardLayout({
14208
14248
  }, [isEditorPage, editorState?.content, setEssayContext]);
14209
14249
  useDashboardKeyboard({
14210
14250
  basePath,
14211
- onToggleView: onToggleView ? () => onToggleView(currentPath, editorSlug) : void 0,
14251
+ onToggleView: onToggleView ? () => {
14252
+ if (isEditorPage && editorState?.status === "draft") {
14253
+ import_sonner3.toast.info("This essay is still a draft. Publish it to view the live page.");
14254
+ return;
14255
+ }
14256
+ onToggleView(currentPath, editorSlug);
14257
+ } : void 0,
14212
14258
  onToggleSettings: () => {
14213
14259
  if (currentPath.startsWith("/settings")) navigate("/");
14214
14260
  else navigate("/settings");