feat: add Zero-Dependency AE_Comp_Editor_TipTap with auto-formatting support
This commit is contained in:
@@ -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,
|
||||
|
||||
21
src/lib/ae_utils/ae_utils__format_html.ts
Normal file
21
src/lib/ae_utils/ae_utils__format_html.ts
Normal 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');
|
||||
}
|
||||
Reference in New Issue
Block a user