Skip to content

Commit 491340a

Browse files
committed
Add slate-utils
1 parent e034ba0 commit 491340a

File tree

13 files changed

+952
-0
lines changed

13 files changed

+952
-0
lines changed

packages/slate-utils/.eslintrc.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
module.exports = require('../../.eslintrc.js');

packages/slate-utils/LICENSE.md

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
MIT License
2+
3+
Copyright (c) [year] [fullname]
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.

packages/slate-utils/README.md

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
# `datocms-structured-text-slate-utils`
2+
3+
A set of Typescript types and helpers to convert Structured Text dast to Slate structures.
4+
5+
## Installation
6+
7+
Using [npm](http://npmjs.org/):
8+
9+
```sh
10+
npm install datocms-structured-text-slate-utils
11+
```
12+
13+
Using [yarn](https://yarnpkg.com/):
14+
15+
```sh
16+
yarn add datocms-structured-text-slate-utils
17+
```
Lines changed: 105 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,105 @@
1+
// Jest Snapshot v1, https://goo.gl/fbAQLP
2+
3+
exports[`datocms-structured-text-slate-utils render some value some rules returns null 1`] = `
4+
Object {
5+
"ancestors": Array [],
6+
"children": Array [
7+
Object {
8+
"ancestors": Array [
9+
Object {
10+
"children": Array [
11+
Object {
12+
"children": Array [
13+
Object {
14+
"marks": Array [
15+
"strikethrough",
16+
],
17+
"type": "span",
18+
"value": "Foobar",
19+
},
20+
],
21+
"type": "paragraph",
22+
},
23+
],
24+
"type": "root",
25+
},
26+
],
27+
"children": Array [
28+
Object {
29+
"ancestors": Array [
30+
Object {
31+
"children": Array [
32+
Object {
33+
"marks": Array [
34+
"strikethrough",
35+
],
36+
"type": "span",
37+
"value": "Foobar",
38+
},
39+
],
40+
"type": "paragraph",
41+
},
42+
Object {
43+
"children": Array [
44+
Object {
45+
"children": Array [
46+
Object {
47+
"marks": Array [
48+
"strikethrough",
49+
],
50+
"type": "span",
51+
"value": "Foobar",
52+
},
53+
],
54+
"type": "paragraph",
55+
},
56+
],
57+
"type": "root",
58+
},
59+
],
60+
"children": undefined,
61+
"key": "t-0",
62+
"node": Object {
63+
"marks": Array [
64+
"strikethrough",
65+
],
66+
"type": "span",
67+
"value": "Foobar",
68+
},
69+
},
70+
],
71+
"key": "t-0",
72+
"node": Object {
73+
"children": Array [
74+
Object {
75+
"marks": Array [
76+
"strikethrough",
77+
],
78+
"type": "span",
79+
"value": "Foobar",
80+
},
81+
],
82+
"type": "paragraph",
83+
},
84+
},
85+
],
86+
"key": "t-0",
87+
"node": Object {
88+
"children": Array [
89+
Object {
90+
"children": Array [
91+
Object {
92+
"marks": Array [
93+
"strikethrough",
94+
],
95+
"type": "span",
96+
"value": "Foobar",
97+
},
98+
],
99+
"type": "paragraph",
100+
},
101+
],
102+
"type": "root",
103+
},
104+
}
105+
`;
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
describe('datocms-structured-text-slate-utils', () => {
2+
describe('definitions', () => {
3+
it('are coherent', () => {
4+
expect(true).toBeTruthy();
5+
});
6+
});
7+
});

packages/slate-utils/package-lock.json

Lines changed: 146 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

packages/slate-utils/package.json

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
{
2+
"name": "datocms-structured-text-slate-utils",
3+
"version": "1.2.0",
4+
"description": "A set of helpers to translate DatoCMS Structured Text fields into Slate structures",
5+
"keywords": [
6+
"datocms",
7+
"structured-text"
8+
],
9+
"author": "Stefano Verna <s.verna@datocms.com>",
10+
"homepage": "https://github.com/datocms/structured-text/tree/master/packages/datocms-structured-text-slate-utils#readme",
11+
"license": "MIT",
12+
"main": "dist/cjs/index.js",
13+
"module": "dist/esm/index.js",
14+
"typings": "dist/types/index.d.ts",
15+
"sideEffects": false,
16+
"directories": {
17+
"lib": "dist",
18+
"test": "__tests__"
19+
},
20+
"files": [
21+
"dist"
22+
],
23+
"repository": {
24+
"type": "git",
25+
"url": "git+https://github.com/datocms/structured-text.git"
26+
},
27+
"scripts": {
28+
"build": "tsc && tsc --project ./tsconfig.esnext.json",
29+
"prebuild": "rimraf dist"
30+
},
31+
"bugs": {
32+
"url": "https://github.com/datocms/structured-text/issues"
33+
},
34+
"dependencies": {
35+
"datocms-structured-text-utils": "1.2.0",
36+
"lodash-es": "^4.17.21",
37+
"slate": "0.60.1"
38+
},
39+
"devDependencies": {
40+
"@types/lodash-es": "^4.17.5"
41+
}
42+
}

0 commit comments

Comments
 (0)