prosemirror-safari-ime-span 1.0.2 → 1.0.3
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 +45 -67
- package/dist/index.d.cts +3 -5
- package/dist/index.d.cts.map +1 -0
- package/dist/index.d.ts +3 -5
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +45 -44
- package/dist/index.js.map +1 -0
- package/package.json +37 -26
package/dist/index.cjs
CHANGED
|
@@ -1,74 +1,52 @@
|
|
|
1
|
-
"
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
-
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
-
var __export = (target, all) => {
|
|
7
|
-
for (var name in all)
|
|
8
|
-
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
-
};
|
|
10
|
-
var __copyProps = (to, from, except, desc) => {
|
|
11
|
-
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
-
for (let key2 of __getOwnPropNames(from))
|
|
13
|
-
if (!__hasOwnProp.call(to, key2) && key2 !== except)
|
|
14
|
-
__defProp(to, key2, { get: () => from[key2], enumerable: !(desc = __getOwnPropDesc(from, key2)) || desc.enumerable });
|
|
15
|
-
}
|
|
16
|
-
return to;
|
|
17
|
-
};
|
|
18
|
-
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
-
|
|
20
|
-
// src/index.ts
|
|
21
|
-
var src_exports = {};
|
|
22
|
-
__export(src_exports, {
|
|
23
|
-
imeSpan: () => imeSpan
|
|
24
|
-
});
|
|
25
|
-
module.exports = __toCommonJS(src_exports);
|
|
26
|
-
var import_prosemirror_state = require("prosemirror-state");
|
|
27
|
-
var import_prosemirror_view = require("prosemirror-view");
|
|
28
|
-
|
|
1
|
+
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
2
|
+
let prosemirror_state = require("prosemirror-state");
|
|
3
|
+
let prosemirror_view = require("prosemirror-view");
|
|
29
4
|
// src/browser.ts
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
var safari = !ie && !!nav && /Apple Computer/.test(nav.vendor);
|
|
37
|
-
|
|
5
|
+
const nav = typeof navigator != "undefined" ? navigator : null;
|
|
6
|
+
const agent = nav && nav.userAgent || "";
|
|
7
|
+
const ie_edge = /Edge\/(\d+)/.exec(agent);
|
|
8
|
+
const ie_upto10 = /MSIE \d/.exec(agent);
|
|
9
|
+
const ie_11up = /Trident\/(?:[7-9]|\d{2,})\..*rv:(\d+)/.exec(agent);
|
|
10
|
+
const safari = !!!(ie_upto10 || ie_11up || ie_edge) && !!nav && /Apple Computer/.test(nav.vendor);
|
|
38
11
|
// src/index.ts
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
12
|
+
const key = new prosemirror_state.PluginKey("safari-ime-span");
|
|
13
|
+
let isComposing = false;
|
|
14
|
+
const spec = {
|
|
15
|
+
key,
|
|
16
|
+
props: {
|
|
17
|
+
decorations: createDecorations,
|
|
18
|
+
handleDOMEvents: {
|
|
19
|
+
compositionstart: () => {
|
|
20
|
+
isComposing = true;
|
|
21
|
+
},
|
|
22
|
+
compositionend: () => {
|
|
23
|
+
isComposing = false;
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
}
|
|
54
27
|
};
|
|
55
28
|
function createDecorations(state) {
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
29
|
+
const { $from, $to, to } = state.selection;
|
|
30
|
+
if (isComposing && $from.sameParent($to)) {
|
|
31
|
+
const deco = prosemirror_view.Decoration.widget(to, createSpan, {
|
|
32
|
+
ignoreSelection: true,
|
|
33
|
+
key: "safari-ime-span"
|
|
34
|
+
});
|
|
35
|
+
return prosemirror_view.DecorationSet.create(state.doc, [deco]);
|
|
36
|
+
}
|
|
64
37
|
}
|
|
65
38
|
function createSpan(view) {
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
39
|
+
const span = view.dom.ownerDocument.createElement("span");
|
|
40
|
+
span.className = "ProseMirror-safari-ime-span";
|
|
41
|
+
return span;
|
|
69
42
|
}
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
43
|
+
/**
|
|
44
|
+
* A plugin as a workaround for a bug in Safari that causes the composition
|
|
45
|
+
* based IME to remove the empty HTML element with CSS `position: relative`.
|
|
46
|
+
*
|
|
47
|
+
* See also https://github.com/ProseMirror/prosemirror/issues/934
|
|
48
|
+
*
|
|
49
|
+
* @public @group Plugins
|
|
50
|
+
*/
|
|
51
|
+
const imeSpan = new prosemirror_state.Plugin(safari ? spec : { key });
|
|
52
|
+
exports.imeSpan = imeSpan;
|
package/dist/index.d.cts
CHANGED
|
@@ -1,5 +1,4 @@
|
|
|
1
|
-
import { Plugin } from
|
|
2
|
-
|
|
1
|
+
import { Plugin } from "prosemirror-state";
|
|
3
2
|
/**
|
|
4
3
|
* A plugin as a workaround for a bug in Safari that causes the composition
|
|
5
4
|
* based IME to remove the empty HTML element with CSS `position: relative`.
|
|
@@ -8,6 +7,5 @@ import { Plugin } from 'prosemirror-state';
|
|
|
8
7
|
*
|
|
9
8
|
* @public @group Plugins
|
|
10
9
|
*/
|
|
11
|
-
declare const imeSpan: Plugin<undefined>;
|
|
12
|
-
|
|
13
|
-
export { imeSpan };
|
|
10
|
+
export declare const imeSpan: Plugin<undefined>;
|
|
11
|
+
//# sourceMappingURL=index.d.cts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.cts","names":[],"sources":["../src/index.ts"],"mappings":";;;;;;;;;qBAsDa,SAAO"}
|
package/dist/index.d.ts
CHANGED
|
@@ -1,5 +1,4 @@
|
|
|
1
|
-
import { Plugin } from
|
|
2
|
-
|
|
1
|
+
import { Plugin } from "prosemirror-state";
|
|
3
2
|
/**
|
|
4
3
|
* A plugin as a workaround for a bug in Safari that causes the composition
|
|
5
4
|
* based IME to remove the empty HTML element with CSS `position: relative`.
|
|
@@ -8,6 +7,5 @@ import { Plugin } from 'prosemirror-state';
|
|
|
8
7
|
*
|
|
9
8
|
* @public @group Plugins
|
|
10
9
|
*/
|
|
11
|
-
declare const imeSpan: Plugin<undefined>;
|
|
12
|
-
|
|
13
|
-
export { imeSpan };
|
|
10
|
+
export declare const imeSpan: Plugin<undefined>;
|
|
11
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","names":[],"sources":["../src/index.ts"],"mappings":";;;;;;;;;qBAsDa,SAAO"}
|
package/dist/index.js
CHANGED
|
@@ -1,52 +1,53 @@
|
|
|
1
|
-
|
|
2
|
-
import {
|
|
3
|
-
Plugin,
|
|
4
|
-
PluginKey
|
|
5
|
-
} from "prosemirror-state";
|
|
1
|
+
import { Plugin, PluginKey } from "prosemirror-state";
|
|
6
2
|
import { Decoration, DecorationSet } from "prosemirror-view";
|
|
7
|
-
|
|
8
3
|
// src/browser.ts
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
var safari = !ie && !!nav && /Apple Computer/.test(nav.vendor);
|
|
16
|
-
|
|
4
|
+
const nav = typeof navigator != "undefined" ? navigator : null;
|
|
5
|
+
const agent = nav && nav.userAgent || "";
|
|
6
|
+
const ie_edge = /Edge\/(\d+)/.exec(agent);
|
|
7
|
+
const ie_upto10 = /MSIE \d/.exec(agent);
|
|
8
|
+
const ie_11up = /Trident\/(?:[7-9]|\d{2,})\..*rv:(\d+)/.exec(agent);
|
|
9
|
+
const safari = !!!(ie_upto10 || ie_11up || ie_edge) && !!nav && /Apple Computer/.test(nav.vendor);
|
|
17
10
|
// src/index.ts
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
11
|
+
const key = new PluginKey("safari-ime-span");
|
|
12
|
+
let isComposing = false;
|
|
13
|
+
const spec = {
|
|
14
|
+
key,
|
|
15
|
+
props: {
|
|
16
|
+
decorations: createDecorations,
|
|
17
|
+
handleDOMEvents: {
|
|
18
|
+
compositionstart: () => {
|
|
19
|
+
isComposing = true;
|
|
20
|
+
},
|
|
21
|
+
compositionend: () => {
|
|
22
|
+
isComposing = false;
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
}
|
|
33
26
|
};
|
|
34
27
|
function createDecorations(state) {
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
28
|
+
const { $from, $to, to } = state.selection;
|
|
29
|
+
if (isComposing && $from.sameParent($to)) {
|
|
30
|
+
const deco = Decoration.widget(to, createSpan, {
|
|
31
|
+
ignoreSelection: true,
|
|
32
|
+
key: "safari-ime-span"
|
|
33
|
+
});
|
|
34
|
+
return DecorationSet.create(state.doc, [deco]);
|
|
35
|
+
}
|
|
43
36
|
}
|
|
44
37
|
function createSpan(view) {
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
38
|
+
const span = view.dom.ownerDocument.createElement("span");
|
|
39
|
+
span.className = "ProseMirror-safari-ime-span";
|
|
40
|
+
return span;
|
|
48
41
|
}
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
42
|
+
/**
|
|
43
|
+
* A plugin as a workaround for a bug in Safari that causes the composition
|
|
44
|
+
* based IME to remove the empty HTML element with CSS `position: relative`.
|
|
45
|
+
*
|
|
46
|
+
* See also https://github.com/ProseMirror/prosemirror/issues/934
|
|
47
|
+
*
|
|
48
|
+
* @public @group Plugins
|
|
49
|
+
*/
|
|
50
|
+
const imeSpan = new Plugin(safari ? spec : { key });
|
|
51
|
+
export { imeSpan };
|
|
52
|
+
|
|
53
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","names":[],"sources":["../src/browser.ts","../src/index.ts"],"sourcesContent":["// Copied from https://github.com/prosemirror/prosemirror-view/blob/1.33.8/src/browser.ts\n\nconst nav = typeof navigator != 'undefined' ? navigator : null\nconst agent = (nav && nav.userAgent) || ''\n\nconst ie_edge = /Edge\\/(\\d+)/.exec(agent)\nconst ie_upto10 = /MSIE \\d/.exec(agent)\nconst ie_11up = /Trident\\/(?:[7-9]|\\d{2,})\\..*rv:(\\d+)/.exec(agent)\n\nconst ie = !!(ie_upto10 || ie_11up || ie_edge)\n\nexport const safari = !ie && !!nav && /Apple Computer/.test(nav.vendor)\n","import {\n Plugin,\n PluginKey,\n type EditorState,\n type PluginSpec,\n} from 'prosemirror-state'\nimport { Decoration, DecorationSet, type EditorView } from 'prosemirror-view'\n\nimport { safari } from './browser'\n\nconst key = new PluginKey('safari-ime-span')\n\nlet isComposing = false\n\nconst spec: PluginSpec<undefined> = {\n key,\n props: {\n decorations: createDecorations,\n handleDOMEvents: {\n compositionstart: () => {\n isComposing = true\n },\n compositionend: () => {\n isComposing = false\n },\n },\n },\n}\n\nfunction createDecorations(state: EditorState): DecorationSet | undefined {\n const { $from, $to, to } = state.selection\n if (isComposing && $from.sameParent($to)) {\n const deco = Decoration.widget(to, createSpan, {\n ignoreSelection: true,\n key: 'safari-ime-span',\n })\n return DecorationSet.create(state.doc, [deco])\n }\n}\n\nfunction createSpan(view: EditorView): HTMLSpanElement {\n const span = view.dom.ownerDocument.createElement('span')\n span.className = 'ProseMirror-safari-ime-span'\n return span\n}\n\n/**\n * A plugin as a workaround for a bug in Safari that causes the composition\n * based IME to remove the empty HTML element with CSS `position: relative`.\n *\n * See also https://github.com/ProseMirror/prosemirror/issues/934\n *\n * @public @group Plugins\n */\nexport const imeSpan = new Plugin(safari ? spec : { key })\n"],"mappings":";;;AAEA,MAAM,MAAM,OAAO,aAAa,cAAc,YAAY;AAC1D,MAAM,QAAS,OAAO,IAAI,aAAc;AAExC,MAAM,UAAU,cAAc,KAAK,KAAK;AACxC,MAAM,YAAY,UAAU,KAAK,KAAK;AACtC,MAAM,UAAU,wCAAwC,KAAK,KAAK;AAIlE,MAAa,SAAS,CAAC,CAFX,EAAE,aAAa,WAAW,YAET,CAAC,CAAC,OAAO,iBAAiB,KAAK,IAAI,MAAM;;ACDtE,MAAM,MAAM,IAAI,UAAU,iBAAiB;AAE3C,IAAI,cAAc;AAElB,MAAM,OAA8B;CAClC;CACA,OAAO;EACL,aAAa;EACb,iBAAiB;GACf,wBAAwB;IACtB,cAAc;GAChB;GACA,sBAAsB;IACpB,cAAc;GAChB;EACF;CACF;AACF;AAEA,SAAS,kBAAkB,OAA+C;CACxE,MAAM,EAAE,OAAO,KAAK,OAAO,MAAM;CACjC,IAAI,eAAe,MAAM,WAAW,GAAG,GAAG;EACxC,MAAM,OAAO,WAAW,OAAO,IAAI,YAAY;GAC7C,iBAAiB;GACjB,KAAK;EACP,CAAC;EACD,OAAO,cAAc,OAAO,MAAM,KAAK,CAAC,IAAI,CAAC;CAC/C;AACF;AAEA,SAAS,WAAW,MAAmC;CACrD,MAAM,OAAO,KAAK,IAAI,cAAc,cAAc,MAAM;CACxD,KAAK,YAAY;CACjB,OAAO;AACT;;;;;;;;;AAUA,MAAa,UAAU,IAAI,OAAO,SAAS,OAAO,EAAE,IAAI,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,9 +1,8 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "prosemirror-safari-ime-span",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "1.0.
|
|
5
|
-
"
|
|
6
|
-
"description": "",
|
|
4
|
+
"version": "1.0.3",
|
|
5
|
+
"description": "A ProseMirror plugin that works around a Safari IME bug that removes empty inline nodes",
|
|
7
6
|
"author": "ocavue <ocavue@gmail.com>",
|
|
8
7
|
"license": "MIT",
|
|
9
8
|
"funding": "https://github.com/sponsors/ocavue",
|
|
@@ -13,24 +12,30 @@
|
|
|
13
12
|
"url": "https://github.com/ocavue/prosemirror-safari-ime-span.git"
|
|
14
13
|
},
|
|
15
14
|
"bugs": "https://github.com/ocavue/prosemirror-safari-ime-span/issues",
|
|
16
|
-
"keywords": [
|
|
15
|
+
"keywords": [
|
|
16
|
+
"prosemirror",
|
|
17
|
+
"prosemirror-plugin",
|
|
18
|
+
"safari",
|
|
19
|
+
"webkit",
|
|
20
|
+
"ime",
|
|
21
|
+
"composition",
|
|
22
|
+
"input-method",
|
|
23
|
+
"rich-text-editor"
|
|
24
|
+
],
|
|
17
25
|
"sideEffects": false,
|
|
18
26
|
"main": "./dist/index.cjs",
|
|
19
27
|
"module": "./dist/index.js",
|
|
20
28
|
"types": "./dist/index.d.ts",
|
|
21
29
|
"exports": {
|
|
22
30
|
".": {
|
|
23
|
-
"
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
"./dist/*",
|
|
32
|
-
"./dist/index.d.ts"
|
|
33
|
-
]
|
|
31
|
+
"import": {
|
|
32
|
+
"types": "./dist/index.d.ts",
|
|
33
|
+
"default": "./dist/index.js"
|
|
34
|
+
},
|
|
35
|
+
"require": {
|
|
36
|
+
"types": "./dist/index.d.cts",
|
|
37
|
+
"default": "./dist/index.cjs"
|
|
38
|
+
}
|
|
34
39
|
}
|
|
35
40
|
},
|
|
36
41
|
"files": [
|
|
@@ -41,12 +46,17 @@
|
|
|
41
46
|
"prosemirror-view": "^1.33.8"
|
|
42
47
|
},
|
|
43
48
|
"devDependencies": {
|
|
44
|
-
"@ocavue/eslint-config": "^
|
|
45
|
-
"@
|
|
46
|
-
"
|
|
47
|
-
"
|
|
48
|
-
"
|
|
49
|
-
"
|
|
49
|
+
"@ocavue/eslint-config": "^4.26.0",
|
|
50
|
+
"@ocavue/tsconfig": "^0.7.1",
|
|
51
|
+
"@types/node": "^24.0.0",
|
|
52
|
+
"eslint": "^10.16.0",
|
|
53
|
+
"jsdom": "^31.0.1",
|
|
54
|
+
"prettier": "^3.10.1",
|
|
55
|
+
"prosemirror-schema-basic": "^1.2.5",
|
|
56
|
+
"tsdown": "^0.23.7",
|
|
57
|
+
"typescript": "^6.0.3",
|
|
58
|
+
"vite": "^8.4.1",
|
|
59
|
+
"vitest": "^5.1.2"
|
|
50
60
|
},
|
|
51
61
|
"renovate": {
|
|
52
62
|
"extends": [
|
|
@@ -54,10 +64,11 @@
|
|
|
54
64
|
]
|
|
55
65
|
},
|
|
56
66
|
"scripts": {
|
|
57
|
-
"build": "
|
|
58
|
-
"dev": "
|
|
59
|
-
"lint": "eslint .",
|
|
60
|
-
"fix": "eslint --fix
|
|
61
|
-
"
|
|
67
|
+
"build": "tsdown",
|
|
68
|
+
"dev": "tsdown --watch",
|
|
69
|
+
"lint": "eslint && prettier --check .",
|
|
70
|
+
"fix": "eslint --fix && prettier --write .",
|
|
71
|
+
"test": "vitest",
|
|
72
|
+
"typecheck": "tsc -b"
|
|
62
73
|
}
|
|
63
74
|
}
|