Refactoring of offline handling
This commit is contained in:
@@ -170,7 +170,7 @@ export function admonitionPlugin(editor: Client) {
|
||||
widget: new AdmonitionIconWidget(
|
||||
iconRange.from + 1,
|
||||
admonitionType,
|
||||
editor.editorView!,
|
||||
editor.editorView,
|
||||
),
|
||||
inclusive: true,
|
||||
}).range(iconRange.from, iconRange.to),
|
||||
|
||||
@@ -49,7 +49,7 @@ export function cleanCommandLinkPlugin(editor: Client) {
|
||||
(e) => {
|
||||
if (e.altKey) {
|
||||
// Move cursor into the link
|
||||
return editor.editorView!.dispatch({
|
||||
return editor.editorView.dispatch({
|
||||
selection: { anchor: from + 2 },
|
||||
});
|
||||
}
|
||||
|
||||
@@ -118,15 +118,15 @@ export function attachmentExtension(editor: Client) {
|
||||
// Only do rich text paste if shift is NOT down
|
||||
if (richText && !shiftDown) {
|
||||
// Are we in a fencede code block?
|
||||
const editorText = editor.editorView!.state.sliceDoc();
|
||||
const editorText = editor.editorView.state.sliceDoc();
|
||||
const tree = lezerToParseTree(
|
||||
editorText,
|
||||
syntaxTree(editor.editorView!.state).topNode,
|
||||
syntaxTree(editor.editorView.state).topNode,
|
||||
);
|
||||
addParentPointers(tree);
|
||||
const currentNode = nodeAtPos(
|
||||
tree,
|
||||
editor.editorView!.state.selection.main.from,
|
||||
editor.editorView.state.selection.main.from,
|
||||
);
|
||||
if (currentNode) {
|
||||
const fencedParentNode = findParentMatching(
|
||||
@@ -141,7 +141,7 @@ export function attachmentExtension(editor: Client) {
|
||||
|
||||
const markdown = striptHtmlComments(turndownService.turndown(richText))
|
||||
.trim();
|
||||
const view = editor.editorView!;
|
||||
const view = editor.editorView;
|
||||
const selection = view.state.selection.main;
|
||||
view.dispatch({
|
||||
changes: [
|
||||
@@ -221,11 +221,11 @@ export function attachmentExtension(editor: Client) {
|
||||
if (mimeType.startsWith("image/")) {
|
||||
attachmentMarkdown = `})`;
|
||||
}
|
||||
editor.editorView!.dispatch({
|
||||
editor.editorView.dispatch({
|
||||
changes: [
|
||||
{
|
||||
insert: attachmentMarkdown,
|
||||
from: editor.editorView!.state.selection.main.from,
|
||||
from: editor.editorView.state.selection.main.from,
|
||||
},
|
||||
],
|
||||
});
|
||||
|
||||
@@ -41,7 +41,7 @@ class IFrameWidget extends WidgetType {
|
||||
iframe.style.height = data.height + "px";
|
||||
break;
|
||||
case "setBody":
|
||||
this.editor.editorView!.dispatch({
|
||||
this.editor.editorView.dispatch({
|
||||
changes: {
|
||||
from: this.from,
|
||||
to: this.to,
|
||||
@@ -50,7 +50,7 @@ class IFrameWidget extends WidgetType {
|
||||
});
|
||||
break;
|
||||
case "blur":
|
||||
this.editor.editorView!.dispatch({
|
||||
this.editor.editorView.dispatch({
|
||||
selection: { anchor: this.from },
|
||||
});
|
||||
this.editor.focus();
|
||||
|
||||
@@ -26,7 +26,7 @@ class TableViewWidget extends WidgetType {
|
||||
// Pulling data-pos to put the cursor in the right place, falling back
|
||||
// to the start of the table.
|
||||
const dataAttributes = (e.target as any).dataset;
|
||||
this.editor.editorView!.dispatch({
|
||||
this.editor.editorView.dispatch({
|
||||
selection: {
|
||||
anchor: dataAttributes.pos ? +dataAttributes.pos : this.pos,
|
||||
},
|
||||
|
||||
@@ -90,7 +90,7 @@ export function cleanWikiLinkPlugin(editor: Client) {
|
||||
callback: (e) => {
|
||||
if (e.altKey) {
|
||||
// Move cursor into the link
|
||||
return editor.editorView!.dispatch({
|
||||
return editor.editorView.dispatch({
|
||||
selection: { anchor: from + 2 },
|
||||
});
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user