Skip to content

Commit

Permalink
fix: wp.blockEditor.RichText multiline prop is deprecated since versi…
Browse files Browse the repository at this point in the history
…on 6.1 and will be removed in version 6.3. Please use nested blocks (InnerBlocks) instead. See: https://developer.wordpress.org/block-editor/how-to-guides/block-tutorial/nested-blocks-inner-blocks/
  • Loading branch information
yhira committed Jul 18, 2023
1 parent 9e5acee commit 44b54e5
Show file tree
Hide file tree
Showing 11 changed files with 60 additions and 6 deletions.
4 changes: 4 additions & 0 deletions amp.css
Expand Up @@ -1962,6 +1962,10 @@ img.blogcard-favicon-image {
margin-left: 0;
}

.blogcard-type br {
display: none;
}

/************************************
** 目次
************************************/
Expand Down
2 changes: 1 addition & 1 deletion blocks/dist/blocks.build.js

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions blocks/src/block/blogcard/edit.js
Expand Up @@ -90,8 +90,8 @@ export default function edit( { attributes, setAttributes, className } ) {
<div { ...blockProps }>
<RichText
onChange={ onChangeContent }
value={ content }
multiline="p"
value={ content.replace( /\s/g, '' ) }
// multiline="p"
/>
</div>
</Fragment>
Expand Down
11 changes: 9 additions & 2 deletions blocks/src/block/blogcard/save.js
Expand Up @@ -6,14 +6,21 @@ export default function save( { attributes } ) {
const blockProps = useBlockProps.save( {
className: classes,
} );
const urlbr = /(http|https):\/\/[^\s$.?#].[^\s]*<br\/?>/g;
const urldiv = /(http|https):\/\/[^\s$.?#].[^\s]*$/g;
return (
<div { ...blockProps }>
<RichText.Content
value={ content
.replace( /<\/p><p>/g, '</p>\n<p>' )
.replace( /^<p>/g, '\n<p>' )
.replace( /<\/p>$/g, '</p>\n' ) }
multiline={ 'p' }
.replace( /<\/p>$/g, '</p>\n' )
.replace( /<br>/g, '\n<br>\n' )
.replace( /^/g, '\n' )
.replace( /$/g, '\n' )
//改行や空白なら変更(置換)してもいいけど文章内容やタグを変更するとエラーになるので注意!
}
// multiline={ 'p' }
/>
</div>
);
Expand Down
1 change: 0 additions & 1 deletion blocks/src/block/faq/edit.js
Expand Up @@ -142,7 +142,6 @@ export function FAQEdit( props ) {
className="faq-question-content"
placeholder={ __( '質問を入力してください…', THEME_NAME ) }
value={ question }
multiline={ false }
onChange={ ( value ) => setAttributes( { question: value } ) }
/>
</div>
Expand Down
6 changes: 6 additions & 0 deletions css/admin.css
Expand Up @@ -2310,6 +2310,9 @@ body.wp-admin {
margin-right: 31.6%;
margin-left: 0;
}
.admin-settings .demo .blogcard-type br {
display: none;
}
.admin-settings .demo .toc {
border: 1px solid var(--cocoon-basic-border-color);
font-size: 0.9em;
Expand Down Expand Up @@ -9952,6 +9955,9 @@ body.wp-admin {
margin-right: 31.6%;
margin-left: 0;
}
.admin-settings .demo .blogcard-type br {
display: none;
}
.admin-settings .demo .toc {
border: 1px solid var(--cocoon-basic-border-color);
font-size: 0.9em;
Expand Down
10 changes: 10 additions & 0 deletions css/gutenberg-editor.css
Expand Up @@ -5156,3 +5156,13 @@ div.editor-styles-wrapper .edit-post-visual-editor__post-title-wrapper {
.block-editor-iframe__body .editor-post-title::after {
display: none;
}

.block-editor-block-list__block.blogcard-type {
line-height: 3;
}
.block-editor-block-list__block.blogcard-type p {
margin: 0;
}
.block-editor-block-list__block.blogcard-type br {
display: initial !important;
}
1 change: 1 addition & 0 deletions lib/blogcard-out.php
Expand Up @@ -30,6 +30,7 @@ function url_to_external_blog_card_tag($url){
//本文中の外部URLをはてなブログカードタグに変更する
if ( !function_exists( 'url_to_external_blog_card' ) ):
function url_to_external_blog_card($the_content) {
// return $the_content;
// //ブロックエディターのブログカード用の本文整形
// $the_content = fix_blogcard_content($the_content);
//1行にURLのみが期待されている行(URL)を全て$mに取得
Expand Down
6 changes: 6 additions & 0 deletions scss/_blogcard.scss
Expand Up @@ -101,3 +101,9 @@ img.blogcard-favicon-image{
.nwa{
@include blog_card_834;
}

.blogcard-type{
br{
display: none;
}
}
17 changes: 17 additions & 0 deletions scss/gutenberg-editor.scss
Expand Up @@ -1354,4 +1354,21 @@ div.editor-styles-wrapper .edit-post-visual-editor__post-title-wrapper {

.block-editor-iframe__body .editor-post-title::after{
display: none;
}

// [data-type="cocoon-blocks/blogcard"]{
// [data-rich-text-line-break="true"]{
// display: none;
// }
// }

//pのブロンカードURL入力と、brのブログカードURL入力の表示を均一化
.block-editor-block-list__block.blogcard-type{
p{
margin: 0;
}
br{
display: initial !important;
}
line-height: 3;
}
4 changes: 4 additions & 0 deletions style.css
Expand Up @@ -1987,6 +1987,10 @@ img.blogcard-favicon-image {
margin-left: 0;
}

.blogcard-type br {
display: none;
}

/************************************
** 目次
************************************/
Expand Down

0 comments on commit 44b54e5

Please sign in to comment.