Skip to content
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Commit ca93b9d

Browse files
committedSep 3, 2020
Initial commit
0 parents  commit ca93b9d

16 files changed

+3333
-0
lines changed
 

‎.github/workflows/linter.yml

+22
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
name: Lint Code Base
2+
on:
3+
push:
4+
branches:
5+
- master
6+
pull_request:
7+
branches:
8+
- master
9+
jobs:
10+
build:
11+
name: Lint Code Base
12+
runs-on: ubuntu-latest
13+
steps:
14+
- name: Checkout Code
15+
uses: actions/checkout@v2
16+
- name: Lint Code Base
17+
uses: docker://github/super-linter:v3
18+
env:
19+
DEFAULT_BRANCH: master
20+
VALIDATE_ALL_CODEBASE: false
21+
VALIDATE_JAVASCRIPT_STANDARD: false
22+
VALIDATE_TYPESCRIPT_STANDARD: false

‎.github/workflows/test.yml

+19
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
name: Test
2+
on:
3+
push:
4+
branches:
5+
- master
6+
pull_request:
7+
branches:
8+
- master
9+
jobs:
10+
test:
11+
runs-on: ubuntu-latest
12+
steps:
13+
- uses: actions/checkout@v2
14+
- uses: actions/setup-node@v1
15+
with:
16+
node-version: 12.x
17+
- run: yarn
18+
- run: yarn test
19+
- uses: codecov/codecov-action@v1

‎.gitignore

+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
.cache
2+
.DS_Store
3+
coverage
4+
node_modules
5+
yarn-error.log

‎.prettierignore

+4
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
DISCLAIMER.md
2+
coverage
3+
dist
4+
src/generated

‎.prettierrc.json

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
{
2+
"singleQuote": true
3+
}

‎CODE_OF_CONDUCT.md

