Autocomplete on/off option on front-end for form elements #1590

Closed
opened 2026-02-05 01:20:49 +03:00 by OVERLORD · 7 comments
Owner

Originally created by @ayyilmaz on GitHub (Mar 15, 2020).

There are many input area on BookStack and their class name is general so they offer me my previous inputs which I used another websites, apps etc. I dont want to see these offers. How can I do it?

Originally created by @ayyilmaz on GitHub (Mar 15, 2020). There are many input area on BookStack and their class name is general so they offer me my previous inputs which I used another websites, apps etc. I dont want to see these offers. How can I do it?
Author
Owner

@ssddanbrown commented on GitHub (Feb 7, 2021):

Hi @ayyilmaz,

This wouldn't want to build-in a setting for something this specific, but you could potentially prevent autofill on your instance by adding the following to your "Custom HTML Head Content" setting:

<script>
document.addEventListener('DOMContentLoaded', () => {
    [...document.querySelectorAll('form,input')].forEach(el => el.setAttribute('autocomplete', 'off'));
});
</script>

Some browsers still may ignore the option though. Seemed to work for me on Firefox.
Since a workaround solution has been provided I'll close this off.

@ssddanbrown commented on GitHub (Feb 7, 2021): Hi @ayyilmaz, This wouldn't want to build-in a setting for something this specific, but you could potentially prevent autofill on your instance by adding the following to your "Custom HTML Head Content" setting: ```html <script> document.addEventListener('DOMContentLoaded', () => { [...document.querySelectorAll('form,input')].forEach(el => el.setAttribute('autocomplete', 'off')); }); </script> ``` Some browsers still may ignore the option though. Seemed to work for me on Firefox. Since a workaround solution has been provided I'll close this off.
Author
Owner

@prohtex commented on GitHub (Jun 16, 2025):

Hi @ssddanbrown is there a way to disable code completion entirely in the Markdown editor? I like syntax highlighting, but code completion interferes with the way I write code, and I much prefer it off.

PS. Thanks for BookStack. It is an incredible best-in-class application.

@prohtex commented on GitHub (Jun 16, 2025): Hi @ssddanbrown is there a way to disable code completion entirely in the Markdown editor? I like syntax highlighting, but code completion interferes with the way I write code, and I much prefer it off. PS. Thanks for BookStack. It is an incredible best-in-class application.
Author
Owner

@ssddanbrown commented on GitHub (Jun 16, 2025):

@prohtex We don't provide any in-built options, but tbh I'm not sure what completion you're referring to, it seems pretty limited/sparse in autocompletion from what I can tell, with just some HTML tag handling if used.

@ssddanbrown commented on GitHub (Jun 16, 2025): @prohtex We don't provide any in-built options, but tbh I'm not sure what completion you're referring to, it seems pretty limited/sparse in autocompletion from what I can tell, with just some HTML tag handling if used.
Author
Owner

@prohtex commented on GitHub (Jun 16, 2025):

Hi @ssddanbrown, the issue I'm having is that I frequently paste text into the editor, and then go through and add tags. Every time I type a new tag, the closing tag is automatically added after, making this cumbersome. Would prefer to disable it if possible.

@prohtex commented on GitHub (Jun 16, 2025): Hi @ssddanbrown, the issue I'm having is that I frequently paste text into the editor, and then go through and add tags. Every time I type a new tag, the closing tag is automatically added after, making this cumbersome. Would prefer to disable it if possible.
Author
Owner

@prohtex commented on GitHub (Jun 24, 2025):

@prohtex We don't provide any in-built options, but tbh I'm not sure what completion you're referring to, it seems pretty limited/sparse in autocompletion from what I can tell, with just some HTML tag handling if used.

Hi @ssddanbrown, I dug into this deeper and it seems the closing tag completion would be enabled with something like this, yet is compiled in and not possible to override with the Logical Theme System:

import {closeTags} from '@codemirror/close-tags';
import {closeBrackets} from '@codemirror/close-brackets';

export function createMarkdownEditor(...) {
  ...
  extensions: [
    closeBrackets(),
    closeTags(),
    ...
  ]
}

Because of the way we write code, we're having to use an external editor and paste code into the markdown editor in blocks, or else feverishly edit out all of the autocompleted closing tags as we type, which is a lot!

Is there any way you can expose an option to modify these behaviors, or point me to some non-breaking mod that would accomplish the same? I also tried this to no avail, in functions.php:

Theme::addHtml('head', <<<'HTML'
<script>
(function() {
  const patchCodeEditor = () => {
    if (window.codeEditor?.create) {
      const originalCreate = window.codeEditor.create;
      window.codeEditor.create = function(el, config = {}) {
        config.autoCloseTags = false;
        config.autoCloseBrackets = false;
        return originalCreate.call(this, el, config);
      };
    } else {
      setTimeout(patchCodeEditor, 50);
    }
  };
  patchCodeEditor();
})();
</script>
HTML
);

I remain extraordinarily grateful for BookStack. Thanks in advance.

