Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
31 changes: 0 additions & 31 deletions packages/layout-engine/pm-adapter/src/attributes/tabs.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,37 +22,6 @@ const PX_TO_TWIPS = 15;
*/
const TWIPS_THRESHOLD = 1000;

/**
* Input format from super-editor (nested structure)
*/
interface SuperEditorTabFormat {
tab: {
tabType: string;
pos: number;
leader?: string;
};
}

/**
* Input format from SuperConverter (flat structure)
*/
interface SuperConverterTabFormat {
val?: string;
align?: string;
alignment?: string;
type?: string;
pos?: number;
position?: number;
offset?: number;
originalPos?: number;
leader?: string;
}

/**
* Union of supported input formats
*/
type _TabStopInput = SuperEditorTabFormat | SuperConverterTabFormat;

/**
* Normalize OOXML tab stops from various input formats to canonical TabStop format.
*
Expand Down
78 changes: 0 additions & 78 deletions packages/layout-engine/pm-adapter/src/constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@

import type { TextRun, TrackedChangeKind } from '@superdoc/contracts';
import type { HyperlinkConfig } from './types.js';
import { SectionType } from './types.js';

/**
* Unit conversion constants
Expand All @@ -13,43 +12,6 @@ export const TWIPS_PER_INCH = 1440;
export const PX_PER_INCH = 96;
export const PX_PER_PT = 96 / 72;

/**
* Default typography settings
*/
export const DEFAULT_FONT = 'Arial';
export const DEFAULT_SIZE = 16;

/**
* List formatting defaults
*/
export const DEFAULT_LIST_INDENT_BASE_PX = 24;
export const DEFAULT_LIST_INDENT_STEP_PX = 24;
export const DEFAULT_LIST_HANGING_PX = 18;
export const DEFAULT_NUMBERING_TYPE = 'decimal';
export const DEFAULT_LVL_TEXT = '%1.';

/**
* Locale defaults
*/
export const DEFAULT_DECIMAL_SEPARATOR = '.';

/**
* Section defaults
*/
export const DEFAULT_COLUMN_GAP_INCHES = 0.5; // 720 twips = 0.5 inches

/**
* BiDi indentation defaults
*/
export const MIN_BIDI_CLAMP_INDENT_PX = 1;
export const DEFAULT_BIDI_INDENT_PX = 24;

/**
* Section type defaults
*/
export const DEFAULT_PARAGRAPH_SECTION_TYPE: SectionType = SectionType.NEXT_PAGE; // Word's default when w:type omitted
export const DEFAULT_BODY_SECTION_TYPE: SectionType = SectionType.CONTINUOUS; // Body sectPr doesn't force page break at end

/**
* Tracked changes mark types
*/
Expand Down Expand Up @@ -151,43 +113,3 @@ export const TOKEN_INLINE_TYPES = new Map<string, TextRun['token']>([
['page-number', 'pageNumber'],
['total-page-number', 'totalPageCount'],
]);

/**
* Valid link target values
*/
export const VALID_LINK_TARGETS = new Set(['_blank', '_self', '_parent', '_top']);

/**
* Bullet marker characters
*/
export const BULLET_MARKERS = ['•', '◦', '▪', '‣'];

/**
* Valid wrap types for images/drawings
*/
export const WRAP_TYPES = new Set(['None', 'Square', 'Tight', 'Through', 'TopAndBottom', 'Inline']);

/**
* Valid wrap text values
*/
export const WRAP_TEXT_VALUES = new Set(['bothSides', 'left', 'right', 'largest']);

/**
* Valid horizontal relative positioning values
*/
export const H_RELATIVE_VALUES = new Set(['column', 'page', 'margin']);

/**
* Valid vertical relative positioning values
*/
export const V_RELATIVE_VALUES = new Set(['paragraph', 'page', 'margin']);

/**
* Valid horizontal alignment values
*/
export const H_ALIGN_VALUES = new Set(['left', 'center', 'right']);

/**
* Valid vertical alignment values
*/
export const V_ALIGN_VALUES = new Set(['top', 'center', 'bottom']);
49 changes: 1 addition & 48 deletions packages/layout-engine/pm-adapter/src/converter-context.test.ts
Original file line number Diff line number Diff line change
@@ -1,54 +1,7 @@
import { describe, expect, it } from 'vitest';
import { hasParagraphStyleContext, hasTableStyleContext } from './converter-context.js';
import { hasTableStyleContext } from './converter-context.js';
import type { ConverterContext } from './converter-context.js';

