fix: improve markdown conversion and advanced fields visibility
- Enhanced markdown to HTML conversion with proper list handling - Added support for H4, H5, H6 headers in TinyMCE editor configuration - Improved bullet list processing with proper <ul> wrapping - Fixed advanced fields visibility by adding CSS display:none default - Timezone selector and advanced options (capacity, cost) now properly hidden 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
parent
b7e5514e8e
commit
d5239d7a3f
3 changed files with 52 additions and 19 deletions
|
|
@ -356,6 +356,7 @@
|
||||||
background: #f8f9fa;
|
background: #f8f9fa;
|
||||||
border-radius: 0 4px 4px 0;
|
border-radius: 0 4px 4px 0;
|
||||||
position: relative;
|
position: relative;
|
||||||
|
display: none; /* Hidden by default */
|
||||||
}
|
}
|
||||||
|
|
||||||
.advanced-field::before {
|
.advanced-field::before {
|
||||||
|
|
|
||||||
|
|
@ -716,7 +716,8 @@ jQuery(document).ready(function($) {
|
||||||
markdownToHtml: function(markdown) {
|
markdownToHtml: function(markdown) {
|
||||||
let html = markdown;
|
let html = markdown;
|
||||||
|
|
||||||
// Convert headers (## -> h2, ### -> h3, etc.)
|
// Convert headers (#### -> h4, ### -> h3, ## -> h2, # -> h1)
|
||||||
|
html = html.replace(/^#### (.+)$/gm, '<h4>$1</h4>');
|
||||||
html = html.replace(/^### (.+)$/gm, '<h3>$1</h3>');
|
html = html.replace(/^### (.+)$/gm, '<h3>$1</h3>');
|
||||||
html = html.replace(/^## (.+)$/gm, '<h2>$1</h2>');
|
html = html.replace(/^## (.+)$/gm, '<h2>$1</h2>');
|
||||||
html = html.replace(/^# (.+)$/gm, '<h1>$1</h1>');
|
html = html.replace(/^# (.+)$/gm, '<h1>$1</h1>');
|
||||||
|
|
@ -727,25 +728,56 @@ jQuery(document).ready(function($) {
|
||||||
// Convert italic text (*text* -> <em>text</em>)
|
// Convert italic text (*text* -> <em>text</em>)
|
||||||
html = html.replace(/\*([^*]+)\*/g, '<em>$1</em>');
|
html = html.replace(/\*([^*]+)\*/g, '<em>$1</em>');
|
||||||
|
|
||||||
// Convert bullet lists (* item -> <ul><li>item</li></ul>)
|
// Process lines for better list handling
|
||||||
html = html.replace(/^\* (.+)$/gm, '<li>$1</li>');
|
|
||||||
|
|
||||||
// Wrap consecutive <li> items in <ul> tags
|
|
||||||
html = html.replace(/(<li>.*<\/li>)/gs, function(match) {
|
|
||||||
if (!match.includes('<ul>')) {
|
|
||||||
return '<ul>' + match + '</ul>';
|
|
||||||
}
|
|
||||||
return match;
|
|
||||||
});
|
|
||||||
|
|
||||||
// Convert line breaks to <p> tags for paragraphs
|
|
||||||
const lines = html.split('\n');
|
const lines = html.split('\n');
|
||||||
|
const processedLines = [];
|
||||||
|
let inList = false;
|
||||||
|
|
||||||
|
for (let i = 0; i < lines.length; i++) {
|
||||||
|
let line = lines[i].trim();
|
||||||
|
|
||||||
|
// Handle bullet list items
|
||||||
|
if (line.match(/^\* (.+)$/)) {
|
||||||
|
const listItemContent = line.replace(/^\* (.+)$/, '$1');
|
||||||
|
|
||||||
|
if (!inList) {
|
||||||
|
processedLines.push('<ul>');
|
||||||
|
inList = true;
|
||||||
|
}
|
||||||
|
processedLines.push(`<li>${listItemContent}</li>`);
|
||||||
|
|
||||||
|
// Check if next line is also a list item or if this is the last line
|
||||||
|
const nextLine = i + 1 < lines.length ? lines[i + 1].trim() : '';
|
||||||
|
if (!nextLine.match(/^\* (.+)$/)) {
|
||||||
|
processedLines.push('</ul>');
|
||||||
|
inList = false;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
// Close list if we were in one
|
||||||
|
if (inList) {
|
||||||
|
processedLines.push('</ul>');
|
||||||
|
inList = false;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Add regular line
|
||||||
|
if (line !== '') {
|
||||||
|
processedLines.push(line);
|
||||||
|
} else {
|
||||||
|
processedLines.push(''); // Preserve empty lines for paragraph breaks
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Close any remaining open list
|
||||||
|
if (inList) {
|
||||||
|
processedLines.push('</ul>');
|
||||||
|
}
|
||||||
|
|
||||||
|
// Convert to paragraphs
|
||||||
const paragraphs = [];
|
const paragraphs = [];
|
||||||
let currentParagraph = '';
|
let currentParagraph = '';
|
||||||
|
|
||||||
for (let line of lines) {
|
for (let line of processedLines) {
|
||||||
line = line.trim();
|
|
||||||
|
|
||||||
// Skip empty lines
|
// Skip empty lines
|
||||||
if (line === '') {
|
if (line === '') {
|
||||||
if (currentParagraph) {
|
if (currentParagraph) {
|
||||||
|
|
@ -756,7 +788,7 @@ jQuery(document).ready(function($) {
|
||||||
}
|
}
|
||||||
|
|
||||||
// If line is already wrapped in HTML tags, add it as is
|
// If line is already wrapped in HTML tags, add it as is
|
||||||
if (line.match(/^<(h[1-6]|ul|li|strong|em)/)) {
|
if (line.match(/^<(h[1-6]|ul|\/ul|li|strong|em)/)) {
|
||||||
if (currentParagraph) {
|
if (currentParagraph) {
|
||||||
paragraphs.push(currentParagraph);
|
paragraphs.push(currentParagraph);
|
||||||
currentParagraph = '';
|
currentParagraph = '';
|
||||||
|
|
@ -779,7 +811,7 @@ jQuery(document).ready(function($) {
|
||||||
|
|
||||||
// Wrap non-HTML paragraphs in <p> tags
|
// Wrap non-HTML paragraphs in <p> tags
|
||||||
const formattedParagraphs = paragraphs.map(p => {
|
const formattedParagraphs = paragraphs.map(p => {
|
||||||
if (p.match(/^<(h[1-6]|ul|li)/)) {
|
if (p.match(/^<(h[1-6]|ul|\/ul|li)/)) {
|
||||||
return p;
|
return p;
|
||||||
} else {
|
} else {
|
||||||
return '<p>' + p + '</p>';
|
return '<p>' + p + '</p>';
|
||||||
|
|
|
||||||
|
|
@ -1652,7 +1652,7 @@ HTML;
|
||||||
'tinymce' => [
|
'tinymce' => [
|
||||||
'toolbar1' => 'formatselect,bold,italic,underline,strikethrough,|,bullist,numlist,|,link,unlink,|,blockquote,hr,|,alignleft,aligncenter,alignright,|,undo,redo',
|
'toolbar1' => 'formatselect,bold,italic,underline,strikethrough,|,bullist,numlist,|,link,unlink,|,blockquote,hr,|,alignleft,aligncenter,alignright,|,undo,redo',
|
||||||
'toolbar2' => '',
|
'toolbar2' => '',
|
||||||
'block_formats' => 'Paragraph=p;Heading 2=h2;Heading 3=h3;Heading 4=h4;Preformatted=pre',
|
'block_formats' => 'Paragraph=p;Heading 2=h2;Heading 3=h3;Heading 4=h4;Heading 5=h5;Heading 6=h6;Preformatted=pre',
|
||||||
'forced_root_block' => 'p',
|
'forced_root_block' => 'p',
|
||||||
'force_p_newlines' => true,
|
'force_p_newlines' => true,
|
||||||
'remove_redundant_brs' => true,
|
'remove_redundant_brs' => true,
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue