Initial search implementation

This commit is contained in:
Zef Hemel
2022-05-16 15:09:36 +02:00
parent 7d01f77318
commit 2cdd3df6c3
17 changed files with 14798 additions and 62 deletions
+3
View File
@@ -1,8 +1,10 @@
import { ViewPlugin, ViewUpdate } from "@codemirror/view";
import { createImportSpecifier } from "typescript";
const urlRegexp =
/^https?:\/\/[-a-zA-Z0-9@:%._\+~#=]{1,256}([-a-zA-Z0-9()@:%_\+.~#?&//=]*)/;
// Known iOS Safari paste issue (unrelated to this implementation): https://voxpelli.com/2015/03/ios-safari-url-copy-paste-bug/
export const pasteLinkExtension = ViewPlugin.fromClass(
class {
update(update: ViewUpdate): void {
@@ -19,6 +21,7 @@ export const pasteLinkExtension = ViewPlugin.fromClass(
let pastedString = pastedText.join("");
if (pastedString.match(urlRegexp)) {
let selection = update.startState.selection.main;
console.log("It's a URL and selection empty?", selection.empty);
if (!selection.empty) {
setTimeout(() => {
update.view.dispatch({