Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

RoosterJs 8.32.0 #1290

Merged
merged 64 commits into from
Sep 23, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
64 commits
Select commit Hold shift + click to select a range
2c17197
test
juliaroldi Sep 6, 2022
de97505
Merge branch 'master' of https://github.com/microsoft/roosterjs
juliaroldi Sep 6, 2022
4574c42
Merge branch 'master' of https://github.com/microsoft/roosterjs
juliaroldi Sep 9, 2022
d2ed2ca
Move normalizeBlockquote from normalizePlugin to Format API (#1250)
BryanValverdeU Sep 12, 2022
0e9b92f
Content Model customization step 1: Reorganize some code (#1252)
JiuqingSong Sep 12, 2022
309973b
Merge branch 'master' of https://github.com/microsoft/roosterjs
juliaroldi Sep 13, 2022
c807e3f
Content Model customization step 2: Customize element processor and d…
JiuqingSong Sep 14, 2022
172abc3
fix: toggling inner list type #1258
tshibley Sep 14, 2022
2facf0b
Add getVisibleViewport function and hide TableSelector when is not in…
BryanValverdeU Sep 15, 2022
f415f47
select image api
juliaroldi Sep 15, 2022
e4a2b37
Merge branch 'master' of https://github.com/microsoft/roosterjs into …
juliaroldi Sep 15, 2022
39752b8
remove code
juliaroldi Sep 15, 2022
18d5021
Content Model customization step 3: Customize format handlers (#1255)
JiuqingSong Sep 15, 2022
52c26a2
Fix Cell Shade metadata (#1263)
BryanValverdeU Sep 16, 2022
f0f765f
Merge branch 'master' of https://github.com/microsoft/roosterjs
juliaroldi Sep 16, 2022
770d5a0
fix maintain list chain
juliaroldi Sep 16, 2022
e4cc216
Remove Table Selection on Delete Row/Columns (#1260)
BryanValverdeU Sep 16, 2022
5391146
ContentModel: BlockGroup is not Block (#1259)
JiuqingSong Sep 17, 2022
c3314b2
fix comments
juliaroldi Sep 19, 2022
f17e7e7
Merge branch 'master' into u/juliaroldi/fix-auto-numbering-triggers
juliaroldi Sep 19, 2022
7aa7566
Merge pull request #1267 from microsoft/u/juliaroldi/fix-auto-numberi…
juliaroldi Sep 19, 2022
935cd09
Content Model: Add a temporary processor for DIV and SPAN (#1268)
JiuqingSong Sep 19, 2022
9ce1bd9
fix selectImageApi
juliaroldi Sep 19, 2022
a097ec2
Merge branch 'master' of https://github.com/microsoft/roosterjs into …
juliaroldi Sep 19, 2022
c6064bf
add initial test
Sep 20, 2022
1635031
refactor 1
Sep 20, 2022
6a8fbd7
improve
Sep 20, 2022
df30f45
remove nest
Sep 20, 2022
9cb9c46
update comment
Sep 20, 2022
620a9c6
Try fix Unstable test by fixing clean up after each test #1277
BryanValverdeU Sep 20, 2022
832571b
selectImageApi
juliaroldi Sep 20, 2022
6f61956
tag
juliaroldi Sep 20, 2022
148c8dd
Merge branch 'master' into u/juliaroldi/selectImageApi
juliaroldi Sep 20, 2022
d969c2a
Add debug unit test commands to launch.json file #1278
BryanValverdeU Sep 20, 2022
82f1ed2
core adding image range
juliaroldi Sep 20, 2022
64331e3
Merge branch 'u/juliaroldi/selectImageApi' of https://github.com/micr…
juliaroldi Sep 20, 2022
c00bc99
Merge branch 'master' into u/juliaroldi/selectImageApi
juliaroldi Sep 20, 2022
de76392
Merge branch 'master' into u/biwu/markdowntests
flyingbee2012 Sep 20, 2022
7c4c9f2
Merge pull request #1272 from microsoft/u/biwu/markdowntests
flyingbee2012 Sep 20, 2022
026d4d9
Merge branch 'master' into u/juliaroldi/selectImageApi
juliaroldi Sep 20, 2022
3ad948d
Content Model: improve demo site, and minor bug fixes (#1271)
JiuqingSong Sep 20, 2022
3384876
Skip unstable test case (#1280)
JiuqingSong Sep 20, 2022
cb66981
Merge branch 'master' into u/juliaroldi/selectImageApi
JiuqingSong Sep 20, 2022
9de6dda
select image data structure
juliaroldi Sep 21, 2022
3ff449d
remove comment
juliaroldi Sep 21, 2022
802cae4
Image Selection plugin
juliaroldi Sep 21, 2022
74f88ff
remove spaces
juliaroldi Sep 21, 2022
493324f
test
juliaroldi Sep 21, 2022
6c1d98b
Use elements from list stack even if they don't match (#1275)
tshibley Sep 22, 2022
8ebd49f
Merge branch 'master' into fhl/juliaroldi/imageSelect-api
juliaroldi Sep 22, 2022
5dcbb43
fix conflicts
juliaroldi Sep 22, 2022
dda80b1
Merge pull request #1284 from microsoft/fhl/juliaroldi/imageSelect-api
juliaroldi Sep 22, 2022
3f8406f
Merge branch 'master' into fhl/juliaroldi/imageSelection-plugin
JiuqingSong Sep 22, 2022
f8198d2
Remove 'caret-color' css rule when paste (#1283)
JiuqingSong Sep 22, 2022
4e3ca79
refactor and add tests
juliaroldi Sep 22, 2022
89673a8
Merge branch 'master' into fhl/juliaroldi/imageSelection-plugin
juliaroldi Sep 22, 2022
15c7363
salve only image id instead of the the image element
juliaroldi Sep 22, 2022
c171e68
Merge branch 'fhl/juliaroldi/imageSelection-plugin' of https://github…
juliaroldi Sep 22, 2022
aea4982
Enable strict mode for "packages-ui" (#1285)
ianeli1 Sep 23, 2022
c492dd4
Merge branch 'master' into fhl/juliaroldi/imageSelection-plugin
juliaroldi Sep 23, 2022
efef982
Merge pull request #1286 from microsoft/fhl/juliaroldi/imageSelection…
juliaroldi Sep 23, 2022
2b518e4
Refactor create content model interfaces (#1273)
JiuqingSong Sep 23, 2022
10c9855
Merge branch 'master' into u/jisong/roosterjs8320
JiuqingSong Sep 23, 2022
d3cee74
RoosterJs 8.32.0
JiuqingSong Sep 23, 2022
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
38 changes: 38 additions & 0 deletions .vscode/launch.json
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,44 @@
"args": ["start", "--chrome", "--components", "${fileBasenameNoExtension}"],
"console": "integratedTerminal"
},
{
"type": "node",
"request": "launch",
"name": "Debug All Unit Tests",
"program": "${workspaceFolder}/node_modules/karma/bin/karma",
"args": ["start", "--no-single-run"],
"console": "integratedTerminal"
},
{
"type": "node",
"request": "launch",
"name": "Debug All Unit Tests (Chrome)",
"program": "${workspaceFolder}/node_modules/karma/bin/karma",
"args": ["start", "--chrome", "--no-single-run"],
"console": "integratedTerminal"
},
{
"type": "node",
"request": "launch",
"name": "Debug current unit test file",
"program": "${workspaceFolder}/node_modules/karma/bin/karma",
"args": ["start", "--components", "${fileBasenameNoExtension}", "--no-single-run"],
"console": "integratedTerminal"
},
{
"type": "node",
"request": "launch",
"name": "Debug current unit test file (Chrome)",
"program": "${workspaceFolder}/node_modules/karma/bin/karma",
"args": [
"start",
"--chrome",
"--components",
"${fileBasenameNoExtension}",
"--no-single-run"
],
"console": "integratedTerminal"
},
{
"type": "chrome",
"request": "launch",
Expand Down
1 change: 1 addition & 0 deletions demo/scripts/controls/BuildInPluginState.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ export interface BuildInPluginList {
tableEditMenu: boolean;
contextMenu: boolean;
autoFormat: boolean;
imageSelection: boolean;
}

export default interface BuildInPluginState {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,12 @@ import { FormatRenderer } from './utils/FormatRenderer';

const styles = require('./FormatView.scss');

export function FormatView<T>(props: { format: T; renderers: FormatRenderer<T>[] }) {
const { format, renderers } = props;
export function FormatView<T>(props: {
format: T;
renderers: FormatRenderer<T>[];
onUpdate?: () => void;
}) {
const { format, renderers, onUpdate } = props;

return <div className={styles.formatTable}>{renderers.map(x => x(format))}</div>;
return <div className={styles.formatTable}>{renderers.map(x => x(format, onUpdate))}</div>;
}
Original file line number Diff line number Diff line change
@@ -1 +1 @@
export type FormatRenderer<T> = (format: T) => JSX.Element;
export type FormatRenderer<T> = (format: T, onUpdate?: () => void) => JSX.Element;
Original file line number Diff line number Diff line change
Expand Up @@ -9,15 +9,17 @@ function CheckboxFormatItem<TFormat>(props: {
format: TFormat;
getter: (format: TFormat) => boolean;
setter?: (format: TFormat, newValue: boolean) => void;
onUpdate?: () => void;
}) {
const { name, getter, setter, format } = props;
const { name, getter, setter, format, onUpdate } = props;
const checkbox = React.useRef<HTMLInputElement>(null);
const [value, setValue] = useProperty<boolean>(getter(format));

const onChange = React.useCallback(() => {
const newValue = checkbox.current.checked;
setValue(newValue);
setter?.(format, newValue);
onUpdate?.();
}, [format, setter, setValue]);

return (
Expand All @@ -35,12 +37,13 @@ export function createCheckboxFormatRenderer<T>(
getter: (format: T) => boolean,
setter?: (format: T, newValue: boolean) => void
): FormatRenderer<T> {
return (format: T) => (
return (format: T, onUpdate?: () => void) => (
<CheckboxFormatItem
name={name}
getter={getter}
setter={setter}
format={format}
onUpdate={onUpdate}
key={name}
/>
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,9 @@ function ColorFormatItem<T>(props: {
format: T;
getter: (format: T) => string;
setter?: (format: T, newValue: string) => void;
onUpdate?: () => void;
}) {
const { name, getter, setter, format } = props;
const { name, getter, setter, format, onUpdate } = props;
const colorPickerBox = React.useRef<HTMLInputElement & HTMLTextAreaElement>(null);
const colorValueBox = React.useRef<HTMLInputElement>(null);
const transparentCheckBox = React.useRef<HTMLInputElement>(null);
Expand All @@ -39,6 +40,7 @@ function ColorFormatItem<T>(props: {

setValue(newValue);
setter?.(format, newValue);
onUpdate?.();
},
[setter, format]
);
Expand Down Expand Up @@ -90,8 +92,15 @@ export function createColorFormatRenderer<T>(
getter: (format: T) => string,
setter?: (format: T, newValue: string) => void
): FormatRenderer<T> {
return (format: T) => (
<ColorFormatItem name={name} getter={getter} setter={setter} format={format} key={name} />
return (format: T, onUpdate?: () => void) => (
<ColorFormatItem
name={name}
getter={getter}
setter={setter}
format={format}
key={name}
onUpdate={onUpdate}
/>
);
}

Expand All @@ -100,7 +109,7 @@ export function createColorFormatRendererGroup<T, V extends string>(
getter: (format: T) => string[],
setter?: (format: T, name: V, newValue: string) => void
): FormatRenderer<T> {
return (format: T) => {
return (format: T, onUpdate?: () => void) => {
const initValues = getter(format);

return (
Expand All @@ -111,6 +120,7 @@ export function createColorFormatRendererGroup<T, V extends string>(
getter={() => initValues[index]}
setter={(format, newValue) => setter?.(format, name, newValue)}
format={format}
onUpdate={onUpdate}
key={name}
/>
))}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,9 @@ function DropDownFormatItem<TFormat, TOption extends string>(props: {
options: TOption[];
getter: (format: TFormat) => TOption | undefined;
setter?: (format: TFormat, newValue: TOption | undefined) => void;
onUpdate?: () => void;
}) {
const { name, getter, setter, format, options } = props;
const { name, getter, setter, format, options, onUpdate } = props;
const dropDown = React.useRef<HTMLSelectElement>(null);
const [value, setValue] = useProperty(getter(format));

Expand All @@ -20,6 +21,7 @@ function DropDownFormatItem<TFormat, TOption extends string>(props: {
dropDown.current.value == '' ? undefined : (dropDown.current.value as TOption);
setValue(newValue);
setter?.(format, newValue);
onUpdate?.();
}, [format, setter]);

return (
Expand All @@ -45,13 +47,14 @@ export function createDropDownFormatRenderer<T, O extends string>(
getter: (format: T) => O,
setter?: (format: T, newValue: O) => void
): FormatRenderer<T> {
return (format: T) => (
return (format: T, onUpdate?: () => void) => (
<DropDownFormatItem
name={name}
getter={getter}
setter={setter}
format={format}
options={options}
onUpdate={onUpdate}
key={name}
/>
);
Expand All @@ -63,7 +66,7 @@ export function createDropDownFormatRendererGroup<T, O extends string, V extends
getter: (format: T) => O[],
setter?: (format: T, name: V, newValue: O) => void
): FormatRenderer<T> {
return (format: T) => {
return (format: T, onUpdate?: () => void) => {
const initValues = getter(format);
return (
<>
Expand All @@ -74,6 +77,7 @@ export function createDropDownFormatRendererGroup<T, O extends string, V extends
setter={(format, newValue) => setter?.(format, name, newValue)}
format={format}
options={options}
onUpdate={onUpdate}
key={name}
/>
))}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,16 +9,18 @@ function TextFormatItem<T>(props: {
format: T;
getter: (format: T) => string;
setter?: (format: T, newValue: string) => void;
onUpdate?: () => void;
type: 'text' | 'number' | 'multiline';
}) {
const { name, getter, setter, format, type } = props;
const { name, getter, setter, format, type, onUpdate } = props;
const textBox = React.useRef<HTMLInputElement & HTMLTextAreaElement>(null);
const [value, setValue] = useProperty(getter(format));

const updateValue = React.useCallback(
(newValue: string) => {
setValue(newValue);
setter?.(format, newValue);
onUpdate();
},
[setter, format]
);
Expand Down Expand Up @@ -78,13 +80,14 @@ export function createTextFormatRenderer<T>(
setter?: (format: T, newValue: string) => void,
type: 'text' | 'number' | 'multiline' = 'text'
): FormatRenderer<T> {
return (format: T) => (
return (format: T, onUpdate?: () => void) => (
<TextFormatItem
name={name}
getter={getter}
setter={setter}
format={format}
type={type}
onUpdate={onUpdate}
key={name}
/>
);
Expand All @@ -96,7 +99,7 @@ export function createTextFormatRendererGroup<T, V extends string>(
setter?: (format: T, name: V, newValue: string) => void,
type: 'text' | 'number' | 'multiline' = 'text'
): FormatRenderer<T> {
return (format: T) => {
return (format: T, onUpdate?: () => void) => {
const initValues = getter(format);

return (
Expand All @@ -108,6 +111,7 @@ export function createTextFormatRendererGroup<T, V extends string>(
setter={(format, newValue) => setter?.(format, name, newValue)}
format={format}
type={type}
onUpdate={onUpdate}
key={name}
/>
))}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import * as React from 'react';
import { BlockGroupContentView } from './BlockGroupContentView';
import { ContentModelDocument, hasSelectionInBlock } from 'roosterjs-content-model';
import { ContentModelDocument, hasSelectionInBlockGroup } from 'roosterjs-content-model';
import { ContentModelView } from '../ContentModelView';

const styles = require('./ContentModelDocumentView.scss');
Expand All @@ -16,7 +16,7 @@ export function ContentModelDocumentView(props: { doc: ContentModelDocument }) {
title="Document"
subTitle={doc.document.location.href}
className={styles.modelDocument}
hasSelection={hasSelectionInBlock(doc)}
hasSelection={hasSelectionInBlockGroup(doc)}
jsonSource={doc}
getContent={getContent}
/>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import { VerticalAlignFormatRenderer } from '../format/formatPart/VerticalAlignF
import {
ContentModelTableCell,
ContentModelTableCellFormat,
hasSelectionInBlock,
hasSelectionInBlockGroup,
} from 'roosterjs-content-model';

const styles = require('./ContentModelTableCellView.scss');
Expand Down Expand Up @@ -99,7 +99,7 @@ export function ContentModelTableCellView(props: { cell: ContentModelTableCell }
title={isHeader ? 'TableCellHeader' : 'TableCell'}
subTitle={subTitle}
className={styles.modelTableCell}
hasSelection={hasSelectionInBlock(cell)}
hasSelection={hasSelectionInBlockGroup(cell)}
isSelected={cell.isSelected}
jsonSource={cell}
getContent={getContent}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import * as React from 'react';
import { applyTableFormat } from 'roosterjs-content-model/lib/modelApi/table/applyTableFormat';
import { BackgroundColorFormatRenderer } from '../format/formatPart/BackgroundColorFormatRenderer';
import { BorderFormatRenderers } from '../format/formatPart/BorderFormatRenderers';
import { ContentModelBlockView } from './ContentModelBlockView';
import { ContentModelBlockGroupView } from './ContentModelBlockGroupView';
import { ContentModelView } from '../ContentModelView';
import { FormatRenderer } from '../format/utils/FormatRenderer';
import { FormatView } from '../format/FormatView';
Expand Down Expand Up @@ -48,7 +48,7 @@ export function ContentModelTableView(props: { table: ContentModelTable }) {
{table.cells.map((row, i) => (
<div className={styles.tableRow} key={i}>
{row.map((cell, j) => (
<ContentModelBlockView block={cell} key={j} />
<ContentModelBlockGroupView group={cell} key={j} />
))}
</div>
))}
Expand Down
40 changes: 22 additions & 18 deletions demo/scripts/controls/editor/ExperimentalContentModelEditor.ts
Original file line number Diff line number Diff line change
@@ -1,12 +1,14 @@
import { ContentPosition, EditorOptions, SelectionRangeTypes } from 'roosterjs-editor-types';
import { Editor } from 'roosterjs-editor-core';
import { EditorOptions, SelectionRangeTypes } from 'roosterjs-editor-types';
import { getComputedStyles, Position } from 'roosterjs-editor-dom';
import {
ContentModelContext,
EditorContext,
ContentModelDocument,
contentModelToDom,
domToContentModel,
DomToModelOption,
IExperimentalContentModelEditor,
ModelToDomOption,
} from 'roosterjs-content-model';

/**
Expand All @@ -29,9 +31,9 @@ export default class ExperimentalContentModelEditor extends Editor
}

/**
* Create a ContentModelContext object used by ContentModel API
* Create a EditorContext object used by ContentModel API
*/
createContentModelContext(): ContentModelContext {
createEditorContext(): EditorContext {
return {
isDarkMode: this.isDarkMode(),
zoomScale: this.getZoomScale(),
Expand All @@ -44,26 +46,25 @@ export default class ExperimentalContentModelEditor extends Editor
* Create Content Model from DOM tree in this editor
* @param startNode Optional start node. If provided, Content Model will be created from this node (including itself),
* otherwise it will create Content Model for the whole content in editor.
* @param option The option to customize the behavior of DOM to Content Model conversion
*/
createContentModel(startNode?: HTMLElement): ContentModelDocument {
return domToContentModel(
startNode || this.contentDiv,
this.createContentModelContext(),
!!startNode,
this.getSelectionRangeEx()
);
createContentModel(startNode?: HTMLElement, option?: DomToModelOption): ContentModelDocument {
return domToContentModel(startNode || this.contentDiv, this.createEditorContext(), {
includeRoot: !!startNode,
selectionRange: this.getSelectionRangeEx(),
...(option || {}),
});
}

/**
* Set content with content model
* @param model The content model to set
* @param mergingCallback A callback to indicate how should the new content be integrated into existing content
* @param option Additional options to customize the behavior of Content Model to DOM conversion
*/
setContentModel(
model: ContentModelDocument,
mergingCallback: (fragment: DocumentFragment) => void = this.defaultMergingCallback
) {
const [fragment, range] = contentModelToDom(model, this.createContentModelContext());
setContentModel(model: ContentModelDocument, option?: ModelToDomOption) {
const [fragment, range] = contentModelToDom(model, this.createEditorContext(), option);
const mergingCallback = option?.mergingCallback || this.defaultMergingCallback;

switch (range?.type) {
case SelectionRangeTypes.Normal:
Expand All @@ -86,7 +87,10 @@ export default class ExperimentalContentModelEditor extends Editor
}

private defaultMergingCallback = (fragment: DocumentFragment) => {
this.setContent('');
this.insertNode(fragment);
while (this.contentDiv.firstChild) {
this.contentDiv.removeChild(this.contentDiv.firstChild);
}

this.insertNode(fragment, { position: ContentPosition.Begin });
};
}
Loading