mirror of
https://github.com/toeverything/AFFiNE.git
synced 2026-07-26 14:58:55 +08:00
feat: Double-link: In-line cursor handling, e.g., up, down, left,right, backspace keys
This commit is contained in:
@@ -503,7 +503,7 @@ Editor.after = function (
|
||||
return target;
|
||||
};
|
||||
|
||||
type SelectionStartAndEnd = {
|
||||
export type SelectionStartAndEnd = {
|
||||
selectionStart: Point;
|
||||
selectionEnd: Point;
|
||||
};
|
||||
@@ -517,6 +517,10 @@ export type Contents = {
|
||||
content: Descendant[];
|
||||
isEmpty: boolean;
|
||||
};
|
||||
contentSelection: {
|
||||
content: Descendant[];
|
||||
isEmpty: boolean;
|
||||
};
|
||||
};
|
||||
|
||||
class SlateUtils {
|
||||
@@ -572,6 +576,7 @@ class SlateUtils {
|
||||
anchor: point1,
|
||||
focus: point2,
|
||||
});
|
||||
|
||||
if (!fragment.length) {
|
||||
console.error('Debug information:', point1, point2, fragment);
|
||||
throw new Error('Failed to get content between!');
|
||||
@@ -602,7 +607,7 @@ class SlateUtils {
|
||||
for (let i = 0; i < fragmentChildren.length; i++) {
|
||||
const child = fragmentChildren[i];
|
||||
if ('type' in child && child.type === 'link') {
|
||||
i !== fragmentChildren.length - 1 && textChildren.push(child);
|
||||
textChildren.push(child);
|
||||
continue;
|
||||
}
|
||||
if (!('text' in child)) {
|
||||
@@ -638,6 +643,10 @@ class SlateUtils {
|
||||
content: this.getContentBetween(selectionEnd, end),
|
||||
isEmpty: Point.equals(end, selectionEnd),
|
||||
},
|
||||
contentSelection: {
|
||||
content: this.getContentBetween(selectionStart, selectionEnd),
|
||||
isEmpty: false,
|
||||
},
|
||||
} as Contents;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user