Skip to content

Commit

Permalink
Fix: lint
Browse files Browse the repository at this point in the history
  • Loading branch information
mtdkei authored and mtdkei committed Feb 19, 2025
1 parent 52fac79 commit a69219c
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 7 deletions.
13 changes: 10 additions & 3 deletions src/blocks/_pro/post-list/edit.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,9 @@ export default function PostListEdit(props) {
// リンクを無効にする関数
const disableLinks = () => {
// iframe の有無を確認して適切なドキュメントを取得
const iframe = document.querySelector('.block-editor-iframe__container iframe');
const iframe = document.querySelector(
'.block-editor-iframe__container iframe'
);
const targetDocument = iframe?.contentWindow?.document || document;

const links = targetDocument.querySelectorAll(
Expand All @@ -39,13 +41,18 @@ export default function PostListEdit(props) {

useEffect(() => {
// MutationObserverでDOMの変化を監視
const iframe = document.querySelector('.block-editor-iframe__container iframe');
const iframe = document.querySelector(
'.block-editor-iframe__container iframe'
);
const targetDocument = iframe?.contentWindow?.document || document;
const observerTarget = targetDocument.querySelector('body');

const observer = new MutationObserver(disableLinks);
if (observerTarget) {
observer.observe(observerTarget, { childList: true, subtree: true });
observer.observe(observerTarget, {
childList: true,
subtree: true,
});
}

// 初回およびattributesの変更時にリンクを無効化
Expand Down
15 changes: 11 additions & 4 deletions src/blocks/slider/edit-slider.js
Original file line number Diff line number Diff line change
Expand Up @@ -309,12 +309,19 @@ const editorRootLaunch = (editorRoot) => {
export const editSliderLaunch = () => {
const iframe = document.querySelector('.block-editor__container iframe');
const iframeDoc = iframe?.contentWindow?.document;
const editorRoot = iframeDoc?.querySelector('.block-editor-block-list__layout') || document.querySelector('.block-editor-block-list__layout');
const editorRoot =
iframeDoc?.querySelector('.block-editor-block-list__layout') ||
document.querySelector('.block-editor-block-list__layout');

if (editorRoot) editorRootLaunch(editorRoot);
if (editorRoot) {
editorRootLaunch(editorRoot);
}

const siteIframe = document.querySelector('#site-editor iframe');
const siteEditorRoot = siteIframe?.contentWindow?.document.querySelector('.is-root-container');
const siteEditorRoot =
siteIframe?.contentWindow?.document.querySelector('.is-root-container');

if (siteEditorRoot) editorRootLaunch(siteEditorRoot);
if (siteEditorRoot) {
editorRootLaunch(siteEditorRoot);
}
};

0 comments on commit a69219c

Please sign in to comment.