Skip to content

Commit

Permalink
RichText & Docs: remove or rename undocumented functions and constants
Browse files Browse the repository at this point in the history
  • Loading branch information
ellatrix committed Mar 28, 2019
1 parent e4108fc commit e3309c7
Show file tree
Hide file tree
Showing 10 changed files with 46 additions and 102 deletions.
30 changes: 7 additions & 23 deletions bin/update-readmes.js
Original file line number Diff line number Diff line change
Expand Up @@ -35,31 +35,15 @@ const packages = [
'wordcount',
];

const getArgsForPackage = ( packageName ) => {
switch ( packageName ) {
case 'rich-text':
return [
`packages/${ packageName }/src/index.js`,
`--output packages/${ packageName }/README.md`,
'--to-token',
'--ignore "/unstable|experimental|^apply$|^changeListType$|^charAt$|^getSelectionStart$|^getSelectionEnd$|^indentListItems$|^insertLineBreak$|^insertLineSeparator$|^isEmptyLine$|^LINE_SEPARATOR$|^outdentListItems$/i"',
];
default:
return [
`packages/${ packageName }/src/index.js`,
`--output packages/${ packageName }/README.md`,
'--to-token',
'--ignore "/unstable|experimental/i"',
];
}
};

Promise.all( packages.map( async ( packageName ) => {
const args = getArgsForPackage( packageName );
const pathToDocGen = path.join( __dirname, '..', 'node_modules', '.bin', 'docgen' );
const { status, stderr } = await spawn(
pathToDocGen,
args,
path.join( __dirname, '..', 'node_modules', '.bin', 'docgen' ),
[
`packages/${ packageName }/src/index.js`,
`--output packages/${ packageName }/README.md`,
'--to-token',
'--ignore "/unstable|experimental/i"',
],
{ shell: true },
);
if ( status !== 0 ) {
Expand Down
19 changes: 9 additions & 10 deletions packages/block-editor/src/components/rich-text/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -33,15 +33,14 @@ import {
toHTMLString,
getTextContent,
insert,
insertLineBreak,
insertLineSeparator,
isEmptyLine,
unstableToDom,
__unstableInsertLineSeparator as insertLineSeparator,
__unstableIsEmptyLine as isEmptyLine,
__unstableToDom as toDom,
remove,
removeFormat,
isCollapsed,
LINE_SEPARATOR,
indentListItems,
__UNSTABLE_LINE_SEPARATOR as LINE_SEPARATOR,
__unstableIndentListItems as indentListItems,
} from '@wordpress/rich-text';
import { decodeEntities } from '@wordpress/html-entities';
import { withFilters, IsolatedEventContainer } from '@wordpress/components';
Expand Down Expand Up @@ -737,14 +736,14 @@ export class RichText extends Component {

if ( this.multilineTag ) {
if ( event.shiftKey ) {
this.onChange( insertLineBreak( record ) );
this.onChange( insert( record, '\n' ) );
} else if ( this.onSplit && isEmptyLine( record ) ) {
this.onSplit( ...split( record ).map( this.valueToFormat ) );
} else {
this.onChange( insertLineSeparator( record ) );
}
} else if ( event.shiftKey || ! this.onSplit ) {
this.onChange( insertLineBreak( record ) );
this.onChange( insert( record, '\n' ) );
} else {
this.splitContent();
}
Expand Down Expand Up @@ -1017,7 +1016,7 @@ export class RichText extends Component {
}

valueToEditableHTML( value ) {
return unstableToDom( {
return toDom( {
value,
multilineTag: this.multilineTag,
prepareEditableTree: this.props.prepareEditableTree,
Expand Down Expand Up @@ -1055,7 +1054,7 @@ export class RichText extends Component {

// Handle deprecated `children` and `node` sources.
if ( this.usedDeprecatedChildrenSource ) {
return children.fromDOM( unstableToDom( {
return children.fromDOM( toDom( {
value,
multilineTag: this.multilineTag,
isEditableTree: false,
Expand Down
6 changes: 3 additions & 3 deletions packages/block-editor/src/components/rich-text/list-edit.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,9 @@ import { Toolbar } from '@wordpress/components';
import { __, _x } from '@wordpress/i18n';
import { Fragment } from '@wordpress/element';
import {
indentListItems,
outdentListItems,
changeListType,
__unstableIndentListItems as indentListItems,
__unstableOutdentListItems as outdentListItems,
__unstableChangeListType as changeListType,
} from '@wordpress/rich-text';

/**
Expand Down
5 changes: 2 additions & 3 deletions packages/block-editor/src/components/rich-text/patterns.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ import {
remove,
applyFormat,
getTextContent,
getSelectionStart,
slice,
} from '@wordpress/rich-text';

Expand All @@ -20,7 +19,7 @@ export function getPatterns( { onReplace, valueToFormat } ) {
return record;
}

const start = getSelectionStart( record );
const { start } = record;
const text = getTextContent( record );
const characterBefore = text.slice( start - 1, start );

Expand All @@ -46,7 +45,7 @@ export function getPatterns( { onReplace, valueToFormat } ) {
},
( record ) => {
const BACKTICK = '`';
const start = getSelectionStart( record );
const { start } = record;
const text = getTextContent( record );
const characterBefore = text.slice( start - 1, start );

Expand Down
18 changes: 18 additions & 0 deletions packages/rich-text/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,21 @@
## 3.2.0 (Unreleased)

### Internal

- Removed and renamed undocumented functions and constants:
* Removed `charAt`
* Removed `getSelectionStart`
* Removed `getSelectionEnd`
* Removed `insertLineBreak`
* Renamed `isEmptyLine` to `__unstableIsEmptyLine`
* Renamed `insertLineSeparator` to `__unstableInsertLineSeparator`
* Renamed `apply` to `__unstableApply`
* Renamed `unstableToDom` to `__unstableToDom`
* Renamed `LINE_SEPARATOR` to `__UNSTABLE_LINE_SEPARATOR`
* Renamed `indentListItems` to `__unstableIndentListItems`
* Renamed `outdentListItems` to `__unstableOutdentListItems`
* Renamed `changeListType` to `__unstableChangeListType`

## 3.1.0 (2019-03-06)

### Enhancement
Expand Down
12 changes: 0 additions & 12 deletions packages/rich-text/src/char-at.js

This file was deleted.

12 changes: 0 additions & 12 deletions packages/rich-text/src/get-selection-end.js

This file was deleted.

12 changes: 0 additions & 12 deletions packages/rich-text/src/get-selection-start.js

This file was deleted.

18 changes: 7 additions & 11 deletions packages/rich-text/src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,32 +4,28 @@
import './store';

export { applyFormat } from './apply-format';
export { charAt } from './char-at';
export { concat } from './concat';
export { create } from './create';
export { getActiveFormat } from './get-active-format';
export { getActiveObject } from './get-active-object';
export { getSelectionEnd } from './get-selection-end';
export { getSelectionStart } from './get-selection-start';
export { getTextContent } from './get-text-content';
export { isCollapsed } from './is-collapsed';
export { isEmpty, isEmptyLine } from './is-empty';
export { isEmpty, isEmptyLine as __unstableIsEmptyLine } from './is-empty';
export { join } from './join';
export { registerFormatType } from './register-format-type';
export { removeFormat } from './remove-format';
export { remove } from './remove';
export { replace } from './replace';
export { insert } from './insert';
export { insertLineBreak } from './insert-line-break';
export { insertLineSeparator } from './insert-line-separator';
export { insertLineSeparator as __unstableInsertLineSeparator } from './insert-line-separator';
export { insertObject } from './insert-object';
export { slice } from './slice';
export { split } from './split';
export { apply, toDom as unstableToDom } from './to-dom';
export { apply as __unstableApply, toDom as __unstableToDom } from './to-dom';
export { toHTMLString } from './to-html-string';
export { toggleFormat } from './toggle-format';
export { LINE_SEPARATOR } from './special-characters';
export { LINE_SEPARATOR as __UNSTABLE_LINE_SEPARATOR } from './special-characters';
export { unregisterFormatType } from './unregister-format-type';
export { indentListItems } from './indent-list-items';
export { outdentListItems } from './outdent-list-items';
export { changeListType } from './change-list-type';
export { indentListItems as __unstableIndentListItems } from './indent-list-items';
export { outdentListItems as __unstableOutdentListItems } from './outdent-list-items';
export { changeListType as __unstableChangeListType } from './change-list-type';
16 changes: 0 additions & 16 deletions packages/rich-text/src/insert-line-break.js

This file was deleted.

0 comments on commit e3309c7

Please sign in to comment.