mirror of
https://github.com/siyuan-note/siyuan.git
synced 2026-03-04 03:40:15 +01:00
This commit is contained in:
parent
c88f99646c
commit
508eb93183
33 changed files with 111 additions and 108 deletions
|
|
@ -139,7 +139,7 @@ export const getEditorRange = (element: Element): Range => {
|
|||
let range: Range;
|
||||
if (getSelection().rangeCount > 0) {
|
||||
range = getSelection().getRangeAt(0);
|
||||
if ((element === range.startContainer) || element.contains(range.startContainer)) {
|
||||
if (element === range.startContainer || element.contains(range.startContainer)) {
|
||||
// 有时候点击编辑器头部需要矫正到第一个块中
|
||||
if (range.toString() === "" && range.startContainer.nodeType === 1 && range.startOffset === 0 &&
|
||||
(range.startContainer as HTMLElement).classList.contains("protyle-wysiwyg")) {
|
||||
|
|
@ -528,7 +528,7 @@ export const focusByWbr = (element: Element, range: Range) => {
|
|||
}
|
||||
} else {
|
||||
const wbrPreviousSibling = hasPreviousSibling(wbrElement);
|
||||
if (wbrPreviousSibling && (wbrElement.previousElementSibling === wbrPreviousSibling)) {
|
||||
if (wbrPreviousSibling && wbrElement.previousElementSibling === wbrPreviousSibling) {
|
||||
if (wbrElement.previousElementSibling.lastChild?.nodeType === 3) {
|
||||
// <em>text</em><wbr> 需把光标放在里面,因为 chrome 点击后也是默认在里面
|
||||
range.setStart(wbrElement.previousElementSibling.lastChild, wbrElement.previousElementSibling.lastChild.textContent.length);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue