Editor refact: rename Editor to Client

This commit is contained in:
Zef Hemel
2023-07-14 16:56:20 +02:00
parent f3936f9b2f
commit 16842a1c4b
20 changed files with 47 additions and 49 deletions
+2 -2
View File
@@ -6,7 +6,7 @@ import {
syntaxTree,
WidgetType,
} from "../deps.ts";
import { Editor } from "../editor.ts";
import { Client } from "../client.ts";
import { decoratorStateField, isCursorInRange } from "./util.ts";
type AdmonitionType = "note" | "warning";
@@ -97,7 +97,7 @@ function extractAdmonitionFields(rawText: string): AdmonitionFields | null {
return null;
}
export function admonitionPlugin(editor: Editor) {
export function admonitionPlugin(editor: Client) {
return decoratorStateField((state: EditorState) => {
const widgets: any[] = [];
+2 -2
View File
@@ -1,6 +1,6 @@
import type { ClickEvent } from "../../plug-api/app_event.ts";
import type { Extension } from "../deps.ts";
import type { Editor } from "../editor.ts";
import type { Client } from "../client.ts";
import { blockquotePlugin } from "./block_quote.ts";
import { admonitionPlugin } from "./admonition.ts";
import { directivePlugin } from "./directive.ts";
@@ -14,7 +14,7 @@ import { cleanWikiLinkPlugin } from "./wiki_link.ts";
import { cleanCommandLinkPlugin } from "./command_link.ts";
import { fencedCodePlugin } from "./fenced_code.ts";
export function cleanModePlugins(editor: Editor) {
export function cleanModePlugins(editor: Client) {
return [
linkPlugin(),
directivePlugin(),
+2 -2
View File
@@ -1,7 +1,7 @@
import { commandLinkRegex } from "../../common/markdown_parser/parser.ts";
import { ClickEvent } from "$sb/app_event.ts";
import { Decoration, syntaxTree } from "../deps.ts";
import { Editor } from "../editor.ts";
import { Client } from "../client.ts";
import {
ButtonWidget,
decoratorStateField,
@@ -12,7 +12,7 @@ import {
/**
* Plugin to hide path prefix when the cursor is not inside.
*/
export function cleanCommandLinkPlugin(editor: Editor) {
export function cleanCommandLinkPlugin(editor: Client) {
return decoratorStateField((state) => {
const widgets: any[] = [];
// let parentRange: [number, number];
+2 -2
View File
@@ -1,6 +1,6 @@
import { EditorView, syntaxTree, ViewPlugin, ViewUpdate } from "../deps.ts";
import { maximumAttachmentSize } from "../../common/types.ts";
import { Editor } from "../editor.ts";
import { Client } from "../client.ts";
// We use turndown to convert HTML to Markdown
import TurndownService from "https://cdn.skypack.dev/turndown@7.1.1";
@@ -80,7 +80,7 @@ export const pasteLinkExtension = ViewPlugin.fromClass(
},
);
export function attachmentExtension(editor: Editor) {
export function attachmentExtension(editor: Client) {
let shiftDown = false;
return EditorView.domEventHandlers({
dragover: (event) => {
+3 -3
View File
@@ -1,7 +1,7 @@
import { WidgetContent } from "../../plug-api/app_event.ts";
import { panelHtml } from "../components/panel.tsx";
import { Decoration, EditorState, syntaxTree, WidgetType } from "../deps.ts";
import type { Editor } from "../editor.ts";
import type { Client } from "../client.ts";
import { CodeWidgetCallback } from "../hooks/code_widget.ts";
import {
decoratorStateField,
@@ -13,7 +13,7 @@ class IFrameWidget extends WidgetType {
constructor(
readonly from: number,
readonly to: number,
readonly editor: Editor,
readonly editor: Client,
readonly bodyText: string,
readonly codeWidgetCallback: CodeWidgetCallback,
) {
@@ -94,7 +94,7 @@ class IFrameWidget extends WidgetType {
}
}
export function fencedCodePlugin(editor: Editor) {
export function fencedCodePlugin(editor: Client) {
return decoratorStateField((state: EditorState) => {
const widgets: any[] = [];
syntaxTree(state).iterate({
+2 -2
View File
@@ -8,7 +8,7 @@ import {
import { decoratorStateField } from "./util.ts";
import type { Space } from "../space.ts";
import type { Editor } from "../editor.ts";
import type { Client } from "../client.ts";
class InlineImageWidget extends WidgetType {
constructor(
@@ -53,7 +53,7 @@ class InlineImageWidget extends WidgetType {
}
}
export function inlineImagesPlugin(editor: Editor) {
export function inlineImagesPlugin(editor: Client) {
return decoratorStateField((state: EditorState) => {
const widgets: Range<Decoration>[] = [];
const imageRegex = /!\[(?<title>[^\]]*)\]\((?<url>.+)\)/;
+3 -3
View File
@@ -8,12 +8,12 @@ import {
import { renderMarkdownToHtml } from "../../plugs/markdown/markdown_render.ts";
import { ParseTree } from "$sb/lib/tree.ts";
import { lezerToParseTree } from "../../common/markdown_parser/parse_tree.ts";
import type { Editor } from "../editor.ts";
import type { Client } from "../client.ts";
class TableViewWidget extends WidgetType {
constructor(
readonly pos: number,
readonly editor: Editor,
readonly editor: Client,
readonly t: ParseTree,
) {
super();
@@ -48,7 +48,7 @@ class TableViewWidget extends WidgetType {
}
}
export function tablePlugin(editor: Editor) {
export function tablePlugin(editor: Client) {
return decoratorStateField((state: EditorState) => {
const widgets: any[] = [];
syntaxTree(state).iterate({
+2 -2
View File
@@ -1,7 +1,7 @@
import { pageLinkRegex } from "../../common/markdown_parser/parser.ts";
import { ClickEvent } from "../../plug-api/app_event.ts";
import { Decoration, syntaxTree } from "../deps.ts";
import { Editor } from "../editor.ts";
import { Client } from "../client.ts";
import {
decoratorStateField,
invisibleDecoration,
@@ -12,7 +12,7 @@ import {
/**
* Plugin to hide path prefix when the cursor is not inside.
*/
export function cleanWikiLinkPlugin(editor: Editor) {
export function cleanWikiLinkPlugin(editor: Client) {
return decoratorStateField((state) => {
const widgets: any[] = [];
// let parentRange: [number, number];