Skip to content

Commit

Permalink
WIP
Browse files Browse the repository at this point in the history
  • Loading branch information
juliaroldi committed Apr 1, 2024
1 parent 7130d12 commit c712f3b
Show file tree
Hide file tree
Showing 6 changed files with 23 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,12 @@ const initialState: OptionState = {
imageMenu: true,
tableMenu: true,
listMenu: true,
autoFormatOptions: {
autoBullet: true,
autoLink: true,
autoNumbering: true,
autoUnlink: false,
},
};

export class EditorOptionsPlugin extends SidePanePluginImpl<OptionsPane, OptionPaneProps> {
Expand Down
2 changes: 2 additions & 0 deletions demo/scripts/controlsV2/sidePane/editorOptions/OptionState.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import { AutoFormatOptions } 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';
Expand Down Expand Up @@ -35,6 +36,7 @@ export interface OptionState {
tableMenu: boolean;
imageMenu: boolean;
watermarkText: string;
autoFormatOptions: AutoFormatOptions;

// Legacy plugin options
contentEditFeatures: ContentEditFeatureSettings;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -138,6 +138,7 @@ export class OptionsPane extends React.Component<OptionPaneProps, OptionState> {
listMenu: this.state.listMenu,
tableMenu: this.state.tableMenu,
imageMenu: this.state.imageMenu,
autoFormatOptions: { ...this.state.autoFormatOptions },
};

if (callback) {
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
import { AutoFormatOptions } from 'roosterjs-content-model-plugins';
import { CodeElement } from './CodeElement';

export class AutoFormatCode extends CodeElement {
constructor(private options: AutoFormatOptions) {
super();
}

getCode() {
return `new roosterjs.AutoFormatPlugin('${this.options}')`;
}
}
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
import { AutoFormatCode } from './AutoFormatCode';
import { CodeElement } from './CodeElement';
import { ContentEditCode } from './ContentEditCode';
import { HyperLinkCode } from './HyperLinkCode';
import { OptionState } from '../OptionState';
import { WatermarkCode } from './WatermarkCode';
import {
AutoFormatPluginCode,
CustomReplaceCode,
EditPluginCode,
ImageEditCode,
Expand Down Expand Up @@ -39,7 +39,7 @@ export class PluginsCode extends PluginsCodeBase {
const pluginList = state.pluginList;

super([
pluginList.autoFormat && new AutoFormatPluginCode(),
pluginList.autoFormat && new AutoFormatCode(state.autoFormatOptions),
pluginList.edit && new EditPluginCode(),
pluginList.paste && new PastePluginCode(),
pluginList.tableEdit && new TableEditPluginCode(),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,6 @@ class SimplePluginCode extends CodeElement {
}
}

export class AutoFormatPluginCode extends SimplePluginCode {
constructor() {
super('AutoFormatPlugin');
}
}

export class EditPluginCode extends SimplePluginCode {
constructor() {
super('EditPlugin');
Expand Down

0 comments on commit c712f3b

Please sign in to comment.