@riebeckite/plugin-markmap 0.0.30 → 0.0.32
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.js +16 -44
- package/dist/src/hast.d.ts +7 -0
- package/package.json +3 -2
package/dist/index.js
CHANGED
|
@@ -5,6 +5,22 @@ import {
|
|
|
5
5
|
definePlugin
|
|
6
6
|
} from "@riebeckite/core";
|
|
7
7
|
|
|
8
|
+
// src/hast.ts
|
|
9
|
+
import {
|
|
10
|
+
element as sharedElement,
|
|
11
|
+
getStringProperty as sharedGetStringProperty,
|
|
12
|
+
getTextContent as sharedGetTextContent,
|
|
13
|
+
hasClass as sharedHasClass,
|
|
14
|
+
text as sharedText,
|
|
15
|
+
visitElements as sharedVisitElements
|
|
16
|
+
} from "@riebeckite/diagram";
|
|
17
|
+
var element = sharedElement;
|
|
18
|
+
var text = sharedText;
|
|
19
|
+
var getTextContent = sharedGetTextContent;
|
|
20
|
+
var getStringProperty = sharedGetStringProperty;
|
|
21
|
+
var hasClass = sharedHasClass;
|
|
22
|
+
var visitElements = sharedVisitElements;
|
|
23
|
+
|
|
8
24
|
// src/options.ts
|
|
9
25
|
var DEFAULT_MARKMAP_CLASS_NAME = "rb-markmap";
|
|
10
26
|
var DEFAULT_MARKMAP_HEIGHT = 320;
|
|
@@ -172,50 +188,6 @@ function reportDiagnostic(file, message) {
|
|
|
172
188
|
});
|
|
173
189
|
}
|
|
174
190
|
}
|
|
175
|
-
function visitElements(node, visitor, parent, index) {
|
|
176
|
-
if (isElementNode(node)) visitor(node, parent, index);
|
|
177
|
-
for (const [childIndex, child] of [...getChildren(node)].entries()) {
|
|
178
|
-
visitElements(
|
|
179
|
-
child,
|
|
180
|
-
visitor,
|
|
181
|
-
hasChildren(node) ? node : parent,
|
|
182
|
-
childIndex
|
|
183
|
-
);
|
|
184
|
-
}
|
|
185
|
-
}
|
|
186
|
-
function element(tagName, properties = {}, children = []) {
|
|
187
|
-
return { type: "element", tagName, properties, children };
|
|
188
|
-
}
|
|
189
|
-
function text(value) {
|
|
190
|
-
return { type: "text", value };
|
|
191
|
-
}
|
|
192
|
-
function getTextContent(node) {
|
|
193
|
-
if (node.type === "text" && "value" in node && typeof node.value === "string") {
|
|
194
|
-
return node.value;
|
|
195
|
-
}
|
|
196
|
-
return getChildren(node).map(getTextContent).join("");
|
|
197
|
-
}
|
|
198
|
-
function getStringProperty(node, key) {
|
|
199
|
-
const value = node.properties?.[key];
|
|
200
|
-
if (typeof value === "string") return value;
|
|
201
|
-
if (Array.isArray(value)) return value.join(" ");
|
|
202
|
-
return null;
|
|
203
|
-
}
|
|
204
|
-
function hasClass(node, className) {
|
|
205
|
-
const value = node.properties?.className;
|
|
206
|
-
const classes = Array.isArray(value) ? value.map(String) : typeof value === "string" ? value.split(/\s+/) : [];
|
|
207
|
-
return classes.includes(className);
|
|
208
|
-
}
|
|
209
|
-
function isElementNode(node) {
|
|
210
|
-
return node.type === "element";
|
|
211
|
-
}
|
|
212
|
-
function hasChildren(node) {
|
|
213
|
-
return Array.isArray(node.children);
|
|
214
|
-
}
|
|
215
|
-
function getChildren(node) {
|
|
216
|
-
const children = node.children;
|
|
217
|
-
return Array.isArray(children) ? children : [];
|
|
218
|
-
}
|
|
219
191
|
|
|
220
192
|
// index.ts
|
|
221
193
|
function markmap(options = {}) {
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import type { ElementNode, HastNode, ParentNode, TextNode } from "./types.js";
|
|
2
|
+
export declare const element: (tagName: string, properties?: Record<string, unknown>, children?: HastNode[]) => ElementNode;
|
|
3
|
+
export declare const text: (value: string) => TextNode;
|
|
4
|
+
export declare const getTextContent: (node: HastNode) => string;
|
|
5
|
+
export declare const getStringProperty: (node: ElementNode, key: string) => string | null;
|
|
6
|
+
export declare const hasClass: (node: ElementNode, className: string) => boolean;
|
|
7
|
+
export declare const visitElements: (node: HastNode, visitor: (node: ElementNode, parent?: ParentNode, index?: number) => void, parent?: ParentNode, index?: number) => void;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@riebeckite/plugin-markmap",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.32",
|
|
4
4
|
"license": "Apache-2.0",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./dist/index.js",
|
|
@@ -23,7 +23,8 @@
|
|
|
23
23
|
"dependencies": {
|
|
24
24
|
"markmap-lib": "^0.18.12",
|
|
25
25
|
"markmap-view": "^0.18.12",
|
|
26
|
-
"@riebeckite/core": "0.0.
|
|
26
|
+
"@riebeckite/core": "0.0.32",
|
|
27
|
+
"@riebeckite/diagram": "0.0.32"
|
|
27
28
|
},
|
|
28
29
|
"publishConfig": {
|
|
29
30
|
"access": "public"
|