Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: List 2.0 #76

Merged
merged 43 commits into from
Aug 7, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
43 commits
Select commit Hold shift + click to select a range
16d85dd
implemented dev model
e11sy Aug 1, 2024
88eb6c6
added ol and ul list renderer classes
e11sy Aug 1, 2024
d057bca
patched types
e11sy Aug 1, 2024
da80ff6
added styles for checklist
e11sy Aug 1, 2024
2afda74
pathced style names
e11sy Aug 1, 2024
e7a585e
added checklist renderer
e11sy Aug 1, 2024
7cbd0d7
separated list renderer classes
e11sy Aug 1, 2024
7452185
types separated
e11sy Aug 1, 2024
d949cbc
added tabulator class
e11sy Aug 1, 2024
df88c86
added new index
e11sy Aug 2, 2024
d46b8dd
list types switch implemented
e11sy Aug 2, 2024
5bae2c0
content is editable
e11sy Aug 2, 2024
dd576b9
ordered list item numbering improved
e11sy Aug 3, 2024
0da5fd1
children styles updated
e11sy Aug 3, 2024
3227a52
fixed saving and content format
e11sy Aug 3, 2024
d484ff8
refactored checkbox styles
e11sy Aug 3, 2024
e04e8df
now tool saving data with meta field
e11sy Aug 3, 2024
a180404
comments improved
e11sy Aug 3, 2024
3d1ef9d
get rid of ex.ts
e11sy Aug 3, 2024
9064c1b
comments improved in types
e11sy Aug 3, 2024
d9110c9
removed unneded for dev mode tools from index
e11sy Aug 3, 2024
f899714
for ordered and unordered list item meta would be {}
e11sy Aug 3, 2024
fdac5a2
added private class properties
e11sy Aug 3, 2024
78d8f32
moved click event delegation from `toggleCheckbox()`
e11sy Aug 3, 2024
8de6984
separated types
e11sy Aug 3, 2024
b4cf738
added `currentLevel` property for ListTabulator
e11sy Aug 3, 2024
91b7cfa
minor fix
e11sy Aug 3, 2024
cf25166
separated css styles for different classes
e11sy Aug 3, 2024
717f079
comments improved
e11sy Aug 3, 2024
99eebd6
files renaming
e11sy Aug 3, 2024
a9e2507
files renaming
e11sy Aug 3, 2024
5903be0
list css classes interface now extended
e11sy Aug 3, 2024
7314e07
style fix
e11sy Aug 3, 2024
348da48
removed itemBody
e11sy Aug 5, 2024
1a012b2
changed addTab behaviour
e11sy Aug 6, 2024
20e6073
file renaming
e11sy Aug 7, 2024
e2a8d6f
file renaming
e11sy Aug 7, 2024
a9abfa3
file renaming
e11sy Aug 7, 2024
c60e9fe
renaming
e11sy Aug 7, 2024
ac07f38
renaming
e11sy Aug 7, 2024
3bb7736
List renderer now interface
e11sy Aug 7, 2024
3d87c88
filled list renderer interface
e11sy Aug 7, 2024
d38e7b2
comment improved
e11sy Aug 7, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
232 changes: 232 additions & 0 deletions index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,232 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Editor.js 🤩🧦🤨 example</title>
<link href="https://fonts.googleapis.com/css?family=PT+Mono" rel="stylesheet">
<link href="/example/assets/demo.css" rel="stylesheet">
<script src="/example/assets/json-preview.js"></script>
<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no" />
</head>
<body>
<div class="ce-example">
<div class="ce-example__header">
<a class="ce-example__header-logo" href="https://codex.so/editor">Editor.js 🤩🧦🤨</a>

<div class="ce-example__header-menu">
<a href="https://github.com/editor-js" target="_blank">Plugins</a>
<a href="https://editorjs.io/usage" target="_blank">Usage</a>
<a href="https://editorjs.io/configuration" target="_blank">Configuration</a>
<a href="https://editorjs.io/creating-a-block-tool" target="_blank">API</a>
</div>
</div>
<div class="ce-example__content _ce-example__content--small">
<div id="editorjs"></div>

