commspliant-html-editor 0.0.24 → 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.
- package/README.md +45 -0
- package/dist/capabilities/CapabilitiesContext.d.ts +13 -0
- package/dist/capabilities/CapabilitiesContext.d.ts.map +1 -0
- package/dist/capabilities/capabilitiesChrome.d.ts +5 -0
- package/dist/capabilities/capabilitiesChrome.d.ts.map +1 -0
- package/dist/capabilities/featureFootprint.d.ts +16 -0
- package/dist/capabilities/featureFootprint.d.ts.map +1 -0
- package/dist/capabilities/formatViolation.d.ts +6 -0
- package/dist/capabilities/formatViolation.d.ts.map +1 -0
- package/dist/capabilities/index.d.ts +10 -0
- package/dist/capabilities/index.d.ts.map +1 -0
- package/dist/capabilities/inlineStyle.d.ts +6 -0
- package/dist/capabilities/inlineStyle.d.ts.map +1 -0
- package/dist/capabilities/isFeatureAllowed.d.ts +5 -0
- package/dist/capabilities/isFeatureAllowed.d.ts.map +1 -0
- package/dist/capabilities/isPageLayoutAllowed.d.ts +3 -0
- package/dist/capabilities/isPageLayoutAllowed.d.ts.map +1 -0
- package/dist/capabilities/normalizeContract.d.ts +3 -0
- package/dist/capabilities/normalizeContract.d.ts.map +1 -0
- package/dist/capabilities/resolveEditorCapabilities.d.ts +3 -0
- package/dist/capabilities/resolveEditorCapabilities.d.ts.map +1 -0
- package/dist/capabilities/testContracts.d.ts +4 -0
- package/dist/capabilities/testContracts.d.ts.map +1 -0
- package/dist/capabilities/types.d.ts +103 -0
- package/dist/capabilities/types.d.ts.map +1 -0
- package/dist/capabilities/validateHtml.d.ts +6 -0
- package/dist/capabilities/validateHtml.d.ts.map +1 -0
- package/dist/commspliant-html-editor.css +1 -1
- package/dist/components/Editor.d.ts +1 -1
- package/dist/components/Editor.d.ts.map +1 -1
- package/dist/components/EditorChrome.d.ts +5 -0
- package/dist/components/EditorChrome.d.ts.map +1 -1
- package/dist/components/EditorWorkspaceHost.d.ts +3 -1
- package/dist/components/EditorWorkspaceHost.d.ts.map +1 -1
- package/dist/components/MultiPageVisualSurface.d.ts +1 -0
- package/dist/components/MultiPageVisualSurface.d.ts.map +1 -1
- package/dist/components/VisualSurface.d.ts +2 -0
- package/dist/components/VisualSurface.d.ts.map +1 -1
- package/dist/core/commandTypes.d.ts +3 -1
- package/dist/core/commandTypes.d.ts.map +1 -1
- package/dist/core/commands.d.ts.map +1 -1
- package/dist/core/stripPageChrome.d.ts +3 -0
- package/dist/core/stripPageChrome.d.ts.map +1 -0
- package/dist/i18n/LocaleProvider.d.ts +1 -0
- package/dist/i18n/LocaleProvider.d.ts.map +1 -1
- package/dist/i18n/en.d.ts.map +1 -1
- package/dist/i18n/es.d.ts.map +1 -1
- package/dist/i18n/types.d.ts +21 -0
- package/dist/i18n/types.d.ts.map +1 -1
- package/dist/index.cjs +16 -16
- package/dist/index.d.ts +2 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +8487 -7611
- package/dist/modules/capabilities/CompatibilityPanel.d.ts +8 -0
- package/dist/modules/capabilities/CompatibilityPanel.d.ts.map +1 -0
- package/dist/modules/capabilities/capabilitiesChrome.d.ts +4 -0
- package/dist/modules/capabilities/capabilitiesChrome.d.ts.map +1 -0
- package/dist/modules/capabilities/catalog.d.ts +3 -0
- package/dist/modules/capabilities/catalog.d.ts.map +1 -0
- package/dist/modules/capabilities/commands.d.ts +3 -0
- package/dist/modules/capabilities/commands.d.ts.map +1 -0
- package/dist/modules/capabilities/index.d.ts +4 -0
- package/dist/modules/capabilities/index.d.ts.map +1 -0
- package/dist/modules/contextMenu/ContextMenu.d.ts +2 -1
- package/dist/modules/contextMenu/ContextMenu.d.ts.map +1 -1
- package/dist/modules/format/FontFamilySelect.d.ts.map +1 -1
- package/dist/modules/format/ParagraphPropertiesFields.d.ts.map +1 -1
- package/dist/modules/format/ParagraphStyleList.d.ts.map +1 -1
- package/dist/modules/help/version.d.ts +1 -1
- package/dist/modules/help/version.d.ts.map +1 -1
- package/dist/test/commandContext.d.ts.map +1 -1
- package/dist/toolbar/CustomizeToolbarDialog.d.ts +2 -1
- package/dist/toolbar/CustomizeToolbarDialog.d.ts.map +1 -1
- package/dist/types.d.ts +11 -0
- package/dist/types.d.ts.map +1 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -172,6 +172,8 @@ Give the editor a parent with a definite height (`height: 100%` on a sized ances
|
|
|
172
172
|
| `menuVisible` | `boolean` | `true` | Show the dropdown menu bar. Set `false` to hide it |
|
|
173
173
|
| `toolbarVisible` | `boolean` | `true` | Show the icon toolbar. Set `false` to hide it |
|
|
174
174
|
| `allowedChrome` | `AllowedChrome` | — | Host allowlist of menus and icon-toolbar buttons. Omit to show everything. See [Allowed chrome](#allowed-chrome) |
|
|
175
|
+
| `renderingCapabilities` | `RenderingCapabilities` | — | Contract-driven chrome hiding and HTML validation. Omit for full editor behavior. See [Rendering capabilities](#rendering-capabilities) |
|
|
176
|
+
| `onCapabilitiesValidation` | `(result: CapabilityValidationResult) => void` | — | Fired after debounced validation when `renderingCapabilities` is set |
|
|
175
177
|
| `toolbarPosition` | `'top' \| 'left' \| 'right' \| 'bottom'` | `'top'` | Initial icon-toolbar dock when nothing is persisted. See [Toolbar position](#toolbar-position) |
|
|
176
178
|
| `toolbarPositionPersistence` | `ToolbarPositionPersistence` | — | Host load/save for the icon-toolbar dock. Omit to persist in `localStorage`. See [Toolbar position](#toolbar-position) |
|
|
177
179
|
| `customActions` | `CustomAction[]` | — | Host-defined menu items and/or toolbar buttons. See [Custom actions](#custom-actions) |
|
|
@@ -334,6 +336,49 @@ import { Editor } from 'commspliant-html-editor'
|
|
|
334
336
|
<Editor />
|
|
335
337
|
```
|
|
336
338
|
|
|
339
|
+
### Rendering capabilities
|
|
340
|
+
|
|
341
|
+
Pass `renderingCapabilities` with a versioned contract JSON object (allowed tags, disallowed tags, CSS rules, global rules). The editor **derives** chrome visibility and validation from that object at runtime — there is no built-in “email mode” flag. When the contract changes, chrome and validation update automatically.
|
|
342
|
+
|
|
343
|
+
- Incompatible toolbar items, menu entries, and context-menu commands are **hidden** (not merely disabled).
|
|
344
|
+
- Paragraph style and font-family pickers filter to contract-allowed options.
|
|
345
|
+
- Properties dialog tabs that expose disallowed CSS are hidden.
|
|
346
|
+
- Document HTML is validated on a **debounced** schedule (~750ms after edits) and when View → Compatibility opens.
|
|
347
|
+
- Validation is advisory; editing is not blocked.
|
|
348
|
+
|
|
349
|
+
Omit `renderingCapabilities` for the default full editor with no compatibility UI.
|
|
350
|
+
|
|
351
|
+
`validateHtmlAgainstCapabilities(html, contract)` is also exported for host-side checks outside the editor.
|
|
352
|
+
|
|
353
|
+
`allowedChrome` and `renderingCapabilities` compose: both filters apply.
|
|
354
|
+
|
|
355
|
+
```tsx
|
|
356
|
+
import {
|
|
357
|
+
Editor,
|
|
358
|
+
validateHtmlAgainstCapabilities,
|
|
359
|
+
type RenderingCapabilities,
|
|
360
|
+
type CapabilityValidationResult,
|
|
361
|
+
} from 'commspliant-html-editor'
|
|
362
|
+
|
|
363
|
+
const emailContract: RenderingCapabilities = {
|
|
364
|
+
version: '1.0.0',
|
|
365
|
+
global_rules: { strip_unknown_tags: true },
|
|
366
|
+
html_elements: {
|
|
367
|
+
allowed_tags: [{ tag: 'p', allowed_attributes: ['style'] }],
|
|
368
|
+
disallowed_tags: ['video', 'audio'],
|
|
369
|
+
},
|
|
370
|
+
}
|
|
371
|
+
|
|
372
|
+
<Editor
|
|
373
|
+
renderingCapabilities={emailContract}
|
|
374
|
+
onCapabilitiesValidation={(result: CapabilityValidationResult) => {
|
|
375
|
+
console.log(result.valid, result.errorCount)
|
|
376
|
+
}}
|
|
377
|
+
/>
|
|
378
|
+
|
|
379
|
+
const report = validateHtmlAgainstCapabilities(html, emailContract)
|
|
380
|
+
```
|
|
381
|
+
|
|
337
382
|
### Toolbar position
|
|
338
383
|
|
|
339
384
|
View → Toolbar → Position docks the **icon toolbar** (Top, Left, Right, or Bottom). The dropdown menu bar stays at the top.
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { CapabilityValidationResult, EditorCapabilityProfile } from './types';
|
|
2
|
+
export type CapabilitiesContextValue = {
|
|
3
|
+
profile: EditorCapabilityProfile | undefined;
|
|
4
|
+
validation: CapabilityValidationResult | null;
|
|
5
|
+
refreshValidation: () => void;
|
|
6
|
+
};
|
|
7
|
+
export declare function CapabilitiesProvider({ value, children, }: {
|
|
8
|
+
value: CapabilitiesContextValue;
|
|
9
|
+
children: React.ReactNode;
|
|
10
|
+
}): import("react").JSX.Element;
|
|
11
|
+
export declare function useCapabilitiesContext(): CapabilitiesContextValue;
|
|
12
|
+
export declare function useCapabilitiesProfile(): EditorCapabilityProfile | undefined;
|
|
13
|
+
//# sourceMappingURL=CapabilitiesContext.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"CapabilitiesContext.d.ts","sourceRoot":"","sources":["../../src/capabilities/CapabilitiesContext.tsx"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,0BAA0B,EAAE,uBAAuB,EAAE,MAAM,SAAS,CAAA;AAElF,MAAM,MAAM,wBAAwB,GAAG;IACrC,OAAO,EAAE,uBAAuB,GAAG,SAAS,CAAA;IAC5C,UAAU,EAAE,0BAA0B,GAAG,IAAI,CAAA;IAC7C,iBAAiB,EAAE,MAAM,IAAI,CAAA;CAC9B,CAAA;AAQD,wBAAgB,oBAAoB,CAAC,EACnC,KAAK,EACL,QAAQ,GACT,EAAE;IACD,KAAK,EAAE,wBAAwB,CAAA;IAC/B,QAAQ,EAAE,KAAK,CAAC,SAAS,CAAA;CAC1B,+BAEA;AAED,wBAAgB,sBAAsB,IAAI,wBAAwB,CAEjE;AAED,wBAAgB,sBAAsB,IAAI,uBAAuB,GAAG,SAAS,CAE5E"}
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import { ToolbarLayout } from '../toolbar/types';
|
|
2
|
+
import { EditorCapabilityProfile } from './types';
|
|
3
|
+
export declare function filterCapabilitiesLayout(layout: ToolbarLayout, profile: EditorCapabilityProfile | undefined): ToolbarLayout;
|
|
4
|
+
export declare function isToolbarItemAllowedByCapabilities(itemId: string, profile: EditorCapabilityProfile | undefined): boolean;
|
|
5
|
+
//# sourceMappingURL=capabilitiesChrome.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"capabilitiesChrome.d.ts","sourceRoot":"","sources":["../../src/capabilities/capabilitiesChrome.ts"],"names":[],"mappings":"AAAA,OAAO,EAAiC,KAAK,aAAa,EAAyB,MAAM,kBAAkB,CAAA;AAC3G,OAAO,KAAK,EAAE,uBAAuB,EAAE,MAAM,SAAS,CAAA;AAmCtD,wBAAgB,wBAAwB,CACtC,MAAM,EAAE,aAAa,EACrB,OAAO,EAAE,uBAAuB,GAAG,SAAS,GAC3C,aAAa,CAmBf;AAED,wBAAgB,kCAAkC,CAChD,MAAM,EAAE,MAAM,EACd,OAAO,EAAE,uBAAuB,GAAG,SAAS,GAC3C,OAAO,CAGT"}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
export type FeatureFootprint = {
|
|
2
|
+
tags?: string[];
|
|
3
|
+
cssProperties?: string[];
|
|
4
|
+
attributes?: {
|
|
5
|
+
tag: string;
|
|
6
|
+
names: string[];
|
|
7
|
+
}[];
|
|
8
|
+
dialogTabs?: {
|
|
9
|
+
dialog: 'paragraph' | 'page';
|
|
10
|
+
tabs: string[];
|
|
11
|
+
}[];
|
|
12
|
+
};
|
|
13
|
+
export declare const EDITOR_FEATURE_FOOTPRINTS: Record<string, FeatureFootprint>;
|
|
14
|
+
export declare const DIALOG_TAB_FOOTPRINTS: Record<'paragraph' | 'page', Record<string, FeatureFootprint>>;
|
|
15
|
+
export declare const CONTEXT_MENU_COMMAND_FOOTPRINTS: Record<string, FeatureFootprint>;
|
|
16
|
+
//# sourceMappingURL=featureFootprint.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"featureFootprint.d.ts","sourceRoot":"","sources":["../../src/capabilities/featureFootprint.ts"],"names":[],"mappings":"AAAA,MAAM,MAAM,gBAAgB,GAAG;IAC7B,IAAI,CAAC,EAAE,MAAM,EAAE,CAAA;IACf,aAAa,CAAC,EAAE,MAAM,EAAE,CAAA;IACxB,UAAU,CAAC,EAAE;QAAE,GAAG,EAAE,MAAM,CAAC;QAAC,KAAK,EAAE,MAAM,EAAE,CAAA;KAAE,EAAE,CAAA;IAC/C,UAAU,CAAC,EAAE;QAAE,MAAM,EAAE,WAAW,GAAG,MAAM,CAAC;QAAC,IAAI,EAAE,MAAM,EAAE,CAAA;KAAE,EAAE,CAAA;CAChE,CAAA;AAED,eAAO,MAAM,yBAAyB,EAAE,MAAM,CAAC,MAAM,EAAE,gBAAgB,CA6CtE,CAAA;AAED,eAAO,MAAM,qBAAqB,EAAE,MAAM,CACxC,WAAW,GAAG,MAAM,EACpB,MAAM,CAAC,MAAM,EAAE,gBAAgB,CAAC,CAkBjC,CAAA;AAED,eAAO,MAAM,+BAA+B,EAAE,MAAM,CAAC,MAAM,EAAE,gBAAgB,CAI5E,CAAA"}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { Locale } from '../i18n/types';
|
|
2
|
+
import { CapabilityViolation } from './types';
|
|
3
|
+
export declare function interpolateMessageParams(template: string, params: Record<string, string>): string;
|
|
4
|
+
export declare function formatCapabilityViolationMessage(violation: CapabilityViolation, locale?: Locale): string;
|
|
5
|
+
export declare function formatCapabilityViolationLocation(violation: CapabilityViolation, locale?: Locale): string;
|
|
6
|
+
//# sourceMappingURL=formatViolation.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"formatViolation.d.ts","sourceRoot":"","sources":["../../src/capabilities/formatViolation.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,MAAM,EAAc,MAAM,eAAe,CAAA;AACvD,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,SAAS,CAAA;AAIlD,wBAAgB,wBAAwB,CACtC,QAAQ,EAAE,MAAM,EAChB,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,GAC7B,MAAM,CAKR;AAED,wBAAgB,gCAAgC,CAC9C,SAAS,EAAE,mBAAmB,EAC9B,MAAM,GAAE,MAAa,GACpB,MAAM,CAIR;AAED,wBAAgB,iCAAiC,CAC/C,SAAS,EAAE,mBAAmB,EAC9B,MAAM,GAAE,MAAa,GACpB,MAAM,CAYR"}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
export type { CapabilityValidationResult, CapabilityViolation, CapabilityViolationSeverity, EditorCapabilityProfile, NormalizedContract, RenderingCapabilities, TagRule, } from './types';
|
|
2
|
+
export { normalizeContract } from './normalizeContract';
|
|
3
|
+
export { resolveEditorCapabilities } from './resolveEditorCapabilities';
|
|
4
|
+
export { filterCapabilitiesLayout, isToolbarItemAllowedByCapabilities, } from './capabilitiesChrome';
|
|
5
|
+
export { validateHtmlAgainstCapabilities, validatePagesAgainstCapabilities, } from './validateHtml';
|
|
6
|
+
export { formatCapabilityViolationLocation, formatCapabilityViolationMessage, interpolateMessageParams, } from './formatViolation';
|
|
7
|
+
export { isFeatureAllowed } from './isFeatureAllowed';
|
|
8
|
+
export { isPageLayoutAllowed } from './isPageLayoutAllowed';
|
|
9
|
+
export { EDITOR_FEATURE_FOOTPRINTS, DIALOG_TAB_FOOTPRINTS } from './featureFootprint';
|
|
10
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/capabilities/index.ts"],"names":[],"mappings":"AAAA,YAAY,EACV,0BAA0B,EAC1B,mBAAmB,EACnB,2BAA2B,EAC3B,uBAAuB,EACvB,kBAAkB,EAClB,qBAAqB,EACrB,OAAO,GACR,MAAM,SAAS,CAAA;AAChB,OAAO,EAAE,iBAAiB,EAAE,MAAM,qBAAqB,CAAA;AACvD,OAAO,EAAE,yBAAyB,EAAE,MAAM,6BAA6B,CAAA;AACvE,OAAO,EACL,wBAAwB,EACxB,kCAAkC,GACnC,MAAM,sBAAsB,CAAA;AAC7B,OAAO,EACL,+BAA+B,EAC/B,gCAAgC,GACjC,MAAM,gBAAgB,CAAA;AACvB,OAAO,EACL,iCAAiC,EACjC,gCAAgC,EAChC,wBAAwB,GACzB,MAAM,mBAAmB,CAAA;AAC1B,OAAO,EAAE,gBAAgB,EAAE,MAAM,oBAAoB,CAAA;AACrD,OAAO,EAAE,mBAAmB,EAAE,MAAM,uBAAuB,CAAA;AAC3D,OAAO,EAAE,yBAAyB,EAAE,qBAAqB,EAAE,MAAM,oBAAoB,CAAA"}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
export declare function parseInlineStyle(style: string): Map<string, string>;
|
|
2
|
+
export declare function serializeInlineStyle(styles: Map<string, string>): string;
|
|
3
|
+
export declare function normalizeCssPropertyName(property: string): string;
|
|
4
|
+
export declare function cssValueUsesFormat(value: string, format: string): boolean;
|
|
5
|
+
export declare function parseAllowedOnTagsFromRestrictions(restrictions?: string): string[] | null;
|
|
6
|
+
//# sourceMappingURL=inlineStyle.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"inlineStyle.d.ts","sourceRoot":"","sources":["../../src/capabilities/inlineStyle.ts"],"names":[],"mappings":"AAAA,wBAAgB,gBAAgB,CAAC,KAAK,EAAE,MAAM,GAAG,GAAG,CAAC,MAAM,EAAE,MAAM,CAAC,CAYnE;AAED,wBAAgB,oBAAoB,CAAC,MAAM,EAAE,GAAG,CAAC,MAAM,EAAE,MAAM,CAAC,GAAG,MAAM,CAExE;AAED,wBAAgB,wBAAwB,CAAC,QAAQ,EAAE,MAAM,GAAG,MAAM,CAEjE;AAED,wBAAgB,kBAAkB,CAAC,KAAK,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,GAAG,OAAO,CAgCzE;AAED,wBAAgB,kCAAkC,CAAC,YAAY,CAAC,EAAE,MAAM,GAAG,MAAM,EAAE,GAAG,IAAI,CAKzF"}
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import { FeatureFootprint } from './featureFootprint';
|
|
2
|
+
import { NormalizedContract } from './types';
|
|
3
|
+
export declare function isFeatureAllowed(footprint: FeatureFootprint | undefined, rules: NormalizedContract): boolean;
|
|
4
|
+
export declare function isDialogTabAllowed(_dialog: 'paragraph' | 'page', tab: string, rules: NormalizedContract, tabFootprints: Record<string, FeatureFootprint>): boolean;
|
|
5
|
+
//# sourceMappingURL=isFeatureAllowed.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"isFeatureAllowed.d.ts","sourceRoot":"","sources":["../../src/capabilities/isFeatureAllowed.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,oBAAoB,CAAA;AAC1D,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,SAAS,CAAA;AAkDjD,wBAAgB,gBAAgB,CAC9B,SAAS,EAAE,gBAAgB,GAAG,SAAS,EACvC,KAAK,EAAE,kBAAkB,GACxB,OAAO,CA2BT;AAED,wBAAgB,kBAAkB,CAChC,OAAO,EAAE,WAAW,GAAG,MAAM,EAC7B,GAAG,EAAE,MAAM,EACX,KAAK,EAAE,kBAAkB,EACzB,aAAa,EAAE,MAAM,CAAC,MAAM,EAAE,gBAAgB,CAAC,GAC9C,OAAO,CAIT"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"isPageLayoutAllowed.d.ts","sourceRoot":"","sources":["../../src/capabilities/isPageLayoutAllowed.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAsB,qBAAqB,EAAE,MAAM,SAAS,CAAA;AAexE,wBAAgB,mBAAmB,CAAC,QAAQ,EAAE,qBAAqB,GAAG,OAAO,CAI5E"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"normalizeContract.d.ts","sourceRoot":"","sources":["../../src/capabilities/normalizeContract.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAGV,kBAAkB,EAElB,qBAAqB,EAEtB,MAAM,SAAS,CAAA;AAmChB,wBAAgB,iBAAiB,CAAC,QAAQ,EAAE,qBAAqB,GAAG,kBAAkB,CAoCrF"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"resolveEditorCapabilities.d.ts","sourceRoot":"","sources":["../../src/capabilities/resolveEditorCapabilities.ts"],"names":[],"mappings":"AASA,OAAO,KAAK,EAAE,uBAAuB,EAAE,qBAAqB,EAAE,MAAM,SAAS,CAAA;AAyD7E,wBAAgB,yBAAyB,CACvC,QAAQ,EAAE,qBAAqB,GAC9B,uBAAuB,CAYzB"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"testContracts.d.ts","sourceRoot":"","sources":["../../src/capabilities/testContracts.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,SAAS,CAAA;AAEpD,eAAO,MAAM,0BAA0B,EAAE,qBA8IxC,CAAA;AAED,eAAO,MAAM,uBAAuB,EAAE,qBA+CrC,CAAA"}
|
|
@@ -0,0 +1,103 @@
|
|
|
1
|
+
export type CssPropertyStatus = 'allowed' | 'restricted' | 'disallowed' | 'allowed_with_degradation';
|
|
2
|
+
export type AllowedTagRule = {
|
|
3
|
+
tag: string;
|
|
4
|
+
required_attributes?: Record<string, string>;
|
|
5
|
+
allowed_attributes?: string[];
|
|
6
|
+
disallowed_css?: string[];
|
|
7
|
+
forced_css?: Record<string, string>;
|
|
8
|
+
default_attributes?: Record<string, string>;
|
|
9
|
+
recommended_css?: string[];
|
|
10
|
+
status?: 'restricted';
|
|
11
|
+
notes?: string;
|
|
12
|
+
};
|
|
13
|
+
export type CssPropertyRuleSource = {
|
|
14
|
+
property: string;
|
|
15
|
+
status: CssPropertyStatus;
|
|
16
|
+
support?: Record<string, string>;
|
|
17
|
+
allowed_values?: string[];
|
|
18
|
+
disallowed_values?: string[];
|
|
19
|
+
allowed_on_tags?: string[];
|
|
20
|
+
restrictions?: string;
|
|
21
|
+
fallback?: string | null;
|
|
22
|
+
fallback_required?: string;
|
|
23
|
+
transformation?: string;
|
|
24
|
+
};
|
|
25
|
+
export type RenderingCapabilities = {
|
|
26
|
+
$schema?: string;
|
|
27
|
+
title?: string;
|
|
28
|
+
version?: string;
|
|
29
|
+
description?: string;
|
|
30
|
+
global_rules?: {
|
|
31
|
+
layout_mode?: string;
|
|
32
|
+
require_inlining?: boolean;
|
|
33
|
+
max_container_width_px?: number;
|
|
34
|
+
strip_unknown_tags?: boolean;
|
|
35
|
+
strip_unknown_attributes?: boolean;
|
|
36
|
+
};
|
|
37
|
+
html_elements?: {
|
|
38
|
+
allowed_tags?: AllowedTagRule[];
|
|
39
|
+
disallowed_tags?: string[];
|
|
40
|
+
};
|
|
41
|
+
css_properties?: CssPropertyRuleSource[];
|
|
42
|
+
};
|
|
43
|
+
export type TagRule = {
|
|
44
|
+
tag: string;
|
|
45
|
+
requiredAttributes: Record<string, string>;
|
|
46
|
+
allowedAttributes: string[] | null;
|
|
47
|
+
disallowedCss: string[];
|
|
48
|
+
forcedCss: Record<string, string>;
|
|
49
|
+
defaultAttributes: Record<string, string>;
|
|
50
|
+
status?: 'restricted';
|
|
51
|
+
notes?: string;
|
|
52
|
+
};
|
|
53
|
+
export type NormalizedCssPropertyRule = {
|
|
54
|
+
property: string;
|
|
55
|
+
status: CssPropertyStatus;
|
|
56
|
+
allowedValues: string[] | null;
|
|
57
|
+
disallowedValues: string[] | null;
|
|
58
|
+
allowedOnTags: string[] | null;
|
|
59
|
+
restrictions?: string;
|
|
60
|
+
fallback?: string | null;
|
|
61
|
+
};
|
|
62
|
+
export type NormalizedContract = {
|
|
63
|
+
allowedTagSet: Set<string> | null;
|
|
64
|
+
disallowedTagSet: Set<string>;
|
|
65
|
+
tagRules: Map<string, TagRule>;
|
|
66
|
+
cssPropertyRules: Map<string, NormalizedCssPropertyRule>;
|
|
67
|
+
globalRules: {
|
|
68
|
+
layoutMode?: string;
|
|
69
|
+
requireInlining?: boolean;
|
|
70
|
+
maxContainerWidthPx?: number;
|
|
71
|
+
stripUnknownTags: boolean;
|
|
72
|
+
stripUnknownAttributes: boolean;
|
|
73
|
+
};
|
|
74
|
+
};
|
|
75
|
+
export type CapabilityViolationSeverity = 'error' | 'warning';
|
|
76
|
+
export type CapabilityViolation = {
|
|
77
|
+
code: string;
|
|
78
|
+
severity: CapabilityViolationSeverity;
|
|
79
|
+
messageKey: string;
|
|
80
|
+
messageParams: Record<string, string>;
|
|
81
|
+
selector?: string;
|
|
82
|
+
tag?: string;
|
|
83
|
+
attribute?: string;
|
|
84
|
+
cssProperty?: string;
|
|
85
|
+
pageIndex?: number;
|
|
86
|
+
};
|
|
87
|
+
export type CapabilityValidationResult = {
|
|
88
|
+
valid: boolean;
|
|
89
|
+
errorCount: number;
|
|
90
|
+
warningCount: number;
|
|
91
|
+
violations: CapabilityViolation[];
|
|
92
|
+
};
|
|
93
|
+
export type EditorCapabilityProfile = {
|
|
94
|
+
normalized: NormalizedContract;
|
|
95
|
+
hiddenToolbarItemIds: ReadonlySet<string>;
|
|
96
|
+
hiddenContextMenuCommands: ReadonlySet<string>;
|
|
97
|
+
allowedParagraphTags: readonly string[];
|
|
98
|
+
allowedFontFamilies: string[] | null;
|
|
99
|
+
hiddenDialogTabs: Partial<Record<'paragraph' | 'page', readonly string[]>>;
|
|
100
|
+
maxContainerWidthPx?: number;
|
|
101
|
+
pageLayoutAllowed: boolean;
|
|
102
|
+
};
|
|
103
|
+
//# sourceMappingURL=types.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/capabilities/types.ts"],"names":[],"mappings":"AAAA,MAAM,MAAM,iBAAiB,GACzB,SAAS,GACT,YAAY,GACZ,YAAY,GACZ,0BAA0B,CAAA;AAE9B,MAAM,MAAM,cAAc,GAAG;IAC3B,GAAG,EAAE,MA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E,mBAAmB,CAAC,EAAE,MAAM,CAAA;IAC5B,iBAAiB,EAAE,OAAO,CAAA;CAC3B,CAAA"}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { CapabilityValidationResult, RenderingCapabilities } from './types';
|
|
2
|
+
export declare function validateHtmlAgainstCapabilities(html: string, contract: RenderingCapabilities, options?: {
|
|
3
|
+
pageIndex?: number;
|
|
4
|
+
}): CapabilityValidationResult;
|
|
5
|
+
export declare function validatePagesAgainstCapabilities(pages: string[], contract: RenderingCapabilities): CapabilityValidationResult;
|
|
6
|
+
//# sourceMappingURL=validateHtml.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"validateHtml.d.ts","sourceRoot":"","sources":["../../src/capabilities/validateHtml.ts"],"names":[],"mappings":"AAKA,OAAO,KAAK,EACV,0BAA0B,EAG1B,qBAAqB,EACtB,MAAM,SAAS,CAAA;AAiVhB,wBAAgB,+BAA+B,CAC7C,IAAI,EAAE,MAAM,EACZ,QAAQ,EAAE,qBAAqB,EAC/B,OAAO,CAAC,EAAE;IAAE,SAAS,CAAC,EAAE,MAAM,CAAA;CAAE,GAC/B,0BAA0B,CAY5B;AAED,wBAAgB,gCAAgC,CAC9C,KAAK,EAAE,MAAM,EAAE,EACf,QAAQ,EAAE,qBAAqB,GAC9B,0BAA0B,CAO5B"}
|