Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/master' into rnmobile/fix-develop
Browse files Browse the repository at this point in the history
  • Loading branch information
Tug committed Mar 13, 2019
2 parents a5f05a2 + 186b672 commit b2e9e36
Show file tree
Hide file tree
Showing 71 changed files with 811 additions and 661 deletions.
27 changes: 15 additions & 12 deletions bin/build-plugin-zip.sh
Original file line number Diff line number Diff line change
Expand Up @@ -47,18 +47,21 @@ fi
# Do a dry run of the repository reset. Prompting the user for a list of all
# files that will be removed should prevent them from losing important files!
status "Resetting the repository to pristine condition. ✨"
git clean -xdf --dry-run
warning "🚨 About to delete everything above! Is this okay? 🚨"
echo -n "[y]es/[N]o: "
read answer
if [ "$answer" != "${answer#[Yy]}" ]; then
# Remove ignored files to reset repository to pristine condition. Previous
# test ensures that changed files abort the plugin build.
status "Cleaning working directory... 🛀"
git clean -xdf
else
error "Fair enough; aborting. Tidy up your repo and try again. 🙂"
exit 1
to_clean=$(git clean -xdf --dry-run)
if [ ! -z "$to_clean" ]; then
echo $to_clean
warning "🚨 About to delete everything above! Is this okay? 🚨"
echo -n "[y]es/[N]o: "
read answer
if [ "$answer" != "${answer#[Yy]}" ]; then
# Remove ignored files to reset repository to pristine condition. Previous
# test ensures that changed files abort the plugin build.
status "Cleaning working directory... 🛀"
git clean -xdf
else
error "Fair enough; aborting. Tidy up your repo and try again. 🙂"
exit 1
fi
fi

