uncial 2.0.3 → 4.0.0

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.
Files changed (51) hide show
  1. package/README.md +6 -1
  2. package/dist/core/defineBlock.js +5 -2
  3. package/dist/core/index.d.ts +2 -2
  4. package/dist/core/index.js +1 -1
  5. package/dist/core/registry.d.ts +8 -1
  6. package/dist/core/registry.js +27 -0
  7. package/dist/core/types.d.ts +21 -1
  8. package/dist/editor/AttributeFieldControl.svelte +127 -3
  9. package/dist/editor/AttributeFieldControl.svelte.d.ts +4 -0
  10. package/dist/editor/BlockAttributesPanel.svelte +12 -3
  11. package/dist/editor/BlockAttributesPanel.svelte.d.ts +5 -0
  12. package/dist/editor/BlockNodeView.svelte +2 -1
  13. package/dist/editor/DocumentMetaPanel.svelte +5 -1
  14. package/dist/editor/Editor.svelte +20 -8
  15. package/dist/editor/Editor.svelte.d.ts +3 -0
  16. package/dist/editor/ImagePicker.svelte +85 -0
  17. package/dist/editor/ImagePicker.svelte.d.ts +13 -0
  18. package/dist/editor/bindEditor.d.ts +3 -0
  19. package/dist/editor/bindEditor.js +1 -1
  20. package/dist/editor/imageSource.d.ts +12 -0
  21. package/dist/editor/imageSource.js +1 -0
  22. package/dist/editor/index.d.ts +1 -0
  23. package/dist/editor/metaController.js +0 -5
  24. package/dist/render/Renderer.svelte +12 -2
  25. package/dist/render/Renderer.svelte.d.ts +2 -1
  26. package/dist/render/RichContent.svelte +4 -2
  27. package/dist/render/RichContent.svelte.d.ts +2 -1
  28. package/dist/render/RichNode.svelte +36 -17
  29. package/dist/render/RichNode.svelte.d.ts +2 -1
  30. package/dist/render/SuperscriptMarkFixture.svelte +7 -0
  31. package/dist/render/SuperscriptMarkFixture.svelte.d.ts +4 -0
  32. package/dist/render/Tabs.svelte +1 -1
  33. package/dist/render/index.d.ts +1 -0
  34. package/dist/render/index.js +1 -0
  35. package/dist/render/resolveImageSrc.d.ts +6 -0
  36. package/dist/render/resolveImageSrc.js +10 -0
  37. package/dist/render/tabSelection.svelte.js +2 -0
  38. package/dist/shared/ImageBlockFixture.svelte +29 -0
  39. package/dist/shared/ImageBlockFixture.svelte.d.ts +11 -0
  40. package/dist/shared/imagePreviews.d.ts +21 -0
  41. package/dist/shared/imagePreviews.js +59 -0
  42. package/dist/shared/tiptap.d.ts +2 -1
  43. package/dist/shared/tiptap.js +16 -13
  44. package/dist/styles/base.css +89 -9
  45. package/dist/ui/ThemeSwitcher.svelte +1 -1
  46. package/dist/ui/theme.svelte.js +1 -1
  47. package/dist/web-components/UncialEditor.svelte +4 -0
  48. package/dist/web-components/UncialEditor.svelte.d.ts +2 -1
  49. package/dist/web-components/index.d.ts +4 -1
  50. package/dist/web-components/index.js +6 -0
  51. package/package.json +3 -3
@@ -396,6 +396,25 @@
396
396
  gap: var(--uncial-space-2);
397
397
  }
398
398
 
399
+ .uncial-image-field {
400
+ display: grid;
401
+ gap: var(--uncial-space-2);
402
+ }
403
+
404
+ .uncial-image-field__thumbnail {
405
+ max-width: 100%;
406
+ max-height: 8rem;
407
+ object-fit: contain;
408
+ justify-self: start;
409
+ border: 1px solid var(--uncial-color-border);
410
+ border-radius: var(--uncial-radius-lg);
411
+ }
412
+
413
+ .uncial-image-field__actions {
414
+ display: flex;
415
+ gap: var(--uncial-space-2);
416
+ }
417
+
399
418
  .uncial-list-item {
400
419
  border: 1px solid var(--uncial-color-border);
401
420
  border-radius: var(--uncial-radius-lg);
@@ -471,16 +490,18 @@
471
490
  -1 *
472
491
  (
473
492
  max(
474
- var(--uncial-gutter-width-sm),
475
- var(--uncial-reserved-gutter-width, var(--uncial-gutter-width-sm))
476
- ) - 0.5rem
493
+ var(--uncial-gutter-width-sm),
494
+ var(--uncial-reserved-gutter-width, var(--uncial-gutter-width-sm))
495
+ ) -
496
+ 0.5rem
477
497
  )
478
498
  );
