├── src
├── global.d.ts
├── lib
│ ├── index.js
│ ├── sass
│ │ └── _mixins.scss
│ ├── icons
│ │ ├── IconHeading.svelte
│ │ ├── IconParagraph.svelte
│ │ ├── IconCode.svelte
│ │ └── IconQuote.svelte
│ ├── Float.svelte
│ ├── Tooltip.svelte
│ └── Editor.svelte
├── routes
│ ├── __layout.svelte
│ ├── api.svelte
│ ├── index.svelte
│ └── styling.svelte
└── app.html
├── .gitignore
├── static
└── favicon.png
├── .prettierrc
├── svelte.config.js
├── .github
└── workflows
│ ├── check.yml
│ └── publish.yml
├── .eslintrc.cjs
├── tsconfig.json
├── LICENSE
├── .all-contributorsrc
├── package.json
└── README.md
/src/global.d.ts:
--------------------------------------------------------------------------------
1 | ///
2 |
--------------------------------------------------------------------------------
/src/lib/index.js:
--------------------------------------------------------------------------------
1 | export { default as OmniaEditor } from './Editor.svelte';
2 |
--------------------------------------------------------------------------------
/.gitignore:
--------------------------------------------------------------------------------
1 | .DS_Store
2 | node_modules
3 | /build
4 | /.svelte-kit
5 | /package
6 | .env
7 |
--------------------------------------------------------------------------------
/static/favicon.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/TorstenDittmann/omnia-editor/HEAD/static/favicon.png
--------------------------------------------------------------------------------
/src/lib/sass/_mixins.scss:
--------------------------------------------------------------------------------
1 | @mixin on-mobile {
2 | @media (max-width: 690px) {
3 | @content;
4 | }
5 | }
6 |
--------------------------------------------------------------------------------
/.prettierrc:
--------------------------------------------------------------------------------
1 | {
2 | "useTabs": true,
3 | "singleQuote": true,
4 | "trailingComma": "none",
5 | "printWidth": 100
6 | }
7 |
--------------------------------------------------------------------------------
/src/lib/icons/IconHeading.svelte:
--------------------------------------------------------------------------------
1 |
5 |
--------------------------------------------------------------------------------
/src/lib/icons/IconParagraph.svelte:
--------------------------------------------------------------------------------
1 |
5 |
--------------------------------------------------------------------------------
/svelte.config.js:
--------------------------------------------------------------------------------
1 | import preprocess from 'svelte-preprocess';
2 | import adapter from '@sveltejs/adapter-static';
3 |
4 | /** @type {import('@sveltejs/kit').Config} */
5 | const config = {
6 | preprocess: preprocess(),
7 | kit: {
8 | target: '#editor',
9 | adapter: adapter()
10 | }
11 | };
12 |
13 | export default config;
14 |
--------------------------------------------------------------------------------
/src/lib/icons/IconCode.svelte:
--------------------------------------------------------------------------------
1 |
8 |
--------------------------------------------------------------------------------
/.github/workflows/check.yml:
--------------------------------------------------------------------------------
1 | name: Check
2 |
3 | on: pull_request
4 |
5 | jobs:
6 | build:
7 | runs-on: ubuntu-latest
8 | steps:
9 | - uses: actions/checkout@v1
10 | - uses: actions/setup-node@v1
11 | with:
12 | node-version: 16
13 | registry-url: https://registry.npmjs.org/
14 | - run: npm ci
15 | - run: npm run check
16 |
--------------------------------------------------------------------------------
/.github/workflows/publish.yml:
--------------------------------------------------------------------------------
1 | name: Publish
2 |
3 | on:
4 | release:
5 | types: [published]
6 |
7 | jobs:
8 | build:
9 | runs-on: ubuntu-latest
10 | steps:
11 | - uses: actions/checkout@v1
12 | - uses: actions/setup-node@v1
13 | with:
14 | node-version: 16
15 | registry-url: https://registry.npmjs.org/
16 | - run: npm ci
17 | - run: npm run package
18 | - run: cd package && npm publish --access public
19 | env:
20 | NODE_AUTH_TOKEN: ${{secrets.NPM_TOKEN}}
21 |
--------------------------------------------------------------------------------
/.eslintrc.cjs:
--------------------------------------------------------------------------------
1 | module.exports = {
2 | root: true,
3 | parser: '@typescript-eslint/parser',
4 | extends: ['eslint:recommended', 'plugin:@typescript-eslint/recommended', 'prettier'],
5 | plugins: ['svelte3', '@typescript-eslint'],
6 | ignorePatterns: ['*.cjs'],
7 | overrides: [{ files: ['*.svelte'], processor: 'svelte3/svelte3' }],
8 | settings: {
9 | 'svelte3/typescript': () => require('typescript')
10 | },
11 | parserOptions: {
12 | sourceType: 'module',
13 | ecmaVersion: 2019
14 | },
15 | env: {
16 | browser: true,
17 | es2017: true,
18 | node: true
19 | }
20 | };
21 |
--------------------------------------------------------------------------------
/src/routes/__layout.svelte:
--------------------------------------------------------------------------------
1 |
8 |
9 |
10 |
11 |
12 |
13 |
33 |
--------------------------------------------------------------------------------
/src/app.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
20 | %svelte.head%
21 |
22 |
23 | %svelte.body%
24 |
25 |
26 |
--------------------------------------------------------------------------------
/src/lib/icons/IconQuote.svelte:
--------------------------------------------------------------------------------
1 |
13 |
--------------------------------------------------------------------------------
/tsconfig.json:
--------------------------------------------------------------------------------
1 | {
2 | "compilerOptions": {
3 | "moduleResolution": "node",
4 | "module": "es2020",
5 | "lib": ["es2020", "DOM"],
6 | "target": "es2020",
7 | /**
8 | svelte-preprocess cannot figure out whether you have a value or a type, so tell TypeScript
9 | to enforce using \`import type\` instead of \`import\` for Types.
10 | */
11 | "importsNotUsedAsValues": "error",
12 | "isolatedModules": true,
13 | "resolveJsonModule": true,
14 | /**
15 | To have warnings/errors of the Svelte compiler at the correct position,
16 | enable source maps by default.
17 | */
18 | "sourceMap": true,
19 | "esModuleInterop": true,
20 | "skipLibCheck": true,
21 | "forceConsistentCasingInFileNames": true,
22 | "baseUrl": ".",
23 | "allowJs": true,
24 | "checkJs": true,
25 | "paths": {
26 | "$lib": ["src/lib"],
27 | "$lib/*": ["src/lib/*"]
28 | }
29 | },
30 | "include": ["src/**/*.d.ts", "src/**/*.js", "src/**/*.ts", "src/**/*.svelte"]
31 | }
32 |
--------------------------------------------------------------------------------
/src/routes/api.svelte:
--------------------------------------------------------------------------------
1 |
19 |
20 | Output
21 |
22 |
23 | {#if output}
24 |
25 | {/if}
26 |
27 |
28 | History
29 |
30 |
31 |
32 |
33 |
--------------------------------------------------------------------------------
/LICENSE:
--------------------------------------------------------------------------------
1 | MIT License
2 |
3 | Copyright (c) 2020 Torsten Dittmann
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.
22 |
--------------------------------------------------------------------------------
/.all-contributorsrc:
--------------------------------------------------------------------------------
1 | {
2 | "files": [
3 | "README.md"
4 | ],
5 | "imageSize": 100,
6 | "commit": false,
7 | "contributors": [
8 | {
9 | "login": "AntonyBoucher",
10 | "name": "AntonyBoucher",
11 | "avatar_url": "https://avatars3.githubusercontent.com/u/69065091?v=4",
12 | "profile": "https://github.com/AntonyBoucher",
13 | "contributions": [
14 | "code"
15 | ]
16 | },
17 | {
18 | "login": "TorstenDittmann",
19 | "name": "Torsten Dittmann",
20 | "avatar_url": "https://avatars1.githubusercontent.com/u/1759475?v=4",
21 | "profile": "https://torstendittmann.now.sh",
22 | "contributions": [
23 | "test",
24 | "code"
25 | ]
26 | },
27 | {
28 | "login": "dennistobar",
29 | "name": "Dennis Tobar",
30 | "avatar_url": "https://avatars1.githubusercontent.com/u/1218182?v=4",
31 | "profile": "https://twitter.com/dennistobar",
32 | "contributions": [
33 | "code"
34 | ]
35 | }
36 | ],
37 | "contributorsPerLine": 7,
38 | "projectName": "omnia-editor",
39 | "projectOwner": "TorstenDittmann",
40 | "repoType": "github",
41 | "repoHost": "https://github.com",
42 | "skipCi": true
43 | }
44 |
--------------------------------------------------------------------------------
/package.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "omnia-editor",
3 | "version": "1.0.0-beta.1",
4 | "scripts": {
5 | "dev": "svelte-kit dev",
6 | "build": "svelte-kit build",
7 | "preview": "svelte-kit preview",
8 | "package": "svelte-kit package",
9 | "check": "svelte-check --tsconfig ./tsconfig.json",
10 | "check:watch": "svelte-check --tsconfig ./tsconfig.json --watch",
11 | "lint": "prettier --ignore-path .gitignore --check --plugin-search-dir=. . && eslint --ignore-path .gitignore .",
12 | "format": "prettier --ignore-path .gitignore --write --plugin-search-dir=. ."
13 | },
14 | "devDependencies": {
15 | "@sveltejs/adapter-static": "^1.0.0-next.21",
16 | "@sveltejs/kit": "next",
17 | "@typescript-eslint/eslint-plugin": "^5.6.0",
18 | "@typescript-eslint/parser": "^5.6.0",
19 | "eslint": "^8.4.0",
20 | "eslint-config-prettier": "^8.3.0",
21 | "eslint-plugin-svelte3": "^3.2.1",
22 | "prettier": "^2.4.1",
23 | "prettier-plugin-svelte": "^2.4.0",
24 | "sass": "^1.43.4",
25 | "svelte": "^3.42.6",
26 | "svelte-check": "^2.2.6",
27 | "svelte-preprocess": "^4.9.4",
28 | "svelte2tsx": "^0.4.10",
29 | "tslib": "^2.3.1",
30 | "typescript": "^4.4.3"
31 | },
32 | "type": "module",
33 | "dependencies": {
34 | "@tiptap/core": "*",
35 | "@tiptap/extension-bubble-menu": "*",
36 | "@tiptap/extension-floating-menu": "*",
37 | "@tiptap/extension-focus": "*",
38 | "@tiptap/extension-history": "*",
39 | "@tiptap/extension-placeholder": "*",
40 | "@tiptap/extension-text-align": "*",
41 | "@tiptap/starter-kit": "*"
42 | }
43 | }
44 |
--------------------------------------------------------------------------------
/src/lib/Float.svelte:
--------------------------------------------------------------------------------
1 |
11 |
12 |
13 | {#if editor}
14 |
20 |
26 |
32 |
38 |
44 | {/if}
45 |
46 |
47 |
79 |
--------------------------------------------------------------------------------
/src/lib/Tooltip.svelte:
--------------------------------------------------------------------------------
1 |
10 |
11 |
12 | {#if editor}
13 |
19 |
25 |
31 |
37 |
43 |
49 |
50 | |
51 |
57 |
63 |
69 |
75 |
81 | {/if}
82 |
83 |
84 |
119 |
--------------------------------------------------------------------------------
/src/routes/index.svelte:
--------------------------------------------------------------------------------
1 |
7 |
8 |
9 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | # omnia-editor
2 |
3 | [](#contributors-)
4 |
5 |
6 | ## Usage in Svelte
7 |
8 | ```bash
9 | npm i omnia-editor
10 | # or
11 | yarn add omnia-editor
12 | ```
13 |
14 | ```svelte
15 |
18 |
19 |
20 | ```
21 |
22 | ## Properties
23 |
24 | ### **value**_: string;_
25 | Initial value of the content.
26 |
27 | ### **editor**_: Editor;_
28 | TipTap instance of the Editor.
29 |
30 | ### **spellcheck**_: boolean;_
31 | Use spellcheck.
32 |
33 | ## Methods
34 |
35 | ### **getJSON()**_: Object;_
36 | Get the document as JSON.
37 | ### **getHTML()**_: string;_
38 | Get the document as HTML.
39 |
40 | ### **getCharacterCount()**_: number;_
41 | Get the number of characters for the current document.
42 |
43 | ### **isFocused()**_: boolean;_
44 | Returns `true` when Editor is focused.
45 |
46 | ### **isEmpty()**_: boolean;_
47 | Returns `true` if there is no content.
48 |
49 | ### **blur()**_: boolean;_
50 | Removes focus from the editor.
51 |
52 | ### **focus(position)**_: boolean;_
53 | Focus the editor at the given position.
54 |
55 | Set the focus to the editor
56 | ```focus()```
57 |
58 | Set the cursor to the first position
59 | ```focus('start')```
60 |
61 | Set the cursor to the last position
62 | ```focus('end')```
63 |
64 | Selects the whole document
65 | ```focus('all')```
66 |
67 | Set the cursor to position 10
68 | ```focus(10)```
69 |
70 | ### **undo()**_: boolean;_
71 | Undo recent changes.
72 |
73 | ### **redo()**_: boolean;_
74 | Reapply reverted changes.
75 |
76 | ### **destroy()**_: void;_
77 | Destroy the editor.
78 |
79 | ## Events
80 |
81 | ### **on:init**
82 | Triggered when the editor is initialized.
83 |
84 | ### **on:focus**
85 | Triggered when the editor is focused.
86 |
87 | ### **on:blur**
88 | Triggered when the editor looses focus.
89 |
90 | ### **on:change**
91 | Triggered when the editors content changes.
92 |
93 | ## Contributors ✨
94 |
95 | Thanks goes to these wonderful people ([emoji key](https://allcontributors.org/docs/en/emoji-key)):
96 |
97 |
98 |
99 |
100 |
107 |
108 |
109 |
110 |
111 |
112 | This project follows the [all-contributors](https://github.com/all-contributors/all-contributors) specification. Contributions of any kind welcome!
--------------------------------------------------------------------------------
/src/routes/styling.svelte:
--------------------------------------------------------------------------------
1 |
6 |
7 |
8 |
9 |
10 |
11 |
24 |
--------------------------------------------------------------------------------
/src/lib/Editor.svelte:
--------------------------------------------------------------------------------
1 |
128 |
129 |
130 |
138 |
139 |
140 |
141 |
142 |
143 |
144 |
145 |
146 |
193 |
--------------------------------------------------------------------------------