@webcoder49/code-input 2.5.1 → 2.6.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (93) hide show
  1. package/LICENSE +1 -1
  2. package/README.md +9 -126
  3. package/code-input.css +70 -33
  4. package/code-input.d.ts +135 -59
  5. package/code-input.js +201 -110
  6. package/code-input.min.css +1 -1
  7. package/code-input.min.js +12 -1
  8. package/docs/LICENSE +3 -0
  9. package/docs/LICENSE.CC-BY-SA-4.0 +116 -0
  10. package/docs/LICENSE.CC0-1.0 +30 -0
  11. package/docs/README.md +5 -0
  12. package/docs/_index.md +308 -0
  13. package/docs/i18n/_index.md +52 -0
  14. package/docs/interface/_index.md +3 -0
  15. package/docs/interface/css/_index.md +12 -0
  16. package/docs/interface/forms/_index.md +17 -0
  17. package/docs/interface/js/_index.md +11 -0
  18. package/docs/modules-and-frameworks/_index.md +3 -0
  19. package/docs/modules-and-frameworks/custom/_index.md +9 -0
  20. package/docs/modules-and-frameworks/hljs/_index.md +13 -0
  21. package/docs/modules-and-frameworks/hljs/esm/_index.md +71 -0
  22. package/docs/modules-and-frameworks/hljs/nuxt/_index.md +250 -0
  23. package/docs/modules-and-frameworks/hljs/nuxt/nuxt-demo-screenshot.png +0 -0
  24. package/docs/modules-and-frameworks/hljs/vue/_index.md +233 -0
  25. package/docs/modules-and-frameworks/hljs/vue/vue-demo-screenshot.png +0 -0
  26. package/docs/modules-and-frameworks/prism/_index.md +14 -0
  27. package/docs/plugins/_index.md +676 -0
  28. package/docs/plugins/new/_index.md +52 -0
  29. package/docs/theory/_index.md +9 -0
  30. package/esm/README.md +23 -0
  31. package/esm/code-input.d.mts +154 -0
  32. package/esm/code-input.mjs +997 -0
  33. package/esm/plugins/auto-close-brackets.d.mts +15 -0
  34. package/esm/plugins/auto-close-brackets.mjs +84 -0
  35. package/esm/plugins/autocomplete.d.mts +14 -0
  36. package/esm/plugins/autocomplete.mjs +93 -0
  37. package/esm/plugins/autodetect.d.mts +11 -0
  38. package/esm/plugins/autodetect.mjs +35 -0
  39. package/esm/plugins/find-and-replace.d.mts +43 -0
  40. package/esm/plugins/find-and-replace.mjs +777 -0
  41. package/esm/plugins/go-to-line.d.mts +29 -0
  42. package/esm/plugins/go-to-line.mjs +217 -0
  43. package/esm/plugins/indent.d.mts +22 -0
  44. package/esm/plugins/indent.mjs +359 -0
  45. package/esm/plugins/select-token-callbacks.d.mts +51 -0
  46. package/esm/plugins/select-token-callbacks.mjs +296 -0
  47. package/esm/plugins/special-chars.d.mts +25 -0
  48. package/esm/plugins/special-chars.mjs +207 -0
  49. package/esm/plugins/test.d.mts +16 -0
  50. package/esm/plugins/test.mjs +56 -0
  51. package/esm/templates/hljs.d.mts +16 -0
  52. package/esm/templates/hljs.mjs +28 -0
  53. package/esm/templates/prism.d.mts +16 -0
  54. package/esm/templates/prism.mjs +25 -0
  55. package/package.json +83 -7
  56. package/plugins/README.md +2 -0
  57. package/plugins/auto-close-brackets.js +2 -0
  58. package/plugins/auto-close-brackets.min.js +1 -1
  59. package/plugins/autocomplete.js +6 -6
  60. package/plugins/autocomplete.min.js +1 -1
  61. package/plugins/autodetect.js +4 -2
  62. package/plugins/autodetect.min.js +1 -1
  63. package/plugins/find-and-replace.css +0 -4
  64. package/plugins/find-and-replace.js +28 -8
  65. package/plugins/find-and-replace.min.css +1 -1
  66. package/plugins/find-and-replace.min.js +1 -1
  67. package/plugins/go-to-line.css +10 -5
  68. package/plugins/go-to-line.js +39 -6
  69. package/plugins/go-to-line.min.css +1 -1
  70. package/plugins/go-to-line.min.js +1 -1
  71. package/plugins/indent.js +4 -2
  72. package/plugins/indent.min.js +1 -1
  73. package/plugins/prism-line-numbers.css +14 -5
  74. package/plugins/prism-line-numbers.min.css +1 -1
  75. package/plugins/select-token-callbacks.js +3 -1
  76. package/plugins/select-token-callbacks.min.js +1 -1
  77. package/plugins/special-chars.css +13 -1
  78. package/plugins/special-chars.js +14 -4
  79. package/plugins/special-chars.min.css +1 -1
  80. package/plugins/special-chars.min.js +1 -1
  81. package/plugins/test.js +22 -7
  82. package/plugins/test.min.js +1 -1
  83. package/.github/workflows/minify.yml +0 -22
  84. package/.github/workflows/npm-publish.yml +0 -21
  85. package/CODE_OF_CONDUCT.md +0 -130
  86. package/CONTRIBUTING.md +0 -35
  87. package/tests/hljs.html +0 -55
  88. package/tests/i18n.html +0 -197
  89. package/tests/prism-match-braces-compatibility.js +0 -215
  90. package/tests/prism-match-braces-compatibility.min.js +0 -1
  91. package/tests/prism.html +0 -54
  92. package/tests/tester.js +0 -600
  93. package/tests/tester.min.js +0 -21
