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

Release v2.0.1

This commit is contained in:
Neil Jenkins 2023-02-14 15:17:01 +11:00
parent 1904405ab8
commit 27f19c4782
8 changed files with 113 additions and 49 deletions

View file

@ -4,6 +4,20 @@ All notable changes to this project will be documented in this file, starting fr
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
## [2.0.1] - 2023-02-14
### Changed
- Auto delink if backspacing inside auto-linked URL. This means if you make a
mistake and backspace, you don't end up accidentally fixing the text but
leaving the link to the wrong URL.
### Fixed
- Fix duplicate CSS created when replacing styles
- Support browsers without Selection#setBaseAndExtent API. This includes some
older Firefox versions.
## [2.0.0] - 2023-01-23
### Added

27
dist/squire-raw.js vendored
View file

@ -338,6 +338,12 @@
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;
@ -695,12 +701,16 @@
newTreeBottom.appendChild(el);
}
newTreeBottom = el;
node.style.setProperty(attr, css);
node.style.removeProperty(attr);
}
}
if (newTreeTop && newTreeBottom) {
newTreeBottom.appendChild(empty(node));
if (node.style.cssText) {
node.appendChild(newTreeTop);
} else {
replaceWith(node, newTreeTop);
}
}
return newTreeBottom || node;
};
@ -1702,12 +1712,22 @@
self.setSelection(range);
self._updatePath(range, true);
}
} else {
moveRangeBoundariesDownTree(range);
const text = range.startContainer;
const offset = range.startOffset;
const a = text.parentNode;
if (text instanceof Text && a instanceof HTMLAnchorElement && offset && a.href.includes(text.data)) {
text.deleteData(offset - 1, 1);
self.setSelection(range);
self.removeLink();
} else {
self.setSelection(range);
setTimeout(() => {
afterDelete(self);
}, 0);
}
}
};
// source/keyboard/Delete.ts
@ -2473,12 +2493,17 @@
} else {
const selection = window.getSelection();
if (selection) {
if ("setBaseAndExtent" in Selection.prototype) {
selection.setBaseAndExtent(
range.startContainer,
range.startOffset,
range.endContainer,
range.endOffset
);
} else {
selection.removeAllRanges();
selection.addRange(range);
}
}
}
return this;

27
dist/squire-raw.mjs vendored
View file

@ -340,6 +340,12 @@ 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;
@ -697,12 +703,16 @@ var replaceStyles = (node, _, config) => {
newTreeBottom.appendChild(el);
}
newTreeBottom = el;
node.style.setProperty(attr, css);
node.style.removeProperty(attr);
}
}
if (newTreeTop && newTreeBottom) {
newTreeBottom.appendChild(empty(node));
if (node.style.cssText) {
node.appendChild(newTreeTop);
} else {
replaceWith(node, newTreeTop);
}
}
return newTreeBottom || node;
};
@ -1704,12 +1714,22 @@ var Backspace = (self, event, range) => {
self.setSelection(range);
self._updatePath(range, true);
}
} else {
moveRangeBoundariesDownTree(range);
const text = range.startContainer;
const offset = range.startOffset;
const a = text.parentNode;
if (text instanceof Text && a instanceof HTMLAnchorElement && offset && a.href.includes(text.data)) {
text.deleteData(offset - 1, 1);
self.setSelection(range);
self.removeLink();
} else {
self.setSelection(range);
setTimeout(() => {
afterDelete(self);
}, 0);
}
}
};
// source/keyboard/Delete.ts
@ -2436,12 +2456,17 @@ var Squire = class {
} else {
const selection = window.getSelection();
if (selection) {
if ("setBaseAndExtent" in Selection.prototype) {
selection.setBaseAndExtent(
range.startContainer,
range.startOffset,
range.endContainer,
range.endOffset
);
} else {
selection.removeAllRanges();
selection.addRange(range);
}
}
}
return this;

18
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

18
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

View file

@ -1,6 +1,6 @@
{
"name": "squire-rte",
"version": "2.0.0",
"version": "2.0.1",
"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",