@henryx/pagely 0.1.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.
Files changed (120) hide show
  1. package/dist/components/BlockMenu.vue.d.ts +27 -0
  2. package/dist/components/CodeBlockView.vue.d.ts +95 -0
  3. package/dist/components/ColAlignBadge.vue.d.ts +15 -0
  4. package/dist/components/ColorPanel.vue.d.ts +14 -0
  5. package/dist/components/CommentContentViewer.vue.d.ts +11 -0
  6. package/dist/components/CommentEditor.vue.d.ts +26 -0
  7. package/dist/components/DotFlowPadBlockView.vue.d.ts +146 -0
  8. package/dist/components/EmbedBlockShell.vue.d.ts +46 -0
  9. package/dist/components/EmbedFullscreenModal.vue.d.ts +29 -0
  10. package/dist/components/EmbedViewBlock.vue.d.ts +26 -0
  11. package/dist/components/EmbedViewToolbar.vue.d.ts +24 -0
  12. package/dist/components/ImageBlockView.vue.d.ts +7 -0
  13. package/dist/components/ImagePreviewDialog.vue.d.ts +13 -0
  14. package/dist/components/InsertLinkDialog.vue.d.ts +19 -0
  15. package/dist/components/InsertMenu.vue.d.ts +27 -0
  16. package/dist/components/LinkToolbar.vue.d.ts +15 -0
  17. package/dist/components/MathPopover.vue.d.ts +15 -0
  18. package/dist/components/MentionNode.vue.d.ts +92 -0
  19. package/dist/components/MermaidBlockView.vue.d.ts +104 -0
  20. package/dist/components/PagelyEditor.vue.d.ts +119 -0
  21. package/dist/components/PagelyViewer.vue.d.ts +15 -0
  22. package/dist/components/SelectionToolbar.vue.d.ts +23 -0
  23. package/dist/components/TableActionMenu.vue.d.ts +28 -0
  24. package/dist/components/TableSizePicker.vue.d.ts +19 -0
  25. package/dist/components/TableTools.vue.d.ts +45 -0
  26. package/dist/composables/useBlockButton.d.ts +21 -0
  27. package/dist/composables/useBlockConvert.d.ts +4 -0
  28. package/dist/composables/useBlockImageExport.d.ts +4 -0
  29. package/dist/composables/useBlockMenu.d.ts +19 -0
  30. package/dist/composables/useBlockOps.d.ts +3 -0
  31. package/dist/composables/useCodeMirror.d.ts +30 -0
  32. package/dist/composables/useCommentAnchors.d.ts +60 -0
  33. package/dist/composables/useCommentEditor.d.ts +24 -0
  34. package/dist/composables/useEditorCommands.d.ts +22 -0
  35. package/dist/composables/useEditorEvents.d.ts +22 -0
  36. package/dist/composables/useEmbedView.d.ts +28 -0
  37. package/dist/composables/useFileUpload.d.ts +28 -0
  38. package/dist/composables/useHeadingCollapse.d.ts +19 -0
  39. package/dist/composables/useHoverMenu.d.ts +7 -0
  40. package/dist/composables/useInsertButton.d.ts +7 -0
  41. package/dist/composables/useInsertMenu.d.ts +17 -0
  42. package/dist/composables/useLinkHover.d.ts +3 -0
  43. package/dist/composables/useLinkOps.d.ts +32 -0
  44. package/dist/composables/useMarkdownSync.d.ts +12 -0
  45. package/dist/composables/useMath.d.ts +38 -0
  46. package/dist/composables/useMention.d.ts +20 -0
  47. package/dist/composables/useMenuPosition.d.ts +13 -0
  48. package/dist/composables/useMenuSidePanel.d.ts +27 -0
  49. package/dist/composables/useNodeViewCommentAttrs.d.ts +12 -0
  50. package/dist/composables/usePagelyEditor.d.ts +17 -0
  51. package/dist/composables/useSelectionToolbar.d.ts +3 -0
  52. package/dist/composables/useTableCellOps.d.ts +21 -0
  53. package/dist/composables/useTableDots.d.ts +60 -0
  54. package/dist/composables/useTableTools.d.ts +72 -0
  55. package/dist/config/blockMenu/index.d.ts +39 -0
  56. package/dist/config/blockMenu/items.d.ts +26 -0
  57. package/dist/config/blockMenu/profiles.d.ts +13 -0
  58. package/dist/config/blockMenu/sections.d.ts +8 -0
  59. package/dist/config/blockMenu/tagMapping.d.ts +9 -0
  60. package/dist/config/blockTypeConfig.d.ts +1 -0
  61. package/dist/config/extensionProfiles.d.ts +3 -0
  62. package/dist/config/insertMenu/blockCommands.d.ts +2 -0
  63. package/dist/config/insertMenu/cellOps.d.ts +22 -0
  64. package/dist/config/insertMenu/commands.d.ts +16 -0
  65. package/dist/config/insertMenu/index.d.ts +10 -0
  66. package/dist/config/insertMenu/items.d.ts +11 -0
  67. package/dist/config/insertMenu/sections.d.ts +15 -0
  68. package/dist/config/selectionToolbarConfig.d.ts +25 -0
  69. package/dist/config/selectionToolbarRules.d.ts +5 -0
  70. package/dist/extensions/AutoLinkTitle.d.ts +2 -0
  71. package/dist/extensions/CodeBlockCM.d.ts +7 -0
  72. package/dist/extensions/CommentBlock.d.ts +3 -0
  73. package/dist/extensions/CommentMark.d.ts +5 -0
  74. package/dist/extensions/CommentableTableView.d.ts +7 -0
  75. package/dist/extensions/DotFlowPadBlock.d.ts +2 -0
  76. package/dist/extensions/EmbedView.d.ts +12 -0
  77. package/dist/extensions/Image.d.ts +15 -0
  78. package/dist/extensions/Mathematics.d.ts +3 -0
  79. package/dist/extensions/Mention.d.ts +13 -0
  80. package/dist/extensions/MermaidBlock.d.ts +2 -0
  81. package/dist/extensions/SlashInsert.d.ts +5 -0
  82. package/dist/extensions/SmartPaste.d.ts +14 -0
  83. package/dist/extensions/TableCellEnter.d.ts +2 -0
  84. package/dist/index.d.ts +41 -0
  85. package/dist/pagely.cjs +318 -0
  86. package/dist/pagely.js +24519 -0
  87. package/dist/stores/linkState.d.ts +21 -0
  88. package/dist/style.css +1 -0
  89. package/dist/types/menuCommands.d.ts +42 -0
  90. package/dist/utils/attachmentUpload.d.ts +15 -0
  91. package/dist/utils/commentIds.d.ts +1 -0
  92. package/dist/utils/embedView/attrs.d.ts +19 -0
  93. package/dist/utils/embedView/detect.d.ts +14 -0
  94. package/dist/utils/embedView/downgrade.d.ts +1 -0
  95. package/dist/utils/embedView/markdown.d.ts +6 -0
  96. package/dist/utils/embedView/metadata.d.ts +8 -0
  97. package/dist/utils/embedView/pagelyPreview.d.ts +1 -0
  98. package/dist/utils/embedView/url.d.ts +10 -0
  99. package/dist/utils/markdown-converter/shared.d.ts +15 -0
  100. package/dist/utils/markdown-converter/toHtml.d.ts +1 -0
  101. package/dist/utils/markdown-converter/toMarkdown.d.ts +7 -0
  102. package/dist/utils/markdown-converter.d.ts +4 -0
  103. package/dist/utils/paste/context.d.ts +4 -0
  104. package/dist/utils/paste/escape.d.ts +2 -0
  105. package/dist/utils/paste/handlers/codeBlock.d.ts +2 -0
  106. package/dist/utils/paste/handlers/dotFlowPad.d.ts +2 -0
  107. package/dist/utils/paste/handlers/jsonCode.d.ts +2 -0
  108. package/dist/utils/paste/handlers/latexBlock.d.ts +2 -0
  109. package/dist/utils/paste/handlers/markdown.d.ts +2 -0
  110. package/dist/utils/paste/handlers/mermaid.d.ts +2 -0
  111. package/dist/utils/paste/handlers/richHtml.d.ts +2 -0
  112. package/dist/utils/paste/handlers/tsv.d.ts +2 -0
  113. package/dist/utils/paste/index.d.ts +10 -0
  114. package/dist/utils/paste/parsers/json.d.ts +5 -0
  115. package/dist/utils/paste/parsers/tsv.d.ts +5 -0
  116. package/dist/utils/paste/richHtml.d.ts +1 -0
  117. package/dist/utils/paste/sanitize.d.ts +1 -0
  118. package/dist/utils/paste/types.d.ts +12 -0
  119. package/dist/utils/tableAlign.d.ts +2 -0
  120. package/package.json +99 -0
