@rufous/ui 0.1.95 → 0.1.96

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.
Files changed (3) hide show
  1. package/dist/main.cjs +14 -20
  2. package/dist/main.js +14 -20
  3. package/package.json +1 -1
package/dist/main.cjs CHANGED
@@ -49677,14 +49677,16 @@ function findMisspelled(doc3) {
49677
49677
  function createSpellCheckPlugin() {
49678
49678
  let debounceTimer = null;
49679
49679
  let viewRef = null;
49680
+ let currentDecos = DecorationSet.empty;
49681
+ let currentDocSize = 0;
49680
49682
  const runCheck = (view) => {
49681
49683
  try {
49682
49684
  if (!typo || !view?.dom?.isConnected || !view.state) return;
49683
49685
  const { doc: doc3 } = view.state;
49684
49686
  if (!doc3 || doc3.content.size <= 4) {
49685
- const tr2 = view.state.tr.setMeta(spellCheckPluginKey, { decorations: DecorationSet.empty });
49686
- tr2.setMeta("addToHistory", false);
49687
- view.dispatch(tr2);
49687
+ currentDecos = DecorationSet.empty;
49688
+ currentDocSize = doc3?.content.size || 0;
49689
+ view.dispatch(view.state.tr.setMeta("spellCheckDone", true).setMeta("addToHistory", false));
49688
49690
  return;
49689
49691
  }
49690
49692
  const misspelled = findMisspelled(doc3);
@@ -49695,11 +49697,11 @@ function createSpellCheckPlugin() {
49695
49697
  "data-spell-word": word
49696
49698
  })
49697
49699
  );
49698
- const decorationSet = DecorationSet.create(doc3, decos);
49699
- const tr = view.state.tr.setMeta(spellCheckPluginKey, { decorations: decorationSet });
49700
- tr.setMeta("addToHistory", false);
49701
- view.dispatch(tr);
49700
+ currentDecos = DecorationSet.create(doc3, decos);
49701
+ currentDocSize = doc3.content.size;
49702
+ view.dispatch(view.state.tr.setMeta("spellCheckDone", true).setMeta("addToHistory", false));
49702
49703
  } catch {
49704
+ currentDecos = DecorationSet.empty;
49703
49705
  }
49704
49706
  };
