@markmap/render 0.0.0-stage → 1.0.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/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2020 Gerald
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md CHANGED
@@ -1,3 +1,5 @@
1
- # Temporary Holding Version
1
+ # @markmap/render
2
2
 
3
- This version is a temporary placeholder for this package. An operational version to replace this has been submitted for review and is awaiting a staged release.
3
+ Measure, lay out and render Markmap trees to primitives and SVG.
4
+
5
+ See the [Markmap README](https://github.com/markmap/markmap#readme) for how the packages fit together.
@@ -0,0 +1,12 @@
1
+ import { type FrameNode, type InterpolateContext, type Layout, type LayoutFrame, type Theme } from '@markmap/core';
2
+ import type { DrawState } from './render';
3
+ export type Easing = (t: number) => number;
4
+ export declare const easeCubicInOut: Easing;
5
+ /**
6
+ * The default {@link Layout.interpolate}: nodes in both frames move in a straight line;
7
+ * entering nodes grow out of their nearest ancestor's anchor (on the side they grow
8
+ * towards) and leaving nodes shrink back into their nearest surviving ancestor's.
9
+ */
10
+ export declare function interpolateFrames<N extends FrameNode>(from: LayoutFrame<N>, to: LayoutFrame<N>, t: number, ctx: InterpolateContext<N>): LayoutFrame<N>;
11
+ /** Interpolate draw states with the layout's own interpolation, or the default one. */
12
+ export declare function interpolateStates(from: DrawState, to: DrawState, t: number, theme: Theme, layout?: Layout): DrawState;
@@ -0,0 +1,10 @@
1
+ import type { ContentPlugin } from '@markmap/core';
2
+ /** Keep http(s), mailto, tel and relative URLs. Anything else, such as `javascript:`, is dropped. */
3
+ export declare function sanitizeUrl(url: string): string | undefined;
4
+ /** Bold, italic, inline code, links, strikethrough, highlight and task checkboxes. */
5
+ export declare const basicContent: ContentPlugin;
6
+ /**
7
+ * Adds a dot after the label of nodes with notes, with a hit area that asks the
8
+ * view to open them. The dot is exported; the hit area is interactive-only.
9
+ */
10
+ export declare const noteContent: ContentPlugin;
@@ -0,0 +1,3 @@
1
+ import type { ContentPlugin } from '@markmap/core';
2
+ /** Plugins used when none are given: basic styles, images, and note dots. */
3
+ export declare const defaultContentPlugins: readonly ContentPlugin[];
@@ -0,0 +1,23 @@
1
+ import type { ContentPlugin, Size } from '@markmap/core';
2
+ export interface ImageContentOptions {
3
+ /**
4
+ * Find an image's natural size. Defaults to loading it with `Image` where that exists
5
+ * (browsers); elsewhere unsized images keep their placeholder size.
6
+ */
7
+ loadSize?: (src: string) => Promise<Size>;
8
+ /** Return `false` to show an image's alt text instead, e.g. to block remote images. */
9
+ allow?: (src: string) => boolean;
10
+ /** Width cap when labels do not wrap, in px. With wrapping, `wrapWidth` caps images too. */
11
+ maxWidth?: number;
12
+ }
13
+ /** Like {@link sanitizeUrl}, plus base64 raster `data:` images. */
14
+ export declare function sanitizeImageUrl(url: string): string | undefined;
15
+ /**
16
+ * Draws Markdown images and sized `<img>` tags inside labels. Sizes come from the tag,
17
+ * from a cache of loaded sizes, or from a placeholder while the image loads; the view
18
+ * then renders again (see `InlineContext.defer`). Images are capped at the label wrap
19
+ * width, keeping their aspect ratio. Images that fail to load show their alt text.
20
+ */
21
+ export declare function createImageContent(options?: ImageContentOptions): ContentPlugin;
22
+ /** Images with sizes loaded in the browser. */
23
+ export declare const imageContent: ContentPlugin;
@@ -0,0 +1,15 @@
1
+ export * from './content';
2
+ export * from './default-plugins';
3
+ export * from './image';
4
+ export * from './layouts';
5
+ export * from './measure';
6
+ export * from './options';
7
+ export * from './paint';
8
+ export * from './render';
9
+ export * from './svg';
10
+ export * from './text';
11
+ export * from './themes/branch';
12
+ export * from './themes/cards';
13
+ export * from './themes/classic';
14
+ export * from './themes/minimal';
15
+ export * from './animate';