0
Fork 0
mirror of https://github.com/fastmail/Squire.git synced 2024-12-22 07:13:08 -05:00

Release v2.0.2

This commit is contained in:
Seth Falco 2023-03-19 10:20:03 +00:00 committed by Neil Jenkins
parent c84f48e480
commit a8cd95a688
8 changed files with 96 additions and 68 deletions

52
dist/squire-raw.js vendored
View file

@ -338,15 +338,15 @@
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;
}
if (child instanceof Text) {
startContainer = child;
startOffset = child.data.length;
let textChild = child;
let prev;
while (!textChild.length && (prev = textChild.previousSibling) && prev instanceof Text) {
textChild.remove();
textChild = prev;
}
startContainer = textChild;
startOffset = textChild.data.length;
}
}
break;
@ -466,18 +466,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];
Array.from(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");
@ -487,15 +483,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));
}
@ -1721,6 +1715,7 @@
text.deleteData(offset - 1, 1);
self.setSelection(range);
self.removeLink();
event.preventDefault();
} else {
self.setSelection(range);
setTimeout(() => {
@ -1928,8 +1923,27 @@
"ArrowLeft"(self) {
self._removeZWS();
},
"ArrowRight"(self) {
"ArrowRight"(self, event, range) {
self._removeZWS();
const root = self.getRoot();
if (rangeDoesEndAtBlockBoundary(range, root)) {
moveRangeBoundariesDownTree(range);
let node = range.endContainer;
do {
if (node.nodeName === "CODE") {
let next = node.nextSibling;
if (!(next instanceof Text)) {
const textNode = document.createTextNode("\xA0");
node.parentNode.insertBefore(textNode, next);
next = textNode;
}
range.setStart(next, 1);
self.setSelection(range);
event.preventDefault();
break;
}
} while (!node.nextSibling && (node = node.parentNode) && node !== root);
}
}
};
if (!supportsInputEvents) {
@ -4032,7 +4046,7 @@
range = this.getSelection();
}
if (range.collapsed) {
return this;
return this.focus();
}
const root = this._root;
let stopNode = range.commonAncestorContainer;
@ -4044,7 +4058,7 @@
stopNode = root;
}
if (stopNode instanceof Text) {
return this;
return this.focus();
}
this.saveUndoState(range);
moveRangeBoundariesUpTree(range, stopNode, stopNode, root);

52
dist/squire-raw.mjs vendored
View file

@ -340,15 +340,15 @@ 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;
}
if (child instanceof Text) {
startContainer = child;
startOffset = child.data.length;
let textChild = child;
let prev;
while (!textChild.length && (prev = textChild.previousSibling) && prev instanceof Text) {
textChild.remove();
textChild = prev;
}
startContainer = textChild;
startOffset = textChild.data.length;
}
}
break;
@ -468,18 +468,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];
Array.from(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");
@ -489,15 +485,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));
}
@ -1723,6 +1717,7 @@ var Backspace = (self, event, range) => {
text.deleteData(offset - 1, 1);
self.setSelection(range);
self.removeLink();
event.preventDefault();
} else {
self.setSelection(range);
setTimeout(() => {
@ -1930,8 +1925,27 @@ var keyHandlers = {
"ArrowLeft"(self) {
self._removeZWS();
},
"ArrowRight"(self) {
"ArrowRight"(self, event, range) {
self._removeZWS();
const root = self.getRoot();
if (rangeDoesEndAtBlockBoundary(range, root)) {
moveRangeBoundariesDownTree(range);
let node = range.endContainer;
do {
if (node.nodeName === "CODE") {
let next = node.nextSibling;
if (!(next instanceof Text)) {
const textNode = document.createTextNode("\xA0");
node.parentNode.insertBefore(textNode, next);
next = textNode;
}
range.setStart(next, 1);
self.setSelection(range);
event.preventDefault();
break;
}
} while (!node.nextSibling && (node = node.parentNode) && node !== root);
}
}
};
if (!supportsInputEvents) {
@ -4053,7 +4067,7 @@ var Squire = class {
range = this.getSelection();
}
if (range.collapsed) {
return this;
return this.focus();
}
const root = this._root;
let stopNode = range.commonAncestorContainer;
@ -4065,7 +4079,7 @@ var Squire = class {
stopNode = root;
}
if (stopNode instanceof Text) {
return this;
return this.focus();
}
this.saveUndoState(range);
moveRangeBoundariesUpTree(range, stopNode, stopNode, root);

20
dist/squire.js vendored

File diff suppressed because one or more lines are too long

6
dist/squire.js.map vendored

File diff suppressed because one or more lines are too long

22
dist/squire.mjs vendored

File diff suppressed because one or more lines are too long

6
dist/squire.mjs.map vendored

File diff suppressed because one or more lines are too long

4
package-lock.json generated
View file

@ -1,12 +1,12 @@
{
"name": "squire-rte",
"version": "2.0.0",
"version": "2.0.2",
"lockfileVersion": 2,
"requires": true,
"packages": {
"": {
"name": "squire-rte",
"version": "2.0.0",
"version": "2.0.2",
"license": "MIT",
"devDependencies": {
"@babel/core": "^7.20.12",

View file

@ -1,6 +1,6 @@
{
"name": "squire-rte",
"version": "2.0.1",
"version": "2.0.2",
"description": "Squire is an HTML5 rich text editor, which provides powerful cross-browser normalisation, whilst being supremely lightweight and flexible.",
"main": "dist/squire.mjs",
"type": "module",