Skip to content

Commit

Permalink
Add support for lists merging
Browse files Browse the repository at this point in the history
Version bump
  • Loading branch information
TheDeadJoe authored and thesebas committed Apr 12, 2021
1 parent b0213f2 commit 917d0a1
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 2 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@editorjs/list",
"version": "1.6.2",
"version": "1.6.2-smb.1",
"keywords": [
"codex editor",
"list",
Expand Down
18 changes: 17 additions & 1 deletion src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,11 @@ class List {

// fill with data
if (this._data.items.length) {
this._data.items.forEach((item) => {
this._data.items.forEach((item, idx) => {
if (this.mergePoint !== undefined && this.mergePoint === idx) {
this._elements.wrapper.appendChild(this._make('span', 'cdx-shadow-caret'));
this.mergePoint = undefined;
}
this._elements.wrapper.appendChild(this._make('li', this.CSS.item, {
innerHTML: item,
}));
Expand Down Expand Up @@ -388,6 +392,18 @@ class List {
return this._data;
}

merge(data) {
this.mergePoint = this.data.items.length;

this.data = {
...this.data,
items: [
...this.data.items,
...data.items,
],
};
}

/**
* Helper for making Elements with attributes
*
Expand Down

0 comments on commit 917d0a1

Please sign in to comment.