-
Notifications
You must be signed in to change notification settings - Fork 4
Lighthouse draftjs #613
base: master
Are you sure you want to change the base?
Lighthouse draftjs #613
Changes from 2 commits
82e1e7f
0021e31
791820a
39d9d71
672de07
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,66 @@ | ||
import React from 'react'; | ||
import { injectLazyLibs } from '@plone/volto/helpers/Loadable/Loadable'; | ||
import Icon from '@plone/volto/components/theme/Icon/Icon'; | ||
import showSVG from '@plone/volto/icons/show.svg'; | ||
|
||
import DraftJsDropdownButton from './DraftJsDropdownButton'; | ||
|
||
const AlignButtonComponent = (props) => { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. C'è un refuso, dai un nome specifico a questo componente |
||
const createBlockStyleButton = props.draftJsCreateBlockStyleButton.default; | ||
const options = [ | ||
{ | ||
block_type: 'lighthouse_appointment-booking', | ||
value: createBlockStyleButton({ | ||
blockType: 'lighthouse_appointment-booking', | ||
children: 'appointment-booking', | ||
}), | ||
contentWhenSelected: <Icon name={showSVG} size="24px" />, | ||
}, | ||
{ | ||
block_type: 'lighthouse_faq', | ||
value: createBlockStyleButton({ | ||
blockType: 'lighthouse_faq', | ||
children: 'faq', | ||
}), | ||
contentWhenSelected: <Icon name={showSVG} size="24px" />, | ||
}, | ||
{ | ||
block_type: 'lighthouse_report-inefficency', | ||
value: createBlockStyleButton({ | ||
blockType: 'lighthouse_report-inefficency', | ||
children: 'report-inefficency', | ||
}), | ||
contentWhenSelected: <Icon name={showSVG} size="24px" />, | ||
}, | ||
{ | ||
block_type: 'lighthouse_accessibility-link', | ||
value: createBlockStyleButton({ | ||
blockType: 'lighthouse_accessibility-link', | ||
children: 'accessibility-link', | ||
}), | ||
contentWhenSelected: <Icon name={showSVG} size="24px" />, | ||
}, | ||
{ | ||
block_type: 'lighthouse_privacy-policy-link', | ||
value: createBlockStyleButton({ | ||
blockType: 'lighthouse_privacy-policy-link', | ||
children: 'privacy-policy-link', | ||
}), | ||
contentWhenSelected: <Icon name={showSVG} size="24px" />, | ||
}, | ||
]; | ||
|
||
return ( | ||
<DraftJsDropdownButton | ||
{...props} | ||
optionsList={options} | ||
content={<Icon name={showSVG} size="24px" />} | ||
/> | ||
); | ||
}; | ||
|
||
export const AlignButton = injectLazyLibs(['draftJsCreateBlockStyleButton'])( | ||
AlignButtonComponent, | ||
); | ||
|
||
export default React.memo(AlignButton); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Idem qua come sopra, occhio quando copi e incolli! |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -11,6 +11,7 @@ import Blocks from '@plone/volto/config/RichTextEditor/Blocks'; | |
import UnderlineButton from '@italia/config/RichTextEditor/ToolbarButtons/UnderlineButton'; | ||
import HeadingsButton from '@italia/config/RichTextEditor/ToolbarButtons/HeadingsButton'; | ||
import AlignButton from '@italia/config/RichTextEditor/ToolbarButtons/AlignButton'; | ||
import Lighthouse from '@italia/config/RichTextEditor/ToolbarButtons/Lighthouse'; | ||
import CalloutsButton from '@italia/config/RichTextEditor/ToolbarButtons/CalloutsButton'; | ||
import ButtonsButton from '@italia/config/RichTextEditor/ToolbarButtons/ButtonsButton'; | ||
import TextSizeButton from '@italia/config/RichTextEditor/ToolbarButtons/TextSizeButton'; | ||
|
@@ -48,6 +49,8 @@ const ItaliaRichTextEditorInlineToolbarButtons = (props, plugins) => { | |
OrderedListButton, | ||
BlockquoteButton, | ||
CalloutsButton(props), | ||
Separator, | ||
Lighthouse, | ||
]; | ||
}; | ||
|
||
|
@@ -72,6 +75,15 @@ const renderHTMLBlock = (child) => { | |
} | ||
}); | ||
}; | ||
const renderDataElement = (element) => { | ||
if (typeof document !== 'undefined') { | ||
document.querySelector(`.lighthouse_${element} a`) && | ||
document | ||
.querySelector(`.lighthouse_${element} a`) | ||
.setAttribute('data-element', element); | ||
} | ||
}; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Questo seleziona un elemento con una classe specifica ma se creo due link con lo stesso data element il secondo è vuoto, qui ho inserito nel secondo e nel terzo link lo stesso data element, il secondo non popola neanche la classe Chiedo, non è possibile invece di utilizzare un selettore, applicare direttamente il data element ad un tag |
||
|
||
const ItaliaBlocksHtmlRenderers = { | ||
blockquote: (children, { keys }) => | ||
children.map((child, i) => ( | ||
|
@@ -83,6 +95,41 @@ const ItaliaBlocksHtmlRenderers = { | |
{renderHTMLBlock(child)} | ||
</p> | ||
)), | ||
'lighthouse_appointment-booking': (children, { keys }) => | ||
children.map((child, i) => ( | ||
<p id={keys[i]} key={keys[i]} className="lighthouse_appointment-booking"> | ||
{renderHTMLBlock(child)} | ||
{renderDataElement('appointment-booking')} | ||
</p> | ||
)), | ||
lighthouse_faq: (children, { keys }) => | ||
children.map((child, i) => ( | ||
<p id={keys[i]} key={keys[i]} className="lighthouse_faq"> | ||
{renderHTMLBlock(child)} | ||
{renderDataElement('faq')} | ||
</p> | ||
)), | ||
'lighthouse_report-inefficency': (children, { keys }) => | ||
children.map((child, i) => ( | ||
<p id={keys[i]} key={keys[i]} className="lighthouse_report-inefficency"> | ||
{renderHTMLBlock(child)} | ||
{renderDataElement('report-inefficency')} | ||
</p> | ||
)), | ||
'lighthouse_accessibility-link': (children, { keys }) => | ||
children.map((child, i) => ( | ||
<p id={keys[i]} key={keys[i]} className="lighthouse_accessibility-link"> | ||
{renderHTMLBlock(child)} | ||
{renderDataElement('accessibility-link')} | ||
</p> | ||
)), | ||
'lighthouse_privacy-policy-link': (children, { keys }) => | ||
children.map((child, i) => ( | ||
<p id={keys[i]} key={keys[i]} className="lighthouse_privacy-policy-link"> | ||
{renderHTMLBlock(child)} | ||
{renderDataElement('privacy-policy-link')} | ||
</p> | ||
)), | ||
'align-right': (children, { keys }) => | ||
children.map((child, i) => ( | ||
<p id={keys[i]} key={keys[i]} className="text-right"> | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Questa icona dell'occhio non mi convince perchè viene utilizzata in generale per mostrare e nascondere un contenuto, non vorrei che venisse fraintesa, suggerisco di utilizzare una di queste due icone