@mce/html 0.24.4
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 +3 -0
- package/dist/index.js +35 -0
- package/dist/plugin.d.ts +2 -0
- package/package.json +61 -0
package/dist/index.d.ts
ADDED
package/dist/index.js
ADDED
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import { definePlugin } from "mce";
|
|
2
|
+
//#region src/plugin.ts
|
|
3
|
+
var RE = /\.html$/i;
|
|
4
|
+
/** 把 .html / text/html 来源解析为 DOM 并交给核心 loader 转换为元素。 */
|
|
5
|
+
function plugin() {
|
|
6
|
+
return definePlugin((editor) => {
|
|
7
|
+
const { load } = editor;
|
|
8
|
+
return {
|
|
9
|
+
name: "mce:html",
|
|
10
|
+
loaders: [{
|
|
11
|
+
name: "html",
|
|
12
|
+
accept: ".html",
|
|
13
|
+
test: (source) => {
|
|
14
|
+
if (source instanceof Blob && source.type.startsWith("text/html")) return true;
|
|
15
|
+
if (source instanceof File && RE.test(source.name)) return true;
|
|
16
|
+
return false;
|
|
17
|
+
},
|
|
18
|
+
load: async (source) => {
|
|
19
|
+
const dom = new DOMParser().parseFromString(await source.text(), "text/html");
|
|
20
|
+
try {
|
|
21
|
+
return await load(dom);
|
|
22
|
+
} catch (err) {
|
|
23
|
+
console.error(err);
|
|
24
|
+
return [];
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
}]
|
|
28
|
+
};
|
|
29
|
+
});
|
|
30
|
+
}
|
|
31
|
+
//#endregion
|
|
32
|
+
//#region src/index.ts
|
|
33
|
+
var src_default = plugin;
|
|
34
|
+
//#endregion
|
|
35
|
+
export { src_default as default, plugin };
|
package/dist/plugin.d.ts
ADDED
package/package.json
ADDED
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@mce/html",
|
|
3
|
+
"type": "module",
|
|
4
|
+
"version": "0.24.4",
|
|
5
|
+
"description": "HTML import plugin for mce",
|
|
6
|
+
"author": "wxm",
|
|
7
|
+
"license": "MIT",
|
|
8
|
+
"homepage": "https://github.com/qq15725/mce",
|
|
9
|
+
"repository": {
|
|
10
|
+
"type": "git",
|
|
11
|
+
"url": "git+https://github.com/qq15725/mce.git"
|
|
12
|
+
},
|
|
13
|
+
"bugs": {
|
|
14
|
+
"url": "https://github.com/qq15725/mce/issues"
|
|
15
|
+
},
|
|
16
|
+
"keywords": [
|
|
17
|
+
"mce",
|
|
18
|
+
"html",
|
|
19
|
+
"plugin"
|
|
20
|
+
],
|
|
21
|
+
"sideEffects": true,
|
|
22
|
+
"exports": {
|
|
23
|
+
".": {
|
|
24
|
+
"types": "./dist/index.d.ts",
|
|
25
|
+
"import": "./dist/index.js",
|
|
26
|
+
"require": "./dist/index.js"
|
|
27
|
+
},
|
|
28
|
+
"./*.mjs": "./*.js",
|
|
29
|
+
"./*": "./*"
|
|
30
|
+
},
|
|
31
|
+
"main": "./dist/index.js",
|
|
32
|
+
"module": "./dist/index.js",
|
|
33
|
+
"browser": "./dist/index.js",
|
|
34
|
+
"typings": "dist/index.d.ts",
|
|
35
|
+
"types": "dist/index.d.ts",
|
|
36
|
+
"typesVersions": {
|
|
37
|
+
"*": {
|
|
38
|
+
"*": [
|
|
39
|
+
"*",
|
|
40
|
+
"dist/*",
|
|
41
|
+
"dist/*.d.ts"
|
|
42
|
+
]
|
|
43
|
+
}
|
|
44
|
+
},
|
|
45
|
+
"files": [
|
|
46
|
+
"dist"
|
|
47
|
+
],
|
|
48
|
+
"devDependencies": {
|
|
49
|
+
"mce": "0.24.4"
|
|
50
|
+
},
|
|
51
|
+
"peerDependencies": {
|
|
52
|
+
"mce": "^0"
|
|
53
|
+
},
|
|
54
|
+
"scripts": {
|
|
55
|
+
"build:code": "vite build",
|
|
56
|
+
"build:tsc": "NODE_ENV=production tsc --emitDeclarationOnly --project tsconfig.json",
|
|
57
|
+
"build": "pnpm build:code && pnpm build:tsc",
|
|
58
|
+
"lint": "eslint src",
|
|
59
|
+
"typecheck": "tsc --noEmit --project tsconfig.json"
|
|
60
|
+
}
|
|
61
|
+
}
|