package/code-input.d.ts CHANGED
@@ -1,4 +1,5 @@
1
1
  export as namespace codeInput;
2
+ // ESM-SUPPORT-END-NOESM-SPECIFIC Do not (re)move this - it's needed for ESM generation
2
3
 
3
4
  /**
4
5
  * Plugins are imported from the plugins folder. They will then
@@ -45,8 +46,16 @@ export abstract class Plugin {
45
46
  * modifications to the `codeInput.Plugin.attributeChanged` method.
46
47
  */
47
48
  observedAttributes: Array<string>
49
+
50
+ /**
51
+ * Replace the values in destination with those from source where the keys match, in-place.
52
+ * @param {Object} destination Where to place the translated strings, already filled with the keys pointing to English strings.
53
+ * @param {Object} source The same keys, or some of them, mapped to translated strings. Keys not present here will retain the values they are maapped to in destination.
54
+ */
55
+ addTranslations(destination: Object, source: Object): void
48
56
  }
49
57
 
58
+ // ESM-SUPPORT-START-NAMESPACE-1 Do not (re)move this - it's needed for ESM generation
50
59
  /**
51
60
  * Before using any plugin in this namespace, please ensure you import its JavaScript
52
61
  * files (in the plugins folder), or continue to get a more detailed error in the developer
@@ -62,6 +71,7 @@ export abstract class Plugin {
62
71
  * @type {Object}
63
72
  */
64
73
  export namespace plugins {
74
+ // ESM-SUPPORT-START-PLUGIN-test Do not (re)move this - it's needed for ESM generation
65
75
  /**
66
76
  * JavaScript example of a plugin, which brings extra,
67
77
  * non-central optional functionality to code-input.
@@ -75,7 +85,9 @@ export namespace plugins {
75
85
  class Test extends Plugin {
76
86
  constructor();
77
87
  }
88
+ // ESM-SUPPORT-END-PLUGIN-test Do not (re)move this - it's needed for ESM generation
78
89
 
90
+ // ESM-SUPPORT-START-PLUGIN-auto-close-brackets Do not (re)move this - it's needed for ESM generation
79
91
  /**
80
92
  * Automatically closes pairs of brackets/quotes/other syntaxes in code, but also lets you choose the brackets this
81
93
  * is activated for.
@@ -86,9 +98,11 @@ export namespace plugins {
86
98
  * Create an auto-close brackets plugin to pass into a template
87
99
  * @param {Object} bracketPairs Opening brackets mapped to closing brackets, default and example {"(": ")", "[": "]", "{": "}", '"': '"'}. All brackets must only be one character.
88
100
  */
89
- constructor(bracketPairs: Object);
101
+ constructor(bracketPairs?: Object);
90
102
  }
