Skip to content

Commit

Permalink
Merge pull request #2550 from microsoft/u/juliaroldi/auto-format-patc…
Browse files Browse the repository at this point in the history
…h-fix

[Patch fix]: Rooster-content-model-plugins Version 9.0.1
  • Loading branch information
juliaroldi authored Apr 2, 2024
2 parents 36a86bc + 76b7f59 commit 0cb9430
Show file tree
Hide file tree
Showing 8 changed files with 33 additions and 11 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,17 @@
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({
autoBullet: ${this.options.autoBullet},
autoLink: ${this.options.autoLink},
autoNumbering: ${this.options.autoNumbering},
autoUnlink: ${this.options.autoUnlink},
})`;
}
}
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
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ export function getListTypeStyle(
listMarkerSegment &&
listMarkerSegment.segmentType == 'Text'
) {
const listMarker = listMarkerSegment.text;
const listMarker = listMarkerSegment.text.trim();
const bulletType = bulletListType[listMarker];

if (bulletType && shouldSearchForBullet) {
Expand Down Expand Up @@ -125,7 +125,7 @@ const bulletListType: Record<string, number> = {
};

const isNewList = (listMarker: string) => {
const marker = listMarker.replace(/[^\w\s]/g, '').trim();
const marker = listMarker.replace(/[^\w\s]/g, '');
const pattern = /^[1aAiI]$/;
return pattern.test(marker);
};
4 changes: 3 additions & 1 deletion versions.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,7 @@
"react": "8.56.0",
"main": "9.0.0",
"legacyAdapter": "8.62.0",
"overrides": {}
"overrides": {
"roosterjs-content-model-plugins": "9.0.1"
}
}

0 comments on commit 0cb9430

Please sign in to comment.