JSFiddle - React, Tailwind, and code Playground

by Pankaj Kargirwar

HTML

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Custom Completer in Ace Editor</title>
    <script src="https://cdnjs.cloudflare.com/ajax/libs/ace/1.4.12/ace.js"></script>
    <script src="https://cdnjs.cloudflare.com/ajax/libs/ace/1.4.12/ext-language_tools.js"></script>
</head>
<body>
    <div id="editor" style="width: 600px; height: 400px;"></div>
    <script>
        class Suggester {
            /**
             * @param {DOMElement} $container - editor container
             * @param {AceEditor} editor - Ace editor instance
             */
            constructor($container, editor) {
                this.$container = $container;
                this.editor = editor;

                ace.require("ace/ext/language_tools");
                this.editor.setOptions({
                    enableBasicAutocompletion: true,
                    enableSnippets: true,
                    enableLiveAutocompletion: true
                });

                // Custom completer for dropdown list
                let customCompleter = {
                    getCompletions: (editor, session, pos, prefix, callback) => {
                        let completions = [
                            {name: "Option 1", value: "Option 1", score: 1000, meta: "custom"},
                            {name: "Option 2", value: "Option 2", score: 1000, meta: "custom"},
                            {name: "Option 3", value: "Option 3", score: 1000, meta: "custom"}
                        ];
                        callback(null, completions);
                    }
                };

                // Adding custom completer to the list of completers
                this.editor.completers = [customCompleter];

                // Trigger the dropdown manually (optional)
                this.editor.commands.addCommand({
                    name: "showCustomCompleter",
                    bindKey:...