103
+ // ESM-SUPPORT-END-PLUGIN-auto-close-brackets Do not (re)move this - it's needed for ESM generation
91
104
 
105
+ // ESM-SUPPORT-START-PLUGIN-autocomplete Do not (re)move this - it's needed for ESM generation
92
106
  /**
93
107
  * Display a popup under the caret using the text in the code-input element. This works well with autocomplete suggestions.
94
108
  * Files: autocomplete.js / autocomplete.css
@@ -96,11 +110,13 @@ export namespace plugins {
96
110
  class Autocomplete extends Plugin {
97
111
  /**
98
112
  * Pass in a function to create a plugin that displays the popup that takes in (popup element, textarea, textarea.selectionEnd).
99
- * @param {(popupElement: HTMLElement, textarea: HTMLTextAreaElement, selectionEnd: number) => void} updatePopupCallback a function to display the popup that takes in (popup element, textarea, textarea.selectionEnd).
113
+ * @param {(popupElement: HTMLElement, textarea: HTMLTextAreaElement, selectionEnd: number, selectionStart?: number) => void} updatePopupCallback a function to display the popup that takes in (popup element, textarea, textarea.selectionEnd).
100
114
  */
101
- constructor(updatePopupCallback: (popupElem: HTMLElement, textarea: HTMLTextAreaElement, selectionEnd: number) => void);
115
+ constructor(updatePopupCallback: (popupElem: HTMLElement, textarea: HTMLTextAreaElement, selectionEnd: number, selectionStart?: number) => void);
102
116
  }
117
+ // ESM-SUPPORT-END-PLUGIN-autocomplete Do not (re)move this - it's needed for ESM generation
103
118
 
119
+ // ESM-SUPPORT-START-PLUGIN-autodetect Do not (re)move this - it's needed for ESM generation
104
120
  /**
105
121
  * Autodetect the language live and change the `lang` attribute using the syntax highlighter's
106
122
  * autodetect capabilities. Works with highlight.js only.
@@ -109,20 +125,9 @@ export namespace plugins {
109
125
  class Autodetect extends Plugin {
110
126
  constructor();
111
127
  }
128
+ // ESM-SUPPORT-END-PLUGIN-autodetect Do not (re)move this - it's needed for ESM generation
112
129
 
113
- /**
114
- * Debounce the update and highlighting function
115
- * https://medium.com/@jamischarles/what-is-debouncing-2505c0648ff1
116
- * Files: debounce-update.js
117
- */
118
- class DebounceUpdate extends Plugin {
119
- /**
120
- * Create a debounced update plugin to pass into a template.
121
- * @param {Number} delayMs Delay, in ms, to wait until updating the syntax highlighting
122
- */
123
- constructor(delayMs: number);
124
- }
125
-
130
+ // ESM-SUPPORT-START-PLUGIN-find-and-replace Do not (re)move this - it's needed for ESM generation
126
131
  /**
127
132
  * Add Find-and-Replace (Ctrl+F for find, Ctrl+H for replace by default) functionality to the code editor.
128
133
  * Files: find-and-replace.js / find-and-replace.css
@@ -130,8 +135,8 @@ export namespace plugins {
130
135
  class FindAndReplace extends Plugin {
131
136
  /**
132
137
  * Create a find-and-replace command plugin to pass into a template
133
- * @param {boolean} useCtrlF Should Ctrl+F be overriden for find-and-replace find functionality? If not, you can trigger it yourself using (instance of this plugin)`.showPrompt(code-input element, false)`.
134
- * @param {boolean} useCtrlH Should Ctrl+H be overriden for find-and-replace replace functionality? If not, you can trigger it yourself using (instance of this plugin)`.showPrompt(code-input element, true)`.
138
+ * @param {boolean} useCtrlF Should Ctrl+F be overriden for find-and-replace find functionality? Either way, you can also trigger it yourself using (instance of this plugin)`.showPrompt(code-input element, false)`.
139
+ * @param {boolean} useCtrlH Should Ctrl+H be overriden for find-and-replace replace functionality? Either way, you can also trigger it yourself using (instance of this plugin)`.showPrompt(code-input element, true)`.
135
140
  * @param {Object} instructionTranslations: user interface string keys mapped to translated versions for localisation. Look at the find-and-replace.js source code for the English text.
136
141
  */
