Skip to content

Commit

Permalink
Assistant: Disable long sentences Breve feature by default (#38508)
Browse files Browse the repository at this point in the history
* disable long sentences by default

* changelog
  • Loading branch information
dhasilva authored Jul 24, 2024
1 parent 4c6d134 commit 904df75
Show file tree
Hide file tree
Showing 6 changed files with 17 additions and 1 deletion.
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
Significance: patch
Type: enhancement

AI Assistant: Disable long sentences Breve feature by default
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ export const COMPLEX_WORDS: BreveFeatureConfig = {
title: 'Complex words',
tagName: 'span',
className: 'has-proofread-highlight--complex-words',
defaultEnabled: true,
};

const list = new RegExp(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ export const LONG_SENTENCES: BreveFeatureConfig = {
title: 'Long sentences',
tagName: 'span',
className: 'has-proofread-highlight--long-sentences',
defaultEnabled: false,
};

const sentenceRegex = /[^\s][^.!?]+[.!?]+/g;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ export const UNCONFIDENT_WORDS: BreveFeatureConfig = {
title: 'Unconfident words',
tagName: 'span',
className: 'has-proofread-highlight--unconfident-words',
defaultEnabled: true,
};

const list = new RegExp( `\\b(${ words.map( escapeRegExp ).join( '|' ) })\\b`, 'gi' );
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,10 @@
* WordPress dependencies
*/
import { combineReducers } from '@wordpress/data';
/**
* Internal dependencies
*/
import features from '../features';
/**
* Types
*/
Expand All @@ -14,7 +18,11 @@ const disabledFeaturesFromLocalStorage = window.localStorage.getItem(
const initialConfiguration = {
enabled: enabledFromLocalStorage === 'true' || enabledFromLocalStorage === null,
disabled:
disabledFeaturesFromLocalStorage !== null ? JSON.parse( disabledFeaturesFromLocalStorage ) : [],
disabledFeaturesFromLocalStorage !== null
? JSON.parse( disabledFeaturesFromLocalStorage )
: features
.filter( feature => ! feature.config.defaultEnabled )
.map( feature => feature.config.name ),
};

export function configuration(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,7 @@ export type BreveFeatureConfig = {
title: string;
tagName: string;
className: string;
defaultEnabled: boolean;
};

export type BreveFeature = {
Expand Down

0 comments on commit 904df75

Please sign in to comment.