@fileverse-dev/ddoc 4.1.9 → 4.1.11-patch-1

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.d.ts CHANGED
@@ -5,6 +5,8 @@ export { DdocExportModal } from './package/components/export-modal';
5
5
  export { useHeadlessEditor } from './package/hooks/use-headless-editor';
6
6
  export { useExportHeadlessEditorContent } from './package/hooks/use-export-headless-editor-content';
7
7
  export { mergeTabAwareYjsUpdates } from './package/components/tabs/utils/tab-utils';
8
+ export { validateCustomCss, sanitizeCustomCss, } from './package/utils/sanitize-css';
9
+ export type { CssDiagnostic, CssValidationResult, } from './package/utils/sanitize-css';
8
10
  export { buildVersionDiffSnapshot } from './package/components/tabs/utils/version-diff-snapshot';
9
11
  export type { DdocExportModalProps, ExportFormatOption, ExportTabOption, } from './package/components/export-modal';
10
12
  export type { VersionTabSnapshot } from './package/components/tabs/utils/version-diff-snapshot';
package/dist/index.es.js CHANGED
@@ -1,12 +1,14 @@
1
- import { D as e, a as o, E as d, P as t, d as r, h as i, m as n, c as E, u as l } from "./index-nuyyRI2j.mjs";
1
+ import { D as e, a as o, E as t, P as d, e as r, h as i, m as n, d as E, c as l, u, v as C } from "./index-ES2pPSG6.mjs";
2
2
  export {
3
3
  e as DdocEditor,
4
4
  o as DdocExportModal,
5
- d as Editor,
6
- t as PreviewDdocEditor,
5
+ t as Editor,
6
+ d as PreviewDdocEditor,
7
7
  r as buildVersionDiffSnapshot,
8
8
  i as handleContentPrint,
9
9
  n as mergeTabAwareYjsUpdates,
10
- E as useExportHeadlessEditorContent,
11
- l as useHeadlessEditor
10
+ E as sanitizeCustomCss,
11
+ l as useExportHeadlessEditorContent,
12
+ u as useHeadlessEditor,
13
+ C as validateCustomCss
12
14
  };
@@ -1,9 +1,9 @@
1
1
  var Vr = Object.defineProperty;
2
2
  var Wr = (t, e, O) => e in t ? Vr(t, e, { enumerable: !0, configurable: !0, writable: !0, value: O }) : t[e] = O;
3
3
  var gt = (t, e, O) => Wr(t, typeof e != "symbol" ? e + "" : e, O);
4
- import { j as Cr } from "./index-nuyyRI2j.mjs";
4
+ import { j as Cr } from "./index-ES2pPSG6.mjs";
5
5
  import { useRef as pe, useEffect as St } from "react";
