mirror of
https://github.com/codex-team/codex.docs.git
synced 2025-07-19 05:09:41 +02:00
.
This commit is contained in:
parent
680bcde28c
commit
b3cf013b84
3 changed files with 60 additions and 32 deletions
|
@ -1,11 +1,7 @@
|
||||||
{% set alignment = alignment|default('center') %}
|
{% set alignment = alignment|default('center') %}
|
||||||
{% set filetype = filetype|default('file') %}
|
{% set filetype = filetype|default('file') %}
|
||||||
|
|
||||||
<figure class="block-video" style="margin:
|
<figure class="block-video">
|
||||||
{% if alignment == 'left' %}0 auto 0 0
|
|
||||||
{% elseif alignment == 'right' %}0 0 0 auto
|
|
||||||
{% else %}0 auto
|
|
||||||
{% endif %};">
|
|
||||||
<div class="{{ classes.join(' ') }}">
|
<div class="{{ classes.join(' ') }}">
|
||||||
{% if filetype == 'youtube' or filetype == 'rutube' %}
|
{% if filetype == 'youtube' or filetype == 'rutube' %}
|
||||||
<iframe
|
<iframe
|
||||||
|
@ -26,4 +22,4 @@
|
||||||
{{ caption|raw }}
|
{{ caption|raw }}
|
||||||
</footer>
|
</footer>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
</figure>
|
</figure>
|
||||||
|
|
|
@ -3,6 +3,7 @@ export default class VideoTool {
|
||||||
return {
|
return {
|
||||||
icon: `<svg width="20" height="20" viewBox="0 0 20 20" fill="none"><path d="M16.25 3.75H3.75C2.36929 3.75 1.25 4.86929 1.25 6.25V13.75C1.25 15.1307 2.36929 16.25 3.75 16.25H16.25C17.6307 16.25 18.75 15.1307 18.75 13.75V6.25C18.75 4.86929 17.6307 3.75 16.25 3.75Z" stroke="currentColor" stroke-width="1.5"/><path d="M8.125 6.875L13.125 10L8.125 13.125V6.875Z" fill="currentColor"/></svg>`,
|
icon: `<svg width="20" height="20" viewBox="0 0 20 20" fill="none"><path d="M16.25 3.75H3.75C2.36929 3.75 1.25 4.86929 1.25 6.25V13.75C1.25 15.1307 2.36929 16.25 3.75 16.25H16.25C17.6307 16.25 18.75 15.1307 18.75 13.75V6.25C18.75 4.86929 17.6307 3.75 16.25 3.75Z" stroke="currentColor" stroke-width="1.5"/><path d="M8.125 6.875L13.125 10L8.125 13.125V6.875Z" fill="currentColor"/></svg>`,
|
||||||
title: 'Video',
|
title: 'Video',
|
||||||
|
name: 'video', // Diagnostic: Add name property
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -14,6 +15,8 @@ export default class VideoTool {
|
||||||
this.wrapper = null;
|
this.wrapper = null;
|
||||||
this.alignment = data.alignment || 'center';
|
this.alignment = data.alignment || 'center';
|
||||||
this.filetype = data.filetype || 'file';
|
this.filetype = data.filetype || 'file';
|
||||||
|
|
||||||
|
this.name = 'video'; // Diagnostic: Add name property to instance
|
||||||
|
|
||||||
this._handleFileUpload = this._handleFileUpload.bind(this);
|
this._handleFileUpload = this._handleFileUpload.bind(this);
|
||||||
this._handleUrlSubmit = this._handleUrlSubmit.bind(this);
|
this._handleUrlSubmit = this._handleUrlSubmit.bind(this);
|
||||||
|
@ -140,9 +143,6 @@ export default class VideoTool {
|
||||||
};
|
};
|
||||||
|
|
||||||
this.api.blocks.update(this.block.id, this.data);
|
this.api.blocks.update(this.block.id, this.data);
|
||||||
|
|
||||||
this.wrapper.innerHTML = '';
|
|
||||||
this._createVideoElement(embedUrl, '');
|
|
||||||
|
|
||||||
submitBtn.disabled = false;
|
submitBtn.disabled = false;
|
||||||
submitBtn.textContent = ' ';
|
submitBtn.textContent = ' ';
|
||||||
|
@ -185,6 +185,10 @@ export default class VideoTool {
|
||||||
const container = document.createElement('div');
|
const container = document.createElement('div');
|
||||||
container.className = 'video-container';
|
container.className = 'video-container';
|
||||||
container.style.margin = this._getAlignmentMargin();
|
container.style.margin = this._getAlignmentMargin();
|
||||||
|
container.style.position = 'relative';
|
||||||
|
container.style.paddingBottom = '56.25%'; // 16:9 aspect ratio
|
||||||
|
container.style.height = '0';
|
||||||
|
container.style.overflow = 'hidden';
|
||||||
|
|
||||||
const type = filetype || this.filetype ||
|
const type = filetype || this.filetype ||
|
||||||
(url.match(/\.(mp4|webm|ogg)$/i) ? 'file' :
|
(url.match(/\.(mp4|webm|ogg)$/i) ? 'file' :
|
||||||
|
@ -192,10 +196,11 @@ export default class VideoTool {
|
||||||
(url.includes('rutube.ru/embed') || url.includes('rutube.ru/video') ? 'rutube' : 'file')));
|
(url.includes('rutube.ru/embed') || url.includes('rutube.ru/video') ? 'rutube' : 'file')));
|
||||||
|
|
||||||
const mediaContainer = document.createElement('div');
|
const mediaContainer = document.createElement('div');
|
||||||
mediaContainer.style.position = 'relative';
|
mediaContainer.style.position = 'absolute';
|
||||||
mediaContainer.style.paddingBottom = '56.25%';
|
mediaContainer.style.top = '0';
|
||||||
mediaContainer.style.height = '0';
|
mediaContainer.style.left = '0';
|
||||||
mediaContainer.style.overflow = 'hidden';
|
mediaContainer.style.width = '100%';
|
||||||
|
mediaContainer.style.height = '100%';
|
||||||
|
|
||||||
if (type === 'file') {
|
if (type === 'file') {
|
||||||
const video = document.createElement('video');
|
const video = document.createElement('video');
|
||||||
|
@ -206,6 +211,7 @@ export default class VideoTool {
|
||||||
video.style.left = '0';
|
video.style.left = '0';
|
||||||
video.style.width = '100%';
|
video.style.width = '100%';
|
||||||
video.style.height = '100%';
|
video.style.height = '100%';
|
||||||
|
video.style.verticalAlign = 'top'; // Добавляем vertical-align
|
||||||
mediaContainer.appendChild(video);
|
mediaContainer.appendChild(video);
|
||||||
} else {
|
} else {
|
||||||
const iframe = document.createElement('iframe');
|
const iframe = document.createElement('iframe');
|
||||||
|
@ -219,6 +225,7 @@ export default class VideoTool {
|
||||||
iframe.style.left = '0';
|
iframe.style.left = '0';
|
||||||
iframe.style.width = '100%';
|
iframe.style.width = '100%';
|
||||||
iframe.style.height = '100%';
|
iframe.style.height = '100%';
|
||||||
|
iframe.style.verticalAlign = 'top'; // Добавляем vertical-align
|
||||||
mediaContainer.appendChild(iframe);
|
mediaContainer.appendChild(iframe);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -307,4 +314,4 @@ export default class VideoTool {
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -123,7 +123,7 @@
|
||||||
display: none;
|
display: none;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Палитра цветов */
|
/* ĐаНиŃŃа ŃвоŃОв */
|
||||||
.color-palette {
|
.color-palette {
|
||||||
background: white;
|
background: white;
|
||||||
border: 1px solid #eaeaea;
|
border: 1px solid #eaeaea;
|
||||||
|
@ -202,7 +202,7 @@
|
||||||
background: rgba(0,0,0,0.1);
|
background: rgba(0,0,0,0.1);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Активная кнопка в тулбаре */
|
/* ĐĐşŃĐ¸Đ˛Đ˝Đ°Ń ĐşĐ˝ĐžĐżĐşĐ° в ŃŃНйаŃĐľ */
|
||||||
.ce-inline-tool--active svg {
|
.ce-inline-tool--active svg {
|
||||||
filter: drop-shadow(0 0 3px rgba(0, 0, 0, 0.3));
|
filter: drop-shadow(0 0 3px rgba(0, 0, 0, 0.3));
|
||||||
}
|
}
|
||||||
|
@ -211,13 +211,13 @@
|
||||||
transition: fill 0.2s ease;
|
transition: fill 0.2s ease;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Стили для палитры размеров */
|
/* ĐĄŃиНи Đ´ĐťŃ ĐżĐ°ĐťĐ¸ŃŃŃ ŃаСПоŃОв */
|
||||||
.size-palette {
|
.size-palette {
|
||||||
background: white;
|
background: white;
|
||||||
border: 1px solid #eaeaea;
|
border: 1px solid #eaeaea;
|
||||||
border-radius: 6px;
|
border-radius: 6px;
|
||||||
padding: 6px;
|
padding: 6px;
|
||||||
width: 90px; /* Уменьшенная ширина */
|
width: 90px; /* УПонŃŃĐľĐ˝Đ˝Đ°Ń ŃиŃина */
|
||||||
max-height: 132px;
|
max-height: 132px;
|
||||||
z-index: 1000;
|
z-index: 1000;
|
||||||
box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
|
box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
|
||||||
|
@ -229,7 +229,7 @@
|
||||||
.size-palette-container {
|
.size-palette-container {
|
||||||
display: flex;
|
display: flex;
|
||||||
flex-direction: column;
|
flex-direction: column;
|
||||||
gap: 4px; /* Уменьшенный gap */
|
gap: 4px; /* УПонŃŃоннŃĐš gap */
|
||||||
}
|
}
|
||||||
|
|
||||||
.size-input-wrapper {
|
.size-input-wrapper {
|
||||||
|
@ -245,7 +245,7 @@
|
||||||
border-radius: 4px;
|
border-radius: 4px;
|
||||||
font-size: 12px;
|
font-size: 12px;
|
||||||
min-width: 0;
|
min-width: 0;
|
||||||
width: 40px; /* Фиксированная ширина поля ввода */
|
width: 40px; /* ФикŃиŃĐžĐ˛Đ°Đ˝Đ˝Đ°Ń ŃиŃина ĐżĐžĐťŃ Đ˛Đ˛ĐžĐ´Đ° */
|
||||||
}
|
}
|
||||||
|
|
||||||
.size-apply-btn {
|
.size-apply-btn {
|
||||||
|
@ -266,7 +266,7 @@
|
||||||
overflow-y: auto;
|
overflow-y: auto;
|
||||||
display: flex;
|
display: flex;
|
||||||
flex-direction: column;
|
flex-direction: column;
|
||||||
gap: 2px; /* Минимальный gap между элементами */
|
gap: 2px; /* ĐиниПаНŃĐ˝ŃĐš gap ĐźĐľĐśĐ´Ń ŃНоПонŃаПи */
|
||||||
}
|
}
|
||||||
|
|
||||||
.size-palette-item {
|
.size-palette-item {
|
||||||
|
@ -285,14 +285,14 @@
|
||||||
background: #f5f5f5;
|
background: #f5f5f5;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Кнопка в тулбаре */
|
/* ĐнОпка в ŃŃНйаŃĐľ */
|
||||||
.ce-inline-tool .size-label {
|
.ce-inline-tool .size-label {
|
||||||
margin-left: 4px;
|
margin-left: 4px;
|
||||||
font-size: 12px;
|
font-size: 12px;
|
||||||
color: #666;
|
color: #666;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Иконка в тулбаре */
|
/* ĐкОнка в ŃŃНйаŃĐľ */
|
||||||
.ce-inline-tool svg text {
|
.ce-inline-tool svg text {
|
||||||
font-family: Arial, sans-serif;
|
font-family: Arial, sans-serif;
|
||||||
font-weight: bold;
|
font-weight: bold;
|
||||||
|
@ -320,9 +320,25 @@
|
||||||
.retry-button:hover {
|
.retry-button:hover {
|
||||||
background: #0d8aee;
|
background: #0d8aee;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.video-upload-button {
|
||||||
|
display: block;
|
||||||
|
padding: 10px 15px;
|
||||||
|
border: 1px solid #ddd;
|
||||||
|
border-radius: 4px;
|
||||||
|
background-color: #f9f9f9;
|
||||||
|
cursor: pointer;
|
||||||
|
text-align: center;
|
||||||
|
font-size: 14px;
|
||||||
|
color: #333;
|
||||||
|
}
|
||||||
|
|
||||||
|
.video-upload-button input[type="file"] {
|
||||||
|
display: none; /* Hide the actual file input */
|
||||||
|
}
|
||||||
|
|
||||||
.video-tool {
|
.video-tool {
|
||||||
position: relative;
|
position: relative;
|
||||||
margin: 1rem 0;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
.video-tool__container {
|
.video-tool__container {
|
||||||
|
@ -338,7 +354,7 @@
|
||||||
height: auto;
|
height: auto;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Ручки ресайза */
|
/* Đ ŃŃки ŃĐľŃаКСа */
|
||||||
.resize-handle {
|
.resize-handle {
|
||||||
position: absolute;
|
position: absolute;
|
||||||
right: 0;
|
right: 0;
|
||||||
|
@ -360,8 +376,6 @@
|
||||||
.cdx-image {
|
.cdx-image {
|
||||||
position: relative;
|
position: relative;
|
||||||
display: block;
|
display: block;
|
||||||
width: fit-content;
|
|
||||||
margin: 1rem auto;
|
|
||||||
max-width: 100%;
|
max-width: 100%;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -382,7 +396,7 @@
|
||||||
|
|
||||||
.block-video > div {
|
.block-video > div {
|
||||||
position: relative;
|
position: relative;
|
||||||
padding-bottom: 56.25%; /* 16:9 <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> */
|
padding-bottom: 56.25%; /* 16:9 ńîîňíîřĺíčĺ */
|
||||||
height: 0;
|
height: 0;
|
||||||
overflow: hidden;
|
overflow: hidden;
|
||||||
background: #000;
|
background: #000;
|
||||||
|
@ -422,12 +436,12 @@
|
||||||
line-height: 1.4;
|
line-height: 1.4;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Общие стили для выравнивания */
|
/* ĐĐąŃио ŃŃиНи Đ´ĐťŃ Đ˛ŃŃĐ°Đ˛Đ˝Đ¸Đ˛Đ°Đ˝Đ¸Ń */
|
||||||
.block-image, .block-video {
|
.block-image, .block-video {
|
||||||
clear: both;
|
clear: both;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Стили для кнопок выравнивания */
|
/* ĐĄŃиНи Đ´ĐťŃ ĐşĐ˝ĐžĐżĐžĐş вŃŃĐ°Đ˛Đ˝Đ¸Đ˛Đ°Đ˝Đ¸Ń */
|
||||||
.image-alignment-controls,
|
.image-alignment-controls,
|
||||||
.video-alignment-controls {
|
.video-alignment-controls {
|
||||||
position: absolute;
|
position: absolute;
|
||||||
|
@ -481,7 +495,7 @@
|
||||||
opacity: 1;
|
opacity: 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Элементы управления выравниванием */
|
/* ĐНоПонŃŃ ŃĐżŃĐ°Đ˛ĐťĐľĐ˝Đ¸Ń Đ˛ŃŃавниваниоП */
|
||||||
.alignment-controls {
|
.alignment-controls {
|
||||||
position: absolute;
|
position: absolute;
|
||||||
top: 5px;
|
top: 5px;
|
||||||
|
@ -565,4 +579,15 @@
|
||||||
.video-container video {
|
.video-container video {
|
||||||
display: block;
|
display: block;
|
||||||
margin: 0 auto;
|
margin: 0 auto;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* Переопределение стилей Editor.js для видеоблока */
|
||||||
|
.video-tool .ce-block,
|
||||||
|
.video-tool .ce-block__content {
|
||||||
|
padding-top: 0 !important;
|
||||||
|
margin-top: 0 !important;
|
||||||
|
}
|
||||||
|
|
||||||
|
.video-tool.cdx-block {
|
||||||
|
padding-top: 0 !important;
|
||||||
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue