Skip to content

Commit

Permalink
Native Mobile: RichText: fix circular dependency (#56061)
Browse files Browse the repository at this point in the history
  • Loading branch information
ellatrix authored Nov 13, 2023
1 parent 7d606b6 commit 261b00b
Show file tree
Hide file tree
Showing 13 changed files with 30 additions and 34 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@ import {
} from '@wordpress/blocks';
import { useInstanceId, useMergeRefs } from '@wordpress/compose';
import {
__experimentalRichText as RichText,
__unstableCreateElement,
isEmpty,
insert,
Expand Down Expand Up @@ -46,6 +45,7 @@ import {
} from './utils';
import EmbedHandlerPicker from './embed-handler-picker';
import { Content } from './content';
import RichText from './native';

const classes = 'block-editor-rich-text__editable';

Expand Down Expand Up @@ -688,6 +688,8 @@ ForwardedRichTextContainer.Content.defaultProps = {
value: '',
};

ForwardedRichTextContainer.Raw = RichText;

/**
* @see https://github.com/WordPress/gutenberg/blob/HEAD/packages/block-editor/src/components/rich-text/README.md
*/
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
/**
* Internal dependencies
* WordPress dependencies
*/
import { getActiveFormat } from '../get-active-format';
import { getActiveObject } from '../get-active-object';
import { getActiveFormat, getActiveObject } from '@wordpress/rich-text';

export default function FormatEdit( {
formatTypes,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/**
* WordPress dependencies
* Internal dependencies
*/
import { getColorObjectByAttributeValues } from '@wordpress/block-editor';
import { getColorObjectByAttributeValues } from '../../../components/colors';

const FORMAT_TYPE = 'core/text-color';
const REGEX_TO_MATCH = /^has-(.*)-color$/;
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export default () => {};
Original file line number Diff line number Diff line change
Expand Up @@ -29,23 +29,25 @@ import { BACKSPACE, DELETE, ENTER } from '@wordpress/keycodes';
import { isURL } from '@wordpress/url';
import { atSymbol, plus } from '@wordpress/icons';
import { __ } from '@wordpress/i18n';
import {
applyFormat,
getActiveFormat,
getActiveFormats,
insert,
getTextContent,
isEmpty,
create,
toHTMLString,
isCollapsed,
remove,
} from '@wordpress/rich-text';

/**
* Internal dependencies
*/
import { useFormatTypes } from './use-format-types';
import FormatEdit from './format-edit';
import { applyFormat } from '../apply-format';
import { getActiveFormat } from '../get-active-format';
import { getActiveFormats } from '../get-active-formats';
import { insert } from '../insert';
import { getTextContent } from '../get-text-content';
import { isEmpty } from '../is-empty';
import { create } from '../create';
import { toHTMLString } from '../to-html-string';
import { isCollapsed } from '../is-collapsed';
import { remove } from '../remove';
import { getFormatColors } from '../get-format-colors';
import { getFormatColors } from './get-format-colors';
import styles from './style.scss';
import ToolbarButtonWithOptions from './toolbar-button-with-options';

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import { getEditorHtml, render, initializeEditor } from 'test/helpers';
* WordPress dependencies
*/
import { select } from '@wordpress/data';
import { store as blockEditorStore } from '@wordpress/block-editor';
import { store as richTextStore } from '@wordpress/rich-text';
import { coreBlocks } from '@wordpress/block-library';
import {
getBlockTypes,
Expand All @@ -19,8 +19,8 @@ import {
/**
* Internal dependencies
*/
import { store as richTextStore } from '../store';
import RichText from '../component/index.native';
import { store as blockEditorStore } from '../../../../store';
import RichText from '../index.native';

/**
* Mock `useSelect` with various global application settings, e.g., styles.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import {
/**
* Internal dependencies
*/
import RichText from '../../component/index.native';
import RichText from '../../index.native';

describe( 'RichText Performance', () => {
const onCreateUndoLevel = jest.fn();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,7 @@
*/
import { useMemo } from '@wordpress/element';
import { useSelect, useDispatch } from '@wordpress/data';
/**
* Internal dependencies
*/
import { store as richTextStore } from '../store';
import { store as richTextStore } from '@wordpress/rich-text';

function formatTypesSelector( select ) {
return select( richTextStore ).getFormatTypes();
Expand Down
12 changes: 4 additions & 8 deletions packages/editor/src/components/post-title/index.native.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,18 +7,14 @@ import { View } from 'react-native';
* WordPress dependencies
*/
import { Component } from '@wordpress/element';
import {
__experimentalRichText as RichText,
create,
insert,
} from '@wordpress/rich-text';
import { create, insert } from '@wordpress/rich-text';
import { decodeEntities } from '@wordpress/html-entities';
import { withDispatch, withSelect } from '@wordpress/data';
import { withFocusOutside } from '@wordpress/components';
import { withInstanceId, compose } from '@wordpress/compose';
import { __, sprintf } from '@wordpress/i18n';
import { pasteHandler } from '@wordpress/blocks';
import { store as blockEditorStore } from '@wordpress/block-editor';
import { store as blockEditorStore, RichText } from '@wordpress/block-editor';
import { store as editorStore } from '@wordpress/editor';

/**
Expand Down Expand Up @@ -152,7 +148,7 @@ class PostTitle extends Component {
accessibilityLabel={ this.getTitle( title, postType ) }
accessibilityHint={ __( 'Updates the title.' ) }
>
<RichText
<RichText.Raw
setRef={ this.setRef }
accessibilityLabel={ this.getTitle( title, postType ) }
tagName={ 'p' }
Expand All @@ -177,7 +173,7 @@ class PostTitle extends Component {
disableEditingMenu={ true }
__unstableIsSelected={ this.props.isSelected }
__unstableOnCreateUndoLevel={ () => {} }
></RichText>
/>
</View>
);
}
Expand Down
1 change: 0 additions & 1 deletion packages/rich-text/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,6 @@ export {
default as __experimentalRichText,
useRichText as __unstableUseRichText,
} from './component';
export { default as __unstableFormatEdit } from './component/format-edit';

/**
* An object which represents a formatted string. See main `@wordpress/rich-text`
Expand Down

0 comments on commit 261b00b

Please sign in to comment.