Skip to content

Commit

Permalink
Merge branch 'master' into u/jisong/improve2_0
Browse files Browse the repository at this point in the history
  • Loading branch information
JiuqingSong committed Jun 29, 2023
2 parents 7c70672 + 2ede8ef commit b8e164f
Show file tree
Hide file tree
Showing 5 changed files with 90 additions and 73 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -110,11 +110,11 @@ export const handleTable: ContentModelBlockHandler<ContentModelTable> = (
}

if (!cell.cachedElement || (cell.format.useBorderBox && hasMetadata(table))) {
if (width > 0) {
if (width > 0 && !td.style.width) {
td.style.width = width + 'px';
}

if (height > 0) {
if (height > 0 && !td.style.height) {
td.style.height = height + 'px';
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -546,4 +546,27 @@ describe('handleTable', () => {

expect(parent.innerHTML).toBe('<table><tbody><tr id="tr1"><td></td></tr></tbody></table>');
});

it('TD already has width and height', () => {
const parent = document.createElement('div');
const table = createTable(1, {});
const cell = createTableCell();

table.rows[0].cells.push(cell);

const td = document.createElement('td');
cell.cachedElement = td;

td.style.width = '20px';
td.style.height = '40px';

table.widths = [100];
table.rows[0].height = 200;

handleTable(document, parent, table, context, null);

expect(parent.innerHTML).toBe(
'<table><tbody><tr><td style="width: 20px; height: 40px;"></td></tr></tbody></table>'
);
});
});
69 changes: 65 additions & 4 deletions packages-content-model/roosterjs-content-model-editor/lib/index.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,68 @@
export * from './publicTypes/index';
export * from './publicApi/index';
export { ContentModelFormatState } from './publicTypes/format/formatState/ContentModelFormatState';
export { ImageFormatState } from './publicTypes/format/formatState/ImageFormatState';
export { Border } from './publicTypes/interface/Border';
export {
CreateEditorContext,
ContentModelCoreApiMap,
ContentModelEditorCore,
CreateContentModel,
SetContentModel,
} from './publicTypes/ContentModelEditorCore';
export {
default as ContentModelBeforePasteEvent,
ContentModelBeforePasteEventData,
CompatibleContentModelBeforePasteEvent,
} from './publicTypes/event/ContentModelBeforePasteEvent';
export { IContentModelEditor, ContentModelEditorOptions } from './publicTypes/IContentModelEditor';
export { InsertPoint } from './publicTypes/selection/InsertPoint';
export { TableSelectionContext } from './publicTypes/selection/TableSelectionContext';

export { default as insertTable } from './publicApi/table/insertTable';
export { default as formatTable } from './publicApi/table/formatTable';
export { default as setTableCellShade } from './publicApi/table/setTableCellShade';
export { default as editTable } from './publicApi/table/editTable';
export { default as toggleBullet } from './publicApi/list/toggleBullet';
export { default as toggleNumbering } from './publicApi/list/toggleNumbering';
export { default as toggleBold } from './publicApi/segment/toggleBold';
export { default as toggleItalic } from './publicApi/segment/toggleItalic';
export { default as toggleUnderline } from './publicApi/segment/toggleUnderline';
export { default as toggleStrikethrough } from './publicApi/segment/toggleStrikethrough';
export { default as toggleSubscript } from './publicApi/segment/toggleSubscript';
export { default as toggleSuperscript } from './publicApi/segment/toggleSuperscript';
export { default as setBackgroundColor } from './publicApi/segment/setBackgroundColor';
export { default as setFontName } from './publicApi/segment/setFontName';
export { default as setFontSize } from './publicApi/segment/setFontSize';
export { default as setTextColor } from './publicApi/segment/setTextColor';
export { default as changeFontSize } from './publicApi/segment/changeFontSize';
export { default as applySegmentFormat } from './publicApi/segment/applySegmentFormat';
export { default as changeCapitalization } from './publicApi/segment/changeCapitalization';
export { default as insertImage } from './publicApi/image/insertImage';
export { default as setListStyle } from './publicApi/list/setListStyle';
export { default as setListStartNumber } from './publicApi/list/setListStartNumber';
export { default as hasSelectionInBlock } from './publicApi/selection/hasSelectionInBlock';
export { default as hasSelectionInSegment } from './publicApi/selection/hasSelectionInSegment';
export { default as hasSelectionInBlockGroup } from './publicApi/selection/hasSelectionInBlockGroup';
export { default as setIndentation } from './publicApi/block/setIndentation';
export { default as setAlignment } from './publicApi/block/setAlignment';
export { default as setDirection } from './publicApi/block/setDirection';
export { default as setHeaderLevel } from './publicApi/block/setHeaderLevel';
export { default as toggleBlockQuote } from './publicApi/block/toggleBlockQuote';
export { default as setSpacing } from './publicApi/block/setSpacing';
export { default as setImageBorder } from './publicApi/image/setImageBorder';
export { default as setImageBoxShadow } from './publicApi/image/setImageBoxShadow';
export { default as changeImage } from './publicApi/image/changeImage';
export { default as getFormatState } from './publicApi/format/getFormatState';
export { default as getSegmentFormat } from './publicApi/format/getSegmentFormat';
export { default as applyPendingFormat } from './publicApi/format/applyPendingFormat';
export { default as clearFormat } from './publicApi/format/clearFormat';
export { default as insertLink } from './publicApi/link/insertLink';
export { default as removeLink } from './publicApi/link/removeLink';
export { default as adjustLinkSelection } from './publicApi/link/adjustLinkSelection';
export { default as setImageAltText } from './publicApi/image/setImageAltText';
export { default as adjustImageSelection } from './publicApi/image/adjustImageSelection';
export { default as setParagraphMargin } from './publicApi/block/setParagraphMargin';
export { default as toggleCode } from './publicApi/segment/toggleCode';
export { default as paste } from './publicApi/utils/paste';

export { default as ContentModelEditor } from './editor/ContentModelEditor';
export { default as isContentModelEditor } from './editor/isContentModelEditor';
Expand All @@ -16,5 +79,3 @@ export { combineBorderValue, extractBorderValues } from './domUtils/borderValues
export { updateImageMetadata } from './domUtils/metadata/updateImageMetadata';
export { updateTableCellMetadata } from './domUtils/metadata/updateTableCellMetadata';
export { updateTableMetadata } from './domUtils/metadata/updateTableMetadata';

export { IContentModelEditor, ContentModelEditorOptions } from './publicTypes/IContentModelEditor';

This file was deleted.

This file was deleted.

0 comments on commit b8e164f

Please sign in to comment.