@3kles/richtext-formats 0.0.0-stage → 1.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.
@@ -0,0 +1 @@
1
+ {"version":3,"file":"tiptap-types.js","sourceRoot":"","sources":["../../src/lib/tiptap-types.ts"],"names":[],"mappings":"AAkBA,MAAM,CAAC,MAAM,4BAA4B,GAAuB,MAAM,CAAC,MAAM,CAAC;IAC1E,QAAQ,EAAE,GAAG;IACb,QAAQ,EAAE,OAAO;IACjB,aAAa,EAAE,SAAS;IACxB,sBAAsB,EAAE,EAAE;IAC1B,kBAAkB,EAAE,MAAM;IAC1B,cAAc,EAAE,GAAG;CACtB,CAAC,CAAC","sourcesContent":["import type { DocumentOptions } from '@3kles/richtext-core';\n\n/** Fixed data profile, not runtime API or extension compatibility. */\nexport type TiptapImportProfile = 'tiptap-3-starterkit';\n\nexport interface TiptapImportLimits {\n /** JSON container nesting, including content/marks arrays and attrs objects. */\n readonly maxDepth: number;\n /** Source JSON values, including containers, fields and array entries. */\n readonly maxNodes: number;\n /** Sum of source string values and property names, in UTF-16 units. */\n readonly maxTextLength: number;\n readonly maxAttributesPerObject: number;\n /** Attribute name/value length; paragraph/code text uses the total text budget. */\n readonly maxAttributeLength: number;\n readonly maxDiagnostics: number;\n}\n\nexport const DEFAULT_TIPTAP_IMPORT_LIMITS: TiptapImportLimits = Object.freeze({\n maxDepth: 128,\n maxNodes: 100_000,\n maxTextLength: 1_000_000,\n maxAttributesPerObject: 32,\n maxAttributeLength: 16_384,\n maxDiagnostics: 200,\n});\n\nexport interface TiptapImportOptions extends DocumentOptions {\n readonly profile: TiptapImportProfile;\n /** Unknown data and nonrepresentable metadata are rejected unless sanitization is explicit. */\n readonly onLoss?: 'reject' | 'sanitize';\n readonly migrationLimits?: Partial<TiptapImportLimits>;\n}\n"]}
package/lib/types.d.ts ADDED
@@ -0,0 +1,39 @@
1
+ import type { DocumentNode, DocumentOptions } from '@3kles/richtext-core';
2
+ export type FormatDiagnosticCode = 'invalidInput' | 'invalidDocument' | 'invalidSelection' | 'invalidUnicode' | 'resourceLimit' | 'malformedHtml' | 'removedElement' | 'removedAttribute' | 'unsafeUrl' | 'unsupportedElement' | 'unsupportedProfile' | 'unsupportedNode' | 'unsupportedMark' | 'unsupportedAttribute' | 'structuralRewrite' | 'normalized' | 'plainTextLoss' | 'diagnosticsTruncated';
3
+ export interface FormatDiagnostic {
4
+ readonly code: FormatDiagnosticCode;
5
+ readonly severity: 'info' | 'warning' | 'error';
6
+ readonly path: readonly (string | number)[];
7
+ /** Describes the operation, never copies attacker-controlled attribute values. */
8
+ readonly message: string;
9
+ }
10
+ export type FormatResult<T> = {
11
+ readonly ok: true;
12
+ readonly value: T;
13
+ readonly lossy: boolean;
14
+ readonly diagnostics: readonly FormatDiagnostic[];
15
+ } | {
16
+ readonly ok: false;
17
+ readonly diagnostics: readonly FormatDiagnostic[];
18
+ };
19
+ export interface HtmlLimits {
20
+ readonly maxHtmlLength: number;
21
+ readonly maxNodes: number;
22
+ readonly maxDepth: number;
23
+ readonly maxTextLength: number;
24
+ readonly maxAttributesPerElement: number;
25
+ readonly maxAttributeLength: number;
26
+ readonly maxOutputLength: number;
27
+ readonly maxDiagnostics: number;
28
+ }
29
+ export declare const DEFAULT_HTML_LIMITS: HtmlLimits;
30
+ export interface FormatOptions extends DocumentOptions {
31
+ readonly htmlLimits?: Partial<HtmlLimits>;
32
+ /** Sanitization is explicit in diagnostics. Reject makes every warning fatal. */
33
+ readonly onLoss?: 'sanitize' | 'reject';
34
+ }
35
+ export interface HtmlFragment {
36
+ readonly document: DocumentNode;
37
+ /** An inline fragment can be inserted into the current text block. */
38
+ readonly inline: boolean;
39
+ }
package/lib/types.js ADDED
@@ -0,0 +1,11 @@
1
+ export const DEFAULT_HTML_LIMITS = Object.freeze({
2
+ maxHtmlLength: 8_000_000,
3
+ maxNodes: 100_000,
4
+ maxDepth: 128,
5
+ maxTextLength: 1_000_000,
6
+ maxAttributesPerElement: 32,
7
+ maxAttributeLength: 16_384,
8
+ maxOutputLength: 8_000_000,
9
+ maxDiagnostics: 200,
10
+ });
11
+ //# sourceMappingURL=types.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.js","sourceRoot":"","sources":["../../src/lib/types.ts"],"names":[],"mappings":"AAkDA,MAAM,CAAC,MAAM,mBAAmB,GAAe,MAAM,CAAC,MAAM,CAAC;IACzD,aAAa,EAAE,SAAS;IACxB,QAAQ,EAAE,OAAO;IACjB,QAAQ,EAAE,GAAG;IACb,aAAa,EAAE,SAAS;IACxB,uBAAuB,EAAE,EAAE;IAC3B,kBAAkB,EAAE,MAAM;IAC1B,eAAe,EAAE,SAAS;IAC1B,cAAc,EAAE,GAAG;CACtB,CAAC,CAAC","sourcesContent":["import type { DocumentNode, DocumentOptions } from '@3kles/richtext-core';\n\nexport type FormatDiagnosticCode =\n | 'invalidInput'\n | 'invalidDocument'\n | 'invalidSelection'\n | 'invalidUnicode'\n | 'resourceLimit'\n | 'malformedHtml'\n | 'removedElement'\n | 'removedAttribute'\n | 'unsafeUrl'\n | 'unsupportedElement'\n | 'unsupportedProfile'\n | 'unsupportedNode'\n | 'unsupportedMark'\n | 'unsupportedAttribute'\n | 'structuralRewrite'\n | 'normalized'\n | 'plainTextLoss'\n | 'diagnosticsTruncated';\n\nexport interface FormatDiagnostic {\n readonly code: FormatDiagnosticCode;\n readonly severity: 'info' | 'warning' | 'error';\n readonly path: readonly (string | number)[];\n /** Describes the operation, never copies attacker-controlled attribute values. */\n readonly message: string;\n}\n\nexport type FormatResult<T> =\n | {\n readonly ok: true;\n readonly value: T;\n readonly lossy: boolean;\n readonly diagnostics: readonly FormatDiagnostic[];\n }\n | { readonly ok: false; readonly diagnostics: readonly FormatDiagnostic[] };\n\nexport interface HtmlLimits {\n readonly maxHtmlLength: number;\n readonly maxNodes: number;\n readonly maxDepth: number;\n readonly maxTextLength: number;\n readonly maxAttributesPerElement: number;\n readonly maxAttributeLength: number;\n readonly maxOutputLength: number;\n readonly maxDiagnostics: number;\n}\n\nexport const DEFAULT_HTML_LIMITS: HtmlLimits = Object.freeze({\n maxHtmlLength: 8_000_000,\n maxNodes: 100_000,\n maxDepth: 128,\n maxTextLength: 1_000_000,\n maxAttributesPerElement: 32,\n maxAttributeLength: 16_384,\n maxOutputLength: 8_000_000,\n maxDiagnostics: 200,\n});\n\nexport interface FormatOptions extends DocumentOptions {\n readonly htmlLimits?: Partial<HtmlLimits>;\n /** Sanitization is explicit in diagnostics. Reject makes every warning fatal. */\n readonly onLoss?: 'sanitize' | 'reject';\n}\n\nexport interface HtmlFragment {\n readonly document: DocumentNode;\n /** An inline fragment can be inserted into the current text block. */\n readonly inline: boolean;\n}\n"]}
package/package.json CHANGED
@@ -1,6 +1,24 @@
1
1
  {
2
2
  "name": "@3kles/richtext-formats",
3
- "version": "0.0.0-stage",
4
- "stub": true,
5
- "description": "Temporary package placeholder for staged publishing"
6
- }
3
+ "version": "1.1.0",
4
+ "private": false,
5
+ "type": "module",
6
+ "sideEffects": false,
7
+ "files": [
8
+ "**/*.js",
9
+ "**/*.js.map",
10
+ "**/*.d.ts",
11
+ "README.md",
12
+ "package.json"
13
+ ],
14
+ "exports": {
15
+ ".": {
16
+ "types": "./public-api.d.ts",
17
+ "import": "./public-api.js"
18
+ }
19
+ },
20
+ "dependencies": {
21
+ "parse5": "8.1.1",
22
+ "@3kles/richtext-core": "1.1.0"
23
+ }
24
+ }
@@ -0,0 +1,8 @@
1
+ export * from './lib/types.js';
2
+ export { importHtml, importHtmlFragment } from './lib/html-import.js';
3
+ export { exportHtml } from './lib/html-export.js';
4
+ export { importPlainText, exportPlainText } from './lib/plain-text.js';
5
+ export { extractSelection, exportSelectionHtml, exportSelectionPlainText } from './lib/selection.js';
6
+ export { importTiptapJson } from './lib/tiptap-import.js';
7
+ export { DEFAULT_TIPTAP_IMPORT_LIMITS } from './lib/tiptap-types.js';
8
+ export type { TiptapImportLimits, TiptapImportOptions, TiptapImportProfile } from './lib/tiptap-types.js';
package/public-api.js ADDED
@@ -0,0 +1,8 @@
1
+ export * from './lib/types.js';
2
+ export { importHtml, importHtmlFragment } from './lib/html-import.js';
3
+ export { exportHtml } from './lib/html-export.js';
4
+ export { importPlainText, exportPlainText } from './lib/plain-text.js';
5
+ export { extractSelection, exportSelectionHtml, exportSelectionPlainText } from './lib/selection.js';
6
+ export { importTiptapJson } from './lib/tiptap-import.js';
7
+ export { DEFAULT_TIPTAP_IMPORT_LIMITS } from './lib/tiptap-types.js';
8
+ //# sourceMappingURL=public-api.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"public-api.js","sourceRoot":"","sources":["../src/public-api.ts"],"names":[],"mappings":"AAAA,cAAc,gBAAgB,CAAC;AAC/B,OAAO,EAAE,UAAU,EAAE,kBAAkB,EAAE,MAAM,sBAAsB,CAAC;AACtE,OAAO,EAAE,UAAU,EAAE,MAAM,sBAAsB,CAAC;AAClD,OAAO,EAAE,eAAe,EAAE,eAAe,EAAE,MAAM,qBAAqB,CAAC;AACvE,OAAO,EAAE,gBAAgB,EAAE,mBAAmB,EAAE,wBAAwB,EAAE,MAAM,oBAAoB,CAAC;AACrG,OAAO,EAAE,gBAAgB,EAAE,MAAM,wBAAwB,CAAC;AAC1D,OAAO,EAAE,4BAA4B,EAAE,MAAM,uBAAuB,CAAC","sourcesContent":["export * from './lib/types.js';\nexport { importHtml, importHtmlFragment } from './lib/html-import.js';\nexport { exportHtml } from './lib/html-export.js';\nexport { importPlainText, exportPlainText } from './lib/plain-text.js';\nexport { extractSelection, exportSelectionHtml, exportSelectionPlainText } from './lib/selection.js';\nexport { importTiptapJson } from './lib/tiptap-import.js';\nexport { DEFAULT_TIPTAP_IMPORT_LIMITS } from './lib/tiptap-types.js';\nexport type { TiptapImportLimits, TiptapImportOptions, TiptapImportProfile } from './lib/tiptap-types.js';\n"]}