137
142
  constructor(useCtrlF?: boolean, useCtrlH?: boolean,
@@ -163,7 +168,9 @@ export namespace plugins {
163
168
  */
164
169
  showPrompt(codeInputElement: CodeInput, replacePartExpanded: boolean): void;
165
170
  }
171
+ // ESM-SUPPORT-END-PLUGIN-find-and-replace Do not (re)move this - it's needed for ESM generation
166
172
 
173
+ // ESM-SUPPORT-START-PLUGIN-go-to-line Do not (re)move this - it's needed for ESM generation
167
174
  /**
168
175
  * Add basic Go-To-Line (ctrl-G by default) functionality to the code editor.
169
176
  * Files: go-to-line.js / go-to-line.css
@@ -171,13 +178,18 @@ export namespace plugins {
171
178
  class GoToLine extends Plugin {
172
179
  /**
173
180
  * Create a go-to-line command plugin to pass into a template
174
- * @param {boolean} useCtrlG Should Ctrl+G be overriden for go-to-line functionality? If not, you can trigger it yourself using (instance of this plugin)`.showPrompt(code-input element)`.
181
+ * @param {boolean} useCtrlG Should Ctrl+G be overriden for go-to-line functionality? Either way, you can trigger it yourself using (instance of this plugin)`.showPrompt(code-input element)`.
175
182
  * @param {Object} instructionTranslations: user interface string keys mapped to translated versions for localisation. Look at the go-to-line.js source code for the English text.
176
183
  */
177
- constructor(useCtrlG: boolean,
184
+ constructor(useCtrlG?: boolean,
178
185
  instructionTranslations?: {
179
186
  closeDialog?: string;
180
187
  input?: string;
188
+ guidanceFormat?: string;
189
+ guidanceLineRange?: (current:Number, max: Number) => string;
190
+ guidanceColumnRange?: (line: Number, current: Number, max: Number) => string;
191
+ guidanceValidLine?: (line: Number) => string;
192
+ guidanceValidColumn?: (line: Number, column: Number) => string;
181
193
  });
182
194
  /**
183
195
  * Show a search-like dialog prompting line number.
@@ -185,7 +197,9 @@ export namespace plugins {
185
197
  */
186
198
  showPrompt(codeInput: CodeInput): void;
187
199
  }
200
+ // ESM-SUPPORT-END-PLUGIN-go-to-line Do not (re)move this - it's needed for ESM generation
188
201
 
202
+ // ESM-SUPPORT-START-PLUGIN-indent Do not (re)move this - it's needed for ESM generation
189
203
  /**
190
204
  * Adds indentation using the `Tab` key, and auto-indents after a newline, as well as making it
191
205
  * possible to indent/unindent multiple lines using Tab/Shift+Tab
@@ -200,12 +214,14 @@ export namespace plugins {
200
214
  * @param {boolean} escTabToChangeFocus Whether pressing the Escape key before (Shift+)Tab should make this keypress focus on a different element (Tab's default behaviour). You should always either enable this or use this plugin's disableTabIndentation and enableTabIndentation methods linked to other keyboard shortcuts, for accessibility.
201
215
  * @param {Object} instructionTranslations: user interface string keys mapped to translated versions for localisation. Look at the go-to-line.js source code for the English text.
202
216
  */
203
- constructor(defaultSpaces?: boolean, numSpaces?: Number, bracketPairs?: Object, escTabToChangeFocus?: boolean, instructionTranslations?: {
217
+ constructor(defaultSpaces?: boolean, numSpaces?: Number, bracketPairs?: Object, escTabToChangeFocus?: boolean, instructionTwranslations?: {
204
218
  tabForIndentation?: string;
205
219
  tabForNavigation?: string;
206
220
  });
207
221
  }
222
+ // ESM-SUPPORT-END-PLUGIN-indent Do not (re)move this - it's needed for ESM generation
208
223
 
224
+ // ESM-SUPPORT-START-PLUGIN-select-token-callbacks Do not (re)move this - it's needed for ESM generation
209
225
  /**
210
226
  * Make tokens in the <pre><code> element that are included within the selected text of the <code-input>
211
227
  * gain a CSS class while selected, or trigger JavaScript callbacks.
@@ -251,35 +267,42 @@ export namespace plugins {
251
267
  * @param {string} selectedClass The CSS class that will be present on tokens only when they are part of the selected text in the `<code-input>` element. Defaults to "code-input_select-token-callbacks_selected".
252
268
  * @returns {TokenSelectorCallbacks} A new TokenSelectorCallbacks instance that encodes this behaviour.
253
269
  */
254
- static createClassSynchronisation(selectedClass: string): codeInput.plugins.SelectTokenCallbacks.TokenSelectorCallbacks;
270
+ static createClassSynchronisation(selectedClass?: string): codeInput.plugins.SelectTokenCallbacks.TokenSelectorCallbacks;
255
271
  }
256
272
  }