479
499
  width: calc(
480
500
  max(
481
- var(--uncial-gutter-width-sm),
482
- var(--uncial-reserved-gutter-width, var(--uncial-gutter-width-sm))
483
- ) - 1rem
501
+ var(--uncial-gutter-width-sm),
502
+ var(--uncial-reserved-gutter-width, var(--uncial-gutter-width-sm))
503
+ ) -
504
+ 1rem
484
505
  );
485
506
  }
486
507
 
@@ -488,9 +509,10 @@
488
509
  font-size: 0.5rem;
489
510
  max-width: calc(
490
511
  max(
491
- var(--uncial-gutter-width-sm),
492
- var(--uncial-reserved-gutter-width, var(--uncial-gutter-width-sm))
493
- ) - 1rem
512
+ var(--uncial-gutter-width-sm),
513
+ var(--uncial-reserved-gutter-width, var(--uncial-gutter-width-sm))
514
+ ) -
515
+ 1rem
494
516
  );
495
517
  }
496
518
 
@@ -600,3 +622,61 @@
600
622
  border-top: 1px solid var(--uncial-color-border);
601
623
  }
602
624
  }
625
+
626
+ .uncial-image-picker {
627
+ width: min(40rem, calc(100vw - 2rem));
628
+ max-height: calc(100vh - 4rem);
629
+ padding: var(--uncial-space-4);
630
+ border: 1px solid var(--uncial-color-border);
631
+ border-radius: var(--uncial-radius-lg);
632
+ background: var(--uncial-color-surface);
633
+ color: var(--uncial-color-text);
634
+ box-shadow: var(--uncial-shadow-md);
635
+ }
636
+
637
+ .uncial-image-picker::backdrop {
638
+ background: color-mix(in srgb, black 40%, transparent);
639
+ }
640
+
641
+ .uncial-image-picker__head {
642
+ display: flex;
643
+ align-items: center;
644
+ justify-content: space-between;
645
+ margin-bottom: var(--uncial-space-3);
646
+ }
647
+
648
+ .uncial-image-picker__head h2 {
649
+ margin: 0;
650
+ }
651
+
652
+ .uncial-image-picker__grid {
653
+ display: grid;
654
+ grid-template-columns: repeat(auto-fill, minmax(7rem, 1fr));
655
+ gap: var(--uncial-space-2);
656
+ }
657
+
658
+ .uncial-image-picker__tile {
659
+ aspect-ratio: 1;
660
+ padding: 0;
661
+ overflow: hidden;
662
+ border: 1px solid var(--uncial-color-border);
663
+ border-radius: var(--uncial-radius-md);
664
+ background: var(--uncial-color-surface-elevated);
665
+ cursor: pointer;
666
+ }
667
+
668
+ .uncial-image-picker__tile:focus-visible {
669
+ outline: 2px solid var(--uncial-color-focus-ring);
670
+ outline-offset: 2px;
671
+ }
672
+
673
+ .uncial-image-picker__tile[aria-pressed='true'] {
674
+ border-color: var(--uncial-color-primary);
675
+ box-shadow: 0 0 0 2px var(--uncial-color-primary);
676
+ }
677
+
678
+ .uncial-image-picker__tile img {
679
+ width: 100%;
680
+ height: 100%;
681
+ object-fit: cover;
682
+ }
@@ -11,7 +11,7 @@
11
11
  const labels: Record<typeof theme.mode, string> = {
12
12
  system: 'System theme (auto)',
13
13
  light: 'Light theme',
14
- dark: 'Dark theme',
14
+ dark: 'Dark theme'
15
15
  };
16
16
  </script>
17
17
 
@@ -50,7 +50,7 @@ function createThemeState() {
50
50
  },
51
51
  apply,
52
52
  cycle,
53
- init,
53
+ init
54
54
  };
55
55
  }
56
56
  export const theme = createThemeState();
@@ -3,6 +3,7 @@
3
3
  import Editor from '../editor/Editor.svelte';
4
4
  import type {
5
5
  BlockAttributesController,
6
+ ImageSource,
6
7
  ToolbarFeature,
7
8
  ToolbarFeatureSelection
8
9
  } from '../editor/index.js';
@@ -28,6 +29,7 @@
28
29
  attributesController?: BlockAttributesController | null;
29
30
  attributesPanel?: boolean | 'docked' | 'overlay' | 'off';
30
31
  presentation?: 'card' | 'bare';
32
+ imageSource?: ImageSource;
31
33
  onIssue?: (issue: ValidationIssue) => void;
32
34
  onChange?: (document: JSONContent) => void;
33
35
  onMetaChange?: (meta: Record<string, unknown>) => void;
@@ -45,6 +47,7 @@
45
47
  attributesController = null,
46
48
  attributesPanel = true,
47
49
  presentation = 'card',
50
+ imageSource,
48
51
  onIssue,
49
52
  onChange,
50
53
  onMetaChange
@@ -70,6 +73,7 @@
70
73
  {attributesController}
71
74
  {attributesPanel}
72
75
  {presentation}
76
+ {imageSource}
73
77
  onIssue={dispatchIssue}
74
78
  {onChange}
75
79
  {onMetaChange}
@@ -1,5 +1,5 @@
1
1
  import type { AnyExtension, JSONContent } from '@tiptap/core';
2
- import type { BlockAttributesController, ToolbarFeature, ToolbarFeatureSelection } from '../editor/index.js';
2
+ import type { BlockAttributesController, ImageSource, ToolbarFeature, ToolbarFeatureSelection } from '../editor/index.js';
3
3
  import type { AttributeSpec, BlockDefinition, BlockRegistry, ContentSchema, DocumentMetaSchema, ValidationIssue } from '../core/types.js';
4
4
  interface Props {
5
5
  blocks?: BlockRegistry | BlockDefinition[];
@@ -13,6 +13,7 @@ interface Props {
13
13
  attributesController?: BlockAttributesController | null;
14
14
  attributesPanel?: boolean | 'docked' | 'overlay' | 'off';
15
15
  presentation?: 'card' | 'bare';
16
+ imageSource?: ImageSource;
16
17
  onIssue?: (issue: ValidationIssue) => void;
17
18
  onChange?: (document: JSONContent) => void;
18
19
  onMetaChange?: (meta: Record<string, unknown>) => void;
@@ -1,7 +1,7 @@
1
1
  import UncialEditor from './UncialEditor.svelte';
2
2
  import UncialRenderer from './UncialRenderer.svelte';
3
3
  import type { AnyExtension, JSONContent } from '@tiptap/core';
4
- import type { BlockAttributesController, ToolbarFeature, ToolbarFeatureSelection } from '../editor/index.js';
4
+ import type { BlockAttributesController, ImageSource, ToolbarFeature, ToolbarFeatureSelection } from '../editor/index.js';
5
5
  import type { AttributeSpec, BlockDefinition, BlockRegistry, ContentSchema, DocumentMetaSchema, ValidationIssue } from '../core/types.js';
6
6
  type EditorProps = {
7
7
  blocks?: BlockRegistry | BlockDefinition[];
@@ -15,6 +15,7 @@ type EditorProps = {
15
15
  attributesController?: BlockAttributesController | null;
16
16
  attributesPanel?: boolean | 'docked' | 'overlay' | 'off';
17
17
  presentation?: 'card' | 'bare';
18
+ imageSource?: ImageSource;
18
19
  };
19
20
  type EditorHostProps = EditorProps & {
20
21
  onIssue?: (issue: ValidationIssue) => void;
@@ -82,6 +83,8 @@ declare class UncialEditorElement extends UncialElement<EditorHostProps> {
82
83
  set attributesPanel(value: EditorProps['attributesPanel']);
83
84
  get presentation(): EditorProps['presentation'];
84
85
  set presentation(value: EditorProps['presentation']);
86
+ get imageSource(): EditorProps['imageSource'];
87
+ set imageSource(value: EditorProps['imageSource']);
85
88
  protected mountComponent(target: ShadowRoot): Record<string, unknown>;
86
89
  }
87
90
  declare class UncialRendererElement extends UncialElement<RendererHostProps> {
@@ -149,6 +149,12 @@ class UncialEditorElement extends UncialElement {
149
149
  set presentation(value) {
150
150
  this.setProp('presentation', value);
151
151
  }
152
+ get imageSource() {
153
+ return this.props.imageSource;
154
+ }
155
+ set imageSource(value) {
156
+ this.setProp('imageSource', value);
157
+ }
152
158
  mountComponent(target) {
153
159
  return mount(UncialEditor, { target, props: this.props });
154
160
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "uncial",
3
- "version": "2.0.3",
3
+ "version": "4.0.0",
4
4
  "license": "MIT",
5
5
  "repository": {
6
6
  "type": "git",
@@ -126,8 +126,8 @@
126
126
  "release": "pnpm run prepack && changeset publish",
127
127
  "check": "svelte-kit sync && svelte-check --tsconfig ./tsconfig.json",
128
128
  "check:watch": "svelte-kit sync && svelte-check --tsconfig ./tsconfig.json --watch",
129
- "lint": "prettier --check . && eslint .",
130
- "format": "prettier --write .",
129
+ "lint": "prettier --check . --ignore-path ../../.gitignore --ignore-path ../../.prettierignore && eslint .",
130
+ "format": "prettier --write . --ignore-path ../../.gitignore --ignore-path ../../.prettierignore",
131
131
  "test:unit": "vitest --project server",
132
132
  "test:browser": "vitest --project client",
133
133
  "test": "pnpm run test:unit -- --run && pnpm run test:browser -- --run && pnpm run test:e2e",