Also render footnotes in tooltip shortcode #60
12
ACTIONS.md
12
ACTIONS.md
@ -583,6 +583,18 @@ Fires right after opening the article’s `<footer>` container in the `single-fc
|
||||
|
||||
---
|
||||
|
||||
### `do_action( 'fictioneer_collect_footnote', $args )`
|
||||
Fires immediately after the HTML output of the tooltip is created to collect tooltip content for footnotes in the `_setup-shortcodes.php` file.
|
||||
|
||||
**$args:**
|
||||
* `footnote_id` (int) – Unique identifier for the footnote.
|
||||
* `content` (string) – Content of the footnote.
|
||||
|
||||
**Hooked Actions:**
|
||||
* `fictioneer_collect_footnote( $footnote_id, $content )` – Collect a footnote to be stored in a global array for later rendering. Priority 10.
|
||||
|
||||
---
|
||||
|
||||
### `do_action( 'fictioneer_collections_no_results', $args )`
|
||||
List page template hook. Fires right at the top of an empty result list in the `'fictioneer_collections_list'` action, before the no-result message is rendered.
|
||||
|
||||
|
@ -374,7 +374,7 @@ Fictioneer customizes WordPress by using as many standard action and filter hook
|
||||
| `show_admin_bar` | `__return_false` (10)
|
||||
| `strip_shortcodes_tagnames` | `fictioneer_exempt_shortcodes_from_removal` (10)
|
||||
| `style_loader_tag` | `fictioneer_add_font_awesome_integrity` (10)
|
||||
| `the_content` | `fictioneer_embed_consent_wrappers` (20), `fictioneer_add_lightbox_to_post_images` (15), `fictioneer_add_chapter_paragraph_id` (10), `fictioneer_replace_br_with_whitespace` (6), `fictioneer_fix_line_breaks` (1)
|
||||
| `the_content` | `fictioneer_append_footnotes_to_content` (20), `fictioneer_embed_consent_wrappers` (20), `fictioneer_add_lightbox_to_post_images` (15), `fictioneer_add_chapter_paragraph_id` (10), `fictioneer_replace_br_with_whitespace` (6), `fictioneer_fix_line_breaks` (1)
|
||||
| `the_password_form` | `fictioneer_password_form` (10), `fictioneer_unlock_with_patreon` (20)
|
||||
| `the_content_more_link` | `fictioneer_wrap_read_more_link` (10)
|
||||
| `the_excerpt_rss` | `fictioneer_filter_rss_excerpt` (10)
|
||||
|
10
FILTERS.md
10
FILTERS.md
@ -929,6 +929,16 @@ Filters the font array compiled from all valid font folders and Google Fonts lin
|
||||
|
||||
---
|
||||
|
||||
### `apply_filters( 'fictioneer_filter_footnotes', $footnotes )`
|
||||
Filters the collection array of footnotes to be rendered.
|
||||
|
||||
Filters the font array compiled from all valid font folders and Google Fonts links in both the parent and child theme. Note that the `fictioneer_get_font_data()` function reads the file system, which is potentially slow.
|
||||
|
||||
**Parameters:**
|
||||
* $footnotes (array) – Array of footnotes (ID => HTML).
|
||||
|
||||
---
|
||||
|
||||
### `apply_filters( 'fictioneer_filter_header_image', $header_image_url, $post_id )`
|
||||
Filters the URL of the header image in the `header.php` template.
|
||||
|
||||
|
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
@ -458,3 +458,79 @@ if ( FICTIONEER_ENABLE_STORY_DATA_META_CACHE ) {
|
||||
add_action( 'wp_insert_comment', 'fictioneer_increment_story_comment_count' );
|
||||
add_action( 'delete_comment', 'fictioneer_decrement_story_comment_count' );
|
||||
}
|
||||
|
||||
// =============================================================================
|
||||
// TOOLTIP FOOTNOTES
|
||||
// =============================================================================
|
||||
|
||||
/**
|
||||
* Collects a footnote to be stored for later rendering
|
||||
*
|
||||
* @since 5.25.0
|
||||
*
|
||||
* @param int $footnote_id Unique identifier for the footnote.
|
||||
* @param string $content Content of the footnote.
|
||||
*/
|
||||
|
||||
function fictioneer_collect_footnote( $footnote_id, $content ) {
|
||||
global $fictioneer_footnotes;
|
||||
|
||||
// Initialize footnotes array if it doesn't exist
|
||||
if ( ! is_array( $fictioneer_footnotes ) ) {
|
||||
$fictioneer_footnotes = [];
|
||||
}
|
||||
|
||||
// Store footnote content with its ID
|
||||
$fictioneer_footnotes[ $footnote_id ] = $content;
|
||||
}
|
||||
|
||||
/**
|
||||
* Renders collected footnotes at the end of the content
|
||||
*
|
||||
* @since 5.25.0
|
||||
*
|
||||
* @param string $content The post content.
|
||||
*
|
||||
* @return string The post content with appended footnotes.
|
||||
*/
|
||||
|
||||
function fictioneer_append_footnotes_to_content( $content ) {
|
||||
global $fictioneer_footnotes;
|
||||
|
||||
// Only proceed for single posts/pages with footnotes
|
||||
if ( ! is_singular() || empty( $fictioneer_footnotes ) ) {
|
||||
return $content;
|
||||
}
|
||||
|
||||
// Allow modifications to the collected footnotes
|
||||
$fictioneer_footnotes = apply_filters( 'fictioneer_filter_footnotes', $fictioneer_footnotes );
|
||||
|
||||
// Generate the HTML for footnotes section
|
||||
$html = sprintf(
|
||||
'<div class="footnotes"><h3>%s</h3>',
|
||||
esc_html( __( 'Footnotes', 'fictioneer' ) )
|
||||
);
|
||||
|
||||
$html .= '<ol class="footnotes__list list">';
|
||||
|
||||
foreach ( $fictioneer_footnotes as $id => $footnote ) {
|
||||
$html .= sprintf(
|
||||
'<li id="footnote-%1$d" class="footnotes__item">%2$s <a href="#tooltip-%1$d" class="footnotes__link-up"><i class="fa-solid fa-arrow-turn-up"></i></a></li>',
|
||||
$id,
|
||||
wp_kses_post( $footnote )
|
||||
);
|
||||
}
|
||||
|
||||
$html .= '</ol></div>';
|
||||
|
||||
// Reset the footnotes array
|
||||
$fictioneer_footnotes = [];
|
||||
|
||||
// Append footnotes to the content
|
||||
return $content . $html;
|
||||
}
|
||||
|
||||
if ( get_option( 'fictioneer_generate_footnotes_from_tooltips' ) ) {
|
||||
add_action( 'fictioneer_collect_footnote', 'fictioneer_collect_footnote', 10, 2 );
|
||||
add_filter( 'the_content', 'fictioneer_append_footnotes_to_content', 20 );
|
||||
}
|
||||
|
@ -2346,51 +2346,90 @@ if ( ! get_option( 'fictioneer_disable_all_widgets' ) ) {
|
||||
}
|
||||
|
||||
// =============================================================================
|
||||
// TOOLTIP SHORTCODE
|
||||
// TOOLTIP AND FOOTNOTE SHORTCODE
|
||||
// =============================================================================
|
||||
|
||||
/**
|
||||
* Shortcode to add tooltip modal
|
||||
* Shortcode to add a tooltip with an associated footnote
|
||||
*
|
||||
* @since 5.25.0
|
||||
*
|
||||
* @param string $atts['header'] Optional. Header of the tooltip.
|
||||
* @param string $atts['content'] Content of the tooltip.
|
||||
* @param bool $atts['footnote'] Optional. Whether to show the footnote. Default true.
|
||||
* @param string $content Shortcode content.
|
||||
*
|
||||
* @return string The shortcode HTML.
|
||||
* @return string HTML for the tooltip and associated footnote link.
|
||||
*/
|
||||
|
||||
function fictioneer_shortcode_tooltip( $atts, $content = null ) {
|
||||
// Initialize a static counter for unique tooltip/footnote IDs
|
||||
static $tooltip_id_counter = 0;
|
||||
|
||||
// Setup
|
||||
$data = '';
|
||||
$attributes = shortcode_atts(
|
||||
array( 'header' => '', 'content' => '' ),
|
||||
$atts,
|
||||
'fcnt'
|
||||
$default_atts = array(
|
||||
'header' => '',
|
||||
'content' => '',
|
||||
'footnote' => true,
|
||||
);
|
||||
|
||||
// Sanitize
|
||||
$modal_header = trim( wp_kses_post( $attributes['header'] ) );
|
||||
$modal_header = esc_attr( $modal_header );
|
||||
$atts = shortcode_atts( $default_atts, $atts, 'fcnt' );
|
||||
$footnote_allowed = get_option( 'fictioneer_generate_footnotes_from_tooltips' ) && $atts['footnote'];
|
||||
$footnote_link = '';
|
||||
|
||||
$modal_content = trim( wp_kses_post( $attributes['content'] ) );
|
||||
$modal_content = esc_attr( $modal_content );
|
||||
// Sanitize user inputs
|
||||
$tooltip_header = trim( wp_kses_post( $atts[ 'header' ] ) );
|
||||
$tooltip_content = trim( wp_kses_post( $atts[ 'content' ] ) );
|
||||
|
||||
// Tooltip content?
|
||||
if ( empty( $modal_content ) ) {
|
||||
// Bail if no content
|
||||
if ( empty( $tooltip_content ) ) {
|
||||
return $content;
|
||||
}
|
||||
|
||||
// Build attributes
|
||||
if ( ! empty( $modal_header ) ) {
|
||||
$data .= 'data-dialog-header="' . esc_attr( $modal_header ) . '" ';
|
||||
// Increment counter
|
||||
$tooltip_id_counter++;
|
||||
|
||||
// Prepare footnote if allowed
|
||||
if ( $footnote_allowed ) {
|
||||
// Create a footnote link to be appended to the tooltip content
|
||||
$footnote_link = sprintf(
|
||||
'<sup class="tooltip-counter"><a href="#footnote-%1$d" class="footnote-link">%1$d</a></sup>',
|
||||
$tooltip_id_counter
|
||||
);
|
||||
}
|
||||
|
||||
$data .= 'data-dialog-content="' . esc_attr( $modal_content ) . '"';
|
||||
$title = _x( 'Click to see note', 'Tooltip shortcode.', 'fictioneer' );
|
||||
// Prepare data attributes for the tooltip
|
||||
$tooltip_data = array(
|
||||
'dialog-header' => $tooltip_header,
|
||||
'dialog-content' => $tooltip_content . $footnote_link,
|
||||
);
|
||||
|
||||
// Return HTML
|
||||
return '<a class="modal-tooltip" title="' . $title . '" ' . $data . ' data-click-action="open-tooltip-modal">' .
|
||||
$content . '</a>';
|
||||
// Convert data array to HTML attributes
|
||||
$tooltip_data_attributes = array_map(
|
||||
function ( $key, $value ) {
|
||||
return sprintf( 'data-%s="%s"', esc_attr( $key ), esc_attr( $value ) );
|
||||
},
|
||||
array_keys( $tooltip_data ),
|
||||
$tooltip_data
|
||||
);
|
||||
|
||||
$tooltip_title = _x( 'Click to see note', 'Tooltip shortcode.', 'fictioneer' );
|
||||
|
||||
// Construct the HTML for the tooltip
|
||||
$html = sprintf(
|
||||
'<span><a id="tooltip-%1$d" class="modal-tooltip" title="%2$s" %3$s data-click-action="open-tooltip-modal">%4$s</a>%5$s</span>',
|
||||
$tooltip_id_counter,
|
||||
esc_attr( $tooltip_title ),
|
||||
implode( ' ', $tooltip_data_attributes ),
|
||||
$content,
|
||||
$footnote_link
|
||||
);
|
||||
|
||||
// Collect footnote if allowed
|
||||
if ( $footnote_allowed ) {
|
||||
do_action( 'fictioneer_collect_footnote', $tooltip_id_counter, $tooltip_content );
|
||||
}
|
||||
|
||||
return $html;
|
||||
}
|
||||
add_shortcode( 'fcnt', 'fictioneer_shortcode_tooltip' );
|
||||
|
@ -582,6 +582,12 @@ define( 'FICTIONEER_OPTIONS', array(
|
||||
'sanitize_callback' => 'fictioneer_sanitize_checkbox',
|
||||
'default' => 0
|
||||
),
|
||||
'fictioneer_generate_footnotes_from_tooltips' => array(
|
||||
'name' => 'fictioneer_generate_footnotes_from_tooltips',
|
||||
'group' => 'fictioneer-settings-general-group',
|
||||
'sanitize_callback' => 'fictioneer_sanitize_checkbox',
|
||||
'default' => 0
|
||||
),
|
||||
'fictioneer_show_protected_excerpt' => array(
|
||||
'name' => 'fictioneer_show_protected_excerpt',
|
||||
'group' => 'fictioneer-settings-general-group',
|
||||
@ -1137,6 +1143,7 @@ function fictioneer_get_option_label( $option ) {
|
||||
'fictioneer_disable_extended_story_list_meta_queries' => __( 'Disable extended story list meta queries', 'fictioneer' ),
|
||||
'fictioneer_disable_extended_chapter_list_meta_queries' => __( 'Disable extended chapter list meta queries', 'fictioneer' ),
|
||||
'fictioneer_count_characters_as_words' => __( 'Count characters instead of words', 'fictioneer' ),
|
||||
'fictioneer_generate_footnotes_from_tooltips' => __( 'Generate footnotes from tooltips', 'fictioneer' ),
|
||||
'fictioneer_show_protected_excerpt' => __( 'Show excerpt on password-protected posts', 'fictioneer' ),
|
||||
'fictioneer_hide_large_card_chapter_list' => __( 'Hide chapter list on large story cards', 'fictioneer' ),
|
||||
'fictioneer_show_story_cards_latest_chapters' => __( 'Show latest chapter on large story cards', 'fictioneer' ),
|
||||
|
@ -472,17 +472,17 @@ function fictioneer_settings_capability_checkbox( $cap, $name, $set ) {
|
||||
* @param string $label Label of the setting.
|
||||
* @param string|null $description Optional. The description below the label.
|
||||
* @param string|null $help Optional. The text for the helper modal.
|
||||
* @param string $image Optional. The image for the helper modal.
|
||||
* @param string $figure Optional. Figure (image, etc.) for the helper modal.
|
||||
*/
|
||||
|
||||
function fictioneer_settings_label_checkbox( $option, $label, $description = null, $help = null, $image = '' ) {
|
||||
function fictioneer_settings_label_checkbox( $option, $label, $description = null, $help = null, $figure = '' ) {
|
||||
// Setup
|
||||
if ( is_string( $help ) ) {
|
||||
$help = strpos( $help, '<p>' ) !== false ? $help : "<p>{$help}</p>";
|
||||
}
|
||||
|
||||
$help = ! is_string( $help ) ? '' :
|
||||
'<i class="fa-regular fa-circle-question fcn-help" data-action="fcn-show-help" data-label="' . esc_attr( $label ) . '" data-help="' . esc_attr( $image ) . esc_attr( $help ) . '" data-fcn-dialog-target="fcn-help-modal"></i>';
|
||||
'<i class="fa-regular fa-circle-question fcn-help" data-action="fcn-show-help" data-label="' . esc_attr( $label ) . '" data-help="' . esc_attr( $figure ) . esc_attr( $help ) . '" data-fcn-dialog-target="fcn-help-modal"></i>';
|
||||
|
||||
// Start HTML ---> ?>
|
||||
<label class="fictioneer-label-checkbox" for="<?php echo $option; ?>">
|
||||
|
@ -675,6 +675,23 @@ $images = get_template_directory_uri() . '/img/documentation/';
|
||||
?>
|
||||
</div>
|
||||
|
||||
<div class="fictioneer-card__row">
|
||||
<?php
|
||||
fictioneer_settings_label_checkbox(
|
||||
'fictioneer_generate_footnotes_from_tooltips',
|
||||
__( 'Enable footnotes from tooltips', 'fictioneer' ),
|
||||
__( 'Generate and show footnotes at the end of the post content based on the tooltips.', 'fictioneer' ),
|
||||
__( '<p>With this feature enabled, tooltips added with the <code>[fcnt]text[/fcnt]</code> shortcode are collected and appended to the content as footnotes, complete with anchor links.</p>', 'fictioneer' ),
|
||||
'<code class="helper-modal-code">' .
|
||||
_x(
|
||||
'[fcnt header="Optional" content="Tooltip content."]text[/fcnt]',
|
||||
'Settings helper modal tooltip shortcode figure.',
|
||||
'fictioneer' ) .
|
||||
'</code>'
|
||||
);
|
||||
?>
|
||||
</div>
|
||||
|
||||
<div class="fictioneer-card__row">
|
||||
<?php
|
||||
fictioneer_settings_label_checkbox(
|
||||
|
4
js/complete.min.js
vendored
4
js/complete.min.js
vendored
File diff suppressed because one or more lines are too long
2
js/suggestion.min.js
vendored
2
js/suggestion.min.js
vendored
@ -1 +1 @@
|
||||
diff_match_patch.prototype.fcn_prettyHtml=function(t){for(var e=[],n=/&/g,i=/</g,o=/>/g,s=/\n/g,l=0;l<t.length;l++){var a=t[l][0],r=t[l][1].replace(n,"&").replace(i,"<").replace(o,">").replace(s,"¶<br>");switch(a){case 1:e[l]=`<ins>${r}</ins>`;break;case-1:e[l]=`<del>${r}</del>`;break;case 0:e[l]=`${r}`}}return e.join("")};class FCN_Suggestion{constructor(){this.toggle=_$$$("suggestions-modal-toggle"),this.tools=_$$$("selection-tools"),this.button=_$$$("button-add-suggestion"),this.toolsButton=_$$$("button-tools-add-suggestion"),this.reset=_$$$("button-suggestion-reset"),this.submit=_$$$("button-suggestion-submit"),this.current=_$$$("suggestions-modal-original"),this.input=_$$$("suggestions-modal-input"),this.output=_$$$("suggestions-modal-diff"),this.chapter=_$(".chapter__article"),this.text="",this.original="",this.latest="",this.paragraph=null,this.dmp=new diff_match_patch,this.bindEvents()}getCaretCoordinates(){let t=0,e=0;if(void 0!==window.getSelection){const n=window.getSelection();if(0!==n.rangeCount){let i=n.getRangeAt(0).cloneRange().getClientRects();i=i[i.length-1],i&&(t=i.right+window.scrollX,e=i.bottom+window.scrollY)}}return{x:t,y:e}}getClosestParagraph(){const t=window.getSelection();return t.rangeCount?t.getRangeAt(0).startContainer.parentNode.closest("p"):null}showTools(t,e){const n=document.documentElement.offsetWidth/2+this.tools.offsetWidth,i=_$$$("wpadminbar")?_$$$("wpadminbar").offsetHeight:0;this.tools.style.transform=e>n?"translate(-100%)":"translate(0)",this.tools.style.top=t+4-i+"px",this.tools.style.left=`${e}px`,this.tools.classList.remove("invisible")}hideTools(){this.tools.style.top="0",this.tools.style.left="-1000px",this.tools.classList.add("invisible")}textSelection(){return fcn_cleanTextSelectionFromButtons(window.getSelection().toString())}clearSelection(){window.getSelection?window.getSelection().empty?window.getSelection().empty():window.getSelection().removeAllRanges&&window.getSelection().removeAllRanges():document.selection&&document.selection.empty()}getDiff(t,e){const n=this.dmp.diff_main(t,e);return this.dmp.diff_cleanupEfficiency(n),this.dmp.fcn_prettyHtml(n)}toggleTools(t){fcn_theSite.classList.contains("transformed-site")||window.getSelection().rangeCount<1||!window.getSelection().getRangeAt(0).startContainer.parentNode.closest(".content-section")||setTimeout((()=>{if(t.text=t.textSelection().replaceAll("\n\n","\n"),""!==t.text){const e=t.getCaretCoordinates();t.showTools(e.y,e.x)}else t.hideTools()}),10)}toggleViaParagraphTools(t){fcn_theSite.classList.contains("transformed-site")||(t.text=_$(".selected-paragraph").querySelector(".paragraph-inner").innerText,t.showModal(t))}resizeInput(){this.input.style.height="auto",this.input.style.height=`${fcn_clamp(32,108,this.input.scrollHeight+4)}px`}showModal(t){fcn_lastSelectedParagraphId&&fcn_toggleParagraphTools(!1),t.original=t.text,t.current.innerHTML=t.text.replaceAll("\n","<br>"),t.input.value=t.text,t.output.innerHTML=t.getDiff(t.original,t.text),t.paragraph=t.getClosestParagraph(),t.toggle.click(),t.toggle.checked=!0,t.clearSelection(),t.hideTools(),t.resizeInput(),t.input.focus()}editSuggestion(t){t.resizeInput(),t.output.innerHTML=t.getDiff(t.original,t.input.value)}resetSuggestion(t){t.input.value=t.original,t.resizeInput(),t.output.innerHTML=t.getDiff(t.original,t.original)}submitSuggestion(t){const e=_$(fictioneer_comments.form_selector??"#comment"),n=t.paragraph?.id??null;let i=t.output.innerHTML;[["¶","¶\n"],["<br>","\n"],["<ins>","[ins]"],["</ins>","[/ins]"],["<del>","[del]"],["</del>","[/del]"]].forEach((([t,e])=>{i=i.replaceAll(t,e)})),t.latest=`\n[quote]${i} [anchor]${n}[/anchor][/quote]\n`,e?"TEXTAREA"==e.tagName?(e.value+=t.latest,fcn_textareaAdjust(_$("textarea#comment"))):"DIV"==e.tagName&&(e.innerHTML+=t.latest):fcn_commentStack?.push(t.latest),t.toggle.click(),t.toggle.checked=!1,fcn_showNotification(fictioneer_tl.notification.suggestionAppendedToComment)}bindEvents(){this.chapter?.addEventListener("mouseup",this.toggleTools.bind(null,this)),this.button?.addEventListener("click",this.showModal.bind(null,this)),this.toolsButton?.addEventListener("click",this.toggleViaParagraphTools.bind(null,this)),this.input?.addEventListener("input",this.editSuggestion.bind(null,this)),this.reset?.addEventListener("click",this.resetSuggestion.bind(null,this)),this.submit?.addEventListener("click",this.submitSuggestion.bind(null,this))}}const fcn_suggestions=_$(".chapter__article")&&_$(".comment-section")&&_$$$("selection-tools")?new FCN_Suggestion:null;fcn_suggestions&&document.addEventListener("click",(function(t){t.target.closest(".content-section")||fcn_suggestions.hideTools()}));
|
||||
diff_match_patch.prototype.fcn_prettyHtml=function(t){for(var e=[],n=/&/g,i=/</g,o=/>/g,s=/\n/g,l=0;l<t.length;l++){var a=t[l][0],r=t[l][1].replace(n,"&").replace(i,"<").replace(o,">").replace(s,"¶<br>");switch(a){case 1:e[l]=`<ins>${r}</ins>`;break;case-1:e[l]=`<del>${r}</del>`;break;case 0:e[l]=`${r}`}}return e.join("")};class FCN_Suggestion{constructor(){this.toggle=_$$$("suggestions-modal-toggle"),this.tools=_$$$("selection-tools"),this.button=_$$$("button-add-suggestion"),this.toolsButton=_$$$("button-tools-add-suggestion"),this.reset=_$$$("button-suggestion-reset"),this.submit=_$$$("button-suggestion-submit"),this.current=_$$$("suggestions-modal-original"),this.input=_$$$("suggestions-modal-input"),this.output=_$$$("suggestions-modal-diff"),this.chapter=_$(".chapter__article"),this.text="",this.original="",this.latest="",this.paragraph=null,this.dmp=new diff_match_patch,this.bindEvents()}getCaretCoordinates(){let t=0,e=0;if(void 0!==window.getSelection){const n=window.getSelection();if(0!==n.rangeCount){let i=n.getRangeAt(0).cloneRange().getClientRects();i=i[i.length-1],i&&(t=i.right+window.scrollX,e=i.bottom+window.scrollY)}}return{x:t,y:e}}getClosestParagraph(){const t=window.getSelection();return t.rangeCount?t.getRangeAt(0).startContainer.parentNode.closest("p"):null}showTools(t,e){const n=document.documentElement.offsetWidth/2+this.tools.offsetWidth,i=_$$$("wpadminbar")?_$$$("wpadminbar").offsetHeight:0;this.tools.style.transform=e>n?"translate(-100%)":"translate(0)",this.tools.style.top=t+4-i+"px",this.tools.style.left=`${e}px`,this.tools.classList.remove("invisible")}hideTools(){this.tools.style.top="0",this.tools.style.left="-1000px",this.tools.classList.add("invisible")}textSelection(){return fcn_cleanTextSelectionFromButtons(window.getSelection().toString())}clearSelection(){window.getSelection?window.getSelection().empty?window.getSelection().empty():window.getSelection().removeAllRanges&&window.getSelection().removeAllRanges():document.selection&&document.selection.empty()}getDiff(t,e){const n=this.dmp.diff_main(t,e);return this.dmp.diff_cleanupEfficiency(n),this.dmp.fcn_prettyHtml(n)}toggleTools(t){fcn_theSite.classList.contains("transformed-site")||window.getSelection().rangeCount<1||!window.getSelection().getRangeAt(0).startContainer.parentNode.closest(".content-section")||setTimeout((()=>{if(t.text=t.textSelection().replaceAll("\n\n","\n"),""!==t.text){const e=t.getCaretCoordinates();t.showTools(e.y,e.x)}else t.hideTools()}),10)}toggleViaParagraphTools(t){fcn_theSite.classList.contains("transformed-site")||(t.text=_$(".selected-paragraph").querySelector(".paragraph-inner").innerText,t.showModal(t))}resizeInput(){this.input.style.height="auto",this.input.style.height=`${fcn_clamp(32,108,this.input.scrollHeight+4)}px`}showModal(t){fcn_lastSelectedParagraphId&&fcn_toggleParagraphTools(!1),t.original=t.text,t.current.innerHTML=t.text.replaceAll("\n","<br>"),t.input.value=t.text,t.output.innerHTML=t.getDiff(t.original,t.text),t.paragraph=t.getClosestParagraph(),t.toggle.click(),t.toggle.checked=!0,t.clearSelection(),t.hideTools(),t.resizeInput(),t.input.focus()}editSuggestion(t){t.resizeInput(),t.output.innerHTML=t.getDiff(t.original,t.input.value)}resetSuggestion(t){t.input.value=t.original,t.resizeInput(),t.output.innerHTML=t.getDiff(t.original,t.original)}submitSuggestion(t){const e=_$(fictioneer_comments.form_selector??"#comment"),n=t.paragraph?.id??null;let i=t.output.innerHTML;[["¶","¶\n"],["<br>","\n"],["<ins>","[ins]"],["</ins>","[/ins]"],["<del>","[del]"],["</del>","[/del]"]].forEach((([t,e])=>{i=i.replaceAll(t,e)})),t.latest=n?`\n[quote]${i} [anchor]${n}[/anchor][/quote]\n`:`\n[quote]${i}[/quote]\n`,e?"TEXTAREA"==e.tagName?(e.value+=t.latest,fcn_textareaAdjust(_$("textarea#comment"))):"DIV"==e.tagName&&(e.innerHTML+=t.latest):fcn_commentStack?.push(t.latest),t.toggle.click(),t.toggle.checked=!1,fcn_showNotification(fictioneer_tl.notification.suggestionAppendedToComment)}bindEvents(){this.chapter?.addEventListener("mouseup",this.toggleTools.bind(null,this)),this.button?.addEventListener("click",this.showModal.bind(null,this)),this.toolsButton?.addEventListener("click",this.toggleViaParagraphTools.bind(null,this)),this.input?.addEventListener("input",this.editSuggestion.bind(null,this)),this.reset?.addEventListener("click",this.resetSuggestion.bind(null,this)),this.submit?.addEventListener("click",this.submitSuggestion.bind(null,this))}}const fcn_suggestions=_$(".chapter__article")&&_$(".comment-section")&&_$$$("selection-tools")?new FCN_Suggestion:null;fcn_suggestions&&document.addEventListener("click",(function(t){t.target.closest(".content-section")||fcn_suggestions.hideTools()}));
|
@ -1292,7 +1292,7 @@ const fcn_chapterKeyboardNavigation = event => {
|
||||
document.addEventListener('keydown', fcn_chapterKeyboardNavigation);
|
||||
|
||||
// =============================================================================
|
||||
// SCROLL TO START OG CHAPTER
|
||||
// SCROLL TO START OF CHAPTER
|
||||
// =============================================================================
|
||||
|
||||
if (window.location.hash === '#start') {
|
||||
|
@ -218,7 +218,11 @@ class FCN_Suggestion {
|
||||
});
|
||||
|
||||
// Output
|
||||
if (paragraphID) {
|
||||
instance.latest = `\n[quote]${final} [anchor]${paragraphID}[/anchor][/quote]\n`;
|
||||
} else {
|
||||
instance.latest = `\n[quote]${final}[/quote]\n`;
|
||||
}
|
||||
|
||||
// Send to comment form or remember for later
|
||||
if (defaultEditor) {
|
||||
|
@ -1260,11 +1260,7 @@ a[data-fcn-dialog-target] {
|
||||
cursor: pointer;
|
||||
}
|
||||
|
||||
.helper-modal-image {
|
||||
padding: 1.5px;
|
||||
border: 1px solid currentColor;
|
||||
border-radius: 3px;
|
||||
|
||||
:is(.helper-modal-code, .helper-modal-image) {
|
||||
&:not(:first-child) {
|
||||
margin-top: .75em;
|
||||
}
|
||||
@ -1272,6 +1268,12 @@ a[data-fcn-dialog-target] {
|
||||
&:not(:last-child) {
|
||||
margin-bottom: .75em;
|
||||
}
|
||||
}
|
||||
|
||||
.helper-modal-image {
|
||||
padding: 1.5px;
|
||||
border: 1px solid currentColor;
|
||||
border-radius: 3px;
|
||||
|
||||
img {
|
||||
display: block;
|
||||
|
@ -886,3 +886,28 @@ html:not(.logged-in) body:not(.logged-in) {
|
||||
background: var(--input-background) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 20 20'%3E%3Cpath fill='%237b7d81' d='M9.293 12.95l.707.707L15.657 8l-1.414-1.414L10 10.828 5.757 6.586 4.343 8z'/%3E%3C/svg%3E") no-repeat right 4px center/1em;
|
||||
}
|
||||
}
|
||||
|
||||
.footnotes {
|
||||
font-size: max(8px, 0.8em); // Relative to content font size
|
||||
line-height: 1.7;
|
||||
margin-top: 4rem;
|
||||
|
||||
&__list:is(ol) {
|
||||
margin: 0;
|
||||
}
|
||||
|
||||
&__item{
|
||||
scroll-margin-top: 64px;
|
||||
|
||||
&::marker {
|
||||
color: inherit !important;
|
||||
}
|
||||
}
|
||||
|
||||
&__link-up {
|
||||
display: inline-block;
|
||||
font-size: 80%;
|
||||
padding: 2px 4px;
|
||||
transform: translateY(-0.1em);
|
||||
}
|
||||
}
|
||||
|
@ -64,8 +64,9 @@ img {
|
||||
|
||||
p a:not(.wp-element-button, .modal-tooltip),
|
||||
.content-section :is(.wp-block-table, .wp-block-pullquote, .wp-block-list) a:not(.wp-element-button, .modal-tooltip),
|
||||
.link,
|
||||
:is(.modal, .dialog-modal) a[href]:not(.button, .wp-element-button, .modal-tooltip) {
|
||||
:is(.modal, .dialog-modal) a[href]:not(.button, .wp-element-button, .modal-tooltip),
|
||||
.footnotes a[href*="http"],
|
||||
.link {
|
||||
color: var(--inline-link-color);
|
||||
text-decoration: var(--inline-link-text-decoration);
|
||||
text-underline-offset: 0.2em;
|
||||
@ -89,12 +90,25 @@ a.modal-tooltip {
|
||||
cursor: pointer;
|
||||
text-decoration: underline var(--fg-900) dotted 1px;
|
||||
text-underline-offset: 0.15em;
|
||||
scroll-margin-top: 64px;
|
||||
|
||||
&:hover {
|
||||
text-decoration-color: currentColor;
|
||||
}
|
||||
}
|
||||
|
||||
.footnote-link {
|
||||
--inline-link-color-visited: var(--inline-link-color);
|
||||
text-decoration: none !important;
|
||||
padding-left: 8px;
|
||||
margin-left: -6px;
|
||||
scroll-margin-top: 64px;
|
||||
|
||||
&:hover {
|
||||
text-decoration: none !important;
|
||||
}
|
||||
}
|
||||
|
||||
.esc-link a:not(.link) {
|
||||
color: inherit;
|
||||
|
||||
@ -115,7 +129,7 @@ a.modal-tooltip {
|
||||
}
|
||||
|
||||
&:where(:not(:last-child, .cell-title, .card__title, .post__title)) {
|
||||
margin-bottom: var(--heading-margin-bottom, min(max(1.25rem, var(--paragraph-spacing) - 0.75rem), 2rem));
|
||||
margin-bottom: var(--heading-margin-bottom, min(max(0.75rem, var(--paragraph-spacing) - 0.75rem), 2rem));
|
||||
}
|
||||
}
|
||||
|
||||
@ -296,7 +310,7 @@ a.modal-tooltip {
|
||||
.content-section {
|
||||
:where(.list, .block-list, .wp-block-footnotes, .litrpg-body :where(ul, ol)) {
|
||||
list-style: initial;
|
||||
padding-left: 1.75rem;
|
||||
padding-left: 1.85em;
|
||||
margin: 1.5rem 0 0;
|
||||
|
||||
&:not(:last-child) {
|
||||
@ -305,7 +319,7 @@ a.modal-tooltip {
|
||||
|
||||
> li {
|
||||
&:not(:last-child) {
|
||||
margin-bottom: .75rem;
|
||||
margin-bottom: .75em;
|
||||
}
|
||||
|
||||
> :is(ul, ol) {
|
||||
|
Loading…
x
Reference in New Issue
Block a user