@prohtex commented on GitHub (Jun 24, 2025): > [@prohtex](https://github.com/prohtex) We don't provide any in-built options, but tbh I'm not sure what completion you're referring to, it seems pretty limited/sparse in autocompletion from what I can tell, with just some HTML tag handling if used. Hi @ssddanbrown, I dug into this deeper and it seems the closing tag completion would be enabled with something like this, yet is compiled in and not possible to override with the Logical Theme System: ``` import {closeTags} from '@codemirror/close-tags'; import {closeBrackets} from '@codemirror/close-brackets'; export function createMarkdownEditor(...) { ... extensions: [ closeBrackets(), closeTags(), ... ] } ``` Because of the way we write code, we're having to use an external editor and paste code into the markdown editor in blocks, or else feverishly edit out all of the autocompleted closing tags as we type, which is a lot! Is there any way you can expose an option to modify these behaviors, or point me to some non-breaking mod that would accomplish the same? I also tried this to no avail, in functions.php: ``` Theme::addHtml('head', <<<'HTML' <script> (function() { const patchCodeEditor = () => { if (window.codeEditor?.create) { const originalCreate = window.codeEditor.create; window.codeEditor.create = function(el, config = {}) { config.autoCloseTags = false; config.autoCloseBrackets = false; return originalCreate.call(this, el, config); }; } else { setTimeout(patchCodeEditor, 50); } }; patchCodeEditor(); })(); </script> HTML ); ``` I remain extraordinarily grateful for BookStack. Thanks in advance.
Author
Owner

@ssddanbrown commented on GitHub (Jun 24, 2025):

I also tried this to no avail, in functions.php:

Are you using an LLM for this? If so, it probably doesn't have the context of something so specific, those aren't really APIs/methods we provide.

Digging into this, it seems like this is enabled at the language level (via a autoCloseTags⁠ option), and the markdown language has its own control for this and here's where the lang is configured in BookStack sources:

8bc6e75319/resources/js/code/languages.js (L52)

Can't see any (simple) way to alter this from what we expose already. I wouldn't want to expose events/config just for this. Could maybe add a JS event for altering the config passed to languages (for those which allow it).

Feel free to raise that as a request in a new feature request issue if desired.

@ssddanbrown commented on GitHub (Jun 24, 2025): > I also tried this to no avail, in functions.php: Are you using an LLM for this? If so, it probably doesn't have the context of something so specific, those aren't really APIs/methods we provide. Digging into this, it seems like this is enabled at the [language level](https://github.com/codemirror/lang-html/blob/main/README.md#api-reference) (via a `autoCloseTags⁠` option), and the markdown language has [its own control](https://github.com/codemirror/lang-markdown?tab=readme-ov-file#user-content-markdown^config.completehtmltags) for this and here's where the lang is configured in BookStack sources: https://github.com/BookStackApp/BookStack/blob/8bc6e75319583298e1f19df5441dc820772f3666/resources/js/code/languages.js#L52 Can't see any (simple) way to alter this from what we expose already. I wouldn't want to expose events/config just for this. Could maybe add a [JS event](https://github.com/BookStackApp/BookStack/blob/development/dev/docs/javascript-public-events.md) for altering the config passed to languages (for those which allow it). Feel free to raise that as a request in a new feature request issue if desired.
Author
Owner

@prohtex commented on GitHub (Jun 24, 2025):

Digging into this, it seems like this is enabled at the language level (via a autoCloseTags⁠ option), and the markdown language has its own control for this and here's where the lang is configured in BookStack sources:

BookStack/resources/js/code/languages.js

Line 52 in 8bc6e75

mdown: async () => markdown(),
Can't see any (simple) way to alter this from what we expose already. I wouldn't want to expose events/config just for this. Could maybe add a JS event for altering the config passed to languages (for those which allow it).

Feel free to raise that as a request in a new feature request issue if desired.

Thanks, and /resources/js/code/languages.js is compiled in right? So I can't override it with a theme? I'll make the request. Greatly appreciated.

@prohtex commented on GitHub (Jun 24, 2025): > Digging into this, it seems like this is enabled at the [language level](https://github.com/codemirror/lang-html/blob/main/README.md#api-reference) (via a `autoCloseTags⁠` option), and the markdown language has [its own control](https://github.com/codemirror/lang-markdown?tab=readme-ov-file#user-content-markdown%5Econfig.completehtmltags) for this and here's where the lang is configured in BookStack sources: > > [BookStack/resources/js/code/languages.js](https://github.com/BookStackApp/BookStack/blob/8bc6e75319583298e1f19df5441dc820772f3666/resources/js/code/languages.js#L52) > > Line 52 in [8bc6e75](/BookStackApp/BookStack/commit/8bc6e75319583298e1f19df5441dc820772f3666) > > mdown: async () => markdown(), > Can't see any (simple) way to alter this from what we expose already. I wouldn't want to expose events/config just for this. Could maybe add a [JS event](https://github.com/BookStackApp/BookStack/blob/development/dev/docs/javascript-public-events.md) for altering the config passed to languages (for those which allow it). > > Feel free to raise that as a request in a new feature request issue if desired. Thanks, and /resources/js/code/languages.js is compiled in right? So I can't override it with a theme? I'll make the request. Greatly appreciated.
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/BookStack#1590