273
+ // ESM-SUPPORT-END-PLUGIN-select-token-callbacks Do not (re)move this - it's needed for ESM generation
257
274
 
275
+ // ESM-SUPPORT-START-PLUGIN-special-chars Do not (re)move this - it's needed for ESM generation
258
276
  /**
259
277
  * Render special characters and control characters as a symbol with their hex code.
260
278
  * Files: special-chars.js, special-chars.css
279
+ *
280
+ * WARNING:
281
+ *
282
+ * This plugin is currently unstable when used with other plugins,
283
+ * Unicode characters, or highlight.js. I hope to fix much of this by
284
+ * major version 3, and if you could help that would be amazing!
285
+ *
286
+ * See https://github.com/WebCoder49/code-input/issues?q=is%3Aissue%20state%3Aopen%20specialchars
261
287
  */
262
288
  class SpecialChars extends Plugin {
263
289
  /**
264
290
  * Create a special characters plugin instance.
265
291
  * Default = covers many non-renderable ASCII characters.
266
- * @param {Boolean} colorInSpecialChars Whether or not to give special characters custom background colors based on their hex code
267
- * @param {Boolean} inheritTextColor If `inheritTextColor` is false, forces the color of the hex code to inherit from syntax highlighting. Otherwise, the base color of the `pre code` element is used to give contrast to the small characters.
268
- * @param {RegExp} specialCharRegExp The regular expression which matches special characters
292
+ * @param {Boolean} colorInSpecialChars Whether or not to give special characters custom background colors based on their hex code. Defaults to false.
293
+ * @param {Boolean} inheritTextColor If true, forces the color of the hex code to inherit from syntax highlighting. If false, the base color of the `pre code` element is used to give contrast to the small characters. Defaults to false.
294
+ * @param {RegExp} specialCharRegExp The regular expression which matches special characters. Defaults to many non-renderable ASCII characters (which characters are renderable depends on the browser and OS).
269
295
  */
270
296
  constructor(colorInSpecialChars?: boolean, inheritTextColor?: boolean, specialCharRegExp?: RegExp);
271
297
  }
298
+ // ESM-SUPPORT-END-PLUGIN-special-chars Do not (re)move this - it's needed for ESM generation
272
299
  }
300
+ // ESM-SUPPORT-END-NAMESPACE-1 Do not (re)move this - it's needed for ESM generation
273
301
 
