-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Implement UI for abstract and lineage tags
With tiptap editor 🪄 SAEON/odp-server#32
- Loading branch information
1 parent
d1d9259
commit 89f66b8
Showing
24 changed files
with
49,956 additions
and
44 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
{% macro render_editor( | ||
element_id | ||
) %} | ||
<div class="btn-toolbar mb-3"> | ||
<div class="btn-group"> | ||
{% for command in 'bold', 'italic', 'underline', 'subscript', 'superscript' %} | ||
<button type="button" id="{{ element_id }}-{{ command }}" title="{{ command | title }}" | ||
class="btn btn-outline-info btn-icon ri-{{ command }}"></button> | ||
{% endfor %} | ||
</div> | ||
</div> | ||
<div id="{{ element_id }}"></div> | ||
{% endmacro %} | ||
|
||
{% macro init_editor( | ||
element_id, | ||
form_id=none, | ||
field_id=none, | ||
modal_id=none, | ||
content='' | ||
) %} | ||
<script type="module"> | ||
import {createEditor} from "{{ url_for('static', filename='scripts/editor.js') }}"; | ||
const {{ element_id }}Editor = createEditor('{{ element_id }}', '{{ content }}'); | ||
{% for command in 'bold', 'italic', 'underline', 'subscript', 'superscript' %} | ||
$("#{{ element_id }}-{{ command }}").bind("click", (event) => { | ||
{{ element_id }}Editor.chain().focus().toggle{{ command | title }}().run(); | ||
}); | ||
{% endfor %} | ||
{% if form_id and field_id %} | ||
$("#{{ form_id }}").bind("submit", (event) => { | ||
$("#{{ field_id }}").val({{ element_id }}Editor.getHTML()); | ||
}); | ||
{% endif %} | ||
{% if modal_id %} | ||
$("#{{ modal_id }}").bind("shown.bs.modal", (event) => { | ||
{{ element_id }}Editor.chain().focus().run(); | ||
}); | ||
{% endif %} | ||
</script> | ||
{% endmacro %} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
import {Editor} from 'https://esm.sh/@tiptap/core' | ||
import Document from 'https://esm.sh/@tiptap/extension-document' | ||
import Paragraph from 'https://esm.sh/@tiptap/extension-paragraph' | ||
import Text from 'https://esm.sh/@tiptap/extension-text' | ||
import Bold from 'https://esm.sh/@tiptap/extension-bold' | ||
import Italic from 'https://esm.sh/@tiptap/extension-italic' | ||
import Underline from 'https://esm.sh/@tiptap/extension-underline' | ||
import Subscript from 'https://esm.sh/@tiptap/extension-subscript' | ||
import Superscript from 'https://esm.sh/@tiptap/extension-superscript' | ||
|
||
export function createEditor(elementId, content) { | ||
return new Editor({ | ||
element: document.querySelector(`#${elementId}`), | ||
content: content, | ||
extensions: [ | ||
Document, | ||
Paragraph, | ||
Text, | ||
Bold, | ||
Italic, | ||
Underline, | ||
Subscript, | ||
Superscript, | ||
], | ||
editorProps: { | ||
attributes: { | ||
class: 'prose prose-sm sm:prose lg:prose-lg xl:prose-2xl mx-auto focus:outline-none ' + | ||
'border', | ||
}, | ||
}, | ||
}); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Large diffs are not rendered by default.
Oops, something went wrong.
Oops, something went wrong.