Skip to content

Commit

Permalink
Version bump: 8.61 & content model 0.27 (#2460)
Browse files Browse the repository at this point in the history
* fix collapsed

* remove test

* fix list

* remove margins

* Workaround for no mouseUp event (#2423)

* Rename StandaloneEditor to Editor (#2416)

* Rename StandaloneEditor to Editor

* fix build

* add parameter

* fix conflicts

* fix selection

* Fix insertNode: Do not reselect if updateCursor is false (#2431)

* Bump ip from 1.1.5 to 1.1.9 (#2433)

Bumps [ip](https://github.com/indutny/node-ip) from 1.1.5 to 1.1.9.
- [Commits](indutny/node-ip@v1.1.5...v1.1.9)

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

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

* Outdent indented empty paragraph when pressing Backspace. (#2429)

* outdent on backspace

* Remove unneeded check

* fix test build

* handle Tab key for paragraph

* fix build

* fix build

* remove /lib

* disable list features

* save last focus

* Support adding options for exportContent (#2443)

* Set RootFontSize to SanitizingContext (#2445)

* init

* fix Build

* Check once if it is Rem Unit

* refactor

* fix build

* Fix #2435 (#2442)

* format with content model

* remove empty line

* Split contentDiv into physicalRoot and logicalRoot (#2441)

* Split contentDiv into physicalRoot and logicalRoot

* Fix failing test

* Fixed failing test harnesses

* Updated in response to PR comments

* Fix tests

* add unit test

* Fix dispose plugin issus in EditorAdapter (#2452)

* Fix #2202 again (#2450)

* Improve Entity State related API (#2444)

* Improve Entity State related API

* fix build and test

* add test

---------

Co-authored-by: Bryan Valverde U <[email protected]>

* Port Table edit plugin (#2358)

* Standalone Editor step 2

* Standalone Editor step 3

* improve

* Standalone Editor step 4

* Standalone Editor: Remove compatible enums from standalone editor

* improve

* Standalone Editor: Create new event types

* Port to new event system

* Revert "Port to new event system"

This reverts commit 60cf041.

* Port to new event system

* Improve

* fix build

* fix demo

* Fix buttons

* fix build

* fix build

* fix build

* plugin added to cm demo site

* pluginUtils imported

* IStandaloneEditor changes

* editTable can skip undo snapshot

* TableEditPlugin port start

* move D&D to folder

* add plugin to Standalone demo and remove old plugin

* demo fix

* rename D&D and fix import

* demo site changes

* rename selector to mover

* new plugin utils, organisation

* isMobileOrTablet

* cleanup

* normalise width too

* remove onShowHelperElement, fix containment, instancing, others

* implement cell resizer

* fix type import

* fix selection

* fix imports

* fix instanceof, use formatTableWithContentModel, getDOMHelper

* fix merge

* small fix

* fix table resize functionality

* fix merge

* fix import

* fix dependency

* fix exports

* merge fix

* export MIN_WIDTH

* fix resizers

* add check

* fix color

* fix instanceof

* change IStandaloneEditor to IEditor

* fix export const

* rename const

* fix cell resizer, add ids

* add tests

* fix build issues

---------

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

* Port ShortcutPlugin (#2427)

* Port ShortcutPlugin

* fix build

* add test

* add test

* add test

* fix build

* fix build

* improve

* fix comment

* fix test

* Add option to configure the default paste type (#2457)

* init

* Add tests

* Fix build

* Bump Versions

* Remove Space

* Fix 258837 and 257626 (#2459)

* Remove Bg Color from block on Merge Paste (#2458)

* init

* Remove unneeded code

* address comment

* remove empty line

* Fix Version Numbers

---------

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: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Co-authored-by: Bryan Valverde U <[email protected]>
Co-authored-by: florian-msft <[email protected]>
Co-authored-by: Andres-CT98 <[email protected]>
  • Loading branch information
8 people authored Mar 1, 2024
1 parent 5e4a0e1 commit 7daf1ba
Show file tree
Hide file tree
Showing 262 changed files with 9,390 additions and 1,281 deletions.
1 change: 0 additions & 1 deletion demo/scripts/controls/BuildInPluginState.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@ export interface BuildInPluginList {
imageEdit: boolean;
cutPasteListChain: boolean;
tableCellSelection: boolean;
tableResize: boolean;
customReplace: boolean;
listEditMenu: boolean;
imageEditMenu: boolean;
Expand Down
16 changes: 10 additions & 6 deletions demo/scripts/controls/ContentModelEditorMainPane.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@ import { alignJustifyButton } from './ribbonButtons/contentModel/alignJustifyBut
import { alignLeftButton } from './ribbonButtons/contentModel/alignLeftButton';
import { alignRightButton } from './ribbonButtons/contentModel/alignRightButton';
import { arrayPush } from 'roosterjs-editor-dom';
import { AutoFormatPlugin, EditPlugin, PastePlugin } from 'roosterjs-content-model-plugins';
import { backgroundColorButton } from './ribbonButtons/contentModel/backgroundColorButton';
import { blockQuoteButton } from './ribbonButtons/contentModel/blockQuoteButton';
import { boldButton } from './ribbonButtons/contentModel/boldButton';
Expand Down Expand Up @@ -80,11 +79,13 @@ import { trustedHTMLHandler } from '../utils/trustedHTMLHandler';
import { underlineButton } from './ribbonButtons/contentModel/underlineButton';
import { undoButton } from './ribbonButtons/contentModel/undoButton';
import { zoom } from './ribbonButtons/contentModel/zoom';
import { ContentModelSegmentFormat, IEditor, Snapshots } from 'roosterjs-content-model-types';
import {
ContentModelSegmentFormat,
IStandaloneEditor,
Snapshots,
} from 'roosterjs-content-model-types';
AutoFormatPlugin,
EditPlugin,
PastePlugin,
TableEditPlugin,
} from 'roosterjs-content-model-plugins';
import {
spaceAfterButton,
spaceBeforeButton,
Expand Down Expand Up @@ -155,7 +156,7 @@ const DarkTheme: PartialTheme = {
};

interface ContentModelMainPaneState extends MainPaneBaseState {
editorCreator: (div: HTMLDivElement, options: EditorAdapterOptions) => IStandaloneEditor;
editorCreator: (div: HTMLDivElement, options: EditorAdapterOptions) => IEditor;
}

class ContentModelEditorMainPane extends MainPaneBase<ContentModelMainPaneState> {
Expand All @@ -174,6 +175,7 @@ class ContentModelEditorMainPane extends MainPaneBase<ContentModelMainPaneState>
private formatPainterPlugin: ContentModelFormatPainterPlugin;
private pastePlugin: PastePlugin;
private sampleEntityPlugin: SampleEntityPlugin;
private tableEditPlugin: TableEditPlugin;
private snapshots: Snapshots;
private buttons: ContentModelRibbonButton<any>[] = [
formatPainterButton,
Expand Down Expand Up @@ -263,6 +265,7 @@ class ContentModelEditorMainPane extends MainPaneBase<ContentModelMainPaneState>
this.pasteOptionPlugin = createPasteOptionPlugin();
this.emojiPlugin = createEmojiPlugin();
this.formatPainterPlugin = new ContentModelFormatPainterPlugin();
this.tableEditPlugin = new TableEditPlugin();
this.pastePlugin = new PastePlugin();
this.sampleEntityPlugin = new SampleEntityPlugin();
this.state = {
Expand Down Expand Up @@ -382,6 +385,7 @@ class ContentModelEditorMainPane extends MainPaneBase<ContentModelMainPaneState>
this.contentModelRibbonPlugin,
this.formatPainterPlugin,
this.pastePlugin,
this.tableEditPlugin,
this.contentModelAutoFormatPlugin,
this.contentModelEditPlugin,
this.contentModelPanePlugin.getInnerRibbonPlugin(),
Expand Down
25 changes: 18 additions & 7 deletions demo/scripts/controls/StandaloneEditorMainPane.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@ import { alignCenterButton } from './ribbonButtons/contentModel/alignCenterButto
import { alignJustifyButton } from './ribbonButtons/contentModel/alignJustifyButton';
import { alignLeftButton } from './ribbonButtons/contentModel/alignLeftButton';
import { alignRightButton } from './ribbonButtons/contentModel/alignRightButton';
import { AutoFormatPlugin, EditPlugin } from 'roosterjs-content-model-plugins';
import { backgroundColorButton } from './ribbonButtons/contentModel/backgroundColorButton';
import { blockQuoteButton } from './ribbonButtons/contentModel/blockQuoteButton';
import { boldButton } from './ribbonButtons/contentModel/boldButton';
Expand All @@ -30,6 +29,7 @@ import { ContentModelRibbonPlugin } from './ribbonButtons/contentModel/ContentMo
import { darkMode } from './ribbonButtons/contentModel/darkMode';
import { decreaseFontSizeButton } from './ribbonButtons/contentModel/decreaseFontSizeButton';
import { decreaseIndentButton } from './ribbonButtons/contentModel/decreaseIndentButton';
import { Editor } from 'roosterjs-content-model-core';
import { exportContent } from './ribbonButtons/contentModel/export';
import { fontButton } from './ribbonButtons/contentModel/fontButton';
import { fontSizeButton } from './ribbonButtons/contentModel/fontSizeButton';
Expand Down Expand Up @@ -63,7 +63,6 @@ import { setTableCellShadeButton } from './ribbonButtons/contentModel/setTableCe
import { setTableHeaderButton } from './ribbonButtons/contentModel/setTableHeaderButton';
import { Snapshots } from 'roosterjs-editor-types';
import { spacingButton } from './ribbonButtons/contentModel/spacingButton';
import { StandaloneEditor } from 'roosterjs-content-model-core';
import { strikethroughButton } from './ribbonButtons/contentModel/strikethroughButton';
import { subscriptButton } from './ribbonButtons/contentModel/subscriptButton';
import { superscriptButton } from './ribbonButtons/contentModel/superscriptButton';
Expand All @@ -76,11 +75,17 @@ import { trustedHTMLHandler } from '../utils/trustedHTMLHandler';
import { underlineButton } from './ribbonButtons/contentModel/underlineButton';
import { undoButton } from './ribbonButtons/contentModel/undoButton';
import { zoom } from './ribbonButtons/contentModel/zoom';
import {
AutoFormatPlugin,
EditPlugin,
ShortcutPlugin,
TableEditPlugin,
} from 'roosterjs-content-model-plugins';
import {
ContentModelSegmentFormat,
IStandaloneEditor,
IEditor,
Snapshot,
StandaloneEditorOptions,
EditorOptions,
} from 'roosterjs-content-model-types';
import {
spaceAfterButton,
Expand Down Expand Up @@ -152,7 +157,7 @@ const DarkTheme: PartialTheme = {
};

interface ContentModelMainPaneState extends MainPaneBaseState {
editorCreator: (div: HTMLDivElement, options: StandaloneEditorOptions) => IStandaloneEditor;
editorCreator: (div: HTMLDivElement, options: EditorOptions) => IEditor;
}

class ContentModelEditorMainPane extends MainPaneBase<ContentModelMainPaneState> {
Expand All @@ -165,7 +170,9 @@ class ContentModelEditorMainPane extends MainPaneBase<ContentModelMainPaneState>
private contentModelRibbonPlugin: RibbonPlugin;
private contentAutoFormatPlugin: AutoFormatPlugin;
private snapshotPlugin: ContentModelSnapshotPlugin;
private shortcutPlugin: ShortcutPlugin;
private formatPainterPlugin: ContentModelFormatPainterPlugin;
private tableEditPlugin: TableEditPlugin;
private snapshots: Snapshots<Snapshot>;
private buttons: ContentModelRibbonButton<any>[] = [
formatPainterButton,
Expand Down Expand Up @@ -251,8 +258,10 @@ class ContentModelEditorMainPane extends MainPaneBase<ContentModelMainPaneState>
this.contentModelPanePlugin = new ContentModelPanePlugin();
this.contentModelEditPlugin = new EditPlugin();
this.contentAutoFormatPlugin = new AutoFormatPlugin();
this.shortcutPlugin = new ShortcutPlugin();
this.contentModelRibbonPlugin = new ContentModelRibbonPlugin();
this.formatPainterPlugin = new ContentModelFormatPainterPlugin();
this.tableEditPlugin = new TableEditPlugin();
this.state = {
showSidePane: window.location.hash != '',
popoutWindow: null,
Expand Down Expand Up @@ -305,8 +314,8 @@ class ContentModelEditorMainPane extends MainPaneBase<ContentModelMainPaneState>

resetEditor() {
this.setState({
editorCreator: (div: HTMLDivElement, options: StandaloneEditorOptions) =>
new StandaloneEditor(div, {
editorCreator: (div: HTMLDivElement, options: EditorOptions) =>
new Editor(div, {
...options,
cacheModel: this.state.initState.cacheModel,
}),
Expand Down Expand Up @@ -345,8 +354,10 @@ class ContentModelEditorMainPane extends MainPaneBase<ContentModelMainPaneState>
plugins={[
this.contentModelRibbonPlugin,
this.formatPainterPlugin,
this.tableEditPlugin,
this.contentModelEditPlugin,
this.contentAutoFormatPlugin,
this.shortcutPlugin,
]}
defaultSegmentFormat={defaultFormat}
inDarkMode={this.state.isDarkMode}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,8 @@ import * as React from 'react';
import { createUIUtilities, ReactEditorPlugin, UIUtilities } from 'roosterjs-react';
import { divProperties, getNativeProps } from '@fluentui/react/lib/Utilities';
import { EditorAdapter, EditorAdapterOptions } from 'roosterjs-editor-adapter';
import { EditorOptions, EditorPlugin, IEditor } from 'roosterjs-content-model-types';
import { useTheme } from '@fluentui/react/lib/Theme';
import {
EditorPlugin,
IStandaloneEditor,
StandaloneEditorOptions,
} from 'roosterjs-content-model-types';
import type { EditorPlugin as LegacyEditorPlugin } from 'roosterjs-editor-types';

/**
Expand All @@ -20,7 +16,7 @@ export interface ContentModelRoosterProps
* Creator function used for creating the instance of roosterjs editor.
* Use this callback when you have your own sub class of roosterjs Editor or force trigging a reset of editor
*/
editorCreator?: (div: HTMLDivElement, options: StandaloneEditorOptions) => IStandaloneEditor;
editorCreator?: (div: HTMLDivElement, options: EditorOptions) => IEditor;

/**
* Whether editor should get focus once it is created
Expand All @@ -36,7 +32,7 @@ export interface ContentModelRoosterProps
*/
export default function ContentModelRooster(props: ContentModelRoosterProps) {
const editorDiv = React.useRef<HTMLDivElement>(null);
const editor = React.useRef<IStandaloneEditor | null>(null);
const editor = React.useRef<IEditor | null>(null);
const theme = useTheme();

const { focusOnInit, editorCreator, inDarkMode, plugins, legacyPlugins } = props;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,15 @@ import { applySegmentFormat, getFormatState } from 'roosterjs-content-model-api'
import {
ContentModelSegmentFormat,
EditorPlugin,
IStandaloneEditor,
IEditor,
PluginEvent,
} from 'roosterjs-content-model-types';

const FORMATPAINTERCURSOR_SVG = require('./formatpaintercursor.svg');
const FORMATPAINTERCURSOR_STYLE = `cursor: url("${FORMATPAINTERCURSOR_SVG}") 8.5 16, auto`;

export default class ContentModelFormatPainterPlugin implements EditorPlugin {
private editor: IStandaloneEditor | null = null;
private editor: IEditor | null = null;
private styleNode: HTMLStyleElement | null = null;
private painterFormat: ContentModelSegmentFormat | null = null;
private static instance: ContentModelFormatPainterPlugin | undefined;
Expand All @@ -24,7 +24,7 @@ export default class ContentModelFormatPainterPlugin implements EditorPlugin {
return 'FormatPainter';
}

initialize(editor: IStandaloneEditor) {
initialize(editor: IEditor) {
this.editor = editor;

const doc = this.editor.getDocument();
Expand Down Expand Up @@ -77,7 +77,7 @@ export default class ContentModelFormatPainterPlugin implements EditorPlugin {
}
}

function getSegmentFormat(editor: IStandaloneEditor): ContentModelSegmentFormat {
function getSegmentFormat(editor: IEditor): ContentModelSegmentFormat {
const formatState = getFormatState(editor);

return {
Expand Down
4 changes: 0 additions & 4 deletions demo/scripts/controls/getToggleablePlugins.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ import { HyperLink } from 'roosterjs-editor-plugins/lib/HyperLink';
import { ImageEdit } from 'roosterjs-editor-plugins/lib/ImageEdit';
import { Paste } from 'roosterjs-editor-plugins/lib/Paste';
import { TableCellSelection } from 'roosterjs-editor-plugins/lib/TableCellSelection';
import { TableResize } from 'roosterjs-editor-plugins/lib/TableResize';
import { Watermark } from 'roosterjs-editor-plugins/lib/Watermark';
import {
createContextMenuPlugin,
Expand Down Expand Up @@ -43,9 +42,6 @@ export default function getToggleablePlugins(initState: BuildInPluginState) {
imageEdit,
cutPasteListChain: pluginList.cutPasteListChain ? new CutPasteListChain() : null,
tableCellSelection: pluginList.tableCellSelection ? new TableCellSelection() : null,
tableResize: pluginList.tableResize
? new TableResize(undefined, initState.tableFeaturesContainerSelector)
: null,
customReplace: pluginList.customReplace ? new CustomReplacePlugin() : null,
autoFormat: pluginList.autoFormat ? new AutoFormat() : null,
listEditMenu:
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { LocalizedStrings, RibbonButtonDropDown, UIUtilities } from 'roosterjs-react';
import type { IStandaloneEditor } from 'roosterjs-content-model-types';
import type { IEditor } from 'roosterjs-content-model-types';
import type { FormatState } from 'roosterjs-editor-types';
import type { ICommandBarItemProps } from '@fluentui/react/lib/CommandBar';

Expand Down Expand Up @@ -35,7 +35,7 @@ export default interface ContentModelRibbonButton<T extends string> {
* @param uiUtilities a utilities object to help render addition UI elements
*/
onClick: (
editor: IStandaloneEditor,
editor: IEditor,
key: T,
strings: LocalizedStrings<T> | undefined,
uiUtilities: UIUtilities
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,10 @@ import { FormatState } from 'roosterjs-editor-types';
import { getFormatState } from 'roosterjs-content-model-api';
import { getObjectKeys } from 'roosterjs-editor-dom';
import { LocalizedStrings, UIUtilities } from 'roosterjs-react';
import {
ContentModelFormatState,
IStandaloneEditor,
PluginEvent,
} from 'roosterjs-content-model-types';
import { ContentModelFormatState, IEditor, PluginEvent } from 'roosterjs-content-model-types';

export class ContentModelRibbonPlugin implements RibbonPlugin {
private editor: IStandaloneEditor | null = null;
private editor: IEditor | null = null;
private onFormatChanged: ((formatState: FormatState) => void) | null = null;
private timer = 0;
private formatState: ContentModelFormatState | null = null;
Expand All @@ -34,7 +30,7 @@ export class ContentModelRibbonPlugin implements RibbonPlugin {
* Initialize this plugin
* @param editor The editor instance
*/
initialize(editor: IStandaloneEditor) {
initialize(editor: IEditor) {
this.editor = editor;
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import ContentModelPane, { ContentModelPaneProps } from './ContentModelPane';
import SidePanePluginImpl from '../SidePanePluginImpl';
import { ContentModelRibbonPlugin } from '../../ribbonButtons/contentModel/ContentModelRibbonPlugin';
import { IEditor, PluginEvent, PluginEventType } from 'roosterjs-editor-types';
import { IStandaloneEditor } from 'roosterjs-content-model-types';
import { IEditor as ILegacyEditor, PluginEvent, PluginEventType } from 'roosterjs-editor-types';
import { IEditor } from 'roosterjs-content-model-types';
import { setCurrentContentModel } from './currentModel';
import { SidePaneElementProps } from '../SidePaneElement';

Expand All @@ -17,10 +17,10 @@ export default class ContentModelPanePlugin extends SidePanePluginImpl<
this.contentModelRibbon = new ContentModelRibbonPlugin();
}

initialize(editor: IEditor): void {
initialize(editor: ILegacyEditor): void {
super.initialize(editor);

this.contentModelRibbon.initialize(editor as IEditor & IStandaloneEditor); // TODO: Port side pane to use IStandaloneEditor
this.contentModelRibbon.initialize(editor as ILegacyEditor & IEditor); // TODO: Port side pane to use IStandaloneEditor
editor.getDocument().addEventListener('selectionchange', this.onModelChangeFromSelection);
}

Expand All @@ -36,8 +36,7 @@ export default class ContentModelPanePlugin extends SidePanePluginImpl<
onPluginEvent(e: PluginEvent) {
if (e.eventType == PluginEventType.ContentChanged && e.source == 'RefreshModel') {
this.getComponent(component => {
// TODO: Port to use IStandaloneEditor and remove type cast here
const model = (this.editor as IEditor & IStandaloneEditor).getContentModelCopy(
const model = (this.editor as ILegacyEditor & IEditor).getContentModelCopy(
'connected'
);
component.setContentModel(model);
Expand Down Expand Up @@ -74,9 +73,7 @@ export default class ContentModelPanePlugin extends SidePanePluginImpl<
private onModelChange = () => {
this.getComponent(component => {
// TODO: Port to use IStandaloneEditor and remove type cast here
const model = (this.editor as IEditor & IStandaloneEditor).getContentModelCopy(
'connected'
);
const model = (this.editor as ILegacyEditor & IEditor).getContentModelCopy('connected');
component.setContentModel(model);
setCurrentContentModel(model);
});
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import * as React from 'react';
import ApiPaneProps from '../ApiPaneProps';
import { Entity, IEditor } from 'roosterjs-editor-types';
import { Entity, IEditor as ILegacyEditor } from 'roosterjs-editor-types';
import { getEntityFromElement, getEntitySelector } from 'roosterjs-editor-dom';
import { IEditor, InsertEntityOptions } from 'roosterjs-content-model-types';
import { insertEntity } from 'roosterjs-content-model-api';
import { InsertEntityOptions, IStandaloneEditor } from 'roosterjs-content-model-types';
import { trustedHTMLHandler } from '../../../../utils/trustedHTMLHandler';

const styles = require('./InsertEntityPane.scss');
Expand Down Expand Up @@ -114,7 +114,7 @@ export default class InsertEntityPane extends React.Component<ApiPaneProps, Inse

if (isBlock) {
insertEntity(
editor as IStandaloneEditor & IEditor,
editor as IEditor & ILegacyEditor,
entityType,
true,
insertAtRoot
Expand All @@ -128,7 +128,7 @@ export default class InsertEntityPane extends React.Component<ApiPaneProps, Inse
);
} else {
insertEntity(
editor as IStandaloneEditor & IEditor,
editor as IEditor & ILegacyEditor,
entityType,
isBlock,
insertAtTop ? 'begin' : insertAtBottom ? 'end' : 'focus',
Expand Down
Loading

0 comments on commit 7daf1ba

Please sign in to comment.