Skip to content
This repository has been archived by the owner on Oct 25, 2022. It is now read-only.

Commit

Permalink
Merge pull request #117 from eea/develop
Browse files Browse the repository at this point in the history
Deserialize break, debounce select
  • Loading branch information
tiberiuichim authored Jul 12, 2021
2 parents 3a9d094 + d6a4966 commit cdcb67a
Show file tree
Hide file tree
Showing 5 changed files with 41 additions and 14 deletions.
14 changes: 14 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,22 @@ All notable changes to this project will be documented in this file. Dates are d

Generated by [`auto-changelog`](https://github.com/CookPete/auto-changelog).

#### [2.8.2](https://github.com/eea/volto-slate/compare/2.8.1...2.8.2)

- Deserialize break properly [`#110`](https://github.com/eea/volto-slate/pull/110)
- Debounce on select state update [`#113`](https://github.com/eea/volto-slate/pull/113)
- Update SlateEditor.jsx [`6e88544`](https://github.com/eea/volto-slate/commit/6e885440dd603536809cd822b6aa73acbb917e78)
- Add Sonarqube tag using frontend addons list [`821e386`](https://github.com/eea/volto-slate/commit/821e386c79307e492546712f8e06cf63e32b206e)
- Add Sonarqube tag using frontend addons list [`fc21423`](https://github.com/eea/volto-slate/commit/fc2142376a65be21a02a5e6f21f92c8f6fff6424)
- fix quotes [`205d2bc`](https://github.com/eea/volto-slate/commit/205d2bcf965e7cd5d124d38ddad81dec8e125614)
- Add Sonarqube tag using frontend addons list [`afa38ab`](https://github.com/eea/volto-slate/commit/afa38abc1c80f441171e652b46439fb7ee24d865)
- Lower timeout to 150 [`363652c`](https://github.com/eea/volto-slate/commit/363652c2e891efc8c6be265e62489bb4ba0239ca)

#### [2.8.1](https://github.com/eea/volto-slate/compare/2.8.0...2.8.1)

> 1 July 2021
- Release Keyboard for detached mode and extras metadata in view mode [`#116`](https://github.com/eea/volto-slate/pull/116)
- Pass metadata extras to Element in view mode [`#115`](https://github.com/eea/volto-slate/pull/115)
- Add keyboard handler for detached mode (adds shift+enter soft break a… [`#114`](https://github.com/eea/volto-slate/pull/114)
- [JENKINS] - Fix eslint [`6931c95`](https://github.com/eea/volto-slate/commit/6931c953f83bc4ae076898a4eb77bb0778a5f780)
Expand Down
2 changes: 1 addition & 1 deletion Jenkinsfile
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ pipeline {
GIT_NAME = "volto-slate"
NAMESPACE = ""
DEPENDENCIES = "volto-slate:asDefault"
SONARQUBE_TAGS = "volto.eea.europa.eu"
SONARQUBE_TAGS = "volto.eea.europa.eu,climate-energy.eea.europa.eu,forest.eea.europa.eu,biodiversity.europa.eu"
}

stages {
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "volto-slate",
"version": "2.8.1",
"version": "2.8.2",
"description": "Slate.js integration with Volto",
"main": "src/index.js",
"author": "European Environment Agency: IDM2 A-Team",
Expand Down
23 changes: 13 additions & 10 deletions src/editor/SlateEditor.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,7 @@ class SlateEditor extends Component {
};

this.editor = null;
this.selectionTimeout = null;
}

getSavedSelection() {
Expand Down Expand Up @@ -248,16 +249,18 @@ class SlateEditor extends Component {
decorate={this.multiDecorator}
spellCheck={false}
onSelect={() => {
if (
editor.selection &&
!isEqual(editor.selection, this.savedSelection)
) {
this.setSavedSelection(
JSON.parse(JSON.stringify(editor.selection)),
);
this.setState((state) => ({ update: !this.state.update }));
// console.log('select', JSON.stringify(editor.selection));
}
if (this.selectionTimeout) clearTimeout(this.selectionTimeout);
this.selectionTimeout = setTimeout(() => {
if (
editor.selection &&
!isEqual(editor.selection, this.savedSelection)
) {
this.setState((state) => ({ update: !this.state.update }));
this.setSavedSelection(
JSON.parse(JSON.stringify(editor.selection)),
);
}
}, 200);
}}
onKeyDown={(event) => {
let wasHotkey = false;
Expand Down
14 changes: 12 additions & 2 deletions src/editor/deserialize.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,16 @@ export const deserialize = (editor, el) => {
// instead of === '\n' we use isWhitespace for when deserializing tables
// from Calc and other similar cases

// console.log('maybe whitespace', {
// text: `-${el.textContent}-`,
// prev: el.previousSibling,
// next: el.nextSibling,
// isPrev: isInline(el.previousSibling),
// isNext: isInline(el.nextSibling),
// prevName: el.previousSibling && el.previousSibling.nodeName,
// nextName: el.nextSibling && el.nextSibling.nodeName,
// });

if (isWhitespace(el.textContent)) {
// console.log({
// text: `-${el.textContent}-`,
Expand All @@ -54,8 +64,8 @@ export const deserialize = (editor, el) => {
} else if (el.nodeType !== ELEMENT_NODE) {
return null;
} else if (el.nodeName === 'BR') {
// TODO: handle <br> ?
return null;
// TODO: is handling <br> like this ok in all cases ?
return '\n';
}

if (el.getAttribute('data-slate-data')) {
Expand Down

0 comments on commit cdcb67a

Please sign in to comment.