274
302
  /**
275
- * Register a plugin class under `codeInput.plugins`.
276
- * @param {string} pluginName The identifier of the plugin: if it is `"foo"`, `new codeInput.plugins.foo(`...`)` will instantiate it, etc.
277
- * @param {Object} pluginClass The class of the plugin, created with `class extends codeInput.plugin {`...`}`
278
- */
279
- export function registerPluginClass(pluginName: string, pluginClass: Object): void;
280
-
281
- /**
282
- * Please see `codeInput.templates.prism` or `codeInput.templates.hljs`.
303
+ * If you're using one of the two named highlighters, please see
304
+ * `codeInput.templates.prism` or `codeInput.templates.hljs`.
305
+ * Otherwise please see this class' constructor.
283
306
  * Templates are used in `<code-input>` elements and once registered with
284
307
  * `codeInput.registerTemplate` will be in charge of the highlighting
285
308
  * algorithm and settings for all code-inputs with a `template` attribute
@@ -292,44 +315,34 @@ export class Template {
292
315
  * Constructor to create a custom template instance. Pass this into `codeInput.registerTemplate` to use it.
293
316
  * I would strongly recommend using the built-in simpler template `codeInput.templates.prism` or `codeInput.templates.hljs`.
294
317
  * @param {(codeElement: HTMLElement) => void} highlight - a callback to highlight the code, that takes an HTML `<code>` element inside a `<pre>` element as a parameter
295
- * @param {boolean} preElementStyled - is the `<pre>` element CSS-styled as well as the `<code>` element? If true, `<pre>` element's scrolling is synchronised; if false, `<code>` element's scrolling is synchronised.
318
+ * @param {boolean} preElementStyled - is the `<pre>` element CSS-styled (if so set to true), or the `<code>` element (false)?
296
319
  * @param {boolean} isCode - is this for writing code? If true, the code-input's lang HTML attribute can be used, and the `<code>` element will be given the class name 'language-[lang attribute's value]'.
297
320
  * @param {false} includeCodeInputInHighlightFunc - Setting this to true passes the `<code-input>` element as a second argument to the highlight function.
298
- * @param {boolean} autoDisableDuplicateSearching - Leaving this as true uses code-input's default fix for preventing duplicate results in Ctrl+F searching from the input and result elements, and setting this to false indicates your highlighting function implements its own fix. The default fix works by moving text content from elements to CSS `::before` pseudo-elements after highlighting.
299
321
  * @param {codeInput.Plugin[]} plugins - An array of plugin objects to add extra features - see `codeInput.Plugin`
300
322
  * @returns template object
301
323
  */
302
- constructor(highlight?: (codeElement: HTMLElement) => void, preElementStyled?: boolean, isCode?: boolean, includeCodeInputInHighlightFunc?: false, autoDisableDuplicateSearching?: boolean, plugins?: Plugin[])
324
+ constructor(highlight?: (codeElement: HTMLElement) => void, preElementStyled?: boolean, isCode?: boolean, includeCodeInputInHighlightFunc?: false, plugins?: Plugin[])
303
325
  /**
304
326
  * **When `includeCodeInputInHighlightFunc` is `true`, `highlight` takes two parameters: the `<pre><code>` element, and the `<code-input>` element.**
305
327
  *
306
328
  * Constructor to create a custom template instance. Pass this into `codeInput.registerTemplate` to use it.
307
329
  * I would strongly recommend using the built-in simpler template `codeInput.templates.prism` or `codeInput.templates.hljs`.
308
330
  * @param {(codeElement: HTMLElement, codeInput: CodeInput) => void} highlight - a callback to highlight the code, that takes an HTML `<code>` element inside a `<pre>` element as a parameter
309
- * @param {boolean} preElementStyled - is the `<pre>` element CSS-styled as well as the `<code>` element? If true, `<pre>` element's scrolling is synchronised; if false, `<code>` element's scrolling is synchronised.
331
+ * @param {boolean} preElementStyled - is the `<pre>` element CSS-styled (if so set to true), or the `<code>` element (false)?
310
332
  * @param {boolean} isCode - is this for writing code? If true, the code-input's lang HTML attribute can be used, and the `<code>` element will be given the class name 'language-[lang attribute's value]'.
311
333
  * @param {true} includeCodeInputInHighlightFunc - Setting this to true passes the `<code-input>` element as a second argument to the highlight function.
312
- * @param {boolean} autoDisableDuplicateSearching - Leaving this as true uses code-input's default fix for preventing duplicate results in Ctrl+F searching from the input and result elements, and setting this to false indicates your highlighting function implements its own fix. The default fix works by moving text content from elements to CSS `::before` pseudo-elements after highlighting.
313
334
  * @param {codeInput.Plugin[]} plugins - An array of plugin objects to add extra features - see `codeInput.Plugin`
314
335
  * @returns template object
315
336
  */
316
- constructor(highlight?: (codeElement: HTMLElement, codeInput: CodeInput) => void, preElementStyled?: boolean, isCode?: boolean, includeCodeInputInHighlightFunc?: true, autoDisableDuplicateSearching?: boolean, plugins?: Plugin[])
337
+ constructor(highlight?: (codeElement: HTMLElement, codeInput: CodeInput) => void, preElementStyled?: boolean, isCode?: boolean, includeCodeInputInHighlightFunc?: true, plugins?: Plugin[])
317
338
  highlight: Function
318
339
  preElementStyled: boolean
319
340
  isCode: boolean
320
341
  includeCodeInputInHighlightFunc: boolean
321
- autoDisableDuplicateSearching: boolean
322
- plugins: Plugin[]
323
- /**
324
- * @deprecated Please give a value for the `autoDisableDuplicateSearching` parameter.
325
- */
326
- constructor(highlight?: (code: HTMLElement) => void, preElementStyled?: boolean, isCode?: boolean, includeCodeInputInHighlightFunc?: false, plugins?: Plugin[])
327
- /**
328
- * @deprecated Please give a value for the `autoDisableDuplicateSearching` parameter.
329
- */
330
- constructor(highlight?: (code: HTMLElement, codeInput: CodeInput) => void, preElementStyled?: boolean, isCode?: boolean, includeCodeInputInHighlightFunc?: true, plugins?: Plugin[])
342
+ plugins: Plugin[]
331
343
  }
332
344
 
345
+ // ESM-SUPPORT-START-NAMESPACE-2 Do not (re)move this - it's needed for ESM generation
333
346
  /**
334
347
  * Shortcut functions for creating templates.
335
348
  * Each code-input element has a template attribute that
@@ -344,18 +357,42 @@ export class Template {
344
357
  * For adding small pieces of functionality, please see `codeInput.plugins`.
345
358
  */
346
359
  export namespace templates {
360
+ // ESM-SUPPORT-START-TEMPLATE-prism Do not (re)move this - it's needed for ESM generation
347
361
  /**
348
- * Constructor to create a template that uses Prism.js syntax highlighting (https://prismjs.com/)
349
- * @param {Object} prism Import Prism.js, then after that import pass the `Prism` object as this parameter.
350
- * @param {codeInput.Plugin[]} plugins - An array of plugin objects to add extra features - see `codeInput.plugins`
351
- * @returns template object
362
+ * A template that uses Prism.js syntax highlighting (https://prismjs.com/).
363
+ */
364
+ class Prism extends Template {
365
+ /**
366
+ * Constructor to create a template that uses Prism.js syntax highlighting (https://prismjs.com/)
367
+ * @param {Object} prism Import Prism.js, then after that import pass the `Prism` object as this parameter.
368
+ * @param {codeInput.Plugin[]} plugins - An array of plugin objects to add extra features - see `codeInput.plugins`
369
+ * @param {boolean} preElementStyled - Defaults to true, which should be right for most themes. If the styling is broken, change to false. (See `codeInput.Template` constructor's definition.)
370
+ * @returns template object
371
+ */
372
+ constructor(prism: Object, plugins?: Plugin[], preElementStyled?: boolean)
373
+ }
374
+ // ESM-SUPPORT-END-TEMPLATE-prism Do not (re)move this - it's needed for ESM generation
375
+ /**
376
+ * @deprecated Please use `new codeInput.templates.Prism(...)`
352
377
  */
353
378
  function prism(prism: Object, plugins?: Plugin[]): Template
379
+ // ESM-SUPPORT-START-TEMPLATE-hljs Do not (re)move this - it's needed for ESM generation
354
380
  /**
355
- * Constructor to create a template that uses highlight.js syntax highlighting (https://highlightjs.org/)
356
- * @param {Object} hljs Import highlight.js, then after that import pass the `hljs` object as this parameter.
357
- * @param {codeInput.Plugin[]} plugins - An array of plugin objects to add extra features - see `codeInput.plugins`
358
- * @returns template object
381
+ * A template that uses highlight.js syntax highlighting (https://highlightjs.org/).
382
+ */
383
+ class Hljs extends Template {
384
+ /**
385
+ * Constructor to create a template that uses highlight.js syntax highlighting (https://highlightjs.org/)
386
+ * @param {Object} hljs Import highlight.js, then after that import pass the `hljs` object as this parameter.
387
+ * @param {codeInput.Plugin[]} plugins - An array of plugin objects to add extra features - see `codeInput.plugins`
388
+ * @param {boolean} preElementStyled - Defaults to false, which should be right for most themes. If the styling is broken, change to true. (See `codeInput.Template` constructor's definition.)
389
+ * @returns template object
390
+ */
391
+ constructor(hljs: Object, plugins?: Plugin[], preElementStyled?: boolean)
392
+ }
393
+ // ESM-SUPPORT-END-TEMPLATE-hljs Do not (re)move this - it's needed for ESM generation
394
+ /**
395
+ * @deprecated Please use `new codeInput.templates.Hljs(...)`
359
396
  */
360
397
  function hljs(hljs: Object, plugins?: Plugin[]): Template
361
398
  /**
@@ -373,12 +410,51 @@ export namespace templates {
373
410
  */
374
411
  function rainbowText(rainbowColors?: string[], delimiter?: string, plugins?: Plugin[]): Template
375
412
  }
