block_editor 0.1.3 → 1.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/README.md +35 -14
- data/app/assets/images/block_editor/contact-form-block.svg +1 -0
- data/app/assets/stylesheets/block_editor/_utilities.scss +16 -0
- data/app/assets/stylesheets/block_editor/backend.scss +70 -2
- data/app/assets/stylesheets/block_editor/blocks/_backend.scss +7 -0
- data/app/assets/stylesheets/block_editor/blocks/_frontend.scss +11 -0
- data/app/assets/stylesheets/block_editor/blocks/be-accordion/_frontend.scss +3 -0
- data/app/assets/stylesheets/block_editor/blocks/be-alert/_frontend.scss +13 -0
- data/app/assets/stylesheets/block_editor/blocks/be-card/_backend.scss +7 -0
- data/app/assets/stylesheets/block_editor/{backend/blocks.scss → blocks/be-card/_frontend.scss} +0 -0
- data/app/assets/stylesheets/block_editor/blocks/be-contact-form/_backend.scss +22 -0
- data/app/assets/stylesheets/block_editor/blocks/be-cover/_backend.scss +8 -0
- data/app/assets/stylesheets/block_editor/blocks/be-cover/_frontend.scss +37 -0
- data/app/assets/stylesheets/block_editor/blocks/block/_backend.scss +11 -0
- data/app/assets/stylesheets/block_editor/blocks/button/_frontend.scss +46 -0
- data/app/assets/stylesheets/block_editor/blocks/buttons/_backend.scss +10 -0
- data/app/assets/stylesheets/block_editor/blocks/buttons/_frontend.scss +3 -0
- data/app/assets/stylesheets/block_editor/blocks/column/_frontend.scss +18 -0
- data/app/assets/stylesheets/block_editor/blocks/columns/_backend.scss +8 -0
- data/app/assets/stylesheets/block_editor/blocks/columns/_frontend.scss +14 -0
- data/app/assets/stylesheets/block_editor/blocks/image/_backend.scss +10 -0
- data/app/assets/stylesheets/block_editor/blocks/image/_frontend.scss +21 -0
- data/app/assets/stylesheets/block_editor/blocks/seperator/_frontend.scss +19 -0
- data/app/assets/stylesheets/block_editor/blocks/table/_frontend.scss +67 -0
- data/app/assets/stylesheets/block_editor/host_app/_variables.scss +1 -0
- data/app/assets/stylesheets/block_editor/host_app/blocks/_backend.scss +1 -0
- data/app/assets/stylesheets/block_editor/host_app/blocks/_frontend.scss +1 -0
- data/app/javascript/block_editor/blocks/be-accordion/index.js +108 -0
- data/app/javascript/block_editor/blocks/be-alert/index.js +51 -0
- data/app/javascript/block_editor/blocks/be-card/index.js +205 -0
- data/app/javascript/block_editor/blocks/be-contact-form/index.js +24 -0
- data/app/javascript/block_editor/blocks/be-cover/index.js +135 -0
- data/app/javascript/block_editor/blocks/block/edit-panel/index.js +132 -0
- data/app/javascript/block_editor/blocks/block/edit.js +163 -0
- data/app/javascript/block_editor/blocks/button/edit.js +0 -13
- data/app/javascript/block_editor/blocks/index.js +51 -102
- data/app/javascript/block_editor/components/block-editor/index.js +107 -36
- data/app/javascript/block_editor/components/block-editor/popover-wrapper.js +60 -0
- data/app/javascript/block_editor/components/block-editor/styles.scss +0 -11
- data/app/javascript/block_editor/components/header/index.js +28 -6
- data/app/javascript/block_editor/components/header/redo.js +1 -1
- data/app/javascript/block_editor/components/header/styles.scss +12 -11
- data/app/javascript/block_editor/components/media-upload/index.js +3 -3
- data/app/javascript/block_editor/components/sidebar/index.js +1 -3
- data/app/javascript/block_editor/components/sidebar/styles.scss +35 -35
- data/app/javascript/block_editor/stores/actions.js +12 -0
- data/app/javascript/block_editor/stores/reducer.js +23 -3
- data/app/javascript/block_editor/stores/selectors.js +14 -3
- data/app/javascript/controllers/block_editor_controller.jsx +15 -8
- data/app/javascript/controllers/index.js +2 -0
- data/app/javascript/packs/block_editor/application.scss +70 -26
- data/app/models/block_editor/block_list.rb +45 -1
- data/app/models/block_editor/block_list_connection.rb +6 -0
- data/app/views/block_editor/blocks/be/contact-form/_block.html +3 -0
- data/db/migrate/20210506220328_create_block_list_connections.rb +8 -0
- data/lib/block_editor.rb +3 -1
- data/lib/block_editor/block_list_renderer.rb +12 -6
- data/lib/block_editor/blocks/base.rb +1 -1
- data/lib/block_editor/blocks/contact_form.rb +11 -0
- data/lib/block_editor/blocks/reusable.rb +16 -0
- data/lib/block_editor/version.rb +1 -1
- data/package.json +16 -7
- data/yarn.lock +727 -530
- metadata +42 -8
- data/app/assets/stylesheets/block_editor/frontend.scss +0 -1
- data/app/assets/stylesheets/block_editor/frontend/blocks.scss +0 -0
- data/app/javascript/block_editor/blocks/image/edit.js +0 -656
@@ -5,10 +5,6 @@
|
|
5
5
|
margin-right: auto;
|
6
6
|
}
|
7
7
|
|
8
|
-
.block-editor-block-list__layout {
|
9
|
-
margin-bottom: 50px;
|
10
|
-
}
|
11
|
-
|
12
8
|
.block-editor__inner-wrapper {
|
13
9
|
-webkit-overflow-scrolling: touch;
|
14
10
|
background: $white;
|
@@ -26,13 +22,6 @@
|
|
26
22
|
|
27
23
|
// Grab the default Editor styles for visual consistency with WP
|
28
24
|
.editor-styles-wrapper {
|
29
|
-
// We need the styles scoped to "body" to be added to the
|
30
|
-
// div.editor-styles wrapper
|
31
|
-
font-family: $editor-font;
|
32
|
-
font-size: $editor-font-size;
|
33
|
-
line-height: $editor-line-height;
|
34
|
-
color: #555;
|
35
|
-
|
36
25
|
// Important all other selectors scoped underneath
|
37
26
|
// `div.editor-styles-wrapper`
|
38
27
|
@import "~@wordpress/editor/src/editor-styles.scss";
|
@@ -6,22 +6,44 @@ import ReactDOM from 'react-dom'
|
|
6
6
|
*/
|
7
7
|
import { NavigableToolbar } from '@wordpress/block-editor';
|
8
8
|
import { Button } from '@wordpress/components';
|
9
|
-
import {
|
10
|
-
import {
|
9
|
+
import { resizeCornerNE as minimizeIcon } from '@wordpress/icons';
|
10
|
+
import { close as closeIcon } from '@wordpress/icons';
|
11
|
+
import { plus as openIcon } from '@wordpress/icons';
|
12
|
+
import { fullscreen as maximizeIcon } from '@wordpress/icons';
|
13
|
+
import { useSelect, useDispatch } from '@wordpress/data';
|
11
14
|
|
12
15
|
import HistoryUndo from './undo';
|
13
16
|
import HistoryRedo from './redo';
|
14
17
|
|
15
18
|
export default function Header() {
|
19
|
+
const { setIsInserterOpened } = useDispatch( 'block-editor' );
|
20
|
+
const isInserterOpened = useSelect((select) => select("block-editor").isInserterOpened());
|
21
|
+
|
16
22
|
return (
|
17
23
|
<div
|
18
24
|
className="block-editor__header"
|
19
25
|
role="region"
|
20
26
|
tabIndex="-1"
|
21
27
|
>
|
22
|
-
<
|
23
|
-
|
24
|
-
|
28
|
+
<div>
|
29
|
+
{ !isInserterOpened &&
|
30
|
+
<Button isPrimary
|
31
|
+
icon={ openIcon }
|
32
|
+
label={ 'Open Library' }
|
33
|
+
onClick={ () =>
|
34
|
+
setIsInserterOpened( true )
|
35
|
+
}
|
36
|
+
/>
|
37
|
+
}
|
38
|
+
{ isInserterOpened &&
|
39
|
+
<Button isSecondary
|
40
|
+
icon={ closeIcon }
|
41
|
+
label={ 'Close Library' }
|
42
|
+
onClick={ () =>
|
43
|
+
setIsInserterOpened( false )
|
44
|
+
}
|
45
|
+
/>
|
46
|
+
}
|
25
47
|
<HistoryUndo />
|
26
48
|
<HistoryRedo />
|
27
49
|
<Button
|
@@ -39,7 +61,7 @@ export default function Header() {
|
|
39
61
|
onClick={() => document.querySelector('.block-editor').classList.remove('block-editor__fullscreen')}
|
40
62
|
/>
|
41
63
|
|
42
|
-
</
|
64
|
+
</div>
|
43
65
|
</div>
|
44
66
|
);
|
45
67
|
}
|
@@ -13,7 +13,7 @@ function HistoryRedo( { hasRedo, redo, ...props } ) {
|
|
13
13
|
{ ...props }
|
14
14
|
icon={ redoIcon }
|
15
15
|
label={ __( 'Redo' ) }
|
16
|
-
shortcut={ displayShortcut.
|
16
|
+
shortcut={ displayShortcut.primaryShift( 'z' ) }
|
17
17
|
// If there are no redo levels we don't want to actually disable this
|
18
18
|
// button, because it will remove focus for keyboard users.
|
19
19
|
// See: https://github.com/WordPress/gutenberg/issues/3486
|
@@ -1,14 +1,15 @@
|
|
1
1
|
.block-editor__header {
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
2
|
+
padding: 0 .5rem;
|
3
|
+
align-items: center;
|
4
|
+
background: $white;
|
5
|
+
border-bottom: 1px solid $gray-200;
|
6
|
+
display: flex;
|
7
|
+
height: $header-height;
|
8
|
+
justify-content: space-between;
|
9
|
+
left: 0;
|
10
|
+
// Stick the toolbar to the top, because the admin bar is not fixed on mobile.
|
11
|
+
position: sticky;
|
12
|
+
right: 0;
|
13
|
+
top: 0;
|
13
14
|
z-index: 1;
|
14
15
|
}
|
@@ -20,12 +20,12 @@ class MediaUpload extends Component {
|
|
20
20
|
}
|
21
21
|
|
22
22
|
openUploader() {
|
23
|
-
if (window.
|
24
|
-
console.
|
23
|
+
if (window.BlockEditorMediaUploader == undefined) {
|
24
|
+
console.warn('window.BlockEditorMediaUploader undefined. Pulling in random image from Unsplash')
|
25
25
|
|
26
26
|
this.props.onSelect( { url: 'https://source.unsplash.com/random/800x500' });
|
27
27
|
} else {
|
28
|
-
|
28
|
+
window.BlockEditorMediaUploader.open(this.props.onSelect);
|
29
29
|
}
|
30
30
|
}
|
31
31
|
|
@@ -19,9 +19,7 @@ function Sidebar() {
|
|
19
19
|
aria-label={ __( 'Standalone Block Editor advanced settings.' ) }
|
20
20
|
tabIndex="-1"
|
21
21
|
>
|
22
|
-
|
23
|
-
<InspectorSlot bubblesVirtually />
|
24
|
-
</Panel>
|
22
|
+
<InspectorSlot bubblesVirtually />
|
25
23
|
</div>
|
26
24
|
);
|
27
25
|
}
|
@@ -1,43 +1,43 @@
|
|
1
1
|
.block-editor__sidebar {
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
2
|
+
background: $white;
|
3
|
+
border-left: $border-width solid $gray-200;
|
4
|
+
bottom: 0;
|
5
|
+
height: 100vh;
|
6
|
+
overflow: hidden;
|
7
|
+
position: absolute;
|
8
|
+
right: 0;
|
9
|
+
top: 0;
|
10
|
+
width: $sidebar-width;
|
11
|
+
margin-bottom: 33px;
|
12
|
+
//z-index: z-index(".edit-site-sidebar");
|
13
13
|
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
14
|
+
@include break-small() {
|
15
|
+
-webkit-overflow-scrolling: touch;
|
16
|
+
height: auto;
|
17
|
+
overflow: auto;
|
18
|
+
// top: $admin-bar-height-big + $header-height;
|
19
|
+
}
|
20
20
|
|
21
|
-
|
22
|
-
|
23
|
-
|
21
|
+
// @include break-medium() {
|
22
|
+
// top: $admin-bar-height + $header-height;
|
23
|
+
// }
|
24
24
|
|
25
|
-
|
26
|
-
|
27
|
-
|
25
|
+
@include break-small() {
|
26
|
+
display: block;
|
27
|
+
}
|
28
28
|
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
29
|
+
> .components-panel {
|
30
|
+
border-left: 0;
|
31
|
+
border-right: 0;
|
32
|
+
margin-bottom: -1px;
|
33
|
+
margin-top: -1px;
|
34
34
|
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
35
|
+
> .components-panel__header {
|
36
|
+
background: $gray-200;
|
37
|
+
}
|
38
|
+
}
|
39
39
|
|
40
|
-
|
41
|
-
|
42
|
-
|
40
|
+
.block-editor-block-inspector__card {
|
41
|
+
margin: 0;
|
42
|
+
}
|
43
43
|
}
|
@@ -6,6 +6,18 @@ import {
|
|
6
6
|
} from "./action-types";
|
7
7
|
import { ActionCreators as ReduxUndo } from "redux-undo";
|
8
8
|
|
9
|
+
/**
|
10
|
+
* Returns an action object used to open/close the inserter.
|
11
|
+
*
|
12
|
+
* @param {boolean} value A boolean representing whether the inserter should be opened or closed.
|
13
|
+
* @return {Object} Action object.
|
14
|
+
*/
|
15
|
+
export function setIsInserterOpened( value ) {
|
16
|
+
return {
|
17
|
+
type: 'SET_IS_INSERTER_OPENED',
|
18
|
+
value,
|
19
|
+
};
|
20
|
+
}
|
9
21
|
|
10
22
|
export function undo() {
|
11
23
|
return ReduxUndo.undo();
|
@@ -1,3 +1,5 @@
|
|
1
|
+
import { combineReducers } from '@wordpress/data';
|
2
|
+
|
1
3
|
import undoable, { groupByActionTypes, includeAction } from "redux-undo";
|
2
4
|
import { UPDATE_BLOCKS, PERSIST_BLOCKS } from "./action-types";
|
3
5
|
|
@@ -15,6 +17,24 @@ function blocksReducer(state = [], action) {
|
|
15
17
|
return state;
|
16
18
|
}
|
17
19
|
|
18
|
-
|
19
|
-
|
20
|
-
|
20
|
+
|
21
|
+
/**
|
22
|
+
* Reducer tracking whether the inserter is open.
|
23
|
+
*
|
24
|
+
* @param {boolean} state
|
25
|
+
* @param {Object} action
|
26
|
+
*/
|
27
|
+
function isInserterOpened( state = false, action ) {
|
28
|
+
switch ( action.type ) {
|
29
|
+
case 'SET_IS_INSERTER_OPENED':
|
30
|
+
return action.value;
|
31
|
+
}
|
32
|
+
return state;
|
33
|
+
}
|
34
|
+
|
35
|
+
export default combineReducers( {
|
36
|
+
isInserterOpened: isInserterOpened,
|
37
|
+
history: undoable(blocksReducer, {
|
38
|
+
filter: includeAction('PERSIST_BLOCKS')
|
39
|
+
})
|
40
|
+
} );
|
@@ -1,13 +1,24 @@
|
|
1
1
|
import { createRegistrySelector } from '@wordpress/data';
|
2
2
|
|
3
3
|
export const getBlocks = ( state ) => {
|
4
|
-
return state.present.blocks || [];
|
4
|
+
return state.history.present.blocks || [];
|
5
|
+
}
|
6
|
+
|
7
|
+
/**
|
8
|
+
* Returns true if the inserter is opened.
|
9
|
+
*
|
10
|
+
* @param {Object} state Global application state.
|
11
|
+
*
|
12
|
+
* @return {boolean} Whether the inserter is opened.
|
13
|
+
*/
|
14
|
+
export function isInserterOpened( state ) {
|
15
|
+
return state.isInserterOpened;
|
5
16
|
}
|
6
17
|
|
7
18
|
export const hasUndo = (state) => {
|
8
|
-
return state.past?.length;
|
19
|
+
return state.history.past?.length;
|
9
20
|
};
|
10
21
|
|
11
22
|
export const hasRedo = (state) => {
|
12
|
-
return state.future?.length;
|
23
|
+
return state.history.future?.length;
|
13
24
|
};
|
@@ -16,14 +16,21 @@ export default class extends Controller {
|
|
16
16
|
|
17
17
|
connect() {
|
18
18
|
const settings = {
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
19
|
+
alignWide: true,
|
20
|
+
__experimentalFeatures: {
|
21
|
+
global: {
|
22
|
+
color: {
|
23
|
+
custom: false,
|
24
|
+
palette: [],
|
25
|
+
gradients: []
|
26
|
+
},
|
27
|
+
typography: {
|
28
|
+
dropCap: false,
|
29
|
+
fontSizes: false,
|
30
|
+
customLineHeight: false
|
31
|
+
}
|
32
|
+
}
|
33
|
+
},
|
27
34
|
mediaUpload: function uploadMedia( {
|
28
35
|
allowedTypes,
|
29
36
|
additionalData = {},
|
@@ -1,12 +1,4 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
@function theme($selector) {
|
4
|
-
@return $primary-color;
|
5
|
-
}
|
6
|
-
|
7
|
-
@function color($color) {
|
8
|
-
@return $color;
|
9
|
-
}
|
1
|
+
@import url('https://fonts.googleapis.com/css2?family=Noto+Serif:wght@400;700&display=swap');
|
10
2
|
|
11
3
|
@import "~@wordpress/base-styles/colors";
|
12
4
|
@import "~@wordpress/base-styles/variables";
|
@@ -15,13 +7,8 @@ $primary-color: #1b8ecf;
|
|
15
7
|
@import "~@wordpress/base-styles/animations";
|
16
8
|
@import "~@wordpress/base-styles/z-index";
|
17
9
|
|
18
|
-
.block-editor {
|
19
|
-
label {
|
20
|
-
font-size: $default-font-size;
|
21
|
-
}
|
22
|
-
}
|
23
|
-
|
24
10
|
@import "~@wordpress/components/src/style";
|
11
|
+
@import "~@wordpress/interface/src/style";
|
25
12
|
@import "~@wordpress/block-editor/src/style";
|
26
13
|
@import "~@wordpress/block-library/src/style";
|
27
14
|
|
@@ -32,26 +19,68 @@ $header-height: 50px;
|
|
32
19
|
@import "../../block_editor/components/header/styles";
|
33
20
|
@import "../../block_editor/components/block-editor/styles";
|
34
21
|
|
22
|
+
.block-editor-block-list__layout.is-root-container {
|
23
|
+
padding-top: 1rem;
|
24
|
+
padding-bottom: 1rem;
|
25
|
+
}
|
26
|
+
|
35
27
|
.block-editor {
|
36
28
|
@include reset;
|
37
29
|
position: relative;
|
38
30
|
margin: 1rem 0;
|
39
31
|
padding: 0;
|
40
|
-
font-family: $
|
41
|
-
font-size: $
|
32
|
+
font-family: $editor-font;
|
33
|
+
font-size: $editor-font-size;
|
34
|
+
line-height: $editor-line-height;
|
42
35
|
border: 1px solid #f3f4f5;
|
43
|
-
|
36
|
+
height: 500px;
|
37
|
+
overflow-y: hidden;
|
44
38
|
|
45
39
|
a,
|
46
40
|
div {
|
47
41
|
outline: 0;
|
48
42
|
}
|
49
43
|
|
44
|
+
label {
|
45
|
+
font-size: $default-font-size;
|
46
|
+
}
|
47
|
+
|
48
|
+
.editor-styles-wrapper {
|
49
|
+
font-family: $default-font;
|
50
|
+
font-size: $default-font-size;
|
51
|
+
}
|
52
|
+
|
53
|
+
[type='text'], [type='password'], [type='date'], [type='datetime'], [type='datetime-local'], [type='month'], [type='week'], [type='email'], [type='number'], [type='search'], [type='tel'], [type='time'], [type='url'], [type='color'], textarea {
|
54
|
+
margin-bottom: 0;
|
55
|
+
}
|
56
|
+
|
57
|
+
@include admin-scheme(#1b8ecf);
|
58
|
+
|
59
|
+
.block-editor-inserter__main-area {
|
60
|
+
padding-bottom: 2rem;
|
61
|
+
}
|
62
|
+
|
50
63
|
.block-editor-url-popover__additional-controls,
|
51
64
|
.block-editor-media-replace-flow__options .components-form-file-upload {
|
52
65
|
display: none;
|
53
66
|
}
|
54
67
|
|
68
|
+
.components-dropdown-menu__toggle[aria-label="Change alignment"] {
|
69
|
+
display: none !important;
|
70
|
+
}
|
71
|
+
|
72
|
+
.components-toolbar-button[aria-label="Crop"] {
|
73
|
+
display: none !important;
|
74
|
+
}
|
75
|
+
|
76
|
+
.block-editor-block-mover__move-button-container {
|
77
|
+
display: inline-flex;
|
78
|
+
}
|
79
|
+
|
80
|
+
.block-editor-inserter__manage-reusable-blocks {
|
81
|
+
display: none;
|
82
|
+
}
|
83
|
+
|
55
84
|
&:not(.block-editor__fullscreen) {
|
56
85
|
.block-editor__size-toggle-button__minimize {
|
57
86
|
display: none;
|
@@ -80,6 +109,7 @@ $header-height: 50px;
|
|
80
109
|
padding: 0;
|
81
110
|
z-index: 99;
|
82
111
|
margin: 0;
|
112
|
+
height: unset;
|
83
113
|
.block-editor {
|
84
114
|
height: 100%;
|
85
115
|
}
|
@@ -97,12 +127,26 @@ html.wp-toolbar {
|
|
97
127
|
@include reset;
|
98
128
|
}
|
99
129
|
|
100
|
-
.
|
101
|
-
|
102
|
-
|
103
|
-
|
104
|
-
|
105
|
-
|
106
|
-
|
107
|
-
|
130
|
+
.interface-interface {
|
131
|
+
&-skeleton {
|
132
|
+
position: absolute;
|
133
|
+
top: 0;
|
134
|
+
left: 0;
|
135
|
+
background-color: white;
|
136
|
+
&__footer {
|
137
|
+
position: inherit;
|
138
|
+
.block-editor-block-breadcrumb {
|
139
|
+
position: absolute;
|
140
|
+
bottom: 0;
|
141
|
+
z-index: 1;
|
142
|
+
background-color: $white;
|
143
|
+
width: 100%;
|
144
|
+
border-top: 1px solid #f3f4f5;
|
145
|
+
padding: 1rem 0;
|
146
|
+
}
|
147
|
+
}
|
148
|
+
&__sidebar {
|
149
|
+
width: 280px;
|
150
|
+
}
|
151
|
+
}
|
108
152
|
}
|