Is it possible to add javascript functions in source code editor ? #1046

Closed
opened 2026-02-04 23:34:25 +03:00 by OVERLORD · 3 comments
Owner

Originally created by @paps016 on GitHub (Feb 18, 2019).

Describe the feature you'd like
Can use javascript function on source code editor in edit page.

Is it possible to use javascript ? i'm trying to create a form where the details will sent to a table..
Because it is time consuming if you input all of the details manually in a table then save it and then edit again if you want to add another information..

I'm new to bookstack and i find it very helpful since im a student need to store things via online.

Originally created by @paps016 on GitHub (Feb 18, 2019). **Describe the feature you'd like** Can use javascript function on source code editor in edit page. Is it possible to use javascript ? i'm trying to create a form where the details will sent to a table.. Because it is time consuming if you input all of the details manually in a table then save it and then edit again if you want to add another information.. I'm new to bookstack and i find it very helpful since im a student need to store things via online.
OVERLORD added the Question🖌️ View Customization💻 Front-End labels 2026-02-04 23:34:25 +03:00
Author
Owner

@ssddanbrown commented on GitHub (Feb 20, 2019):

Hi @paps016,

It is currently not possible to add JavaScript to the WYSIWYG editor source view since it will be stripped out on edit.

It is possible to add scripts in the Custom HTML head content textarea in settings. You could possibly add JavaScript in there and set it to only run if a specific ID is on the page, Then you can add that ID to an element in the source code view to enable it on a page.
A bit more complex but a possible work-around.

@ssddanbrown commented on GitHub (Feb 20, 2019): Hi @paps016, It is currently not possible to add JavaScript to the WYSIWYG editor source view since it will be stripped out on edit. It is possible to add scripts in the `Custom HTML head content` textarea in settings. You could possibly add JavaScript in there and set it to only run if a specific ID is on the page, Then you can add that ID to an element in the source code view to enable it on a page. A bit more complex but a possible work-around.
Author
Owner

@ssddanbrown commented on GitHub (Dec 17, 2020):

Since the original question was answered I'll close this off.

something to note since this was answered, is that we do expose some hooks into the editors so that custom buttons/actions can be added if you want to get advanced although this system can break upon updates:

https://www.bookstackapp.com/docs/admin/hacking-bookstack/#bookstack-editor-events

@ssddanbrown commented on GitHub (Dec 17, 2020): Since the original question was answered I'll close this off. something to note since this was answered, is that we do expose some hooks into the editors so that custom buttons/actions can be added if you want to get advanced although this system can break upon updates: https://www.bookstackapp.com/docs/admin/hacking-bookstack/#bookstack-editor-events
Author
Owner

@cittadhammo commented on GitHub (Sep 23, 2024):

Yes adding in the setting the custom code:

<script>

  document.addEventListener('DOMContentLoaded', function() {
    const table = document.getElementById('bkmrk-csv-table');
    
    if (table) {
...

allow the exectuion of the script on the page that contain that table id

@cittadhammo commented on GitHub (Sep 23, 2024): Yes adding in the setting the custom code: ``` <script> document.addEventListener('DOMContentLoaded', function() { const table = document.getElementById('bkmrk-csv-table'); if (table) { ... ``` allow the exectuion of the script on the page that contain that table id
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/BookStack#1046