@markweave/vue2 0.8.0 → 0.9.0

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/legacy.d.ts ADDED
@@ -0,0 +1 @@
1
+ export * from "./dist/types/index";
package/legacy.js ADDED
@@ -0,0 +1 @@
1
+ export * from "./dist/legacy/index.js";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@markweave/vue2",
3
- "version": "0.8.0",
3
+ "version": "0.9.0",
4
4
  "type": "module",
5
5
  "description": "Vue 2 adapter for the Markweave Markdown-first WYSIWYG editor.",
6
6
  "license": "MIT",
@@ -38,10 +38,23 @@
38
38
  "types": "./dist/types/index.d.ts",
39
39
  "import": "./dist/index.js"
40
40
  },
41
+ "./legacy": {
42
+ "types": "./legacy.d.ts",
43
+ "import": "./legacy.js",
44
+ "default": "./legacy.js"
45
+ },
46
+ "./webpack4": {
47
+ "types": "./webpack4/index.d.cts",
48
+ "require": "./webpack4/index.cjs",
49
+ "default": "./webpack4/index.cjs"
50
+ },
41
51
  "./styles.css": "./styles.css"
42
52
  },
43
53
  "files": [
44
54
  "dist",
55
+ "legacy.js",
56
+ "legacy.d.ts",
57
+ "webpack4",
45
58
  "styles.css",
46
59
  "README.md",
47
60
  "LICENSE"
@@ -53,14 +66,17 @@
53
66
  "@tiptap/extension-image": "3.29.2",
54
67
  "@tiptap/pm": "3.29.2",
55
68
  "@tiptap/vue-2": "3.29.2",
56
- "markweave": "^0.8.0"
69
+ "prosemirror-model": "1.25.11",
70
+ "prosemirror-state": "1.4.4",
71
+ "prosemirror-view": "1.42.2",
72
+ "markweave": "^0.9.0"
57
73
  },
58
74
  "peerDependencies": {
59
75
  "vue": "^2.6.12"
60
76
  },
61
77
  "devDependencies": {},
62
78
  "scripts": {
63
- "build": "node -e \"require('node:fs').rmSync('dist',{recursive:true,force:true})\" && vite build && tsc -p tsconfig.build.json",
79
+ "build": "node -e \"require('node:fs').rmSync('dist',{recursive:true,force:true})\" && vite build && vite build --config vite.legacy.config.ts --logLevel warn && tsc -p tsconfig.build.json",
64
80
  "typecheck": "tsc -p tsconfig.json --noEmit"
65
81
  }
66
82
  }