@@ -0,0 +1,42 @@
1
+ import { ChainedCommands } from '@tiptap/core';
2
+ import { EmbedViewAttrs } from '../extensions/EmbedView';
3
+ export type MenuChain = ChainedCommands & {
4
+ toggleOrderedList: () => MenuChain;
5
+ toggleBulletList: () => MenuChain;
6
+ toggleTaskList: () => MenuChain;
7
+ liftListItem: (typeOrName: string) => MenuChain;
8
+ setCodeBlock: () => MenuChain;
9
+ unsetCodeBlock: () => MenuChain;
10
+ toggleBlockquote: () => MenuChain;
11
+ setHorizontalRule: () => MenuChain;
12
+ insertInlineMath: (options: {
13
+ latex: string;
14
+ pos?: number;
15
+ }) => MenuChain;
16
+ updateInlineMath: (options: {
17
+ latex: string;
18
+ pos?: number;
19
+ }) => MenuChain;
20
+ insertBlockMath: (options: {
21
+ latex: string;
22
+ pos?: number;
23
+ }) => MenuChain;
24
+ updateBlockMath: (options: {
25
+ latex: string;
26
+ pos?: number;
27
+ }) => MenuChain;
28
+ insertImage: (options: {
29
+ src: string;
30
+ alt?: string | null;
31
+ title?: string | null;
32
+ width?: number | null;
33
+ }) => MenuChain;
34
+ insertEmbedView: (options: EmbedViewAttrs) => MenuChain;
35
+ insertDotFlowPadBlock: () => MenuChain;
36
+ insertMermaidBlock: () => MenuChain;
37
+ insertTable: (options: {
38
+ rows: number;
39
+ cols: number;
40
+ withHeaderRow?: boolean;
41
+ }) => MenuChain;
42
+ };
@@ -0,0 +1,15 @@
1
+ /**
2
+ * Attachment upload — generic file-attachment helpers for the editor.
3
+ *
4
+ * pagely accepts any file as an attachment and embeds it via EmbedView. The
5
+ * default handler produces a local blob URL (good for demos); production hosts
6
+ * should pass their own `FileUploadHandler` that uploads to a CDN/store and
7
+ * returns a stable `href` + display `label`.
8
+ */
9
+ export declare const DEFAULT_ATTACHMENT_ACCEPT = "*/*";
10
+ export interface FileUploadResult {
11
+ href: string;
12
+ label: string;
13
+ }
14
+ export type FileUploadHandler = (file: File) => Promise<FileUploadResult | null>;
15
+ export declare function defaultAttachmentUpload(file: File): Promise<FileUploadResult | null>;
@@ -0,0 +1 @@
1
+ export declare function parseCommentIds(raw: unknown): string[];
@@ -0,0 +1,19 @@
1
+ import { EmbedViewMode } from './detect';
2
+ export interface EmbedViewAttrs {
3
+ href: string;
4
+ label: string;
5
+ view: EmbedViewMode;
6
+ }
7
+ export interface CreateEmbedAttrsInput {
8
+ href: string;
9
+ label?: string;
10
+ /** Optional user-supplied view; ignored if illegal or not previewable. */
11
+ preferredView?: unknown;
12
+ }
13
+ /**
14
+ * Produce validated `EmbedViewAttrs`, or `null` if the href is unsafe.
15
+ *
16
+ * Trims href/label, fills the label from the URL when empty, normalises the
17
+ * view through `pickView`.
18
+ */
19
+ export declare function createEmbedAttrs(input: CreateEmbedAttrsInput): EmbedViewAttrs | null;
@@ -0,0 +1,14 @@
1
+ export type EmbedViewMode = 'link' | 'card' | 'preview';
2
+ export type EmbedFileType = 'pdf' | 'md' | 'url';
3
+ export { extractDomain, extractFileName } from './url';
4
+ export declare function detectFileType(href: string): EmbedFileType;
5
+ /**
6
+ * Detect file type from href first, falling back to the label when the href
7
+ * carries no extension (typical of blob: URLs from local uploads). Used by
8
+ * both default-view selection and runtime fetch gating (e.g. "should I fetch
9
+ * this as markdown text?").
10
+ */
11
+ export declare function detectFileTypeWithLabel(href: string, label: string): EmbedFileType;
12
+ export declare function getDefaultView(href: string, label?: string): EmbedViewMode;
13
+ export declare function canPreviewEmbedView(href: string, label?: string): boolean;
14
+ export declare function isSafeUrl(href: string): boolean;
@@ -0,0 +1 @@
1
+ export declare function downgradeEmbedViewHtml(html: string): string;
@@ -0,0 +1,6 @@
1
+ import { default as MarkdownIt } from 'markdown-it';
2
+ import { default as TurndownService } from 'turndown';
3
+ export declare function embedViewCorePlugin(md: MarkdownIt): void;
4
+ export declare const embedViewTurndownRule: {
5
+ name: string;
6
+ } & TurndownService.Rule;
@@ -0,0 +1,8 @@
1
+ export interface UrlMetadata {
2
+ title: string | null;
3
+ favicon: string | null;
4
+ domain: string;
5
+ }
6
+ export declare function fetchUrlMetadata(href: string, signal?: AbortSignal): Promise<UrlMetadata>;
7
+ export declare function fetchMdContent(href: string, signal?: AbortSignal): Promise<string>;
8
+ export declare function renderMdToSafeHtml(md: string): string;
@@ -0,0 +1 @@
1
+ export declare function buildPagelyPreviewSrcdoc(body: string): string;
@@ -0,0 +1,10 @@
1
+ /**
2
+ * Pure URL-string utilities. No business policy lives here — only mechanical
3
+ * parsing/decomposition of href strings. Higher-level decisions (safety,
4
+ * file-type semantics, default view) belong in detect.ts and attrs.ts.
5
+ */
6
+ export declare function stripQueryAndHash(value: string): string;
7
+ export declare function extractExt(value: string): string;
8
+ export declare function isBlobUrl(href: string): boolean;
9
+ export declare function extractDomain(href: string): string;
10
+ export declare function extractFileName(href: string): string;
@@ -0,0 +1,15 @@
1
+ /** Shared helpers for pagely markdown conversion. */
2
+ export declare function normalizeLanguage(lang: string): string;
3
+ export type FencedBlockMapping = {
4
+ lang: string;
5
+ dataType: string;
6
+ htmlTag: 'pre' | 'div';
7
+ extractBody: (el: Element) => string;
8
+ buildHtml: (body: string, esc: (value: string) => string) => string;
9
+ };
10
+ export declare function fencedBlockReplacement(mapping: FencedBlockMapping, node: Node): string;
11
+ export declare const FENCED_BLOCK_MAPPINGS: FencedBlockMapping[];
12
+ export declare function getFencedBlockMapping(node: Node): FencedBlockMapping | null;
13
+ export declare function escapeHtml(value: string): string;
14
+ export declare function getInlineMathLatex(node: Node): string | null;
15
+ export declare function getBlockMathLatex(node: Node): string | null;
@@ -0,0 +1 @@
1
+ export declare function markdownToHtml(markdown: string): string;
@@ -0,0 +1,7 @@
1
+ import { default as TurndownService } from 'turndown';
2
+ type NamedRule = {
3
+ name: string;
4
+ } & TurndownService.Rule;
5
+ export declare function buildTdRules(td: TurndownService): NamedRule[];
6
+ export declare function htmlToMarkdown(html: string): string;
7
+ export {};
@@ -0,0 +1,4 @@
1
+ /** Markdown <-> HTML bidirectional conversion for pagely. */
2
+ export { normalizeLanguage } from './markdown-converter/shared';
3
+ export { markdownToHtml } from './markdown-converter/toHtml';
4
+ export { htmlToMarkdown } from './markdown-converter/toMarkdown';
@@ -0,0 +1,4 @@
1
+ import { EditorView } from '@tiptap/pm/view';
2
+ import { PasteContext } from './types';
3
+ export declare function buildContext(event: ClipboardEvent, view: EditorView): PasteContext | null;
4
+ export declare function isInlineOnlyContext(view: EditorView): boolean;
@@ -0,0 +1,2 @@
1
+ export declare function escapeText(value: string): string;
2
+ export declare function escapeAttr(value: string): string;
@@ -0,0 +1,2 @@
1
+ import { PasteHandler } from '../types';
2
+ export declare const codeBlockHandler: PasteHandler;
@@ -0,0 +1,2 @@
1
+ import { PasteHandler } from '../types';
2
+ export declare const dotFlowPadHandler: PasteHandler;
@@ -0,0 +1,2 @@
1
+ import { PasteHandler } from '../types';
2
+ export declare const jsonCodeHandler: PasteHandler;
@@ -0,0 +1,2 @@
1
+ import { PasteHandler } from '../types';
2
+ export declare const latexBlockHandler: PasteHandler;
@@ -0,0 +1,2 @@
1
+ import { PasteHandler } from '../types';
2
+ export declare const markdownHandler: PasteHandler;
@@ -0,0 +1,2 @@
1
+ import { PasteHandler } from '../types';
2
+ export declare const mermaidHandler: PasteHandler;
@@ -0,0 +1,2 @@
1
+ import { PasteHandler } from '../types';
2
+ export declare const richHtmlHandler: PasteHandler;
@@ -0,0 +1,2 @@
1
+ import { PasteHandler } from '../types';
2
+ export declare const tsvHandler: PasteHandler;
@@ -0,0 +1,10 @@
1
+ import { codeBlockHandler } from './handlers/codeBlock';
2
+ import { dotFlowPadHandler } from './handlers/dotFlowPad';
3
+ import { jsonCodeHandler } from './handlers/jsonCode';
4
+ import { latexBlockHandler } from './handlers/latexBlock';
5
+ import { markdownHandler } from './handlers/markdown';
6
+ import { mermaidHandler } from './handlers/mermaid';
7
+ import { richHtmlHandler } from './handlers/richHtml';
8
+ import { tsvHandler } from './handlers/tsv';
9
+ export { codeBlockHandler, dotFlowPadHandler, jsonCodeHandler, latexBlockHandler, markdownHandler, mermaidHandler, richHtmlHandler, tsvHandler, };
10
+ export declare const defaultPasteHandlers: import('./types').PasteHandler[];
@@ -0,0 +1,5 @@
1
+ export declare function safeParseJson(text: string): {
2
+ value: unknown;
3
+ } | null;
4
+ export declare function isArray(value: unknown): value is unknown[];
5
+ export declare function isObject(value: unknown): value is Record<string, unknown>;
@@ -0,0 +1,5 @@
1
+ export interface TsvParsed {
2
+ rows: string[][];
3
+ cols: number;
4
+ }
5
+ export declare function parseTsv(text: string): TsvParsed | null;
@@ -0,0 +1 @@
1
+ export declare function detectRichHtml(html: string | null): boolean;
@@ -0,0 +1 @@
1
+ export declare function sanitize(html: string): string;
@@ -0,0 +1,12 @@
1
+ export interface PasteContext {
2
+ plainText: string;
3
+ html: string | null;
4
+ isRichHtml: boolean;
5
+ inlineOnly: boolean;
6
+ }
7
+ export interface PasteHandler {
8
+ name: string;
9
+ priority: number;
10
+ detect: (ctx: PasteContext) => boolean;
11
+ transform: (ctx: PasteContext) => string;
12
+ }
@@ -0,0 +1,2 @@
1
+ export type TableAlign = 'left' | 'center' | 'right' | null;
2
+ export declare function extractTableAlign(el: Element): TableAlign;
package/package.json ADDED
@@ -0,0 +1,99 @@
1
+ {
2
+ "name": "@henryx/pagely",
3
+ "version": "0.1.0",
4
+ "type": "module",
5
+ "description": "A block-style rich text editor built with Vue 3 and TipTap",
6
+ "keywords": [
7
+ "vue",
8
+ "vue3",
9
+ "tiptap",
10
+ "block-editor",
11
+ "rich-text-editor"
12
+ ],
13
+ "license": "MIT",
14
+ "author": "",
15
+ "repository": {
16
+ "type": "git",
17
+ "url": ""
18
+ },
19
+ "main": "dist/pagely.cjs",
20
+ "module": "dist/pagely.js",
21
+ "types": "dist/index.d.ts",
22
+ "exports": {
23
+ ".": {
24
+ "import": "./dist/pagely.js",
25
+ "require": "./dist/pagely.cjs",
26
+ "types": "./dist/index.d.ts"
27
+ },
28
+ "./style.css": "./dist/style.css"
29
+ },
30
+ "files": [
31
+ "dist"
32
+ ],
33
+ "sideEffects": [
34
+ "**/*.css"
35
+ ],
36
+ "scripts": {
37
+ "dev": "vite",
38
+ "build": "vite build",
39
+ "preview": "vite preview",
40
+ "test": "vitest run",
41
+ "test:watch": "vitest"
42
+ },
43
+ "dependencies": {
44
+ "@codemirror/autocomplete": "^6.20.1",
45
+ "@codemirror/commands": "^6.10.2",
46
+ "@codemirror/lang-cpp": "^6.0.3",
47
+ "@codemirror/lang-css": "^6.3.1",
48
+ "@codemirror/lang-html": "^6.4.11",
49
+ "@codemirror/lang-java": "^6.0.2",
50
+ "@codemirror/lang-javascript": "^6.2.5",
51
+ "@codemirror/lang-json": "^6.0.2",
52
+ "@codemirror/lang-markdown": "^6.5.0",
53
+ "@codemirror/lang-php": "^6.0.2",
54
+ "@codemirror/lang-python": "^6.2.1",
55
+ "@codemirror/lang-rust": "^6.0.2",
56
+ "@codemirror/lang-sql": "^6.10.0",
57
+ "@codemirror/lang-xml": "^6.1.0",
58
+ "@codemirror/language": "^6.12.2",
59
+ "@codemirror/state": "^6.5.4",
60
+ "@codemirror/view": "^6.39.17",
61
+ "@floating-ui/dom": "^1.6.0",
62
+ "@fontsource/jetbrains-mono": "^5.2.8",
63
+ "@tiptap/extension-code-block-lowlight": "^3",
64
+ "@tiptap/extension-color": "^3.20.2",
65
+ "@tiptap/extension-highlight": "^3.20.2",
66
+ "@tiptap/extension-link": "^3.20.1",
67
+ "@tiptap/extension-mathematics": "^3.23.1",
68
+ "@tiptap/extension-table": "^3",
69
+ "@tiptap/extension-task-item": "^3.20.1",
70
+ "@tiptap/extension-task-list": "^3.20.1",
71
+ "@tiptap/extension-text-align": "^3.20.2",
72
+ "@tiptap/starter-kit": "^3",
73
+ "@tiptap/vue-3": "^3",
74
+ "dot-flow-pad": "^0.1.2",
75
+ "katex": "^0.16.45",
76
+ "lowlight": "^3.1.0",
77
+ "lucide-vue-next": "^0.577.0",
78
+ "markdown-it": "^14.1.1",
79
+ "mermaid": "^11.13.0",
80
+ "mermaid-smart-editor": "^0.1.1",
81
+ "turndown": "^7.2.2",
82
+ "vue": "^3.4.0"
83
+ },
84
+ "devDependencies": {
85
+ "@types/jsdom": "^21.1.7",
86
+ "@types/markdown-it": "^14.1.2",
87
+ "@types/turndown": "^5.0.6",
88
+ "@vitejs/plugin-vue": "^5.0.0",
89
+ "jsdom": "^24.1.3",
90
+ "typescript": "^5.3.0",
91
+ "vite": "^5.2.0",
92
+ "vite-plugin-dts": "^4.5.4",
93
+ "vitest": "^1.6.1",
94
+ "vue-tsc": "^2.0.0"
95
+ },
96
+ "peerDependencies": {
97
+ "vue": "^3.4.0"
98
+ }
99
+ }