@kedataindo/docflow-core 0.0.85 → 0.0.86

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/ai/index.cjs CHANGED
@@ -23,6 +23,7 @@ __export(ai_exports, {
23
23
  CONTEXT_CHAR_CAP: () => CONTEXT_CHAR_CAP,
24
24
  LOCAL_STORAGE_KEY: () => LOCAL_STORAGE_KEY,
25
25
  buildAIPrompt: () => buildAIPrompt,
26
+ claudeProvider: () => claudeProvider,
26
27
  httpKeyStorage: () => httpKeyStorage,
27
28
  localStorageKeyStorage: () => localStorageKeyStorage,
28
29
  memoryKeyStorage: () => memoryKeyStorage,
@@ -295,11 +296,156 @@ function openaiCompatibleProvider(config) {
295
296
  }
296
297
  };
297
298
  }
299
+
300
+ // src/ai/claudeProvider.ts
301
+ var DEFAULT_BASE_URL = "https://api.anthropic.com";
302
+ var ANTHROPIC_VERSION = "2023-06-01";
303
+ var DEFAULT_MAX_TOKENS = 4096;
304
+ function authHeaders2(auth) {
305
+ switch (auth.type) {
306
+ case "bearer":
307
+ return { "x-api-key": auth.apiKey };
308
+ case "header":
309
+ return { [auth.name]: auth.value };
310
+ case "none":
311
+ return {};
312
+ }
313
+ }
314
+ function toError2(err) {
315
+ return err instanceof Error ? err : new Error(String(err));
316
+ }
317
+ function claudeProvider(config) {
318
+ const baseUrl = (config.baseUrl ?? DEFAULT_BASE_URL).replace(/\/+$/, "");
319
+ const maxTokens = config.maxTokens ?? DEFAULT_MAX_TOKENS;
320
+ return {
321
+ async *complete(req) {
322
+ const controller = new AbortController();
323
+ const onAbort = () => controller.abort();
324
+ const callerSignal = req.signal;
325
+ if (callerSignal) {
326
+ if (callerSignal.aborted) controller.abort();
327
+ else callerSignal.addEventListener("abort", onAbort, { once: true });
328
+ }
329
+ try {
330
+ const system = [config.systemPrompt, req.system].filter(Boolean).join("\n\n");
331
+ const body = {
332
+ model: config.model,
333
+ max_tokens: maxTokens,
334
+ messages: [{ role: "user", content: req.prompt }],
335
+ stream: true
336
+ };
337
+ if (system) body.system = system;
338
+ let res;
339
+ try {
340
+ res = await fetch(`${baseUrl}/v1/messages`, {
341
+ method: "POST",
342
+ headers: {
343
+ "Content-Type": "application/json",
344
+ "anthropic-version": ANTHROPIC_VERSION,
345
+ // Anthropic only allows browser calls with this explicit opt-in.
346
+ "anthropic-dangerous-direct-browser-access": "true",
347
+ ...authHeaders2(config.auth)
348
+ },
349
+ body: JSON.stringify(body),
350
+ signal: controller.signal
351
+ });
352
+ } catch (err) {
353
+ if (controller.signal.aborted) return;
354
+ yield { type: "error", error: toError2(err) };
355
+ return;
356
+ }
357
+ if (!res.ok) {
358
+ const detail = await res.text().catch(() => "");
359
+ yield {
360
+ type: "error",
361
+ error: new Error(
362
+ `Claude provider responded ${res.status}${detail ? `: ${detail.slice(0, 200)}` : ""}`
363
+ )
364
+ };
365
+ return;
366
+ }
367
+ if (!res.body) {
368
+ yield { type: "error", error: new Error("Claude provider response has no body") };
369
+ return;
370
+ }
371
+ const reader = res.body.getReader();
372
+ const decoder = new TextDecoder();
373
+ let buffer = "";
374
+ let sawDone = false;
375
+ let stopReason;
376
+ try {
377
+ for (; ; ) {
378
+ const { done, value } = await reader.read();
379
+ if (done) break;
380
+ buffer += decoder.decode(value, { stream: true });
381
+ let sep;
382
+ while ((sep = buffer.indexOf("\n\n")) >= 0) {
383
+ const block = buffer.slice(0, sep);
384
+ buffer = buffer.slice(sep + 2);
385
+ for (const line of block.split("\n")) {
386
+ if (!line.startsWith("data:")) continue;
387
+ const data = line.slice("data:".length).trim();
388
+ if (!data) continue;
389
+ let json;
390
+ try {
391
+ json = JSON.parse(data);
392
+ } catch {
393
+ continue;
394
+ }
395
+ switch (json.type) {
396
+ case "content_block_delta": {
397
+ const text = json.delta?.text;
398
+ if (text) yield { type: "delta", text };
399
+ break;
400
+ }
401
+ case "message_delta": {
402
+ if (json.delta?.stop_reason) stopReason = json.delta.stop_reason;
403
+ break;
404
+ }
405
+ case "message_stop": {
406
+ sawDone = true;
407
+ yield stopReason ? { type: "done", stopReason } : { type: "done" };
408
+ return;
409
+ }
410
+ case "error": {
411
+ yield {
412
+ type: "error",
413
+ error: new Error(
414
+ json.error?.message ? `Claude provider error: ${json.error.message}` : "Claude provider stream error"
415
+ )
416
+ };
417
+ return;
418
+ }
419
+ default:
420
+ break;
421
+ }
422
+ }
423
+ }
424
+ }
425
+ } catch (err) {
426
+ if (!controller.signal.aborted) {
427
+ yield { type: "error", error: toError2(err) };
428
+ return;
429
+ }
430
+ } finally {
431
+ reader.releaseLock();
432
+ }
433
+ if (!sawDone && !controller.signal.aborted) {
434
+ yield stopReason ? { type: "done", stopReason } : { type: "done" };
435
+ }
436
+ } finally {
437
+ callerSignal?.removeEventListener("abort", onAbort);
438
+ controller.abort();
439
+ }
440
+ }
441
+ };
442
+ }
298
443
  // Annotate the CommonJS export names for ESM import in node:
