Skip to content

Commit

Permalink
first version 2
Browse files Browse the repository at this point in the history
  • Loading branch information
pouchcms committed Feb 28, 2024
1 parent 87eb18e commit 45d77d4
Show file tree
Hide file tree
Showing 89 changed files with 26,763 additions and 23,843 deletions.
13 changes: 13 additions & 0 deletions .eslintignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
.DS_Store
node_modules
/build
/.svelte-kit
/package
.env
.env.*
!.env.example

# Ignore files for PNPM, NPM and YARN
pnpm-lock.yaml
package-lock.json
yarn.lock
15 changes: 15 additions & 0 deletions .eslintrc.cjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
/** @type { import("eslint").Linter.Config } */
module.exports = {
root: true,
extends: ['eslint:recommended', 'plugin:svelte/recommended', 'prettier'],
parserOptions: {
sourceType: 'module',
ecmaVersion: 2020,
extraFileExtensions: ['.svelte']
},
env: {
browser: true,
es2017: true,
node: true
}
};
14 changes: 10 additions & 4 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
/node_modules/
/public/build/

.DS_Store
package-lock.json
/node_modules
/build
/dist
/.svelte-kit
/package
.env
.env.*
!.env.example
vite.config.js.timestamp-*
vite.config.ts.timestamp-*
11 changes: 11 additions & 0 deletions .npmignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
.DS_Store
/node_modules
/build
/.svelte-kit
/package
/static
.env
.env.*
!.env.example
vite.config.js.timestamp-*
vite.config.ts.timestamp-*
1 change: 1 addition & 0 deletions .npmrc
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
engine-strict=true
4 changes: 4 additions & 0 deletions .prettierignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
# Ignore files for PNPM, NPM and YARN
pnpm-lock.yaml
package-lock.json
yarn.lock
8 changes: 8 additions & 0 deletions .prettierrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
{
"useTabs": true,
"singleQuote": true,
"trailingComma": "none",
"printWidth": 100,
"plugins": ["prettier-plugin-svelte"],
"overrides": [{ "files": "*.svelte", "options": { "parser": "svelte" } }]
}
73 changes: 48 additions & 25 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,37 +1,60 @@

# svelte editorjs
## sveditorjs v2

simple editorjs wrapper in svelte
sveditorjs can be embed into any svelte or sveltekit project,the editor is wraped around editorjs ,for block editing that outputs clean json document.json can be consumed by any app.

![alt text](https://github.com/pouchcms/sveditorjs/blob/master/ScreenShot%20Tool%20-20231030152142.png?raw=true)
on version we added support for sveltekit
and added a utility helper
that generates html

## docs and example
see the docs and example here [sveditorjs](https://sveditorjs.vercel.app):

```bash
npm install sveditorjs

//load the editor

import {Editor,editor} from 'sveditorjs';

Editor => is the editor svelte component
editor => is the editor instance

required props are data and url endpoint for image uploads

npm install --save sveditorjs
```

follow doc at
[docs](https://editorjs.io/)
for advance usage


```js
<script>
//this for testing purpose
import {Editor,editor} from "sveditorjs";


import Editor ,{genHtml} from "$lib/index.js";

let modes = {
'js': 'JavaScript',
'py': 'Python',
'go': 'Go',
'cpp': 'C++',
'cs': 'C#',
'md': 'Markdown',
}
let data = {}; //correct editorjs json data
let urls = {} //this object should be
//{
upload:"",
load:"",
}
async function handleChange(ev){
console.log(ev.detail)
let editor = ev.detail.editor;
editor.save().then(async (savedData)=>{
// do something with data
console.log(window.current_sveditor);
// use helper to gen html
let html = await genHtml(savedData);
console.log(html);
}).catch((err)=>{console.log(err)})
}
</script>
<Editor >

<Editor data={data} urls={urls} modes={modes} top="true" aside="true" on:editor_ready={(ev)=>{console.log("ready",ev.detail)}} on:editor_change ={(ev)=>{handleChange(ev)}} >
<svelte:fragment slot="top" >
top
</svelte:fragment>
<svelte:fragment slot="aside" >
aside
</svelte:fragment>
<svelte:fragment slot="extra" >
extra unstyled
</svelte:fragment>
</Editor>


```
3 changes: 0 additions & 3 deletions index.js

This file was deleted.

12 changes: 12 additions & 0 deletions jsconfig.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
{
"extends": "./.svelte-kit/tsconfig.json",
"compilerOptions": {
"esModuleInterop": true,
"forceConsistentCasingInFileNames": true,
"resolveJsonModule": true,
"skipLibCheck": true,
"sourceMap": true,
"module": "NodeNext",
"moduleResolution": "NodeNext"
}
}
Loading

0 comments on commit 45d77d4

Please sign in to comment.