describe('hasParagraphStyleContext', () => {
it('should return false when context is undefined', () => {
const result = hasParagraphStyleContext(undefined);
expect(result).toBe(false);
});

it('should return true when context.docx is present but context.numbering is undefined', () => {
const context: ConverterContext = {
docx: { styles: {}, docDefaults: {} },
};
const result = hasParagraphStyleContext(context);
expect(result).toBe(true);
});

it('should return true when both context.docx and context.numbering are present', () => {
const context: ConverterContext = {
docx: { styles: {}, docDefaults: {} },
numbering: { definitions: {}, abstracts: {} },
};
const result = hasParagraphStyleContext(context);
expect(result).toBe(true);
});

it('should return false when only context.numbering is present', () => {
const context: ConverterContext = {
numbering: { definitions: {}, abstracts: {} },
};
const result = hasParagraphStyleContext(context);
expect(result).toBe(false);
});

it('should return false when context is empty object', () => {
const context: ConverterContext = {};
const result = hasParagraphStyleContext(context);
expect(result).toBe(false);
});

it('should return false when context.docx is undefined', () => {
const context: ConverterContext = {
docx: undefined,
numbering: { definitions: {}, abstracts: {} },
};
const result = hasParagraphStyleContext(context);
expect(result).toBe(false);
});
});

describe('hasTableStyleContext', () => {
it('should return false when context is undefined', () => {
const result = hasTableStyleContext(undefined);
Expand Down
29 changes: 0 additions & 29 deletions packages/layout-engine/pm-adapter/src/converter-context.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,19 +11,6 @@
import type { ParagraphSpacing } from '@superdoc/contracts';
import type { NumberingProperties, StylesDocumentProperties, TableInfo } from '@superdoc/style-engine/ooxml';

export type ConverterNumberingContext = {
definitions?: Record<string, unknown>;
abstracts?: Record<string, unknown>;
};

export type ConverterLinkedStyle = {
id: string;
definition?: {
styles?: Record<string, unknown>;
attrs?: Record<string, unknown>;
};
};

/**
* Paragraph properties from a table style that should be applied to
* paragraphs inside table cells as part of the OOXML style cascade.
Expand All @@ -34,8 +21,6 @@ export type TableStyleParagraphProps = {

export type ConverterContext = {
docx?: Record<string, unknown>;
numbering?: ConverterNumberingContext;
linkedStyles?: ConverterLinkedStyle[];
translatedNumbering: NumberingProperties;
translatedLinkedStyles: StylesDocumentProperties;
/**
Expand All @@ -61,20 +46,6 @@ export type ConverterContext = {
backgroundColor?: string;
};

/**
* Guard that checks whether the converter context includes DOCX data
* required for paragraph style hydration.
*
* Paragraph hydration needs DOCX structures so it can follow style
* inheritance chains via resolveParagraphProperties. Numbering is optional
* since documents without lists should still get docDefaults spacing.
*/
export const hasParagraphStyleContext = (
context?: ConverterContext,
): context is ConverterContext & { docx: Record<string, unknown> } => {
return Boolean(context?.docx);
};

/**
* Guard that checks whether DOCX data is available for table style lookups.
*
Expand Down
9 changes: 0 additions & 9 deletions packages/layout-engine/pm-adapter/src/internal.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -62,15 +62,7 @@ vi.mock('./sections/index.js', () => {
});

vi.mock('./utilities.js', () => ({
pxToPt: vi.fn((px) => (px != null ? px / 1.333 : undefined)),
pickNumber: vi.fn((value) => (typeof value === 'number' ? value : undefined)),
pickDecimalSeparator: vi.fn((value) => {
if (typeof value === 'string' && (value.trim() === '.' || value.trim() === ',')) {
return value.trim();
}
return undefined;
}),
pickLang: vi.fn((value) => (typeof value === 'string' ? value.toLowerCase() : undefined)),
normalizePrefix: vi.fn((value) => (value ? String(value) : '')),
buildPositionMap: vi.fn(() => new WeakMap()),
createBlockIdGenerator: vi.fn((prefix = '') => {
Expand Down Expand Up @@ -646,7 +638,6 @@ describe('internal', () => {

toFlowBlocks(doc);

// pickLang should be called with the lang value
expect(handleParagraphNode).toHaveBeenCalled();
});

Expand Down
3 changes: 1 addition & 2 deletions packages/layout-engine/pm-adapter/src/internal.ts
Original file line number Diff line number Diff line change
Expand Up @@ -66,15 +66,14 @@ export const nodeHandlers: Record<string, NodeHandler> = {
documentSection: handleDocumentSectionNode,
table: handleTableNode,
documentPartObject: handleDocumentPartObjectNode,
// orderedList and bulletList removed - list handling moved out of layout-engine
image: handleImageNode,
vectorShape: handleVectorShapeNode,
shapeGroup: handleShapeGroupNode,
shapeContainer: handleShapeContainerNode,
shapeTextbox: handleShapeTextboxNode,
};

export const converters: NestedConverters = {
const converters: NestedConverters = {
contentBlockNodeToDrawingBlock,
imageNodeToBlock,
vectorShapeNodeToDrawingBlock,
Expand Down
10 changes: 0 additions & 10 deletions packages/layout-engine/pm-adapter/src/node-handlers/index.ts

This file was deleted.

Loading
Loading