Skip to content

Commit

Permalink
ci: add test and lint jobs to ci
Browse files Browse the repository at this point in the history
  • Loading branch information
SethFalco committed Mar 19, 2023
1 parent cdb57eb commit 04578d3
Show file tree
Hide file tree
Showing 11 changed files with 66 additions and 58 deletions.
3 changes: 3 additions & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
Expand Up @@ -10,3 +10,6 @@ insert_final_newline = true
charset = utf-8
indent_style = space
indent_size = 4

[*.{yml,yaml}]
indent_size = 2
17 changes: 16 additions & 1 deletion .gitlab-ci.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,20 @@
before_script:
- npm ci --ignore-scripts --force

build:
stage: build
script: npm run build
only:
- merge_requests

lint:
stage: test
script: npm run lint
only:
- merge_requests

test:
stage: test
script: npm ci --ignore-scripts --force && npm run test
script: npm run test
only:
- merge_requests
22 changes: 9 additions & 13 deletions dist/squire-raw.js
Original file line number Diff line number Diff line change
Expand Up @@ -338,11 +338,13 @@
if (!child || isLeaf(child)) {
if (startOffset) {
child = startContainer.childNodes[startOffset - 1];
let prev = child.previousSibling;
while (child instanceof Text && !child.length && prev && prev instanceof Text) {
child.remove();
child = prev;
continue;
const prev = child.previousSibling;
if (prev && prev instanceof Text) {
while (child instanceof Text && !child.length) {
child.remove();
child = prev;
continue;
}
}
if (child instanceof Text) {
startContainer = child;
Expand Down Expand Up @@ -466,18 +468,14 @@
return node;
};
var fixContainer = (container, root) => {
const children = container.childNodes;
let wrapper = null;
for (let i = 0, l = children.length; i < l; i += 1) {
const child = children[i];
[...container.childNodes].forEach((child) => {
const isBR = child.nodeName === "BR";
if (!isBR && isInline(child)) {
if (!wrapper) {
wrapper = createElement("DIV");
}
wrapper.appendChild(child);
i -= 1;
l -= 1;
} else if (isBR || wrapper) {
if (!wrapper) {
wrapper = createElement("DIV");
Expand All @@ -487,15 +485,13 @@
container.replaceChild(wrapper, child);
} else {
container.insertBefore(wrapper, child);
i += 1;
l += 1;
}
wrapper = null;
}
if (isContainer(child)) {
fixContainer(child, root);
}
}
});
if (wrapper) {
container.appendChild(fixCursor(wrapper));
}
Expand Down
22 changes: 9 additions & 13 deletions dist/squire-raw.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -340,11 +340,13 @@ var moveRangeBoundariesDownTree = (range) => {
if (!child || isLeaf(child)) {
if (startOffset) {
child = startContainer.childNodes[startOffset - 1];
let prev = child.previousSibling;
while (child instanceof Text && !child.length && prev && prev instanceof Text) {
child.remove();
child = prev;
continue;
const prev = child.previousSibling;
if (prev && prev instanceof Text) {
while (child instanceof Text && !child.length) {
child.remove();
child = prev;
continue;
}
}
if (child instanceof Text) {
startContainer = child;
Expand Down Expand Up @@ -468,18 +470,14 @@ var fixCursor = (node) => {
return node;
};
var fixContainer = (container, root) => {
const children = container.childNodes;
let wrapper = null;
for (let i = 0, l = children.length; i < l; i += 1) {
const child = children[i];
[...container.childNodes].forEach((child) => {
const isBR = child.nodeName === "BR";
if (!isBR && isInline(child)) {
if (!wrapper) {
wrapper = createElement("DIV");
}
wrapper.appendChild(child);
i -= 1;
l -= 1;
} else if (isBR || wrapper) {
if (!wrapper) {
wrapper = createElement("DIV");
Expand All @@ -489,15 +487,13 @@ var fixContainer = (container, root) => {
container.replaceChild(wrapper, child);
} else {
container.insertBefore(wrapper, child);
i += 1;
l += 1;
}
wrapper = null;
}
if (isContainer(child)) {
fixContainer(child, root);
}
}
});
if (wrapper) {
container.appendChild(fixCursor(wrapper));
}
Expand Down
2 changes: 1 addition & 1 deletion dist/squire.js

Large diffs are not rendered by default.

6 changes: 3 additions & 3 deletions dist/squire.js.map

Large diffs are not rendered by default.

22 changes: 11 additions & 11 deletions dist/squire.mjs

Large diffs are not rendered by default.

6 changes: 3 additions & 3 deletions dist/squire.mjs.map

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion source/node/MergeSplit.ts
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ const fixContainer = (
root: Element | DocumentFragment,
): Node => {
let wrapper: HTMLElement | null = null;
[...container.childNodes].forEach(child => {
[...container.childNodes].forEach((child) => {
const isBR = child.nodeName === 'BR';
if (!isBR && isInline(child)) {
if (!wrapper) {
Expand Down
18 changes: 8 additions & 10 deletions source/range/Boundaries.ts
Original file line number Diff line number Diff line change
Expand Up @@ -48,19 +48,17 @@ const moveRangeBoundariesDownTree = (range: Range): void => {
if (!child || isLeaf(child)) {
if (startOffset) {
child = startContainer.childNodes[startOffset - 1];
let prev = child.previousSibling;
const prev = child.previousSibling;
// If we have an empty text node next to another text node,
// just skip and remove it.
while (
child instanceof Text &&
!child.length &&
prev &&
prev instanceof Text
) {
child.remove();
child = prev;
continue;
if (prev && prev instanceof Text) {
while (child instanceof Text && !child.length) {
child.remove();
child = prev;
continue;
}
}

if (child instanceof Text) {
startContainer = child;
startOffset = child.data.length;
Expand Down

0 comments on commit 04578d3

Please sign in to comment.