Skip to content

Commit

Permalink
Editor: wpcom-view: dump sites-list, select from Redux state (Automat…
Browse files Browse the repository at this point in the history
  • Loading branch information
mcsf authored Apr 28, 2017
1 parent 11cf35d commit bef1eb0
Showing 1 changed file with 10 additions and 9 deletions.
19 changes: 10 additions & 9 deletions client/components/tinymce/plugins/wpcom-view/plugin.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,9 @@ var tinymce = require( 'tinymce/tinymce' ),
/**
* Internal dependencies
*/
var views = require( './views' ),
sites = require( 'lib/sites-list' )();

import views from './views';
import { renderWithReduxStore } from 'lib/react-helpers';
import { getSelectedSiteId } from 'state/ui/selectors';

/**
* WordPress View plugin.
Expand Down Expand Up @@ -81,24 +80,26 @@ function wpview( editor ) {
return;
}

const store = editor.getParam( 'redux_store' );
const siteId = getSelectedSiteId( store.getState() );

$( '.wpview-wrap' ).each( function( index, view ) {
var $view = $( view ),
type;
const $view = $( view );

if ( undefined !== $view.attr( 'data-wpview-rendered' ) ) {
return;
}

type = $view.attr( 'data-wpview-type' );
const type = $view.attr( 'data-wpview-type' );

renderWithReduxStore(
React.createElement( views.components[ type ], {
content: getText( view ),
siteId: sites.getSelectedSite() ? sites.getSelectedSite().ID : null,
siteId,
onResize: debounce( triggerNodeChanged, 500 )
} ),
$view.find( '.wpview-body' )[0],
editor.getParam( 'redux_store' )
$view.find( '.wpview-body' )[ 0 ],
store
);

$view.attr( 'data-wpview-rendered', '' );
Expand Down

0 comments on commit bef1eb0

Please sign in to comment.