-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
bd5df8e
commit 2de8f41
Showing
48 changed files
with
483 additions
and
1,352 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,52 +1,32 @@ | ||
import { html } from "../../utils"; | ||
import "./ucd-wp-faq-item"; | ||
import { useBlockProps, BlockControls, InnerBlocks } from '@wordpress/block-editor'; | ||
import { useRef, useEffect } from "@wordpress/element"; | ||
|
||
import { useBlockProps, InnerBlocks, RichText } from '@wordpress/block-editor'; | ||
import classnames from 'classnames'; | ||
|
||
export default ( props ) => { | ||
const { attributes, setAttributes } = props; | ||
const blockProps = useBlockProps(); | ||
const mainEleRef = useRef(); | ||
|
||
// Wire up the main component | ||
const onMainEleUpdated = (e) => { | ||
const propName = e.detail.propName; | ||
const propValue = e.detail.propValue; | ||
const newAttrs = {}; | ||
newAttrs[propName] = propValue; | ||
setAttributes(newAttrs); | ||
} | ||
|
||
useEffect(() => { | ||
let mainEle = null; | ||
if ( mainEleRef.current ) { | ||
mainEleRef.current.addEventListener('updated', onMainEleUpdated); | ||
mainEle = mainEleRef.current; | ||
} | ||
return () => { | ||
if ( mainEle ) { | ||
mainEle.removeEventListener('updated', onMainEleUpdated); | ||
} | ||
}; | ||
const classes = classnames({ | ||
[`list--${attributes.listStyle}`]: true, | ||
}); | ||
|
||
const mainEleProps = () => { | ||
let p = {ref: mainEleRef}; | ||
if ( attributes.question ) p.question = attributes.question; | ||
p['list-style'] = attributes.listStyle; | ||
return p; | ||
} | ||
|
||
return html` | ||
<div ...${ blockProps }> | ||
<ucd-wp-faq-item ...${ mainEleProps() }> | ||
<div slot="question" contentEditable="true"></div> | ||
<div slot="answer"> | ||
<${InnerBlocks} /> | ||
</div> | ||
</ucd-wp-faq-item> | ||
<ul className=${classes}> | ||
<li> | ||
<${RichText} | ||
tagName="div" | ||
value=${attributes.question} | ||
onChange=${(v) => setAttributes({question: v})} | ||
withoutInteractiveFormatting | ||
allowedFormats=${[]} | ||
placeholder="Enter a question" | ||
/> | ||
</li> | ||
<li> | ||
<${InnerBlocks} /> | ||
</li> | ||
</ul> | ||
</div> | ||
` | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
38 changes: 0 additions & 38 deletions
38
src/editor/lib/blocks/ucd-theme-faq-item/ucd-wp-faq-item.js
This file was deleted.
Oops, something went wrong.
38 changes: 0 additions & 38 deletions
38
src/editor/lib/blocks/ucd-theme-faq-item/ucd-wp-faq-item.tpl.js
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.