Comparing version 0.0.1 to 0.0.2
@@ -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 @@ |
@@ -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", |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
8023
6
11
11
106
+ Added@types/virtual-dom@^2.1.0
+ Added@types/virtual-dom@2.1.4(transitive)
- Removedmarkdown-it@^10.0.0
- Removedsync-rpc@^1.3.6
- Removedargparse@1.0.10(transitive)
- Removedentities@2.0.3(transitive)
- Removedget-port@3.2.0(transitive)
- Removedlinkify-it@2.2.0(transitive)
- Removedmarkdown-it@10.0.0(transitive)
- Removedsprintf-js@1.0.3(transitive)
- Removedsync-rpc@1.3.6(transitive)
- Removeduc.micro@1.0.6(transitive)