Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

markduckjs

Package Overview
Dependencies
Maintainers
1
Versions
8
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

markduckjs - npm Package Compare versions

Comparing version 0.0.1 to 0.0.2

changelog.config.js

9

CHANGELOG.md

@@ -0,1 +1,10 @@

## [0.0.2](https://github.com/ymmooot/markduck/compare/v0.0.1...v0.0.2) (2019-12-20)
### Features
* register component via function ([99b335f](https://github.com/ymmooot/markduck/commit/99b335f704efc9aa27773b25138676377057a9ba))
## 0.0.1 (2019-12-20)

@@ -2,0 +11,0 @@

7

lib/convert.d.ts

@@ -1,6 +0,7 @@

import { VueConstructor, CreateElement, VNode } from "vue";
import { VueConstructor, CreateElement, VNode as VueVNode } from "vue";
declare type ComponentRegisterFunc = (RVDom: any) => VueConstructor<Vue> | undefined;
export declare type ComponentRegisterOption = {
[keyof: string]: VueConstructor<Vue>;
[keyof: string]: VueConstructor<Vue> | ComponentRegisterFunc;
};
declare const convert: (createElement: CreateElement, markdown: string, components: ComponentRegisterOption) => VNode[];
declare const convert: (createElement: CreateElement, markdown: string, components: ComponentRegisterOption) => (string | VueVNode)[];
export default convert;

@@ -16,2 +16,5 @@ "use strict";

};
const isFunc = (customComponent) => typeof customComponent === "function";
const isVText = (vdom) => vdom.type === 'VirtualText';
const isVNode = (vdom) => vdom.type === 'VirtualNode';
const vdomToVNode = (createElement, vdoms, components) => {

@@ -22,10 +25,15 @@ var _a, _b, _c;

const vdom = vdoms[index];
const children = ((_a = vdom.children) === null || _a === void 0 ? void 0 : _a.length) > 0 ? vdomToVNode(createElement, vdom.children, components) : [];
// vdom that having text is a VirtualText
if (vdom.text) {
// VirtualText has no tag
if (isVText(vdom)) {
nodes.push(vdom.text);
continue;
}
if (!isVNode(vdom)) {
continue;
}
const children = ((_a = vdom.children) === null || _a === void 0 ? void 0 : _a.length) > 0 ? vdomToVNode(createElement, vdom.children, components) : [];
// get custom component
const tagName = (_b = vdom.tagName) === null || _b === void 0 ? void 0 : _b.toLowerCase();
const customComponent = components[tagName];
const customComponentOpt = components[tagName];
const customComponent = isFunc(customComponentOpt) ? customComponentOpt(vdom) : customComponentOpt;
if (customComponent) {

@@ -32,0 +40,0 @@ const node = createElement(customComponent, {

{
"name": "markduckjs",
"version": "0.0.1",
"version": "0.0.2",
"description": "Render markdown with your Vue components.",

@@ -28,6 +28,5 @@ "main": "lib/index.js",

"dependencies": {
"markdown-it": "^10.0.0",
"@types/virtual-dom": "^2.1.0",
"remark-parse": "^7.0.2",
"remark-vdom": "^8.0.0",
"sync-rpc": "^1.3.6",
"unified": "^8.4.2",

@@ -38,3 +37,2 @@ "vue": "^2.6.11",

"devDependencies": {
"@types/markdown-it": "0.0.9",
"@vue/component-compiler-utils": "^3.1.0",

@@ -41,0 +39,0 @@ "babel-core": "^6.26.3",

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc