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 +8 -18
- package/dist/index.d.cts +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.js +8 -18
- package/package.json +1 -1
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: (
|
|
55
|
-
|
|
46
|
+
compositionstart: () => {
|
|
47
|
+
isComposing = true;
|
|
56
48
|
},
|
|
57
|
-
compositionend: (
|
|
58
|
-
|
|
49
|
+
compositionend: () => {
|
|
50
|
+
isComposing = false;
|
|
59
51
|
}
|
|
60
52
|
}
|
|
61
53
|
}
|
|
62
54
|
};
|
|
63
55
|
function createDecorations(state) {
|
|
64
|
-
const { $from, $to,
|
|
65
|
-
|
|
66
|
-
|
|
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
package/dist/index.d.ts
CHANGED
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: (
|
|
34
|
-
|
|
25
|
+
compositionstart: () => {
|
|
26
|
+
isComposing = true;
|
|
35
27
|
},
|
|
36
|
-
compositionend: (
|
|
37
|
-
|
|
28
|
+
compositionend: () => {
|
|
29
|
+
isComposing = false;
|
|
38
30
|
}
|
|
39
31
|
}
|
|
40
32
|
}
|
|
41
33
|
};
|
|
42
34
|
function createDecorations(state) {
|
|
43
|
-
const { $from, $to,
|
|
44
|
-
|
|
45
|
-
|
|
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
|
});
|