<div class="ce-example__button" id="saveButton">
editor.save()
</div>

<div class="ce-example__statusbar">
Readonly:
<b id="readonly-state">
Off
</b>
<div class="ce-example__statusbar-button" id="toggleReadOnlyButton">
toggle
</div>
</div>
</div>
<div class="ce-example__output">
<pre class="ce-example__output-content" id="output"></pre>

<div class="ce-example__output-footer">
<a href="https://codex.so" style="font-weight: bold;">Made by CodeX</a>
</div>
</div>
</div>

<!-- Load Tools -->
<!--
You can upload Tools to your project's directory and connect them by relative links.

Also you can load each Tool from CDN or use NPM/Yarn packages.

Read more at Tools Connection doc:
https://editorjs.io/getting-started#tools-connection
-->

<!-- Load Editor.js's Core -->
<script src="https://cdn.jsdelivr.net/npm/@editorjs/editorjs@latest"></script>

<!-- Initialization -->
<script type="module">
import List from './src/index.ts';

/**
* To initialize the Editor, create a new instance with configuration object
* @see docs/installation.md for mode details
*/
var editor = new EditorJS({
/**
* Enable/Disable the read only mode
*/
readOnly: false,

/**
* Wrapper of Editor
*/
holder: 'editorjs',

/**
* Common Inline Toolbar settings
* - if true (or not specified), the order from 'tool' property will be used
* - if an array of tool names, this order will be used
*/
// inlineToolbar: ['link', 'marker', 'bold', 'italic'],
// inlineToolbar: true,

/**
* Tools list
*/
tools: {
/**
* Each Tool is a Plugin. Pass them via 'class' option with necessary settings {@link docs/tools.md}
*/
List: {
class: List,
inlineToolbar: true,
shortcut: 'CMD+SHIFT+L',
config: {
defaultStyle: 'checklist'
}
},
},

/**
* This Tool will be used as default
*/
// defaultBlock: 'paragraph',

/**
* Initial Editor data
*/
data: {
blocks: [
{
type : 'List',
data : {
items : [
{
"content": "Canon",
"items": [
{
"content": "Fisheye",
"items": [
{
"content": "Canon 15mm f/2.8",
"items": []
},
]
},
{
"content": "Normal",
"items": [
{
"content": "Canon 40mm f/2.8",
"items": []
},
{
"content": "Canon 50mm f/1.8",
"items": []
},
]
},
{
"content": "Zoom",
"items": [
{
"content": "Canon 75-300mm f/4-5.6",
"items": []
},
]
},
]
},
{
"content": "Tamron",
"items": [
{
"content": "Zoom",
"items": [
{
"content": "Tamron 28-75mm f/2.8",
"items": []
},
]
},
]
},
{
"content": "Samyang",
"items": [
{
"content": "Wide",
"items": [
{
"content": "Samyang 14mm f/2.8",
"items": []
},
]
},
]
},
],
style: 'checklist'
}
},
]
},
onReady: function(){
saveButton.click();
},
onChange: function() {
console.log('something changed');
}
});

/**
* Saving button
*/
const saveButton = document.getElementById('saveButton');

/**
* Toggle read-only button
*/
const toggleReadOnlyButton = document.getElementById('toggleReadOnlyButton');
const readOnlyIndicator = document.getElementById('readonly-state');

/**
* Saving example
*/
saveButton.addEventListener('click', function () {
editor.save()
.then((savedData) => {
cPreview.show(savedData, document.getElementById("output"));
})
.catch((error) => {
console.error('Saving error', error);
});
});

/**
* Toggle read-only example
*/
toggleReadOnlyButton.addEventListener('click', async () => {
const readOnlyState = await editor.readOnly.toggle();

readOnlyIndicator.textContent = readOnlyState ? 'On' : 'Off';
});
</script>
</body>
</html>
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,6 @@
"vite-plugin-dts": "^3.9.1"
},
"dependencies": {
"@codexteam/icons": "^0.0.2"
"@codexteam/icons": "^0.3.2"
}
}
Loading
Loading