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

canvas-native

Package Overview
Dependencies
Maintainers
1
Versions
25
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

canvas-native - npm Package Compare versions

Comparing version 1.0.0 to 1.1.0

circle.yml

7

dist/lib/types/checklist.js

@@ -33,2 +33,9 @@ 'use strict';

_createClass(Checklist, [{
key: 'toJSON',
value: function toJSON() {
var json = _get(Object.getPrototypeOf(Checklist.prototype), 'toJSON', this).call(this);
json.meta.checked = this.isChecked;
return json;
}
}, {
key: 'isChecked',

@@ -35,0 +42,0 @@ get: function get() {

@@ -33,2 +33,10 @@ 'use strict';

_createClass(Code, [{
key: 'toJSON',
value: function toJSON() {
return {
type: this.type,
content: this.match[2]
};
}
}, {
key: 'toMarkdown',

@@ -52,2 +60,7 @@ value: function toMarkdown(prev, next) {

}
}, {
key: 'groupType',
get: function get() {
return 'code-block';
}
}], [{

@@ -54,0 +67,0 @@ key: 'name',

@@ -31,2 +31,11 @@ 'use strict';

_createClass(Heading, [{
key: 'toJSON',
value: function toJSON() {
return {
type: this.type,
content: this.match[0],
meta: { level: this.level }
};
}
}, {
key: 'toMarkdown',

@@ -33,0 +42,0 @@ value: function toMarkdown(prev, next) {

@@ -31,2 +31,10 @@ 'use strict';

_createClass(HorizontalRule, [{
key: 'toJSON',
value: function toJSON() {
return {
type: this.type,
content: this.match[0]
};
}
}, {
key: 'toMarkdown',

@@ -33,0 +41,0 @@ value: function toMarkdown(prev, next) {

@@ -33,2 +33,10 @@ 'use strict';

_createClass(Image, [{
key: 'toJSON',
value: function toJSON() {
return {
type: this.type,
content: this.match[2]
};
}
}, {
key: 'toMarkdown',

@@ -35,0 +43,0 @@ value: function toMarkdown(prev, next) {

@@ -31,2 +31,14 @@ 'use strict';

_createClass(LinkDefinition, [{
key: 'toJSON',
value: function toJSON() {
return {
type: this.type,
content: this.match[0],
meta: {
label: this.label,
url: this.url
}
};
}
}, {
key: 'toMarkdown',

@@ -33,0 +45,0 @@ value: function toMarkdown(prev, next) {

@@ -31,2 +31,11 @@ 'use strict';

_createClass(List, [{
key: 'toJSON',
value: function toJSON() {
return {
type: this.type,
content: this.match[3],
meta: { level: this.level }
};
}
}, {
key: 'toMarkdown',

@@ -48,2 +57,7 @@ value: function toMarkdown(prev, next) {

}, {
key: 'groupType',
get: function get() {
return this.type.replace(/-item$/, '');
}
}, {
key: 'level',

@@ -50,0 +64,0 @@ get: function get() {

@@ -31,2 +31,10 @@ 'use strict';

_createClass(Paragraph, [{
key: 'toJSON',
value: function toJSON() {
return {
content: this.match[0],
type: this.type
};
}
}, {
key: 'toMarkdown',

@@ -33,0 +41,0 @@ value: function toMarkdown(prev, next) {

@@ -33,2 +33,10 @@ 'use strict';

_createClass(Title, [{
key: 'toJSON',
value: function toJSON() {
return {
type: this.type,
content: this.match[2]
};
}
}, {
key: 'toMarkdown',

@@ -35,0 +43,0 @@ value: function toMarkdown(prev, next) {

@@ -19,2 +19,7 @@ 'use strict';

_createClass(Type, [{
key: 'toJSON',
value: function toJSON() {
throw new Error('Must implement `toJSON` for each type');
}
}, {
key: 'toMarkdown',

@@ -25,2 +30,7 @@ value: function toMarkdown() /* prev, next */{

}, {
key: 'groupType',
get: function get() {
return 'canvas';
}
}, {
key: 'type',

@@ -27,0 +37,0 @@ get: function get() {

@@ -9,2 +9,8 @@ import UnorderedList from './unordered-list';

toJSON() {
const json = super.toJSON();
json.meta.checked = this.isChecked;
return json;
}
static get name() {

@@ -11,0 +17,0 @@ return 'checklist-item';

@@ -5,2 +5,13 @@ import Type from './type';

export default class Code extends Type {
get groupType() {
return 'code-block';
}
toJSON() {
return {
type : this.type,
content: this.match[2],
};
}
toMarkdown(prev, next) {

@@ -7,0 +18,0 @@ let result = this.match[2];

@@ -8,2 +8,10 @@ import Type from './type';

toJSON() {
return {
type : this.type,
content: this.match[0],
meta : { level: this.level },
}
}
toMarkdown(prev, next) {

@@ -10,0 +18,0 @@ if (!next) {

import Type from './type';
export default class HorizontalRule extends Type {
toJSON() {
return {
type : this.type,
content: this.match[0],
}
}
toMarkdown(prev, next) {

@@ -5,0 +12,0 @@ if (!next) {

@@ -5,2 +5,9 @@ import Type from './type';

export default class Image extends Type {
toJSON() {
return {
type : this.type,
content: this.match[2],
}
}
toMarkdown(prev, next) {

@@ -7,0 +14,0 @@ if (!next) {

@@ -12,2 +12,13 @@ import Type from './type';

toJSON() {
return {
type : this.type,
content: this.match[0],
meta : {
label: this.label,
url : this.url,
}
};
}
toMarkdown(prev, next) {

@@ -14,0 +25,0 @@ if (!next) {

import Type from './type';
export default class List extends Type {
get groupType() {
return this.type.replace(/-item$/, '');
}
toJSON() {
return {
type : this.type,
content: this.match[3],
meta : { level: this.level },
};
}
toMarkdown(prev, next) {

@@ -5,0 +17,0 @@ let result = this.match[3];

import Type from './type';
export default class Paragraph extends Type {
toJSON() {
return {
content: this.match[0],
type : this.type,
};
}
toMarkdown(prev, next) {

@@ -5,0 +12,0 @@ if (!next) {

@@ -5,2 +5,9 @@ import Type from './type';

export default class Title extends Type {
toJSON() {
return {
type : this.type,
content: this.match[2],
}
}
toMarkdown(prev, next) {

@@ -7,0 +14,0 @@ const result = `# ${this.match[2]}`;

@@ -6,2 +6,6 @@ export default class Type {

get groupType() {
return 'canvas';
}
get type() {

@@ -11,2 +15,6 @@ return this.constructor.name;

toJSON() {
throw new Error('Must implement `toJSON` for each type');
}
toMarkdown(/* prev, next */) {

@@ -13,0 +21,0 @@ throw new Error('Must implement `toMarkdown` for each type');

2

package.json
{
"name": "canvas-native",
"description": "Utilities for working with the native Canvas format",
"version": "1.0.0",
"version": "1.1.0",
"author": "Jonathan Clem <jonathan@usecanvas.com>",

@@ -6,0 +6,0 @@ "bugs": "https://github.com/usecanvas/canvas-native/issues",

@@ -1,2 +0,2 @@

# Canvas Native
# Canvas Native [![Circle CI](https://circleci.com/gh/usecanvas/canvas-native.svg?style=svg&circle-token=69d5436f464606a7de833acd870799390aef8fee)](https://circleci.com/gh/usecanvas/canvas-native)

@@ -3,0 +3,0 @@ Canvas Native is a set of utilities for parsing and converting between the

@@ -63,2 +63,16 @@ import Checklist from '../../../lib/types/checklist';

});
describe('#toJSON', () => {
it('includes its checked status and level', () => {
const line = Checklist.match(wrap('checklist-0') + '- [x] Foo');
expect(line.toJSON()).to.eql({
type : 'checklist-item',
content: '- [x] Foo',
meta : {
level : 0,
checked: true,
}
});
});
});
});

@@ -14,2 +14,12 @@ import Code from '../../../lib/types/code';

describe('#toJSON', () => {
it('serializes to JSON', () => {
const line = Code.match(wrap('code') + 'alert("ok");');
expect(line.toJSON()).to.eql({
type : 'code',
content: 'alert("ok");',
});
});
});
describe('#toMarkdown', () => {

@@ -16,0 +26,0 @@ let line;

@@ -17,2 +17,15 @@ import Heading from '../../../lib/types/heading';

describe('#toJSON', () => {
it('serializes to JSON with its level', () => {
const line = Heading.match('#### Foo');
expect(line.toJSON()).to.eql({
type : 'heading',
content: '#### Foo',
meta : {
level: 4
}
});
});
});
describe('#toMarkdown', () => {

@@ -19,0 +32,0 @@ let line;

@@ -14,2 +14,12 @@ import HorizontalRule from '../../../lib/types/horizontal-rule';

describe('#toJSON', () => {
it('serializes to JSON', () => {
const line = HorizontalRule.match('- - -');
expect(line.toJSON()).to.eql({
type : 'horizontal-rule',
content: '- - -',
});
});
});
describe('#toMarkdown', () => {

@@ -16,0 +26,0 @@ let line;

@@ -13,2 +13,12 @@ import Image from '../../../lib/types/image';

describe('#toJSON', () => {
it('serializes to JSON', () => {
const line = Image.match(`${wrap('image')}https://example.com/test.png`);
expect(line.toJSON()).to.eql({
type : 'image',
content: 'https://example.com/test.png',
});
});
});
describe('#toMarkdown', () => {

@@ -15,0 +25,0 @@ let line;

@@ -25,2 +25,16 @@ import LinkDefinition from '../../../lib/types/link-definition';

describe('#toJSON', () => {
it('serializes to JSON', () => {
const line = LinkDefinition.match('[foo]: bar');
expect(line.toJSON()).to.eql({
type : 'link-definition',
content: '[foo]: bar',
meta : {
label: 'foo',
url : 'bar',
}
});
});
});
describe('#toMarkdown', () => {

@@ -27,0 +41,0 @@ let line;

@@ -13,2 +13,12 @@ import Title from '../../../lib/types/title';

describe('#toJSON', () => {
it('serializes to JSON', () => {
const line = Title.match(`${wrap('doc-heading')}Foo`);
expect(line.toJSON()).to.eql({
type : 'title',
content: 'Foo',
});
});
});
describe('#toMarkdown', () => {

@@ -15,0 +25,0 @@ let line;

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