-
-
Notifications
You must be signed in to change notification settings - Fork 6.2k
Closed
Labels
type/proposalThe new feature has not been accepted yet but needs to be discussed first.The new feature has not been accepted yet but needs to be discussed first.
Description
- Gitea version (or commit ref): v1.12.0-dev
- Git version: 2.24.1
- Operating system: GNU Linux, Debian
- Database (use
[x]):- PostgreSQL
- MySQL
- MSSQL
- SQLite
- Not relevant
- Can you reproduce the bug at https://try.gitea.io:
- Yes (provide example URL)
- No
- Not relevant
Description
I think exposing simpleMDEditor as Javascript object from web_src/js/index.js could be very useful for customizing Gitea.
I added this function to web_src/js/index.js:
window.getSimpleMDEditor = function () {
return simpleMDEditor;
};and that allows me to play with CodeMirror. Fox example:
script = document.createElement('script');
script.src = "https://cdnjs.cloudflare.com/ajax/libs/codemirror/5.10.0/addon/hint/show-hint.min.js"
document.body.appendChild(script)
link = document.createElement('link')
link.rel = "stylesheet"
link.href = "https://cdnjs.cloudflare.com/ajax/libs/codemirror/5.10.0/addon/hint/show-hint.min.css"
document.body.appendChild(link)
editor = getSimpleMDEditor().codemirror
editor.setOption("extraKeys", {
'Alt-U': function () {
var options = {
hint: function() {
return {
from: editor.getDoc().getCursor(),
to: editor.getDoc().getCursor(),
list: ['foo', 'bar']
}
}
};
editor.showHint(options)}
});allowed me to bring popup list after one would use [Alt-u] keyboard shortcut.
I am working on a simple UI in which one could use Gitea to maintain Hugo web site and so far it worked very good but for less tech-savvy people in our team I wanted to bring autocomplete for internal links of the Hugo website. This is the way which allows me to do that.
I played with adding these kind of things via custom templates and it worked great.
Screenshots
lunny
Metadata
Metadata
Assignees
Labels
type/proposalThe new feature has not been accepted yet but needs to be discussed first.The new feature has not been accepted yet but needs to be discussed first.