413
+ // ESM-SUPPORT-END-NAMESPACE-2 Do not (re)move this - it's needed for ESM generation
376
414
 
377
415
  /**
378
416
  * A `<code-input>` element, an instance of an `HTMLElement`, and the result
379
- * of `document.createElement("code-input")`.
417
+ * of `document.createElement("code-input")`. Attributes are only set when
418
+ * the element's template has been registered, and before this are null.
380
419
  */
381
- export class CodeInput extends HTMLElement { }
420
+ export class CodeInput extends HTMLTextAreaElement { // Tries to implement textarea interface
421
+ /**
422
+ * When the code-input's template is registered, this contains its codeInput.Template object.
423
+ */
424
+ templateObject?: readonly Template
425
+ /**
426
+ * Exposed child textarea element for user to input code in; in this version of code-input you shouldn't need to access
427
+ * it because most textarea functionality is present on the code-input element itself.
428
+ */
429
+ textareaElement?: HTMLTextAreaElement
430
+ /**
431
+ * Exposed child pre element where syntax-highlighted code is outputted.
432
+ * Contains this.codeElement as its only child.
433
+ */
434
+ preElement?: HTMLPreElement
435
+ /**
436
+ * Exposed child pre element's child code element where syntax-highlighted code is outputted.
437
+ * Has this.preElement as its parent.
438
+ */
439
+ codeElement?: HTMLElement
440
+ /**
441
+ * Exposed non-scrolling element designed to contain dialog boxes etc. from plugins,
442
+ * that shouldn't scroll with the code-input element.
443
+ */
444
+ dialogContainerElement?: HTMLElement
445
+ /**
446
+ * Show some instructions to the user only if they are using keyboard navigation - for example, a prompt on how to navigate with the keyboard if Tab is repurposed.
447
+ * @param {string} instructions The instructions to display only if keyboard navigation is being used. If it's blank, no instructions will be shown.
448
+ * @param {boolean} includeAriaDescriptionFirst Whether to include the aria-description of the code-input element before the keyboard navigation instructions for a screenreader. Keep this as true when the textarea is first focused.
449
+ */
450
+ setKeyboardNavInstructions(instructions: string, includeAriaDescriptionFirst: boolean): void
451
+ /**
452
+ * Allows plugins to store data in the scope of a single element.
453
+ * Key - name of the plugin, in camelCase
454
+ * Value - object of data to be stored; different plugins may use this differently.
455
+ */
456
+ pluginData: Object
457
+ }
382
458
 
383
459
  /**
384
460
  * Register a template so code-input elements with a template attribute that equals the templateName will use the template.