299
444
  0 && (module.exports = {
300
445
  CONTEXT_CHAR_CAP,
301
446
  LOCAL_STORAGE_KEY,
302
447
  buildAIPrompt,
448
+ claudeProvider,
303
449
  httpKeyStorage,
304
450
  localStorageKeyStorage,
305
451
  memoryKeyStorage,
@@ -1 +1 @@
1
- export { b as AIAction, c as AIActionRequest, d as AICompleteRequest, e as AIConfig, f as AIDraftCitation, g as AIDraftEvent, a as AIDraftFn, h as AIProvider, A as AIStreamFn, j as Auth, k as CONTEXT_CHAR_CAP, l as CslDate, m as CslItemData, n as CslName, H as HttpKeyStorageUrls, K as KeyStorage, L as LOCAL_STORAGE_KEY, O as OpenAICompatibleConfig, S as StreamEvent, p as buildAIPrompt, q as httpKeyStorage, r as localStorageKeyStorage, s as memoryKeyStorage, t as openaiCompatibleProvider, u as toAIStreamFn, v as trimContextAfter, w as trimContextBefore } from '../index-BsIFJXPk.cjs';
1
+ export { b as AIAction, c as AIActionRequest, d as AICompleteRequest, e as AIConfig, f as AIDraftCitation, g as AIDraftEvent, a as AIDraftFn, h as AIProvider, A as AIStreamFn, j as Auth, k as CONTEXT_CHAR_CAP, l as ClaudeConfig, m as CslDate, n as CslItemData, o as CslName, H as HttpKeyStorageUrls, K as KeyStorage, L as LOCAL_STORAGE_KEY, O as OpenAICompatibleConfig, S as StreamEvent, q as buildAIPrompt, r as claudeProvider, s as httpKeyStorage, t as localStorageKeyStorage, u as memoryKeyStorage, v as openaiCompatibleProvider, w as toAIStreamFn, x as trimContextAfter, y as trimContextBefore } from '../index-3B5ckTRa.cjs';
@@ -1 +1 @@
1
- export { b as AIAction, c as AIActionRequest, d as AICompleteRequest, e as AIConfig, f as AIDraftCitation, g as AIDraftEvent, a as AIDraftFn, h as AIProvider, A as AIStreamFn, j as Auth, k as CONTEXT_CHAR_CAP, l as CslDate, m as CslItemData, n as CslName, H as HttpKeyStorageUrls, K as KeyStorage, L as LOCAL_STORAGE_KEY, O as OpenAICompatibleConfig, S as StreamEvent, p as buildAIPrompt, q as httpKeyStorage, r as localStorageKeyStorage, s as memoryKeyStorage, t as openaiCompatibleProvider, u as toAIStreamFn, v as trimContextAfter, w as trimContextBefore } from '../index-BsIFJXPk.js';
1
+ export { b as AIAction, c as AIActionRequest, d as AICompleteRequest, e as AIConfig, f as AIDraftCitation, g as AIDraftEvent, a as AIDraftFn, h as AIProvider, A as AIStreamFn, j as Auth, k as CONTEXT_CHAR_CAP, l as ClaudeConfig, m as CslDate, n as CslItemData, o as CslName, H as HttpKeyStorageUrls, K as KeyStorage, L as LOCAL_STORAGE_KEY, O as OpenAICompatibleConfig, S as StreamEvent, q as buildAIPrompt, r as claudeProvider, s as httpKeyStorage, t as localStorageKeyStorage, u as memoryKeyStorage, v as openaiCompatibleProvider, w as toAIStreamFn, x as trimContextAfter, y as trimContextBefore } from '../index-3B5ckTRa.js';
package/dist/ai/index.js CHANGED
@@ -2,6 +2,7 @@ import {
2
2
  CONTEXT_CHAR_CAP,
3
3
  LOCAL_STORAGE_KEY,
4
4
  buildAIPrompt,
5
+ claudeProvider,
5
6
  httpKeyStorage,
6
7
  localStorageKeyStorage,
7
8
  memoryKeyStorage,
@@ -9,11 +10,12 @@ import {
9
10
  toAIStreamFn,
10
11
  trimContextAfter,
11
12
  trimContextBefore
12
- } from "../chunk-HMOWKFPE.js";
13
+ } from "../chunk-6RIBBYIP.js";
13
14
  export {
14
15
  CONTEXT_CHAR_CAP,
15
16
  LOCAL_STORAGE_KEY,
16
17
  buildAIPrompt,
18
+ claudeProvider,
17
19
  httpKeyStorage,
18
20
  localStorageKeyStorage,
19
21
  memoryKeyStorage,
@@ -261,6 +261,150 @@ function openaiCompatibleProvider(config) {
261
261
  };
262
262
  }
263
263
 
264
+ // src/ai/claudeProvider.ts
265
+ var DEFAULT_BASE_URL = "https://api.anthropic.com";
266
+ var ANTHROPIC_VERSION = "2023-06-01";
267
+ var DEFAULT_MAX_TOKENS = 4096;
268
+ function authHeaders2(auth) {
269
+ switch (auth.type) {
270
+ case "bearer":
271
+ return { "x-api-key": auth.apiKey };
272
+ case "header":
273
+ return { [auth.name]: auth.value };
274
+ case "none":
275
+ return {};
276
+ }
277
+ }
278
+ function toError2(err) {
279
+ return err instanceof Error ? err : new Error(String(err));
280
+ }
281
+ function claudeProvider(config) {
282
+ const baseUrl = (config.baseUrl ?? DEFAULT_BASE_URL).replace(/\/+$/, "");
283
+ const maxTokens = config.maxTokens ?? DEFAULT_MAX_TOKENS;
284
+ return {
285
+ async *complete(req) {
286
+ const controller = new AbortController();
287
+ const onAbort = () => controller.abort();
288
+ const callerSignal = req.signal;
289
+ if (callerSignal) {
290
+ if (callerSignal.aborted) controller.abort();
291
+ else callerSignal.addEventListener("abort", onAbort, { once: true });
292
+ }
293
+ try {
294
+ const system = [config.systemPrompt, req.system].filter(Boolean).join("\n\n");
295
+ const body = {
296
+ model: config.model,
297
+ max_tokens: maxTokens,
298
+ messages: [{ role: "user", content: req.prompt }],
299
+ stream: true
300
+ };
301
+ if (system) body.system = system;
302
+ let res;
303
+ try {
304
+ res = await fetch(`${baseUrl}/v1/messages`, {
305
+ method: "POST",
306
+ headers: {
307
+ "Content-Type": "application/json",
308
+ "anthropic-version": ANTHROPIC_VERSION,
309
+ // Anthropic only allows browser calls with this explicit opt-in.
310
+ "anthropic-dangerous-direct-browser-access": "true",
311
+ ...authHeaders2(config.auth)
312
+ },
313
+ body: JSON.stringify(body),
314
+ signal: controller.signal
315
+ });
316
+ } catch (err) {
317
+ if (controller.signal.aborted) return;
318
+ yield { type: "error", error: toError2(err) };
319
+ return;
320
+ }
321
+ if (!res.ok) {
322
+ const detail = await res.text().catch(() => "");
323
+ yield {
324
+ type: "error",
325
+ error: new Error(
326
+ `Claude provider responded ${res.status}${detail ? `: ${detail.slice(0, 200)}` : ""}`
327
+ )
328
+ };
329
+ return;
330
+ }
331
+ if (!res.body) {
332
+ yield { type: "error", error: new Error("Claude provider response has no body") };
333
+ return;
334
+ }
335
+ const reader = res.body.getReader();
336
+ const decoder = new TextDecoder();
337
+ let buffer = "";
338
+ let sawDone = false;
339
+ let stopReason;
340
+ try {
341
+ for (; ; ) {
342
+ const { done, value } = await reader.read();
343
+ if (done) break;
344
+ buffer += decoder.decode(value, { stream: true });
345
+ let sep;
346
+ while ((sep = buffer.indexOf("\n\n")) >= 0) {
347
+ const block = buffer.slice(0, sep);
348
+ buffer = buffer.slice(sep + 2);
349
+ for (const line of block.split("\n")) {
350
+ if (!line.startsWith("data:")) continue;
351
+ const data = line.slice("data:".length).trim();
352
+ if (!data) continue;
353
+ let json;
354
+ try {
355
+ json = JSON.parse(data);
356
+ } catch {
357
+ continue;
358
+ }
359
+ switch (json.type) {
360
+ case "content_block_delta": {
361
+ const text = json.delta?.text;
362
+ if (text) yield { type: "delta", text };
363
+ break;
364
+ }
365
+ case "message_delta": {
366
+ if (json.delta?.stop_reason) stopReason = json.delta.stop_reason;
367
+ break;
368
+ }
369
+ case "message_stop": {
370
+ sawDone = true;
371
+ yield stopReason ? { type: "done", stopReason } : { type: "done" };
372
+ return;
373
+ }
374
+ case "error": {
375
+ yield {
376
+ type: "error",
377
+ error: new Error(
378
+ json.error?.message ? `Claude provider error: ${json.error.message}` : "Claude provider stream error"
379
+ )
380
+ };
381
+ return;
382
+ }
383
+ default:
384
+ break;
385
+ }
386
+ }
387
+ }
388
+ }
389
+ } catch (err) {
390
+ if (!controller.signal.aborted) {
391
+ yield { type: "error", error: toError2(err) };
392
+ return;
393
+ }
394
+ } finally {
395
+ reader.releaseLock();
396
+ }
397
+ if (!sawDone && !controller.signal.aborted) {
398
+ yield stopReason ? { type: "done", stopReason } : { type: "done" };
399
+ }
400
+ } finally {
401
+ callerSignal?.removeEventListener("abort", onAbort);
402
+ controller.abort();
403
+ }
404
+ }
405
+ };
406
+ }
407
+
264
408
  export {
265
409
  CONTEXT_CHAR_CAP,
266
410
  trimContextBefore,
@@ -271,5 +415,6 @@ export {
271
415
  LOCAL_STORAGE_KEY,
272
416
  localStorageKeyStorage,
273
417
  httpKeyStorage,
274
- openaiCompatibleProvider
418
+ openaiCompatibleProvider,
419
+ claudeProvider
275
420
  };
@@ -310,4 +310,35 @@ interface OpenAICompatibleConfig {
310
310
  }
311
311
  declare function openaiCompatibleProvider(config: OpenAICompatibleConfig): AIProvider;
312
312
 
313
- export { type AIStreamFn as A, type CitationPort as C, type HttpKeyStorageUrls as H, type ImageUploadHandler as I, type KeyStorage as K, LOCAL_STORAGE_KEY as L, type OpenAICompatibleConfig as O, type StreamEvent as S, type AIDraftFn as a, type AIAction as b, type AIActionRequest as c, type AICompleteRequest as d, type AIConfig as e, type AIDraftCitation as f, type AIDraftEvent as g, type AIProvider as h, type AIProviderFactory as i, type Auth as j, CONTEXT_CHAR_CAP as k, type CslDate as l, type CslItemData as m, type CslName as n, type ImageUploadResult as o, buildAIPrompt as p, httpKeyStorage as q, localStorageKeyStorage as r, memoryKeyStorage as s, openaiCompatibleProvider as t, toAIStreamFn as u, trimContextAfter as v, trimContextBefore as w };
313
+ /**
314
+ * Native Anthropic Claude `AIProvider` (per-user BYOK — issue #118,
315
+ * `docs/plans/PER_USER_BYOK.md` §3.4).
316
+ *
317
+ * Anthropic's Messages API is not OpenAI-shaped: different endpoint
318
+ * (`/v1/messages`), different auth (`x-api-key`), a **required** `max_tokens`, a
319
+ * top-level `system` parameter (not a system message), and its own SSE event
320
+ * names. This provider maps all of that onto the same `AIProvider` contract, so
321
+ * hosts can swap it for `openaiCompatibleProvider` without changing call sites.
322
+ *
323
+ * Cancellation contract matches `openaiCompatibleProvider`:
324
+ * - a non-2xx response yields `{ type: 'error' }` (never throws out of the iterator);
325
+ * - an aborted `req.signal` ends the stream **silently**;
326
+ * - closing the iterator early aborts the in-flight `fetch` so no tokens are wasted.
327
+ */
328
+
329
+ interface ClaudeConfig {
330
+ /** Base URL of the Anthropic (or compatible) endpoint. Defaults to `https://api.anthropic.com`. */
331
+ baseUrl?: string;
332
+ auth: Auth;
333
+ model: string;
334
+ /**
335
+ * Required by the Messages API. Defaults to 4096 — omit it and every call
336
+ * would fail with a 400.
337
+ */
338
+ maxTokens?: number;
339
+ /** Prepended to every call's system prompt so hosts don't repeat it. */
340
+ systemPrompt?: string;
341
+ }
342
+ declare function claudeProvider(config: ClaudeConfig): AIProvider;
343
+
344
+ export { type AIStreamFn as A, type CitationPort as C, type HttpKeyStorageUrls as H, type ImageUploadHandler as I, type KeyStorage as K, LOCAL_STORAGE_KEY as L, type OpenAICompatibleConfig as O, type StreamEvent as S, type AIDraftFn as a, type AIAction as b, type AIActionRequest as c, type AICompleteRequest as d, type AIConfig as e, type AIDraftCitation as f, type AIDraftEvent as g, type AIProvider as h, type AIProviderFactory as i, type Auth as j, CONTEXT_CHAR_CAP as k, type ClaudeConfig as l, type CslDate as m, type CslItemData as n, type CslName as o, type ImageUploadResult as p, buildAIPrompt as q, claudeProvider as r, httpKeyStorage as s, localStorageKeyStorage as t, memoryKeyStorage as u, openaiCompatibleProvider as v, toAIStreamFn as w, trimContextAfter as x, trimContextBefore as y };
@@ -310,4 +310,35 @@ interface OpenAICompatibleConfig {
310
310
  }
311
311
  declare function openaiCompatibleProvider(config: OpenAICompatibleConfig): AIProvider;
312
312
 
313
- export { type AIStreamFn as A, type CitationPort as C, type HttpKeyStorageUrls as H, type ImageUploadHandler as I, type KeyStorage as K, LOCAL_STORAGE_KEY as L, type OpenAICompatibleConfig as O, type StreamEvent as S, type AIDraftFn as a, type AIAction as b, type AIActionRequest as c, type AICompleteRequest as d, type AIConfig as e, type AIDraftCitation as f, type AIDraftEvent as g, type AIProvider as h, type AIProviderFactory as i, type Auth as j, CONTEXT_CHAR_CAP as k, type CslDate as l, type CslItemData as m, type CslName as n, type ImageUploadResult as o, buildAIPrompt as p, httpKeyStorage as q, localStorageKeyStorage as r, memoryKeyStorage as s, openaiCompatibleProvider as t, toAIStreamFn as u, trimContextAfter as v, trimContextBefore as w };
313
+ /**
314
+ * Native Anthropic Claude `AIProvider` (per-user BYOK — issue #118,
315
+ * `docs/plans/PER_USER_BYOK.md` §3.4).
316
+ *
317
+ * Anthropic's Messages API is not OpenAI-shaped: different endpoint
318
+ * (`/v1/messages`), different auth (`x-api-key`), a **required** `max_tokens`, a
319
+ * top-level `system` parameter (not a system message), and its own SSE event
320
+ * names. This provider maps all of that onto the same `AIProvider` contract, so
321
+ * hosts can swap it for `openaiCompatibleProvider` without changing call sites.
322
+ *
323
+ * Cancellation contract matches `openaiCompatibleProvider`:
324
+ * - a non-2xx response yields `{ type: 'error' }` (never throws out of the iterator);
325
+ * - an aborted `req.signal` ends the stream **silently**;
326
+ * - closing the iterator early aborts the in-flight `fetch` so no tokens are wasted.
327
+ */
328
+
329
+ interface ClaudeConfig {
330
+ /** Base URL of the Anthropic (or compatible) endpoint. Defaults to `https://api.anthropic.com`. */
331
+ baseUrl?: string;
332
+ auth: Auth;
333
+ model: string;
334
+ /**
335
+ * Required by the Messages API. Defaults to 4096 — omit it and every call
336
+ * would fail with a 400.
337
+ */
338
+ maxTokens?: number;
339
+ /** Prepended to every call's system prompt so hosts don't repeat it. */
340
+ systemPrompt?: string;
341
+ }
342
+ declare function claudeProvider(config: ClaudeConfig): AIProvider;
343
+
344
+ export { type AIStreamFn as A, type CitationPort as C, type HttpKeyStorageUrls as H, type ImageUploadHandler as I, type KeyStorage as K, LOCAL_STORAGE_KEY as L, type OpenAICompatibleConfig as O, type StreamEvent as S, type AIDraftFn as a, type AIAction as b, type AIActionRequest as c, type AICompleteRequest as d, type AIConfig as e, type AIDraftCitation as f, type AIDraftEvent as g, type AIProvider as h, type AIProviderFactory as i, type Auth as j, CONTEXT_CHAR_CAP as k, type ClaudeConfig as l, type CslDate as m, type CslItemData as n, type CslName as o, type ImageUploadResult as p, buildAIPrompt as q, claudeProvider as r, httpKeyStorage as s, localStorageKeyStorage as t, memoryKeyStorage as u, openaiCompatibleProvider as v, toAIStreamFn as w, trimContextAfter as x, trimContextBefore as y };
package/dist/index.cjs CHANGED
@@ -32,6 +32,7 @@ var index_exports = {};
32
32
  __export(index_exports, {
33
33
  BlockAttributesExtension: () => BlockAttributesExtension,
34
34
  CONTEXT_CHAR_CAP: () => CONTEXT_CHAR_CAP,
35
+ DOCUMENT_MODES: () => DOCUMENT_MODES,
35
36
  EditorContextExtension: () => EditorContextExtension,
36
37
  FontSizeExtension: () => FontSizeExtension,
37
38
  LOCAL_STORAGE_KEY: () => LOCAL_STORAGE_KEY,
@@ -41,6 +42,7 @@ __export(index_exports, {
41
42
  SearchAndReplaceExtension: () => SearchAndReplaceExtension,
42
43
  SubdocumentProvider: () => SubdocumentProvider,
43
44
  buildAIPrompt: () => buildAIPrompt,
45
+ claudeProvider: () => claudeProvider,
44
46
  clearSearch: () => clearSearch,
45
47
  collaborationExtensions: () => collaborationExtensions,
46
48
  collectExtensions: () => collectExtensions,
@@ -787,13 +789,13 @@ function replaceAll(editor, replacement) {
787
789
  return s.matches.length;
788
790
  }
789
791
 
790
- // ../../node_modules/.pnpm/tiptap-pagination-plus@3.1.0_patch_hash=4857789ba5672a185fb96bdd854e03e0c6ec8ed26abfeea_16730b2b361cd3f71113c52459ed62fd/node_modules/tiptap-pagination-plus/dist/PaginationPlus.js
792
+ // ../../node_modules/.pnpm/tiptap-pagination-plus@3.1.0_patch_hash=00858351959cd6e40e43520c066de1f40e312b64dcfd6be_bddb103a385fcb63b7133ac6ead3d2c8/node_modules/tiptap-pagination-plus/dist/PaginationPlus.js
791
793
  var import_core5 = require("@tiptap/core");
792
794
  var import_state4 = require("@tiptap/pm/state");
793
795
  var import_transform = require("@tiptap/pm/transform");
794
796
  var import_view3 = require("@tiptap/pm/view");
795
797
 
796
- // ../../node_modules/.pnpm/tiptap-pagination-plus@3.1.0_patch_hash=4857789ba5672a185fb96bdd854e03e0c6ec8ed26abfeea_16730b2b361cd3f71113c52459ed62fd/node_modules/tiptap-pagination-plus/dist/utils.js
798
+ // ../../node_modules/.pnpm/tiptap-pagination-plus@3.1.0_patch_hash=00858351959cd6e40e43520c066de1f40e312b64dcfd6be_bddb103a385fcb63b7133ac6ead3d2c8/node_modules/tiptap-pagination-plus/dist/utils.js
797
799
  var updateCssVariables = (targetNode, config) => {
798
800
  const cssVariables = {
799
801
  "rm-page-height": `${config.pageHeight}px`,
@@ -967,7 +969,7 @@ var footerClickEvent = (pageNumber, onFooterClick) => {
967
969
  };
968
970
  };
969
971
 
970
- // ../../node_modules/.pnpm/tiptap-pagination-plus@3.1.0_patch_hash=4857789ba5672a185fb96bdd854e03e0c6ec8ed26abfeea_16730b2b361cd3f71113c52459ed62fd/node_modules/tiptap-pagination-plus/dist/PaginationPlus.js
972
+ // ../../node_modules/.pnpm/tiptap-pagination-plus@3.1.0_patch_hash=00858351959cd6e40e43520c066de1f40e312b64dcfd6be_bddb103a385fcb63b7133ac6ead3d2c8/node_modules/tiptap-pagination-plus/dist/PaginationPlus.js
971
973
  var page_count_meta_key = "PAGE_COUNT_META_KEY";
972
974
  var key = new import_state4.PluginKey("brDecoration");
973
975
  function buildDecorations(doc) {
@@ -1474,12 +1476,6 @@ var calculatePageCount = (view, pageOptions, headerHeight = 0, footerHeight = 0)
1474
1476
  const lastPageGap = lastElementRect.bottom - lastPageBreakRect.bottom;
1475
1477
  if (lastPageGap > 0) {
1476
1478
  const addPage = Math.ceil(lastPageGap / pageContentAreaHeight);
1477
- if (lastElementRect.height > pageContentAreaHeight) {
1478
- const isSplittableTable = (lastElementOfEditor === null || lastElementOfEditor === void 0 ? void 0 : lastElementOfEditor.tagName) === "TABLE" && lastElementOfEditor.hasAttribute("data-tps-splittable");
1479
- if (!isSplittableTable) {
1480
- return currentPageCount;
1481
- }
1482
- }
1483
1479
  const prev = pageGapTracker.get(editorDom);
1484
1480
  if (prev && prev.pages < currentPageCount && lastPageGap > prev.gap - 2) {
1485
1481
  return currentPageCount;
@@ -1630,7 +1626,7 @@ function createDecoration(pageOptions, headerHeightMap, footerHeightMap) {
1630
1626
  return [pageWidget, firstHeaderWidget];
1631
1627
  }
1632
1628
 
1633
- // ../../node_modules/.pnpm/tiptap-pagination-plus@3.1.0_patch_hash=4857789ba5672a185fb96bdd854e03e0c6ec8ed26abfeea_16730b2b361cd3f71113c52459ed62fd/node_modules/tiptap-pagination-plus/dist/constants.js
1629
+ // ../../node_modules/.pnpm/tiptap-pagination-plus@3.1.0_patch_hash=00858351959cd6e40e43520c066de1f40e312b64dcfd6be_bddb103a385fcb63b7133ac6ead3d2c8/node_modules/tiptap-pagination-plus/dist/constants.js
1634
1630
  var A4_PAGE_SIZE = getPageSize(1123, 794, 95, 95, 76, 76);
1635
1631
  var A3_PAGE_SIZE = getPageSize(1591, 1123, 95, 95, 76, 76);
1636
1632
  var A5_PAGE_SIZE = getPageSize(794, 419, 76, 76, 57, 57);
@@ -2303,6 +2299,9 @@ var FontSizeExtension = import_core7.Extension.create({
2303
2299
  }
2304
2300
  });
2305
2301
 
2302
+ // src/modes.ts
2303
+ var DOCUMENT_MODES = ["editing", "suggesting", "viewing"];
2304
+
2306
2305
  // src/SubdocumentProvider.ts
2307
2306
  var import_awareness2 = require("y-protocols/awareness");
2308
2307
  var import_y_websocket2 = require("y-websocket");
@@ -2672,10 +2671,155 @@ function openaiCompatibleProvider(config) {
2672
2671
  }
2673
2672
  };
2674
2673
  }
2674
+
2675
+ // src/ai/claudeProvider.ts
2676
+ var DEFAULT_BASE_URL = "https://api.anthropic.com";
2677
+ var ANTHROPIC_VERSION = "2023-06-01";
2678
+ var DEFAULT_MAX_TOKENS = 4096;
2679
+ function authHeaders2(auth) {
2680
+ switch (auth.type) {
2681
+ case "bearer":
2682
+ return { "x-api-key": auth.apiKey };
2683
+ case "header":
2684
+ return { [auth.name]: auth.value };
2685
+ case "none":
2686
+ return {};
2687
+ }
2688
+ }
2689
+ function toError2(err) {
2690
+ return err instanceof Error ? err : new Error(String(err));
2691
+ }
2692
+ function claudeProvider(config) {
2693
+ const baseUrl = (config.baseUrl ?? DEFAULT_BASE_URL).replace(/\/+$/, "");
2694
+ const maxTokens = config.maxTokens ?? DEFAULT_MAX_TOKENS;
2695
+ return {
2696
+ async *complete(req) {
2697
+ const controller = new AbortController();
2698
+ const onAbort = () => controller.abort();
2699
+ const callerSignal = req.signal;
2700
+ if (callerSignal) {
2701
+ if (callerSignal.aborted) controller.abort();
2702
+ else callerSignal.addEventListener("abort", onAbort, { once: true });
2703
+ }
2704
+ try {
2705
+ const system = [config.systemPrompt, req.system].filter(Boolean).join("\n\n");
2706
+ const body = {
2707
+ model: config.model,
2708
+ max_tokens: maxTokens,
2709
+ messages: [{ role: "user", content: req.prompt }],
2710
+ stream: true
2711
+ };
2712
+ if (system) body.system = system;
2713
+ let res;
2714
+ try {
2715
+ res = await fetch(`${baseUrl}/v1/messages`, {
2716
+ method: "POST",
2717
+ headers: {
2718
+ "Content-Type": "application/json",
2719
+ "anthropic-version": ANTHROPIC_VERSION,
2720
+ // Anthropic only allows browser calls with this explicit opt-in.
2721
+ "anthropic-dangerous-direct-browser-access": "true",
2722
+ ...authHeaders2(config.auth)
2723
+ },
2724
+ body: JSON.stringify(body),
2725
+ signal: controller.signal
2726
+ });
2727
+ } catch (err) {
2728
+ if (controller.signal.aborted) return;
2729
+ yield { type: "error", error: toError2(err) };
2730
+ return;
2731
+ }
2732
+ if (!res.ok) {
2733
+ const detail = await res.text().catch(() => "");
2734
+ yield {
2735
+ type: "error",
2736
+ error: new Error(
2737
+ `Claude provider responded ${res.status}${detail ? `: ${detail.slice(0, 200)}` : ""}`
2738
+ )
2739
+ };
2740
+ return;
2741
+ }
2742
+ if (!res.body) {
2743
+ yield { type: "error", error: new Error("Claude provider response has no body") };
2744
+ return;
2745
+ }
2746
+ const reader = res.body.getReader();
2747
+ const decoder = new TextDecoder();
2748
+ let buffer = "";
2749
+ let sawDone = false;
2750
+ let stopReason;
2751
+ try {
2752
+ for (; ; ) {
2753
+ const { done, value } = await reader.read();
2754
+ if (done) break;
2755
+ buffer += decoder.decode(value, { stream: true });
2756
+ let sep;
2757
+ while ((sep = buffer.indexOf("\n\n")) >= 0) {
2758
+ const block = buffer.slice(0, sep);
2759
+ buffer = buffer.slice(sep + 2);
2760
+ for (const line of block.split("\n")) {
2761
+ if (!line.startsWith("data:")) continue;
2762
+ const data = line.slice("data:".length).trim();
2763
+ if (!data) continue;
2764
+ let json;
2765
+ try {
2766
+ json = JSON.parse(data);
2767
+ } catch {
2768
+ continue;
2769
+ }
2770
+ switch (json.type) {
2771
+ case "content_block_delta": {
2772
+ const text = json.delta?.text;
2773
+ if (text) yield { type: "delta", text };
2774
+ break;
2775
+ }
2776
+ case "message_delta": {
2777
+ if (json.delta?.stop_reason) stopReason = json.delta.stop_reason;
2778
+ break;
2779
+ }
2780
+ case "message_stop": {
2781
+ sawDone = true;
2782
+ yield stopReason ? { type: "done", stopReason } : { type: "done" };
2783
+ return;
2784
+ }
2785
+ case "error": {
2786
+ yield {
2787
+ type: "error",
2788
+ error: new Error(
2789
+ json.error?.message ? `Claude provider error: ${json.error.message}` : "Claude provider stream error"
2790
+ )
2791
+ };
2792
+ return;
2793
+ }
2794
+ default:
2795
+ break;
2796
+ }
2797
+ }
2798
+ }
2799
+ }
2800
+ } catch (err) {
2801
+ if (!controller.signal.aborted) {
2802
+ yield { type: "error", error: toError2(err) };
2803
+ return;
2804
+ }
2805
+ } finally {
2806
+ reader.releaseLock();
2807
+ }
2808
+ if (!sawDone && !controller.signal.aborted) {
2809
+ yield stopReason ? { type: "done", stopReason } : { type: "done" };
2810
+ }
2811
+ } finally {
2812
+ callerSignal?.removeEventListener("abort", onAbort);
2813
+ controller.abort();
2814
+ }
2815
+ }
2816
+ };
2817
+ }
2675
2818
  // Annotate the CommonJS export names for ESM import in node:
2676
2819
  0 && (module.exports = {
2677
2820
  BlockAttributesExtension,
2678
2821
  CONTEXT_CHAR_CAP,
2822
+ DOCUMENT_MODES,
2679
2823
  EditorContextExtension,
2680
2824
  FontSizeExtension,
2681
2825
  LOCAL_STORAGE_KEY,
@@ -2685,6 +2829,7 @@ function openaiCompatibleProvider(config) {
2685
2829
  SearchAndReplaceExtension,
2686
2830
  SubdocumentProvider,
2687
2831
  buildAIPrompt,
2832
+ claudeProvider,
2688
2833
  clearSearch,
2689
2834
  collaborationExtensions,
2690
2835
  collectExtensions,
package/dist/index.d.cts CHANGED
@@ -4,8 +4,8 @@ import { IndexeddbPersistence } from 'y-indexeddb';
4
4
  import { WebrtcProvider } from 'y-webrtc';
5
5
  import { WebsocketProvider } from 'y-websocket';
6
6
  import * as Y from 'yjs';
7
- import { I as ImageUploadHandler, C as CitationPort, A as AIStreamFn, a as AIDraftFn } from './index-BsIFJXPk.cjs';
8
- export { b as AIAction, c as AIActionRequest, d as AICompleteRequest, e as AIConfig, f as AIDraftCitation, g as AIDraftEvent, h as AIProvider, i as AIProviderFactory, j as Auth, k as CONTEXT_CHAR_CAP, l as CslDate, m as CslItemData, n as CslName, H as HttpKeyStorageUrls, o as ImageUploadResult, K as KeyStorage, L as LOCAL_STORAGE_KEY, O as OpenAICompatibleConfig, S as StreamEvent, p as buildAIPrompt, q as httpKeyStorage, r as localStorageKeyStorage, s as memoryKeyStorage, t as openaiCompatibleProvider, u as toAIStreamFn, v as trimContextAfter, w as trimContextBefore } from './index-BsIFJXPk.cjs';
7
+ import { I as ImageUploadHandler, C as CitationPort, A as AIStreamFn, a as AIDraftFn } from './index-3B5ckTRa.cjs';
8
+ export { b as AIAction, c as AIActionRequest, d as AICompleteRequest, e as AIConfig, f as AIDraftCitation, g as AIDraftEvent, h as AIProvider, i as AIProviderFactory, j as Auth, k as CONTEXT_CHAR_CAP, l as ClaudeConfig, m as CslDate, n as CslItemData, o as CslName, H as HttpKeyStorageUrls, p as ImageUploadResult, K as KeyStorage, L as LOCAL_STORAGE_KEY, O as OpenAICompatibleConfig, S as StreamEvent, q as buildAIPrompt, r as claudeProvider, s as httpKeyStorage, t as localStorageKeyStorage, u as memoryKeyStorage, v as openaiCompatibleProvider, w as toAIStreamFn, x as trimContextAfter, y as trimContextBefore } from './index-3B5ckTRa.cjs';
9
9
  import { PaginationPlusOptions } from 'tiptap-pagination-plus';
10
10
  export { PAGE_SIZES, PageSize, PaginationPlus, PaginationPlusOptions } from 'tiptap-pagination-plus';
11
11
  import { PluginKey } from '@tiptap/pm/state';
@@ -335,6 +335,21 @@ declare function replaceCurrent(editor: Editor, replacement: string): boolean;
335
335
  /** Replace every match in one transaction (applied back-to-front). */
336
336
  declare function replaceAll(editor: Editor, replacement: string): number;
337
337
 
338
+ /**
339
+ * Document editing modes (issues #27 / #28 — suggesting mode + track changes).
340
+ *
341
+ * - `editing` — normal editing (default).
342
+ * - `suggesting` — edits are recorded as suggestion marks instead of applied.
343
+ * - `viewing` — read-only; the editor is not editable.
344
+ *
345
+ * Hosts own *authorisation* (who may suggest / accept). The library only
346
+ * provides the mode behaviour and the commands; see
347
+ * `docs/plans/suggesting-mode-and-track-changes.md`.
348
+ */
349
+ type DocumentMode = 'editing' | 'suggesting' | 'viewing';
350
+ /** Every document mode, in menu order. */
351
+ declare const DOCUMENT_MODES: readonly DocumentMode[];
352
+
338
353
  interface SubdocState {
339
354
  id: string;
340
355
  doc: Y.Doc;
@@ -397,4 +412,4 @@ declare class SubdocumentProvider {
397
412
  destroy(): void;
398
413
  }
399
414
 
400
- export { AIDraftFn, AIStreamFn, type AwarenessState, BlockAttributesExtension, CitationPort, type ClipboardSource, type CollaborationOptions, type CollaborationSetup, type DocsEditor, type DocsEditorPlugin, EditorContextExtension, type EditorContextOptions, type EditorOptions, FontSizeExtension, ImageUploadHandler, type MonitorMetric, PerformanceMonitor, type PerformanceMonitorOptions, SearchAndReplaceExtension, type SearchMatch, type SearchState, type SlashCommand, type SubdocState, SubdocumentProvider, type SubdocumentProviderOptions, type ToolbarItem, clearSearch, collaborationExtensions, collectExtensions, createActionMap, createCollaboration, createEditor, createPerformanceMonitor, definePlugin, detectClipboardSource, findMatches, getSearchState, normalizeClipboardHTML, replaceAll, replaceCurrent, resolveAction, sanitizeInlineHTML, sanitizePastedHTML, searchAndReplaceKey, searchNext, searchPrev, setSearchQuery };
415
+ export { AIDraftFn, AIStreamFn, type AwarenessState, BlockAttributesExtension, CitationPort, type ClipboardSource, type CollaborationOptions, type CollaborationSetup, DOCUMENT_MODES, type DocsEditor, type DocsEditorPlugin, type DocumentMode, EditorContextExtension, type EditorContextOptions, type EditorOptions, FontSizeExtension, ImageUploadHandler, type MonitorMetric, PerformanceMonitor, type PerformanceMonitorOptions, SearchAndReplaceExtension, type SearchMatch, type SearchState, type SlashCommand, type SubdocState, SubdocumentProvider, type SubdocumentProviderOptions, type ToolbarItem, clearSearch, collaborationExtensions, collectExtensions, createActionMap, createCollaboration, createEditor, createPerformanceMonitor, definePlugin, detectClipboardSource, findMatches, getSearchState, normalizeClipboardHTML, replaceAll, replaceCurrent, resolveAction, sanitizeInlineHTML, sanitizePastedHTML, searchAndReplaceKey, searchNext, searchPrev, setSearchQuery };
package/dist/index.d.ts CHANGED
@@ -4,8 +4,8 @@ import { IndexeddbPersistence } from 'y-indexeddb';
4
4
  import { WebrtcProvider } from 'y-webrtc';
5
5
  import { WebsocketProvider } from 'y-websocket';
6
6
  import * as Y from 'yjs';
7
- import { I as ImageUploadHandler, C as CitationPort, A as AIStreamFn, a as AIDraftFn } from './index-BsIFJXPk.js';
8
- export { b as AIAction, c as AIActionRequest, d as AICompleteRequest, e as AIConfig, f as AIDraftCitation, g as AIDraftEvent, h as AIProvider, i as AIProviderFactory, j as Auth, k as CONTEXT_CHAR_CAP, l as CslDate, m as CslItemData, n as CslName, H as HttpKeyStorageUrls, o as ImageUploadResult, K as KeyStorage, L as LOCAL_STORAGE_KEY, O as OpenAICompatibleConfig, S as StreamEvent, p as buildAIPrompt, q as httpKeyStorage, r as localStorageKeyStorage, s as memoryKeyStorage, t as openaiCompatibleProvider, u as toAIStreamFn, v as trimContextAfter, w as trimContextBefore } from './index-BsIFJXPk.js';
7
+ import { I as ImageUploadHandler, C as CitationPort, A as AIStreamFn, a as AIDraftFn } from './index-3B5ckTRa.js';
8
+ export { b as AIAction, c as AIActionRequest, d as AICompleteRequest, e as AIConfig, f as AIDraftCitation, g as AIDraftEvent, h as AIProvider, i as AIProviderFactory, j as Auth, k as CONTEXT_CHAR_CAP, l as ClaudeConfig, m as CslDate, n as CslItemData, o as CslName, H as HttpKeyStorageUrls, p as ImageUploadResult, K as KeyStorage, L as LOCAL_STORAGE_KEY, O as OpenAICompatibleConfig, S as StreamEvent, q as buildAIPrompt, r as claudeProvider, s as httpKeyStorage, t as localStorageKeyStorage, u as memoryKeyStorage, v as openaiCompatibleProvider, w as toAIStreamFn, x as trimContextAfter, y as trimContextBefore } from './index-3B5ckTRa.js';
9
9
  import { PaginationPlusOptions } from 'tiptap-pagination-plus';
10
10
  export { PAGE_SIZES, PageSize, PaginationPlus, PaginationPlusOptions } from 'tiptap-pagination-plus';
11
11
  import { PluginKey } from '@tiptap/pm/state';
@@ -335,6 +335,21 @@ declare function replaceCurrent(editor: Editor, replacement: string): boolean;
335
335
  /** Replace every match in one transaction (applied back-to-front). */
336
336
  declare function replaceAll(editor: Editor, replacement: string): number;
337
337
 
338
+ /**
339
+ * Document editing modes (issues #27 / #28 — suggesting mode + track changes).
340
+ *
341
+ * - `editing` — normal editing (default).
342
+ * - `suggesting` — edits are recorded as suggestion marks instead of applied.
343
+ * - `viewing` — read-only; the editor is not editable.
344
+ *
345
+ * Hosts own *authorisation* (who may suggest / accept). The library only
346
+ * provides the mode behaviour and the commands; see
347
+ * `docs/plans/suggesting-mode-and-track-changes.md`.
348
+ */
349
+ type DocumentMode = 'editing' | 'suggesting' | 'viewing';
350
+ /** Every document mode, in menu order. */
351
+ declare const DOCUMENT_MODES: readonly DocumentMode[];
352
+
338
353
  interface SubdocState {
339
354
  id: string;
340
355
  doc: Y.Doc;
@@ -397,4 +412,4 @@ declare class SubdocumentProvider {
397
412
  destroy(): void;
398
413
  }
399
414
 
400
- export { AIDraftFn, AIStreamFn, type AwarenessState, BlockAttributesExtension, CitationPort, type ClipboardSource, type CollaborationOptions, type CollaborationSetup, type DocsEditor, type DocsEditorPlugin, EditorContextExtension, type EditorContextOptions, type EditorOptions, FontSizeExtension, ImageUploadHandler, type MonitorMetric, PerformanceMonitor, type PerformanceMonitorOptions, SearchAndReplaceExtension, type SearchMatch, type SearchState, type SlashCommand, type SubdocState, SubdocumentProvider, type SubdocumentProviderOptions, type ToolbarItem, clearSearch, collaborationExtensions, collectExtensions, createActionMap, createCollaboration, createEditor, createPerformanceMonitor, definePlugin, detectClipboardSource, findMatches, getSearchState, normalizeClipboardHTML, replaceAll, replaceCurrent, resolveAction, sanitizeInlineHTML, sanitizePastedHTML, searchAndReplaceKey, searchNext, searchPrev, setSearchQuery };
415
+ export { AIDraftFn, AIStreamFn, type AwarenessState, BlockAttributesExtension, CitationPort, type ClipboardSource, type CollaborationOptions, type CollaborationSetup, DOCUMENT_MODES, type DocsEditor, type DocsEditorPlugin, type DocumentMode, EditorContextExtension, type EditorContextOptions, type EditorOptions, FontSizeExtension, ImageUploadHandler, type MonitorMetric, PerformanceMonitor, type PerformanceMonitorOptions, SearchAndReplaceExtension, type SearchMatch, type SearchState, type SlashCommand, type SubdocState, SubdocumentProvider, type SubdocumentProviderOptions, type ToolbarItem, clearSearch, collaborationExtensions, collectExtensions, createActionMap, createCollaboration, createEditor, createPerformanceMonitor, definePlugin, detectClipboardSource, findMatches, getSearchState, normalizeClipboardHTML, replaceAll, replaceCurrent, resolveAction, sanitizeInlineHTML, sanitizePastedHTML, searchAndReplaceKey, searchNext, searchPrev, setSearchQuery };
package/dist/index.js CHANGED
@@ -2,6 +2,7 @@ import {
2
2
  CONTEXT_CHAR_CAP,
3
3
  LOCAL_STORAGE_KEY,
4
4
  buildAIPrompt,
5
+ claudeProvider,
5
6
  httpKeyStorage,
6
7
  localStorageKeyStorage,
7
8
  memoryKeyStorage,
@@ -9,7 +10,7 @@ import {
9
10
  toAIStreamFn,
10
11
  trimContextAfter,
11
12
  trimContextBefore
12
- } from "./chunk-HMOWKFPE.js";
13
+ } from "./chunk-6RIBBYIP.js";
13
14
 
14
15
  // src/Editor.ts
15
16
  import { Editor as TiptapEditor } from "@tiptap/core";
@@ -726,13 +727,13 @@ function replaceAll(editor, replacement) {
726
727
  return s.matches.length;
727
728
  }
728
729
 
729
- // ../../node_modules/.pnpm/tiptap-pagination-plus@3.1.0_patch_hash=4857789ba5672a185fb96bdd854e03e0c6ec8ed26abfeea_16730b2b361cd3f71113c52459ed62fd/node_modules/tiptap-pagination-plus/dist/PaginationPlus.js
730
+ // ../../node_modules/.pnpm/tiptap-pagination-plus@3.1.0_patch_hash=00858351959cd6e40e43520c066de1f40e312b64dcfd6be_bddb103a385fcb63b7133ac6ead3d2c8/node_modules/tiptap-pagination-plus/dist/PaginationPlus.js
730
731
  import { Extension as Extension5 } from "@tiptap/core";
731
732
  import { Plugin as Plugin4, PluginKey as PluginKey4 } from "@tiptap/pm/state";
732
733
  import { ReplaceStep, ReplaceAroundStep, AddMarkStep, RemoveMarkStep, RemoveNodeMarkStep, AttrStep } from "@tiptap/pm/transform";
733
734
  import { Decoration as Decoration3, DecorationSet as DecorationSet3 } from "@tiptap/pm/view";
734
735
 
735
- // ../../node_modules/.pnpm/tiptap-pagination-plus@3.1.0_patch_hash=4857789ba5672a185fb96bdd854e03e0c6ec8ed26abfeea_16730b2b361cd3f71113c52459ed62fd/node_modules/tiptap-pagination-plus/dist/utils.js
736
+ // ../../node_modules/.pnpm/tiptap-pagination-plus@3.1.0_patch_hash=00858351959cd6e40e43520c066de1f40e312b64dcfd6be_bddb103a385fcb63b7133ac6ead3d2c8/node_modules/tiptap-pagination-plus/dist/utils.js
736
737
  var updateCssVariables = (targetNode, config) => {
737
738
  const cssVariables = {
738
739
  "rm-page-height": `${config.pageHeight}px`,
@@ -906,7 +907,7 @@ var footerClickEvent = (pageNumber, onFooterClick) => {
906
907
  };
907
908
  };
908
909
 
909
- // ../../node_modules/.pnpm/tiptap-pagination-plus@3.1.0_patch_hash=4857789ba5672a185fb96bdd854e03e0c6ec8ed26abfeea_16730b2b361cd3f71113c52459ed62fd/node_modules/tiptap-pagination-plus/dist/PaginationPlus.js
910
+ // ../../node_modules/.pnpm/tiptap-pagination-plus@3.1.0_patch_hash=00858351959cd6e40e43520c066de1f40e312b64dcfd6be_bddb103a385fcb63b7133ac6ead3d2c8/node_modules/tiptap-pagination-plus/dist/PaginationPlus.js
910
911
  var page_count_meta_key = "PAGE_COUNT_META_KEY";
911
912
  var key = new PluginKey4("brDecoration");
912
913
  function buildDecorations(doc) {
@@ -1413,12 +1414,6 @@ var calculatePageCount = (view, pageOptions, headerHeight = 0, footerHeight = 0)
1413
1414
  const lastPageGap = lastElementRect.bottom - lastPageBreakRect.bottom;
1414
1415
  if (lastPageGap > 0) {
1415
1416
  const addPage = Math.ceil(lastPageGap / pageContentAreaHeight);
1416
- if (lastElementRect.height > pageContentAreaHeight) {
1417
- const isSplittableTable = (lastElementOfEditor === null || lastElementOfEditor === void 0 ? void 0 : lastElementOfEditor.tagName) === "TABLE" && lastElementOfEditor.hasAttribute("data-tps-splittable");
1418
- if (!isSplittableTable) {
1419
- return currentPageCount;
1420
- }
1421
- }
1422
1417
  const prev = pageGapTracker.get(editorDom);
1423
1418
  if (prev && prev.pages < currentPageCount && lastPageGap > prev.gap - 2) {
1424
1419
  return currentPageCount;
@@ -1569,7 +1564,7 @@ function createDecoration(pageOptions, headerHeightMap, footerHeightMap) {
1569
1564
  return [pageWidget, firstHeaderWidget];
1570
1565
  }
1571
1566
 
1572
- // ../../node_modules/.pnpm/tiptap-pagination-plus@3.1.0_patch_hash=4857789ba5672a185fb96bdd854e03e0c6ec8ed26abfeea_16730b2b361cd3f71113c52459ed62fd/node_modules/tiptap-pagination-plus/dist/constants.js
1567
+ // ../../node_modules/.pnpm/tiptap-pagination-plus@3.1.0_patch_hash=00858351959cd6e40e43520c066de1f40e312b64dcfd6be_bddb103a385fcb63b7133ac6ead3d2c8/node_modules/tiptap-pagination-plus/dist/constants.js
1573
1568
  var A4_PAGE_SIZE = getPageSize(1123, 794, 95, 95, 76, 76);
1574
1569
  var A3_PAGE_SIZE = getPageSize(1591, 1123, 95, 95, 76, 76);
1575
1570
  var A5_PAGE_SIZE = getPageSize(794, 419, 76, 76, 57, 57);
@@ -2242,6 +2237,9 @@ var FontSizeExtension = Extension6.create({
2242
2237
  }
2243
2238
  });
2244
2239
 
2240
+ // src/modes.ts
2241
+ var DOCUMENT_MODES = ["editing", "suggesting", "viewing"];
2242
+
2245
2243
  // src/SubdocumentProvider.ts
2246
2244
  import { Awareness as AwarenessClass } from "y-protocols/awareness";
2247
2245
  import { WebsocketProvider as WebsocketProvider2 } from "y-websocket";
@@ -2351,6 +2349,7 @@ var SubdocumentProvider = class {
2351
2349
  export {
2352
2350
  BlockAttributesExtension,
2353
2351
  CONTEXT_CHAR_CAP,
2352
+ DOCUMENT_MODES,
2354
2353
  EditorContextExtension,
2355
2354
  FontSizeExtension,
2356
2355
  LOCAL_STORAGE_KEY,
@@ -2360,6 +2359,7 @@ export {
2360
2359
  SearchAndReplaceExtension,
2361
2360
  SubdocumentProvider,
2362
2361
  buildAIPrompt,
2362
+ claudeProvider,
2363
2363
  clearSearch,
2364
2364
  collaborationExtensions,
2365
2365
  collectExtensions,
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@kedataindo/docflow-core",
3
3
  "license": "Apache-2.0",
4
- "version": "0.0.85",
4
+ "version": "0.0.86",
5
5
  "type": "module",
6
6
  "main": "./dist/index.js",
7
7
  "module": "./dist/index.js",