6
- import { s as y, A as pO, T as dO, a as Gr, S as et, b as Lr, P as fO, E as j, i as QO, c as _, D as le, k as tt, F as Ar, M as Pt, W as Er, R as Ur, d as mO, N as oe, e as V, f as Mr, g as Ot, h as ce, p as $O, j as Y, t as h, l as Ir, I as rt, L as at, m as ye, n as ue, o as Qe, q as gO, r as te, u as SO, v as Br, w as Nr, x as PO, y as kO, z as Dr, B as Fr, C as Kr, G as Oe, H as ZO, J as Jr, K as kt, O as Hr, Q as ea, U as ta, V as Oa, X as ra, Y as aa, Z as ia, _ as sa, $ as na, a0 as la, a1 as oa, a2 as ca } from "./index-DRxp2R0b.mjs";
6
+ import { s as y, A as pO, T as dO, a as Gr, S as et, b as Lr, P as fO, E as j, i as QO, c as _, D as le, k as tt, F as Ar, M as Pt, W as Er, R as Ur, d as mO, N as oe, e as V, f as Mr, g as Ot, h as ce, p as $O, j as Y, t as h, l as Ir, I as rt, L as at, m as ye, n as ue, o as Qe, q as gO, r as te, u as SO, v as Br, w as Nr, x as PO, y as kO, z as Dr, B as Fr, C as Kr, G as Oe, H as ZO, J as Jr, K as kt, O as Hr, Q as ea, U as ta, V as Oa, X as ra, Y as aa, Z as ia, _ as sa, $ as na, a0 as la, a1 as oa, a2 as ca } from "./index-CqX0iYGN.mjs";
7
7
  class ua {
8
8
  /**
9
9
  Create a new completion context. (Mostly useful for testing
@@ -3,6 +3,7 @@ import { InlineCommentDraft } from './context/types';
3
3
  interface MobileInlineCommentProps {
4
4
  activeDraft: InlineCommentDraft | null;
5
5
  activeDraftId: string | null;
6
+ isConnected: boolean;
6
7
  isDiscardCommentOverlayVisible: boolean;
7
8
  mobileDraftRef: React.RefObject<HTMLDivElement>;
8
9
  onAttemptClose: () => void;
@@ -11,5 +12,5 @@ interface MobileInlineCommentProps {
11
12
  onSubmit: () => void;
12
13
  onUpdateDraftText: (draftId: string, text: string) => void;
13
14
  }
14
- export declare const MobileInlineComment: ({ activeDraft, activeDraftId, isDiscardCommentOverlayVisible, mobileDraftRef, onAttemptClose, onCancelDiscard, onConfirmDiscard, onSubmit, onUpdateDraftText, }: MobileInlineCommentProps) => import("react/jsx-runtime").JSX.Element;
15
+ export declare const MobileInlineComment: ({ activeDraft, activeDraftId, isConnected, isDiscardCommentOverlayVisible, mobileDraftRef, onAttemptClose, onCancelDiscard, onConfirmDiscard, onSubmit, onUpdateDraftText, }: MobileInlineCommentProps) => import("react/jsx-runtime").JSX.Element;
15
16
  export {};
@@ -0,0 +1,10 @@
1
+ interface UseAutoSubmitCountdownProps {
2
+ label: string;
3
+ onSubmit: () => void;
4
+ resetKey: string | null;
5
+ shouldRun: boolean;
6
+ }
7
+ export declare const useAutoSubmitCountdown: ({ label, onSubmit, resetKey, shouldRun, }: UseAutoSubmitCountdownProps) => {
8
+ submitLabel: string;
9
+ };
10
+ export {};
@@ -0,0 +1,11 @@
1
+ interface UseCommentDraftAutoSubmitCountdownProps {
2
+ draftId: string | null;
3
+ canAutoSubmit: boolean;
4
+ onSubmit: () => void;
5
+ }
6
+ export declare const useCommentDraftAutoSubmitCountdown: ({ draftId, canAutoSubmit, onSubmit, }: UseCommentDraftAutoSubmitCountdownProps) => {
7
+ handleDraftBlur: () => void;
8
+ handleDraftFocus: () => void;
9
+ submitLabel: string;
10
+ };
11
+ export {};
@@ -0,0 +1,9 @@
1
+ interface UseSuggestionAutoSubmitCountdownProps {
2
+ suggestionId: string;
3
+ canAutoSubmit: boolean;
4
+ onSubmit: () => void;
5
+ }
6
+ export declare const useSuggestionAutoSubmitCountdown: ({ suggestionId, canAutoSubmit, onSubmit, }: UseSuggestionAutoSubmitCountdownProps) => {
7
+ submitLabel: string;
8
+ };
9
+ export {};
@@ -0,0 +1,13 @@
1
+ interface SplitViewCssAccordionProps {
2
+ /** The document's custom CSS (raw author selectors). */
3
+ customCSS?: string;
4
+ }
5
+ /**
6
+ * Split View LEFT pane: a collapsible, READ-ONLY view of the document's custom
7
+ * CSS, shown above the markdown source. Custom CSS is edited in the styling
8
+ * palette (the single source of truth), not in the markdown pane — this is a
9
+ * transparency affordance so the author can see what CSS is applied while in
10
+ * markdown mode. Renders nothing when there is no custom CSS.
11
+ */
12
+ export declare const SplitViewCssAccordion: ({ customCSS, }: SplitViewCssAccordionProps) => import("react/jsx-runtime").JSX.Element | null;
13
+ export {};
@@ -6,6 +6,8 @@ interface SplitViewMarkdownPaneProps {
6
6
  /** Same uploader the editor uses — for the markdown toolbar's Image button. */
7
7
  ipfsImageUploadFn?: (file: File) => Promise<IpfsImageUploadResponse>;
8
8
  onError?: (error: string) => void;
9
+ /** Document custom CSS — shown read-only in a collapsible accordion. */
10
+ customCSS?: string;
9
11
  /** Sizing for the resizable split (flex-grow set by the draggable splitter). */
10
12
  style?: React.CSSProperties;
11
13
  }
