diff --git a/apps/wpcom-block-editor/README.md b/apps/wpcom-block-editor/README.md index a772fc909c21e8..ac89dd4888d356 100644 --- a/apps/wpcom-block-editor/README.md +++ b/apps/wpcom-block-editor/README.md @@ -4,32 +4,152 @@ This package provides utilities for the WordPress.com block editor integration. These utilities are intended to be built and then served from `widgets.wp.com`, so they can be loaded by a WordPress.com or a Jetpack connected site. -## Environments +## Editors -There are two environments the block editor integration supports: +There are two editors supported: - **WP Admin block editor**. The block editor loaded by the WP Admin interface on `https:///wp-admin/post-new.php`. - **Calypso block editor**. This is the block editor loaded by Calypso on `https://wordpress.com/block-editor/post/`. It is actually the WP Admin block editor embed on an iframe. We also refer to this implementation as _Gutenframe_. - -## File architecture -- `/common`: Logic than runs on both environments (WP Admin and Calypso). -- `/calypso`: Logic than runs only on the Calypso iframed block editor. +## Features + +The block editor integration provides features for the following combination of sites and editors: + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
FeatureEditorSimple siteAtomic siteJetpack site
+ rich-text: + Extensions for the Rich Text toolbar with the Calypso buttons missing on Core (i.e. underline, justify). + WP Admin
Calypso
+ switch-to-classic: + Appends a button to the "More tools" menu for switching to the classic editor. + WP Admin
Calypso
+ fix-block-invalidation-errors: + Performs block attempt block recovery on editor load if validation errors are detected. + WP Admin
Calypso
+ reorder-block-categories: + Moves Jetpack and CoBlocks Block Categories below Core Categories. + WP Admin
Calypso
+ tracking: + Adds analytics around specific user actions. + WP Admin
Calypso
+ iframe-bridge-server: + Server-side handlers of the different communication channels we establish with the client-side when Calypso loads the iframed block editor. See calypsoify-iframe.jsx. + WP Admin
Calypso
+ tinymce: + Tiny MCE plugin that overrides the core media modal used on classic blocks with the Calypso media modal. + WP Admin
Calypso
+ +## Structure + +Features in the `wpcom-block-editor/src` folder loosely follow this structure: -### Common utilities - -- `disable-nux-tour.js`: Disable the pop-up tooltip tour that is displayed on first use. -- `rich-text.js`: Extensions for the Rich Text toolbar with the Calypso buttons missing on Core (i.e. underline, justify). -- `fix-block-invalidation-errors.js`: (Atomic/Simple) Performs block attempt block recovery on editor load if validation errors are detected. -- `switch-to-classic.js`: Append a button to the "More tools" menu for switching to the classic editor. -- `tracking`: Adds analytics around specific user actions for Simple, Jetpack and Atomic sites. -- `reorder-block-categories`: (Atomic/Simple) Moves Jetpack and CoBlocks Block Categories below Core Categories -- `unregister-experimental-blocks`: Removes some experimental blocks from the Gutenberg Plugin. - -### Calypso utilities - -- `iframe-bridge-server.js`: Server-side handlers of the different communication channels we establish with the client-side when Calypso loads the iframed block editor. See [`calypsoify-iframe.jsx`](https://github.com/Automattic/wp-calypso/blob/master/client/gutenberg/editor/calypsoify-iframe.jsx). -- `tinymce.js`: Tiny MCE plugin that overrides the core media modal used on classic blocks with the Calypso media modal. +``` +. +└── bundle-name/ + ├── features ← Directory with all features that are bundled under this group. + ├── editor.js ← script importing features that will be loaded only in the editor. + ├── editor.scss ← stylesheet importing styles of features that will be loaded only in the editor. + ├── view.js ← script importing features that will be loaded in both editor and front-end. + └── view.scss ← stylesheet importing styles of features that will loaded in both editor and front-end. +``` ## Build diff --git a/apps/wpcom-block-editor/src/calypso/editor.js b/apps/wpcom-block-editor/src/calypso/editor.js new file mode 100644 index 00000000000000..c7ed535f212e3c --- /dev/null +++ b/apps/wpcom-block-editor/src/calypso/editor.js @@ -0,0 +1,9 @@ +/** + * Internal dependencies + */ +import './features/iframe-bridge-server'; + +/** + * Style dependencies + */ +import './editor.scss'; diff --git a/apps/wpcom-block-editor/src/calypso/editor.scss b/apps/wpcom-block-editor/src/calypso/editor.scss new file mode 100644 index 00000000000000..a9dee9775f5c07 --- /dev/null +++ b/apps/wpcom-block-editor/src/calypso/editor.scss @@ -0,0 +1 @@ +@import './features/iframe-bridge-server'; diff --git a/apps/wpcom-block-editor/src/calypso/iframe-bridge-server.js b/apps/wpcom-block-editor/src/calypso/features/iframe-bridge-server.js similarity index 99% rename from apps/wpcom-block-editor/src/calypso/iframe-bridge-server.js rename to apps/wpcom-block-editor/src/calypso/features/iframe-bridge-server.js index f1ac1bc2374f3d..ba6a3388334248 100644 --- a/apps/wpcom-block-editor/src/calypso/iframe-bridge-server.js +++ b/apps/wpcom-block-editor/src/calypso/features/iframe-bridge-server.js @@ -1,5 +1,5 @@ /* eslint-disable import/no-extraneous-dependencies */ -/* global calypsoifyGutenberg */ +/* global calypsoifyGutenberg, Image, MessageChannel, MessagePort */ /** * External dependencies @@ -17,7 +17,7 @@ import debugFactory from 'debug'; /** * Internal dependencies */ -import { inIframe, sendMessage } from './utils'; +import { inIframe, sendMessage } from '../utils'; const debug = debugFactory( 'wpcom-block-editor:iframe-bridge-server' ); @@ -72,7 +72,7 @@ function triggerConversionPrompt( calypsoPort ) { */ function transmitDraftId( calypsoPort ) { // Bail if we are not writing a new post. - if ( ! /wp-admin\/post-new.php/.test( location.href ) ) { + if ( ! /wp-admin\/post-new.php/.test( window.location.href ) ) { return; } diff --git a/apps/wpcom-block-editor/src/common/style.scss b/apps/wpcom-block-editor/src/calypso/features/iframe-bridge-server.scss similarity index 93% rename from apps/wpcom-block-editor/src/common/style.scss rename to apps/wpcom-block-editor/src/calypso/features/iframe-bridge-server.scss index 2bf33aab5d78b1..3c2d91b1670af4 100644 --- a/apps/wpcom-block-editor/src/common/style.scss +++ b/apps/wpcom-block-editor/src/calypso/features/iframe-bridge-server.scss @@ -31,7 +31,3 @@ body.is-fullscreen-mode { .components-notice-list { z-index: 29; // Ensure notices are placed behind the editor header (z-index: 30). } - -.has-text-align-justify { - text-align: justify; -} diff --git a/apps/wpcom-block-editor/src/calypso/features/tinymce.js b/apps/wpcom-block-editor/src/calypso/features/tinymce.js new file mode 100644 index 00000000000000..c652ada7626e4a --- /dev/null +++ b/apps/wpcom-block-editor/src/calypso/features/tinymce.js @@ -0,0 +1,38 @@ +/* eslint-disable import/no-extraneous-dependencies */ + +/** + * External dependencies + */ +import tinymce from 'tinymce/tinymce'; + +/** + * Internal dependencies + */ +import { inIframe, sendMessage } from '../utils'; + +function replaceMediaModalOnClassicBlocks() { + if ( ! inIframe() ) { + return; + } + + tinymce.PluginManager.add( 'gutenberg-wpcom-iframe-media-modal', editor => { + editor.addCommand( 'WP_Medialib', () => { + sendMessage( { + action: 'classicBlockOpenMediaModal', + editorId: editor.id, + } ); + } ); + + editor.buttons.wp_img_edit.onclick = () => { + const img = editor.selection.getNode(); + const imageId = img.className.match( /wp-image-(\d+)/ )[ 1 ]; + sendMessage( { + action: 'classicBlockOpenMediaModal', + editorId: editor.id, + imageId: imageId, + } ); + }; + } ); +} + +replaceMediaModalOnClassicBlocks(); diff --git a/apps/wpcom-block-editor/src/calypso/tinymce.js b/apps/wpcom-block-editor/src/calypso/tinymce.js index 212697a05a0aca..2f49e5197bd6b7 100644 --- a/apps/wpcom-block-editor/src/calypso/tinymce.js +++ b/apps/wpcom-block-editor/src/calypso/tinymce.js @@ -1,36 +1,4 @@ -/** - * External dependencies - */ -import tinymce from 'tinymce/tinymce'; - /** * Internal dependencies */ -import { inIframe, sendMessage } from './utils'; - -function replaceMediaModalOnClassicBlocks() { - if ( ! inIframe() ) { - return; - } - - tinymce.PluginManager.add( 'gutenberg-wpcom-iframe-media-modal', editor => { - editor.addCommand( 'WP_Medialib', () => { - sendMessage( { - action: 'classicBlockOpenMediaModal', - editorId: editor.id, - } ); - } ); - - editor.buttons.wp_img_edit.onclick = () => { - const img = editor.selection.getNode(); - const imageId = img.className.match( /wp-image-(\d+)/ )[ 1 ]; - sendMessage( { - action: 'classicBlockOpenMediaModal', - editorId: editor.id, - imageId: imageId, - } ); - }; - } ); -} - -replaceMediaModalOnClassicBlocks(); +import './features/tinymce'; diff --git a/apps/wpcom-block-editor/src/calypso/utils.js b/apps/wpcom-block-editor/src/calypso/utils/index.js similarity index 83% rename from apps/wpcom-block-editor/src/calypso/utils.js rename to apps/wpcom-block-editor/src/calypso/utils/index.js index 2456b26598b3c1..f66b1818c2e67f 100644 --- a/apps/wpcom-block-editor/src/calypso/utils.js +++ b/apps/wpcom-block-editor/src/calypso/utils/index.js @@ -2,7 +2,7 @@ * Checks self and top to determine if we are being loaded in an iframe. * Can't use window.frameElement because we are being embedded from a different origin. * - * @return {Boolean} Whether this script is loaded in a iframe. + * @returns {boolean} Whether this script is loaded in a iframe. */ export function inIframe() { try { @@ -16,7 +16,7 @@ export function inIframe() { * Sends a message object to the parent. The object is extended to include a type that * identifies the source as Gutenberg related. * - * @param {Object} message object containing the action to be performed on the parent and any require options + * @param {object} message object containing the action to be performed on the parent and any require options */ export function sendMessage( message ) { if ( ! window || ! window.parent ) { diff --git a/apps/wpcom-block-editor/src/common/disable-nux-tour.js b/apps/wpcom-block-editor/src/common/disable-nux-tour.js deleted file mode 100644 index f8c2fb20dacb2e..00000000000000 --- a/apps/wpcom-block-editor/src/common/disable-nux-tour.js +++ /dev/null @@ -1,7 +0,0 @@ -/** - * External dependencies - */ -import { dispatch } from '@wordpress/data'; -import '@wordpress/nux'; //ensure nux store loads - -dispatch( 'core/nux' ).disableTips(); diff --git a/apps/wpcom-block-editor/src/common/fix-block-invalidation-errors.js b/apps/wpcom-block-editor/src/common/fix-block-invalidation-errors.js deleted file mode 100644 index 1be07bbddd154b..00000000000000 --- a/apps/wpcom-block-editor/src/common/fix-block-invalidation-errors.js +++ /dev/null @@ -1,40 +0,0 @@ -/* eslint-disable import/no-extraneous-dependencies */ - -/** - * External dependencies - */ -import { select, dispatch, subscribe } from '@wordpress/data'; -import { createBlock } from '@wordpress/blocks'; - -// Very fragile checks, we'll replace with proper common bundle splitting in https://github.com/Automattic/wp-calypso/issues/34476 -const isSimpleSite = !! window.wpcomGutenberg.pluginVersion; -const isAtomicSite = window._currentSiteType === 'atomic'; - -if ( isAtomicSite || isSimpleSite ) { - const unsubscribe = subscribe( () => { - const isCleanNewPost = select( 'core/editor' ).isCleanNewPost(); - - if ( isCleanNewPost ) { - unsubscribe(); - } - - const blocks = select( 'core/editor' ).getBlocks(); - - if ( blocks.length === 0 ) { - return; - } - - unsubscribe(); - - //If any blocks have validation issues auto-fix them for now, until core is less strict. - select( 'core/editor' ) - .getBlocks() - .filter( block => ! block.isValid ) - .forEach( ( { clientId, name, attributes, innerBlocks } ) => { - dispatch( 'core/editor' ).replaceBlock( - clientId, - createBlock( name, attributes, innerBlocks ) - ); - } ); - } ); -} diff --git a/apps/wpcom-block-editor/src/common/index.js b/apps/wpcom-block-editor/src/common/index.js deleted file mode 100644 index 2c77362b32dc8e..00000000000000 --- a/apps/wpcom-block-editor/src/common/index.js +++ /dev/null @@ -1,11 +0,0 @@ -/** - * Internal dependencies - */ -import './disable-nux-tour'; -import './fix-block-invalidation-errors'; -import './reorder-block-categories'; -import './rich-text'; -import './style.scss'; -import './switch-to-classic'; -import './tracking'; -import './unregister-experimental-blocks'; diff --git a/apps/wpcom-block-editor/src/common/reorder-block-categories.js b/apps/wpcom-block-editor/src/common/reorder-block-categories.js deleted file mode 100644 index ab50dde729a64f..00000000000000 --- a/apps/wpcom-block-editor/src/common/reorder-block-categories.js +++ /dev/null @@ -1,47 +0,0 @@ -/* eslint-disable import/no-extraneous-dependencies */ -/** - * External dependencies - */ -import { getCategories, setCategories } from '@wordpress/blocks'; -import domReady from '@wordpress/dom-ready'; - -const categorySlugs = [ 'jetpack', 'coblocks', 'coblocks-galleries' ]; - -// Very fragile checks, we'll replace with proper common bundle splitting in https://github.com/Automattic/wp-calypso/issues/34476 -const isSimpleSite = !! window.wpcomGutenberg.pluginVersion; -const isAtomicSite = window._currentSiteType === 'atomic'; - -if ( isAtomicSite || isSimpleSite ) { - domReady( function() { - //preserve order of other columns, and split matching - const { core: coreCategories, custom: unsorted } = getCategories().reduce( - ( { core, custom }, category ) => { - const isCustomCategory = categorySlugs.includes( category.slug ); - if ( isCustomCategory ) { - return { - core, - custom: [ ...custom, category ], - }; - } - return { - core: [ ...core, category ], - custom, - }; - }, - { custom: [], core: [] } - ); - //sort once following order of categorySlugs - const customCategories = unsorted.sort( ( { slug }, { slug: slugB } ) => { - const index = categorySlugs.indexOf( slug ); - const indexB = categorySlugs.indexOf( slugB ); - if ( index === indexB ) { - return 0; - } - if ( index < indexB ) { - return -1; - } - return 1; - } ); - setCategories( [ ...coreCategories, ...customCategories ] ); - } ); -} diff --git a/apps/wpcom-block-editor/src/common/unregister-experimental-blocks.js b/apps/wpcom-block-editor/src/common/unregister-experimental-blocks.js deleted file mode 100644 index 38668f07ba632e..00000000000000 --- a/apps/wpcom-block-editor/src/common/unregister-experimental-blocks.js +++ /dev/null @@ -1,20 +0,0 @@ -/** - * External dependencies - */ -import { getBlockType, unregisterBlockType } from '@wordpress/blocks'; -import domReady from '@wordpress/dom-ready'; - -const experimentalBlocks = [ - 'core/legacy-widget', - 'core/navigation-menu', - 'core/navigation-menu-item', -]; - -domReady( function() { - experimentalBlocks.forEach( blockName => { - const block = getBlockType( blockName ); - if ( block ) { - unregisterBlockType( blockName ); - } - } ); -} ); diff --git a/apps/wpcom-block-editor/src/default/editor.js b/apps/wpcom-block-editor/src/default/editor.js new file mode 100644 index 00000000000000..793f05b8c5d000 --- /dev/null +++ b/apps/wpcom-block-editor/src/default/editor.js @@ -0,0 +1,5 @@ +/** + * Internal dependencies + */ +import './features/rich-text'; +import './features/switch-to-classic'; diff --git a/apps/wpcom-block-editor/src/common/rich-text.js b/apps/wpcom-block-editor/src/default/features/rich-text.js similarity index 100% rename from apps/wpcom-block-editor/src/common/rich-text.js rename to apps/wpcom-block-editor/src/default/features/rich-text.js diff --git a/apps/wpcom-block-editor/src/default/features/rich-text.scss b/apps/wpcom-block-editor/src/default/features/rich-text.scss new file mode 100644 index 00000000000000..cc3d82ef735631 --- /dev/null +++ b/apps/wpcom-block-editor/src/default/features/rich-text.scss @@ -0,0 +1,3 @@ +.has-text-align-justify { + text-align: justify; +} diff --git a/apps/wpcom-block-editor/src/common/switch-to-classic.js b/apps/wpcom-block-editor/src/default/features/switch-to-classic.js similarity index 78% rename from apps/wpcom-block-editor/src/common/switch-to-classic.js rename to apps/wpcom-block-editor/src/default/features/switch-to-classic.js index 7c584aa1115469..b80a67f81fad33 100644 --- a/apps/wpcom-block-editor/src/common/switch-to-classic.js +++ b/apps/wpcom-block-editor/src/default/features/switch-to-classic.js @@ -1,3 +1,4 @@ +/* eslint-disable import/no-extraneous-dependencies */ /* global wpcomGutenberg */ /** @@ -6,7 +7,7 @@ import $ from 'jquery'; function addSwitchToClassicButton() { - if ( ! wpcomGutenberg.switchToClassic.isVisible ) { + if ( ! wpcomGutenberg?.switchToClassic?.isVisible ) { return; } @@ -15,10 +16,10 @@ function addSwitchToClassicButton() { setTimeout( () => { //role may be 'menu' or 'group', depending on the Gutenberg version $( '.edit-post-more-menu__content .components-menu-group:last-child > div[role]' ).append( ` - ${ wpcomGutenberg.switchToClassic.label } diff --git a/apps/wpcom-block-editor/src/default/view.js b/apps/wpcom-block-editor/src/default/view.js new file mode 100644 index 00000000000000..741c50d6a0ff93 --- /dev/null +++ b/apps/wpcom-block-editor/src/default/view.js @@ -0,0 +1,4 @@ +/** + * Internal dependencies + */ +import './view.scss'; diff --git a/apps/wpcom-block-editor/src/default/view.scss b/apps/wpcom-block-editor/src/default/view.scss new file mode 100644 index 00000000000000..fb2b520bec2d29 --- /dev/null +++ b/apps/wpcom-block-editor/src/default/view.scss @@ -0,0 +1 @@ +@import './features/rich-text'; diff --git a/apps/wpcom-block-editor/src/wpcom/editor.js b/apps/wpcom-block-editor/src/wpcom/editor.js new file mode 100644 index 00000000000000..056631195d2886 --- /dev/null +++ b/apps/wpcom-block-editor/src/wpcom/editor.js @@ -0,0 +1,6 @@ +/** + * Internal dependencies + */ +import './features/fix-block-invalidation-errors'; +import './features/reorder-block-categories'; +import './features/tracking'; diff --git a/apps/wpcom-block-editor/src/wpcom/features/fix-block-invalidation-errors.js b/apps/wpcom-block-editor/src/wpcom/features/fix-block-invalidation-errors.js new file mode 100644 index 00000000000000..809aaab120596d --- /dev/null +++ b/apps/wpcom-block-editor/src/wpcom/features/fix-block-invalidation-errors.js @@ -0,0 +1,34 @@ +/* eslint-disable import/no-extraneous-dependencies */ + +/** + * External dependencies + */ +import { select, dispatch, subscribe } from '@wordpress/data'; +import { createBlock } from '@wordpress/blocks'; + +const unsubscribe = subscribe( () => { + const isCleanNewPost = select( 'core/editor' ).isCleanNewPost(); + + if ( isCleanNewPost ) { + unsubscribe(); + } + + const blocks = select( 'core/editor' ).getBlocks(); + + if ( blocks.length === 0 ) { + return; + } + + unsubscribe(); + + //If any blocks have validation issues auto-fix them for now, until core is less strict. + select( 'core/editor' ) + .getBlocks() + .filter( block => ! block.isValid ) + .forEach( ( { clientId, name, attributes, innerBlocks } ) => { + dispatch( 'core/editor' ).replaceBlock( + clientId, + createBlock( name, attributes, innerBlocks ) + ); + } ); +} ); diff --git a/apps/wpcom-block-editor/src/wpcom/features/reorder-block-categories.js b/apps/wpcom-block-editor/src/wpcom/features/reorder-block-categories.js new file mode 100644 index 00000000000000..f928733bc866a2 --- /dev/null +++ b/apps/wpcom-block-editor/src/wpcom/features/reorder-block-categories.js @@ -0,0 +1,41 @@ +/* eslint-disable import/no-extraneous-dependencies */ +/** + * External dependencies + */ +import { getCategories, setCategories } from '@wordpress/blocks'; +import domReady from '@wordpress/dom-ready'; + +const categorySlugs = [ 'jetpack', 'coblocks', 'coblocks-galleries' ]; + +domReady( function() { + //preserve order of other columns, and split matching + const { core: coreCategories, custom: unsorted } = getCategories().reduce( + ( { core, custom }, category ) => { + const isCustomCategory = categorySlugs.includes( category.slug ); + if ( isCustomCategory ) { + return { + core, + custom: [ ...custom, category ], + }; + } + return { + core: [ ...core, category ], + custom, + }; + }, + { custom: [], core: [] } + ); + //sort once following order of categorySlugs + const customCategories = unsorted.sort( ( { slug }, { slug: slugB } ) => { + const index = categorySlugs.indexOf( slug ); + const indexB = categorySlugs.indexOf( slugB ); + if ( index === indexB ) { + return 0; + } + if ( index < indexB ) { + return -1; + } + return 1; + } ); + setCategories( [ ...coreCategories, ...customCategories ] ); +} ); diff --git a/apps/wpcom-block-editor/src/common/tracking.js b/apps/wpcom-block-editor/src/wpcom/features/tracking.js similarity index 100% rename from apps/wpcom-block-editor/src/common/tracking.js rename to apps/wpcom-block-editor/src/wpcom/features/tracking.js diff --git a/apps/wpcom-block-editor/src/common/tracking/delegate-event-tracking.js b/apps/wpcom-block-editor/src/wpcom/features/tracking/delegate-event-tracking.js similarity index 100% rename from apps/wpcom-block-editor/src/common/tracking/delegate-event-tracking.js rename to apps/wpcom-block-editor/src/wpcom/features/tracking/delegate-event-tracking.js diff --git a/apps/wpcom-block-editor/src/common/tracking/track-record-event.js b/apps/wpcom-block-editor/src/wpcom/features/tracking/track-record-event.js similarity index 100% rename from apps/wpcom-block-editor/src/common/tracking/track-record-event.js rename to apps/wpcom-block-editor/src/wpcom/features/tracking/track-record-event.js diff --git a/apps/wpcom-block-editor/src/common/tracking/wpcom-block-editor-close-click.js b/apps/wpcom-block-editor/src/wpcom/features/tracking/wpcom-block-editor-close-click.js similarity index 100% rename from apps/wpcom-block-editor/src/common/tracking/wpcom-block-editor-close-click.js rename to apps/wpcom-block-editor/src/wpcom/features/tracking/wpcom-block-editor-close-click.js diff --git a/apps/wpcom-block-editor/src/common/tracking/wpcom-block-picker-search-term-handler.js b/apps/wpcom-block-editor/src/wpcom/features/tracking/wpcom-block-picker-search-term-handler.js similarity index 100% rename from apps/wpcom-block-editor/src/common/tracking/wpcom-block-picker-search-term-handler.js rename to apps/wpcom-block-editor/src/wpcom/features/tracking/wpcom-block-picker-search-term-handler.js diff --git a/apps/wpcom-block-editor/webpack.config.js b/apps/wpcom-block-editor/webpack.config.js index ba150af181f31d..a263dde84d6446 100644 --- a/apps/wpcom-block-editor/webpack.config.js +++ b/apps/wpcom-block-editor/webpack.config.js @@ -6,6 +6,7 @@ /** * External dependencies */ +// eslint-disable-next-line import/no-extraneous-dependencies const DependencyExtractionWebpackPlugin = require( '@wordpress/dependency-extraction-webpack-plugin' ); const getBaseWebpackConfig = require( '@automattic/calypso-build/webpack.config.js' ); const path = require( 'path' ); @@ -24,26 +25,23 @@ const isDevelopment = process.env.NODE_ENV !== 'production'; * @see {@link https://webpack.js.org/configuration/configuration-types/#exporting-a-function} * @see {@link https://webpack.js.org/api/cli/} * - * @param {object} env environment options - * @param {object} argv options map - * @param {object} argv.entry Entry point(s) - * @param {string} argv.'output-path' Output path - * @param {string} argv.'output-filename' Output filename pattern - * @param {string} argv.'output-library-target' Output library target - * @return {object} webpack config + * @param {object} env environment options + * @param {object} argv options map + * @param {object} argv.entry Entry point(s) + * @param {string} argv.'output-path' Output path + * @param {string} argv.'output-filename' Output filename pattern + * @param {string} argv.'output-library-target' Output library target + * @returns {object} webpack config */ function getWebpackConfig( env = {}, { entry = { - common: path.join( __dirname, 'src', 'common' ), - 'calypso-iframe-bridge-server': path.join( - __dirname, - 'src', - 'calypso', - 'iframe-bridge-server.js' - ), - 'calypso-tinymce': path.join( __dirname, 'src', 'calypso', 'tinymce.js' ), + 'default.editor': path.join( __dirname, 'src', 'default', 'editor' ), + 'default.view': path.join( __dirname, 'src', 'default', 'view' ), + 'wpcom.editor': path.join( __dirname, 'src', 'wpcom', 'editor' ), + 'calypso.editor': path.join( __dirname, 'src', 'calypso', 'editor' ), + 'calypso.tinymce': path.join( __dirname, 'src', 'calypso', 'tinymce' ), }, 'output-path': outputPath = path.join( __dirname, 'dist' ), 'output-filename': outputFilename = isDevelopment ? '[name].js' : '[name].min.js',