A fully open source & end-to-end encrypted note taking alternative to Evernote.
TypeScript asp-net-coredotnet-coreelectronfosshacktoberfestnote-managmentnote-takingnote-taking-appnotebooknotesnotes-appopen-sourceopensourceprivacyproductivityreactreact-nativereactjsself-hosted
feat: add vscode-like search replace
thecodrra45e6c094d19
diff --git a/packages/editor/dist/components/menu/menu.js b/packages/editor/dist/components/menu/menu.jsindex c40de8f4f..be94557d3 100644--- a/packages/editor/dist/components/menu/menu.js+++ b/packages/editor/dist/components/menu/menu.js@@ -20,6 +20,22 @@ var __rest = (this && this.__rest) || function (s, e) {}return t;};+var __read = (this && this.__read) || function (o, n) {+ var m = typeof Symbol === "function" && o[Symbol.iterator];+ if (!m) return o;+ var i = m.call(o), r, ar = [], e;+ try {+ while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value);+ }+ catch (error) { e = { error: error }; }+ finally {+ try {+ if (r && !r.done && (m = i["return"])) m.call(i);+ }+ finally { if (e) throw e.error; }+ }+ return ar;+};import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "react/jsx-runtime";import { useCallback, useRef, useEffect, useState, } from "react";import { Box, Flex, Text } from "rebass";@@ -30,8 +46,8 @@ import MenuItem from "./menuitem";import Modal from "react-modal";// import { store as selectionStore } from "../../stores/selectionstore";function useMenuFocus(items, onAction, onClose) {- var _a = useState(-1), focusIndex = _a[0], setFocusIndex = _a[1];- var _b = useState(false), isSubmenuOpen = _b[0], setIsSubmenuOpen = _b[1];+ var _a = __read(useState(-1), 2), focusIndex = _a[0], setFocusIndex = _a[1];+ var _b = __read(useState(false), 2), isSubmenuOpen = _b[0], setIsSubmenuOpen = _b[1];var moveItemIntoView = useCallback(function (index) {var item = items[index];if (!item)diff --git a/packages/editor/dist/extensions/image/component.js b/packages/editor/dist/extensions/image/component.jsindex 5a9163dd2..ead2e82d9 100644--- a/packages/editor/dist/extensions/image/component.js+++ b/packages/editor/dist/extensions/image/component.js@@ -9,6 +9,22 @@ var __assign = (this && this.__assign) || function () {};return __assign.apply(this, arguments);};+var __read = (this && this.__read) || function (o, n) {+ var m = typeof Symbol === "function" && o[Symbol.iterator];+ if (!m) return o;+ var i = m.call(o), r, ar = [], e;+ try {+ while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value);+ }+ catch (error) { e = { error: error }; }+ finally {+ try {+ if (r && !r.done && (m = i["return"])) m.call(i);+ }+ finally { if (e) throw e.error; }+ }+ return ar;+};import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";import { Box, Flex, Image, Text } from "rebass";import { NodeViewWrapper } from "@tiptap/react";@@ -25,7 +41,7 @@ export function ImageComponent(props) {var editor = props.editor, updateAttributes = props.updateAttributes;var imageRef = useRef();var isActive = editor.isActive("image", { src: src });- var _b = useState(), isToolbarVisible = _b[0], setIsToolbarVisible = _b[1];+ var _b = __read(useState(), 2), isToolbarVisible = _b[0], setIsToolbarVisible = _b[1];var theme = editor.storage.theme;useEffect(function () {setIsToolbarVisible(isActive);@@ -58,7 +74,7 @@ export function ImageComponent(props) {}function ImageToolbar(props) {var editor = props.editor, float = props.float, height = props.height, width = props.width;- var _a = useState(false), isOpen = _a[0], setIsOpen = _a[1];+ var _a = __read(useState(false), 2), isOpen = _a[0], setIsOpen = _a[1];var onSizeChange = useCallback(function (newWidth, newHeight) {var size = newWidth? {diff --git a/packages/editor/dist/extensions/image/image.js b/packages/editor/dist/extensions/image/image.jsindex 915061016..7c0c3f6a0 100644--- a/packages/editor/dist/extensions/image/image.js+++ b/packages/editor/dist/extensions/image/image.js@@ -9,6 +9,22 @@ var __assign = (this && this.__assign) || function () {};return __assign.apply(this, arguments);};+var __read = (this && this.__read) || function (o, n) {+ var m = typeof Symbol === "function" && o[Symbol.iterator];+ if (!m) return o;+ var i = m.call(o), r, ar = [], e;+ try {+ while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value);+ }+ catch (error) { e = { error: error }; }+ finally {+ try {+ if (r && !r.done && (m = i["return"])) m.call(i);+ }+ finally { if (e) throw e.error; }+ }+ return ar;+};import { Node, nodeInputRule, mergeAttributes } from "@tiptap/core";import { ReactNodeViewRenderer } from "@tiptap/react";import { ImageComponent } from "./component";@@ -99,7 +115,7 @@ export var ImageNode = Node.create({find: inputRegex,type: this.type,getAttributes: function (match) {- var alt = match[2], src = match[3], title = match[4];+ var _a = __read(match, 5), alt = _a[2], src = _a[3], title = _a[4];return { src: src, alt: alt, title: title };},}),diff --git a/packages/editor/dist/extensions/searchreplace/index.d.ts b/packages/editor/dist/extensions/searchreplace/index.d.tsnew file mode 100644index 000000000..8a016dad8--- /dev/null+++ b/packages/editor/dist/extensions/searchreplace/index.d.ts@@ -0,0 +1 @@+export * from "./search-replace";diff --git a/packages/editor/dist/extensions/searchreplace/index.js b/packages/editor/dist/extensions/searchreplace/index.jsnew file mode 100644index 000000000..8a016dad8--- /dev/null+++ b/packages/editor/dist/extensions/searchreplace/index.js@@ -0,0 +1 @@+export * from "./search-replace";diff --git a/packages/editor/dist/extensions/searchreplace/searchreplace.d.ts b/packages/editor/dist/extensions/searchreplace/searchreplace.d.tsnew file mode 100644index 000000000..dc199dc44--- /dev/null+++ b/packages/editor/dist/extensions/searchreplace/searchreplace.d.ts@@ -0,0 +1,35 @@+import { Extension } from "@tiptap/core";+declare module "@tiptap/core" {+ interface Commands<ReturnType> {+ searchreplace: {+ startSearch: () => ReturnType;+ endSearch: () => ReturnType;+ search: (term: string, options?: SearchSettings) => ReturnType;+ moveToNextResult: () => ReturnType;+ moveToPreviousResult: () => ReturnType;+ replace: (term: string) => ReturnType;+ replaceAll: (term: string) => ReturnType;+ };+ }+}+interface Result {+ from: number;+ to: number;+}+interface SearchOptions {+ searchResultClass: string;+}+interface SearchSettings {+ matchCase: boolean;+ enableRegex: boolean;+ matchWholeWord: boolean;+}+export declare type SearchStorage = SearchSettings & {+ searchTerm: string;+ selectedIndex: number;+ isSearching: boolean;+ selectedText: string;+ results: Result[];+};+export declare const SearchReplace: Extension<SearchOptions, SearchStorage>;+export {};diff --git a/packages/editor/dist/extensions/searchreplace/searchreplace.js b/packages/editor/dist/extensions/searchreplace/searchreplace.jsnew file mode 100644index 000000000..3c32d918b--- /dev/null+++ b/packages/editor/dist/extensions/searchreplace/searchreplace.js@@ -0,0 +1,276 @@+var __values = (this && this.__values) || function(o) {+ var s = typeof Symbol === "function" && Symbol.iterator, m = s && o[s], i = 0;+ if (m) return m.call(o);+ if (o && typeof o.length === "number") return {+ next: function () {+ if (o && i >= o.length) o = void 0;+ return { value: o && o[i++], done: !o };+ }+ };+ throw new TypeError(s ? "Object is not iterable." : "Symbol.iterator is not defined.");+};+import { Extension } from "@tiptap/core";+import { Decoration, DecorationSet } from "prosemirror-view";+import { Plugin, PluginKey, TextSelection, } from "prosemirror-state";+var updateView = function (state, dispatch) {+ return dispatch(state.tr);+};+var regex = function (s, settings) {+ var enableRegex = settings.enableRegex, matchCase = settings.matchCase, matchWholeWord = settings.matchWholeWord;+ var boundary = matchWholeWord ? "\\b" : "";+ console.log(boundary);+ return RegExp(boundary ++ (enableRegex ? s : s.replace(/[-/\\^$*+?.()|[\]{}]/g, "\\$&")) ++ boundary, matchCase ? "gu" : "gui");+};+function searchDocument(doc, searchResultClass, searchTerm) {+ var e_1, _a, e_2, _b, e_3, _c;+ if (!searchTerm)+ return { decorationSet: DecorationSet.empty, results: [] };+ var decorations = [];+ var results = [];+ var index = 0;+ var textNodesWithPosition = [];+ doc === null || doc === void 0 ? void 0 : doc.descendants(function (node, pos) {+ if (node.isText) {+ if (textNodesWithPosition[index]) {+ textNodesWithPosition[index] = {+ text: textNodesWithPosition[index].text + node.text,+ pos: textNodesWithPosition[index].pos,+ };+ }+ else {+ textNodesWithPosition[index] = {+ text: node.text || "",+ pos: pos,+ };+ }+ }+ else {+ index += 1;+ }+ });+ textNodesWithPosition = textNodesWithPosition.filter(Boolean);+ try {+ for (var textNodesWithPosition_1 = __values(textNodesWithPosition), textNodesWithPosition_1_1 = textNodesWithPosition_1.next(); !textNodesWithPosition_1_1.done; textNodesWithPosition_1_1 = textNodesWithPosition_1.next()) {+ var _d = textNodesWithPosition_1_1.value, text = _d.text, pos = _d.pos;+ var matches = text.matchAll(searchTerm);+ try {+ for (var matches_1 = (e_2 = void 0, __values(matches)), matches_1_1 = matches_1.next(); !matches_1_1.done; matches_1_1 = matches_1.next()) {+ var m = matches_1_1.value;+ if (m[0] === "")+ break;+ if (m.index !== undefined) {+ results.push({+ from: pos + m.index,+ to: pos + m.index + m[0].length,+ });+ }+ }+ }+ catch (e_2_1) { e_2 = { error: e_2_1 }; }+ finally {+ try {+ if (matches_1_1 && !matches_1_1.done && (_b = matches_1.return)) _b.call(matches_1);+ }+ finally { if (e_2) throw e_2.error; }+ }+ }+ }+ catch (e_1_1) { e_1 = { error: e_1_1 }; }+ finally {+ try {+ if (textNodesWithPosition_1_1 && !textNodesWithPosition_1_1.done && (_a = textNodesWithPosition_1.return)) _a.call(textNodesWithPosition_1);+ }+ finally { if (e_1) throw e_1.error; }+ }+ try {+ for (var results_1 = __values(results), results_1_1 = results_1.next(); !results_1_1.done; results_1_1 = results_1.next()) {+ var _e = results_1_1.value, from = _e.from, to = _e.to;+ decorations.push(Decoration.inline(from, to, { class: searchResultClass }));+ }+ }+ catch (e_3_1) { e_3 = { error: e_3_1 }; }+ finally {+ try {+ if (results_1_1 && !results_1_1.done && (_c = results_1.return)) _c.call(results_1);+ }+ finally { if (e_3) throw e_3.error; }+ }+ return {+ decorationSet: DecorationSet.create(doc, decorations),+ results: results,+ };+}+var replaceAll = function (replaceTerm, results, tr) {+ var offset = 0;+ if (!results.length)+ return;+ var map = tr.mapping;+ for (var i = 0; i < results.length; i += 1) {+ var _a = results[i], from = _a.from, to = _a.to;+ tr.insertText(replaceTerm, from, to);+ if (i + 1 < results.length) {+ var _b = results[i + 1], from_1 = _b.from, to_1 = _b.to;+ results[i + 1] = {+ from: map.map(from_1),+ to: map.map(to_1),+ };+ }+ }+ return tr;+};+export var SearchReplace = Extension.create({+ name: "searchreplace",+ addOptions: function () {+ return {+ searchResultClass: "search-result",+ };+ },+ addCommands: function () {+ var _this = this;+ return {+ startSearch: function () {+ return function (_a) {+ var state = _a.state;+ _this.storage.isSearching = true;+ if (!state.selection.empty) {+ _this.storage.selectedText = state.doc.textBetween(state.selection.$from.pos, state.selection.$to.pos);+ }+ return true;+ };+ },+ endSearch: function () { return function () {+ _this.storage.isSearching = false;+ return true;+ }; },+ search: function (term, options) {+ return function (_a) {+ var state = _a.state, dispatch = _a.dispatch;+ _this.storage.searchTerm = term;+ _this.storage.enableRegex = (options === null || options === void 0 ? void 0 : options.enableRegex) || false;+ _this.storage.matchCase = (options === null || options === void 0 ? void 0 : options.matchCase) || false;+ _this.storage.matchWholeWord = (options === null || options === void 0 ? void 0 : options.matchWholeWord) || false;+ updateView(state, dispatch);+ return true;+ };+ },+ moveToNextResult: function () {+ return function (_a) {+ var chain = _a.chain;+ var _b = _this.storage, selectedIndex = _b.selectedIndex, results = _b.results;+ if (results.length <= 0)+ return false;+ var nextIndex = selectedIndex + 1;+ if (isNaN(nextIndex) || nextIndex >= results.length)+ nextIndex = 0;+ var _c = results[nextIndex], from = _c.from, to = _c.to;+ console.log("[moveToNextResult]", from, to);+ var result = chain()+ .focus(undefined, { scrollIntoView: true })+ .setTextSelection({ from: from, to: to })+ .run();+ if (result)+ _this.storage.selectedIndex = nextIndex;+ return result;+ };+ },+ moveToPreviousResult: function () {+ return function (_a) {+ var chain = _a.chain;+ var _b = _this.storage, selectedIndex = _b.selectedIndex, results = _b.results;+ if (results.length <= 0)+ return false;+ var prevIndex = selectedIndex - 1;+ if (isNaN(prevIndex) || prevIndex < 0)+ prevIndex = results.length - 1;+ var _c = results[prevIndex], from = _c.from, to = _c.to;+ var result = chain()+ .focus(undefined, { scrollIntoView: true })+ .setTextSelection({ from: from, to: to })+ .run();+ if (result)+ _this.storage.selectedIndex = prevIndex;+ return result;+ };+ },+ replace: function (term) {+ return function (_a) {+ var commands = _a.commands, tr = _a.tr, dispatch = _a.dispatch;+ var _b = _this.storage, selectedIndex = _b.selectedIndex, results = _b.results;+ if (!dispatch || results.length <= 0)+ return false;+ var index = selectedIndex === undefined ? 0 : selectedIndex;+ var _c = results[index], from = _c.from, to = _c.to;+ tr.insertText(term, from, to);+ if (index + 1 < results.length) {+ var _d = results[index + 1], from_2 = _d.from, to_2 = _d.to;+ var nextResult = (results[index + 1] = {+ from: tr.mapping.map(from_2),+ to: tr.mapping.map(to_2),+ });+ commands.focus();+ tr.setSelection(new TextSelection(tr.doc.resolve(nextResult.from), tr.doc.resolve(nextResult.to)));+ }+ dispatch(tr);+ results.splice(index, 1);+ return true;+ };+ },+ replaceAll: function (term) {+ return function (_a) {+ var state = _a.state, tr = _a.tr, dispatch = _a.dispatch;+ if (!dispatch)+ return false;+ var _b = _this.storage, selectedIndex = _b.selectedIndex, results = _b.results;+ dispatch(replaceAll(term, results, tr));+ return true;+ };+ },+ };+ },+ addKeyboardShortcuts: function () {+ return {+ "Mod-f": function (_a) {+ var editor = _a.editor;+ return editor.commands.startSearch();+ },+ Escape: function (_a) {+ var editor = _a.editor;+ return editor.commands.endSearch();+ },+ };+ },+ addProseMirrorPlugins: function () {+ var _this = this;+ return [+ new Plugin({+ key: new PluginKey("searchreplace"),+ state: {+ init: function () {+ return DecorationSet.empty;+ },+ apply: function (_a) {+ var doc = _a.doc, docChanged = _a.docChanged, setSelection = _a.setSelection;+ var _b = _this.storage, searchTerm = _b.searchTerm, enableRegex = _b.enableRegex, matchCase = _b.matchCase, matchWholeWord = _b.matchWholeWord;+ var searchResultClass = _this.options.searchResultClass;+ if (docChanged || searchTerm) {+ var searchRegex = searchTerm+ ? regex(searchTerm, { enableRegex: enableRegex, matchCase: matchCase, matchWholeWord: matchWholeWord })+ : undefined;+ var _c = searchDocument(doc, searchResultClass, searchRegex), decorationSet = _c.decorationSet, results = _c.results;+ _this.storage.results = results;+ return decorationSet;+ }+ return DecorationSet.empty;+ },+ },+ props: {+ decorations: function (state) {+ return this.getState(state);+ },+ },+ }),+ ];+ },+});diff --git a/packages/editor/dist/extensions/taskitem/component.js b/packages/editor/dist/extensions/taskitem/component.jsindex 3c6251edd..db7e857a5 100644--- a/packages/editor/dist/extensions/taskitem/component.js+++ b/packages/editor/dist/extensions/taskitem/component.js@@ -9,6 +9,33 @@ var __assign = (this && this.__assign) || function () {};return __assign.apply(this, arguments);};+var __read = (this && this.__read) || function (o, n) {+ var m = typeof Symbol === "function" && o[Symbol.iterator];+ if (!m) return o;+ var i = m.call(o), r, ar = [], e;+ try {+ while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value);+ }+ catch (error) { e = { error: error }; }+ finally {+ try {+ if (r && !r.done && (m = i["return"])) m.call(i);+ }+ finally { if (e) throw e.error; }+ }+ return ar;+};+var __values = (this && this.__values) || function(o) {+ var s = typeof Symbol === "function" && Symbol.iterator, m = s && o[s], i = 0;+ if (m) return m.call(o);+ if (o && typeof o.length === "number") return {+ next: function () {+ if (o && i >= o.length) o = void 0;+ return { value: o && o[i++], done: !o };+ }+ };+ throw new TypeError(s ? "Object is not iterable." : "Symbol.iterator is not defined.");+};import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";import { Flex, Text } from "rebass";import { NodeViewWrapper, NodeViewContent, } from "@tiptap/react";@@ -19,7 +46,7 @@ import { findChildren, } from "@tiptap/core";import { useCallback, useEffect, useState } from "react";export function TaskItemComponent(props) {var checked = props.node.attrs.checked;- var _a = useState({ checked: 0, total: 0 }), stats = _a[0], setStats = _a[1];+ var _a = __read(useState({ checked: 0, total: 0 }), 2), stats = _a[0], setStats = _a[1];var editor = props.editor, updateAttributes = props.updateAttributes, node = props.node, getPos = props.getPos;var theme = editor.storage.theme;var toggle = useCallback(function () {@@ -119,14 +146,24 @@ export function TaskItemComponent(props) {} })] }))] })) })) }));}function toggleChildren(node, tr, toggleState, parentPos) {+ var e_1, _a;var children = findChildren(node, function (node) { return node.type.name === "taskItem"; });- for (var _i = 0, children_1 = children; _i < children_1.length; _i++) {- var pos = children_1[_i].pos;- // need to add 1 to get inside the node- var actualPos = pos + parentPos + 1;- tr.setNodeMarkup(actualPos, undefined, {- checked: toggleState,- });+ try {+ for (var children_1 = __values(children), children_1_1 = children_1.next(); !children_1_1.done; children_1_1 = children_1.next()) {+ var pos = children_1_1.value.pos;+ // need to add 1 to get inside the node+ var actualPos = pos + parentPos + 1;+ tr.setNodeMarkup(actualPos, undefined, {+ checked: toggleState,+ });+ }+ }+ catch (e_1_1) { e_1 = { error: e_1_1 }; }+ finally {+ try {+ if (children_1_1 && !children_1_1.done && (_a = children_1.return)) _a.call(children_1);+ }+ finally { if (e_1) throw e_1.error; }}return tr;}diff --git a/packages/editor/dist/extensions/tasklist/component.js b/packages/editor/dist/extensions/tasklist/component.jsindex 678dcb764..8cec96bc3 100644--- a/packages/editor/dist/extensions/tasklist/component.js+++ b/packages/editor/dist/extensions/tasklist/component.js@@ -9,6 +9,22 @@ var __assign = (this && this.__assign) || function () {};return __assign.apply(this, arguments);};+var __read = (this && this.__read) || function (o, n) {+ var m = typeof Symbol === "function" && o[Symbol.iterator];+ if (!m) return o;+ var i = m.call(o), r, ar = [], e;+ try {+ while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value);+ }+ catch (error) { e = { error: error }; }+ finally {+ try {+ if (r && !r.done && (m = i["return"])) m.call(i);+ }+ finally { if (e) throw e.error; }+ }+ return ar;+};import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";import { Box, Flex, Text } from "rebass";import { NodeViewWrapper, NodeViewContent, } from "@tiptap/react";@@ -21,7 +37,7 @@ import { Input } from "@rebass/forms";export function TaskListComponent(props) {var editor = props.editor, getPos = props.getPos, node = props.node, updateAttributes = props.updateAttributes;var _a = node.attrs, collapsed = _a.collapsed, title = _a.title;- var _b = useState({ checked: 0, total: 0, percentage: 0 }), stats = _b[0], setStats = _b[1];+ var _b = __read(useState({ checked: 0, total: 0, percentage: 0 }), 2), stats = _b[0], setStats = _b[1];var theme = editor.storage.theme;var resolvedPos = editor.state.doc.resolve(getPos());var parentTaskItem = findParentNodeClosestToPos(resolvedPos, function (node) { return node.type.name === "taskItem"; });diff --git a/packages/editor/dist/index.d.ts b/packages/editor/dist/index.d.tsindex 42fca2c06..e85a96c93 100644--- a/packages/editor/dist/index.d.ts+++ b/packages/editor/dist/index.d.ts@@ -1,3 +1,4 @@+/// <reference types="react" />import { EditorOptions } from "@tiptap/react";import Toolbar from "./toolbar";import { ThemeConfig } from "@notesnook/theme/dist/theme/types";diff --git a/packages/editor/dist/index.js b/packages/editor/dist/index.jsindex c9e814591..c16bf0e48 100644--- a/packages/editor/dist/index.js+++ b/packages/editor/dist/index.js@@ -50,6 +50,7 @@ import { AttachmentNode } from "./extensions/attachment";import { TaskListNode } from "./extensions/task-list";import { TaskItemNode } from "./extensions/task-item";import { Dropcursor } from "./extensions/drop-cursor";+import { SearchReplace } from "./extensions/search-replace";EditorView.prototype.updateState = function updateState(state) {if (!this.docView)return; // This prevents the matchesNode error on hot reloads@@ -60,6 +61,7 @@ var useTiptap = function (options, deps) {var theme = options.theme, accent = options.accent, scale = options.scale, onCreate = options.onCreate, onDownloadAttachment = options.onDownloadAttachment, restOptions = __rest(options, ["theme", "accent", "scale", "onCreate", "onDownloadAttachment"]);var defaultOptions = useMemo(function () { return ({extensions: [+ SearchReplace,TextStyle,StarterKit.configure({dropcursor: false,diff --git a/packages/editor/dist/toolbar/components/dropdown.js b/packages/editor/dist/toolbar/components/dropdown.jsindex d7b2b968a..1274e1f63 100644--- a/packages/editor/dist/toolbar/components/dropdown.js+++ b/packages/editor/dist/toolbar/components/dropdown.js@@ -9,6 +9,22 @@ var __assign = (this && this.__assign) || function () {};return __assign.apply(this, arguments);};+var __read = (this && this.__read) || function (o, n) {+ var m = typeof Symbol === "function" && o[Symbol.iterator];+ if (!m) return o;+ var i = m.call(o), r, ar = [], e;+ try {+ while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value);+ }+ catch (error) { e = { error: error }; }+ finally {+ try {+ if (r && !r.done && (m = i["return"])) m.call(i);+ }+ finally { if (e) throw e.error; }+ }+ return ar;+};import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";import { useRef, useState } from "react";import { Button, Text } from "rebass";@@ -18,7 +34,7 @@ import { MenuPresenter } from "../../components/menu/menu";export function Dropdown(props) {var items = props.items, selectedItem = props.selectedItem;var buttonRef = useRef(null);- var _a = useState(false), isOpen = _a[0], setIsOpen = _a[1];+ var _a = __read(useState(false), 2), isOpen = _a[0], setIsOpen = _a[1];return (_jsxs(_Fragment, { children: [_jsxs(Button, __assign({ ref: buttonRef, sx: {p: 1,m: 0,diff --git a/packages/editor/dist/toolbar/floatingmenus/index.js b/packages/editor/dist/toolbar/floatingmenus/index.jsindex c3e948034..58c6bf446 100644--- a/packages/editor/dist/toolbar/floatingmenus/index.js+++ b/packages/editor/dist/toolbar/floatingmenus/index.js@@ -11,6 +11,7 @@ var __assign = (this && this.__assign) || function () {};import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "react/jsx-runtime";import { TableRowFloatingMenu, TableColumnFloatingMenu } from "./table";+import { SearchReplaceFloatingMenu } from "./search-replace";export function EditorFloatingMenus(props) {- return (_jsxs(_Fragment, { children: [_jsx(TableRowFloatingMenu, __assign({}, props)), _jsx(TableColumnFloatingMenu, __assign({}, props))] }));+ return (_jsxs(_Fragment, { children: [_jsx(TableRowFloatingMenu, __assign({}, props)), _jsx(TableColumnFloatingMenu, __assign({}, props)), _jsx(SearchReplaceFloatingMenu, __assign({}, props))] }));}diff --git a/packages/editor/dist/toolbar/floatingmenus/searchreplace.d.ts b/packages/editor/dist/toolbar/floatingmenus/searchreplace.d.tsnew file mode 100644index 000000000..78197e973--- /dev/null+++ b/packages/editor/dist/toolbar/floatingmenus/searchreplace.d.ts@@ -0,0 +1,3 @@+/// <reference types="react" />+import { FloatingMenuProps } from "./types";+export declare function SearchReplaceFloatingMenu(props: FloatingMenuProps): JSX.Element | null;diff --git a/packages/editor/dist/toolbar/floatingmenus/searchreplace.js b/packages/editor/dist/toolbar/floatingmenus/searchreplace.jsnew file mode 100644index 000000000..b35388d24--- /dev/null+++ b/packages/editor/dist/toolbar/floatingmenus/searchreplace.js@@ -0,0 +1,87 @@+var __assign = (this && this.__assign) || function () {+ __assign = Object.assign || function(t) {+ for (var s, i = 1, n = arguments.length; i < n; i++) {+ s = arguments[i];+ for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))+ t[p] = s[p];+ }+ return t;+ };+ return __assign.apply(this, arguments);+};+var __read = (this && this.__read) || function (o, n) {+ var m = typeof Symbol === "function" && o[Symbol.iterator];+ if (!m) return o;+ var i = m.call(o), r, ar = [], e;+ try {+ while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value);+ }+ catch (error) { e = { error: error }; }+ finally {+ try {+ if (r && !r.done && (m = i["return"])) m.call(i);+ }+ finally { if (e) throw e.error; }+ }+ return ar;+};+import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";+import { Input } from "@rebass/forms";+import { useCallback, useEffect, useRef, useState } from "react";+import { Flex } from "rebass";+import { MenuPresenter } from "../../components/menu/menu";+import { Popup } from "../components/popup";+import { ToolButton } from "../components/tool-button";+export function SearchReplaceFloatingMenu(props) {+ var editor = props.editor;+ var _a = editor.storage+ .searchreplace, isSearching = _a.isSearching, selectedText = _a.selectedText;+ var _b = __read(useState(false), 2), matchCase = _b[0], setMatchCase = _b[1];+ var _c = __read(useState(false), 2), matchWholeWord = _c[0], setMatchWholeWord = _c[1];+ var _d = __read(useState(false), 2), enableRegex = _d[0], setEnableRegex = _d[1];+ var replaceText = useRef("");+ var searchText = useRef("");+ var search = useCallback(function (term) {+ editor.commands.search(term, {+ matchCase: matchCase,+ enableRegex: enableRegex,+ matchWholeWord: matchWholeWord,+ });+ }, [matchCase, enableRegex, matchWholeWord]);+ useEffect(function () {+ search(searchText.current);+ }, [search, matchCase, matchWholeWord, enableRegex]);+ useEffect(function () {+ if (isSearching && selectedText)+ search(selectedText);+ }, [isSearching, selectedText, search]);+ if (!isSearching)+ return null;+ return (_jsx(MenuPresenter, __assign({ isOpen: true, items: [], onClose: function () { }, options: {+ type: "autocomplete",+ position: {+ target: document.querySelector(".editor-toolbar") || "mouse",+ isTargetAbsolute: true,+ location: "below",+ align: "end",+ },+ } }, { children: _jsx(Popup, { children: _jsxs(Flex, __assign({ sx: { p: 1, flexDirection: "column" } }, { children: [_jsxs(Flex, __assign({ sx: { alignItems: "start", flexShrink: 0 } }, { children: [_jsxs(Flex, __assign({ sx: {+ position: "relative",+ mr: 1,+ width: 200,+ alignItems: "center",+ } }, { children: [_jsx(Input, { defaultValue: selectedText, autoFocus: true, sx: { p: 1 }, placeholder: "Find", onChange: function (e) {+ searchText.current = e.target.value;+ search(searchText.current);+ } }), _jsxs(Flex, __assign({ sx: {+ position: "absolute",+ right: 0,+ mr: 0,+ } }, { children: [_jsx(ToolButton, { sx: {+ mr: 0,+ }, toggled: matchCase, title: "Match case", id: "matchCase", icon: "caseSensitive", onClick: function () { return setMatchCase(function (s) { return !s; }); }, iconSize: 14 }), _jsx(ToolButton, { sx: {+ mr: 0,+ }, toggled: matchWholeWord, title: "Match whole word", id: "matchWholeWord", icon: "wholeWord", onClick: function () { return setMatchWholeWord(function (s) { return !s; }); }, iconSize: 14 }), _jsx(ToolButton, { sx: {+ mr: 0,+ }, toggled: enableRegex, title: "Enable regex", id: "enableRegex", icon: "regex", onClick: function () { return setEnableRegex(function (s) { return !s; }); }, iconSize: 14 })] }))] })), _jsx(ToolButton, { toggled: false, title: "Previous match", id: "previousMatch", icon: "previousMatch", onClick: function () { return editor.commands.moveToPreviousResult(); }, sx: { mr: 0 }, iconSize: 16 }), _jsx(ToolButton, { toggled: false, title: "Next match", id: "nextMatch", icon: "nextMatch", onClick: function () { return editor.commands.moveToNextResult(); }, sx: { mr: 0 }, iconSize: 16 }), _jsx(ToolButton, { toggled: false, title: "Close", id: "close", icon: "close", onClick: function () { return editor.chain().focus().endSearch().run(); }, iconSize: 16, sx: { mr: 0 } })] })), _jsxs(Flex, __assign({ sx: { alignItems: "start", flexShrink: 0, mt: 1 } }, { children: [_jsx(Input, { sx: { p: 1, width: 200, mr: 1 }, placeholder: "Replace", onChange: function (e) { return (replaceText.current = e.target.value); } }), _jsx(ToolButton, { toggled: false, title: "Replace", id: "replace", icon: "replaceOne", onClick: function () { return editor.commands.replace(replaceText.current); }, sx: { mr: 0 }, iconSize: 16 }), _jsx(ToolButton, { toggled: false, title: "Replace all", id: "replaceAll", icon: "replaceAll", onClick: function () { return editor.commands.replaceAll(replaceText.current); }, sx: { mr: 0 }, iconSize: 16 })] }))] })) }) })));+}diff --git a/packages/editor/dist/toolbar/floatingmenus/table.js b/packages/editor/dist/toolbar/floatingmenus/table.jsindex 456fd0f54..9d3dd60a2 100644--- a/packages/editor/dist/toolbar/floatingmenus/table.js+++ b/packages/editor/dist/toolbar/floatingmenus/table.js@@ -45,6 +45,22 @@ var __generator = (this && this.__generator) || function (thisArg, body) {if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };}};+var __read = (this && this.__read) || function (o, n) {+ var m = typeof Symbol === "function" && o[Symbol.iterator];+ if (!m) return o;+ var i = m.call(o), r, ar = [], e;+ try {+ while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value);+ }+ catch (error) { e = { error: error }; }+ finally {+ try {+ if (r && !r.done && (m = i["return"])) m.call(i);+ }+ finally { if (e) throw e.error; }+ }+ return ar;+};var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {if (ar || !(i in from)) {@@ -66,8 +82,8 @@ import { selectedRect } from "prosemirror-tables";export function TableRowFloatingMenu(props) {var editor = props.editor;var theme = editor.storage.theme;- var _a = useState(null), position = _a[0], setPosition = _a[1];- var _b = useState(false), isMenuOpen = _b[0], setIsMenuOpen = _b[1];+ var _a = __read(useState(null), 2), position = _a[0], setPosition = _a[1];+ var _b = __read(useState(false), 2), isMenuOpen = _b[0], setIsMenuOpen = _b[1];useEffect(function () {var _a;if (!editor.isActive("tableCell") &&@@ -147,12 +163,12 @@ export function TableRowFloatingMenu(props) {export function TableColumnFloatingMenu(props) {var _this = this;var editor = props.editor;- var _a = useState(null), position = _a[0], setPosition = _a[1];+ var _a = __read(useState(null), 2), position = _a[0], setPosition = _a[1];var isInsideCellSelection = !editor.state.selection.empty &&editor.state.selection.$anchor.node().type.name === "tableCell";- var _b = useState(false), isMenuOpen = _b[0], setIsMenuOpen = _b[1];- var _c = useState(false), showCellProps = _c[0], setShowCellProps = _c[1];- var _d = useState(null), menuPosition = _d[0], setMenuPosition = _d[1];+ var _b = __read(useState(false), 2), isMenuOpen = _b[0], setIsMenuOpen = _b[1];+ var _c = __read(useState(false), 2), showCellProps = _c[0], setShowCellProps = _c[1];+ var _d = __read(useState(null), 2), menuPosition = _d[0], setMenuPosition = _d[1];useEffect(function () {var _a;if (!editor.isActive("tableCell") &&@@ -282,11 +298,11 @@ export function TableColumnFloatingMenu(props) {type: "menu",position: {},}, items: isInsideCellSelection- ? __spreadArray(__spreadArray([], mergeSplitProperties, true), cellProperties, true) : __spreadArray(__spreadArray(__spreadArray(__spreadArray(__spreadArray([], columnProperties, true), [+ ? __spreadArray(__spreadArray([], __read(mergeSplitProperties), false), __read(cellProperties), false) : __spreadArray(__spreadArray(__spreadArray(__spreadArray(__spreadArray([], __read(columnProperties), false), [{ type: "seperator", key: "cellSeperator" }- ], false), cellProperties, true), [+ ], false), __read(cellProperties), false), [{ type: "seperator", key: "tableSeperator" }- ], false), tableProperties, true) }), _jsx(MenuPresenter, __assign({ isOpen: showCellProps, onClose: function () {+ ], false), __read(tableProperties), false) }), _jsx(MenuPresenter, __assign({ isOpen: showCellProps, onClose: function () {setShowCellProps(false);editor.commands.focus();}, options: {@@ -318,7 +334,7 @@ function CellProperties(props) {}function ColorPickerTool(props) {var color = props.color, title = props.title, icon = props.icon, onColorChange = props.onColorChange;- var _a = useState(false), isOpen = _a[0], setIsOpen = _a[1];+ var _a = __read(useState(false), 2), isOpen = _a[0], setIsOpen = _a[1];var buttonRef = useRef(null);return (_jsxs(_Fragment, { children: [_jsxs(Flex, __assign({ sx: { justifyContent: "space-between", alignItems: "center", mt: 1 } }, { children: [_jsx(Text, __assign({ variant: "body" }, { children: title })), _jsx(ToolButton, { buttonRef: buttonRef, toggled: isOpen, title: title, id: icon, icon: icon, iconSize: 16, sx: {p: "2.5px",diff --git a/packages/editor/dist/toolbar/icons.d.ts b/packages/editor/dist/toolbar/icons.d.tsindex 9bdad04bc..c7d18eb41 100644--- a/packages/editor/dist/toolbar/icons.d.ts+++ b/packages/editor/dist/toolbar/icons.d.ts@@ -50,6 +50,13 @@ export declare const Icons: {splitCells: string;checklist: string;dragHandle: string;+ previousMatch: string;+ nextMatch: string;+ replaceOne: string;+ replaceAll: string;+ caseSensitive: string;+ wholeWord: string;+ regex: string;plus: string;close: string;delete: string;diff --git a/packages/editor/dist/toolbar/icons.js b/packages/editor/dist/toolbar/icons.jsindex cc242fd49..fffbc2aae 100644--- a/packages/editor/dist/toolbar/icons.js+++ b/packages/editor/dist/toolbar/icons.js@@ -1,4 +1,4 @@-import { mdiAttachment, mdiBorderHorizontal, mdiCheck, mdiChevronDown, mdiCodeBraces, mdiCodeTags, mdiDotsVertical, mdiFormatAlignCenter, mdiFormatAlignJustify, mdiFormatAlignLeft, mdiFormatAlignRight, mdiFormatBold, mdiFormatClear, mdiFormatColorHighlight, mdiFormatColorText, mdiFormatItalic, mdiFormatListBulleted, mdiFormatListNumbered, mdiFormatQuoteClose, mdiFormatStrikethrough, mdiFormatSubscript, mdiFormatSuperscript, mdiFormatTextdirectionLToR, mdiFormatTextdirectionRToL, mdiFormatUnderline, mdiImage, mdiInvertColorsOff, mdiLinkPlus, mdiLoading, mdiTable, mdiTableBorder, mdiTableRowPlusBefore, mdiTableRowRemove, mdiTableColumnPlusAfter, mdiTableColumnPlusBefore, mdiTableColumnRemove, mdiUploadOutline, mdiPlus, mdiSquareRoundedBadgeOutline, mdiFormatColorFill, mdiBorderAllVariant, mdiClose, mdiSortDescending, mdiArrowExpandRight, mdiArrowExpandLeft, mdiArrowExpandDown, mdiArrowExpandUp, mdiTrashCanOutline, mdiTableMergeCells, mdiTableSplitCell, mdiDeleteOutline, mdiDownloadOutline, mdiFormatListCheckbox, mdiDrag, mdiCheckboxMarkedOutline, mdiChevronUp, } from "@mdi/js";+import { mdiAttachment, mdiBorderHorizontal, mdiCheck, mdiChevronDown, mdiCodeBraces, mdiCodeTags, mdiDotsVertical, mdiFormatAlignCenter, mdiFormatAlignJustify, mdiFormatAlignLeft, mdiFormatAlignRight, mdiFormatBold, mdiFormatClear, mdiFormatColorHighlight, mdiFormatColorText, mdiFormatItalic, mdiFormatListBulleted, mdiFormatListNumbered, mdiFormatQuoteClose, mdiFormatStrikethrough, mdiFormatSubscript, mdiFormatSuperscript, mdiFormatTextdirectionLToR, mdiFormatTextdirectionRToL, mdiFormatUnderline, mdiImage, mdiInvertColorsOff, mdiLinkPlus, mdiLoading, mdiTable, mdiTableBorder, mdiTableRowPlusBefore, mdiTableRowRemove, mdiTableColumnPlusAfter, mdiTableColumnPlusBefore, mdiTableColumnRemove, mdiUploadOutline, mdiPlus, mdiSquareRoundedBadgeOutline, mdiFormatColorFill, mdiBorderAllVariant, mdiClose, mdiSortDescending, mdiArrowExpandRight, mdiArrowExpandLeft, mdiArrowExpandDown, mdiArrowExpandUp, mdiTrashCanOutline, mdiTableMergeCells, mdiTableSplitCell, mdiDeleteOutline, mdiDownloadOutline, mdiFormatListCheckbox, mdiDrag, mdiCheckboxMarkedOutline, mdiChevronUp, mdiArrowUp, mdiArrowDown, mdiRegex, mdiFormatLetterCase, mdiFormatLetterMatches, } from "@mdi/js";export var Icons = {bold: mdiFormatBold,italic: mdiFormatItalic,@@ -51,6 +51,13 @@ export var Icons = {splitCells: mdiTableSplitCell,checklist: mdiFormatListCheckbox,dragHandle: mdiDrag,+ previousMatch: mdiArrowUp,+ nextMatch: mdiArrowDown,+ replaceOne: "m5.4 5.42 3.48 3.5 3.43-3.43-1.08-1.08-1.57 1.55V3.5a.8.8 0 0 1 .76-.81h2.35v-1.5h-2.35a2.29 2.29 0 0 0-2.28 2.3v2.5L6.48 4.33Zm10.3 2.77c.3.48.7.72 1.25.72.61 0 1.1-.26 1.45-.78.37-.51.55-1.2.55-2.05 0-.8-.15-1.41-.46-1.87a1.51 1.51 0 0 0-1.33-.68c-.63 0-1.11.3-1.45.9h-.02V1.19h-1.37v7.6h1.37v-.6Zm-.03-1.64v-.52c0-.39.09-.7.27-.93a.83.83 0 0 1 .69-.36.76.76 0 0 1 .67.36c.16.24.24.57.24 1 0 .5-.09.9-.26 1.18a.8.8 0 0 1-.73.42.76.76 0 0 1-.63-.33 1.32 1.32 0 0 1-.25-.82zm-1.35 12.82c-.4.23-.97.35-1.71.35-.87 0-1.58-.27-2.12-.82a2.9 2.9 0 0 1-.8-2.12c0-1 .28-1.8.86-2.37a3.12 3.12 0 0 1 2.31-.87c.67 0 1.16.1 1.46.28v1.54a1.95 1.95 0 0 0-1.23-.42c-.5 0-.9.15-1.2.46-.29.3-.43.72-.43 1.26 0 .52.14.93.42 1.23.28.3.67.44 1.16.44.43 0 .86-.14 1.28-.43zm-7.73-8.91L5.05 12v9.27l1.54 1.54h10.82l1.54-1.54V12l-1.54-1.54zm0 1.54h10.82v9.27H6.59Z",+ replaceAll: "M16.53 4.22c.22-.45.52-.68.92-.68.36 0 .64.17.83.52.2.34.3.81.3 1.4a3.1 3.1 0 0 1-.35 1.57c-.22.39-.53.59-.91.59-.35 0-.61-.19-.79-.55h-.01v.45h-.87V1.77h.87v2.45h.01zm-.02 1.6a1.14 1.14 0 0 0 .15.63c.1.17.24.25.4.25.2 0 .35-.1.46-.32a2 2 0 0 0 .17-.9c0-.32-.05-.57-.15-.75-.1-.18-.24-.27-.43-.27-.17 0-.32.09-.43.27a1.3 1.3 0 0 0-.17.7ZM5.6 11.56l-3.1-3.1.97-.97 1.47 1.46v-2.2A2.03 2.03 0 0 1 6.96 4.7h3.43v1.32H6.96a.72.72 0 0 0-.68.73l.01 2.19 1.39-1.38.96.96-3.04 3.04Zm7.65-4.04h.94v-2.5c0-1.18-.46-1.78-1.38-1.78-.2 0-.41.04-.66.1a2.11 2.11 0 0 0-.56.25v.97c.34-.3.71-.44 1.1-.44.38 0 .57.23.57.68l-.88.16c-.74.12-1.11.59-1.11 1.4 0 .38.09.7.27.92a.9.9 0 0 0 .74.35c.42 0 .74-.24.96-.7h.01zm0-1.98v.28a1.1 1.1 0 0 1-.17.64.54.54 0 0 1-.46.25.4.4 0 0 1-.32-.14.56.56 0 0 1-.11-.36c0-.33.16-.51.48-.57l.59-.1zM9.82 19.21h-.94v-.6h-.02c-.21.46-.53.7-.96.7a.9.9 0 0 1-.74-.35 1.47 1.47 0 0 1-.27-.92c0-.8.38-1.28 1.12-1.4l.87-.15c0-.46-.19-.69-.57-.69-.38 0-.75.15-1.1.45v-.98c.14-.09.33-.17.57-.24.24-.07.46-.1.66-.1.92 0 1.38.59 1.38 1.78zm-.94-1.7v-.29l-.58.1c-.33.06-.49.25-.49.57 0 .15.04.27.12.36a.4.4 0 0 0 .32.14.54.54 0 0 0 .46-.25c.11-.17.17-.38.17-.63zm4.24 1.8c.47 0 .83-.09 1.08-.26v-1.03a1.32 1.32 0 0 1-.8.3.9.9 0 0 1-.74-.31c-.17-.22-.26-.5-.26-.88s.1-.68.28-.9a.94.94 0 0 1 .75-.32c.28 0 .54.1.77.3v-1.1c-.19-.12-.5-.19-.91-.19-.61 0-1.1.2-1.47.62-.36.4-.54.97-.54 1.68 0 .61.17 1.11.5 1.5.35.4.8.59 1.34.59zM2.5 13.46 3.96 12h13.16l1.46 1.46v7.3l-1.46 1.47H3.96L2.5 20.77Zm1.46 0v7.3h13.16v-7.3Zm4.39-2.92L9.8 9.08h10.23l1.46 1.46v7.3l-1.46 1.47v-8.77z",+ caseSensitive: mdiFormatLetterCase,+ wholeWord: mdiFormatLetterMatches,+ regex: mdiRegex,plus: mdiPlus,close: mdiClose,delete: mdiDeleteOutline,diff --git a/packages/editor/dist/toolbar/toolbar.js b/packages/editor/dist/toolbar/toolbar.jsindex 95c1fb83b..5157d2412 100644--- a/packages/editor/dist/toolbar/toolbar.js+++ b/packages/editor/dist/toolbar/toolbar.js@@ -31,7 +31,7 @@ export function Toolbar(props) {];if (!editor)return null;- return (_jsxs(ThemeProvider, __assign({ theme: themeProperties }, { children: [_jsx(Flex, __assign({ sx: { flexWrap: "wrap" } }, { children: tools.map(function (tools) {+ return (_jsxs(ThemeProvider, __assign({ theme: themeProperties }, { children: [_jsx(Flex, __assign({ className: "editor-toolbar", sx: { flexWrap: "wrap" } }, { children: tools.map(function (tools) {return (_jsx(Flex, __assign({ className: "toolbar-group", sx: {pr: 2,mr: 2,diff --git a/packages/editor/dist/toolbar/tools/block.js b/packages/editor/dist/toolbar/tools/block.jsindex e64a84644..9739f6505 100644--- a/packages/editor/dist/toolbar/tools/block.js+++ b/packages/editor/dist/toolbar/tools/block.js@@ -24,6 +24,22 @@ var __assign = (this && this.__assign) || function () {};return __assign.apply(this, arguments);};+var __read = (this && this.__read) || function (o, n) {+ var m = typeof Symbol === "function" && o[Symbol.iterator];+ if (!m) return o;+ var i = m.call(o), r, ar = [], e;+ try {+ while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value);+ }+ catch (error) { e = { error: error }; }+ finally {+ try {+ if (r && !r.done && (m = i["return"])) m.call(i);+ }+ finally { if (e) throw e.error; }+ }+ return ar;+};import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "react/jsx-runtime";import { ToolButton } from "../components/tool-button";import { Icons } from "../icons";@@ -115,16 +131,16 @@ var Table = /** @class */ (function () {this.MIN_ROWS = 4;this.render = function (props) {var editor = props.editor;- var _a = useState(false), isOpen = _a[0], setIsOpen = _a[1];+ var _a = __read(useState(false), 2), isOpen = _a[0], setIsOpen = _a[1];var ref = useRef(null);- var _b = useState({+ var _b = __read(useState({column: 0,row: 0,- }), cellLocation = _b[0], setCellLocation = _b[1];- var _c = useState({+ }), 2), cellLocation = _b[0], setCellLocation = _b[1];+ var _c = __read(useState({columns: _this.MIN_COLUMNS,rows: _this.MIN_ROWS,- }), tableSize = _c[0], setTableSize = _c[1];+ }), 2), tableSize = _c[0], setTableSize = _c[1];useEffect(function () {setTableSize(function (old) {var columns = old.columns, rows = old.rows;diff --git a/packages/editor/dist/toolbar/tools/colors.js b/packages/editor/dist/toolbar/tools/colors.jsindex e3d273488..1c20cf21d 100644--- a/packages/editor/dist/toolbar/tools/colors.js+++ b/packages/editor/dist/toolbar/tools/colors.js@@ -24,6 +24,22 @@ var __assign = (this && this.__assign) || function () {};return __assign.apply(this, arguments);};+var __read = (this && this.__read) || function (o, n) {+ var m = typeof Symbol === "function" && o[Symbol.iterator];+ if (!m) return o;+ var i = m.call(o), r, ar = [], e;+ try {+ while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value);+ }+ catch (error) { e = { error: error }; }+ finally {+ try {+ if (r && !r.done && (m = i["return"])) m.call(i);+ }+ finally { if (e) throw e.error; }+ }+ return ar;+};import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";import { Box, Button, Flex, Text } from "rebass";import { Input } from "@rebass/forms";@@ -58,7 +74,7 @@ var ColorTool = /** @class */ (function () {this.onColorChange = onColorChange;this.render = function (props) {var editor = props.editor;- var _a = useState(false), isOpen = _a[0], setIsOpen = _a[1];+ var _a = __read(useState(false), 2), isOpen = _a[0], setIsOpen = _a[1];var attrs = editor.getAttributes(_this.id === "highlight" ? "highlight" : "textStyle");var ref = useRef(null);var isActive = editor.isActive(_this.id === "highlight" ? "highlight" : "textStyle", { color: /\W+/gm });@@ -120,7 +136,7 @@ var TextColor = /** @class */ (function (_super) {export { TextColor };export function ColorPicker(props) {var colors = props.colors, color = props.color, onClear = props.onClear, onChange = props.onChange;- var _a = useState(tinycolor(color || colors[0]).toHexString()), currentColor = _a[0], setCurrentColor = _a[1];+ var _a = __read(useState(tinycolor(color || colors[0]).toHexString()), 2), currentColor = _a[0], setCurrentColor = _a[1];return (_jsxs(_Fragment, { children: [_jsx(Flex, __assign({ sx: {width: "100%",height: 50,diff --git a/packages/editor/dist/toolbar/tools/font.js b/packages/editor/dist/toolbar/tools/font.jsindex 8f23058ea..a77fa466b 100644--- a/packages/editor/dist/toolbar/tools/font.js+++ b/packages/editor/dist/toolbar/tools/font.js@@ -1,3 +1,19 @@+var __read = (this && this.__read) || function (o, n) {+ var m = typeof Symbol === "function" && o[Symbol.iterator];+ if (!m) return o;+ var i = m.call(o), r, ar = [], e;+ try {+ while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value);+ }+ catch (error) { e = { error: error }; }+ finally {+ try {+ if (r && !r.done && (m = i["return"])) m.call(i);+ }+ finally { if (e) throw e.error; }+ }+ return ar;+};import { jsx as _jsx } from "react/jsx-runtime";import { Dropdown } from "../components/dropdown";var FontSize = /** @class */ (function () {@@ -40,7 +56,7 @@ var FontFamily = /** @class */ (function () {var editor = props.editor;var currentFontFamily = ((_b = (_a = Object.entries(_this.fontFamilies).find(function (_a) {- var key = _a[0], value = _a[1];+ var _b = __read(_a, 2), key = _b[0], value = _b[1];return editor.isActive("textStyle", { fontFamily: value });})) === null || _a === void 0 ? void 0 : _a.map(function (a) { return a; })) === null || _b === void 0 ? void 0 : _b.at(0)) || "System";return (_jsx(Dropdown, { selectedItem: currentFontFamily, items: _this.toMenuItems(editor, currentFontFamily) }));diff --git a/packages/editor/dist/toolbar/tools/headings.js b/packages/editor/dist/toolbar/tools/headings.jsindex 68d053a12..86ab926ca 100644--- a/packages/editor/dist/toolbar/tools/headings.js+++ b/packages/editor/dist/toolbar/tools/headings.js@@ -1,3 +1,19 @@+var __read = (this && this.__read) || function (o, n) {+ var m = typeof Symbol === "function" && o[Symbol.iterator];+ if (!m) return o;+ var i = m.call(o), r, ar = [], e;+ try {+ while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value);+ }+ catch (error) { e = { error: error }; }+ finally {+ try {+ if (r && !r.done && (m = i["return"])) m.call(i);+ }+ finally { if (e) throw e.error; }+ }+ return ar;+};var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {if (ar || !(i in from)) {@@ -44,7 +60,7 @@ var Headings = /** @class */ (function () {isChecked: !currentHeadingLevel,onClick: function () { return editor.chain().focus().setParagraph().run(); },};- return __spreadArray([paragraph], menuItems, true);+ return __spreadArray([paragraph], __read(menuItems), false);};return Headings;}());diff --git a/packages/editor/dist/toolbar/tools/inline.js b/packages/editor/dist/toolbar/tools/inline.jsindex 02a92a62f..79180d7ea 100644--- a/packages/editor/dist/toolbar/tools/inline.js+++ b/packages/editor/dist/toolbar/tools/inline.js@@ -24,6 +24,22 @@ var __assign = (this && this.__assign) || function () {};return __assign.apply(this, arguments);};+var __read = (this && this.__read) || function (o, n) {+ var m = typeof Symbol === "function" && o[Symbol.iterator];+ if (!m) return o;+ var i = m.call(o), r, ar = [], e;+ try {+ while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value);+ }+ catch (error) { e = { error: error }; }+ finally {+ try {+ if (r && !r.done && (m = i["return"])) m.call(i);+ }+ finally { if (e) throw e.error; }+ }+ return ar;+};import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";import { ToolButton } from "../components/tool-button";import { MenuPresenter } from "../../components/menu/menu";@@ -124,9 +140,9 @@ var Link = /** @class */ (function () {var editor = props.editor;var buttonRef = useRef(null);var targetRef = useRef();- var _a = useState(false), isOpen = _a[0], setIsOpen = _a[1];- var _b = useState(), href = _b[0], setHref = _b[1];- var _c = useState(), text = _c[0], setText = _c[1];+ var _a = __read(useState(false), 2), isOpen = _a[0], setIsOpen = _a[1];+ var _b = __read(useState(), 2), href = _b[0], setHref = _b[1];+ var _c = __read(useState(), 2), text = _c[0], setText = _c[1];var currentUrl = editor.getAttributes("link").href;var isEditing = !!currentUrl;return (_jsxs(_Fragment, { children: [_jsx(ToolButton, { ref: buttonRef, title: _this.title, id: _this.id, icon: "link", onClick: function () {diff --git a/packages/editor/dist/toolbar/tools/lists.js b/packages/editor/dist/toolbar/tools/lists.jsindex 303774692..2b12173f9 100644--- a/packages/editor/dist/toolbar/tools/lists.js+++ b/packages/editor/dist/toolbar/tools/lists.js@@ -24,6 +24,22 @@ var __assign = (this && this.__assign) || function () {};return __assign.apply(this, arguments);};+var __read = (this && this.__read) || function (o, n) {+ var m = typeof Symbol === "function" && o[Symbol.iterator];+ if (!m) return o;+ var i = m.call(o), r, ar = [], e;+ try {+ while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value);+ }+ catch (error) { e = { error: error }; }+ finally {+ try {+ if (r && !r.done && (m = i["return"])) m.call(i);+ }+ finally { if (e) throw e.error; }+ }+ return ar;+};import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";import { Box, Button, Flex } from "rebass";import { Icon } from "../components/icon";@@ -39,7 +55,7 @@ var ListTool = /** @class */ (function () {this.options = options;this.render = function (props) {var editor = props.editor;- var _a = useState(false), isOpen = _a[0], setIsOpen = _a[1];+ var _a = __read(useState(false), 2), isOpen = _a[0], setIsOpen = _a[1];var ref = useRef(null);var isActive = editor.isActive(_this.options.type);return (_jsxs(Flex, __assign({ ref: ref }, { children: [_jsx(ToolButton, { title: _this.title, id: _this.id, icon: _this.options.icon, onClick: function () { return _this.options.onClick(editor); }, toggled: isActive, sx: { mr: 0 } }), _jsx(Button, __assign({ sx: {diff --git a/packages/editor/src/extensions/search-replace/index.ts b/packages/editor/src/extensions/search-replace/index.tsnew file mode 100644index 000000000..8a016dad8--- /dev/null+++ b/packages/editor/src/extensions/search-replace/index.ts@@ -0,0 +1 @@+export * from "./search-replace";diff --git a/packages/editor/src/extensions/search-replace/search-replace.ts b/packages/editor/src/extensions/search-replace/search-replace.tsnew file mode 100644index 000000000..5fbe1cf19--- /dev/null+++ b/packages/editor/src/extensions/search-replace/search-replace.ts@@ -0,0 +1,314 @@+import { Extension } from "@tiptap/core";+import { Decoration, DecorationSet } from "prosemirror-view";+import {+ EditorState,+ Plugin,+ PluginKey,+ TextSelection,+ Transaction,+} from "prosemirror-state";+import { Node as ProsemirrorNode } from "prosemirror-model";+import { findChildren } from "@tiptap/react";++declare module "@tiptap/core" {+ interface Commands<ReturnType> {+ searchreplace: {+ startSearch: () => ReturnType;+ endSearch: () => ReturnType;+ search: (term: string, options?: SearchSettings) => ReturnType;+ moveToNextResult: () => ReturnType;+ moveToPreviousResult: () => ReturnType;+ replace: (term: string) => ReturnType;+ replaceAll: (term: string) => ReturnType;+ };+ }+}++interface Result {+ from: number;+ to: number;+}++interface SearchOptions {+ searchResultClass: string;+}++interface SearchSettings {+ matchCase: boolean;+ enableRegex: boolean;+ matchWholeWord: boolean;+}++export type SearchStorage = SearchSettings & {+ searchTerm: string;+ selectedIndex: number;+ isSearching: boolean;+ selectedText: string;+ results: Result[];+};++interface TextNodesWithPosition {+ text: string;+ pos: number;+}++const updateView = (state: EditorState<any>, dispatch: any) =>+ dispatch(state.tr);++const regex = (s: string, settings: SearchSettings): RegExp => {+ const { enableRegex, matchCase, matchWholeWord } = settings;+ const boundary = matchWholeWord ? "\\b" : "";+ console.log(boundary);+ return RegExp(+ boundary ++ (enableRegex ? s : s.replace(/[-/\\^$*+?.()|[\]{}]/g, "\\$&")) ++ boundary,+ matchCase ? "gu" : "gui"+ );+};++function searchDocument(+ doc: ProsemirrorNode,+ searchResultClass: string,+ searchTerm?: RegExp+): { decorationSet: DecorationSet; results: Result[] } {+ if (!searchTerm) return { decorationSet: DecorationSet.empty, results: [] };++ const decorations: Decoration[] = [];+ const results: Result[] = [];++ let index = 0;++ let textNodesWithPosition: TextNodesWithPosition[] = [];++ doc?.descendants((node, pos) => {+ if (node.isText) {+ if (textNodesWithPosition[index]) {+ textNodesWithPosition[index] = {+ text: textNodesWithPosition[index].text + node.text,+ pos: textNodesWithPosition[index].pos,+ };+ } else {+ textNodesWithPosition[index] = {+ text: node.text || "",+ pos,+ };+ }+ } else {+ index += 1;+ }+ });+ textNodesWithPosition = textNodesWithPosition.filter(Boolean);++ for (const { text, pos } of textNodesWithPosition) {+ const matches = text.matchAll(searchTerm);++ for (const m of matches) {+ if (m[0] === "") break;++ if (m.index !== undefined) {+ results.push({+ from: pos + m.index,+ to: pos + m.index + m[0].length,+ });+ }+ }+ }++ for (const { from, to } of results) {+ decorations.push(Decoration.inline(from, to, { class: searchResultClass }));+ }++ return {+ decorationSet: DecorationSet.create(doc, decorations),+ results,+ };+}++const replaceAll = (+ replaceTerm: string,+ results: Result[],+ tr: Transaction<any>+) => {+ let offset = 0;++ if (!results.length) return;++ const map = tr.mapping;+ for (let i = 0; i < results.length; i += 1) {+ const { from, to } = results[i];++ tr.insertText(replaceTerm, from, to);++ if (i + 1 < results.length) {+ const { from, to } = results[i + 1];+ results[i + 1] = {+ from: map.map(from),+ to: map.map(to),+ };+ }+ }+ return tr;+};++export const SearchReplace = Extension.create<SearchOptions, SearchStorage>({+ name: "searchreplace",++ addOptions() {+ return {+ searchResultClass: "search-result",+ };+ },++ addCommands() {+ return {+ startSearch:+ () =>+ ({ state }) => {+ this.storage.isSearching = true;+ if (!state.selection.empty) {+ this.storage.selectedText = state.doc.textBetween(+ state.selection.$from.pos,+ state.selection.$to.pos+ );+ }+ return true;+ },+ endSearch: () => () => {+ this.storage.isSearching = false;+ return true;+ },+ search:+ (term, options?: SearchSettings) =>+ ({ state, dispatch }) => {+ this.storage.searchTerm = term;+ this.storage.enableRegex = options?.enableRegex || false;+ this.storage.matchCase = options?.matchCase || false;+ this.storage.matchWholeWord = options?.matchWholeWord || false;+ updateView(state, dispatch);+ return true;+ },+ moveToNextResult:+ () =>+ ({ chain }) => {+ const { selectedIndex, results } = this.storage;+ if (results.length <= 0) return false;++ let nextIndex = selectedIndex + 1;+ if (isNaN(nextIndex) || nextIndex >= results.length) nextIndex = 0;++ const { from, to } = results[nextIndex];+ console.log("[moveToNextResult]", from, to);+ const result = chain()+ .focus(undefined, { scrollIntoView: true })+ .setTextSelection({ from, to })+ .run();++ if (result) this.storage.selectedIndex = nextIndex;+ return result;+ },+ moveToPreviousResult:+ () =>+ ({ chain }) => {+ const { selectedIndex, results } = this.storage;+ if (results.length <= 0) return false;++ let prevIndex = selectedIndex - 1;+ if (isNaN(prevIndex) || prevIndex < 0) prevIndex = results.length - 1;++ const { from, to } = results[prevIndex];+ const result = chain()+ .focus(undefined, { scrollIntoView: true })+ .setTextSelection({ from, to })+ .run();++ if (result) this.storage.selectedIndex = prevIndex;+ return result;+ },+ replace:+ (term) =>+ ({ commands, tr, dispatch }) => {+ const { selectedIndex, results } = this.storage;++ if (!dispatch || results.length <= 0) return false;++ const index = selectedIndex === undefined ? 0 : selectedIndex;+ const { from, to } = results[index];++ tr.insertText(term, from, to);++ if (index + 1 < results.length) {+ const { from, to } = results[index + 1];+ const nextResult = (results[index + 1] = {+ from: tr.mapping.map(from),+ to: tr.mapping.map(to),+ });++ commands.focus();+ tr.setSelection(+ new TextSelection(+ tr.doc.resolve(nextResult.from),+ tr.doc.resolve(nextResult.to)+ )+ );+ }+ dispatch(tr);+ results.splice(index, 1);+ return true;+ },+ replaceAll:+ (term) =>+ ({ state, tr, dispatch }) => {+ if (!dispatch) return false;+ const { selectedIndex, results } = this.storage;+ dispatch(replaceAll(term, results, tr));+ return true;+ },+ };+ },++ addKeyboardShortcuts() {+ return {+ "Mod-f": ({ editor }) => editor.commands.startSearch(),+ Escape: ({ editor }) => editor.commands.endSearch(),+ };+ },++ addProseMirrorPlugins() {+ return [+ new Plugin({+ key: new PluginKey("searchreplace"),+ state: {+ init() {+ return DecorationSet.empty;+ },+ apply: ({ doc, docChanged, setSelection }) => {+ const { searchTerm, enableRegex, matchCase, matchWholeWord } =+ this.storage;+ const { searchResultClass } = this.options;++ if (docChanged || searchTerm) {+ const searchRegex = searchTerm+ ? regex(searchTerm, { enableRegex, matchCase, matchWholeWord })+ : undefined;+ const { decorationSet, results } = searchDocument(+ doc,+ searchResultClass,+ searchRegex+ );+ this.storage.results = results;++ return decorationSet;+ }+ return DecorationSet.empty;+ },+ },+ props: {+ decorations(state) {+ return this.getState(state);+ },+ },+ }),+ ];+ },+});diff --git a/packages/editor/src/index.ts b/packages/editor/src/index.tsindex 188d991f0..4779a115d 100644--- a/packages/editor/src/index.ts+++ b/packages/editor/src/index.ts@@ -29,6 +29,7 @@ import { AttachmentNode, AttachmentOptions } from "./extensions/attachment";import { TaskListNode } from "./extensions/task-list";import { TaskItemNode } from "./extensions/task-item";import { Dropcursor } from "./extensions/drop-cursor";+import { SearchReplace } from "./extensions/search-replace";EditorView.prototype.updateState = function updateState(state) {if (!(this as any).docView) return; // This prevents the matchesNode error on hot reloads@@ -51,6 +52,7 @@ const useTiptap = (const defaultOptions = useMemo<Partial<EditorOptions>>(() => ({extensions: [+ SearchReplace,TextStyle,StarterKit.configure({dropcursor: false,diff --git a/packages/editor/src/toolbar/floating-menus/index.tsx b/packages/editor/src/toolbar/floating-menus/index.tsxindex 2f6cbcc1e..bab012c96 100644--- a/packages/editor/src/toolbar/floating-menus/index.tsx+++ b/packages/editor/src/toolbar/floating-menus/index.tsx@@ -1,4 +1,5 @@import { TableRowFloatingMenu, TableColumnFloatingMenu } from "./table";+import { SearchReplaceFloatingMenu } from "./search-replace";import { FloatingMenuProps } from "./types";export function EditorFloatingMenus(props: FloatingMenuProps) {@@ -6,6 +7,7 @@ export function EditorFloatingMenus(props: FloatingMenuProps) {<><TableRowFloatingMenu {...props} /><TableColumnFloatingMenu {...props} />+ <SearchReplaceFloatingMenu {...props} /></>);}diff --git a/packages/editor/src/toolbar/floating-menus/search-replace.tsx b/packages/editor/src/toolbar/floating-menus/search-replace.tsxnew file mode 100644index 000000000..e9123b27f--- /dev/null+++ b/packages/editor/src/toolbar/floating-menus/search-replace.tsx@@ -0,0 +1,177 @@+import { Input } from "@rebass/forms";+import { useCallback, useEffect, useRef, useState } from "react";+import { Flex } from "rebass";+import { MenuPresenter } from "../../components/menu/menu";+import { SearchStorage } from "../../extensions/search-replace";+import { Popup } from "../components/popup";+import { ToolButton } from "../components/tool-button";+import { FloatingMenuProps } from "./types";++export function SearchReplaceFloatingMenu(props: FloatingMenuProps) {+ const { editor } = props;+ const { isSearching, selectedText } = editor.storage+ .searchreplace as SearchStorage;++ const [matchCase, setMatchCase] = useState(false);+ const [matchWholeWord, setMatchWholeWord] = useState(false);+ const [enableRegex, setEnableRegex] = useState(false);+ const replaceText = useRef("");+ const searchText = useRef("");++ const search = useCallback(+ (term: string) => {+ editor.commands.search(term, {+ matchCase,+ enableRegex,+ matchWholeWord,+ });+ },+ [matchCase, enableRegex, matchWholeWord]+ );++ useEffect(() => {+ search(searchText.current);+ }, [search, matchCase, matchWholeWord, enableRegex]);++ useEffect(() => {+ if (isSearching && selectedText) search(selectedText);+ }, [isSearching, selectedText, search]);++ if (!isSearching) return null;+ return (+ <MenuPresenter+ isOpen+ items={[]}+ onClose={() => {}}+ options={{+ type: "autocomplete",+ position: {+ target:+ document.querySelector<HTMLElement>(".editor-toolbar") || "mouse",+ isTargetAbsolute: true,+ location: "below",+ align: "end",+ },+ }}+ >+ <Popup>+ <Flex sx={{ p: 1, flexDirection: "column" }}>+ <Flex sx={{ alignItems: "start", flexShrink: 0 }}>+ <Flex+ sx={{+ position: "relative",+ mr: 1,+ width: 200,+ alignItems: "center",+ }}+ >+ <Input+ defaultValue={selectedText}+ autoFocus+ sx={{ p: 1 }}+ placeholder="Find"+ onChange={(e) => {+ searchText.current = e.target.value;+ search(searchText.current);+ }}+ />+ <Flex+ sx={{+ position: "absolute",+ right: 0,+ mr: 0,+ }}+ >+ <ToolButton+ sx={{+ mr: 0,+ }}+ toggled={matchCase}+ title="Match case"+ id="matchCase"+ icon="caseSensitive"+ onClick={() => setMatchCase((s) => !s)}+ iconSize={14}+ />+ <ToolButton+ sx={{+ mr: 0,+ }}+ toggled={matchWholeWord}+ title="Match whole word"+ id="matchWholeWord"+ icon="wholeWord"+ onClick={() => setMatchWholeWord((s) => !s)}+ iconSize={14}+ />+ <ToolButton+ sx={{+ mr: 0,+ }}+ toggled={enableRegex}+ title="Enable regex"+ id="enableRegex"+ icon="regex"+ onClick={() => setEnableRegex((s) => !s)}+ iconSize={14}+ />+ </Flex>+ </Flex>+ <ToolButton+ toggled={false}+ title="Previous match"+ id="previousMatch"+ icon="previousMatch"+ onClick={() => editor.commands.moveToPreviousResult()}+ sx={{ mr: 0 }}+ iconSize={16}+ />+ <ToolButton+ toggled={false}+ title="Next match"+ id="nextMatch"+ icon="nextMatch"+ onClick={() => editor.commands.moveToNextResult()}+ sx={{ mr: 0 }}+ iconSize={16}+ />+ <ToolButton+ toggled={false}+ title="Close"+ id="close"+ icon="close"+ onClick={() => editor.chain().focus().endSearch().run()}+ iconSize={16}+ sx={{ mr: 0 }}+ />+ </Flex>+ <Flex sx={{ alignItems: "start", flexShrink: 0, mt: 1 }}>+ <Input+ sx={{ p: 1, width: 200, mr: 1 }}+ placeholder="Replace"+ onChange={(e) => (replaceText.current = e.target.value)}+ />+ <ToolButton+ toggled={false}+ title="Replace"+ id="replace"+ icon="replaceOne"+ onClick={() => editor.commands.replace(replaceText.current)}+ sx={{ mr: 0 }}+ iconSize={16}+ />+ <ToolButton+ toggled={false}+ title="Replace all"+ id="replaceAll"+ icon="replaceAll"+ onClick={() => editor.commands.replaceAll(replaceText.current)}+ sx={{ mr: 0 }}+ iconSize={16}+ />+ </Flex>+ </Flex>+ </Popup>+ </MenuPresenter>+ );+}diff --git a/packages/editor/src/toolbar/icons.ts b/packages/editor/src/toolbar/icons.tsindex 99d64b834..2143fddbb 100644--- a/packages/editor/src/toolbar/icons.ts+++ b/packages/editor/src/toolbar/icons.ts@@ -56,6 +56,25 @@ import {mdiDrag,mdiCheckboxMarkedOutline,mdiChevronUp,+ mdiArrowUp,+ mdiArrowDown,+ mdiText,+ mdiTextBoxMultipleOutline,+ mdiTextBoxOutline,+ mdiAllInclusiveBoxOutline,+ mdiSetAll,+ mdiArrowCollapseAll,+ mdiArrowExpandAll,+ mdiClipboardMultipleOutline,+ mdiBackspaceReverseOutline,+ mdiRepeat,+ mdiRepeatOnce,+ mdiRepeatVariant,+ mdiCaseSensitiveAlt,+ mdiRegex,+ mdiFormatFont,+ mdiFormatLetterCase,+ mdiFormatLetterMatches,} from "@mdi/js";export const Icons = {@@ -110,6 +129,15 @@ export const Icons = {splitCells: mdiTableSplitCell,checklist: mdiFormatListCheckbox,dragHandle: mdiDrag,+ previousMatch: mdiArrowUp,+ nextMatch: mdiArrowDown,+ replaceOne:+ "m5.4 5.42 3.48 3.5 3.43-3.43-1.08-1.08-1.57 1.55V3.5a.8.8 0 0 1 .76-.81h2.35v-1.5h-2.35a2.29 2.29 0 0 0-2.28 2.3v2.5L6.48 4.33Zm10.3 2.77c.3.48.7.72 1.25.72.61 0 1.1-.26 1.45-.78.37-.51.55-1.2.55-2.05 0-.8-.15-1.41-.46-1.87a1.51 1.51 0 0 0-1.33-.68c-.63 0-1.11.3-1.45.9h-.02V1.19h-1.37v7.6h1.37v-.6Zm-.03-1.64v-.52c0-.39.09-.7.27-.93a.83.83 0 0 1 .69-.36.76.76 0 0 1 .67.36c.16.24.24.57.24 1 0 .5-.09.9-.26 1.18a.8.8 0 0 1-.73.42.76.76 0 0 1-.63-.33 1.32 1.32 0 0 1-.25-.82zm-1.35 12.82c-.4.23-.97.35-1.71.35-.87 0-1.58-.27-2.12-.82a2.9 2.9 0 0 1-.8-2.12c0-1 .28-1.8.86-2.37a3.12 3.12 0 0 1 2.31-.87c.67 0 1.16.1 1.46.28v1.54a1.95 1.95 0 0 0-1.23-.42c-.5 0-.9.15-1.2.46-.29.3-.43.72-.43 1.26 0 .52.14.93.42 1.23.28.3.67.44 1.16.44.43 0 .86-.14 1.28-.43zm-7.73-8.91L5.05 12v9.27l1.54 1.54h10.82l1.54-1.54V12l-1.54-1.54zm0 1.54h10.82v9.27H6.59Z",+ replaceAll:+ "M16.53 4.22c.22-.45.52-.68.92-.68.36 0 .64.17.83.52.2.34.3.81.3 1.4a3.1 3.1 0 0 1-.35 1.57c-.22.39-.53.59-.91.59-.35 0-.61-.19-.79-.55h-.01v.45h-.87V1.77h.87v2.45h.01zm-.02 1.6a1.14 1.14 0 0 0 .15.63c.1.17.24.25.4.25.2 0 .35-.1.46-.32a2 2 0 0 0 .17-.9c0-.32-.05-.57-.15-.75-.1-.18-.24-.27-.43-.27-.17 0-.32.09-.43.27a1.3 1.3 0 0 0-.17.7ZM5.6 11.56l-3.1-3.1.97-.97 1.47 1.46v-2.2A2.03 2.03 0 0 1 6.96 4.7h3.43v1.32H6.96a.72.72 0 0 0-.68.73l.01 2.19 1.39-1.38.96.96-3.04 3.04Zm7.65-4.04h.94v-2.5c0-1.18-.46-1.78-1.38-1.78-.2 0-.41.04-.66.1a2.11 2.11 0 0 0-.56.25v.97c.34-.3.71-.44 1.1-.44.38 0 .57.23.57.68l-.88.16c-.74.12-1.11.59-1.11 1.4 0 .38.09.7.27.92a.9.9 0 0 0 .74.35c.42 0 .74-.24.96-.7h.01zm0-1.98v.28a1.1 1.1 0 0 1-.17.64.54.54 0 0 1-.46.25.4.4 0 0 1-.32-.14.56.56 0 0 1-.11-.36c0-.33.16-.51.48-.57l.59-.1zM9.82 19.21h-.94v-.6h-.02c-.21.46-.53.7-.96.7a.9.9 0 0 1-.74-.35 1.47 1.47 0 0 1-.27-.92c0-.8.38-1.28 1.12-1.4l.87-.15c0-.46-.19-.69-.57-.69-.38 0-.75.15-1.1.45v-.98c.14-.09.33-.17.57-.24.24-.07.46-.1.66-.1.92 0 1.38.59 1.38 1.78zm-.94-1.7v-.29l-.58.1c-.33.06-.49.25-.49.57 0 .15.04.27.12.36a.4.4 0 0 0 .32.14.54.54 0 0 0 .46-.25c.11-.17.17-.38.17-.63zm4.24 1.8c.47 0 .83-.09 1.08-.26v-1.03a1.32 1.32 0 0 1-.8.3.9.9 0 0 1-.74-.31c-.17-.22-.26-.5-.26-.88s.1-.68.28-.9a.94.94 0 0 1 .75-.32c.28 0 .54.1.77.3v-1.1c-.19-.12-.5-.19-.91-.19-.61 0-1.1.2-1.47.62-.36.4-.54.97-.54 1.68 0 .61.17 1.11.5 1.5.35.4.8.59 1.34.59zM2.5 13.46 3.96 12h13.16l1.46 1.46v7.3l-1.46 1.47H3.96L2.5 20.77Zm1.46 0v7.3h13.16v-7.3Zm4.39-2.92L9.8 9.08h10.23l1.46 1.46v7.3l-1.46 1.47v-8.77z",+ caseSensitive: mdiFormatLetterCase,+ wholeWord: mdiFormatLetterMatches,+ regex: mdiRegex,plus: mdiPlus,close: mdiClose,diff --git a/packages/editor/src/toolbar/toolbar.tsx b/packages/editor/src/toolbar/toolbar.tsxindex 005abc10c..06e7c7d1a 100644--- a/packages/editor/src/toolbar/toolbar.tsx+++ b/packages/editor/src/toolbar/toolbar.tsx@@ -41,7 +41,7 @@ export function Toolbar(props: ToolbarProps) {if (!editor) return null;return (<ThemeProvider theme={themeProperties}>- <Flex sx={{ flexWrap: "wrap" }}>+ <Flex className="editor-toolbar" sx={{ flexWrap: "wrap" }}>{tools.map((tools) => {return (<Flexdiff --git a/packages/editor/tsconfig.json b/packages/editor/tsconfig.jsonindex 87fc5c90b..e928ccb25 100644--- a/packages/editor/tsconfig.json+++ b/packages/editor/tsconfig.json@@ -56,7 +56,7 @@// "noEmit": true, /* Disable emitting files from a compilation. */// "importHelpers": true, /* Allow importing helper functions from tslib once per project, instead of including them per-file. */// "importsNotUsedAsValues": "remove", /* Specify emit/checking behavior for imports that are only used for types */- // "downlevelIteration": true, /* Emit more compliant, but verbose and less performant JavaScript for iteration. */+ "downlevelIteration": true /* Emit more compliant, but verbose and less performant JavaScript for iteration. */,// "sourceRoot": "", /* Specify the root path for debuggers to find the reference source code. */// "mapRoot": "", /* Specify the location where debugger should locate map files instead of generated locations. */// "inlineSourceMap": true, /* Include sourcemap files inside the emitted JavaScript. */