Skip to content

Commit

Permalink
Merge branch 'master' of https://github.com/WordPress/gutenberg into …
Browse files Browse the repository at this point in the history
…rnmobile/port-quote-block-step-1

* 'master' of https://github.com/WordPress/gutenberg: (22 commits)
  Add removed periods to block descriptions. (#11367)
  Remove findDOMNode usage from the inserter (#11363)
  Remove deprecated componentWillReceiveProps from TinyMCE component (#11368)
  Create file blocks when dropping multiple files at once (#11297)
  Try avoiding the deprecated findDOMNode API from DropZone Provider (#11168)
  Fix: make meta+A behaviour of selecting all blocks work on safari and firefox. (#8180)
  Remove _wpGutenbergCodeEditorSettings and wp.codeEditor assets (#11342)
  Remove the Cloudflare warning (#11350)
  Image Block: Use source_url for media file link (#11254)
  Enhance styling of nextpage block using the Hr element (#11354)
  Embed block refactor and tidy (#10958)
  Nonce Middleware: Wrap the nonce middleware function into it's own function that isn't regenerated on every API request. (#11347)
  Fix RTL block alignments (#11293)
  RichText: fix buggy enter/delete behaviour (#11287)
  Remove code coverage setup (#11198)
  Parser: Runs all parser implementations against the same tests (#11320)
  Stop trying to autosave when title and classic block content both are empty. (#10404)
  Fix "Mac OS" typo + use fancy quotes consistently (#11310)
  Update documentation link paths (#11324)
  Editor: Reshape blocks state under own key (#11315)
  ...

# Conflicts:
#	gutenberg-mobile
  • Loading branch information
daniloercoli committed Nov 1, 2018
2 parents 4d25e41 + 5d3c7a1 commit 4e7dd62
Show file tree
Hide file tree
Showing 84 changed files with 3,857 additions and 3,660 deletions.
4 changes: 1 addition & 3 deletions .eslintignore
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
build
build-module
coverage
node_modules
test/e2e/test-plugins
vendor
packages/block-serialization-spec-parser/index.js
gutenberg-mobile
packages/block-serialization-spec-parser/parser.js
1 change: 0 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
build
build-module
build-style
coverage
node_modules
gutenberg.zip
languages/gutenberg.pot
Expand Down
3 changes: 0 additions & 3 deletions .gitmodules

This file was deleted.

1 change: 0 additions & 1 deletion .stylelintignore

This file was deleted.

41 changes: 0 additions & 41 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -69,44 +69,3 @@ jobs:
script:
- npm install || exit 1
- ./bin/run-e2e-tests.sh || exit 1
- stage: test
language: node_js
node_js: 8
env:
LANE='node'
GUTENBERG_AS_PARENT=true
CHECK_CORRECTNESS='true'
cache:
yarn: true
script:
- cd ./gutenberg-mobile
- yarn install
- ./.travis/travis-checks-js.sh
- stage: test
language: node_js
node_js: 8
env:
LANE='node'
GUTENBERG_AS_PARENT=true
CHECK_TESTS='true'
TEST_RN_PLATFORM='android'
cache:
yarn: true
script:
- cd ./gutenberg-mobile
- yarn install
- ./.travis/travis-checks-js.sh
- stage: test
language: node_js
node_js: 8
env:
LANE='node'
GUTENBERG_AS_PARENT=true
CHECK_TESTS='true'
TEST_RN_PLATFORM='ios'
cache:
yarn: true
script:
- cd ./gutenberg-mobile
- yarn install
- ./.travis/travis-checks-js.sh
1 change: 1 addition & 0 deletions CONTRIBUTORS.md
Original file line number Diff line number Diff line change
Expand Up @@ -110,5 +110,6 @@ This list is manually curated to include valuable contributions by volunteers th
| @jorgefilipecosta | |
| @ajitbohra | |
| @ChrisVanPatten | |
| @mayukojpn | @mayukojpn |
| @tofumatt | @lonelyvegan |
| @LukePettway | @luke_pettway |
1 change: 0 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
# Gutenberg
[![Build Status](https://img.shields.io/travis/WordPress/gutenberg/master.svg)](https://travis-ci.org/WordPress/gutenberg)
[![Coverage](https://img.shields.io/codecov/c/github/WordPress/gutenberg/master.svg)](https://codecov.io/gh/WordPress/gutenberg)
[![lerna](https://img.shields.io/badge/maintained%20with-lerna-cc00ff.svg)](https://lernajs.io/)

Printing since 1440.
Expand Down
9 changes: 0 additions & 9 deletions codecov.yml

This file was deleted.

2 changes: 1 addition & 1 deletion docs/readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

Gutenberg began as a transformation of the WordPress editor — a new interface for adding, editing, and manipulating content. It seeks to make it easy for anyone to create rich, flexible content layouts with a block-based UI. All types of page components are represented as modular blocks, which means they can be accessed from a unified block menu, dropped anywhere on a page, and directly edited to create the custom presentation the user wants.

It is a fundamental modernization and transformation of how the WordPress experience works, creating new opportunities for both users and developers. Gutenberg introduces new frameworks, interaction patterns, functionality, and user experiences for WordPress. And similar to a new Mac OS version, we will talk about "Gutenberg", and all the new possibilities it enables, until eventually the idea of Gutenberg as a separate entity will fade and it will simply be WordPress.
It is a fundamental modernization and transformation of how the WordPress experience works, creating new opportunities for both users and developers. Gutenberg introduces new frameworks, interaction patterns, functionality, and user experiences for WordPress. And similar to a new macOS version, we will talk about Gutenberg, and all the new possibilities it enables, until eventually the idea of Gutenberg as a separate entity will fade and it will simply be WordPress.

![Gutenberg Demo](https://cldup.com/kZXGDcGPMU.gif)

Expand Down
30 changes: 0 additions & 30 deletions docs/reference/testing-overview.md
Original file line number Diff line number Diff line change
Expand Up @@ -342,11 +342,6 @@ test( 'should contain mars if planets is true', () => {
It's tempting to snapshot deep renders, but that makes for huge snapshots. Additionally, deep renders no longer test a single component, but an entire tree. With `shallow`, we snapshot just the components that are directly rendered by the component we want to test.

### Code Coverage

Code coverage is measured for each PR using the [codecov.io](https://codecov.io/gh/WordPress/gutenberg) tool.
[Code coverage](https://en.wikipedia.org/wiki/Code_coverage) is a way of measuring the amount of code covered by the tests in the test suite of a project. In Gutenberg, it is currently measured for JavaScript code only.

## End to end Testing

If you're using the built-in [local environment](https://github.com/WordPress/gutenberg/blob/master/CONTRIBUTING.md#local-environment), you can run the e2e tests locally using this command:
Expand Down Expand Up @@ -379,30 +374,5 @@ Code style in PHP is enforced using [PHP_CodeSniffer](https://github.com/squizla

To run unit tests only, without the linter, use `npm run test-unit-php` instead.

## Native Mobile Testing

To enable automated testing against the native mobile app currently in development, the whole of the mobile source code is pulled in as a git submodule. Its testsuite is included in the Travis tests run but it can also be used locally, during development.

To test locally, along with the typical Gutenberg setup and testing instructions already mentioned earlier, make sure you check out the code of the submodule:
```
git submodule --init --recursive
```
You can then use the available script to launch the mobile testsuite in isolation:
```
npm run test-mobile
```

or the typical `npm run test` to run all the lint, unit and mobile tests in one go.

The mobile tests pick up the compiled Gutenberg code/packages and so, don't forget to run `npm install` (while at the Gutenberg root) after you've made changes to the code.

### Debugging native mobile

Say you have made some changes to Gutenberg's code and turns out the mobile tests get broken. What's the path forward? Hopefully, the Jest tests output will have an error message and stacktrace that is indicative enough and helps point where the error happens and what went wrong. Oftenly, what happens is that the code being shared between the web and the mobile project is no longer compatible.

For example, changing an intermediate interface can inadvertently bring the `file.js` and `file.native.js` pair out of sync. You'll then need to update the `.native.js` file to adhere to the new interface or iterate on the interface itself. Feel free to reach out to mobile devs for help if needed.

In other usual cases, you might directly employ HTML elements in a `render()` function but those are not actually offered by React Native, the UI framework the native mobile is build on. Those elements are usually starting with a lower-case character like `div` or `span`. In any case that code is incompatible or doesn't make sense for mobile, what needs to be done is to wrap that code in a new component and provide a "nativized" variant of it to be loaded when on native mobile instead. To "nativize" a component just create a new `.native.js` file right alongside the web version one and in it return/run the code that is compatible with mobile. The proper variant will be picked up by the toolchain automatically.

[snapshot testing]: https://facebook.github.io/jest/docs/en/snapshot-testing.html
[update snapshots]: https://facebook.github.io/jest/docs/en/snapshot-testing.html#updating-snapshots
1 change: 0 additions & 1 deletion jsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@
"exclude": [
"build",
"build-module",
"coverage",
"node_modules",
"test/e2e/test-plugins",
"vendor"
Expand Down
39 changes: 0 additions & 39 deletions lib/client-assets.php
Original file line number Diff line number Diff line change
Expand Up @@ -1239,32 +1239,6 @@ function gutenberg_default_post_format_template( $settings, $post ) {
}
add_filter( 'block_editor_settings', 'gutenberg_default_post_format_template', 10, 2 );

/**
* The code editor settings that were last captured by
* gutenberg_capture_code_editor_settings().
*
* @var array|false
*/
$gutenberg_captured_code_editor_settings = false;

/**
* When passed to the wp_code_editor_settings filter, this function captures
* the code editor settings given to it and then prevents
* wp_enqueue_code_editor() from enqueuing any assets.
*
* This is a workaround until e.g. code_editor_settings() is added to Core.
*
* @since 2.1.0
*
* @param array $settings Code editor settings.
* @return false
*/
function gutenberg_capture_code_editor_settings( $settings ) {
global $gutenberg_captured_code_editor_settings;
$gutenberg_captured_code_editor_settings = $settings;
return false;
}

/**
* Retrieve a stored autosave that is newer than the post save.
*
Expand Down Expand Up @@ -1509,19 +1483,6 @@ function gutenberg_editor_scripts_and_styles( $hook ) {
);
wp_localize_script( 'wp-editor', '_wpMetaBoxUrl', $meta_box_url );

// Populate default code editor settings by short-circuiting wp_enqueue_code_editor.
global $gutenberg_captured_code_editor_settings;
add_filter( 'wp_code_editor_settings', 'gutenberg_capture_code_editor_settings' );
wp_enqueue_code_editor( array( 'type' => 'text/html' ) );
remove_filter( 'wp_code_editor_settings', 'gutenberg_capture_code_editor_settings' );
wp_add_inline_script(
'wp-editor',
sprintf(
'window._wpGutenbergCodeEditorSettings = %s;',
wp_json_encode( $gutenberg_captured_code_editor_settings )
)
);

// Initialize the editor.
$gutenberg_theme_support = get_theme_support( 'gutenberg' );
$align_wide = get_theme_support( 'align-wide' );
Expand Down
155 changes: 2 additions & 153 deletions lib/compat.php
Original file line number Diff line number Diff line change
Expand Up @@ -134,19 +134,15 @@ function gutenberg_check_if_classic_needs_warning_about_blocks() {
return;
}

if ( ! has_blocks( $post ) && ! isset( $_REQUEST['cloudflare-error'] ) ) {
if ( ! has_blocks( $post ) ) {
return;
}

// Enqueue the JS we're going to need in the dialog.
wp_enqueue_script( 'wp-a11y' );
wp_enqueue_script( 'wp-sanitize' );

if ( isset( $_REQUEST['cloudflare-error'] ) ) {
add_action( 'admin_footer', 'gutenberg_warn_classic_about_cloudflare' );
} else {
add_action( 'admin_footer', 'gutenberg_warn_classic_about_blocks' );
}
add_action( 'admin_footer', 'gutenberg_warn_classic_about_blocks' );
}
add_action( 'admin_enqueue_scripts', 'gutenberg_check_if_classic_needs_warning_about_blocks' );

Expand Down Expand Up @@ -308,150 +304,3 @@ function gutenberg_warn_classic_about_blocks() {
</script>
<?php
}

/**
* Adds a warning to the Classic Editor when CloudFlare is blocking REST API requests.
*
* @since 3.4.0
*/
function gutenberg_warn_classic_about_cloudflare() {
?>
<style type="text/css">
#cloudflare-block-dialog .notification-dialog {
position: fixed;
top: 50%;
left: 50%;
width: 500px;
box-sizing: border-box;
transform: translate(-50%, -50%);
margin: 0;
padding: 25px;
max-height: 90%;
background: #fff;
box-shadow: 0 3px 6px rgba(0, 0, 0, 0.3);
line-height: 1.5;
z-index: 1000005;
overflow-y: auto;
}

#cloudflare-block-dialog ul {
list-style: initial;
padding-left: 20px;
}

@media only screen and (max-height: 480px), screen and (max-width: 450px) {
#cloudflare-block-dialog .notification-dialog {
top: 0;
left: 0;
width: 100%;
height: 100%;
transform: none;
max-height: 100%;
}
}
</style>

<div id="cloudflare-block-dialog" class="notification-dialog-wrap">
<div class="notification-dialog-background"></div>
<div class="notification-dialog">
<div class="cloudflare-block-message">
<h2><?php _e( 'Cloudflare is blocking REST API requests', 'gutenberg' ); ?></h2>
<p><?php _e( 'Your site uses Cloudflare, which provides a Web Application Firewall (WAF) to secure your site against attacks. Unfortunately, some of these WAF rules are incorrectly blocking legitimate access to your site, preventing Gutenberg from functioning correctly.', 'gutenberg' ); ?></p>
<p><?php _e( "We're working closely with Cloudflare to fix this issue, but in the mean time, you can work around it in one of two ways:", 'gutenberg' ); ?></p>
<ul>
<li><?php _e( 'If you have a Cloudflare Pro account, log in to Cloudflare, visit the Firewall settings page, open the "Cloudflare Rule Set" details, open the "Cloudflare WordPress" ruleset, then set the rules "WP0025A" and "WP0025B" to "Disable".', 'gutenberg' ); ?></li>
<li>
<?php
printf(
/* translators: %s: link to a comment in the Gutenberg repository */
__( 'For free Cloudflare accounts, you can <a href="%s">change the REST API URL</a>, to avoid triggering the WAF rules. Please be aware that this may cause issues with other plugins that use the REST API, and removes any other protection Cloudflare may be offering for the REST API.', 'gutenberg' ),
'https://github.com/WordPress/gutenberg/issues/2704#issuecomment-410582252'
);
?>
</li>
</ul>
<p>
<?php
printf(
/* translators: %s link to an issue in the Gutenberg repository */
__( 'If neither of these options are possible for you, please <a href="%s">follow this issue for updates</a>. We hope to have this issue rectified soon!', 'gutenberg' ),
'https://github.com/WordPress/gutenberg/issues/2704'
);
?>
</p>
</div>
<p>
<button type="button" class="button button-primary cloudflare-block-classic-button"><?php _e( 'Continue to Classic Editor', 'gutenberg' ); ?></button>
</p>
</div>
</div>

<script type="text/javascript">
/* <![CDATA[ */
( function( $ ) {
var dialog = {};

dialog.init = function() {
// The modal
dialog.warning = $( '#cloudflare-block-dialog' );
// Get the links and buttons within the modal.
dialog.warningTabbables = dialog.warning.find( 'a, button' );

// Get the text within the modal.
dialog.rawMessage = dialog.warning.find( '.cloudflare-block-message' ).text();

// Hide all the #wpwrap content from assistive technologies.
$( '#wpwrap' ).attr( 'aria-hidden', 'true' );

// Detach the warning modal from its position and append it to the body.
$( document.body )
.addClass( 'modal-open' )
.append( dialog.warning.detach() );

// Reveal the modal and set focus on the Gutenberg button.
dialog.warning
.removeClass( 'hidden' )
.find( '.cloudflare-block-classic-button' ).focus();

// Attach event handlers.
dialog.warningTabbables.on( 'keydown', dialog.constrainTabbing );
dialog.warning.on( 'click', '.cloudflare-block-classic-button', dialog.dismissWarning );

// Make screen readers announce the warning message after a short delay (necessary for some screen readers).
setTimeout( function() {
wp.a11y.speak( wp.sanitize.stripTags( dialog.rawMessage.replace( /\s+/g, ' ' ) ), 'assertive' );
}, 1000 );
};

dialog.constrainTabbing = function( event ) {
var firstTabbable, lastTabbable;

if ( 9 !== event.which ) {
return;
}

firstTabbable = dialog.warningTabbables.first()[0];
lastTabbable = dialog.warningTabbables.last()[0];

if ( lastTabbable === event.target && ! event.shiftKey ) {
firstTabbable.focus();
event.preventDefault();
} else if ( firstTabbable === event.target && event.shiftKey ) {
lastTabbable.focus();
event.preventDefault();
}
};

dialog.dismissWarning = function() {
// Hide modal.
dialog.warning.remove();
$( '#wpwrap' ).removeAttr( 'aria-hidden' );
$( 'body' ).removeClass( 'modal-open' );
};

$( document ).ready( dialog.init );
} )( jQuery );
/* ]]> */
</script>
<?php
}
Loading

0 comments on commit 4e7dd62

Please sign in to comment.