feat: add Zero-Dependency AE_Comp_Editor_TipTap with auto-formatting support

This commit is contained in:
Scott Idem
2026-01-29 14:30:28 -05:00
parent 363d94a36b
commit 7ec3bae343
5 changed files with 231 additions and 0 deletions

View File

@@ -16,6 +16,7 @@ import { to_title_case } from './ae_utils__to_title_case';
import { process_data_string } from './ae_utils__process_data_string';
import { set_obj_prop_display_name } from './ae_utils__set_obj_prop_display_name';
import { return_obj_type_path } from './ae_utils__return_obj_type_path';
import { format_html } from './ae_utils__format_html';
import {
combine_iv_and_base64,
encrypt_content,
@@ -336,6 +337,7 @@ export const ae_util = {
shorten_string: shorten_string,
shorten_filename: shorten_filename,
file_extension_icon: file_extension_icon,
format_html: format_html,
set_obj_prop_display_name: set_obj_prop_display_name,
return_obj_type_path: return_obj_type_path,
combine_iv_and_base64: combine_iv_and_base64,

View File

@@ -0,0 +1,21 @@
/**
* Simple Regex-based HTML Formatter for Aether Platform.
* Adds newlines and indentation to raw HTML strings.
*/
export function format_html(html: string): string {
if (!html) return '';
let indent = 0;
const tab = ' ';
return html
.replace(/>\s*</g, '>\n<') // Add newlines between tags
.split('\n')
.map(line => {
line = line.trim();
if (line.match(/<\//)) indent--; // Decrease indent for closing tags
const out = tab.repeat(Math.max(0, indent)) + line;
if (line.match(/<[^\/!]/) && !line.match(/\/>/) && !line.match(/<\//)) indent++; // Increase indent for opening tags
return out;
})
.join('\n');
}