rme 0.3.0-beta.39 → 0.3.0-beta.40

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.d.ts CHANGED
@@ -1,9 +1,10 @@
1
1
  import * as _drl990114_codemirror_themes from '@drl990114/codemirror-themes';
2
2
  import { CreateThemeOptions } from '@drl990114/codemirror-themes';
3
3
  export { CreateThemeOptions, createTheme } from '@drl990114/codemirror-themes';
4
+ import * as _codemirror_state from '@codemirror/state';
5
+ import { Compartment, Extension, StateField } from '@codemirror/state';
4
6
  import { LanguageSupport, LanguageDescription } from '@codemirror/language';
5
- import { Compartment, Extension } from '@codemirror/state';
6
- import { EditorView, EditorViewConfig } from '@codemirror/view';
7
+ import { EditorView, EditorViewConfig, ViewPlugin, DecorationSet, ViewUpdate } from '@codemirror/view';
7
8
  import { ProsemirrorNode, EditorView as EditorView$1 } from '@rme-sdk/pm';
8
9
  import * as react from 'react';
9
10
  import react__default, { CSSProperties, ComponentType, ReactNode, MouseEvent, JSX, FC } from 'react';
@@ -67,8 +68,30 @@ declare const defaultCommandShortcutMap: {
67
68
 
68
69
  type CustomCopyFunction = (code: string) => Promise<boolean> | boolean;
69
70
 
71
+ declare const cmInstanceMap: Map<string, MfCodemirrorView>;
70
72
  declare const changeTheme: (theme: CreateThemeOptions) => void;
71
73
  declare const extractMatches: (view: EditorView) => any[];
74
+ interface SearchData {
75
+ ranges?: Array<{
76
+ from: number;
77
+ to: number;
78
+ }>;
79
+ curIndex?: number | null;
80
+ }
81
+ declare const cmSearchEffects: _codemirror_state.StateEffectType<SearchData>;
82
+ interface SearchState {
83
+ ranges: Array<{
84
+ from: number;
85
+ to: number;
86
+ }>;
87
+ curIndex: number | null;
88
+ }
89
+ declare const cmSearchField: StateField<SearchState>;
90
+ declare const cmSearchDecorations: ViewPlugin<{
91
+ decorations: DecorationSet;
92
+ update(update: ViewUpdate): void;
93
+ buildDecorations(view: EditorView): DecorationSet;
94
+ }, undefined>;
72
95
  type CreateCodemirrorOptions = {
73
96
  /**
74
97
  * when it is true, undo and redo will use prosemirror view.
@@ -112,13 +135,15 @@ declare class MfCodemirrorView {
112
135
  options?: CreateCodemirrorOptions;
113
136
  private copyButton;
114
137
  private copyButtonContainer;
115
- constructor({ view, getPos, node, extensions, languageName, options, }: {
138
+ private parentEditorId;
139
+ constructor({ view, getPos, node, extensions, languageName, options, editorId, }: {
116
140
  node: ProsemirrorNode;
117
141
  view: EditorView$1;
118
142
  getPos: () => number;
119
143
  extensions?: Extension[] | null;
120
144
  languageName: string;
121
145
  options?: CreateCodemirrorOptions;
146
+ editorId?: string;
122
147
  });
123
148
  update(node: ProsemirrorNode): boolean;
124
149
  setSelection(anchor: number, head: number): void;
@@ -953,5 +978,5 @@ type WysiwygToolbarProps = {
953
978
  };
954
979
  declare const WysiwygToolbar: FC<WysiwygToolbarProps>;
955
980
 
956
- export { CommandButton, CommandButtonIcon, Editor, extensions as EditorExtensions, EditorViewType, HtmlImageExtension, LineListExtension, MarkdownNodeExtension, MdImgUriExtension, MfCodemirrorView, Preview, SourceCodeThemeWrapper, _default$1 as SourceEditor, ThemeProvider, _default as WysiwygEditor, WysiwygThemeWrapper, WysiwygToolbar, alwaysTrue, buildMarkdownParser, buildMarkdownSerializer, changeTheme, common, computeChange, createSourceCodeDelegate, createSourceCodeManager, createWysiwygDelegate, darkTheme, defaultStyleToken, extractMatches, getLanguageMap, isImageFileType, isOrderedListNode, lightTheme, loadLanguage, tableSelectorSize };
957
- export type { CommandButtonIconProps, CommandButtonProps, CreateCodemirrorOptions, CreateWysiwygDelegateOptions, DelayedImage$1 as DelayedImage, DocToString, EditorChangeEventParams, EditorChangeHandler, EditorContext, EditorDelegate, EditorProps, EditorRef, EditorState, ExtensionsOptions, FileWithProgress$1 as FileWithProgress, HTMLAstNode, ImageAttributes, ImageExtensionAttributes, ImageOptions, Note, StringToDoc, WysiwygToolbarProps };
981
+ export { CommandButton, CommandButtonIcon, Editor, extensions as EditorExtensions, EditorViewType, HtmlImageExtension, LineListExtension, MarkdownNodeExtension, MdImgUriExtension, MfCodemirrorView, Preview, SourceCodeThemeWrapper, _default$1 as SourceEditor, ThemeProvider, _default as WysiwygEditor, WysiwygThemeWrapper, WysiwygToolbar, alwaysTrue, buildMarkdownParser, buildMarkdownSerializer, changeTheme, cmInstanceMap, cmSearchDecorations, cmSearchEffects, cmSearchField, common, computeChange, createSourceCodeDelegate, createSourceCodeManager, createWysiwygDelegate, darkTheme, defaultStyleToken, extractMatches, getLanguageMap, isImageFileType, isOrderedListNode, lightTheme, loadLanguage, tableSelectorSize };
982
+ export type { CommandButtonIconProps, CommandButtonProps, CreateCodemirrorOptions, CreateWysiwygDelegateOptions, DelayedImage$1 as DelayedImage, DocToString, EditorChangeEventParams, EditorChangeHandler, EditorContext, EditorDelegate, EditorProps, EditorRef, EditorState, ExtensionsOptions, FileWithProgress$1 as FileWithProgress, HTMLAstNode, ImageAttributes, ImageExtensionAttributes, ImageOptions, Note, SearchState, StringToDoc, WysiwygToolbarProps };
package/dist/index.mjs CHANGED
@@ -18,8 +18,8 @@ import {
18
18
  ensureSyntaxTree
19
19
  } from "@codemirror/language";
20
20
  import { languages } from "@codemirror/language-data";
21
- import { EditorState as CodeMirrorEditorState, Compartment } from "@codemirror/state";
22
- import { EditorView as CodeMirrorEditorView, keymap } from "@codemirror/view";
21
+ import { EditorState as CodeMirrorEditorState, Compartment, StateEffect, StateField } from "@codemirror/state";
22
+ import { EditorView as CodeMirrorEditorView, Decoration, keymap, ViewPlugin } from "@codemirror/view";
23
23
  import { assertGet, isPromise, replaceNodeAtPosition } from "@rme-sdk/core";
24
24
  import { exitCode } from "@rme-sdk/pm/commands";
25
25
  import { redo as redo2, undo as undo2 } from "@rme-sdk/pm/history";
@@ -1666,6 +1666,18 @@ var WysiwygThemeWrapper = styled.div.attrs((p) => ({
1666
1666
  background-color: transparent;
1667
1667
  }
1668
1668
 
1669
+ .rme-find-decoration,
1670
+ .cm-search-match {
1671
+ background-color: yellow;
1672
+ color: #222;
1673
+ }
1674
+
1675
+ .rme-find-active-decoration,
1676
+ .cm-search-active {
1677
+ background-color: orange;
1678
+ color: #222;
1679
+ }
1680
+
1669
1681
  & .html-image-node-view-wrapper,
1670
1682
  & .md-image-node-view-wrapper {
1671
1683
  display: inline-flex;
@@ -1833,6 +1845,16 @@ var SourceCodeThemeWrapper = styled2.div.attrs((p) => ({
1833
1845
  }
1834
1846
  }
1835
1847
 
1848
+ .cm-search-match {
1849
+ background-color: yellow;
1850
+ color: #222;
1851
+ }
1852
+
1853
+ .cm-search-active {
1854
+ background-color: orange;
1855
+ color: #222;
1856
+ }
1857
+
1836
1858
  ${(props) => props.dark && css3`
1837
1859
  color-scheme: dark;
1838
1860
  `}
@@ -1896,6 +1918,85 @@ var extractMatches = (view) => {
1896
1918
  });
1897
1919
  return matches;
1898
1920
  };
1921
+ var cmSearchEffects = StateEffect.define({
1922
+ map: (value, mapping) => {
1923
+ if (!value.ranges) return value;
1924
+ const mappedRanges = value.ranges.map((range) => ({
1925
+ from: mapping.mapPos(range.from),
1926
+ to: mapping.mapPos(range.to)
1927
+ }));
1928
+ return {
1929
+ ranges: mappedRanges,
1930
+ curIndex: value.curIndex !== void 0 ? value.curIndex : void 0
1931
+ };
1932
+ }
1933
+ });
1934
+ var SEARCH_MATCH_CLASS = "cm-search-match";
1935
+ var SEARCH_ACTIVE_CLASS = "cm-search-active";
1936
+ var cmSearchField = StateField.define({
1937
+ create(state) {
1938
+ return {
1939
+ ranges: [],
1940
+ curIndex: null
1941
+ };
1942
+ },
1943
+ update(value, tr) {
1944
+ let ranges = value.ranges;
1945
+ let curIndex = value.curIndex;
1946
+ for (const effect of tr.effects) {
1947
+ if (effect.is(cmSearchEffects)) {
1948
+ if (effect.value.ranges !== void 0) {
1949
+ ranges = effect.value.ranges;
1950
+ }
1951
+ if ("curIndex" in effect.value) {
1952
+ curIndex = effect.value.curIndex ?? null;
1953
+ }
1954
+ }
1955
+ }
1956
+ ranges = ranges.map((range) => ({
1957
+ from: tr.changes.mapPos(range.from),
1958
+ to: tr.changes.mapPos(range.to)
1959
+ }));
1960
+ return { ranges, curIndex };
1961
+ }
1962
+ });
1963
+ var cmSearchDecorations = ViewPlugin.fromClass(
1964
+ class {
1965
+ constructor(view) {
1966
+ this.decorations = this.buildDecorations(view);
1967
+ }
1968
+ update(update) {
1969
+ if (update.docChanged || update.state.field(cmSearchField, false)) {
1970
+ this.decorations = this.buildDecorations(update.view);
1971
+ }
1972
+ }
1973
+ buildDecorations(view) {
1974
+ let searchState;
1975
+ try {
1976
+ searchState = view.state.field(cmSearchField, false);
1977
+ } catch (e) {
1978
+ return Decoration.none;
1979
+ }
1980
+ if (!searchState || !searchState.ranges.length) {
1981
+ return Decoration.none;
1982
+ }
1983
+ const { ranges, curIndex } = searchState;
1984
+ const widgets = [];
1985
+ console.log("searchState", searchState);
1986
+ ranges.forEach((range, index) => {
1987
+ const isCurrent = curIndex !== null && curIndex !== void 0 && curIndex === index;
1988
+ const decoration = Decoration.mark({
1989
+ class: isCurrent ? `${SEARCH_MATCH_CLASS} ${SEARCH_ACTIVE_CLASS}` : SEARCH_MATCH_CLASS
1990
+ });
1991
+ widgets.push(decoration.range(range.from, range.to));
1992
+ });
1993
+ return Decoration.set(widgets);
1994
+ }
1995
+ },
1996
+ {
1997
+ decorations: (v) => v.decorations
1998
+ }
1999
+ );
1899
2000
  var MfCodemirrorView = class {
1900
2001
  constructor({
1901
2002
  view,
@@ -1903,7 +2004,8 @@ var MfCodemirrorView = class {
1903
2004
  node,
1904
2005
  extensions: extensions2 = [],
1905
2006
  languageName,
1906
- options = {}
2007
+ options = {},
2008
+ editorId
1907
2009
  }) {
1908
2010
  this.toggleName = "paragraph";
1909
2011
  this.id = nanoid();
@@ -1911,6 +2013,7 @@ var MfCodemirrorView = class {
1911
2013
  this.updating = false;
1912
2014
  this.copyButton = null;
1913
2015
  this.copyButtonContainer = null;
2016
+ this.parentEditorId = null;
1914
2017
  this.view = view;
1915
2018
  this.getPos = getPos;
1916
2019
  this.node = node;
@@ -1920,6 +2023,7 @@ var MfCodemirrorView = class {
1920
2023
  this.languageName = languageName;
1921
2024
  this.loadLanguage = loadLanguage;
1922
2025
  this.options = options;
2026
+ this.parentEditorId = editorId || null;
1923
2027
  this.content = this.node.textContent;
1924
2028
  const changeFilter = CodeMirrorEditorState.changeFilter.of((tr) => {
1925
2029
  if (!tr.docChanged) {
@@ -1934,6 +2038,8 @@ var MfCodemirrorView = class {
1934
2038
  changeFilter,
1935
2039
  this.languageConf.of([]),
1936
2040
  this.editorTheme.of(themeRef.current),
2041
+ cmSearchField,
2042
+ cmSearchDecorations,
1937
2043
  ...extensions2 ?? []
1938
2044
  ]
1939
2045
  });
@@ -2479,7 +2585,7 @@ import {
2479
2585
  setBlockType as setBlockType3
2480
2586
  } from "@rme-sdk/core";
2481
2587
  import { TextSelection as TextSelection12 } from "@rme-sdk/pm/state";
2482
- import { Decoration as Decoration8, DecorationSet as DecorationSet6 } from "@rme-sdk/pm/view";
2588
+ import { Decoration as Decoration9, DecorationSet as DecorationSet7 } from "@rme-sdk/pm/view";
2483
2589
 
2484
2590
  // src/editor/transform/parser.ts
2485
2591
  import { Mark } from "@rme-sdk/pm/model";
@@ -3583,7 +3689,7 @@ import { PlainExtension } from "@rme-sdk/core";
3583
3689
  // src/editor/extensions/Table/table-selector.ts
3584
3690
  import { cx } from "@rme-sdk/core";
3585
3691
  import { isCellSelection, TableMap as TableMap3 } from "@rme-sdk/pm/tables";
3586
- import { Decoration, DecorationSet } from "@rme-sdk/pm/view";
3692
+ import { Decoration as Decoration2, DecorationSet as DecorationSet2 } from "@rme-sdk/pm/view";
3587
3693
 
3588
3694
  // src/editor/utils/dom.ts
3589
3695
  import { getDocument, getId } from "@ocavue/utils";
@@ -3843,11 +3949,11 @@ function createSelectorDecorations(state) {
3843
3949
  const { doc, selection } = state;
3844
3950
  const table = findTable(selection);
3845
3951
  if (!table) {
3846
- return DecorationSet.empty;
3952
+ return DecorationSet2.empty;
3847
3953
  }
3848
3954
  const map = TableMap3.get(table.node);
3849
3955
  if (!map.map.length) {
3850
- return DecorationSet.empty;
3956
+ return DecorationSet2.empty;
3851
3957
  }
3852
3958
  const decos = [];
3853
3959
  const selectionType = isCellSelection(selection) ? getCellSelectionType(selection) : null;
@@ -3877,7 +3983,7 @@ function createSelectorDecorations(state) {
3877
3983
  };
3878
3984
  const cornerCell = getCellsInRect(selection, { top: 0, bottom: 1, left: 0, right: 1 })[0];
3879
3985
  decos.push(
3880
- Decoration.widget(
3986
+ Decoration2.widget(
3881
3987
  cornerCell.pos + 1,
3882
3988
  (view, getPos) => createBodySelector(view, getPos, selectionType === "table"),
3883
3989
  spec
@@ -3886,7 +3992,7 @@ function createSelectorDecorations(state) {
3886
3992
  getCellsInColumn(selection, 0).forEach((cell, rowIndex) => {
3887
3993
  const highlight = rowIndex >= minHighlightRow && rowIndex <= maxHighlightRow;
3888
3994
  decos.push(
3889
- Decoration.widget(
3995
+ Decoration2.widget(
3890
3996
  cell.pos + 1,
3891
3997
  (view, getPos) => createRowSelector(view, getPos, highlight),
3892
3998
  spec
@@ -3896,14 +4002,14 @@ function createSelectorDecorations(state) {
3896
4002
  getCellsInRow(selection, 0).forEach((cell, colIndex) => {
3897
4003
  const highlight = colIndex >= minHighlightCol && colIndex <= maxHighlightCol;
3898
4004
  decos.push(
3899
- Decoration.widget(
4005
+ Decoration2.widget(
3900
4006
  cell.pos + 1,
3901
4007
  (view, getPos) => createColumnSelector(view, getPos, highlight),
3902
4008
  spec
3903
4009
  )
3904
4010
  );
3905
4011
  });
3906
- return DecorationSet.create(doc, decos);
4012
+ return DecorationSet2.create(doc, decos);
3907
4013
  }
3908
4014
 
3909
4015
  // src/editor/extensions/Table/table-selector-extension.ts
@@ -4914,7 +5020,7 @@ import {
4914
5020
  extension as extension3,
4915
5021
  PlainExtension as PlainExtension3
4916
5022
  } from "@rme-sdk/core";
4917
- import { Decoration as Decoration2, DecorationSet as DecorationSet2 } from "@rme-sdk/pm/view";
5023
+ import { Decoration as Decoration3, DecorationSet as DecorationSet3 } from "@rme-sdk/pm/view";
4918
5024
  import escapeStringRegex from "escape-string-regexp";
4919
5025
  import matchAll from "string.prototype.matchall";
4920
5026
 
@@ -4943,6 +5049,7 @@ var FindExtension = class extends PlainExtension3 {
4943
5049
  return this.stopFind();
4944
5050
  }
4945
5051
  this.setProps({ query, activeIndex, caseSensitive });
5052
+ this.syncSearchToCodeMirror(query, activeIndex);
4946
5053
  return ({ tr, dispatch }) => this.updateView(tr, dispatch);
4947
5054
  };
4948
5055
  /**
@@ -4952,6 +5059,14 @@ var FindExtension = class extends PlainExtension3 {
4952
5059
  return ({ tr, dispatch }) => {
4953
5060
  this._query = "";
4954
5061
  this._activeIndex = void 0;
5062
+ cmInstanceMap.forEach((cmInstance) => {
5063
+ cmInstance.cm.dispatch({
5064
+ effects: cmSearchEffects.of({
5065
+ ranges: [],
5066
+ curIndex: void 0
5067
+ })
5068
+ });
5069
+ });
4955
5070
  return this.updateView(tr, dispatch);
4956
5071
  };
4957
5072
  };
@@ -5032,7 +5147,7 @@ var FindExtension = class extends PlainExtension3 {
5032
5147
  return {
5033
5148
  state: {
5034
5149
  init() {
5035
- return DecorationSet2.empty;
5150
+ return DecorationSet3.empty;
5036
5151
  },
5037
5152
  apply: (tr, old) => {
5038
5153
  if (this._updating || tr.docChanged && this.options.alwaysFind) {
@@ -5040,9 +5155,17 @@ var FindExtension = class extends PlainExtension3 {
5040
5155
  this._ranges = this.gatherFindResults(doc);
5041
5156
  this.normalizeActiveIndex();
5042
5157
  this.scrollToActiveResult();
5158
+ if (this._query) {
5159
+ this.syncSearchToCodeMirror(this._query, this._activeIndex);
5160
+ }
5043
5161
  return this.createDecorationSet(doc);
5044
5162
  }
5045
5163
  if (tr.docChanged) {
5164
+ if (this._query && this.options.alwaysFind) {
5165
+ this._ranges = this.gatherFindResults(tr.doc);
5166
+ this.normalizeActiveIndex();
5167
+ this.syncSearchToCodeMirror(this._query, this._activeIndex);
5168
+ }
5046
5169
  return old.map(tr.mapping, tr.doc);
5047
5170
  }
5048
5171
  return old;
@@ -5069,6 +5192,30 @@ var FindExtension = class extends PlainExtension3 {
5069
5192
  const re = new RegExp(this._query, this._caseSensitive ? "gu" : "gui");
5070
5193
  const ranges = [];
5071
5194
  doc.descendants((node, pos) => {
5195
+ if (node.type.name === "codeMirror") {
5196
+ let codeContent = node.textContent;
5197
+ for (const [id, cmView] of Array.from(cmInstanceMap.entries())) {
5198
+ if (cmView.node && cmView.node.eq(node)) {
5199
+ try {
5200
+ codeContent = cmView.cm.state.doc.toString();
5201
+ } catch (e) {
5202
+ codeContent = node.textContent;
5203
+ }
5204
+ break;
5205
+ }
5206
+ }
5207
+ for (const match of matchAll(codeContent, re)) {
5208
+ const from = pos + 2 + (match.index ?? 0);
5209
+ const to = from + match[0].length;
5210
+ const nodeEnd = pos + node.nodeSize;
5211
+ const boundedFrom = Math.min(from, nodeEnd);
5212
+ const boundedTo = Math.min(to, nodeEnd);
5213
+ if (boundedFrom < boundedTo) {
5214
+ ranges.push({ from: boundedFrom, to: boundedTo });
5215
+ }
5216
+ }
5217
+ return false;
5218
+ }
5072
5219
  if (!node.isTextblock) {
5073
5220
  return true;
5074
5221
  }
@@ -5102,13 +5249,13 @@ var FindExtension = class extends PlainExtension3 {
5102
5249
  }
5103
5250
  createDecorationSet(doc) {
5104
5251
  const decorations = this._ranges.map(
5105
- (deco, index) => Decoration2.inline(
5252
+ (deco, index) => Decoration3.inline(
5106
5253
  deco.from,
5107
5254
  deco.to,
5108
5255
  index === this._activeIndex ? this.options.activeDecoration : this.options.decoration
5109
5256
  )
5110
5257
  );
5111
- return DecorationSet2.create(doc, decorations);
5258
+ return DecorationSet3.create(doc, decorations);
5112
5259
  }
5113
5260
  /**
5114
5261
  * Dispatch an empty transaction to trigger an update of the decoration.
@@ -5121,6 +5268,65 @@ var FindExtension = class extends PlainExtension3 {
5121
5268
  this._updating = false;
5122
5269
  return true;
5123
5270
  }
5271
+ syncSearchToCodeMirror(query, activeIndex) {
5272
+ const allRanges = this.gatherFindResults(this.store.view.state.doc);
5273
+ const cmRangesMap = /* @__PURE__ */ new Map();
5274
+ allRanges.forEach((range, globalIndex) => {
5275
+ const $pos = this.store.view.state.doc.resolve(range.from);
5276
+ const node = $pos.node();
5277
+ if (node.type.name === "codeMirror") {
5278
+ if (!cmRangesMap.has(node)) {
5279
+ cmRangesMap.set(node, []);
5280
+ }
5281
+ const cmContentStart = range.from - ($pos.start() + 1);
5282
+ const cmContentEnd = range.to - ($pos.start() + 1);
5283
+ const cmDocLength = node.textContent.length;
5284
+ const adjustedFrom = Math.max(0, Math.min(cmContentStart, cmDocLength));
5285
+ const adjustedTo = Math.max(adjustedFrom, Math.min(cmContentEnd, cmDocLength));
5286
+ cmRangesMap.get(node).push({
5287
+ from: adjustedFrom,
5288
+ to: adjustedTo,
5289
+ index: globalIndex
5290
+ // 全局索引
5291
+ });
5292
+ }
5293
+ });
5294
+ const processedNodes = /* @__PURE__ */ new Set();
5295
+ this.store.view.state.doc.descendants((node, pos) => {
5296
+ if (node.type.name === "codeMirror") {
5297
+ const nodeId = `${pos}-${node.textContent.substring(0, 20)}-${node.nodeSize}`;
5298
+ if (processedNodes.has(nodeId)) {
5299
+ return false;
5300
+ }
5301
+ processedNodes.add(nodeId);
5302
+ const cmRanges = cmRangesMap.get(node);
5303
+ if (cmRanges) {
5304
+ for (const [id, cmView] of Array.from(cmInstanceMap.entries())) {
5305
+ if (cmView.node && cmView.node.eq(node)) {
5306
+ let cmActiveIndex = null;
5307
+ if (activeIndex !== void 0 && activeIndex !== null) {
5308
+ const localActiveIndex = cmRanges.findIndex((r) => r.index === activeIndex);
5309
+ if (localActiveIndex !== -1) {
5310
+ cmActiveIndex = localActiveIndex;
5311
+ } else {
5312
+ cmActiveIndex = null;
5313
+ }
5314
+ }
5315
+ cmView.cm.dispatch({
5316
+ effects: cmSearchEffects.of({
5317
+ ranges: cmRanges.map((r) => ({ from: r.from, to: r.to })),
5318
+ curIndex: cmActiveIndex
5319
+ })
5320
+ });
5321
+ break;
5322
+ }
5323
+ }
5324
+ }
5325
+ return false;
5326
+ }
5327
+ return true;
5328
+ });
5329
+ }
5124
5330
  scrollToActiveResult() {
5125
5331
  if (this._activeIndex == null) {
5126
5332
  return;
@@ -5142,8 +5348,8 @@ var FindExtension = class extends PlainExtension3 {
5142
5348
  FindExtension = __decorateClass([
5143
5349
  extension3({
5144
5350
  defaultOptions: {
5145
- decoration: { style: "background-color: yellow;" },
5146
- activeDecoration: { style: "background-color: orange;" },
5351
+ decoration: { style: "background-color: yellow;", class: "rme-find-decoration" },
5352
+ activeDecoration: { style: "background-color: orange;", class: "rme-find-active-decoration" },
5147
5353
  alwaysFind: false
5148
5354
  },
5149
5355
  staticKeys: [],
@@ -8266,7 +8472,7 @@ function isClipboardEvent(event) {
8266
8472
 
8267
8473
  // src/editor/extensions/Inline/inline-deco-extension.ts
8268
8474
  import { isTextSelection as isTextSelection2, PlainExtension as PlainExtension5 } from "@rme-sdk/core";
8269
- import { Decoration as Decoration4, DecorationSet as DecorationSet3 } from "@rme-sdk/pm/view";
8475
+ import { Decoration as Decoration5, DecorationSet as DecorationSet4 } from "@rme-sdk/pm/view";
8270
8476
 
8271
8477
  // src/editor/extensions/Inline/inline-mark-extensions.ts
8272
8478
  import { MarkExtension, extension as extension10 } from "@rme-sdk/core";
@@ -9480,9 +9686,9 @@ function createDecorationPlugin() {
9480
9686
  false
9481
9687
  );
9482
9688
  }
9483
- return DecorationSet3.create(
9689
+ return DecorationSet4.create(
9484
9690
  state.doc,
9485
- posPairs.map(([from, to]) => Decoration4.inline(from, to, { class: "show" }))
9691
+ posPairs.map(([from, to]) => Decoration5.inline(from, to, { class: "show" }))
9486
9692
  );
9487
9693
  }
9488
9694
  }
@@ -10965,6 +11171,10 @@ var NodeIndicatorExtension = class extends PlainExtension7 {
10965
11171
  return true;
10966
11172
  },
10967
11173
  handleDOMEvents: {
11174
+ pointerout: (view, event) => {
11175
+ view.dispatch(view.state.tr.setMeta(pluginKey, { node: null, pos: null }));
11176
+ return false;
11177
+ },
10968
11178
  pointermove: (view, event) => {
10969
11179
  const { x, y } = event;
10970
11180
  const block = findBlockByCoords(view, x, y);
@@ -11031,7 +11241,7 @@ var LineParagraphExtension = class extends ParagraphExtension {
11031
11241
 
11032
11242
  // src/editor/extensions/Placeholder/index.ts
11033
11243
  import { extension as extension14, ManagerPhase, PlainExtension as PlainExtension8 } from "@rme-sdk/core";
11034
- import { Decoration as Decoration6, DecorationSet as DecorationSet4 } from "@rme-sdk/pm/view";
11244
+ import { Decoration as Decoration7, DecorationSet as DecorationSet5 } from "@rme-sdk/pm/view";
11035
11245
  var PlaceholderExtension = class extends PlainExtension8 {
11036
11246
  get name() {
11037
11247
  return "placeholder";
@@ -11069,14 +11279,14 @@ function createDecorationSet(props) {
11069
11279
  const decorations = [];
11070
11280
  state.doc.descendants((node, pos) => {
11071
11281
  if (node.type.name === "paragraph" && node.content.size === 0 && placeholder && state.selection.from - 1 === pos) {
11072
- const placeholderDecoration = Decoration6.node(pos, pos + node.nodeSize, {
11282
+ const placeholderDecoration = Decoration7.node(pos, pos + node.nodeSize, {
11073
11283
  class: emptyNodeClass,
11074
11284
  "data-placeholder": placeholder
11075
11285
  });
11076
11286
  decorations.push(placeholderDecoration);
11077
11287
  }
11078
11288
  });
11079
- return DecorationSet4.create(state.doc, decorations);
11289
+ return DecorationSet5.create(state.doc, decorations);
11080
11290
  }
11081
11291
 
11082
11292
  // src/editor/extensions/Reference/reference-def-extension.tsx
@@ -11088,7 +11298,7 @@ import {
11088
11298
  NodeExtension as NodeExtension12,
11089
11299
  nodeInputRule as nodeInputRule10
11090
11300
  } from "@rme-sdk/core";
11091
- import { Decoration as Decoration7, DecorationSet as DecorationSet5 } from "@rme-sdk/pm/view";
11301
+ import { Decoration as Decoration8, DecorationSet as DecorationSet6 } from "@rme-sdk/pm/view";
11092
11302
  var ReferenceDefinitionExtension = class extends NodeExtension12 {
11093
11303
  get name() {
11094
11304
  return "reference_def";
@@ -11147,10 +11357,10 @@ var ReferenceDefinitionExtension = class extends NodeExtension12 {
11147
11357
  createDecorations(state) {
11148
11358
  const found = findParentNodeOfType5({ types: this.type, selection: state.selection });
11149
11359
  if (!found) {
11150
- return DecorationSet5.empty;
11360
+ return DecorationSet6.empty;
11151
11361
  }
11152
- return DecorationSet5.create(state.doc, [
11153
- Decoration7.node(found.pos, found.pos + found.node.nodeSize, { class: "rme-block-focus" })
11362
+ return DecorationSet6.create(state.doc, [
11363
+ Decoration8.node(found.pos, found.pos + found.node.nodeSize, { class: "rme-block-focus" })
11154
11364
  ]);
11155
11365
  }
11156
11366
  createInputRules() {
@@ -12007,13 +12217,16 @@ var CodeMirror6NodeView = class {
12007
12217
  this.view = view;
12008
12218
  this.getPos = getPos;
12009
12219
  this.languageName = "";
12220
+ const editorId = this.view._rme_editor_id || String(view.dom?.id || Date.now() + Math.random());
12221
+ this.view._rme_editor_id = editorId;
12010
12222
  this.mfCodemirrorView = new MfCodemirrorView({
12011
12223
  view: this.view,
12012
12224
  getPos: this.getPos,
12013
12225
  node: this.node,
12014
12226
  extensions: extensions2,
12015
12227
  languageName: this.languageName,
12016
- options
12228
+ options,
12229
+ editorId
12017
12230
  });
12018
12231
  if (onCodemirrorViewLoad) {
12019
12232
  onCodemirrorViewLoad(this.mfCodemirrorView);
@@ -12255,23 +12468,23 @@ var LineCodeMirrorExtension = class extends NodeExtension14 {
12255
12468
  }
12256
12469
  createDecorations(state) {
12257
12470
  if (this.options.hideDecoration) {
12258
- return DecorationSet6.empty;
12471
+ return DecorationSet7.empty;
12259
12472
  }
12260
12473
  const found = findParentNodeOfType6({ types: this.type, selection: state.selection });
12261
12474
  if (!found || found.node.attrs["front-matter"] === true) {
12262
- return DecorationSet6.empty;
12475
+ return DecorationSet7.empty;
12263
12476
  }
12264
12477
  if (!languages3 || languages3.length <= 1) {
12265
- return DecorationSet6.empty;
12478
+ return DecorationSet7.empty;
12266
12479
  }
12267
12480
  const { create, destroy } = codemirror_lang_menu_default(found);
12268
- const deco = Decoration8.widget(found.pos, create, {
12481
+ const deco = Decoration9.widget(found.pos, create, {
12269
12482
  ignoreSelection: true,
12270
12483
  stopEvent: () => true,
12271
12484
  key: "language-menu",
12272
12485
  destroy
12273
12486
  });
12274
- return DecorationSet6.create(state.doc, [deco]);
12487
+ return DecorationSet7.create(state.doc, [deco]);
12275
12488
  }
12276
12489
  };
12277
12490
  LineCodeMirrorExtension = __decorateClass([
@@ -12296,6 +12509,7 @@ function createSourceCodeManager(options) {
12296
12509
  return createReactManager(() => [
12297
12510
  new CountExtension2({}),
12298
12511
  new DocExtension({ content: "codeMirror" }),
12512
+ new FindExtension({}),
12299
12513
  new LineCodeMirrorExtension({
12300
12514
  hideDecoration: true,
12301
12515
  showCopyButton: false,
@@ -13997,6 +14211,10 @@ export {
13997
14211
  buildMarkdownParser,
13998
14212
  buildMarkdownSerializer,
13999
14213
  changeTheme,
14214
+ cmInstanceMap,
14215
+ cmSearchDecorations,
14216
+ cmSearchEffects,
14217
+ cmSearchField,
14000
14218
  common,
14001
14219
  computeChange,
14002
14220
  createSourceCodeDelegate,