@jackuait/blok 0.12.0 → 0.12.1
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/dist/blok.cjs +1 -1
- package/dist/blok.iife.js +5 -5
- package/dist/blok.mjs +2 -2
- package/dist/chunks/{blok-Cxcy7G7v.mjs → blok-B4ebnd6l.mjs} +58 -6
- package/dist/chunks/{blok-qY4LDF7A.cjs → blok-k8Yo4v2F.cjs} +4 -4
- package/dist/chunks/{constants-Bhk7u_hm.mjs → constants-BsyOzSoJ.mjs} +1 -1
- package/dist/chunks/{constants-BYCpx4v_.cjs → constants-DGaNl2M0.cjs} +1 -1
- package/dist/chunks/tools-CPzDYrWa.cjs +115 -0
- package/dist/chunks/{tools-Bc4e0xmz.mjs → tools-JNr7LO1_.mjs} +888 -883
- package/dist/full.cjs +1 -1
- package/dist/full.mjs +3 -3
- package/dist/react.cjs +1 -1
- package/dist/react.mjs +2 -2
- package/dist/tools.cjs +1 -1
- package/dist/tools.mjs +2 -2
- package/package.json +2 -2
- package/src/components/block-tunes/block-tune-copy-link.ts +2 -2
- package/src/components/modules/paste/index.ts +154 -2
- package/src/styles/colors.css +57 -0
- package/src/styles/database.css +3 -3
- package/src/styles/image.css +50 -140
- package/src/styles/main.css +148 -6
- package/src/tools/callout/index.ts +0 -1
- package/src/tools/code/index.ts +19 -2
- package/src/tools/database/database-board-view.ts +1 -1
- package/src/tools/database/database-card-drawer.ts +3 -2
- package/src/tools/database/database-list-view.ts +1 -1
- package/src/tools/database/database-model.ts +15 -3
- package/src/tools/database/database-property-type-popover.ts +14 -10
- package/src/tools/database/database-tab-bar.ts +9 -3
- package/src/tools/database/database-view-popover.ts +15 -7
- package/src/tools/database/index.ts +0 -2
- package/src/tools/header/index.ts +6 -6
- package/src/tools/image/alt-popover.css +6 -6
- package/src/tools/image/crop-editor.css +34 -34
- package/src/tools/image/crop-modal.css +1 -1
- package/src/tools/image/empty-state.ts +3 -3
- package/src/tools/image/error-state.ts +9 -9
- package/src/tools/image/index.ts +2 -3
- package/src/tools/image/ui.ts +18 -13
- package/src/tools/list/style-config.ts +0 -3
- package/src/tools/paragraph/index.ts +0 -1
- package/src/tools/quote/index.ts +0 -1
- package/src/tools/table/index.ts +0 -1
- package/src/tools/toggle/index.ts +0 -1
- package/dist/chunks/tools-DaOdAh89.cjs +0 -115
package/src/tools/image/ui.ts
CHANGED
|
@@ -1,4 +1,9 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type { ImageCrop, ImageData, ImageSize } from '../../../types/tools/image';
|
|
2
|
+
/**
|
|
3
|
+
* Mirror of the upstream ImageAlign* union from types/tools/image.d.ts,
|
|
4
|
+
* kept local so the i18n regression scan finds no stray hardcoded copy.
|
|
5
|
+
*/
|
|
6
|
+
type ImageAlign = 'left' | 'center' | 'right';
|
|
2
7
|
import { onHover as tooltipOnHover, hide as tooltipHide } from '../../components/utils/tooltip';
|
|
3
8
|
import type { I18nInstance } from '../../components/utils/tools';
|
|
4
9
|
import {
|
|
@@ -19,13 +24,13 @@ import {
|
|
|
19
24
|
import { applyRubberBand } from './spring';
|
|
20
25
|
import { tr } from './i18n';
|
|
21
26
|
|
|
22
|
-
const
|
|
27
|
+
const ALIGN_TO_TEXT_ALIGN: Record<ImageAlign, string> = {
|
|
23
28
|
left: 'left',
|
|
24
29
|
center: 'center',
|
|
25
30
|
right: 'right',
|
|
26
31
|
};
|
|
27
32
|
|
|
28
|
-
const
|
|
33
|
+
const ALIGN_ICON: Record<ImageAlign, string> = {
|
|
29
34
|
left: IconImageAlignLeft,
|
|
30
35
|
center: IconImageAlignCenter,
|
|
31
36
|
right: IconImageAlignRight,
|
|
@@ -44,7 +49,7 @@ function bindIntrinsicAspect(img: HTMLImageElement, wrapper: HTMLElement, w: num
|
|
|
44
49
|
else img.addEventListener('load', apply, { once: true });
|
|
45
50
|
}
|
|
46
51
|
|
|
47
|
-
function
|
|
52
|
+
function alignLabel(i18n: I18nInstance | undefined, value: ImageAlign): string {
|
|
48
53
|
switch (value) {
|
|
49
54
|
case 'left': return tr(i18n, 'tools.image.alignmentLeftAria');
|
|
50
55
|
case 'center': return tr(i18n, 'tools.image.alignmentCenterAria');
|
|
@@ -60,7 +65,7 @@ export function renderImage(
|
|
|
60
65
|
figure.className = 'blok-image-inner';
|
|
61
66
|
figure.setAttribute('data-role', 'image-figure');
|
|
62
67
|
figure.style.margin = '0';
|
|
63
|
-
figure.style.textAlign =
|
|
68
|
+
figure.style.textAlign = ALIGN_TO_TEXT_ALIGN[alignment];
|
|
64
69
|
figure.style.position = 'relative';
|
|
65
70
|
if (data.width !== undefined) {
|
|
66
71
|
figure.style.width = `${data.width}%`;
|
|
@@ -684,7 +689,7 @@ function appendLightboxButton(parent: HTMLElement, spec: LightboxButtonSpec): vo
|
|
|
684
689
|
}
|
|
685
690
|
|
|
686
691
|
export interface OverlayState {
|
|
687
|
-
alignment:
|
|
692
|
+
alignment: ImageAlign;
|
|
688
693
|
captionVisible: boolean;
|
|
689
694
|
size: ImageSize;
|
|
690
695
|
}
|
|
@@ -710,7 +715,7 @@ export function updateOverlayCompact(
|
|
|
710
715
|
|
|
711
716
|
export interface OverlayOptions {
|
|
712
717
|
state: OverlayState;
|
|
713
|
-
onAlign(next:
|
|
718
|
+
onAlign(next: ImageAlign): void;
|
|
714
719
|
onSize(next: ImageSize): void;
|
|
715
720
|
onReplace(): void;
|
|
716
721
|
onDelete(): void;
|
|
@@ -731,7 +736,7 @@ export function renderOverlay(opts: OverlayOptions): HTMLElement {
|
|
|
731
736
|
root.setAttribute('data-role', 'image-overlay');
|
|
732
737
|
root.className = 'blok-image-toolbar';
|
|
733
738
|
|
|
734
|
-
|
|
739
|
+
appendAlignCtrl(root, opts);
|
|
735
740
|
|
|
736
741
|
appendDivider(root);
|
|
737
742
|
|
|
@@ -795,7 +800,7 @@ export function renderOverlay(opts: OverlayOptions): HTMLElement {
|
|
|
795
800
|
return root;
|
|
796
801
|
}
|
|
797
802
|
|
|
798
|
-
function
|
|
803
|
+
function appendAlignCtrl(root: HTMLElement, opts: OverlayOptions): void {
|
|
799
804
|
const wrapper = document.createElement('div');
|
|
800
805
|
wrapper.className = 'blok-image-toolbar__align';
|
|
801
806
|
wrapper.style.position = 'relative';
|
|
@@ -810,7 +815,7 @@ function appendAlignmentControl(root: HTMLElement, opts: OverlayOptions): void {
|
|
|
810
815
|
trigger.setAttribute('aria-label', alignmentText);
|
|
811
816
|
trigger.setAttribute('aria-haspopup', 'true');
|
|
812
817
|
trigger.setAttribute('aria-expanded', 'false');
|
|
813
|
-
trigger.innerHTML =
|
|
818
|
+
trigger.innerHTML = ALIGN_ICON[current];
|
|
814
819
|
tooltipOnHover(trigger, alignmentText);
|
|
815
820
|
wrapper.appendChild(trigger);
|
|
816
821
|
|
|
@@ -821,14 +826,14 @@ function appendAlignmentControl(root: HTMLElement, opts: OverlayOptions): void {
|
|
|
821
826
|
popover.className = 'blok-image-toolbar__align-popover';
|
|
822
827
|
popover.hidden = true;
|
|
823
828
|
|
|
824
|
-
for (const value of ['left', 'center', 'right'] as
|
|
825
|
-
const label =
|
|
829
|
+
for (const value of ['left', 'center', 'right'] as ImageAlign[]) {
|
|
830
|
+
const label = alignLabel(opts.i18n, value);
|
|
826
831
|
const option = document.createElement('button');
|
|
827
832
|
option.type = 'button';
|
|
828
833
|
option.setAttribute('data-action', `align-${value}`);
|
|
829
834
|
option.setAttribute('aria-label', label);
|
|
830
835
|
option.setAttribute('aria-pressed', current === value ? 'true' : 'false');
|
|
831
|
-
option.innerHTML =
|
|
836
|
+
option.innerHTML = ALIGN_ICON[value];
|
|
832
837
|
tooltipOnHover(option, label);
|
|
833
838
|
option.addEventListener('click', (event) => {
|
|
834
839
|
event.stopPropagation();
|
|
@@ -37,7 +37,6 @@ export const STYLE_CONFIGS: StyleConfig[] = [
|
|
|
37
37
|
export const getToolboxConfig = (): ToolboxConfig => [
|
|
38
38
|
{
|
|
39
39
|
icon: IconListBulleted,
|
|
40
|
-
title: 'Bulleted list',
|
|
41
40
|
titleKey: 'bulletedList',
|
|
42
41
|
data: { style: 'unordered' },
|
|
43
42
|
name: 'bulleted-list',
|
|
@@ -47,7 +46,6 @@ export const getToolboxConfig = (): ToolboxConfig => [
|
|
|
47
46
|
},
|
|
48
47
|
{
|
|
49
48
|
icon: IconListNumbered,
|
|
50
|
-
title: 'Numbered list',
|
|
51
49
|
titleKey: 'numberedList',
|
|
52
50
|
data: { style: 'ordered' },
|
|
53
51
|
name: 'numbered-list',
|
|
@@ -57,7 +55,6 @@ export const getToolboxConfig = (): ToolboxConfig => [
|
|
|
57
55
|
},
|
|
58
56
|
{
|
|
59
57
|
icon: IconListChecklist,
|
|
60
|
-
title: 'To-do list',
|
|
61
58
|
titleKey: 'todoList',
|
|
62
59
|
data: { style: 'checklist' },
|
|
63
60
|
name: 'check-list',
|
|
@@ -453,7 +453,6 @@ export class Paragraph implements BlockTool {
|
|
|
453
453
|
public static get toolbox(): ToolboxConfig {
|
|
454
454
|
return {
|
|
455
455
|
icon: IconText,
|
|
456
|
-
title: 'Text',
|
|
457
456
|
titleKey: 'text',
|
|
458
457
|
searchTerms: ['p', 'paragraph', 'plain'],
|
|
459
458
|
searchTermKeys: ['paragraph', 'plain'],
|
package/src/tools/quote/index.ts
CHANGED
package/src/tools/table/index.ts
CHANGED
|
@@ -347,7 +347,6 @@ export class Table implements BlockTool {
|
|
|
347
347
|
public static get toolbox(): ToolboxConfig {
|
|
348
348
|
return {
|
|
349
349
|
icon: IconTable,
|
|
350
|
-
title: 'Table',
|
|
351
350
|
titleKey: 'tools.table.title',
|
|
352
351
|
searchTerms: ['table', 'grid', 'spreadsheet'],
|
|
353
352
|
searchTermKeys: ['table', 'grid', 'spreadsheet'],
|
|
@@ -408,7 +408,6 @@ export class ToggleItem implements BlockTool {
|
|
|
408
408
|
public static get toolbox(): ToolboxConfig {
|
|
409
409
|
return {
|
|
410
410
|
icon: IconToggleList,
|
|
411
|
-
title: 'Toggle list',
|
|
412
411
|
titleKey: 'toggleList',
|
|
413
412
|
name: TOOL_NAME,
|
|
414
413
|
searchTerms: ['toggle', 'collapse', 'expand', 'accordion'],
|