Skip to content

Commit

Permalink
Merge branch 'master' into u/jisong/shadoweditselection
Browse files Browse the repository at this point in the history
  • Loading branch information
JiuqingSong authored Apr 5, 2024
2 parents 06ac515 + 53f1f4d commit eea61b8
Show file tree
Hide file tree
Showing 25 changed files with 1,320 additions and 260 deletions.
10 changes: 9 additions & 1 deletion demo/scripts/controlsV2/mainPane/MainPane.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ import { getDarkColor } from 'roosterjs-color-utils';
import { getPresetModelById } from '../sidePane/presets/allPresets/allPresets';
import { getTabs, tabNames } from '../tabs/getTabs';
import { getTheme } from '../theme/themes';
import { OptionState } from '../sidePane/editorOptions/OptionState';
import { OptionState, UrlPlaceholder } from '../sidePane/editorOptions/OptionState';
import { popoutButton } from '../demoButtons/popoutButton';
import { PresetPlugin } from '../sidePane/presets/PresetPlugin';
import { redoButton } from '../roosterjsReact/ribbon/buttons/redoButton';
Expand All @@ -47,6 +47,7 @@ import {
import {
AutoFormatPlugin,
EditPlugin,
HyperlinkPlugin,
MarkdownPlugin,
PastePlugin,
ShortcutPlugin,
Expand Down Expand Up @@ -476,6 +477,7 @@ export class MainPane extends React.Component<{}, MainPaneState> {
watermarkText,
markdownOptions,
autoFormatOptions,
linkTitle,
} = this.state.initState;
return [
pluginList.autoFormat && new AutoFormatPlugin(autoFormatOptions),
Expand All @@ -492,6 +494,12 @@ export class MainPane extends React.Component<{}, MainPaneState> {
pluginList.contextMenu && listMenu && createListEditMenuProvider(),
pluginList.contextMenu && tableMenu && createTableEditMenuProvider(),
pluginList.contextMenu && imageMenu && createImageEditMenuProvider(),
pluginList.hyperlink &&
new HyperlinkPlugin(
linkTitle?.indexOf(UrlPlaceholder) >= 0
? url => linkTitle.replace(UrlPlaceholder, url)
: linkTitle
),
].filter(x => !!x);
}
}
Expand Down
26 changes: 3 additions & 23 deletions demo/scripts/controlsV2/plugins/createLegacyPlugins.ts
Original file line number Diff line number Diff line change
@@ -1,31 +1,11 @@
import { Announce, CustomReplace, ImageEdit } from 'roosterjs-editor-plugins';
import { EditorPlugin as LegacyEditorPlugin, KnownAnnounceStrings } from 'roosterjs-editor-types';
import {
Announce,
ContentEdit,
CustomReplace,
HyperLink,
ImageEdit,
} from 'roosterjs-editor-plugins';
import {
LegacyPluginList,
OptionState,
UrlPlaceholder,
} from '../sidePane/editorOptions/OptionState';
import { LegacyPluginList, OptionState } from '../sidePane/editorOptions/OptionState';

export function createLegacyPlugins(initState: OptionState): LegacyEditorPlugin[] {
const { pluginList, linkTitle } = initState;
const { pluginList } = initState;

const plugins: Record<keyof LegacyPluginList, LegacyEditorPlugin | null> = {
contentEdit: pluginList.contentEdit ? new ContentEdit(initState.contentEditFeatures) : null,
hyperlink: pluginList.hyperlink
? new HyperLink(
linkTitle?.indexOf(UrlPlaceholder) >= 0
? url => linkTitle.replace(UrlPlaceholder, url)
: linkTitle
? () => linkTitle
: null
)
: null,
imageEdit: pluginList.imageEdit
? new ImageEdit({
preserveRatio: initState.forcePreserveRatio,
Expand Down
117 changes: 0 additions & 117 deletions demo/scripts/controlsV2/sidePane/editorOptions/ContentEditFeatures.tsx

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ export class DefaultFormatPane extends React.Component<DefaultFormatProps, {}> {
[NOT_SET]: 'Not Set',
'8pt': '8',
'10pt': '10',
'11pt': '11',
'12pt': '12',
'16pt': '16',
'20pt': '20',
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import { getDefaultContentEditFeatureSettings } from './getDefaultContentEditFeatureSettings';
import { OptionPaneProps, OptionState, UrlPlaceholder } from './OptionState';
import { OptionsPane } from './OptionsPane';
import { SidePaneElementProps } from '../SidePaneElement';
Expand All @@ -17,16 +16,18 @@ const initialState: OptionState = {
pasteOption: true,
sampleEntity: true,
markdown: true,
hyperlink: true,

// Legacy plugins
contentEdit: false,
hyperlink: false,
imageEdit: false,
customReplace: false,
announce: false,
},
contentEditFeatures: getDefaultContentEditFeatureSettings(),
defaultFormat: {},
defaultFormat: {
fontFamily: 'Calibri',
fontSize: '11pt',
textColor: '#000000',
},
linkTitle: 'Ctrl+Click to follow the link:' + UrlPlaceholder,
watermarkText: 'Type content here ...',
forcePreserveRatio: false,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,8 @@
import { AutoFormatOptions, MarkdownOptions } from 'roosterjs-content-model-plugins';
import type { ContentEditFeatureSettings } from 'roosterjs-editor-types';
import type { SidePaneElementProps } from '../SidePaneElement';
import type { ContentModelSegmentFormat } from 'roosterjs-content-model-types';

export interface LegacyPluginList {
contentEdit: boolean;
hyperlink: boolean;
imageEdit: boolean;
customReplace: boolean;
announce: boolean;
Expand All @@ -23,6 +20,7 @@ export interface NewPluginList {
pasteOption: boolean;
sampleEntity: boolean;
markdown: boolean;
hyperlink: boolean;
}

export interface BuildInPluginList extends LegacyPluginList, NewPluginList {}
Expand All @@ -40,7 +38,6 @@ export interface OptionState {
markdownOptions: MarkdownOptions;

// Legacy plugin options
contentEditFeatures: ContentEditFeatureSettings;
defaultFormat: ContentModelSegmentFormat;
linkTitle: string;
forcePreserveRatio: boolean;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,6 @@ export class OptionsPane extends React.Component<OptionPaneProps, OptionState> {
linkTitle: this.state.linkTitle,
watermarkText: this.state.watermarkText,
pluginList: { ...this.state.pluginList },
contentEditFeatures: { ...this.state.contentEditFeatures },
defaultFormat: { ...this.state.defaultFormat },
forcePreserveRatio: this.state.forcePreserveRatio,
applyChangesOnMouseUp: this.state.applyChangesOnMouseUp,
Expand Down
Loading

0 comments on commit eea61b8

Please sign in to comment.