this.ref = ref }
+ className="editor-visual-editor__block-controls freeform-toolbar"
+ />,
+
,
+ ];
+ }
+}
diff --git a/blocks/library/freeform/style.scss b/blocks/library/freeform/style.scss
index 835c15bf1e87b..e51650d57748b 100644
--- a/blocks/library/freeform/style.scss
+++ b/blocks/library/freeform/style.scss
@@ -18,15 +18,6 @@
color: $dark-gray-800;
}
- h1,
- h2,
- h3,
- h4,
- h5,
- h6 {
- margin: 0;
- }
-
h1 {
font-size: 2em;
}
@@ -51,15 +42,15 @@
font-size: 1em;
}
- > p:first-child {
+ > *:first-child {
margin-top: 0;
}
- > p:last-child {
+ > *:last-child {
margin-bottom: 0;
}
- &:focus {
+ &.mce-edit-focus {
outline: none;
}
@@ -87,4 +78,140 @@
&:focus code[data-mce-selected] {
background: $light-gray-400;
}
-}
\ No newline at end of file
+}
+
+.editor-visual-editor__block-controls.freeform-toolbar {
+ width: auto;
+}
+
+.freeform-toolbar .mce-tinymce-inline {
+ margin: 0;
+ background: transparent;
+}
+
+// Overwrite inline styles.
+.freeform-toolbar .mce-tinymce-inline,
+.freeform-toolbar .mce-tinymce-inline > div,
+.freeform-toolbar div.mce-toolbar-grp,
+.freeform-toolbar div.mce-toolbar-grp > div {
+ height: auto !important;
+ width: 100% !important;
+ border: none !important;
+}
+
+.freeform-toolbar div.mce-toolbar-grp {
+ background-color: transparent;
+ border: none;
+ position: static;
+}
+
+div.mce-toolbar-grp > div {
+ padding: 0;
+}
+
+.freeform-toolbar div.mce-btn-group {
+ border: 1px solid $light-gray-500;
+ box-shadow: $shadow-popover;
+ background-color: $white;
+ padding: 0;
+
+ &:not(:first-child) {
+ margin-left: 6px;
+ }
+}
+
+.freeform-toolbar .mce-container-body.mce-abs-layout {
+ overflow: visible;
+}
+
+.freeform-toolbar .mce-toolbar:not(:first-child) {
+ display: none;
+ position: absolute;
+ top: -44px;
+}
+
+.freeform-toolbar.has-advanced-toolbar .mce-toolbar {
+ display: block;
+}
+
+.freeform-toolbar .mce-toolbar .mce-btn {
+ margin: 0;
+ padding: 3px;
+ background: none;
+ outline: none;
+ color: $dark-gray-500;
+ cursor: pointer;
+ position: relative;
+ width: $icon-button-size;
+ height: $icon-button-size;
+
+ // Overwrite
+ border: none;
+ box-sizing: border-box;
+
+ &:hover,
+ /* the ":not(:disabled)" is needed to make it specific enough */
+ &:hover:not(:disabled),
+ &:focus,
+ &:focus:active {
+ color: $dark-gray-500;
+ outline: none;
+ box-shadow: none;
+ background: inherit;
+ }
+
+ &.mce-active,
+ &.mce-active:hover {
+ background: none;
+ color: $white;
+ }
+
+ &:disabled {
+ cursor: default;
+ }
+
+ &> button {
+ border: 1px solid transparent;
+ padding: 4px;
+ box-sizing: content-box;
+ }
+
+ &:hover button,
+ &:focus button {
+ color: $dark-gray-500;
+ }
+
+ &:not(:disabled) {
+ &.mce-active button,
+ &:hover button,
+ &:focus button {
+ border: 1px solid $dark-gray-500;
+ }
+ }
+
+ &.mce-active button,
+ &.mce-active:hover button {
+ background-color: $dark-gray-500;
+ color: $white;
+ }
+
+ &.mce-active .mce-ico {
+ color: $white;
+ }
+
+ &.mce-listbox,
+ &.mce-colorbutton {
+ width: auto;
+ border: none;
+ box-shadow: none;
+ }
+
+ &.mce-colorbutton .mce-preview {
+ bottom: 8px;
+ left: 8px;
+ }
+}
+
+.components-toolbar__control .dashicon {
+ display: block;
+}
diff --git a/blocks/library/freeform/test/naiveCss2Jsx.js b/blocks/library/freeform/test/naiveCss2Jsx.js
deleted file mode 100644
index 4384ecc724ec7..0000000000000
--- a/blocks/library/freeform/test/naiveCss2Jsx.js
+++ /dev/null
@@ -1,158 +0,0 @@
-/**
- * External dependencies
- */
-import { expect } from 'chai';
-/**
- * Internal dependencies
- */
-import { naiveCss2Jsx } from '../format-list';
-
-describe( 'naiveCss2Jsx', () => {
- it( 'should convert the Paragraph format', () => {
- expect( naiveCss2Jsx(
- 'font-family:"Noto Serif",serif;font-size:16px;font-weight:400;' +
- 'font-style:normal;text-decoration:none;text-transform:none;' +
- 'color:rgb(68, 68, 68);background-color:transparent;border:;' +
- 'border-radius:;outline:;text-shadow:none;'
- ) ).to.deep.equal( {
- fontFamily: '"Noto Serif",serif',
- fontSize: '16px',
- fontWeight: '400',
- fontStyle: 'normal',
- textDecoration: 'none',
- textTransform: 'none',
- color: 'rgb(68, 68, 68)',
- backgroundColor: 'transparent',
- border: '',
- borderRadius: '',
- outline: '',
- textShadow: 'none',
- } );
- } );
- it( 'should convert the Heading 1 format', () => {
- expect( naiveCss2Jsx(
- 'font-family:"Noto Serif",serif;font-size:32px;font-weight:600;' +
- 'font-style:normal;text-decoration:none;text-transform:none;' +
- 'color:rgb(35, 40, 45);background-color:transparent;border:;' +
- 'border-radius:;outline:;text-shadow:none;'
- ) ).to.deep.equal( {
- fontFamily: '"Noto Serif",serif',
- fontSize: '32px',
- fontWeight: '600',
- fontStyle: 'normal',
- textDecoration: 'none',
- textTransform: 'none',
- color: 'rgb(35, 40, 45)',
- backgroundColor: 'transparent',
- border: '',
- borderRadius: '',
- outline: '',
- textShadow: 'none',
- } );
- } );
- it( 'should convert the Heading 2/3 format', () => {
- expect( naiveCss2Jsx(
- 'font-family:"Noto Serif",serif;font-size:20.8px;font-weight:600;' +
- 'font-style:normal;text-decoration:none;text-transform:none;' +
- 'color:rgb(35, 40, 45);background-color:transparent;border:;' +
- 'border-radius:;outline:;text-shadow:none;'
- ) ).to.deep.equal( {
- fontFamily: '"Noto Serif",serif',
- fontSize: '20.8px',
- fontWeight: '600',
- fontStyle: 'normal',
- textDecoration: 'none',
- textTransform: 'none',
- color: 'rgb(35, 40, 45)',
- backgroundColor: 'transparent',
- border: '',
- borderRadius: '',
- outline: '',
- textShadow: 'none',
- } );
- } );
- it( 'should convert the Heading 4 format', () => {
- expect( naiveCss2Jsx(
- 'font-family:"Noto Serif",serif;font-size:16px;font-weight:600;' +
- 'font-style:normal;text-decoration:none;text-transform:none;' +
- 'color:rgb(68, 68, 68);background-color:transparent;border:;' +
- 'border-radius:;outline:;text-shadow:none;'
- ) ).to.deep.equal( {
- fontFamily: '"Noto Serif",serif',
- fontSize: '16px',
- fontWeight: '600',
- fontStyle: 'normal',
- textDecoration: 'none',
- textTransform: 'none',
- color: 'rgb(68, 68, 68)',
- backgroundColor: 'transparent',
- border: '',
- borderRadius: '',
- outline: '',
- textShadow: 'none',
- } );
- } );
- it( 'should convert the Heading 5 format', () => {
- expect( naiveCss2Jsx(
- 'font-family:"Noto Serif",serif;font-size:13.2833px;font-weight:600;' +
- 'font-style:normal;text-decoration:none;text-transform:none;' +
- 'color:rgb(68, 68, 68);background-color:transparent;border:;' +
- 'border-radius:;outline:;text-shadow:none;'
- ) ).to.deep.equal( {
- fontFamily: '"Noto Serif",serif',
- fontSize: '13.2833px',
- fontWeight: '600',
- fontStyle: 'normal',
- textDecoration: 'none',
- textTransform: 'none',
- color: 'rgb(68, 68, 68)',
- backgroundColor: 'transparent',
- border: '',
- borderRadius: '',
- outline: '',
- textShadow: 'none',
- } );
- } );
- it( 'should convert the Heading 6 format', () => {
- expect( naiveCss2Jsx(
- 'font-family:"Noto Serif",serif;font-size:10.7167px;font-weight:600;' +
- 'font-style:normal;text-decoration:none;text-transform:none;' +
- 'color:rgb(68, 68, 68);background-color:transparent;border:;' +
- 'border-radius:;outline:;text-shadow:none;'
- ) ).to.deep.equal( {
- fontFamily: '"Noto Serif",serif',
- fontSize: '10.7167px',
- fontWeight: '600',
- fontStyle: 'normal',
- textDecoration: 'none',
- textTransform: 'none',
- color: 'rgb(68, 68, 68)',
- backgroundColor: 'transparent',
- border: '',
- borderRadius: '',
- outline: '',
- textShadow: 'none',
- } );
- } );
- it( 'should convert the Preformatted format', () => {
- expect( naiveCss2Jsx(
- 'font-family:monospace;font-size:16px;font-weight:400;' +
- 'font-style:normal;text-decoration:none;text-transform:none;' +
- 'color:rgb(68, 68, 68);background-color:transparent;border:;' +
- 'border-radius:;outline:;text-shadow:none;'
- ) ).to.deep.equal( {
- fontFamily: 'monospace',
- fontSize: '16px',
- fontWeight: '400',
- fontStyle: 'normal',
- textDecoration: 'none',
- textTransform: 'none',
- color: 'rgb(68, 68, 68)',
- backgroundColor: 'transparent',
- border: '',
- borderRadius: '',
- outline: '',
- textShadow: 'none',
- } );
- } );
-} );
diff --git a/blocks/test/fixtures/core-freeform.json b/blocks/test/fixtures/core-freeform.json
index c12160e958417..35efd7b04fd19 100644
--- a/blocks/test/fixtures/core-freeform.json
+++ b/blocks/test/fixtures/core-freeform.json
@@ -3,28 +3,7 @@
"uid": "_uid_0",
"name": "core/freeform",
"attributes": {
- "content": [
- "Testing freeform block with some\n",
- {
- "attributes": {
- "className": "wp-some-class"
- },
- "children": [
- "\n\tHTML ",
- {
- "attributes": {
- "style": {
- "color": "red"
- }
- },
- "children": "content",
- "type": "span"
- },
- "\n"
- ],
- "type": "div"
- }
- ]
+ "content": "Testing freeform block with some\n
\n\tHTML content\n
"
}
}
]
diff --git a/blocks/test/fixtures/core-freeform.serialized.html b/blocks/test/fixtures/core-freeform.serialized.html
index a31ee92b0385e..05bbc06efe57b 100644
--- a/blocks/test/fixtures/core-freeform.serialized.html
+++ b/blocks/test/fixtures/core-freeform.serialized.html
@@ -1,7 +1,7 @@
Testing freeform block with some
-
- HTML
content
+
+ HTML content
diff --git a/lib/client-assets.php b/lib/client-assets.php
index 99f3036b83581..8eaaa258d2fdb 100644
--- a/lib/client-assets.php
+++ b/lib/client-assets.php
@@ -374,6 +374,11 @@ function gutenberg_scripts_and_styles( $hook ) {
* Scripts
*/
wp_enqueue_media();
+ wp_enqueue_editor();
+
+ wp_add_inline_script(
+ 'editor', 'window.wp.oldEditor = window.wp.editor;', 'after'
+ );
gutenberg_extend_wp_api_backbone_client();
@@ -381,11 +386,72 @@ function gutenberg_scripts_and_styles( $hook ) {
wp_enqueue_script(
'wp-editor',
gutenberg_url( 'editor/build/index.js' ),
- array( 'wp-api', 'wp-date', 'wp-i18n', 'wp-blocks', 'wp-element', 'wp-components', 'wp-utils' ),
+ array( 'wp-api', 'wp-date', 'wp-i18n', 'wp-blocks', 'wp-element', 'wp-components', 'wp-utils', 'editor' ),
filemtime( gutenberg_dir_path() . 'editor/build/index.js' ),
true // enqueue in the footer.
);
+ wp_localize_script( 'wp-editor', 'wpEditorL10n', array(
+ 'tinymce' => array(
+ 'baseURL' => includes_url( 'js/tinymce' ),
+ 'suffix' => SCRIPT_DEBUG ? '' : '.min',
+ 'settings' => array(
+ 'external_plugins' => apply_filters( 'mce_external_plugins', array() ),
+ 'plugins' => array_unique( apply_filters( 'tiny_mce_plugins', array(
+ 'charmap',
+ 'colorpicker',
+ 'hr',
+ 'lists',
+ 'media',
+ 'paste',
+ 'tabfocus',
+ 'textcolor',
+ 'fullscreen',
+ 'wordpress',
+ 'wpautoresize',
+ 'wpeditimage',
+ 'wpemoji',
+ 'wpgallery',
+ 'wplink',
+ 'wpdialogs',
+ 'wptextpattern',
+ 'wpview',
+ ) ) ),
+ 'toolbar1' => array_merge( apply_filters( 'mce_buttons', array(
+ 'formatselect',
+ '|',
+ 'alignleft',
+ 'aligncenter',
+ 'alignright',
+ '|',
+ 'bullist',
+ 'numlist',
+ 'blockquote',
+ '|',
+ 'bold',
+ 'italic',
+ 'strikethrough',
+ 'link',
+ ), 'editor' ), array( '|', 'kitchensink' ) ),
+ 'toolbar2' => apply_filters( 'mce_buttons_2', array(
+ 'hr',
+ 'wp_more',
+ 'forecolor',
+ 'pastetext',
+ 'removeformat',
+ 'charmap',
+ 'outdent',
+ 'indent',
+ 'undo',
+ 'redo',
+ 'wp_help',
+ ), 'editor' ),
+ 'toolbar3' => apply_filters( 'mce_buttons_3', array(), 'editor' ),
+ 'toolbar4' => apply_filters( 'mce_buttons_4', array(), 'editor' ),
+ ),
+ ),
+ ) );
+
$post_id = null;
if ( isset( $_GET['post_id'] ) && (int) $_GET['post_id'] > 0 ) {
$post_id = (int) $_GET['post_id'];