@henryx/pagely 0.1.0 → 0.2.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.
@@ -0,0 +1,50 @@
1
+ import { ComputedRef, Ref } from 'vue';
2
+ import { Editor } from '@tiptap/vue-3';
3
+ type MaybeRef<T> = T | Ref<T> | ComputedRef<T>;
4
+ export interface PagelyTocItem {
5
+ id: string;
6
+ text: string;
7
+ level: number;
8
+ pos: number;
9
+ }
10
+ export interface PagelyTocExtractOptions {
11
+ minLevel?: number;
12
+ maxLevel?: number;
13
+ }
14
+ export interface PagelyTocSourceNode {
15
+ type: {
16
+ name: string;
17
+ };
18
+ attrs?: Record<string, unknown>;
19
+ textContent?: string;
20
+ }
21
+ export interface PagelyTocSourceDoc {
22
+ descendants: (callback: (node: PagelyTocSourceNode, pos: number) => boolean | void) => void;
23
+ }
24
+ export interface UsePagelyTocOptions extends PagelyTocExtractOptions {
25
+ scrollContainer?: MaybeRef<HTMLElement | Window | null | undefined>;
26
+ scrollOffset?: MaybeRef<number | undefined>;
27
+ activeOffset?: MaybeRef<number | undefined>;
28
+ behavior?: MaybeRef<ScrollBehavior | undefined>;
29
+ }
30
+ export declare function slugifyTocId(value: string, fallback?: string): string;
31
+ export declare function extractPagelyTocItemsFromDoc(doc: PagelyTocSourceDoc, options?: PagelyTocExtractOptions): PagelyTocItem[];
32
+ export declare function extractPagelyTocItems(editor: Editor | null | undefined, options?: PagelyTocExtractOptions): PagelyTocItem[];
33
+ export declare function usePagelyToc(editorSource: MaybeRef<Editor | null | undefined>, options?: UsePagelyTocOptions): {
34
+ items: Ref<{
35
+ id: string;
36
+ text: string;
37
+ level: number;
38
+ pos: number;
39
+ }[], PagelyTocItem[] | {
40
+ id: string;
41
+ text: string;
42
+ level: number;
43
+ pos: number;
44
+ }[]>;
45
+ activeId: Ref<string, string>;
46
+ refresh: () => void;
47
+ scrollToItem: (item: PagelyTocItem) => void;
48
+ updateActiveFromScroll: () => void;
49
+ };
50
+ export {};
@@ -6,6 +6,9 @@ export interface InsertCtx {
6
6
  rows?: number;
7
7
  cols?: number;
8
8
  src?: string;
9
+ attachmentId?: string | number | null;
10
+ fileName?: string | null;
11
+ mimeType?: string | null;
9
12
  alt?: string | null;
10
13
  title?: string | null;
11
14
  label?: string;
@@ -1,10 +1,17 @@
1
1
  import { Node } from '@tiptap/core';
2
2
  export interface ImageAttrs {
3
- src: string;
3
+ src?: string;
4
+ attachmentId?: string | number | null;
5
+ fileName?: string | null;
6
+ mimeType?: string | null;
4
7
  alt?: string | null;
5
8
  title?: string | null;
6
9
  width?: number | null;
7
10
  }
11
+ export type ImageUrlResolver = (attachmentId: string | number) => Promise<string | null>;
12
+ export interface ImageOptions {
13
+ imageUrlResolver?: ImageUrlResolver;
14
+ }
8
15
  declare module '@tiptap/core' {
9
16
  interface Commands<ReturnType> {
10
17
  image: {
@@ -12,4 +19,4 @@ declare module '@tiptap/core' {
12
19
  };
13
20
  }
14
21
  }
15
- export declare const Image: Node<any, any>;
22
+ export declare const Image: Node<ImageOptions, any>;
package/dist/index.d.ts CHANGED
@@ -1,4 +1,6 @@
1
1
  export { default as PagelyEditor } from './components/PagelyEditor.vue';
2
+ export { default as PagelyPage } from './components/PagelyPage.vue';
3
+ export { default as PagelyToc } from './components/PagelyToc.vue';
2
4
  export { default as PagelyViewer } from './components/PagelyViewer.vue';
3
5
  export { default as CommentEditor } from './components/CommentEditor.vue';
4
6
  export { default as CommentContentViewer } from './components/CommentContentViewer.vue';
@@ -19,12 +21,15 @@ export { useInsertMenu } from './composables/useInsertMenu';
19
21
  export { useMarkdownSync } from './composables/useMarkdownSync';
20
22
  export { useMenuSidePanel } from './composables/useMenuSidePanel';
21
23
  export { calcMenuPosition } from './composables/useMenuPosition';
24
+ export { usePagelyToc, extractPagelyTocItems, extractPagelyTocItemsFromDoc, slugifyTocId } from './composables/usePagelyToc';
22
25
  export { useTableTools } from './composables/useTableTools';
23
26
  export type { FileUploadHandler, FileUploadResult } from './composables/useFileUpload';
27
+ export type { ImageAttrs, ImageUrlResolver } from './extensions/Image';
24
28
  export type { AnchorSpec, CommentAnchor, CommentCreateSpec, CommentClickPayload, CommentHoverPayload } from './composables/useCommentAnchors';
25
29
  export type { MentionAnchor, MentionTriggerPayload } from './composables/useMention';
26
30
  export type { CellBounds, InsertDot } from './composables/useTableTools';
27
31
  export type { MenuAnchor, MenuPlacement, MenuPosition } from './composables/useMenuPosition';
32
+ export type { PagelyTocExtractOptions, PagelyTocItem, UsePagelyTocOptions } from './composables/usePagelyToc';
28
33
  export { BLOCK_CONFIGS } from './config/blockMenu';
29
34
  export { EXTENSION_PROFILES, shouldLoad } from './config/extensionProfiles';
30
35
  export type { ExtensionProfile } from './config/extensionProfiles';