handling post-content-container words
This commit is contained in:
parent
dea39d7219
commit
7f8848b839
|
|
@ -1 +1 @@
|
|||
<?php return array('dependencies' => array('react', 'wp-block-editor', 'wp-blocks', 'wp-core-data', 'wp-data', 'wp-element', 'wp-i18n'), 'version' => 'ae650f260e754cce11e3');
|
||||
<?php return array('dependencies' => array('react', 'wp-block-editor', 'wp-blocks', 'wp-core-data', 'wp-data', 'wp-element', 'wp-i18n'), 'version' => 'd735e42cab437d8c526f');
|
||||
|
|
|
|||
|
|
@ -104,7 +104,7 @@ function Edit({
|
|||
function parseBlocksTooltips(currentBlocks) {
|
||||
const blocksTooltipWords = [];
|
||||
currentBlocks.forEach(block => {
|
||||
if (block.name === "homegrade-content-blocks/questions-container" && block.attributes && block.attributes.tooltipsWordsUsed && block.attributes.tooltipsWordsUsed.length > 0) {
|
||||
if ((block.name === "homegrade-content-blocks/questions-container" || block.name === "homegrade-content-blocks/post-content-container") && block?.attributes?.tooltipsWordsUsed?.length > 0) {
|
||||
block.attributes.tooltipsWordsUsed.forEach(tooltipWord => {
|
||||
blocksTooltipWords.push(tooltipWord);
|
||||
});
|
||||
|
|
@ -114,6 +114,7 @@ function Edit({
|
|||
}
|
||||
function buildTooltipWords() {
|
||||
let newParsedTooltipWords = parseContentTooltips(currentPost.content);
|
||||
console.log("qsdqsd", newParsedTooltipWords);
|
||||
let newBlocksTooltipWords = parseBlocksTooltips(currentBlocks);
|
||||
let allTooltipWords = [...newParsedTooltipWords, ...newBlocksTooltipWords];
|
||||
const filteredTooltipWords = filterToolTipsArray(allTooltipWords);
|
||||
|
|
|
|||
File diff suppressed because one or more lines are too long
|
|
@ -12,13 +12,13 @@ if (!function_exists('compareTooltipText')) :
|
|||
endif;
|
||||
|
||||
global $post;
|
||||
$thematique = get_the_terms($post->ID, 'thematiques')[0];
|
||||
$thematique = get_the_terms($post->ID, 'thematiques')[0] ?? null;
|
||||
|
||||
?>
|
||||
|
||||
<section id="vocabulaire-summary" class="homegrade-blocks-vocabulaire-summary">
|
||||
<h2 className="homegrade-blocks-vocabulaire-summary__title">
|
||||
<?php echo __("Vocabulaire", "homegrade-blocks") ?><?php echo $thematique->name ? " — " . $thematique->name : ""; ?>
|
||||
<?php echo __("Vocabulaire", "homegrade-blocks") ?><?php echo $thematique->name ? " — " . $thematique->name : ""; ?>
|
||||
</h2>
|
||||
|
||||
<?php foreach ($tooltipWords as $word) : ?>
|
||||
|
|
|
|||
|
|
@ -16,7 +16,7 @@ export default function Edit({ attributes, setAttributes }) {
|
|||
const { record, isResolving } = useEntityRecord(
|
||||
"taxonomy",
|
||||
"thematiques",
|
||||
id
|
||||
id,
|
||||
);
|
||||
|
||||
if (isResolving) {
|
||||
|
|
@ -31,7 +31,7 @@ export default function Edit({ attributes, setAttributes }) {
|
|||
const { record, isResolving } = useEntityRecord(
|
||||
"taxonomy",
|
||||
"thematiques",
|
||||
id
|
||||
id,
|
||||
);
|
||||
|
||||
if (isResolving) {
|
||||
|
|
@ -48,7 +48,7 @@ export default function Edit({ attributes, setAttributes }) {
|
|||
|
||||
tooltipWords.forEach((tooltipWord) => {
|
||||
const existingTooltip = filteredTooltipWords.find(
|
||||
(item) => item.tooltipID === tooltipWord.tooltipID
|
||||
(item) => item.tooltipID === tooltipWord.tooltipID,
|
||||
);
|
||||
|
||||
if (!existingTooltip) {
|
||||
|
|
@ -70,7 +70,7 @@ export default function Edit({ attributes, setAttributes }) {
|
|||
const tooltipID = tooltipWord.getAttribute("data-definition-id");
|
||||
const tooltipText = tooltipWord.getAttribute("data-tooltip-word");
|
||||
const tooltipDefinition = tooltipWord.getAttribute(
|
||||
"data-tooltip-definition"
|
||||
"data-tooltip-definition",
|
||||
);
|
||||
|
||||
tooltipWords.push({
|
||||
|
|
@ -85,10 +85,9 @@ export default function Edit({ attributes, setAttributes }) {
|
|||
const blocksTooltipWords = [];
|
||||
currentBlocks.forEach((block) => {
|
||||
if (
|
||||
block.name === "homegrade-content-blocks/questions-container" &&
|
||||
block.attributes &&
|
||||
block.attributes.tooltipsWordsUsed &&
|
||||
block.attributes.tooltipsWordsUsed.length > 0
|
||||
(block.name === "homegrade-content-blocks/questions-container" ||
|
||||
block.name === "homegrade-content-blocks/post-content-container") &&
|
||||
block?.attributes?.tooltipsWordsUsed?.length > 0
|
||||
) {
|
||||
block.attributes.tooltipsWordsUsed.forEach((tooltipWord) => {
|
||||
blocksTooltipWords.push(tooltipWord);
|
||||
|
|
@ -100,10 +99,10 @@ export default function Edit({ attributes, setAttributes }) {
|
|||
}
|
||||
function buildTooltipWords() {
|
||||
let newParsedTooltipWords = parseContentTooltips(currentPost.content);
|
||||
console.log("qsdqsd", newParsedTooltipWords);
|
||||
let newBlocksTooltipWords = parseBlocksTooltips(currentBlocks);
|
||||
let allTooltipWords = [...newParsedTooltipWords, ...newBlocksTooltipWords];
|
||||
const filteredTooltipWords = filterToolTipsArray(allTooltipWords);
|
||||
|
||||
return filteredTooltipWords;
|
||||
}
|
||||
|
||||
|
|
@ -112,15 +111,15 @@ export default function Edit({ attributes, setAttributes }) {
|
|||
}
|
||||
|
||||
const currentPost = useSelect((select) =>
|
||||
select("core/editor").getCurrentPost()
|
||||
select("core/editor").getCurrentPost(),
|
||||
);
|
||||
|
||||
const currentBlocks = useSelect((select) =>
|
||||
select("core/block-editor").getBlocks()
|
||||
select("core/block-editor").getBlocks(),
|
||||
);
|
||||
|
||||
const currentTaxonomies = useSelect((select) =>
|
||||
select("core/editor").getCurrentPostAttribute("thematiques")
|
||||
select("core/editor").getCurrentPostAttribute("thematiques"),
|
||||
);
|
||||
|
||||
let currentThematique = useSelect(
|
||||
|
|
@ -128,9 +127,9 @@ export default function Edit({ attributes, setAttributes }) {
|
|||
select("core").getEntityRecord(
|
||||
"taxonomy",
|
||||
"thematiques",
|
||||
currentTaxonomies[0] // or currentPost.thematiques[0] works as well
|
||||
currentTaxonomies[0], // or currentPost.thematiques[0] works as well
|
||||
),
|
||||
[currentTaxonomies]
|
||||
[currentTaxonomies],
|
||||
);
|
||||
function getAdminLanguageFromCookie(c_name) {
|
||||
var c_value = document.cookie,
|
||||
|
|
|
|||
|
|
@ -12,13 +12,13 @@ if (!function_exists('compareTooltipText')) :
|
|||
endif;
|
||||
|
||||
global $post;
|
||||
$thematique = get_the_terms($post->ID, 'thematiques')[0];
|
||||
$thematique = get_the_terms($post->ID, 'thematiques')[0] ?? null;
|
||||
|
||||
?>
|
||||
|
||||
<section id="vocabulaire-summary" class="homegrade-blocks-vocabulaire-summary">
|
||||
<h2 className="homegrade-blocks-vocabulaire-summary__title">
|
||||
<?php echo __("Vocabulaire", "homegrade-blocks") ?><?php echo $thematique->name ? " — " . $thematique->name : ""; ?>
|
||||
<?php echo __("Vocabulaire", "homegrade-blocks") ?><?php echo $thematique->name ? " — " . $thematique->name : ""; ?>
|
||||
</h2>
|
||||
|
||||
<?php foreach ($tooltipWords as $word) : ?>
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user