# Download all vendor scripts
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,7 @@ This POT file can then be used as the template for new translations. You should
cp myguten.pot myguten-eo.po
```

For this simple example, you can simply edit the `.po` file in your editor and add the translation to all the `msgstr` sets. For a larger, more complex set of translation, the [Glotpress](https://glotpress.blog/) and [poedit](https://poedit.net/) tools exist to help.
For this simple example, you can simply edit the `.po` file in your editor and add the translation to all the `msgstr` sets. For a larger, more complex set of translation, the [GlotPress](https://glotpress.blog/) and [Poedit](https://poedit.net/) tools exist to help.

You need also to add the `Language: eo` parameter. Here is full `myguten-eo.po` translated file

Expand Down
1 change: 0 additions & 1 deletion lib/load.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@

require dirname( __FILE__ ) . '/client-assets.php';
require dirname( __FILE__ ) . '/i18n.php';
require dirname( __FILE__ ) . '/register.php';
require dirname( __FILE__ ) . '/demo.php';
require dirname( __FILE__ ) . '/widgets-page.php';

Expand Down
86 changes: 0 additions & 86 deletions lib/register.php

This file was deleted.

1 change: 1 addition & 0 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

53 changes: 27 additions & 26 deletions packages/block-editor/src/components/inserter/menu.js
Original file line number Diff line number Diff line change
Expand Up @@ -360,21 +360,30 @@ export class InserterMenu extends Component {
}

export default compose(
withSelect( ( select, { rootClientId } ) => {
withSelect( ( select, { clientId, isAppender, rootClientId } ) => {
const {
getInserterItems,
getBlockName,
getBlockRootClientId,
getBlockSelectionEnd,
} = select( 'core/block-editor' );
const {
getChildBlockNames,
} = select( 'core/blocks' );

const rootBlockName = getBlockName( rootClientId );
let destinationRootClientId = rootClientId;
if ( ! destinationRootClientId && ! clientId && ! isAppender ) {
const end = getBlockSelectionEnd();
if ( end ) {
destinationRootClientId = getBlockRootClientId( end ) || undefined;
}
}
const destinationRootBlockName = getBlockName( destinationRootClientId );

return {
rootChildBlocks: getChildBlockNames( rootBlockName ),
items: getInserterItems( rootClientId ),
rootClientId,
rootChildBlocks: getChildBlockNames( destinationRootBlockName ),
items: getInserterItems( destinationRootClientId ),
destinationRootClientId,
};
} ),
withDispatch( ( dispatch, ownProps, { select } ) => {
Expand All @@ -388,50 +397,39 @@ export default compose(
__experimentalFetchReusableBlocks: fetchReusableBlocks,
} = dispatch( 'core/editor' );

// To avoid duplication, getInsertionPoint is extracted and used in two event handlers
// To avoid duplication, getInsertionIndex is extracted and used in two event handlers
// This breaks the withDispatch not containing any logic rule.
// Since it's a function only called when the event handlers are called,
// it's fine to extract it.
// eslint-disable-next-line no-restricted-syntax
function getInsertionPoint() {
function getInsertionIndex() {
const {
getBlockIndex,
getBlockRootClientId,
getBlockSelectionEnd,
getBlockOrder,
} = select( 'core/block-editor' );
const { clientId, rootClientId, isAppender } = ownProps;
const { clientId, destinationRootClientId, isAppender } = ownProps;

// If the clientId is defined, we insert at the position of the block.
if ( clientId ) {
return {
index: getBlockIndex( clientId, rootClientId ),
rootClientId,
};
return getBlockIndex( clientId, destinationRootClientId );
}

// If there a selected block, we insert after the selected block.
const end = getBlockSelectionEnd();
if ( ! isAppender && end ) {
const selectedBlockRootClientId = getBlockRootClientId( end ) || undefined;
return {
index: getBlockIndex( end, selectedBlockRootClientId ) + 1,
rootClientId: selectedBlockRootClientId,
};
return getBlockIndex( end, destinationRootClientId ) + 1;
}

// Otherwise, we insert at the end of the current rootClientId
return {
index: getBlockOrder( rootClientId ).length,
rootClientId,
};
return getBlockOrder( destinationRootClientId ).length;
}

return {
fetchReusableBlocks,
showInsertionPoint() {
const { index, rootClientId } = getInsertionPoint();
showInsertionPoint( rootClientId, index );
const index = getInsertionIndex();
showInsertionPoint( ownProps.destinationRootClientId, index );
},
hideInsertionPoint,
onSelect( item ) {
Expand All @@ -449,8 +447,11 @@ export default compose(
if ( ! isAppender && selectedBlock && isUnmodifiedDefaultBlock( selectedBlock ) ) {
replaceBlocks( selectedBlock.clientId, insertedBlock );
} else {
const { index, rootClientId } = getInsertionPoint();
insertBlock( insertedBlock, index, rootClientId );
insertBlock(
insertedBlock,
getInsertionIndex(),
ownProps.destinationRootClientId
);
}

ownProps.onSelect();
Expand Down
26 changes: 2 additions & 24 deletions packages/block-editor/src/components/provider/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,30 +3,8 @@
*/
import { Component } from '@wordpress/element';
import { DropZoneProvider, SlotFillProvider } from '@wordpress/components';
import { withDispatch, RegistryConsumer } from '@wordpress/data';
import { createHigherOrderComponent, compose } from '@wordpress/compose';

/**
* Higher-order component which renders the original component with the current
* registry context passed as its `registry` prop.
*
* @param {WPComponent} OriginalComponent Original component.
*
* @return {WPComponent} Enhanced component.
*/
const withRegistry = createHigherOrderComponent(
( OriginalComponent ) => ( props ) => (
<RegistryConsumer>
{ ( registry ) => (
<OriginalComponent
{ ...props }
registry={ registry }
/>
) }
</RegistryConsumer>
),
'withRegistry'
);
import { withDispatch, withRegistry } from '@wordpress/data';
import { compose } from '@wordpress/compose';

class BlockEditorProvider extends Component {
componentDidMount() {
Expand Down
13 changes: 10 additions & 3 deletions packages/block-editor/src/components/rich-text/format-edit.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
*/
import { withSelect } from '@wordpress/data';
import { Fragment } from '@wordpress/element';
import { getActiveFormat } from '@wordpress/rich-text';
import { getActiveFormat, getActiveObject } from '@wordpress/rich-text';

const FormatEdit = ( { formatTypes, onChange, value } ) => {
return (
Expand All @@ -15,13 +15,20 @@ const FormatEdit = ( { formatTypes, onChange, value } ) => {

const activeFormat = getActiveFormat( value, name );
const isActive = activeFormat !== undefined;
const activeAttributes = isActive ? activeFormat.attributes || {} : {};
const activeObject = getActiveObject( value );
const isObjectActive = activeObject !== undefined;

return (
<Edit
key={ name }
isActive={ isActive }
activeAttributes={ activeAttributes }
activeAttributes={
isActive ? activeFormat.attributes || {} : {}
}
isObjectActive={ isObjectActive }
activeObjectAttributes={
isObjectActive ? activeObject.attributes || {} : {}
}
value={ value }
onChange={ onChange }
/>
Expand Down
24 changes: 13 additions & 11 deletions packages/block-editor/src/components/rich-text/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -177,10 +177,10 @@ export class RichText extends Component {
* @return {Object} The current record (value and selection).
*/
getRecord() {
const { formats, text } = this.formatToValue( this.props.value );
const { formats, replacements, text } = this.formatToValue( this.props.value );
const { start, end, selectedFormat } = this.state;

return { formats, text, start, end, selectedFormat };
return { formats, replacements, text, start, end, selectedFormat };
}

createRecord() {
Expand Down Expand Up @@ -394,13 +394,17 @@ export class RichText extends Component {
}

let { selectedFormat } = this.state;
const { formats, text, start, end } = this.createRecord();
const { formats, replacements, text, start, end } = this.createRecord();

if ( this.formatPlaceholder ) {
formats[ this.state.start ] = formats[ this.state.start ] || [];
formats[ this.state.start ].push( this.formatPlaceholder );
selectedFormat = formats[ this.state.start ].length;
} else if ( selectedFormat ) {
selectedFormat = this.formatPlaceholder.length;

if ( selectedFormat > 0 ) {
formats[ this.state.start ] = this.formatPlaceholder;
} else {
delete formats[ this.state.start ];
}
} else if ( selectedFormat > 0 ) {
const formatsBefore = formats[ start - 1 ] || [];
const formatsAfter = formats[ start ] || [];

Expand All @@ -411,12 +415,13 @@ export class RichText extends Component {
}

source = source.slice( 0, selectedFormat );

formats[ this.state.start ] = source;
} else {
delete formats[ this.state.start ];
}

const change = { formats, text, start, end, selectedFormat };
const change = { formats, replacements, text, start, end, selectedFormat };

this.onChange( change, {
withoutHistory: true,
Expand Down Expand Up @@ -936,7 +941,6 @@ export class RichText extends Component {
return unstableToDom( {
value,
multilineTag: this.multilineTag,
multilineWrapperTags: this.multilineWrapperTags,
prepareEditableTree: this.props.prepareEditableTree,
} ).body.innerHTML;
}
Expand Down Expand Up @@ -975,7 +979,6 @@ export class RichText extends Component {
return children.fromDOM( unstableToDom( {
value,
multilineTag: this.multilineTag,
multilineWrapperTags: this.multilineWrapperTags,
isEditableTree: false,
} ).body.childNodes );
}
Expand All @@ -984,7 +987,6 @@ export class RichText extends Component {
return toHTMLString( {
value,
multilineTag: this.multilineTag,
multilineWrapperTags: this.multilineWrapperTags,
} );
}

Expand Down
Loading

0 comments on commit b2e9e36

Please sign in to comment.