mirror of
https://github.com/DanielnetoDotCom/YouPHPTube
synced 2025-10-04 02:09:22 +02:00
add p2p support for HLS https://github.com/Novage/p2p-media-loader
This commit is contained in:
parent
64c36d9f4e
commit
0d0338876d
1197 changed files with 121461 additions and 179724 deletions
2
node_modules/@codemirror/commands/.github/workflows/dispatch.yml
generated
vendored
2
node_modules/@codemirror/commands/.github/workflows/dispatch.yml
generated
vendored
|
@ -11,6 +11,6 @@ jobs:
|
|||
with:
|
||||
# You should create a personal access token and store it in your repository
|
||||
token: ${{ secrets.DISPATCH_AUTH }}
|
||||
repo: codemirror.next
|
||||
repo: dev
|
||||
owner: codemirror
|
||||
event_type: push
|
||||
|
|
44
node_modules/@codemirror/commands/CHANGELOG.md
generated
vendored
44
node_modules/@codemirror/commands/CHANGELOG.md
generated
vendored
|
@ -1,3 +1,47 @@
|
|||
## 6.2.0 (2023-01-18)
|
||||
|
||||
### New features
|
||||
|
||||
The new `joinToEvent` history configuration option allows you to provide custom logic that determines whether a new transaction is added to an existing history event.
|
||||
|
||||
## 6.1.3 (2022-12-26)
|
||||
|
||||
### Bug fixes
|
||||
|
||||
Preserve selection bidi level when extending the selection, to prevent shift-selection from getting stuck in some kinds of bidirectional text.
|
||||
|
||||
## 6.1.2 (2022-10-13)
|
||||
|
||||
### Bug fixes
|
||||
|
||||
Fix a bug that caused deletion commands on non-empty ranges to incorrectly return false and do nothing, causing the editor to fall back to native behavior.
|
||||
|
||||
## 6.1.1 (2022-09-28)
|
||||
|
||||
### Bug fixes
|
||||
|
||||
Make sure the selection endpoints are moved out of atomic ranges when applying a deletion command to a non-empty selection.
|
||||
|
||||
## 6.1.0 (2022-08-18)
|
||||
|
||||
### Bug fixes
|
||||
|
||||
Prevent native behavior on Ctrl/Cmd-ArrowLeft/ArrowRight bindings, so that browsers with odd bidi behavior won't do the wrong thing at start/end of line.
|
||||
|
||||
Cmd-ArrowLeft/Right on macOS now moves the cursor in the direction of the arrow even in right-to-left content.
|
||||
|
||||
### New features
|
||||
|
||||
The new `cursorLineBoundaryLeft`/`Right` and `selectLineBoundaryLeft`/`Right` commands allow directional motion to line boundaries.
|
||||
|
||||
## 6.0.1 (2022-06-30)
|
||||
|
||||
### Bug fixes
|
||||
|
||||
Announce to the screen reader when the selection is deleted.
|
||||
|
||||
Also bind Ctrl-Shift-z to redo on Linux.
|
||||
|
||||
## 6.0.0 (2022-06-08)
|
||||
|
||||
### Bug fixes
|
||||
|
|
10
node_modules/@codemirror/commands/README.md
generated
vendored
10
node_modules/@codemirror/commands/README.md
generated
vendored
|
@ -1,13 +1,13 @@
|
|||
# @codemirror/commands [](https://www.npmjs.org/package/@codemirror/commands)
|
||||
|
||||
[ [**WEBSITE**](https://codemirror.net/6/) | [**DOCS**](https://codemirror.net/6/docs/ref/#commands) | [**ISSUES**](https://github.com/codemirror/codemirror.next/issues) | [**FORUM**](https://discuss.codemirror.net/c/next/) | [**CHANGELOG**](https://github.com/codemirror/commands/blob/main/CHANGELOG.md) ]
|
||||
[ [**WEBSITE**](https://codemirror.net/) | [**DOCS**](https://codemirror.net/docs/ref/#commands) | [**ISSUES**](https://github.com/codemirror/dev/issues) | [**FORUM**](https://discuss.codemirror.net/c/next/) | [**CHANGELOG**](https://github.com/codemirror/commands/blob/main/CHANGELOG.md) ]
|
||||
|
||||
This package implements a collection of editing commands for the
|
||||
[CodeMirror](https://codemirror.net/6/) code editor.
|
||||
[CodeMirror](https://codemirror.net/) code editor.
|
||||
|
||||
The [project page](https://codemirror.net/6/) has more information, a
|
||||
number of [examples](https://codemirror.net/6/examples/) and the
|
||||
[documentation](https://codemirror.net/6/docs/).
|
||||
The [project page](https://codemirror.net/) has more information, a
|
||||
number of [examples](https://codemirror.net/examples/) and the
|
||||
[documentation](https://codemirror.net/docs/).
|
||||
|
||||
This code is released under an
|
||||
[MIT license](https://github.com/codemirror/commands/tree/main/LICENSE).
|
||||
|
|
137
node_modules/@codemirror/commands/dist/index.cjs
generated
vendored
137
node_modules/@codemirror/commands/dist/index.cjs
generated
vendored
|
@ -32,35 +32,35 @@ The line comment syntax is taken from the
|
|||
[`commentTokens`](https://codemirror.net/6/docs/ref/#commands.CommentTokens) [language
|
||||
data](https://codemirror.net/6/docs/ref/#state.EditorState.languageDataAt).
|
||||
*/
|
||||
const toggleLineComment = command(changeLineComment, 0 /* Toggle */);
|
||||
const toggleLineComment = command(changeLineComment, 0 /* CommentOption.Toggle */);
|
||||
/**
|
||||
Comment the current selection using line comments.
|
||||
*/
|
||||
const lineComment = command(changeLineComment, 1 /* Comment */);
|
||||
const lineComment = command(changeLineComment, 1 /* CommentOption.Comment */);
|
||||
/**
|
||||
Uncomment the current selection using line comments.
|
||||
*/
|
||||
const lineUncomment = command(changeLineComment, 2 /* Uncomment */);
|
||||
const lineUncomment = command(changeLineComment, 2 /* CommentOption.Uncomment */);
|
||||
/**
|
||||
Comment or uncomment the current selection using block comments.
|
||||
The block comment syntax is taken from the
|
||||
[`commentTokens`](https://codemirror.net/6/docs/ref/#commands.CommentTokens) [language
|
||||
data](https://codemirror.net/6/docs/ref/#state.EditorState.languageDataAt).
|
||||
*/
|
||||
const toggleBlockComment = command(changeBlockComment, 0 /* Toggle */);
|
||||
const toggleBlockComment = command(changeBlockComment, 0 /* CommentOption.Toggle */);
|
||||
/**
|
||||
Comment the current selection using block comments.
|
||||
*/
|
||||
const blockComment = command(changeBlockComment, 1 /* Comment */);
|
||||
const blockComment = command(changeBlockComment, 1 /* CommentOption.Comment */);
|
||||
/**
|
||||
Uncomment the current selection using block comments.
|
||||
*/
|
||||
const blockUncomment = command(changeBlockComment, 2 /* Uncomment */);
|
||||
const blockUncomment = command(changeBlockComment, 2 /* CommentOption.Uncomment */);
|
||||
/**
|
||||
Comment or uncomment the lines around the current selection using
|
||||
block comments.
|
||||
*/
|
||||
const toggleBlockCommentByLine = command((o, s) => changeBlockComment(o, s, selectedLineRanges(s)), 0 /* Toggle */);
|
||||
const toggleBlockCommentByLine = command((o, s) => changeBlockComment(o, s, selectedLineRanges(s)), 0 /* CommentOption.Toggle */);
|
||||
function getConfig(state, pos = state.selection.main.head) {
|
||||
let data = state.languageDataAt("commentTokens", pos);
|
||||
return data.length ? data[0] : {};
|
||||
|
@ -119,14 +119,14 @@ function changeBlockComment(option, state, ranges = state.selection.ranges) {
|
|||
if (!tokens.every(c => c))
|
||||
return null;
|
||||
let comments = ranges.map((r, i) => findBlockComment(state, tokens[i], r.from, r.to));
|
||||
if (option != 2 /* Uncomment */ && !comments.every(c => c)) {
|
||||
if (option != 2 /* CommentOption.Uncomment */ && !comments.every(c => c)) {
|
||||
return { changes: state.changes(ranges.map((range, i) => {
|
||||
if (comments[i])
|
||||
return [];
|
||||
return [{ from: range.from, insert: tokens[i].open + " " }, { from: range.to, insert: " " + tokens[i].close }];
|
||||
})) };
|
||||
}
|
||||
else if (option != 1 /* Comment */ && comments.some(c => c)) {
|
||||
else if (option != 1 /* CommentOption.Comment */ && comments.some(c => c)) {
|
||||
let changes = [];
|
||||
for (let i = 0, comment; i < comments.length; i++)
|
||||
if (comment = comments[i]) {
|
||||
|
@ -166,7 +166,7 @@ function changeLineComment(option, state, ranges = state.selection.ranges) {
|
|||
if (lines.length == startI + 1)
|
||||
lines[startI].single = true;
|
||||
}
|
||||
if (option != 2 /* Uncomment */ && lines.some(l => l.comment < 0 && (!l.empty || l.single))) {
|
||||
if (option != 2 /* CommentOption.Uncomment */ && lines.some(l => l.comment < 0 && (!l.empty || l.single))) {
|
||||
let changes = [];
|
||||
for (let { line, token, indent, empty, single } of lines)
|
||||
if (single || !empty)
|
||||
|
@ -174,7 +174,7 @@ function changeLineComment(option, state, ranges = state.selection.ranges) {
|
|||
let changeSet = state.changes(changes);
|
||||
return { changes: changeSet, selection: state.selection.map(changeSet, 1) };
|
||||
}
|
||||
else if (option != 1 /* Comment */ && lines.some(l => l.comment >= 0)) {
|
||||
else if (option != 1 /* CommentOption.Comment */ && lines.some(l => l.comment >= 0)) {
|
||||
let changes = [];
|
||||
for (let { line, comment, token } of lines)
|
||||
if (comment >= 0) {
|
||||
|
@ -209,8 +209,13 @@ const historyConfig = state.Facet.define({
|
|||
combine(configs) {
|
||||
return state.combineConfig(configs, {
|
||||
minDepth: 100,
|
||||
newGroupDelay: 500
|
||||
}, { minDepth: Math.max, newGroupDelay: Math.min });
|
||||
newGroupDelay: 500,
|
||||
joinToEvent: (_t, isAdjacent) => isAdjacent,
|
||||
}, {
|
||||
minDepth: Math.max,
|
||||
newGroupDelay: Math.min,
|
||||
joinToEvent: (a, b) => (tr, adj) => a(tr, adj) || b(tr, adj)
|
||||
});
|
||||
}
|
||||
});
|
||||
function changeEnd(changes) {
|
||||
|
@ -228,12 +233,12 @@ const historyField_ = state.StateField.define({
|
|||
if (fromHist) {
|
||||
let selection = tr.docChanged ? state.EditorSelection.single(changeEnd(tr.changes)) : undefined;
|
||||
let item = HistEvent.fromTransaction(tr, selection), from = fromHist.side;
|
||||
let other = from == 0 /* Done */ ? state$1.undone : state$1.done;
|
||||
let other = from == 0 /* BranchName.Done */ ? state$1.undone : state$1.done;
|
||||
if (item)
|
||||
other = updateBranch(other, other.length, config.minDepth, item);
|
||||
else
|
||||
other = addSelection(other, tr.startState.selection);
|
||||
return new HistoryState(from == 0 /* Done */ ? fromHist.rest : other, from == 0 /* Done */ ? other : fromHist.rest);
|
||||
return new HistoryState(from == 0 /* BranchName.Done */ ? fromHist.rest : other, from == 0 /* BranchName.Done */ ? other : fromHist.rest);
|
||||
}
|
||||
let isolate = tr.annotation(isolateHistory);
|
||||
if (isolate == "full" || isolate == "before")
|
||||
|
@ -243,7 +248,7 @@ const historyField_ = state.StateField.define({
|
|||
let event = HistEvent.fromTransaction(tr);
|
||||
let time = tr.annotation(state.Transaction.time), userEvent = tr.annotation(state.Transaction.userEvent);
|
||||
if (event)
|
||||
state$1 = state$1.addChanges(event, time, userEvent, config.newGroupDelay, config.minDepth);
|
||||
state$1 = state$1.addChanges(event, time, userEvent, config, tr);
|
||||
else if (tr.selection)
|
||||
state$1 = state$1.addSelection(tr.startState.selection, time, userEvent, config.newGroupDelay);
|
||||
if (isolate == "full" || isolate == "after")
|
||||
|
@ -301,37 +306,37 @@ function cmd(side, selection) {
|
|||
Undo a single group of history events. Returns false if no group
|
||||
was available.
|
||||
*/
|
||||
const undo = cmd(0 /* Done */, false);
|
||||
const undo = cmd(0 /* BranchName.Done */, false);
|
||||
/**
|
||||
Redo a group of history events. Returns false if no group was
|
||||
available.
|
||||
*/
|
||||
const redo = cmd(1 /* Undone */, false);
|
||||
const redo = cmd(1 /* BranchName.Undone */, false);
|
||||
/**
|
||||
Undo a change or selection change.
|
||||
*/
|
||||
const undoSelection = cmd(0 /* Done */, true);
|
||||
const undoSelection = cmd(0 /* BranchName.Done */, true);
|
||||
/**
|
||||
Redo a change or selection change.
|
||||
*/
|
||||
const redoSelection = cmd(1 /* Undone */, true);
|
||||
const redoSelection = cmd(1 /* BranchName.Undone */, true);
|
||||
function depth(side) {
|
||||
return function (state) {
|
||||
let histState = state.field(historyField_, false);
|
||||
if (!histState)
|
||||
return 0;
|
||||
let branch = side == 0 /* Done */ ? histState.done : histState.undone;
|
||||
let branch = side == 0 /* BranchName.Done */ ? histState.done : histState.undone;
|
||||
return branch.length - (branch.length && !branch[0].changes ? 1 : 0);
|
||||
};
|
||||
}
|
||||
/**
|
||||
The amount of undoable change events available in a given state.
|
||||
*/
|
||||
const undoDepth = depth(0 /* Done */);
|
||||
const undoDepth = depth(0 /* BranchName.Done */);
|
||||
/**
|
||||
The amount of redoable change events available in a given state.
|
||||
*/
|
||||
const redoDepth = depth(1 /* Undone */);
|
||||
const redoDepth = depth(1 /* BranchName.Undone */);
|
||||
// History events store groups of changes or effects that need to be
|
||||
// undone/redone together.
|
||||
class HistEvent {
|
||||
|
@ -343,7 +348,10 @@ class HistEvent {
|
|||
// changes == startSelection == undefined
|
||||
changes,
|
||||
// The effects associated with this event
|
||||
effects, mapped,
|
||||
effects,
|
||||
// Accumulated mapping (from addToHistory==false) that should be
|
||||
// applied to events below this one.
|
||||
mapped,
|
||||
// The selection before this event
|
||||
startSelection,
|
||||
// Stores selection changes after this event, to be used for
|
||||
|
@ -477,19 +485,19 @@ class HistoryState {
|
|||
isolate() {
|
||||
return this.prevTime ? new HistoryState(this.done, this.undone) : this;
|
||||
}
|
||||
addChanges(event, time, userEvent, newGroupDelay, maxLen) {
|
||||
addChanges(event, time, userEvent, config, tr) {
|
||||
let done = this.done, lastEvent = done[done.length - 1];
|
||||
if (lastEvent && lastEvent.changes && !lastEvent.changes.empty && event.changes &&
|
||||
(!userEvent || joinableUserEvent.test(userEvent)) &&
|
||||
((!lastEvent.selectionsAfter.length &&
|
||||
time - this.prevTime < newGroupDelay &&
|
||||
isAdjacent(lastEvent.changes, event.changes)) ||
|
||||
time - this.prevTime < config.newGroupDelay &&
|
||||
config.joinToEvent(tr, isAdjacent(lastEvent.changes, event.changes))) ||
|
||||
// For compose (but not compose.start) events, always join with previous event
|
||||
userEvent == "input.type.compose")) {
|
||||
done = updateBranch(done, done.length - 1, maxLen, new HistEvent(event.changes.compose(lastEvent.changes), conc(event.effects, lastEvent.effects), lastEvent.mapped, lastEvent.startSelection, none));
|
||||
done = updateBranch(done, done.length - 1, config.minDepth, new HistEvent(event.changes.compose(lastEvent.changes), conc(event.effects, lastEvent.effects), lastEvent.mapped, lastEvent.startSelection, none));
|
||||
}
|
||||
else {
|
||||
done = updateBranch(done, done.length, maxLen, event);
|
||||
done = updateBranch(done, done.length, config.minDepth, event);
|
||||
}
|
||||
return new HistoryState(done, none, time, userEvent);
|
||||
}
|
||||
|
@ -506,7 +514,7 @@ class HistoryState {
|
|||
return new HistoryState(addMappingToBranch(this.done, mapping), addMappingToBranch(this.undone, mapping), this.prevTime, this.prevUserEvent);
|
||||
}
|
||||
pop(side, state, selection) {
|
||||
let branch = side == 0 /* Done */ ? this.done : this.undone;
|
||||
let branch = side == 0 /* BranchName.Done */ ? this.done : this.undone;
|
||||
if (branch.length == 0)
|
||||
return null;
|
||||
let event = branch[branch.length - 1];
|
||||
|
@ -514,7 +522,7 @@ class HistoryState {
|
|||
return state.update({
|
||||
selection: event.selectionsAfter[event.selectionsAfter.length - 1],
|
||||
annotations: fromHistory.of({ side, rest: popSelection(branch) }),
|
||||
userEvent: side == 0 /* Done */ ? "select.undo" : "select.redo",
|
||||
userEvent: side == 0 /* BranchName.Done */ ? "select.undo" : "select.redo",
|
||||
scrollIntoView: true
|
||||
});
|
||||
}
|
||||
|
@ -531,7 +539,7 @@ class HistoryState {
|
|||
effects: event.effects,
|
||||
annotations: fromHistory.of({ side, rest }),
|
||||
filter: false,
|
||||
userEvent: side == 0 /* Done */ ? "undo" : "redo",
|
||||
userEvent: side == 0 /* BranchName.Done */ ? "undo" : "redo",
|
||||
scrollIntoView: true
|
||||
});
|
||||
}
|
||||
|
@ -542,13 +550,14 @@ HistoryState.empty = new HistoryState(none, none);
|
|||
Default key bindings for the undo history.
|
||||
|
||||
- Mod-z: [`undo`](https://codemirror.net/6/docs/ref/#commands.undo).
|
||||
- Mod-y (Mod-Shift-z on macOS): [`redo`](https://codemirror.net/6/docs/ref/#commands.redo).
|
||||
- Mod-y (Mod-Shift-z on macOS) + Ctrl-Shift-z on Linux: [`redo`](https://codemirror.net/6/docs/ref/#commands.redo).
|
||||
- Mod-u: [`undoSelection`](https://codemirror.net/6/docs/ref/#commands.undoSelection).
|
||||
- Alt-u (Mod-Shift-u on macOS): [`redoSelection`](https://codemirror.net/6/docs/ref/#commands.redoSelection).
|
||||
*/
|
||||
const historyKeymap = [
|
||||
{ key: "Mod-z", run: undo, preventDefault: true },
|
||||
{ key: "Mod-y", mac: "Mod-Shift-z", run: redo, preventDefault: true },
|
||||
{ linux: "Ctrl-Shift-z", run: redo, preventDefault: true },
|
||||
{ key: "Mod-u", run: undoSelection, preventDefault: true },
|
||||
{ key: "Alt-u", mac: "Mod-Shift-u", run: redoSelection, preventDefault: true }
|
||||
];
|
||||
|
@ -762,6 +771,14 @@ end of the indentation instead of the start of the line.
|
|||
*/
|
||||
const cursorLineBoundaryBackward = view => moveSel(view, range => moveByLineBoundary(view, range, false));
|
||||
/**
|
||||
Move the selection one line wrap point to the left.
|
||||
*/
|
||||
const cursorLineBoundaryLeft = view => moveSel(view, range => moveByLineBoundary(view, range, !ltrAtCursor(view)));
|
||||
/**
|
||||
Move the selection one line wrap point to the right.
|
||||
*/
|
||||
const cursorLineBoundaryRight = view => moveSel(view, range => moveByLineBoundary(view, range, ltrAtCursor(view)));
|
||||
/**
|
||||
Move the selection to the start of the line.
|
||||
*/
|
||||
const cursorLineStart = view => moveSel(view, range => state.EditorSelection.cursor(view.lineBlockAt(range.head).from, 1));
|
||||
|
@ -799,7 +816,7 @@ const selectMatchingBracket = ({ state, dispatch }) => toMatchingBracket(state,
|
|||
function extendSel(view, how) {
|
||||
let selection = updateSel(view.state.selection, range => {
|
||||
let head = how(range);
|
||||
return state.EditorSelection.range(range.anchor, head.head, head.goalColumn);
|
||||
return state.EditorSelection.range(range.anchor, head.head, head.goalColumn, head.bidiLevel || undefined);
|
||||
});
|
||||
if (selection.eq(view.state.selection))
|
||||
return false;
|
||||
|
@ -896,6 +913,14 @@ Move the selection head to the previous line boundary.
|
|||
*/
|
||||
const selectLineBoundaryBackward = view => extendSel(view, range => moveByLineBoundary(view, range, false));
|
||||
/**
|
||||
Move the selection head one line boundary to the left.
|
||||
*/
|
||||
const selectLineBoundaryLeft = view => extendSel(view, range => moveByLineBoundary(view, range, !ltrAtCursor(view)));
|
||||
/**
|
||||
Move the selection head one line boundary to the right.
|
||||
*/
|
||||
const selectLineBoundaryRight = view => extendSel(view, range => moveByLineBoundary(view, range, ltrAtCursor(view)));
|
||||
/**
|
||||
Move the selection head to the start of the line.
|
||||
*/
|
||||
const selectLineStart = view => extendSel(view, range => state.EditorSelection.cursor(view.lineBlockAt(range.head).from));
|
||||
|
@ -981,26 +1006,38 @@ const simplifySelection = ({ state: state$1, dispatch }) => {
|
|||
dispatch(setSel(state$1, selection));
|
||||
return true;
|
||||
};
|
||||
function deleteBy({ state: state$1, dispatch }, by) {
|
||||
if (state$1.readOnly)
|
||||
function deleteBy(target, by) {
|
||||
if (target.state.readOnly)
|
||||
return false;
|
||||
let event = "delete.selection";
|
||||
let event = "delete.selection", { state: state$1 } = target;
|
||||
let changes = state$1.changeByRange(range => {
|
||||
let { from, to } = range;
|
||||
if (from == to) {
|
||||
let towards = by(from);
|
||||
if (towards < from)
|
||||
if (towards < from) {
|
||||
event = "delete.backward";
|
||||
else if (towards > from)
|
||||
towards = skipAtomic(target, towards, false);
|
||||
}
|
||||
else if (towards > from) {
|
||||
event = "delete.forward";
|
||||
towards = skipAtomic(target, towards, true);
|
||||
}
|
||||
from = Math.min(from, towards);
|
||||
to = Math.max(to, towards);
|
||||
}
|
||||
else {
|
||||
from = skipAtomic(target, from, false);
|
||||
to = skipAtomic(target, to, true);
|
||||
}
|
||||
return from == to ? { range } : { changes: { from, to }, range: state.EditorSelection.cursor(from) };
|
||||
});
|
||||
if (changes.changes.empty)
|
||||
return false;
|
||||
dispatch(state$1.update(changes, { scrollIntoView: true, userEvent: event }));
|
||||
target.dispatch(state$1.update(changes, {
|
||||
scrollIntoView: true,
|
||||
userEvent: event,
|
||||
effects: event == "delete.selection" ? view.EditorView.announce.of(state$1.phrase("Selection deleted")) : undefined
|
||||
}));
|
||||
return true;
|
||||
}
|
||||
function skipAtomic(target, pos, forward) {
|
||||
|
@ -1028,7 +1065,7 @@ const deleteByChar = (target, forward) => deleteBy(target, pos => {
|
|||
if (targetPos == pos && line.number != (forward ? state$1.doc.lines : 1))
|
||||
targetPos += forward ? 1 : -1;
|
||||
}
|
||||
return skipAtomic(target, targetPos, forward);
|
||||
return targetPos;
|
||||
});
|
||||
/**
|
||||
Delete the selection, or, for cursor selections, the character
|
||||
|
@ -1057,7 +1094,7 @@ const deleteByGroup = (target, forward) => deleteBy(target, start => {
|
|||
cat = nextCat;
|
||||
pos = next;
|
||||
}
|
||||
return skipAtomic(target, pos, forward);
|
||||
return pos;
|
||||
});
|
||||
/**
|
||||
Delete the selection or backward until the end of the next
|
||||
|
@ -1076,7 +1113,7 @@ line, delete the line break after it.
|
|||
*/
|
||||
const deleteToLineEnd = view => deleteBy(view, pos => {
|
||||
let lineEnd = view.lineBlockAt(pos).to;
|
||||
return skipAtomic(view, pos < lineEnd ? lineEnd : Math.min(view.state.doc.length, pos + 1), true);
|
||||
return pos < lineEnd ? lineEnd : Math.min(view.state.doc.length, pos + 1);
|
||||
});
|
||||
/**
|
||||
Delete the selection, or, if it is a cursor selection, delete to
|
||||
|
@ -1085,7 +1122,7 @@ line, delete the line break before it.
|
|||
*/
|
||||
const deleteToLineStart = view => deleteBy(view, pos => {
|
||||
let lineStart = view.lineBlockAt(pos).from;
|
||||
return skipAtomic(view, pos > lineStart ? lineStart : Math.max(0, pos - 1), false);
|
||||
return pos > lineStart ? lineStart : Math.max(0, pos - 1);
|
||||
});
|
||||
/**
|
||||
Delete all whitespace directly before a line end from the
|
||||
|
@ -1460,11 +1497,11 @@ property changed to `mac`.)
|
|||
*/
|
||||
const standardKeymap = [
|
||||
{ key: "ArrowLeft", run: cursorCharLeft, shift: selectCharLeft, preventDefault: true },
|
||||
{ key: "Mod-ArrowLeft", mac: "Alt-ArrowLeft", run: cursorGroupLeft, shift: selectGroupLeft },
|
||||
{ mac: "Cmd-ArrowLeft", run: cursorLineBoundaryBackward, shift: selectLineBoundaryBackward },
|
||||
{ key: "Mod-ArrowLeft", mac: "Alt-ArrowLeft", run: cursorGroupLeft, shift: selectGroupLeft, preventDefault: true },
|
||||
{ mac: "Cmd-ArrowLeft", run: cursorLineBoundaryLeft, shift: selectLineBoundaryLeft, preventDefault: true },
|
||||
{ key: "ArrowRight", run: cursorCharRight, shift: selectCharRight, preventDefault: true },
|
||||
{ key: "Mod-ArrowRight", mac: "Alt-ArrowRight", run: cursorGroupRight, shift: selectGroupRight },
|
||||
{ mac: "Cmd-ArrowRight", run: cursorLineBoundaryForward, shift: selectLineBoundaryForward },
|
||||
{ key: "Mod-ArrowRight", mac: "Alt-ArrowRight", run: cursorGroupRight, shift: selectGroupRight, preventDefault: true },
|
||||
{ mac: "Cmd-ArrowRight", run: cursorLineBoundaryRight, shift: selectLineBoundaryRight, preventDefault: true },
|
||||
{ key: "ArrowUp", run: cursorLineUp, shift: selectLineUp, preventDefault: true },
|
||||
{ mac: "Cmd-ArrowUp", run: cursorDocStart, shift: selectDocStart },
|
||||
{ mac: "Ctrl-ArrowUp", run: cursorPageUp, shift: selectPageUp },
|
||||
|
@ -1551,6 +1588,8 @@ exports.cursorGroupLeft = cursorGroupLeft;
|
|||
exports.cursorGroupRight = cursorGroupRight;
|
||||
exports.cursorLineBoundaryBackward = cursorLineBoundaryBackward;
|
||||
exports.cursorLineBoundaryForward = cursorLineBoundaryForward;
|
||||
exports.cursorLineBoundaryLeft = cursorLineBoundaryLeft;
|
||||
exports.cursorLineBoundaryRight = cursorLineBoundaryRight;
|
||||
exports.cursorLineDown = cursorLineDown;
|
||||
exports.cursorLineEnd = cursorLineEnd;
|
||||
exports.cursorLineStart = cursorLineStart;
|
||||
|
@ -1606,6 +1645,8 @@ exports.selectGroupRight = selectGroupRight;
|
|||
exports.selectLine = selectLine;
|
||||
exports.selectLineBoundaryBackward = selectLineBoundaryBackward;
|
||||
exports.selectLineBoundaryForward = selectLineBoundaryForward;
|
||||
exports.selectLineBoundaryLeft = selectLineBoundaryLeft;
|
||||
exports.selectLineBoundaryRight = selectLineBoundaryRight;
|
||||
exports.selectLineDown = selectLineDown;
|
||||
exports.selectLineEnd = selectLineEnd;
|
||||
exports.selectLineStart = selectLineStart;
|
||||
|
|
27
node_modules/@codemirror/commands/dist/index.d.ts
generated
vendored
27
node_modules/@codemirror/commands/dist/index.d.ts
generated
vendored
|
@ -88,6 +88,13 @@ interface HistoryConfig {
|
|||
apart and still be grouped together. Defaults to 500.
|
||||
*/
|
||||
newGroupDelay?: number;
|
||||
/**
|
||||
By default, when close enough together in time, changes are
|
||||
joined into an existing undo event if they touch any of the
|
||||
changed ranges from that event. You can pass a custom predicate
|
||||
here to influence that logic.
|
||||
*/
|
||||
joinToEvent?: (tr: Transaction, isAdjacent: boolean) => boolean;
|
||||
}
|
||||
/**
|
||||
Create a history extension with the given configuration.
|
||||
|
@ -131,7 +138,7 @@ declare const redoDepth: (state: EditorState) => number;
|
|||
Default key bindings for the undo history.
|
||||
|
||||
- Mod-z: [`undo`](https://codemirror.net/6/docs/ref/#commands.undo).
|
||||
- Mod-y (Mod-Shift-z on macOS): [`redo`](https://codemirror.net/6/docs/ref/#commands.redo).
|
||||
- Mod-y (Mod-Shift-z on macOS) + Ctrl-Shift-z on Linux: [`redo`](https://codemirror.net/6/docs/ref/#commands.redo).
|
||||
- Mod-u: [`undoSelection`](https://codemirror.net/6/docs/ref/#commands.undoSelection).
|
||||
- Alt-u (Mod-Shift-u on macOS): [`redoSelection`](https://codemirror.net/6/docs/ref/#commands.redoSelection).
|
||||
*/
|
||||
|
@ -216,6 +223,14 @@ end of the indentation instead of the start of the line.
|
|||
*/
|
||||
declare const cursorLineBoundaryBackward: Command;
|
||||
/**
|
||||
Move the selection one line wrap point to the left.
|
||||
*/
|
||||
declare const cursorLineBoundaryLeft: Command;
|
||||
/**
|
||||
Move the selection one line wrap point to the right.
|
||||
*/
|
||||
declare const cursorLineBoundaryRight: Command;
|
||||
/**
|
||||
Move the selection to the start of the line.
|
||||
*/
|
||||
declare const cursorLineStart: Command;
|
||||
|
@ -308,6 +323,14 @@ Move the selection head to the previous line boundary.
|
|||
*/
|
||||
declare const selectLineBoundaryBackward: Command;
|
||||
/**
|
||||
Move the selection head one line boundary to the left.
|
||||
*/
|
||||
declare const selectLineBoundaryLeft: Command;
|
||||
/**
|
||||
Move the selection head one line boundary to the right.
|
||||
*/
|
||||
declare const selectLineBoundaryRight: Command;
|
||||
/**
|
||||
Move the selection head to the start of the line.
|
||||
*/
|
||||
declare const selectLineStart: Command;
|
||||
|
@ -540,4 +563,4 @@ this.
|
|||
*/
|
||||
declare const indentWithTab: KeyBinding;
|
||||
|
||||
export { CommentTokens, blockComment, blockUncomment, copyLineDown, copyLineUp, cursorCharBackward, cursorCharForward, cursorCharLeft, cursorCharRight, cursorDocEnd, cursorDocStart, cursorGroupBackward, cursorGroupForward, cursorGroupLeft, cursorGroupRight, cursorLineBoundaryBackward, cursorLineBoundaryForward, cursorLineDown, cursorLineEnd, cursorLineStart, cursorLineUp, cursorMatchingBracket, cursorPageDown, cursorPageUp, cursorSubwordBackward, cursorSubwordForward, cursorSyntaxLeft, cursorSyntaxRight, defaultKeymap, deleteCharBackward, deleteCharForward, deleteGroupBackward, deleteGroupForward, deleteLine, deleteToLineEnd, deleteToLineStart, deleteTrailingWhitespace, emacsStyleKeymap, history, historyField, historyKeymap, indentLess, indentMore, indentSelection, indentWithTab, insertBlankLine, insertNewline, insertNewlineAndIndent, insertTab, invertedEffects, isolateHistory, lineComment, lineUncomment, moveLineDown, moveLineUp, redo, redoDepth, redoSelection, selectAll, selectCharBackward, selectCharForward, selectCharLeft, selectCharRight, selectDocEnd, selectDocStart, selectGroupBackward, selectGroupForward, selectGroupLeft, selectGroupRight, selectLine, selectLineBoundaryBackward, selectLineBoundaryForward, selectLineDown, selectLineEnd, selectLineStart, selectLineUp, selectMatchingBracket, selectPageDown, selectPageUp, selectParentSyntax, selectSubwordBackward, selectSubwordForward, selectSyntaxLeft, selectSyntaxRight, simplifySelection, splitLine, standardKeymap, toggleBlockComment, toggleBlockCommentByLine, toggleComment, toggleLineComment, transposeChars, undo, undoDepth, undoSelection };
|
||||
export { CommentTokens, blockComment, blockUncomment, copyLineDown, copyLineUp, cursorCharBackward, cursorCharForward, cursorCharLeft, cursorCharRight, cursorDocEnd, cursorDocStart, cursorGroupBackward, cursorGroupForward, cursorGroupLeft, cursorGroupRight, cursorLineBoundaryBackward, cursorLineBoundaryForward, cursorLineBoundaryLeft, cursorLineBoundaryRight, cursorLineDown, cursorLineEnd, cursorLineStart, cursorLineUp, cursorMatchingBracket, cursorPageDown, cursorPageUp, cursorSubwordBackward, cursorSubwordForward, cursorSyntaxLeft, cursorSyntaxRight, defaultKeymap, deleteCharBackward, deleteCharForward, deleteGroupBackward, deleteGroupForward, deleteLine, deleteToLineEnd, deleteToLineStart, deleteTrailingWhitespace, emacsStyleKeymap, history, historyField, historyKeymap, indentLess, indentMore, indentSelection, indentWithTab, insertBlankLine, insertNewline, insertNewlineAndIndent, insertTab, invertedEffects, isolateHistory, lineComment, lineUncomment, moveLineDown, moveLineUp, redo, redoDepth, redoSelection, selectAll, selectCharBackward, selectCharForward, selectCharLeft, selectCharRight, selectDocEnd, selectDocStart, selectGroupBackward, selectGroupForward, selectGroupLeft, selectGroupRight, selectLine, selectLineBoundaryBackward, selectLineBoundaryForward, selectLineBoundaryLeft, selectLineBoundaryRight, selectLineDown, selectLineEnd, selectLineStart, selectLineUp, selectMatchingBracket, selectPageDown, selectPageUp, selectParentSyntax, selectSubwordBackward, selectSubwordForward, selectSyntaxLeft, selectSyntaxRight, simplifySelection, splitLine, standardKeymap, toggleBlockComment, toggleBlockCommentByLine, toggleComment, toggleLineComment, transposeChars, undo, undoDepth, undoSelection };
|
||||
|
|
137
node_modules/@codemirror/commands/dist/index.js
generated
vendored
137
node_modules/@codemirror/commands/dist/index.js
generated
vendored
|
@ -1,6 +1,6 @@
|
|||
import { Annotation, Facet, combineConfig, StateField, EditorSelection, Transaction, ChangeSet, ChangeDesc, StateEffect, Text, findClusterBreak, countColumn, CharCategory } from '@codemirror/state';
|
||||
import { EditorView, Direction } from '@codemirror/view';
|
||||
import { IndentContext, getIndentation, indentString, indentUnit, getIndentUnit, matchBrackets, syntaxTree } from '@codemirror/language';
|
||||
import { IndentContext, getIndentation, indentString, matchBrackets, syntaxTree, getIndentUnit, indentUnit } from '@codemirror/language';
|
||||
import { NodeProp } from '@lezer/common';
|
||||
|
||||
/**
|
||||
|
@ -28,35 +28,35 @@ The line comment syntax is taken from the
|
|||
[`commentTokens`](https://codemirror.net/6/docs/ref/#commands.CommentTokens) [language
|
||||
data](https://codemirror.net/6/docs/ref/#state.EditorState.languageDataAt).
|
||||
*/
|
||||
const toggleLineComment = /*@__PURE__*/command(changeLineComment, 0 /* Toggle */);
|
||||
const toggleLineComment = /*@__PURE__*/command(changeLineComment, 0 /* CommentOption.Toggle */);
|
||||
/**
|
||||
Comment the current selection using line comments.
|
||||
*/
|
||||
const lineComment = /*@__PURE__*/command(changeLineComment, 1 /* Comment */);
|
||||
const lineComment = /*@__PURE__*/command(changeLineComment, 1 /* CommentOption.Comment */);
|
||||
/**
|
||||
Uncomment the current selection using line comments.
|
||||
*/
|
||||
const lineUncomment = /*@__PURE__*/command(changeLineComment, 2 /* Uncomment */);
|
||||
const lineUncomment = /*@__PURE__*/command(changeLineComment, 2 /* CommentOption.Uncomment */);
|
||||
/**
|
||||
Comment or uncomment the current selection using block comments.
|
||||
The block comment syntax is taken from the
|
||||
[`commentTokens`](https://codemirror.net/6/docs/ref/#commands.CommentTokens) [language
|
||||
data](https://codemirror.net/6/docs/ref/#state.EditorState.languageDataAt).
|
||||
*/
|
||||
const toggleBlockComment = /*@__PURE__*/command(changeBlockComment, 0 /* Toggle */);
|
||||
const toggleBlockComment = /*@__PURE__*/command(changeBlockComment, 0 /* CommentOption.Toggle */);
|
||||
/**
|
||||
Comment the current selection using block comments.
|
||||
*/
|
||||
const blockComment = /*@__PURE__*/command(changeBlockComment, 1 /* Comment */);
|
||||
const blockComment = /*@__PURE__*/command(changeBlockComment, 1 /* CommentOption.Comment */);
|
||||
/**
|
||||
Uncomment the current selection using block comments.
|
||||
*/
|
||||
const blockUncomment = /*@__PURE__*/command(changeBlockComment, 2 /* Uncomment */);
|
||||
const blockUncomment = /*@__PURE__*/command(changeBlockComment, 2 /* CommentOption.Uncomment */);
|
||||
/**
|
||||
Comment or uncomment the lines around the current selection using
|
||||
block comments.
|
||||
*/
|
||||
const toggleBlockCommentByLine = /*@__PURE__*/command((o, s) => changeBlockComment(o, s, selectedLineRanges(s)), 0 /* Toggle */);
|
||||
const toggleBlockCommentByLine = /*@__PURE__*/command((o, s) => changeBlockComment(o, s, selectedLineRanges(s)), 0 /* CommentOption.Toggle */);
|
||||
function getConfig(state, pos = state.selection.main.head) {
|
||||
let data = state.languageDataAt("commentTokens", pos);
|
||||
return data.length ? data[0] : {};
|
||||
|
@ -115,14 +115,14 @@ function changeBlockComment(option, state, ranges = state.selection.ranges) {
|
|||
if (!tokens.every(c => c))
|
||||
return null;
|
||||
let comments = ranges.map((r, i) => findBlockComment(state, tokens[i], r.from, r.to));
|
||||
if (option != 2 /* Uncomment */ && !comments.every(c => c)) {
|
||||
if (option != 2 /* CommentOption.Uncomment */ && !comments.every(c => c)) {
|
||||
return { changes: state.changes(ranges.map((range, i) => {
|
||||
if (comments[i])
|
||||
return [];
|
||||
return [{ from: range.from, insert: tokens[i].open + " " }, { from: range.to, insert: " " + tokens[i].close }];
|
||||
})) };
|
||||
}
|
||||
else if (option != 1 /* Comment */ && comments.some(c => c)) {
|
||||
else if (option != 1 /* CommentOption.Comment */ && comments.some(c => c)) {
|
||||
let changes = [];
|
||||
for (let i = 0, comment; i < comments.length; i++)
|
||||
if (comment = comments[i]) {
|
||||
|
@ -162,7 +162,7 @@ function changeLineComment(option, state, ranges = state.selection.ranges) {
|
|||
if (lines.length == startI + 1)
|
||||
lines[startI].single = true;
|
||||
}
|
||||
if (option != 2 /* Uncomment */ && lines.some(l => l.comment < 0 && (!l.empty || l.single))) {
|
||||
if (option != 2 /* CommentOption.Uncomment */ && lines.some(l => l.comment < 0 && (!l.empty || l.single))) {
|
||||
let changes = [];
|
||||
for (let { line, token, indent, empty, single } of lines)
|
||||
if (single || !empty)
|
||||
|
@ -170,7 +170,7 @@ function changeLineComment(option, state, ranges = state.selection.ranges) {
|
|||
let changeSet = state.changes(changes);
|
||||
return { changes: changeSet, selection: state.selection.map(changeSet, 1) };
|
||||
}
|
||||
else if (option != 1 /* Comment */ && lines.some(l => l.comment >= 0)) {
|
||||
else if (option != 1 /* CommentOption.Comment */ && lines.some(l => l.comment >= 0)) {
|
||||
let changes = [];
|
||||
for (let { line, comment, token } of lines)
|
||||
if (comment >= 0) {
|
||||
|
@ -205,8 +205,13 @@ const historyConfig = /*@__PURE__*/Facet.define({
|
|||
combine(configs) {
|
||||
return combineConfig(configs, {
|
||||
minDepth: 100,
|
||||
newGroupDelay: 500
|
||||
}, { minDepth: Math.max, newGroupDelay: Math.min });
|
||||
newGroupDelay: 500,
|
||||
joinToEvent: (_t, isAdjacent) => isAdjacent,
|
||||
}, {
|
||||
minDepth: Math.max,
|
||||
newGroupDelay: Math.min,
|
||||
joinToEvent: (a, b) => (tr, adj) => a(tr, adj) || b(tr, adj)
|
||||
});
|
||||
}
|
||||
});
|
||||
function changeEnd(changes) {
|
||||
|
@ -224,12 +229,12 @@ const historyField_ = /*@__PURE__*/StateField.define({
|
|||
if (fromHist) {
|
||||
let selection = tr.docChanged ? EditorSelection.single(changeEnd(tr.changes)) : undefined;
|
||||
let item = HistEvent.fromTransaction(tr, selection), from = fromHist.side;
|
||||
let other = from == 0 /* Done */ ? state.undone : state.done;
|
||||
let other = from == 0 /* BranchName.Done */ ? state.undone : state.done;
|
||||
if (item)
|
||||
other = updateBranch(other, other.length, config.minDepth, item);
|
||||
else
|
||||
other = addSelection(other, tr.startState.selection);
|
||||
return new HistoryState(from == 0 /* Done */ ? fromHist.rest : other, from == 0 /* Done */ ? other : fromHist.rest);
|
||||
return new HistoryState(from == 0 /* BranchName.Done */ ? fromHist.rest : other, from == 0 /* BranchName.Done */ ? other : fromHist.rest);
|
||||
}
|
||||
let isolate = tr.annotation(isolateHistory);
|
||||
if (isolate == "full" || isolate == "before")
|
||||
|
@ -239,7 +244,7 @@ const historyField_ = /*@__PURE__*/StateField.define({
|
|||
let event = HistEvent.fromTransaction(tr);
|
||||
let time = tr.annotation(Transaction.time), userEvent = tr.annotation(Transaction.userEvent);
|
||||
if (event)
|
||||
state = state.addChanges(event, time, userEvent, config.newGroupDelay, config.minDepth);
|
||||
state = state.addChanges(event, time, userEvent, config, tr);
|
||||
else if (tr.selection)
|
||||
state = state.addSelection(tr.startState.selection, time, userEvent, config.newGroupDelay);
|
||||
if (isolate == "full" || isolate == "after")
|
||||
|
@ -297,37 +302,37 @@ function cmd(side, selection) {
|
|||
Undo a single group of history events. Returns false if no group
|
||||
was available.
|
||||
*/
|
||||
const undo = /*@__PURE__*/cmd(0 /* Done */, false);
|
||||
const undo = /*@__PURE__*/cmd(0 /* BranchName.Done */, false);
|
||||
/**
|
||||
Redo a group of history events. Returns false if no group was
|
||||
available.
|
||||
*/
|
||||
const redo = /*@__PURE__*/cmd(1 /* Undone */, false);
|
||||
const redo = /*@__PURE__*/cmd(1 /* BranchName.Undone */, false);
|
||||
/**
|
||||
Undo a change or selection change.
|
||||
*/
|
||||
const undoSelection = /*@__PURE__*/cmd(0 /* Done */, true);
|
||||
const undoSelection = /*@__PURE__*/cmd(0 /* BranchName.Done */, true);
|
||||
/**
|
||||
Redo a change or selection change.
|
||||
*/
|
||||
const redoSelection = /*@__PURE__*/cmd(1 /* Undone */, true);
|
||||
const redoSelection = /*@__PURE__*/cmd(1 /* BranchName.Undone */, true);
|
||||
function depth(side) {
|
||||
return function (state) {
|
||||
let histState = state.field(historyField_, false);
|
||||
if (!histState)
|
||||
return 0;
|
||||
let branch = side == 0 /* Done */ ? histState.done : histState.undone;
|
||||
let branch = side == 0 /* BranchName.Done */ ? histState.done : histState.undone;
|
||||
return branch.length - (branch.length && !branch[0].changes ? 1 : 0);
|
||||
};
|
||||
}
|
||||
/**
|
||||
The amount of undoable change events available in a given state.
|
||||
*/
|
||||
const undoDepth = /*@__PURE__*/depth(0 /* Done */);
|
||||
const undoDepth = /*@__PURE__*/depth(0 /* BranchName.Done */);
|
||||
/**
|
||||
The amount of redoable change events available in a given state.
|
||||
*/
|
||||
const redoDepth = /*@__PURE__*/depth(1 /* Undone */);
|
||||
const redoDepth = /*@__PURE__*/depth(1 /* BranchName.Undone */);
|
||||
// History events store groups of changes or effects that need to be
|
||||
// undone/redone together.
|
||||
class HistEvent {
|
||||
|
@ -339,7 +344,10 @@ class HistEvent {
|
|||
// changes == startSelection == undefined
|
||||
changes,
|
||||
// The effects associated with this event
|
||||
effects, mapped,
|
||||
effects,
|
||||
// Accumulated mapping (from addToHistory==false) that should be
|
||||
// applied to events below this one.
|
||||
mapped,
|
||||
// The selection before this event
|
||||
startSelection,
|
||||
// Stores selection changes after this event, to be used for
|
||||
|
@ -473,19 +481,19 @@ class HistoryState {
|
|||
isolate() {
|
||||
return this.prevTime ? new HistoryState(this.done, this.undone) : this;
|
||||
}
|
||||
addChanges(event, time, userEvent, newGroupDelay, maxLen) {
|
||||
addChanges(event, time, userEvent, config, tr) {
|
||||
let done = this.done, lastEvent = done[done.length - 1];
|
||||
if (lastEvent && lastEvent.changes && !lastEvent.changes.empty && event.changes &&
|
||||
(!userEvent || joinableUserEvent.test(userEvent)) &&
|
||||
((!lastEvent.selectionsAfter.length &&
|
||||
time - this.prevTime < newGroupDelay &&
|
||||
isAdjacent(lastEvent.changes, event.changes)) ||
|
||||
time - this.prevTime < config.newGroupDelay &&
|
||||
config.joinToEvent(tr, isAdjacent(lastEvent.changes, event.changes))) ||
|
||||
// For compose (but not compose.start) events, always join with previous event
|
||||
userEvent == "input.type.compose")) {
|
||||
done = updateBranch(done, done.length - 1, maxLen, new HistEvent(event.changes.compose(lastEvent.changes), conc(event.effects, lastEvent.effects), lastEvent.mapped, lastEvent.startSelection, none));
|
||||
done = updateBranch(done, done.length - 1, config.minDepth, new HistEvent(event.changes.compose(lastEvent.changes), conc(event.effects, lastEvent.effects), lastEvent.mapped, lastEvent.startSelection, none));
|
||||
}
|
||||
else {
|
||||
done = updateBranch(done, done.length, maxLen, event);
|
||||
done = updateBranch(done, done.length, config.minDepth, event);
|
||||
}
|
||||
return new HistoryState(done, none, time, userEvent);
|
||||
}
|
||||
|
@ -502,7 +510,7 @@ class HistoryState {
|
|||
return new HistoryState(addMappingToBranch(this.done, mapping), addMappingToBranch(this.undone, mapping), this.prevTime, this.prevUserEvent);
|
||||
}
|
||||
pop(side, state, selection) {
|
||||
let branch = side == 0 /* Done */ ? this.done : this.undone;
|
||||
let branch = side == 0 /* BranchName.Done */ ? this.done : this.undone;
|
||||
if (branch.length == 0)
|
||||
return null;
|
||||
let event = branch[branch.length - 1];
|
||||
|
@ -510,7 +518,7 @@ class HistoryState {
|
|||
return state.update({
|
||||
selection: event.selectionsAfter[event.selectionsAfter.length - 1],
|
||||
annotations: fromHistory.of({ side, rest: popSelection(branch) }),
|
||||
userEvent: side == 0 /* Done */ ? "select.undo" : "select.redo",
|
||||
userEvent: side == 0 /* BranchName.Done */ ? "select.undo" : "select.redo",
|
||||
scrollIntoView: true
|
||||
});
|
||||
}
|
||||
|
@ -527,7 +535,7 @@ class HistoryState {
|
|||
effects: event.effects,
|
||||
annotations: fromHistory.of({ side, rest }),
|
||||
filter: false,
|
||||
userEvent: side == 0 /* Done */ ? "undo" : "redo",
|
||||
userEvent: side == 0 /* BranchName.Done */ ? "undo" : "redo",
|
||||
scrollIntoView: true
|
||||
});
|
||||
}
|
||||
|
@ -538,13 +546,14 @@ HistoryState.empty = /*@__PURE__*/new HistoryState(none, none);
|
|||
Default key bindings for the undo history.
|
||||
|
||||
- Mod-z: [`undo`](https://codemirror.net/6/docs/ref/#commands.undo).
|
||||
- Mod-y (Mod-Shift-z on macOS): [`redo`](https://codemirror.net/6/docs/ref/#commands.redo).
|
||||
- Mod-y (Mod-Shift-z on macOS) + Ctrl-Shift-z on Linux: [`redo`](https://codemirror.net/6/docs/ref/#commands.redo).
|
||||
- Mod-u: [`undoSelection`](https://codemirror.net/6/docs/ref/#commands.undoSelection).
|
||||
- Alt-u (Mod-Shift-u on macOS): [`redoSelection`](https://codemirror.net/6/docs/ref/#commands.redoSelection).
|
||||
*/
|
||||
const historyKeymap = [
|
||||
{ key: "Mod-z", run: undo, preventDefault: true },
|
||||
{ key: "Mod-y", mac: "Mod-Shift-z", run: redo, preventDefault: true },
|
||||
{ linux: "Ctrl-Shift-z", run: redo, preventDefault: true },
|
||||
{ key: "Mod-u", run: undoSelection, preventDefault: true },
|
||||
{ key: "Alt-u", mac: "Mod-Shift-u", run: redoSelection, preventDefault: true }
|
||||
];
|
||||
|
@ -758,6 +767,14 @@ end of the indentation instead of the start of the line.
|
|||
*/
|
||||
const cursorLineBoundaryBackward = view => moveSel(view, range => moveByLineBoundary(view, range, false));
|
||||
/**
|
||||
Move the selection one line wrap point to the left.
|
||||
*/
|
||||
const cursorLineBoundaryLeft = view => moveSel(view, range => moveByLineBoundary(view, range, !ltrAtCursor(view)));
|
||||
/**
|
||||
Move the selection one line wrap point to the right.
|
||||
*/
|
||||
const cursorLineBoundaryRight = view => moveSel(view, range => moveByLineBoundary(view, range, ltrAtCursor(view)));
|
||||
/**
|
||||
Move the selection to the start of the line.
|
||||
*/
|
||||
const cursorLineStart = view => moveSel(view, range => EditorSelection.cursor(view.lineBlockAt(range.head).from, 1));
|
||||
|
@ -795,7 +812,7 @@ const selectMatchingBracket = ({ state, dispatch }) => toMatchingBracket(state,
|
|||
function extendSel(view, how) {
|
||||
let selection = updateSel(view.state.selection, range => {
|
||||
let head = how(range);
|
||||
return EditorSelection.range(range.anchor, head.head, head.goalColumn);
|
||||
return EditorSelection.range(range.anchor, head.head, head.goalColumn, head.bidiLevel || undefined);
|
||||
});
|
||||
if (selection.eq(view.state.selection))
|
||||
return false;
|
||||
|
@ -892,6 +909,14 @@ Move the selection head to the previous line boundary.
|
|||
*/
|
||||
const selectLineBoundaryBackward = view => extendSel(view, range => moveByLineBoundary(view, range, false));
|
||||
/**
|
||||
Move the selection head one line boundary to the left.
|
||||
*/
|
||||
const selectLineBoundaryLeft = view => extendSel(view, range => moveByLineBoundary(view, range, !ltrAtCursor(view)));
|
||||
/**
|
||||
Move the selection head one line boundary to the right.
|
||||
*/
|
||||
const selectLineBoundaryRight = view => extendSel(view, range => moveByLineBoundary(view, range, ltrAtCursor(view)));
|
||||
/**
|
||||
Move the selection head to the start of the line.
|
||||
*/
|
||||
const selectLineStart = view => extendSel(view, range => EditorSelection.cursor(view.lineBlockAt(range.head).from));
|
||||
|
@ -977,26 +1002,38 @@ const simplifySelection = ({ state, dispatch }) => {
|
|||
dispatch(setSel(state, selection));
|
||||
return true;
|
||||
};
|
||||
function deleteBy({ state, dispatch }, by) {
|
||||
if (state.readOnly)
|
||||
function deleteBy(target, by) {
|
||||
if (target.state.readOnly)
|
||||
return false;
|
||||
let event = "delete.selection";
|
||||
let event = "delete.selection", { state } = target;
|
||||
let changes = state.changeByRange(range => {
|
||||
let { from, to } = range;
|
||||
if (from == to) {
|
||||
let towards = by(from);
|
||||
if (towards < from)
|
||||
if (towards < from) {
|
||||
event = "delete.backward";
|
||||
else if (towards > from)
|
||||
towards = skipAtomic(target, towards, false);
|
||||
}
|
||||
else if (towards > from) {
|
||||
event = "delete.forward";
|
||||
towards = skipAtomic(target, towards, true);
|
||||
}
|
||||
from = Math.min(from, towards);
|
||||
to = Math.max(to, towards);
|
||||
}
|
||||
else {
|
||||
from = skipAtomic(target, from, false);
|
||||
to = skipAtomic(target, to, true);
|
||||
}
|
||||
return from == to ? { range } : { changes: { from, to }, range: EditorSelection.cursor(from) };
|
||||
});
|
||||
if (changes.changes.empty)
|
||||
return false;
|
||||
dispatch(state.update(changes, { scrollIntoView: true, userEvent: event }));
|
||||
target.dispatch(state.update(changes, {
|
||||
scrollIntoView: true,
|
||||
userEvent: event,
|
||||
effects: event == "delete.selection" ? EditorView.announce.of(state.phrase("Selection deleted")) : undefined
|
||||
}));
|
||||
return true;
|
||||
}
|
||||
function skipAtomic(target, pos, forward) {
|
||||
|
@ -1024,7 +1061,7 @@ const deleteByChar = (target, forward) => deleteBy(target, pos => {
|
|||
if (targetPos == pos && line.number != (forward ? state.doc.lines : 1))
|
||||
targetPos += forward ? 1 : -1;
|
||||
}
|
||||
return skipAtomic(target, targetPos, forward);
|
||||
return targetPos;
|
||||
});
|
||||
/**
|
||||
Delete the selection, or, for cursor selections, the character
|
||||
|
@ -1053,7 +1090,7 @@ const deleteByGroup = (target, forward) => deleteBy(target, start => {
|
|||
cat = nextCat;
|
||||
pos = next;
|
||||
}
|
||||
return skipAtomic(target, pos, forward);
|
||||
return pos;
|
||||
});
|
||||
/**
|
||||
Delete the selection or backward until the end of the next
|
||||
|
@ -1072,7 +1109,7 @@ line, delete the line break after it.
|
|||
*/
|
||||
const deleteToLineEnd = view => deleteBy(view, pos => {
|
||||
let lineEnd = view.lineBlockAt(pos).to;
|
||||
return skipAtomic(view, pos < lineEnd ? lineEnd : Math.min(view.state.doc.length, pos + 1), true);
|
||||
return pos < lineEnd ? lineEnd : Math.min(view.state.doc.length, pos + 1);
|
||||
});
|
||||
/**
|
||||
Delete the selection, or, if it is a cursor selection, delete to
|
||||
|
@ -1081,7 +1118,7 @@ line, delete the line break before it.
|
|||
*/
|
||||
const deleteToLineStart = view => deleteBy(view, pos => {
|
||||
let lineStart = view.lineBlockAt(pos).from;
|
||||
return skipAtomic(view, pos > lineStart ? lineStart : Math.max(0, pos - 1), false);
|
||||
return pos > lineStart ? lineStart : Math.max(0, pos - 1);
|
||||
});
|
||||
/**
|
||||
Delete all whitespace directly before a line end from the
|
||||
|
@ -1456,11 +1493,11 @@ property changed to `mac`.)
|
|||
*/
|
||||
const standardKeymap = /*@__PURE__*/[
|
||||
{ key: "ArrowLeft", run: cursorCharLeft, shift: selectCharLeft, preventDefault: true },
|
||||
{ key: "Mod-ArrowLeft", mac: "Alt-ArrowLeft", run: cursorGroupLeft, shift: selectGroupLeft },
|
||||
{ mac: "Cmd-ArrowLeft", run: cursorLineBoundaryBackward, shift: selectLineBoundaryBackward },
|
||||
{ key: "Mod-ArrowLeft", mac: "Alt-ArrowLeft", run: cursorGroupLeft, shift: selectGroupLeft, preventDefault: true },
|
||||
{ mac: "Cmd-ArrowLeft", run: cursorLineBoundaryLeft, shift: selectLineBoundaryLeft, preventDefault: true },
|
||||
{ key: "ArrowRight", run: cursorCharRight, shift: selectCharRight, preventDefault: true },
|
||||
{ key: "Mod-ArrowRight", mac: "Alt-ArrowRight", run: cursorGroupRight, shift: selectGroupRight },
|
||||
{ mac: "Cmd-ArrowRight", run: cursorLineBoundaryForward, shift: selectLineBoundaryForward },
|
||||
{ key: "Mod-ArrowRight", mac: "Alt-ArrowRight", run: cursorGroupRight, shift: selectGroupRight, preventDefault: true },
|
||||
{ mac: "Cmd-ArrowRight", run: cursorLineBoundaryRight, shift: selectLineBoundaryRight, preventDefault: true },
|
||||
{ key: "ArrowUp", run: cursorLineUp, shift: selectLineUp, preventDefault: true },
|
||||
{ mac: "Cmd-ArrowUp", run: cursorDocStart, shift: selectDocStart },
|
||||
{ mac: "Ctrl-ArrowUp", run: cursorPageUp, shift: selectPageUp },
|
||||
|
@ -1531,4 +1568,4 @@ this.
|
|||
*/
|
||||
const indentWithTab = { key: "Tab", run: indentMore, shift: indentLess };
|
||||
|
||||
export { blockComment, blockUncomment, copyLineDown, copyLineUp, cursorCharBackward, cursorCharForward, cursorCharLeft, cursorCharRight, cursorDocEnd, cursorDocStart, cursorGroupBackward, cursorGroupForward, cursorGroupLeft, cursorGroupRight, cursorLineBoundaryBackward, cursorLineBoundaryForward, cursorLineDown, cursorLineEnd, cursorLineStart, cursorLineUp, cursorMatchingBracket, cursorPageDown, cursorPageUp, cursorSubwordBackward, cursorSubwordForward, cursorSyntaxLeft, cursorSyntaxRight, defaultKeymap, deleteCharBackward, deleteCharForward, deleteGroupBackward, deleteGroupForward, deleteLine, deleteToLineEnd, deleteToLineStart, deleteTrailingWhitespace, emacsStyleKeymap, history, historyField, historyKeymap, indentLess, indentMore, indentSelection, indentWithTab, insertBlankLine, insertNewline, insertNewlineAndIndent, insertTab, invertedEffects, isolateHistory, lineComment, lineUncomment, moveLineDown, moveLineUp, redo, redoDepth, redoSelection, selectAll, selectCharBackward, selectCharForward, selectCharLeft, selectCharRight, selectDocEnd, selectDocStart, selectGroupBackward, selectGroupForward, selectGroupLeft, selectGroupRight, selectLine, selectLineBoundaryBackward, selectLineBoundaryForward, selectLineDown, selectLineEnd, selectLineStart, selectLineUp, selectMatchingBracket, selectPageDown, selectPageUp, selectParentSyntax, selectSubwordBackward, selectSubwordForward, selectSyntaxLeft, selectSyntaxRight, simplifySelection, splitLine, standardKeymap, toggleBlockComment, toggleBlockCommentByLine, toggleComment, toggleLineComment, transposeChars, undo, undoDepth, undoSelection };
|
||||
export { blockComment, blockUncomment, copyLineDown, copyLineUp, cursorCharBackward, cursorCharForward, cursorCharLeft, cursorCharRight, cursorDocEnd, cursorDocStart, cursorGroupBackward, cursorGroupForward, cursorGroupLeft, cursorGroupRight, cursorLineBoundaryBackward, cursorLineBoundaryForward, cursorLineBoundaryLeft, cursorLineBoundaryRight, cursorLineDown, cursorLineEnd, cursorLineStart, cursorLineUp, cursorMatchingBracket, cursorPageDown, cursorPageUp, cursorSubwordBackward, cursorSubwordForward, cursorSyntaxLeft, cursorSyntaxRight, defaultKeymap, deleteCharBackward, deleteCharForward, deleteGroupBackward, deleteGroupForward, deleteLine, deleteToLineEnd, deleteToLineStart, deleteTrailingWhitespace, emacsStyleKeymap, history, historyField, historyKeymap, indentLess, indentMore, indentSelection, indentWithTab, insertBlankLine, insertNewline, insertNewlineAndIndent, insertTab, invertedEffects, isolateHistory, lineComment, lineUncomment, moveLineDown, moveLineUp, redo, redoDepth, redoSelection, selectAll, selectCharBackward, selectCharForward, selectCharLeft, selectCharRight, selectDocEnd, selectDocStart, selectGroupBackward, selectGroupForward, selectGroupLeft, selectGroupRight, selectLine, selectLineBoundaryBackward, selectLineBoundaryForward, selectLineBoundaryLeft, selectLineBoundaryRight, selectLineDown, selectLineEnd, selectLineStart, selectLineUp, selectMatchingBracket, selectPageDown, selectPageUp, selectParentSyntax, selectSubwordBackward, selectSubwordForward, selectSyntaxLeft, selectSyntaxRight, simplifySelection, splitLine, standardKeymap, toggleBlockComment, toggleBlockCommentByLine, toggleComment, toggleLineComment, transposeChars, undo, undoDepth, undoSelection };
|
||||
|
|
4
node_modules/@codemirror/commands/package.json
generated
vendored
4
node_modules/@codemirror/commands/package.json
generated
vendored
|
@ -1,6 +1,6 @@
|
|||
{
|
||||
"name": "@codemirror/commands",
|
||||
"version": "6.0.0",
|
||||
"version": "6.2.0",
|
||||
"description": "Collection of editing commands for the CodeMirror code editor",
|
||||
"scripts": {
|
||||
"test": "cm-runtests",
|
||||
|
@ -27,7 +27,7 @@
|
|||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"@codemirror/language": "^6.0.0",
|
||||
"@codemirror/state": "^6.0.0",
|
||||
"@codemirror/state": "^6.2.0",
|
||||
"@codemirror/view": "^6.0.0",
|
||||
"@lezer/common": "^1.0.0"
|
||||
},
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue