-
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.
Merge pull request #34 from vektor-inc/fix/zoomout-toggle/api-v3
エディターツールバーにズームアウトのトグルが常に表示されない不具合を修正
- Loading branch information
Showing
65 changed files
with
11,709 additions
and
9,265 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 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 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 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 +1 @@ | ||
16.15.1 | ||
20.9.0 |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,21 +1,56 @@ | ||
# VK Pattern Directory Creator | ||
VK Pattern Directory Creator | ||
|
||
https://pdc.vs4.nagoya/ にて開発中 | ||
|
||
## これはなに? | ||
|
||
ブロックパターンディレクトリのサイトを作るためのプラグイン。 | ||
|
||
ブロックパターンディレクトリのサイトを作るためのプラグイン。 | ||
※ https://github.com/vektor-inc/vk-patterns に依存関係のないまったく別で独立したプラグイン | ||
|
||
### 想定用途 | ||
|
||
* ベクトルサーバーで、ベクトルのテーマ用のパターンを提供する | ||
* ベクトルテーマから API で直接アクセスして、ユーザーが管理画面から直接呼び出せるようにする | ||
* ベクトル以外の開発者がパターンディレクトリを作る事が出来る -> 販売するかどうかは未定 | ||
- ベクトルサーバーで、ベクトルのテーマ用のパターンを提供する | ||
- ベクトルテーマから API で直接アクセスして、ユーザーが管理画面から直接呼び出せるようにする | ||
- ベクトル以外の開発者がパターンディレクトリを作る事が出来る → 販売するかどうかは未定 | ||
|
||
## なぜ必要? | ||
|
||
現状 patterns.vektor-inc.co.jp 複数のテーマ用のパターンを入れているが、余白や色の定義 / 幅処理の方式 などがテーマによって異なるため、テーマ指定の余白サイズが使いづらかったりいろいろ無理がある。 | ||
現状 `patterns.vektor-inc.co.jp` は複数のテーマ用のパターンを入れているが、余白や色の定義 / 幅処理の方式などがテーマによって異なるため、テーマ指定の余白サイズが使いづらかったりいろいろ無理がある。 | ||
特に SmaVeksive は幅の扱いが全く違うため、SmaVeksive 専用のパターンディレクトリを作らないといけない。 | ||
|
||
## 仕様 | ||
|
||
### assets | ||
|
||
| ファイル名 | 説明 | | ||
|--------------------------|------------------------------------------------------------------------------------------| | ||
| **`copy-button.js`** | ボタンをクリックして、コードスニペットを簡単にコピー。コピー回数を記録して人気のあるパターンを把握。 | | ||
| **`iframe-responsive.js`** | ページ内のiframeをレスポンシブ対応にするスクリプトです。 | | ||
| **`size-select.js`** | ユーザーが選択したサイズで、iframe内のコンテンツをプレビュー。 | | ||
|
||
### modules | ||
|
||
| ファイル名 | 説明 | | ||
|-------------------------------|------------------------------------------------------------------------------------------| | ||
| **`blocks.php`** | カスタムブロックを登録し、WordPressブロックエディタ内で使用可能にする。 | | ||
| **`content-archive.php`** | アーカイブページ用のコンテンツテンプレートを提供。 | | ||
| **`content-archive-setting.php`** | アーカイブページ設定用の画面。 | | ||
| **`content-part.php`** | 特定の部分テンプレート(パーツ)を構成し、再利用性を向上させる。クラシックテーマのみ利用可能。 | | ||
| **`content-single.php`** | シングル投稿ページのコンテンツをレンダリング。 | | ||
| **`enquque-scripts.php`** | 必要なCSSやJavaScriptをWordPressに登録・読み込み。 | | ||
| **`iframe-sizes.php`** | iframeのサイズに関する設定・レスポンシブ対応を管理。 | | ||
| **`iframe-view.php`** | iframeの表示ロジックを定義し、ビューを出力するテンプレート。 | | ||
| **`register-post-type.php`** | カスタム投稿タイプ「Block Patterns」の登録ロジックを実装し、独自投稿タイプを作成。 | | ||
| **`register-custom-taxonomies.php`** | カスタム投稿タイプ「Block Patterns」のタクソノミー登録画面を実装し、独自カスタムタクソノミーを作成。 | | ||
|
||
また、テーマ「SmaVeksive」用にiframeの幅処理が必要なため、smaveksiveフォルダにまとめています。 | ||
|
||
### blocks | ||
|
||
| ブロック名 | 説明 | | ||
|-----------------------------|---------------------------------------------------------------------------------------| | ||
| **VK Pattern Description** | `vk-pattern-directory-creator/assets/src/js/copy-button.js`でパターンをコピーする際に、パターンの説明を入れたいけどコピーされたくない時は「VK Pattern Description」を使うとコピーされない。 | | ||
| **VK Pattern Display** | 固定ページか投稿か何かにブロックエディターで作ったページを参照してコピーできるブロック。 | | ||
| **VK Pattern List** | アーカイブなどでパターン一覧を作る時に使用。現在は件数、表示順が変更可能。 | | ||
|
||
### views | ||
|
||
テーマがブロックテーマかクラシックテーマかを見分ける時に使用される。 |
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 |
---|---|---|
@@ -0,0 +1,41 @@ | ||
const copyButtonOuterAll = document.querySelectorAll( | ||
'.vkpdc_button-outer--copy' | ||
); | ||
// eslint-disable-next-line no-undef | ||
const beforeTextSingle = VKPDCButtonCopy.beforeTextSingle; | ||
// eslint-disable-next-line no-undef | ||
const beforeTextArchive = VKPDCButtonCopy.beforeTextArchive; | ||
// eslint-disable-next-line no-undef | ||
const afterText = VKPDCButtonCopy.afterText; | ||
// eslint-disable-next-line no-undef | ||
const copyAjaxUrl = VKPDCButtonCopy.ajaxUrl; | ||
|
||
copyButtonOuterAll.forEach( ( copyButtonOuter ) => { | ||
const post_id = Number( copyButtonOuter.dataset.post ); | ||
const copyButton = copyButtonOuter.querySelector( `.vkpdc_button--copy` ); | ||
|
||
copyButton.onclick = () => { | ||
const req = new XMLHttpRequest(); // eslint-disable-line no-undef | ||
req.open( 'POST', copyAjaxUrl, true ); | ||
req.setRequestHeader( | ||
'content-type', | ||
'application/x-www-form-urlencoded;charset=UTF-8' | ||
); | ||
req.send( `action=copy_count&post=${ post_id }` ); | ||
let str = copyButton.getAttribute( 'data-clipboard-text' ); | ||
str = str.replace( /\\\[/g, '[' ); | ||
str = str.replace( /\\\]/g, ']' ); | ||
// eslint-disable-next-line no-undef | ||
navigator.clipboard.writeText( str ).then( | ||
// eslint-disable-next-line no-unused-vars | ||
( success ) => { | ||
let html = copyButton.innerHTML; | ||
html = html.replace( beforeTextSingle, afterText ); | ||
html = html.replace( beforeTextArchive, afterText ); | ||
copyButton.innerHTML = html; | ||
}, | ||
// eslint-disable-next-line no-unused-vars, no-undef, no-alert | ||
( error ) => alert( 'テキストのコピーに失敗😫' ) | ||
); | ||
}; | ||
} ); |
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 |
---|---|---|
@@ -0,0 +1,38 @@ | ||
( ( window, document ) => { | ||
/*-------------------------------------------*/ | ||
/* iframeのレスポンシブ対応 | ||
/*-------------------------------------------*/ | ||
function iframe_responsive() { | ||
Array.prototype.forEach.call( | ||
document.getElementsByTagName( 'iframe' ), | ||
( i ) => { | ||
const iframeUrl = i.getAttribute( 'src' ); | ||
if ( ! iframeUrl ) { | ||
return; | ||
} | ||
// iframeのURLの中に youtube か map が存在する位置を検索する | ||
// 見つからなかった場合には -1 が返される | ||
if ( | ||
iframeUrl.indexOf( 'youtube' ) >= 0 || | ||
iframeUrl.indexOf( 'vimeo' ) >= 0 || | ||
iframeUrl.indexOf( 'maps' ) >= 0 | ||
) { | ||
const iframeWidth = i.getAttribute( 'width' ); | ||
const iframeHeight = i.getAttribute( 'height' ); | ||
const iframeRate = iframeHeight / iframeWidth; | ||
const nowIframeWidth = i.offsetWidth; | ||
const newIframeHeight = nowIframeWidth * iframeRate; | ||
i.style.maxWidth = '100%'; | ||
i.style.height = newIframeHeight + 'px'; | ||
} | ||
} | ||
); | ||
} | ||
|
||
window.addEventListener( 'DOMContentLoaded', iframe_responsive ); | ||
let timer = false; | ||
window.addEventListener( 'resize', () => { | ||
if ( timer ) clearTimeout( timer ); | ||
timer = setTimeout( iframe_responsive, 200 ); | ||
} ); | ||
} )( window, document ); |
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 |
---|---|---|
@@ -0,0 +1,42 @@ | ||
const SelectSizeAll = document.querySelectorAll( '.vkpdc_select--size' ); | ||
// eslint-disable-next-line no-undef | ||
const SizeList = vkPatternsSizeSelect.sizeList; | ||
let WindowSize = document.body.clientWidth; | ||
const iframeContainer = document.querySelector( '.vkpdc_iframe-wrapper' ); | ||
|
||
function updateSizeOptionsAndIframe( selectSizeElement ) { | ||
const sizeOption = selectSizeElement.querySelectorAll( 'option' ); | ||
let selectFlag = false; | ||
|
||
SizeList.forEach( ( size ) => { | ||
sizeOption.forEach( ( option ) => { | ||
if ( size.value === option.value ) { | ||
if ( parseInt( size.value ) > WindowSize ) { | ||
option.style.display = 'none'; | ||
} else { | ||
option.style.display = 'block'; | ||
} | ||
} | ||
} ); | ||
} ); | ||
} | ||
|
||
SelectSizeAll.forEach( ( selectSize ) => { | ||
// 初期設定としてオプションとiframeの幅を更新 | ||
updateSizeOptionsAndIframe( selectSize ); | ||
|
||
// セレクトボックス変更時のイベントリスナー | ||
selectSize.onchange = () => { | ||
if ( selectSize.value === '100%' ) { | ||
iframeContainer.style.width = '100%'; | ||
} else { | ||
iframeContainer.style.width = (parseInt(selectSize.value) + 2) + 'px'; | ||
} | ||
}; | ||
}); | ||
|
||
// ウィンドウリサイズ時のイベントリスナー | ||
window.addEventListener( 'resize', () => { | ||
WindowSize = document.body.clientWidth; | ||
SelectSizeAll.forEach( updateSizeOptionsAndIframe ); | ||
} ); |
Oops, something went wrong.