Skip to content

Commit ff91466

Browse files
authored
feat(toolbar): toolbar refactored and ui improved (#1815)
* chore(block-tune-toggler): toggler moved to the left (draft) * toolbox ui updated * fixd caret jumpling, improved some styles * toolbar moving by block-hover - UI module triggers 'block-hovered' event - Toolbar uses 'block-hovered' for appearing - `currentBlock` setter added to the BlockManager - (reactangle-selection): the throttling added to the mousemove and scroll handlers - `getBlockIndex` method added to the Api - (api-blocks): toolbar moving logic removed from `blocks.move()` and `blocks.swap()` methods. Instead, MoveUp and MoveDown tunes uses Toolbar API * the dark-theme to the example-dev.html * positioning improved * fix(rectangle-selection): first click after RS does not clears selection state * toolbox position fixed * the toolbox module became a standalone class - Toolbox became a standalone class from the editor module. It can be accessed only via the owner (the Toolbar module) - (api.blocks) the insert() method now has the `replace` param. Also, it returns inserted Block API now. * new(api.listeners): `on()` now returns the listener id. The new `offById()` method added * fix bug with Tab pressing on hovered but not focused block * mobile version improved * upd example dev * small updaets * add nested-list * linting * (api.toolbar): `toggleBlockSettings` now fires toggling event with the same state * EventDispatcher used instead of callbacks for the Toolbox * UIApi added * fix ci * git submodules removed from the ci flow * add paragraph submodule to the ci flow * Update CHANGELOG.md * Update package.json * use ubuntu-latest for chrome ci
1 parent acdd1f5 commit ff91466

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

50 files changed

+1123
-790
lines changed

.github/workflows/cypress.yml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,17 +8,17 @@ jobs:
88
options: --user 1001
99
steps:
1010
- uses: actions/checkout@v2
11-
- run: yarn pull_tools && yarn tools:update
11+
- run: yarn ci:pull_paragraph
1212
- uses: cypress-io/github-action@v2
1313
with:
1414
config: video=false
1515
browser: firefox
1616
build: yarn build
1717
chrome:
18-
runs-on: ubuntu-16.04
18+
runs-on: ubuntu-latest
1919
steps:
2020
- uses: actions/checkout@v2
21-
- run: yarn pull_tools && yarn tools:update
21+
- run: yarn ci:pull_paragraph
2222
- uses: cypress-io/github-action@v2
2323
with:
2424
config: video=false
@@ -28,7 +28,7 @@ jobs:
2828
runs-on: windows-latest
2929
steps:
3030
- uses: actions/checkout@v2
31-
- run: yarn pull_tools && yarn tools:update
31+
- run: yarn ci:pull_paragraph
3232
- uses: cypress-io/github-action@v2
3333
with:
3434
config: video=false

.gitmodules

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,3 +49,6 @@
4949
[submodule "example/tools/underline"]
5050
path = example/tools/underline
5151
url = https://github.com/editor-js/underline
52+
[submodule "example/tools/nested-list"]
53+
path = example/tools/nested-list
54+
url = https://github.com/editor-js/nested-list

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -251,4 +251,4 @@ CodeX is a team of digital specialists around the world interested in building h
251251

252252
| 🌐 | Join 👋 | Twitter | Instagram |
253253
| -- | -- | -- | -- |
254-
| [codex.so](https://codex.so) | [codex.so/join](https://codex.so/join) |[@codex_team](http://twitter.com/codex_team) | [@codex_team](http://instagram.com/codex_team) |
254+
| [codex.so](https://codex.so) | [codex.so/join](https://codex.so/join) |[@codex_team](http://twitter.com/codex_team) | [@codex_team](http://instagram.com/codex_team/) |

docs/CHANGELOG.md

Lines changed: 18 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,24 @@
22

33
### 2.23.0
44

5-
- `Improvement` — The `onChange` callback now accepts two arguments: EditorJS API and the CustomEvent with `type` and `detail` allowing to determine what happened with a Block
6-
- `New` *Block API* — The new `dispatchChange()` method allows to manually trigger the 'onChange' callback. Useful when Tool made a state mutation that is invisible for editor core.
5+
- `Improvement`*EditorConfig* — The `onChange` callback now accepts two arguments: EditorJS API and the CustomEvent with `type` and `detail` allowing to determine what happened with a Block
6+
- `New`*Block API* — The new `dispatchChange()` method allows to manually trigger the 'onChange' callback. Useful when Tool made a state mutation that is invisible for editor core.
7+
- `Improvement`*UI* — Block Tunes toggler moved to the left
8+
- `Improvement`*UI* — Block Actions (BT toggler + Plus Button) will appear on block hovering instead of click
9+
- `Improvement`*UI* — Block Tunes toggler icon and Plus button icon updated
10+
- `Improvement`*Dev Example Page* — The menu with helpful buttons added to the bottom of the screen
11+
- `Improvement`*Dev Example Page* — The 'dark' theme added. Now we can code at night more comfortably.
12+
- `Improvement`*Rectangle Selection* — paint optimized
13+
- `Fix`*Rectangle Selection* — the first click after RS was not clear selection state. Now does.
14+
- `Improvement`*Blocks API* — toolbar moving logic removed from `blocks.move()` and `blocks.swap()` methods. Instead, you should use Toolbar API (it was used by MoveUp and MoveDown tunes, they were updated).
15+
- `New`*Blocks API* — The `getBlockIndex()` method added
16+
- `New`*Blocks API* — the `insert()` method now has the `replace: boolean` parameter
17+
- `New`*Blocks API* — the `insert()` method now returns the inserted `Block API`
18+
- `New`*Listeners API* — the `on()` method now returns the listener id.
19+
- `New`*Listeners API* — the new `offById()` method added
20+
- `New``API` — The new `UiApi` section was added. It allows accessing some editor UI nodes and methods.
21+
- `Refactoring` — Toolbox became a standalone class instead of a Module. It can be accessed only through the Toolbar module.
22+
- `Refactoring` — CI flow optimized.
723

824
### 2.22.3
925

example/assets/demo.css

Lines changed: 195 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,35 @@
11
/**
22
* Styles for the example page
33
*/
4+
5+
:root {
6+
--color-bg-main: #fff;
7+
--color-border-light: #E8E8EB;
8+
--color-text-main: #000;
9+
}
10+
11+
.dark-mode {
12+
--color-border-light: rgba(255, 255, 255,.08);
13+
--color-bg-main: #1c1e24;
14+
--color-text-main: #737886;
15+
}
16+
17+
418
body {
519
font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "Roboto", "Oxygen", "Ubuntu", "Cantarell", "Fira Sans", "Droid Sans", "Helvetica Neue", sans-serif;
620
font-size: 14px;
721
line-height: 1.5em;
822
margin: 0;
23+
background: var(--color-bg-main);
24+
color: var(--color-text-main);
925
}
1026

1127
.ce-example {
1228
font-size: 16.2px;
1329
}
1430

1531
.ce-example__header {
16-
border-bottom: 1px solid #E8E8EB;
32+
border-bottom: 1px solid var(--color-border-light);
1733
height: 50px;
1834
line-height: 50px;
1935
display: flex;
@@ -62,23 +78,17 @@ body {
6278
-moz-osx-font-smoothing: grayscale;
6379
}
6480

65-
.ce-example__content--small {
81+
.thin-mode .ce-example__content {
6682
max-width: 500px;
6783
border-left: 1px solid #eee;
6884
border-right: 1px solid #eee;
6985
padding: 0 15px;
7086
}
7187

72-
.ce-example__content--with-bg {
73-
background: #f4f4f4;
74-
max-width: none;
75-
margin-top: -30px;
76-
}
77-
7888
.ce-example__output {
7989
background: #1B202B;
8090
overflow-x: auto;
81-
padding: 0 30px;
91+
padding: 0 30px 80px;
8292
}
8393

8494
.ce-example__output-content {
@@ -127,29 +137,94 @@ body {
127137
}
128138

129139
.ce-example__statusbar {
140+
display: flex;
141+
align-items: center;
130142
position: fixed;
131-
bottom: 10px;
132-
right: 10px;
133-
background: #fff;
134-
border-radius: 8px;
135-
box-shadow: 0 2px 6px rgba(0, 0, 0, 0.18);
136-
font-size: 12px;
143+
bottom: 0;
144+
right: 0;
145+
left: 0;
146+
background: var(--color-bg-main);
147+
border-radius: 8px 8px 0 0;
148+
border-top: 1px solid var(--color-border-light);
149+
box-shadow: 0 2px 6px var(--color-border-light);
150+
font-size: 13px;
137151
padding: 8px 15px;
138152
z-index: 1;
153+
user-select: none;
154+
}
155+
156+
@media (max-width: 768px) {
157+
.ce-example__statusbar {
158+
display: none;
159+
}
160+
}
161+
162+
.ce-example__statusbar-item:not(:last-of-type)::after {
163+
content: '|';
164+
color: #ddd;
165+
margin: 0 15px 0 12px;
166+
}
167+
168+
.ce-example__statusbar-item--right {
169+
margin-left: auto;
139170
}
140171

141172
.ce-example__statusbar-button {
142-
display: inline-flex;
143-
margin-left: 10px;
144-
background: #4A9DF8;
145-
padding: 6px 12px;
146-
box-shadow: 0 7px 8px -4px rgba(137, 207, 255, 0.77);
173+
display: inline-block;
174+
padding: 3px 12px;
147175
transition: all 150ms ease;
148176
cursor: pointer;
149177
border-radius: 31px;
178+
background: #eff1f4;
179+
text-align: center;
180+
user-select: none;
181+
}
182+
183+
.ce-example__statusbar-button:hover {
184+
background: #e0e4eb;
185+
}
186+
187+
.ce-example__statusbar-button-primary {
188+
background: #4A9DF8;
150189
color: #fff;
190+
box-shadow: 0 7px 8px -4px rgba(137, 207, 255, 0.77);
151191
font-family: 'PT Mono', Menlo, Monaco, Consolas, Courier New, monospace;
152-
text-align: center;
192+
}
193+
194+
.ce-example__statusbar {
195+
--toggler-size: 20px;
196+
}
197+
198+
.ce-example__statusbar-toggler {
199+
position: relative;
200+
background: #7b8799;
201+
border-radius: 20px;
202+
padding: 2px;
203+
width: calc(var(--toggler-size) * 2.2);
204+
cursor: pointer;
205+
user-select: none;
206+
}
207+
208+
.ce-example__statusbar-toggler::before {
209+
display: block;
210+
content: '';
211+
width: var(--toggler-size);
212+
height: var(--toggler-size);
213+
background: #fff;
214+
border-radius: 50%;
215+
transition: transform 100ms ease-in;
216+
}
217+
218+
.ce-example__statusbar-toggler::after {
219+
--moon-size: calc(var(--toggler-size) * 0.5);
220+
content: '';
221+
position: absolute;
222+
top: 5px;
223+
right: 5px;
224+
height: var(--moon-size);
225+
width: var(--moon-size);
226+
box-shadow: calc(var(--moon-size) * 0.25 * -1) calc(var(--moon-size) * 0.18) 0 calc(var(--moon-size) * 0.05) white;
227+
border-radius: 50%;
153228
}
154229

155230
@media all and (max-width: 730px){
@@ -178,22 +253,10 @@ body {
178253
color: rgb(247, 60, 173);
179254
}
180255

181-
.ce-example .ce-block:first-of-type h2.ce-header{
256+
.ce-example .ce-block:first-of-type h1.ce-header{
182257
font-size: 50px;
183258
}
184259

185-
.ce-example h2.ce-header{
186-
font-size: 30px;
187-
}
188-
189-
.ce-example h3.ce-header {
190-
font-size: 24px;
191-
}
192-
193-
.ce-example h4.ce-header {
194-
font-size: 18px;
195-
}
196-
197260
.ce-example-multiple {
198261
display: grid;
199262
grid-template-columns: calc(50% - 15px) calc(50% - 15px);
@@ -206,3 +269,101 @@ body {
206269
border-radius: 7px;
207270
padding: 30px;
208271
}
272+
273+
.show-block-boundaries .ce-block {
274+
box-shadow: inset 0 0 0 1px #eff2f5;
275+
}
276+
277+
.show-block-boundaries .ce-block__content {
278+
box-shadow: 0 0 0 1px rgba(224, 231, 241, 0.61) inset;
279+
}
280+
.show-block-boundaries #showBlocksBoundariesButton span,
281+
.thin-mode #enableThinModeButton span {
282+
font-size: 0;
283+
vertical-align: bottom;
284+
}
285+
286+
.show-block-boundaries #showBlocksBoundariesButton span::before,
287+
.thin-mode #enableThinModeButton span::before {
288+
content: attr(data-toggled-text);
289+
display: inline;
290+
font-size: 13px;
291+
}
292+
293+
294+
295+
/**
296+
* Dark theme overrides
297+
*/
298+
.dark-mode img {
299+
opacity: 0.5;
300+
}
301+
302+
.dark-mode .cdx-simple-image__picture--with-border,
303+
.dark-mode .cdx-input {
304+
border-color: var(--color-border-light);
305+
}
306+
307+
.dark-mode .ce-example__button {
308+
box-shadow: 0 24px 18px -14px rgba(4, 154, 255, 0.24);
309+
}
310+
311+
.dark-mode .ce-example__output {
312+
background-color: #17191f;
313+
}
314+
315+
.dark-mode .inline-code {
316+
background-color: rgba(53, 56, 68, 0.62);
317+
color: #727683;
318+
}
319+
320+
.dark-mode a {
321+
color: #959ba8;
322+
}
323+
324+
.dark-mode .ce-example__statusbar-toggler,
325+
.dark-mode .ce-example__statusbar-button {
326+
background-color: #343842;
327+
}
328+
329+
.dark-mode .ce-example__statusbar-toggler::before {
330+
transform: translateX(calc(var(--toggler-size) * 2.2 - var(--toggler-size)));
331+
}
332+
333+
.dark-mode .ce-example__statusbar-toggler::after {
334+
content: '*';
335+
right: auto;
336+
left: 6px;
337+
top: 7px;
338+
color: #fff;
339+
box-shadow: none;
340+
font-size: 32px;
341+
}
342+
343+
.dark-mode.show-block-boundaries .ce-block,
344+
.dark-mode.show-block-boundaries .ce-block__content {
345+
box-shadow: 0 0 0 1px rgba(128, 144, 159, 0.09) inset;
346+
}
347+
348+
.dark-mode.thin-mode .ce-example__content{
349+
border-color: var(--color-border-light);
350+
}
351+
352+
.dark-mode .ce-example__statusbar-item:not(:last-of-type)::after {
353+
color: var(--color-border-light);
354+
}
355+
356+
.dark-mode .ce-block--selected .ce-block__content,
357+
.dark-mode ::selection{
358+
background-color: rgba(57, 68, 84, 0.57);
359+
}
360+
361+
.dark-mode .ce-toolbox__button,
362+
.dark-mode .ce-toolbar__settings-btn,
363+
.dark-mode .ce-toolbar__plus {
364+
color: inherit;
365+
}
366+
367+
.dark-mode .ce-stub {
368+
opacity: 0.3;
369+
}

0 commit comments

Comments
 (0)