@@ -0,0 +1,186 @@
1
+ "use strict";
2
+
3
+ const fs = require("node:fs");
4
+ const path = require("node:path");
5
+
6
+ const TIPTAP_PM_SUBPATHS = [
7
+ "changeset",
8
+ "commands",
9
+ "dropcursor",
10
+ "gapcursor",
11
+ "history",
12
+ "inputrules",
13
+ "keymap",
14
+ "model",
15
+ "schema-list",
16
+ "state",
17
+ "tables",
18
+ "transform",
19
+ "view",
20
+ ];
21
+ const PROSEMIRROR_RUNTIME_PACKAGES = [
22
+ "prosemirror-model",
23
+ "prosemirror-state",
24
+ "prosemirror-view",
25
+ ];
26
+
27
+ function findPackageRoot(packageName, searchPaths) {
28
+ for (const searchPath of searchPaths) {
29
+ const candidate = path.join(searchPath, "node_modules", packageName);
30
+ const manifest = path.join(candidate, "package.json");
31
+ if (fs.existsSync(manifest)) {
32
+ try {
33
+ if (JSON.parse(fs.readFileSync(manifest, "utf8")).name === packageName) {
34
+ return fs.realpathSync(candidate);
35
+ }
36
+ } catch {
37
+ return null;
38
+ }
39
+ }
40
+ }
41
+
42
+ let entry;
43
+ try {
44
+ entry = require.resolve(packageName, { paths: searchPaths });
45
+ } catch {
46
+ return null;
47
+ }
48
+
49
+ let current = path.dirname(entry);
50
+ while (current !== path.dirname(current)) {
51
+ const manifest = path.join(current, "package.json");
52
+ if (fs.existsSync(manifest)) {
53
+ try {
54
+ if (JSON.parse(fs.readFileSync(manifest, "utf8")).name === packageName) {
55
+ return fs.realpathSync(current);
56
+ }
57
+ } catch {
58
+ return null;
59
+ }
60
+ }
61
+ current = path.dirname(current);
62
+ }
63
+ return null;
64
+ }
65
+
66
+ function setExistingAlias(config, request, target) {
67
+ if (target && fs.existsSync(target)) {
68
+ config.resolve.alias.set(request, target);
69
+ }
70
+ }
71
+
72
+ function addBabelRule(config, ruleName, test, dependencyRoots, cacheDirectory, asJavascriptAuto) {
73
+ const rule = config.module.rule(ruleName).test(test);
74
+ if (asJavascriptAuto) {
75
+ rule.type("javascript/auto");
76
+ }
77
+ dependencyRoots.forEach((dependencyRoot) => rule.include.add(dependencyRoot));
78
+ rule
79
+ .use("babel-loader")
80
+ .loader("babel-loader")
81
+ .options({
82
+ cacheCompression: false,
83
+ cacheDirectory,
84
+ presets: ["@vue/cli-plugin-babel/preset"],
85
+ });
86
+ }
87
+
88
+ function applyMarkweaveVue2Webpack4Legacy(config, options = {}) {
89
+ const projectRoot = path.resolve(options.projectRoot || process.cwd());
90
+ const cacheDirectory = path.resolve(
91
+ options.cacheDirectory
92
+ || process.env.MARKWEAVE_BABEL_CACHE_DIR
93
+ || path.join(projectRoot, ".cache/markweave-babel-loader"),
94
+ );
95
+ const installedPackageRoot = path.join(projectRoot, "node_modules/@markweave/vue2");
96
+ const packageRoot = fs.existsSync(installedPackageRoot)
97
+ ? installedPackageRoot
98
+ : path.resolve(__dirname, "..");
99
+ const searchPaths = [projectRoot, packageRoot];
100
+ const tiptapCoreRoot = findPackageRoot("@tiptap/core", searchPaths);
101
+ const tiptapPmRoot = findPackageRoot("@tiptap/pm", searchPaths);
102
+ const tiptapVue2Root = findPackageRoot("@tiptap/vue-2", searchPaths);
103
+ const prosemirrorRoots = new Map(
104
+ PROSEMIRROR_RUNTIME_PACKAGES.map((packageName) => [
105
+ packageName,
106
+ findPackageRoot(packageName, searchPaths),
107
+ ]),
108
+ );
109
+ const missingPackages = [
110
+ ["@tiptap/core", tiptapCoreRoot],
111
+ ["@tiptap/pm", tiptapPmRoot],
112
+ ["@tiptap/vue-2", tiptapVue2Root],
113
+ ...prosemirrorRoots.entries(),
114
+ ].filter(([, packagePath]) => !packagePath).map(([packageName]) => packageName);
115
+ const legacyEntry = path.join(packageRoot, "legacy.js");
116
+
117
+ if (!fs.existsSync(legacyEntry) || missingPackages.length > 0) {
118
+ throw new Error(
119
+ `@markweave/vue2 Webpack 4 legacy setup is incomplete. Missing: ${[
120
+ ...(!fs.existsSync(legacyEntry) ? ["@markweave/vue2/legacy.js"] : []),
121
+ ...missingPackages,
122
+ ].join(", ")}`,
123
+ );
124
+ }
125
+
126
+ if (options.aliasPackageImport !== false) {
127
+ setExistingAlias(config, "@markweave/vue2$", legacyEntry);
128
+ }
129
+ setExistingAlias(config, "@markweave/vue2/legacy$", legacyEntry);
130
+ setExistingAlias(config, "@markweave/vue2/styles.css$", path.join(packageRoot, "styles.css"));
131
+
132
+ if (tiptapCoreRoot) {
133
+ setExistingAlias(
134
+ config,
135
+ "@tiptap/core/jsx-runtime$",
136
+ path.join(tiptapCoreRoot, "dist/jsx-runtime/index.js"),
137
+ );
138
+ }
139
+ if (tiptapVue2Root) {
140
+ setExistingAlias(config, "@tiptap/vue-2$", path.join(tiptapVue2Root, "dist/index.js"));
141
+ setExistingAlias(config, "@tiptap/vue-2/menus$", path.join(tiptapVue2Root, "dist/menus/index.js"));
142
+ }
143
+ if (tiptapPmRoot) {
144
+ TIPTAP_PM_SUBPATHS.forEach((subpath) => {
145
+ setExistingAlias(
146
+ config,
147
+ `@tiptap/pm/${subpath}$`,
148
+ path.join(tiptapPmRoot, `dist/${subpath}/index.js`),
149
+ );
150
+ });
151
+ }
152
+ prosemirrorRoots.forEach((dependencyRoot, packageName) => {
153
+ setExistingAlias(
154
+ config,
155
+ `${packageName}$`,
156
+ dependencyRoot && path.join(dependencyRoot, "dist/index.js"),
157
+ );
158
+ });
159
+
160
+ if (config.resolve.extensions && typeof config.resolve.extensions.add === "function") {
161
+ config.resolve.extensions.add(".mjs");
162
+ }
163
+
164
+ const dependencyRoots = [tiptapCoreRoot, tiptapPmRoot, tiptapVue2Root].filter(Boolean);
165
+ if (dependencyRoots.length > 0) {
166
+ addBabelRule(
167
+ config,
168
+ "markweave-vue2-legacy-shared-runtime-js",
169
+ /\.js$/,
170
+ dependencyRoots,
171
+ cacheDirectory,
172
+ false,
173
+ );
174
+ addBabelRule(
175
+ config,
176
+ "markweave-vue2-legacy-shared-runtime-mjs",
177
+ /\.mjs$/,
178
+ dependencyRoots,
179
+ cacheDirectory,
180
+ true,
181
+ );
182
+ }
183
+ }
184
+
185
+ module.exports = applyMarkweaveVue2Webpack4Legacy;
186
+ module.exports.applyMarkweaveVue2Webpack4Legacy = applyMarkweaveVue2Webpack4Legacy;
@@ -0,0 +1,12 @@
1
+ interface MarkweaveVue2Webpack4LegacyOptions {
2
+ projectRoot?: string;
3
+ cacheDirectory?: string;
4
+ aliasPackageImport?: boolean;
5
+ }
6
+
7
+ declare function applyMarkweaveVue2Webpack4Legacy(
8
+ config: any,
9
+ options?: MarkweaveVue2Webpack4LegacyOptions,
10
+ ): void;
11
+
12
+ export = applyMarkweaveVue2Webpack4Legacy;
@@ -0,0 +1,5 @@
1
+ {
2
+ "type": "commonjs",
3
+ "main": "./index.cjs",
4
+ "types": "./index.d.cts"
5
+ }