Skip to content

Commit

Permalink
Version bump 8.35.2 to 8.36.0 (#1403)
Browse files Browse the repository at this point in the history
* WIP

* WIP

* enable flight

* adapt Image Edit to Image Selection

* typo

* compare files

* add image selection

* remove alignment

* typo

* if click in image, select it

* remove check

* picker plugin tests

* setEditing

* change variable names

* WIP

* WIP

* WIP

* change to mouse up

* remove comment

* remove comment

* fix copy/paste

* dispose properties

* add test

* Enable strict mode for color utils (#1319)

* use queryelements

* Change the order of karma plugins (#1371)

* Remove empty div Between list when backspacing. (#1365)

* init

* Check if prevElement is List, to avoid perf issue

* remove debugger

* Fix dependency iss

* Do not merge if lists have different type

* use Editor Document

* Make strings constant

* add checker

* Content Model Bug fix: part 1 (#1370)

* Bug bash bug fix

* fix test

* improve

* WIP

* new update wrapper

* Content Model bug fix part 2: Support hyperlink and better support align (#1376)

* Bug bash bug fix

* fix test

* improve

* Bug bash bug fix 2: Better support align

* Fix test

* Improve hyper link

* improve

* add null check

* add const to metadata

* add null check and list chain

* refactor image edit

* Apply default format on SPAN instead of DIV (#1380)

* Apply default format in SPAN

* Enable in demo site by default

* fix test

* refactor

* Fix changing font size doesn't work for empty selections (#1384)

Co-authored-by: Ying Zhong <[email protected]>

* refactor

* Content Model Bug bash fix part 3: More content fidelity fixes (#1378)

* Bug bash bug fix

* fix test

* improve

* Bug bash bug fix 2: Better support align

* Fix test

* Improve hyper link

* improve

* Content Model bug fix part 3: More content fidelity fix

* Fix more bugs

* add more test

* use remove global styles

* use clone to applay changes

* refactor

* Content Model Bug bash fix part 4: More content fidelity fixes (#1386)

* Bug bash bug fix

* fix test

* improve

* Bug bash bug fix 2: Better support align

* Fix test

* Improve hyper link

* improve

* Content Model bug fix part 3: More content fidelity fix

* Fix more bugs

* add more test

* More fidelity fixes

* fix test

* Content Model: Better support dataset and metadata step 1 of 5: New dataset and metadata API, and apply to image (#1388)

* Content Model: Better support dataset and metadata step 1: New dataset and metadata API, and apply to image

* fix build

* Content Model: Better support dataset and metadata step 2 of 5: Port Table Cell metadata (#1389)

* Content Model: Better support dataset and metadata step 1: New dataset and metadata API, and apply to image

* fix build

* Content Model metadata step 2

* Content Model: Better support dataset and metadata step 3 of 5: Port Table metadata (#1390)

* Content Model: Better support dataset and metadata step 1: New dataset and metadata API, and apply to image

* fix build

* Content Model metadata step 2

* Content Model Metadata step 3

* fix build

* Content Model: Better support dataset and metadata step 4 of 5: Port list metadata (#1391)

* Content Model: Better support dataset and metadata step 1: New dataset and metadata API, and apply to image

* fix build

* Content Model metadata step 2

* Content Model Metadata step 3

* fix build

* Content Model metadata step 4

* fix test

* Content Model: Better support dataset and metadata step 5 of 5: Port hyperlink dataset (#1393)

* Content Model: Better support dataset and metadata step 1: New dataset and metadata API, and apply to image

* fix build

* Content Model metadata step 2

* Content Model Metadata step 3

* fix build

* Content Model metadata step 4

* fix test

* Content Model metadata step 5

* fix build

* Fix image zoom scale while editing (#1383)

* fix zoom sacle

* WIP

* fix zoom

* remove scale property

Co-authored-by: Jiuqing Song <[email protected]>

* Graduate experimental features (#1385)

* graduate experimental features

* graduate experimental features

* deprecate

Co-authored-by: Jiuqing Song <[email protected]>

* More ImageSelection plugin into core plugin (#1395)

* Content Model: Provide default settings in context so overriding functions can call it (#1396)

* Provide default settings in context so overriding functions can call it

* fix build

* Remove unused code

* Content Model: reorganize some code (#1394)

* Content Model: Better support dataset and metadata step 1: New dataset and metadata API, and apply to image

* fix build

* Content Model metadata step 2

* Content Model Metadata step 3

* fix build

* Content Model metadata step 4

* fix test

* Content Model metadata step 5

* fix build

* Reorg Content Model code

* Bump socket.io-parser from 4.0.4 to 4.0.5 (#1397)

Bumps [socket.io-parser](https://github.com/socketio/socket.io-parser) from 4.0.4 to 4.0.5.
- [Release notes](https://github.com/socketio/socket.io-parser/releases)
- [Changelog](https://github.com/socketio/socket.io-parser/blob/main/CHANGELOG.md)
- [Commits](socketio/socket.io-parser@4.0.4...4.0.5)

---
updated-dependencies:
- dependency-name: socket.io-parser
  dependency-type: indirect
...

Signed-off-by: dependabot[bot] <[email protected]>

Signed-off-by: dependabot[bot] <[email protected]>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>

* Fix list style issue (#1399)

* Fix list style issue

* fix bug and test cases

* Bump minimatch from 3.0.4 to 3.1.2 (#1398)

Bumps [minimatch](https://github.com/isaacs/minimatch) from 3.0.4 to 3.1.2.
- [Release notes](https://github.com/isaacs/minimatch/releases)
- [Commits](isaacs/minimatch@v3.0.4...v3.1.2)

---
updated-dependencies:
- dependency-name: minimatch
  dependency-type: indirect
...

Signed-off-by: dependabot[bot] <[email protected]>

Signed-off-by: dependabot[bot] <[email protected]>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Co-authored-by: Jiuqing Song <[email protected]>

* Content Model: Fix two list issues (#1400)

* Content Model: Fix two list issues

* Fix implicit

* Apply default format on SPAN instead of DIV (#1380)

* Apply default format in SPAN

* Enable in demo site by default

* fix test

* version bump 8.36.0

* bumped Content model version too.

Signed-off-by: dependabot[bot] <[email protected]>
Co-authored-by: Júlia Roldi <[email protected]>
Co-authored-by: Julia Roldi <[email protected]>
Co-authored-by: Jiuqing Song <[email protected]>
Co-authored-by: Bryan Valverde U <[email protected]>
Co-authored-by: Gnohz Gniy <[email protected]>
Co-authored-by: Ying Zhong <[email protected]>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
  • Loading branch information
8 people committed Jun 16, 2023
1 parent f6d6a75 commit 2156518
Show file tree
Hide file tree
Showing 58 changed files with 2,164 additions and 390 deletions.
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import * as React from 'react';
import { ButtonGroup } from './ButtonGroup';
import { ContentModelJson } from './model/ContentModelJson';
import { ContentModelWithDataset, DatasetFormat } from 'roosterjs-content-model';
import { css } from '@fluentui/react/lib/Utilities';
import { getObjectKeys } from 'roosterjs-editor-dom';
import { useProperty } from '../hooks/useProperty';
Expand Down
Original file line number Diff line number Diff line change
@@ -1,13 +1,19 @@
import * as Color from 'color';
import { createColorFormatRenderer } from '../utils/createColorFormatRender';
import { FormatRenderer } from '../utils/FormatRenderer';
import { HyperLinkColorPlaceholder } from 'roosterjs-content-model/lib/formatHandlers/utils/defaultStyles';
import { TextColorFormat } from 'roosterjs-content-model';

export const TextColorFormatRenderer: FormatRenderer<TextColorFormat> = createColorFormatRenderer<
TextColorFormat
>(
'Text color',
format => (format.textColor ? Color(format.textColor).hex() : ''),
format =>
format.textColor == HyperLinkColorPlaceholder
? format.textColor
: format.textColor
? Color(format.textColor).hex()
: '',
(format, value) => {
format.textColor = value;
return undefined;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,15 +56,23 @@ export function ContentModelTableView(props: { table: ContentModelTable }) {
}, [table]);

const getFormat = React.useCallback(() => {
return <FormatView format={table.format} renderers={TableFormatRenderers} />;
}, [table.format]);

const getMetadata = React.useCallback(() => {
return (
<>
<MetadataView
model={table}
renderers={TableMetadataFormatRenders}
updater={updateTableMetadata}
/>
<div>
<button onClick={onApplyTableFormat}>Apply table format</button>
</div>
<FormatView format={table.format} renderers={TableFormatRenderers} />
</>
);
}, [table.format]);
}, [table]);

const getMetadata = React.useCallback(() => {
return (
Expand Down
1 change: 0 additions & 1 deletion demo/scripts/controls/getToggleablePlugins.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ import { CutPasteListChain } from 'roosterjs-editor-plugins/lib/CutPasteListChai
import { EditorPlugin } from 'roosterjs-editor-types';
import { HyperLink } from 'roosterjs-editor-plugins/lib/HyperLink';
import { ImageEdit } from 'roosterjs-editor-plugins/lib/ImageEdit';
import { ImageSelection } from 'roosterjs-editor-plugins';
import { Paste } from 'roosterjs-editor-plugins/lib/Paste';
import { TableCellSelection } from 'roosterjs-editor-plugins/lib/TableCellSelection';
import { TableResize } from 'roosterjs-editor-plugins/lib/TableResize';
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,9 @@ const generalSegmentProcessor: ElementProcessor<HTMLElement> = (group, element,
addDecorators(segment, context);
addSegment(group, segment);

addLink(segment, context.link);
addSegment(group, segment);

stackFormat(
context,
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -143,6 +143,12 @@ export const tableProcessor: ElementProcessor<HTMLTableElement> = (
context.segmentFormat,
context
);
parseFormat(
td,
context.formatParsers.dataset,
cell.dataset,
context
);

const cellFormat: ContentModelTableCellFormat = {
...context.blockFormat,
Expand Down

This file was deleted.

10 changes: 10 additions & 0 deletions packages/roosterjs-content-model/lib/domUtils/hasSpacesOnly.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
// A regex to match text that only has space and CR
// We use real space char " " (\u0020) here but not "\s" since "\s" will also match "&nbsp;" (\u00A0) which is something we need to keep
const SPACE_TEXT_REGEX = /^[\r\n\t ]*$/;

/**
* @internal
*/
export function hasSpacesOnly(txt: string): boolean {
return SPACE_TEXT_REGEX.test(txt);
}
Original file line number Diff line number Diff line change
Expand Up @@ -198,23 +198,16 @@ const defaultFormatKeysPerCategory: {
'backgroundColor',
],
segmentOnBlock: ['fontFamily', 'fontSize', 'underline', 'italic', 'bold', 'textColor'],
tableCell: [
'border',
'borderBox',
'backgroundColor',
'padding',
'direction',
'verticalAlign',
'tableCellMetadata',
],
tableCell: ['border', 'borderBox', 'backgroundColor', 'padding', 'direction', 'verticalAlign'],
table: [
'id',
'border',
'borderBox',
'tableMetadata',
'tableSpacing',
'margin',
'backgroundColor',
'display',
'direction',
],
};

Expand Down
8 changes: 4 additions & 4 deletions packages/roosterjs-content-model/lib/modelApi/block/indent.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import { ContentModelBlockGroup } from '../../publicTypes/block/group/ContentModelBlockGroup';
import { ContentModelDocument } from '../../publicTypes/block/group/ContentModelDocument';
import { ContentModelListItem } from '../../publicTypes/block/group/ContentModelListItem';
import { ContentModelBlockGroup } from '../../publicTypes/group/ContentModelBlockGroup';
import { ContentModelDocument } from '../../publicTypes/group/ContentModelDocument';
import { ContentModelListItem } from '../../publicTypes/group/ContentModelListItem';
import { ContentModelListItemLevelFormat } from '../../publicTypes/format/ContentModelListItemLevelFormat';
import { ContentModelQuote } from '../../publicTypes/block/group/ContentModelQuote';
import { ContentModelQuote } from '../../publicTypes/group/ContentModelQuote';
import { createQuote } from '../creators/createQuote';
import { getOperationalBlocks } from '../common/getOperationalBlocks';
import { getSelectedParagraphs } from '../selection/getSelectedParagraphs';
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { ContentModelDocument } from '../../publicTypes/block/group/ContentModelDocument';
import { ContentModelListItem } from '../../publicTypes/block/group/ContentModelListItem';
import { ContentModelQuote } from '../../publicTypes/block/group/ContentModelQuote';
import { ContentModelDocument } from '../../publicTypes/group/ContentModelDocument';
import { ContentModelListItem } from '../../publicTypes/group/ContentModelListItem';
import { ContentModelQuote } from '../../publicTypes/group/ContentModelQuote';
import { createQuote } from '../creators/createQuote';
import { getOperationalBlocks } from '../common/getOperationalBlocks';
import { getSelectedParagraphs } from '../selection/getSelectedParagraphs';
Expand Down
14 changes: 14 additions & 0 deletions packages/roosterjs-content-model/lib/modelApi/common/addLink.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
import { ContentModelLink } from '../../publicTypes/decorator/ContentModelLink';
import { ContentModelSegment } from '../../publicTypes/segment/ContentModelSegment';

/**
* @internal
*/
export function addLink(segment: ContentModelSegment, link: ContentModelLink) {
if (link.format.href) {
segment.link = {
format: { ...link.format },
dataset: { ...link.dataset },
};
}
}
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { ContentModelBlockGroup } from '../../publicTypes/block/group/ContentModelBlockGroup';
import { ContentModelBlockGroupBase } from '../../publicTypes/block/group/ContentModelBlockGroupBase';
import { ContentModelBlockGroup } from '../../publicTypes/group/ContentModelBlockGroup';
import { ContentModelBlockGroupBase } from '../../publicTypes/group/ContentModelBlockGroupBase';
import { ContentModelBlockGroupType } from '../../publicTypes/enum/BlockGroupType';
import { SelectedParagraphWithPath } from '../selection/getSelectedParagraphs';

Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { ContentModelDocument } from '../../publicTypes/block/group/ContentModelDocument';
import { ContentModelListItem } from '../../publicTypes/block/group/ContentModelListItem';
import { ContentModelDocument } from '../../publicTypes/group/ContentModelDocument';
import { ContentModelListItem } from '../../publicTypes/group/ContentModelListItem';
import { getOperationalBlocks } from '../common/getOperationalBlocks';
import { getSelectedParagraphs } from '../selection/getSelectedParagraphs';
import { isBlockGroupOfType } from '../common/isBlockGroupOfType';
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
import { BulletListType, NumberingListType } from 'roosterjs-editor-types';
import { ContentModelWithDataset } from '../../publicTypes/format/ContentModelWithDataset';
import { createNumberDefinition, createObjectDefinition } from 'roosterjs-editor-dom';
import { ListMetadataFormat } from '../../publicTypes/format/formatParts/ListMetadataFormat';
import { updateMetadata } from './updateMetadata';

const ListStyleDefinitionMetadata = createObjectDefinition<ListMetadataFormat>(
{
orderedStyleType: createNumberDefinition(
true /** isOptional */,
undefined /** value **/,
NumberingListType.Min,
NumberingListType.Max
),
unorderedStyleType: createNumberDefinition(
true /** isOptional */,
undefined /** value **/,
BulletListType.Min,
BulletListType.Max
),
},
true /** isOptional */,
true /** allowNull */
);

/**
* @internal
* Update list metadata with a callback
* @param list The list Content Model (metadata holder)
* @param callback The callback function used for updating metadata
*/
export function updateListMetadata(
list: ContentModelWithDataset<ListMetadataFormat>,
callback: (format: ListMetadataFormat | null) => ListMetadataFormat | null
) {
updateMetadata(list, callback, ListStyleDefinitionMetadata);
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
import { ContentModelWithDataset } from '../../publicTypes/format/ContentModelWithDataset';
import { Definition } from 'roosterjs-editor-types';
import { validate } from 'roosterjs-editor-dom';

const EditingInfoDatasetName = 'editingInfo';

/**
* @internal
*/
export function updateMetadata<T>(
model: ContentModelWithDataset<T>,
callback: (metadata: T | null) => T | null,
definition?: Definition<T>
) {
const metadataString = model.dataset[EditingInfoDatasetName];
let obj: T | null = null;

try {
obj = JSON.parse(metadataString) as T;
} catch {}

if (definition && !validate(obj, definition)) {
obj = null;
}

obj = callback(obj);

if (!obj) {
delete model.dataset[EditingInfoDatasetName];
} else if (!definition || validate(obj, definition)) {
model.dataset[EditingInfoDatasetName] = JSON.stringify(obj);
}
}

/**
* @internal Check if the given model has metadata
*/
export function hasMetadata<T>(model: ContentModelWithDataset<T>): boolean {
return !!model.dataset[EditingInfoDatasetName];
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
import { ContentModelTableCell } from '../../publicTypes/group/ContentModelTableCell';
import { createBooleanDefinition, createObjectDefinition } from 'roosterjs-editor-dom';
import { TableCellMetadataFormat } from 'roosterjs-editor-types';
import { updateMetadata } from './updateMetadata';

const TableCellMetadataFormatDefinition = createObjectDefinition<Required<TableCellMetadataFormat>>(
{
bgColorOverride: createBooleanDefinition(true /** isOptional */),
},
false /* isOptional */,
true /** allowNull */
);

/**
* @internal
* Update table cell metadata with a callback
* @param cell The table cell Content Model
* @param callback The callback function used for updating metadata
*/
export function updateTableCellMetadata(
cell: ContentModelTableCell,
callback: (format: TableCellMetadataFormat | null) => TableCellMetadataFormat | null
) {
updateMetadata(cell, callback, TableCellMetadataFormatDefinition);
}
Loading

0 comments on commit 2156518

Please sign in to comment.