49705
49707
  const scheduleCheck = (view) => {
@@ -49708,20 +49710,10 @@ function createSpellCheckPlugin() {
49708
49710
  };
49709
49711
  return new Plugin2({
49710
49712
  key: spellCheckPluginKey,
49711
- state: {
49712
- init() {
49713
- return DecorationSet.empty;
49714
- },
49715
- apply(tr, _oldDecos) {
49716
- const meta = tr.getMeta(spellCheckPluginKey);
49717
- if (meta?.decorations) return meta.decorations;
49718
- if (tr.docChanged) return DecorationSet.empty;
49719
- return _oldDecos;
49720
- }
49721
- },
49722
49713
  props: {
49723
49714
  decorations(state) {
49724
- return spellCheckPluginKey.getState(state) || DecorationSet.empty;
49715
+ if (state.doc.content.size !== currentDocSize) return DecorationSet.empty;
49716
+ return currentDecos;
49725
49717
  }
49726
49718
  },
49727
49719
  view(editorView) {
@@ -49730,17 +49722,19 @@ function createSpellCheckPlugin() {
49730
49722
  if (viewRef) scheduleCheck(viewRef);
49731
49723
  };
49732
49724
  initSpellChecker().then(() => {
49733
- if (viewRef) runCheck(viewRef);
49725
+ if (viewRef?.dom?.isConnected) runCheck(viewRef);
49734
49726
  });
49735
49727
  return {
49736
49728
  update(view, prevState) {
49737
49729
  viewRef = view;
49738
49730
  if (view.state.doc !== prevState.doc) {
49731
+ currentDecos = DecorationSet.empty;
49739
49732
  scheduleCheck(view);
49740
49733
  }
49741
49734
  },
49742
49735
  destroy() {
49743
49736
  if (debounceTimer) clearTimeout(debounceTimer);
49737
+ currentDecos = DecorationSet.empty;
49744
49738
  viewRef = null;
49745
49739
  scheduleRecheckFn = null;
49746
49740
  }
package/dist/main.js CHANGED
@@ -21007,14 +21007,16 @@ function findMisspelled(doc3) {
21007
21007
  function createSpellCheckPlugin() {
21008
21008
  let debounceTimer = null;
21009
21009
  let viewRef = null;
21010
+ let currentDecos = DecorationSet.empty;
21011
+ let currentDocSize = 0;
21010
21012
  const runCheck = (view) => {
21011
21013
  try {
21012
21014
  if (!typo || !view?.dom?.isConnected || !view.state) return;
21013
21015
  const { doc: doc3 } = view.state;
21014
21016
  if (!doc3 || doc3.content.size <= 4) {
21015
- const tr2 = view.state.tr.setMeta(spellCheckPluginKey, { decorations: DecorationSet.empty });
21016
- tr2.setMeta("addToHistory", false);
21017
- view.dispatch(tr2);
21017
+ currentDecos = DecorationSet.empty;
21018
+ currentDocSize = doc3?.content.size || 0;
21019
+ view.dispatch(view.state.tr.setMeta("spellCheckDone", true).setMeta("addToHistory", false));
21018
21020
  return;
21019
21021
  }
21020
21022
  const misspelled = findMisspelled(doc3);
@@ -21025,11 +21027,11 @@ function createSpellCheckPlugin() {
21025
21027
  "data-spell-word": word
21026
21028
  })
21027
21029
  );
21028
- const decorationSet = DecorationSet.create(doc3, decos);
21029
- const tr = view.state.tr.setMeta(spellCheckPluginKey, { decorations: decorationSet });
21030
- tr.setMeta("addToHistory", false);
21031
- view.dispatch(tr);
21030
+ currentDecos = DecorationSet.create(doc3, decos);
21031
+ currentDocSize = doc3.content.size;
21032
+ view.dispatch(view.state.tr.setMeta("spellCheckDone", true).setMeta("addToHistory", false));
21032
21033
  } catch {
21034
+ currentDecos = DecorationSet.empty;
21033
21035
  }
21034
21036
  };
21035
21037
  const scheduleCheck = (view) => {
@@ -21038,20 +21040,10 @@ function createSpellCheckPlugin() {
21038
21040
  };
21039
21041
  return new Plugin({
21040
21042
  key: spellCheckPluginKey,
21041
- state: {
21042
- init() {
21043
- return DecorationSet.empty;
21044
- },
21045
- apply(tr, _oldDecos) {
21046
- const meta = tr.getMeta(spellCheckPluginKey);
21047
- if (meta?.decorations) return meta.decorations;
21048
- if (tr.docChanged) return DecorationSet.empty;
21049
- return _oldDecos;
21050
- }
21051
- },
21052
21043
  props: {
21053
21044
  decorations(state) {
21054
- return spellCheckPluginKey.getState(state) || DecorationSet.empty;
21045
+ if (state.doc.content.size !== currentDocSize) return DecorationSet.empty;
21046
+ return currentDecos;
21055
21047
  }
21056
21048
  },
21057
21049
  view(editorView) {
@@ -21060,17 +21052,19 @@ function createSpellCheckPlugin() {
21060
21052
  if (viewRef) scheduleCheck(viewRef);
21061
21053
  };
21062
21054
  initSpellChecker().then(() => {
21063
- if (viewRef) runCheck(viewRef);
21055
+ if (viewRef?.dom?.isConnected) runCheck(viewRef);
21064
21056
  });
21065
21057
  return {
21066
21058
  update(view, prevState) {
21067
21059
  viewRef = view;
21068
21060
  if (view.state.doc !== prevState.doc) {
21061
+ currentDecos = DecorationSet.empty;
21069
21062
  scheduleCheck(view);
21070
21063
  }
21071
21064
  },
21072
21065
  destroy() {
21073
21066
  if (debounceTimer) clearTimeout(debounceTimer);
21067
+ currentDecos = DecorationSet.empty;
21074
21068
  viewRef = null;
21075
21069
  scheduleRecheckFn = null;
21076
21070
  }
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@rufous/ui",
3
3
  "private": false,
4
- "version": "0.1.95",
4
+ "version": "0.1.96",
5
5
  "type": "module",
6
6
  "description": "Experimental: A lightweight React UI component library (Beta)",
7
7
  "style": "./dist/main.css",