+128
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,128 @@
1+
# Contributor Covenant Code of Conduct
2+
3+
## Our Pledge
4+
5+
We as members, contributors, and leaders pledge to make participation in our
6+
community a harassment-free experience for everyone, regardless of age, body
7+
size, visible or invisible disability, ethnicity, sex characteristics, gender
8+
identity and expression, level of experience, education, socio-economic status,
9+
nationality, personal appearance, race, religion, or sexual identity
10+
and orientation.
11+
12+
We pledge to act and interact in ways that contribute to an open, welcoming,
13+
diverse, inclusive, and healthy community.
14+
15+
## Our Standards
16+
17+
Examples of behavior that contributes to a positive environment for our
18+
community include:
19+
20+
- Demonstrating empathy and kindness toward other people
21+
- Being respectful of differing opinions, viewpoints, and experiences
22+
- Giving and gracefully accepting constructive feedback
23+
- Accepting responsibility and apologizing to those affected by our mistakes,
24+
and learning from the experience
25+
- Focusing on what is best not just for us as individuals, but for the
26+
overall community
27+
28+
Examples of unacceptable behavior include:
29+
30+
- The use of sexualized language or imagery, and sexual attention or
31+
advances of any kind
32+
- Trolling, insulting or derogatory comments, and personal or political attacks
33+
- Public or private harassment
34+
- Publishing others' private information, such as a physical or email
35+
address, without their explicit permission
36+
- Other conduct which could reasonably be considered inappropriate in a
37+
professional setting
38+
39+
## Enforcement Responsibilities
40+
41+
Community leaders are responsible for clarifying and enforcing our standards of
42+
acceptable behavior and will take appropriate and fair corrective action in
43+
response to any behavior that they deem inappropriate, threatening, offensive,
44+
or harmful.
45+
46+
Community leaders have the right and responsibility to remove, edit, or reject
47+
comments, commits, code, wiki edits, issues, and other contributions that are
48+
not aligned to this Code of Conduct, and will communicate reasons for moderation
49+
decisions when appropriate.
50+
51+
## Scope
52+
53+
This Code of Conduct applies within all community spaces, and also applies when
54+
an individual is officially representing the community in public spaces.
55+
Examples of representing our community include using an official e-mail address,
56+
posting via an official social media account, or acting as an appointed
57+
representative at an online or offline event.
58+
59+
## Enforcement
60+
61+
Instances of abusive, harassing, or otherwise unacceptable behavior may be
62+
reported to the community leaders responsible for enforcement at
63+
hato6502@gmail.com.
64+
All complaints will be reviewed and investigated promptly and fairly.
65+
66+
All community leaders are obligated to respect the privacy and security of the
67+
reporter of any incident.
68+
69+
## Enforcement Guidelines
70+
71+
Community leaders will follow these Community Impact Guidelines in determining
72+
the consequences for any action they deem in violation of this Code of Conduct:
73+
74+
### 1. Correction
75+
76+
**Community Impact**: Use of inappropriate language or other behavior deemed
77+
unprofessional or unwelcome in the community.
78+
79+
**Consequence**: A private, written warning from community leaders, providing
80+
clarity around the nature of the violation and an explanation of why the
81+
behavior was inappropriate. A public apology may be requested.
82+
83+
### 2. Warning
84+
85+
**Community Impact**: A violation through a single incident or series
86+
of actions.
87+
88+
**Consequence**: A warning with consequences for continued behavior. No
89+
interaction with the people involved, including unsolicited interaction with
90+
those enforcing the Code of Conduct, for a specified period of time. This
91+
includes avoiding interactions in community spaces as well as external channels
92+
like social media. Violating these terms may lead to a temporary or
93+
permanent ban.
94+
95+
### 3. Temporary Ban
96+
97+
**Community Impact**: A serious violation of community standards, including
98+
sustained inappropriate behavior.
99+
100+
**Consequence**: A temporary ban from any sort of interaction or public
101+
communication with the community for a specified period of time. No public or
102+
private interaction with the people involved, including unsolicited interaction
103+
with those enforcing the Code of Conduct, is allowed during this period.
104+
Violating these terms may lead to a permanent ban.
105+
106+
### 4. Permanent Ban
107+
108+
**Community Impact**: Demonstrating a pattern of violation of community
109+
standards, including sustained inappropriate behavior, harassment of an
110+
individual, or aggression toward or disparagement of classes of individuals.
111+
112+
**Consequence**: A permanent ban from any sort of public interaction within
113+
the community.
114+
115+
## Attribution
116+
117+
This Code of Conduct is adapted from the [Contributor Covenant][homepage],
118+
version 2.0, available at
119+
https://www.contributor-covenant.org/version/2/0/code_of_conduct.html.
120+
121+
Community Impact Guidelines were inspired by [Mozilla's code of conduct
122+
enforcement ladder](https://github.com/mozilla/diversity).
123+
124+
[homepage]: https://www.contributor-covenant.org
125+
126+
For answers to common questions about this code of conduct, see the FAQ at
127+
https://www.contributor-covenant.org/faq. Translations are available at
128+
https://www.contributor-covenant.org/translations.

‎LICENSE

+21
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
MIT License
2+
3+
Copyright (c) 2020 Tomoyuki Hata
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.

‎README.md

+14
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
# editorjs-style
2+
3+
Inline-style Tool for Editor.js
4+
5+
## 💡 Motivation
6+
7+
Editor.js may need many inline tools to styling inline elements.
8+
By attaching any id, class and style to inline elements, it can be used like a HTML editor.
9+
10+
**Note: This is an experimental inline tool 🔬**
11+
12+
## ✨ Demo
13+
14+
[Live demo](https://hata6502.github.io/editorjs-style/)

‎dist/index.d.ts

+13
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
import type { InlineTool, InlineToolConstructorOptions } from '@editorjs/editorjs';
2+
declare class EditorJSStyle implements InlineTool {
3+
static get isInline(): boolean;
4+
static get sanitize(): {};
5+
static get title(): string;
6+
private api;
7+
constructor({ api }: InlineToolConstructorOptions);
8+
get shortcut(): string;
9+
surround(range: Range): void;
10+
checkState(): boolean;
11+
render(): HTMLButtonElement;
12+
}
13+
export default EditorJSStyle;

‎dist/index.js

+1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

‎index.html

+44
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
<!DOCTYPE html>
2+
<html>
3+
<head>
4+
<meta charset="utf-8" />
5+
<title>editorjs-style</title>
6+
<script src="dist/index.js"></script>
7+
<script src="https://cdn.jsdelivr.net/npm/@editorjs/editorjs@latest"></script>
8+
</head>
9+
10+
<body>
11+
<div id="editorjs"></div>
12+
<button id="button" type="button">Save</button>
13+
<div id="output-data"></div>
14+
<script>
15+
const data = {
16+
time: 1598789264099,
17+
blocks: [
18+
{
19+
type: 'paragraph',
20+
data: {
21+
text: 'editorjs-style test',
22+
},
23+
},
24+
],
25+
version: '2.18.0',
26+
};
27+
28+
const editorJS = new EditorJS({
29+
data,
30+
tools: {
31+
editorJSStyle,
32+
},
33+
});
34+
35+
document.querySelector('#button').addEventListener('click', async () => {
36+
const outputData = await editorJS.save();
37+
38+
document.querySelector('#output-data').textContent = JSON.stringify(
39+
outputData
40+
);
41+
});
42+
</script>
43+
</body>
44+
</html>

‎package.json

+33
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
{
2+
"name": "editorjs-style",
3+
"version": "0.0.0",
4+
"description": "Inline-style Tool for Editor.js",
5+
"keywords": [
6+
"codex",
7+
"editor",
8+
"style",
9+
"tool",
10+
"editor.js",
11+
"editorjs"
12+
],
13+
"repository": "https://github.com/hata6502/editorjs-style",
14+
"license": "MIT",
15+
"author": "hata6502",
16+
"main": "dist/index.js",
17+
"scripts": {
18+
"fix": "prettier --write .",
19+
"generate-disclaimer": "yarn licenses generate-disclaimer --ignore-platform > DISCLAIMER.md",
20+
"license-checker": "license-checker --excludePackages 'css-select@1.2.0;dictionary-en@3.0.0;domutils@1.5.1;optimist@0.6.1;tiny-segmenter@0.2.0;trim@0.0.1;union@0.5.0;unorm@1.6.0;zlibjs@0.2.0' --excludePrivatePackages --onlyAllow 'Apache-2.0;BSD;BSD-2-Clause;BSD-3-Clause;CC0-1.0;CC-BY-3.0;CC-BY-4.0;ISC;MIT;Public Domain;Unlicense;WTFPL' --production --unknown > /dev/null",
21+
"test": "tsc --noEmit",
22+
"webpack": "webpack"
23+
},
24+
"devDependencies": {
25+
"@editorjs/editorjs": "^2.18.0",
26+
"license-checker": "^25.0.1",
27+
"prettier": "^2.0.5",
28+
"ts-loader": "^8.0.3",
29+
"typescript": "^4.0.2",
30+
"webpack": "^4.44.1",
31+
"webpack-cli": "^3.3.12"
32+
}
33+
}

‎src/index.ts

+59
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
import type {
2+
API,
3+
InlineTool,
4+
InlineToolConstructorOptions,
5+
} from '@editorjs/editorjs';
6+
7+
class EditorJSStyle implements InlineTool {
8+
static get isInline() {
9+
return true;
10+
}
11+
12+
static get sanitize() {
13+
return {
14+
/*span: {
15+
'data-editorjs-inline': true,
16+
},*/
17+
};
18+
}
19+
20+
static get title() {
21+
return 'Style';
22+
}
23+
24+
private api: API;
25+
26+
constructor({ api }: InlineToolConstructorOptions) {
27+
this.api = api;
28+
}
29+
30+
get shortcut() {
31+
return 'CMD+E';
32+
}
33+
34+
surround(range: Range) {}
35+
36+
checkState() {
37+
return false;
38+
}
39+
40+
render() {
41+
const button = document.createElement('button');
42+
43+
button.classList.add(this.api.styles.inlineToolButton);
44+
button.type = 'button';
45+
button.innerHTML = `
46+
<svg class="icon" viewBox="0 0 14 14">
47+
<g stroke="currentColor" stroke-width="2">
48+
<circle cx="7" cy="7" r="6" fill="none" />
49+
<line x1="4" y1="7" x2="10" y2="7" />
50+
<line x1="7" y1="4" x2="7" y2="10" />
51+
</g>
52+
</svg>
53+
`;
54+
55+
return button;
56+
}
57+
}
58+
59+
export default EditorJSStyle;

‎tsconfig.json

+15
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
{
2+
"compilerOptions": {
3+
"allowSyntheticDefaultImports": true,
4+
"declaration": true,
5+
"lib": ["ESNext", "DOM"],
6+
"module": "ESNext",
7+
"moduleResolution": "node",
8+
"outDir": "dist",
9+
"pretty": true,
10+
"skipLibCheck": true,
11+
"sourceMap": true,
12+
"strict": true,
13+
"target": "ES5"
14+
}
15+
}

‎webpack.config.js

+20
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
module.exports = {
2+
mode: 'production',
3+
module: {
4+
rules: [
5+
{
6+
test: /\.tsx?$/,
7+
loader: 'ts-loader',
8+
},
9+
],
10+
},
11+
resolve: {
12+
extensions: ['.js', '.jsx', '.ts', '.tsx'],
13+
},
14+
output: {
15+
filename: 'index.js',
16+
library: 'EditorJSStyle',
17+
libraryExport: 'default',
18+
libraryTarget: 'umd',
19+
},
20+
};

‎yarn.lock

+2,932
Large diffs are not rendered by default.

0 commit comments

Comments
 (0)
Please sign in to comment.