Skip to content

Commit

Permalink
Refactor: replace textarea with rich text editor on Visual Form Build…
Browse files Browse the repository at this point in the history
…er header description (#7494)
  • Loading branch information
glaubersilva authored Sep 17, 2024
1 parent ada6072 commit cdf17eb
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 5 deletions.
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
import type {HeaderDescriptionProps} from '@givewp/forms/propTypes';
import {Interweave} from 'interweave';

/**
* @unreleased Replace <p></p> tag with Interweave to be able to render the content generated through the ClassicEditor component
* @since 3.0.0
*/
export default function HeaderDescription({text}: HeaderDescriptionProps) {
return <p>{text}</p>;
return <Interweave content={text} />;
}
Original file line number Diff line number Diff line change
@@ -1,9 +1,13 @@
import {__} from '@wordpress/i18n';
import {PanelBody, PanelRow, SelectControl, TextareaControl, TextControl, ToggleControl} from '@wordpress/components';
import {PanelBody, PanelRow, SelectControl, TextControl, ToggleControl} from '@wordpress/components';
import {setFormSettings, useFormState} from '@givewp/form-builder/stores/form-state';
import MediaLibrary from '@givewp/form-builder/components/settings/MediaLibrary';
import {upload} from '@wordpress/icons';
import {ClassicEditor} from '@givewp/form-builder-library';

/**
* @unreleased Replace TextareaControl component with ClassicEditor component on the description option
*/
export default function Header({dispatch, publishSettings}) {
const {
settings: {
Expand Down Expand Up @@ -99,10 +103,12 @@ export default function Header({dispatch, publishSettings}) {
)}
{showDescription && (
<PanelRow>
<TextareaControl
<ClassicEditor
key={'givewp-header-description'}
id={'givewp-header-description'}
label={__('Description', 'give')}
value={description}
onChange={(description) => {
content={description}
setContent={(description) => {
dispatch(
setFormSettings({
description,
Expand All @@ -112,6 +118,7 @@ export default function Header({dispatch, publishSettings}) {
description,
});
}}
rows={10}
/>
</PanelRow>
)}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -473,3 +473,9 @@ This creates a consistent separator between the tabs and the rest of the sidebar
}
}
}

/* Ensure that the link editor modal from the ClassicEditor component will be visible. */
#wp-link-backdrop,
#wp-link-wrap {
z-index: 9999999999 !important;
}

0 comments on commit cdf17eb

Please sign in to comment.