@growgroup/visual-editor 0.7.0 → 0.7.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +1 -1
- package/src/editor/FrontendVisualEditor.tsx +1 -1
- package/src/editor/components/EditorCanvas.tsx +2 -6
- package/src/editor/components/EditorHeader.tsx +1 -4
- package/src/editor/hooks/useIframeInitializer.ts +1 -5
- package/src/editor/hooks/useKeepArtboardInPlace.ts +3 -2
- package/src/editor/hooks/useMediaLibrary.ts +1 -1
- package/src/version.ts +1 -1
package/package.json
CHANGED
|
@@ -726,7 +726,7 @@ function FrontendVisualEditorInner({
|
|
|
726
726
|
async (item: MediaItem) => {
|
|
727
727
|
setIsMediaLibraryOpen(false);
|
|
728
728
|
|
|
729
|
-
//
|
|
729
|
+
// 埋め込みiframeでも同じ素材を参照できるよう絶対URLへ(保存時に相対へ戻る)
|
|
730
730
|
const src = toEditorMediaUrl(item.url);
|
|
731
731
|
|
|
732
732
|
if (isImageSelected) {
|
|
@@ -978,7 +978,7 @@ export function EditorCanvas() {
|
|
|
978
978
|
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
979
979
|
}, []);
|
|
980
980
|
|
|
981
|
-
//
|
|
981
|
+
// 本文をsrcdocで渡す。Blob URLを解決できない埋め込みブラウザでも読み込める。
|
|
982
982
|
// 依存に iframeHtml(=originalHtml由来)を含めることで、ページ切替(サムネイル/URL)で
|
|
983
983
|
// コンテンツが差し替わったときに**iframeだけ**を作り直す。殻(ヘッダー・パネル・
|
|
984
984
|
// サムネイル)は残るので、切替のたびに画面全体がリロードされたようには見えない
|
|
@@ -993,14 +993,10 @@ export function EditorCanvas() {
|
|
|
993
993
|
// マルチフレームのキャンバスはこれを見て、前のページの姿が新しい枠に
|
|
994
994
|
// 見えないようエディタを隠す(読み込みが済むまで見るだけの紙面が透ける)
|
|
995
995
|
setIframeReady(false);
|
|
996
|
-
|
|
997
|
-
iframe.src = URL.createObjectURL(blob);
|
|
996
|
+
iframe.srcdoc = iframeHtml;
|
|
998
997
|
|
|
999
998
|
return () => {
|
|
1000
999
|
iframe.removeEventListener("load", handleIframeLoad);
|
|
1001
|
-
if (iframe.src.startsWith("blob:")) {
|
|
1002
|
-
URL.revokeObjectURL(iframe.src);
|
|
1003
|
-
}
|
|
1004
1000
|
|
|
1005
1001
|
// 重要: アンマウント時にすべてのイベントリスナーをクリーンアップ
|
|
1006
1002
|
// これにより、メモリリークとゴーストリスナーを防ぐ
|
|
@@ -138,10 +138,7 @@ export function EditorHeader({
|
|
|
138
138
|
const handleReset = () => {
|
|
139
139
|
const iframe = iframeRef.current;
|
|
140
140
|
if (iframe) {
|
|
141
|
-
|
|
142
|
-
type: "text/html",
|
|
143
|
-
});
|
|
144
|
-
iframe.src = URL.createObjectURL(blob);
|
|
141
|
+
iframe.srcdoc = generateEditableHtml(originalHtml, editorMode);
|
|
145
142
|
}
|
|
146
143
|
setHtml(originalHtml);
|
|
147
144
|
setSelectedElement(null);
|
|
@@ -525,14 +525,10 @@ export function useIframeInitializer() {
|
|
|
525
525
|
|
|
526
526
|
iframe.addEventListener('load', handleLoad);
|
|
527
527
|
|
|
528
|
-
|
|
529
|
-
iframe.src = URL.createObjectURL(blob);
|
|
528
|
+
iframe.srcdoc = generateEditableHtml(html, editorMode);
|
|
530
529
|
|
|
531
530
|
return () => {
|
|
532
531
|
iframe.removeEventListener('load', handleLoad);
|
|
533
|
-
if (iframe.src.startsWith('blob:')) {
|
|
534
|
-
URL.revokeObjectURL(iframe.src);
|
|
535
|
-
}
|
|
536
532
|
};
|
|
537
533
|
}, []);
|
|
538
534
|
|
|
@@ -62,7 +62,7 @@ export function useKeepArtboardInPlace(
|
|
|
62
62
|
}
|
|
63
63
|
lastRef.current = {
|
|
64
64
|
left,
|
|
65
|
-
viewportWidth: doc?.documentElement
|
|
65
|
+
viewportWidth: doc?.documentElement?.clientWidth ?? 0,
|
|
66
66
|
scrollLeft: scroller?.scrollLeft ?? 0,
|
|
67
67
|
};
|
|
68
68
|
});
|
|
@@ -78,7 +78,8 @@ export function useKeepArtboardInPlace(
|
|
|
78
78
|
if (!doc || !scroller) return;
|
|
79
79
|
const remember = () => {
|
|
80
80
|
const last = lastRef.current;
|
|
81
|
-
|
|
81
|
+
// ページを移る途中は文書が差し替わり、documentElement が無いことがある(⌘ クリックのリンク移動で実測)
|
|
82
|
+
if (last && doc.documentElement && doc.documentElement.clientWidth === last.viewportWidth) last.scrollLeft = scroller.scrollLeft;
|
|
82
83
|
};
|
|
83
84
|
remember();
|
|
84
85
|
scroller.addEventListener('scroll', remember, { passive: true });
|
|
@@ -59,7 +59,7 @@ async function fetchMediaItems(): Promise<MediaItem[]> {
|
|
|
59
59
|
/**
|
|
60
60
|
* カタログのURL(`/media/...`)をエディタのiframeで解決できる形へ変換する。
|
|
61
61
|
*
|
|
62
|
-
*
|
|
62
|
+
* エディタのキャンバスは埋め込みiframe。実行時のbaseに依存させず、元のページと同じ素材を参照する。
|
|
63
63
|
* `src/lib/slide-html.ts` の toEditorUrls / fromEditorUrls と同じ規約に合わせ、
|
|
64
64
|
* 挿入時は絶対URLにしておく(保存時に fromEditorUrls が相対へ戻す)。
|
|
65
65
|
*/
|
package/src/version.ts
CHANGED