prosemirror-safari-ime-span 1.0.0 → 1.0.2

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.cjs CHANGED
@@ -37,35 +37,25 @@ var safari = !ie && !!nav && /Apple Computer/.test(nav.vendor);
37
37
 
38
38
  // src/index.ts
39
39
  var key = new import_prosemirror_state.PluginKey("safari-ime-span");
40
+ var isComposing = false;
40
41
  var spec = {
41
42
  key,
42
- state: {
43
- init: () => {
44
- return false;
45
- },
46
- apply: (tr, value) => {
47
- const composing = tr.getMeta(key);
48
- return composing != null ? composing : value;
49
- }
50
- },
51
43
  props: {
52
44
  decorations: createDecorations,
53
45
  handleDOMEvents: {
54
- compositionstart: (view) => {
55
- view.dispatch(view.state.tr.setMeta(key, true));
46
+ compositionstart: () => {
47
+ isComposing = true;
56
48
  },
57
- compositionend: (view) => {
58
- view.dispatch(view.state.tr.setMeta(key, false));
49
+ compositionend: () => {
50
+ isComposing = false;
59
51
  }
60
52
  }
61
53
  }
62
54
  };
63
55
  function createDecorations(state) {
64
- const { $from, $to, from } = state.selection;
65
- const composing = key.getState(state);
66
- if (composing && $from.sameParent($to)) {
67
- const deco = import_prosemirror_view.Decoration.widget(from, createSpan, {
68
- side: -100,
56
+ const { $from, $to, to } = state.selection;
57
+ if (isComposing && $from.sameParent($to)) {
58
+ const deco = import_prosemirror_view.Decoration.widget(to, createSpan, {
69
59
  ignoreSelection: true,
70
60
  key: "safari-ime-span"
71
61
  });
package/dist/index.d.cts CHANGED
@@ -8,6 +8,6 @@ import { Plugin } from 'prosemirror-state';
8
8
  *
9
9
  * @public @group Plugins
10
10
  */
11
- declare const imeSpan: Plugin<boolean>;
11
+ declare const imeSpan: Plugin<undefined>;
12
12
 
13
13
  export { imeSpan };
package/dist/index.d.ts CHANGED
@@ -8,6 +8,6 @@ import { Plugin } from 'prosemirror-state';
8
8
  *
9
9
  * @public @group Plugins
10
10
  */
11
- declare const imeSpan: Plugin<boolean>;
11
+ declare const imeSpan: Plugin<undefined>;
12
12
 
13
13
  export { imeSpan };
package/dist/index.js CHANGED
@@ -16,35 +16,25 @@ var safari = !ie && !!nav && /Apple Computer/.test(nav.vendor);
16
16
 
17
17
  // src/index.ts
18
18
  var key = new PluginKey("safari-ime-span");
19
+ var isComposing = false;
19
20
  var spec = {
20
21
  key,
21
- state: {
22
- init: () => {
23
- return false;
24
- },
25
- apply: (tr, value) => {
26
- const composing = tr.getMeta(key);
27
- return composing != null ? composing : value;
28
- }
29
- },
30
22
  props: {
31
23
  decorations: createDecorations,
32
24
  handleDOMEvents: {
33
- compositionstart: (view) => {
34
- view.dispatch(view.state.tr.setMeta(key, true));
25
+ compositionstart: () => {
26
+ isComposing = true;
35
27
  },
36
- compositionend: (view) => {
37
- view.dispatch(view.state.tr.setMeta(key, false));
28
+ compositionend: () => {
29
+ isComposing = false;
38
30
  }
39
31
  }
40
32
  }
41
33
  };
42
34
  function createDecorations(state) {
43
- const { $from, $to, from } = state.selection;
44
- const composing = key.getState(state);
45
- if (composing && $from.sameParent($to)) {
46
- const deco = Decoration.widget(from, createSpan, {
47
- side: -100,
35
+ const { $from, $to, to } = state.selection;
36
+ if (isComposing && $from.sameParent($to)) {
37
+ const deco = Decoration.widget(to, createSpan, {
48
38
  ignoreSelection: true,
49
39
  key: "safari-ime-span"
50
40
  });
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "prosemirror-safari-ime-span",
3
3
  "type": "module",
4
- "version": "1.0.0",
4
+ "version": "1.0.2",
5
5
  "packageManager": "pnpm@8.15.8",
6
6
  "description": "",
7
7
  "author": "ocavue <ocavue@gmail.com>",