@@ -15,5 +17,5 @@ interface SplitViewMarkdownPaneProps {
15
17
  * real ddoc editor itself — see ddoc-editor.tsx, which keeps that editor mounted
16
18
  * in place (never a second <EditorContent>) so its React node views survive.
17
19
  */
18
- export declare const SplitViewMarkdownPane: ({ markdown, onMarkdownChange, ipfsImageUploadFn, onError, style, }: SplitViewMarkdownPaneProps) => import("react/jsx-runtime").JSX.Element;
20
+ export declare const SplitViewMarkdownPane: ({ markdown, onMarkdownChange, ipfsImageUploadFn, onError, customCSS, style, }: SplitViewMarkdownPaneProps) => import("react/jsx-runtime").JSX.Element;
19
21
  export {};
@@ -46,6 +46,7 @@ export declare function resolveCommentAnchorRangeInState(anchor: Pick<CommentAnc
46
46
  * so we need a separate path that allows a point position.
47
47
  */
48
48
  export declare function resolveCommentAnchorPointInState(anchor: Pick<CommentAnchor, 'anchorFrom'>, state: EditorState): number | null;
49
+ export declare function hasResolvableCommentAnchorInState(anchor: Pick<CommentAnchor, 'anchorFrom' | 'anchorTo' | 'isSuggestion' | 'suggestionType'>, state: EditorState): boolean;
49
50
  export declare function resolveCommentAnchorRangeForAnalysis(anchor: Pick<CommentAnchor, 'id' | 'anchorFrom' | 'anchorTo'>, state: EditorState): CommentAnchorRange | null;
50
51
  export declare function resolveCommentAnchorPointForAnalysis(anchor: Pick<CommentAnchor, 'id' | 'anchorFrom'>, state: EditorState): number | null;
51
52
  /**
@@ -7,6 +7,11 @@ export declare const turndownService: TurndownService;
7
7
  export declare const setMarkdownInlineStyles: (enabled: boolean) => void;
8
8
  export declare const setResolveColorVars: (enabled: boolean) => void;
9
9
  declare module '@tiptap/core' {
10
+ interface Storage {
11
+ markdownPasteHandler: {
12
+ customCSS: string;
13
+ };
14
+ }
10
15
  interface Commands {
11
16
  uploadMarkdownFile: {
12
17
  uploadMarkdownFile: (ipfsImageUploadFn?: (file: File) => Promise<IpfsImageUploadResponse>, onError?: (error: string) => void) => any;
@@ -23,6 +23,8 @@ export interface SuggestionTrackingOptions {
23
23
  onDeleteSelection: (from: number, to: number) => void;
24
24
  /** Viewer pastes a link over selected text. */
25
25
  onPasteLink: (from: number, to: number, href: string) => void;
26
+ /** Viewer attempted an unsupported paste/drop in suggestion mode. */
27
+ onUnsupportedPaste?: () => void;
26
28
  /**
27
29
  * Viewer presses Backspace/Delete with a collapsed cursor.
28
30
  * The consumer decides whether this should shrink an active draft or create
@@ -126,6 +126,8 @@ export interface CommentStoreState {
126
126
  pendingPrehydrationFloatingThreadIds: string[];
127
127
  /** In-progress suggestion drafts — keyed by suggestionId. Viewer-local, lost on refresh. */
128
128
  drafts: Record<string, DraftSuggestion>;
129
+ /** Suggestion draft currently under the focused editor cursor, if any. */
130
+ activeSuggestionDraftIdAtCursor: string | null;
129
131
  inlineDrafts: InlineDraftRecordMap;
130
132
  activeDraftId: string | null;
131
133
  isDesktopFloatingEnabled: boolean;
@@ -255,6 +257,11 @@ export interface CommentStoreState {
255
257
  * range while the viewer's draft is open.
256
258
  */
257
259
  refreshDraftOriginalContent: (suggestionId: string, currentText: string) => void;
260
+ /**
261
+ * Sync the draft id under the current editor cursor. Each draft card uses
262
+ * this to decide whether its own auto-submit countdown should run.
263
+ */
264
+ syncActiveSuggestionDraftAtCursor: () => void;
258
265
  /**
259
266
  * Promote a draft to a submitted suggestion. Pushes the anchor into
260
267
  * commentAnchorsRef, calls onNewComment, removes the draft, and swaps the
@@ -103,6 +103,17 @@ export interface DocumentStyling {
103
103
  * @example "portrait" | "landscape"
104
104
  */
105
105
  orientation?: 'portrait' | 'landscape';
106
+ /**
107
+ * Custom CSS
108
+ * @description The author's escape hatch for styling the document beyond the
109
+ * structured options above. Write BARE selectors (`h1 { … }`, `p { … }`,
110
+ * `blockquote { … }`) — they are auto-scoped to the document content, so rules
111
+ * can't leak into the toolbar or the host app. Bare top-level declarations
112
+ * (e.g. `background`, `font-family`) style the document surface itself.
113
+ * Applies live in the editor, in preview, and in exports (Markdown/HTML).
114
+ * @example "h1 { letter-spacing: -0.02em } p { line-height: 1.8 }"
115
+ */
116
+ customCSS?: string;
106
117
  }
107
118
  export interface DdocProps extends CommentAccountProps {
108
119
  /**
@@ -0,0 +1,45 @@
1
+ /**
2
+ * Sanitize + validate author-supplied custom CSS before it is injected into the
3
+ * document.
4
+ *
5
+ * Custom CSS travels to VIEWERS of a published document, so the raw string is
6
+ * NOT a trusted stylesheet. We defend against:
7
+ * - scope breakout: a `}` in the CSS escaping the `scope { … }` wrapper to
8
+ * style the whole app (toolbar, other content, security UI, overlays);
9
+ * - external resource loads / exfiltration: `url(…)` and `@import` (tracking
10
+ * beacons, plus CSS attribute-selector data exfiltration);
11
+ * - clickjacking / UI redressing: `position: fixed | sticky` overlays that
12
+ * escape the document box and cover the viewport;
13
+ * - legacy script vectors: `expression()`, `-moz-binding`, `behavior:`.
14
+ *
15
+ * Strategy: wrap the raw CSS in `scope { … }` and parse it with the browser's
16
+ * own CSS engine (no dependency, no regex parsing). A well-formed input yields
17
+ * exactly ONE top-level rule whose selector is `scope`; a breakout produces
18
+ * extra top-level rules with other selectors — we keep only `scope` rules and
19
+ * drop the rest. Dangerous declarations are stripped at every nesting level.
20
+ * The kept rules are re-serialized by the engine, so the output is always a
21
+ * valid, balanced stylesheet.
22
+ *
23
+ * The sanitizer knows exactly what it removed, so it also returns non-blocking
24
+ * `diagnostics` — the editing UI shows these so authors aren't left wondering
25
+ * why a rule silently vanished (CSS is forgiving; we warn, never block).
26
+ */
27
+ export interface CssDiagnostic {
28
+ level: 'warning' | 'error';
29
+ message: string;
30
+ }
31
+ export interface CssValidationResult {
32
+ /** Sanitized, scope-wrapped CSS, safe to inject. '' when nothing survives. */
33
+ css: string;
34
+ /** What was stripped/ignored, deduped. Empty when the CSS was fully clean. */
35
+ diagnostics: CssDiagnostic[];
36
+ }
37
+ /**
38
+ * Sanitize AND report. Use this from the editing UI to surface diagnostics.
39
+ */
40
+ export declare const validateCustomCss: (raw: string | undefined | null, scope?: string) => CssValidationResult;
41
+ /**
42
+ * Sanitized CSS only — used at injection/export sinks that just need the safe
43
+ * string. Diagnostics are surfaced separately via validateCustomCss.
44
+ */
45
+ export declare const sanitizeCustomCss: (raw: string | undefined | null, scope?: string) => string;
@@ -1,7 +1,7 @@
1
- import { j as d } from "./index-nuyyRI2j.mjs";
1
+ import { j as d } from "./index-ES2pPSG6.mjs";
2
2
  import { useRef as I, useState as N, useEffect as D } from "react";
3
3
  import { DynamicDropdown as E, Tooltip as R, IconButton as O } from "@fileverse/ui";
4
- import { a3 as A, a4 as P, c as y } from "./index-DRxp2R0b.mjs";
4
+ import { a3 as A, a4 as P, c as y } from "./index-CqX0iYGN.mjs";
5
5
  const p = (e, t, o = t) => {
6
6
  const { state: s } = e, l = s.changeByRange((n) => {
7
7
  const u = s.sliceDoc(n.from, n.to), r = s.sliceDoc(