@shelamkoff/rector 1.0.1 → 1.0.3

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 (63) hide show
  1. package/README.md +25 -24
  2. package/dist/core/clipboard/Clipboard.d.ts +2 -0
  3. package/dist/core/clipboard/Clipboard.js +52 -24
  4. package/dist/core/index.js +195 -194
  5. package/dist/core/locale/en.d.ts +1 -0
  6. package/dist/core/locale/en.js +1 -0
  7. package/dist/core/locale/ru.d.ts +1 -0
  8. package/dist/core/locale/ru.js +1 -0
  9. package/dist/core/themes/light.css +1 -1
  10. package/dist/core/themes/variables.css +72 -10
  11. package/dist/locale/en.d.ts +41 -0
  12. package/dist/locale/ru.d.ts +41 -0
  13. package/dist/plugins/attaches/attaches.css +16 -14
  14. package/dist/plugins/attaches/index.js +997 -920
  15. package/dist/plugins/attaches/locale/en.d.ts +9 -0
  16. package/dist/plugins/attaches/locale/en.js +11 -2
  17. package/dist/plugins/attaches/locale/ru.d.ts +9 -0
  18. package/dist/plugins/attaches/locale/ru.js +11 -2
  19. package/dist/plugins/carousel/carousel.css +213 -49
  20. package/dist/plugins/carousel/index.js +918 -858
  21. package/dist/plugins/carousel/locale/en.d.ts +15 -0
  22. package/dist/plugins/carousel/locale/en.js +18 -3
  23. package/dist/plugins/carousel/locale/ru.d.ts +15 -0
  24. package/dist/plugins/carousel/locale/ru.js +18 -3
  25. package/dist/plugins/gallery/README.md +92 -92
  26. package/dist/plugins/gallery/README.ru.md +17 -17
  27. package/dist/plugins/gallery/gallery.css +44 -19
  28. package/dist/plugins/gallery/index.js +375 -354
  29. package/dist/plugins/gallery/locale/en.d.ts +8 -0
  30. package/dist/plugins/gallery/locale/en.js +11 -3
  31. package/dist/plugins/gallery/locale/ru.d.ts +8 -0
  32. package/dist/plugins/gallery/locale/ru.js +11 -3
  33. package/dist/plugins/gallery/settings.js +15 -10
  34. package/dist/plugins/gallery/view-empty.d.ts +2 -0
  35. package/dist/plugins/gallery/view-empty.js +21 -15
  36. package/dist/plugins/gallery/view-filled.d.ts +2 -2
  37. package/dist/plugins/gallery/view-filled.js +84 -72
  38. package/dist/plugins/image/image.css +7 -2
  39. package/dist/plugins/image/index.js +365 -345
  40. package/dist/plugins/image/locale/en.d.ts +8 -0
  41. package/dist/plugins/image/locale/en.js +11 -3
  42. package/dist/plugins/image/locale/ru.d.ts +8 -0
  43. package/dist/plugins/image/locale/ru.js +11 -3
  44. package/dist/plugins/image/view-empty.d.ts +2 -0
  45. package/dist/plugins/image/view-empty.js +21 -15
  46. package/dist/plugins/image/view-filled.d.ts +2 -2
  47. package/dist/plugins/image/view-filled.js +77 -72
  48. package/dist/plugins/shared/dropzone.d.ts +6 -0
  49. package/dist/plugins/shared/dropzone.js +47 -36
  50. package/dist/plugins/shared/layer.d.ts +13 -0
  51. package/dist/plugins/shared/layer.js +45 -0
  52. package/dist/plugins/shared/sourceEditor.css +165 -0
  53. package/dist/plugins/shared/sourceEditor.d.ts +97 -0
  54. package/dist/plugins/shared/sourceEditor.js +260 -0
  55. package/dist/renderer/renderers/carousel/index.js +24 -23
  56. package/dist/renderer/renderers/carousel/styles.css +8 -2
  57. package/dist/renderer/renderers/gallery/README.md +41 -41
  58. package/dist/renderer/renderers/gallery/README.ru.md +41 -41
  59. package/dist/renderer/renderers/gallery/index.js +100 -85
  60. package/dist/renderer/renderers/gallery/styles.css +417 -401
  61. package/dist/shared/galleryMasonry.d.ts +34 -0
  62. package/dist/shared/galleryMasonry.js +152 -0
  63. package/package.json +29 -28
@@ -0,0 +1,34 @@
1
+ /**
2
+ * @typedef {Object} GalleryMasonryOptions
3
+ * @property {AbortSignal} [signal]
4
+ * @property {number} [columnWidth]
5
+ * @property {number} [transitionDuration]
6
+ * @property {number} [fadeInDuration]
7
+ * @property {number} [contentLoadTimeout]
8
+ * @property {(error: unknown) => void} [onError]
9
+ */
10
+ /**
11
+ * Mount a Masonry instance once its container is connected and measurable.
12
+ *
13
+ * Editor plugins and renderers both create their DOM before the host inserts
14
+ * it into the document. Waiting for a non-zero box avoids a failed first
15
+ * layout and keeps the two rendering paths on the same implementation.
16
+ *
17
+ * @param {HTMLElement} container
18
+ * @param {HTMLElement[]} elements
19
+ * @param {GalleryMasonryOptions} [options]
20
+ */
21
+ export function mountGalleryMasonry(container: HTMLElement, elements: HTMLElement[], options?: GalleryMasonryOptions): {
22
+ ready: Promise<any>;
23
+ destroy: () => void;
24
+ readonly instance: Masonry;
25
+ };
26
+ export type GalleryMasonryOptions = {
27
+ signal?: AbortSignal;
28
+ columnWidth?: number;
29
+ transitionDuration?: number;
30
+ fadeInDuration?: number;
31
+ contentLoadTimeout?: number;
32
+ onError?: (error: unknown) => void;
33
+ };
34
+ import { Masonry } from '@shelamkoff/masonry';
@@ -0,0 +1,152 @@
1
+ // @ts-check
2
+ import { Masonry } from '@shelamkoff/masonry'
3
+
4
+ /**
5
+ * @typedef {Object} GalleryMasonryOptions
6
+ * @property {AbortSignal} [signal]
7
+ * @property {number} [columnWidth]
8
+ * @property {number} [transitionDuration]
9
+ * @property {number} [fadeInDuration]
10
+ * @property {number} [contentLoadTimeout]
11
+ * @property {(error: unknown) => void} [onError]
12
+ */
13
+
14
+ /**
15
+ * Mount a Masonry instance once its container is connected and measurable.
16
+ *
17
+ * Editor plugins and renderers both create their DOM before the host inserts
18
+ * it into the document. Waiting for a non-zero box avoids a failed first
19
+ * layout and keeps the two rendering paths on the same implementation.
20
+ *
21
+ * @param {HTMLElement} container
22
+ * @param {HTMLElement[]} elements
23
+ * @param {GalleryMasonryOptions} [options]
24
+ */
25
+ export function mountGalleryMasonry(container, elements, options = {}) {
26
+ const {
27
+ signal,
28
+ columnWidth = 240,
29
+ transitionDuration = 200,
30
+ fadeInDuration = 180,
31
+ contentLoadTimeout = 10_000,
32
+ onError,
33
+ } = options
34
+
35
+ /** @type {Masonry | null} */
36
+ let instance = null
37
+ /** @type {ResizeObserver | null} */
38
+ let waitingObserver = null
39
+ /** @type {number | null} */
40
+ let frameId = null
41
+ let destroyed = false
42
+ let starting = false
43
+ let settled = false
44
+ /** @type {(value: Masonry | null) => void} */
45
+ let resolveReady = () => {}
46
+
47
+ const ready = new Promise((resolve) => {
48
+ resolveReady = resolve
49
+ })
50
+
51
+ const settle = (/** @type {Masonry | null} */ value) => {
52
+ if (settled) return
53
+ settled = true
54
+ resolveReady(value)
55
+ }
56
+
57
+ const stopWaiting = () => {
58
+ waitingObserver?.disconnect()
59
+ waitingObserver = null
60
+ if (frameId !== null && typeof cancelAnimationFrame === 'function') {
61
+ cancelAnimationFrame(frameId)
62
+ }
63
+ frameId = null
64
+ }
65
+
66
+ const readGap = () => {
67
+ const style = getComputedStyle(container)
68
+ const value = Number.parseFloat(style.columnGap || style.gap)
69
+ return Number.isFinite(value) && value >= 0 ? value : 4
70
+ }
71
+
72
+ const start = async () => {
73
+ if (destroyed || starting || settled) return
74
+ if (!container.isConnected || container.getBoundingClientRect().width <= 0) return
75
+
76
+ starting = true
77
+ stopWaiting()
78
+
79
+ try {
80
+ instance = new Masonry(container, {
81
+ columnWidth,
82
+ layoutMode: 'masonry',
83
+ autoColSpan: false,
84
+ gap: readGap(),
85
+ transitionDuration,
86
+ fadeInDuration,
87
+ contentLoadTimeout,
88
+ })
89
+ await instance.append(elements.map((element, index) => ({
90
+ id: `gallery-item-${index}`,
91
+ element,
92
+ colSpan: 1,
93
+ meta: { index },
94
+ })))
95
+
96
+ if (destroyed) {
97
+ instance.destroy()
98
+ instance = null
99
+ settle(null)
100
+ return
101
+ }
102
+ settle(instance)
103
+ } catch (error) {
104
+ instance?.destroy()
105
+ instance = null
106
+ if (!destroyed) {
107
+ container.classList.add('eg--masonry-fallback')
108
+ onError?.(error)
109
+ }
110
+ settle(null)
111
+ }
112
+ }
113
+
114
+ const destroy = () => {
115
+ if (destroyed) return
116
+ destroyed = true
117
+ stopWaiting()
118
+ instance?.destroy()
119
+ instance = null
120
+ signal?.removeEventListener('abort', destroy)
121
+ settle(null)
122
+ }
123
+
124
+ if (signal?.aborted) {
125
+ destroy()
126
+ } else {
127
+ signal?.addEventListener('abort', destroy, { once: true })
128
+ if (typeof ResizeObserver === 'function') {
129
+ waitingObserver = new ResizeObserver(() => {
130
+ void start()
131
+ })
132
+ waitingObserver.observe(container)
133
+ }
134
+ if (typeof requestAnimationFrame === 'function') {
135
+ frameId = requestAnimationFrame(() => {
136
+ frameId = null
137
+ void start()
138
+ })
139
+ }
140
+ queueMicrotask(() => {
141
+ void start()
142
+ })
143
+ }
144
+
145
+ return {
146
+ ready,
147
+ destroy,
148
+ get instance() {
149
+ return instance
150
+ },
151
+ }
152
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@shelamkoff/rector",
3
- "version": "1.0.1",
3
+ "version": "1.0.3",
4
4
  "description": "Extensible browser-native block editor with atomic history, versioned JSON, and document rendering",
5
5
  "type": "module",
6
6
  "sideEffects": [
@@ -46,14 +46,14 @@
46
46
  "types": "./dist/inline-tools/*.d.ts",
47
47
  "import": "./dist/inline-tools/*.js"
48
48
  },
49
- "./renderer": {
50
- "types": "./dist/renderer/index.d.ts",
51
- "import": "./dist/renderer/index.js"
52
- },
53
- "./renderer/types": {
54
- "types": "./dist/renderer/types.d.ts"
55
- },
56
- "./renderer/async": {
49
+ "./renderer": {
50
+ "types": "./dist/renderer/index.d.ts",
51
+ "import": "./dist/renderer/index.js"
52
+ },
53
+ "./renderer/types": {
54
+ "types": "./dist/renderer/types.d.ts"
55
+ },
56
+ "./renderer/async": {
57
57
  "types": "./dist/renderer/async.d.ts",
58
58
  "import": "./dist/renderer/async.js"
59
59
  },
@@ -78,39 +78,40 @@
78
78
  "./styles/themes/*": "./dist/core/themes/*.css",
79
79
  "./package.json": "./package.json"
80
80
  },
81
- "files": [
82
- "dist",
83
- "README.md",
84
- "LICENSE",
85
- "NOTICE",
86
- "THIRD_PARTY_LICENSES.txt"
81
+ "files": [
82
+ "dist",
83
+ "README.md",
84
+ "LICENSE",
85
+ "NOTICE",
86
+ "THIRD_PARTY_LICENSES.txt"
87
87
  ],
88
88
  "scripts": {
89
- "build": "npm run docs:validate-readmes && node scripts/build-package.mjs",
89
+ "build": "npm run docs:validate-readmes && node scripts/build-package.mjs",
90
90
  "build:types": "node scripts/generate-declarations.mjs --out dist",
91
91
  "typecheck": "node node_modules/typescript/bin/tsc -p jsconfig.json",
92
- "docs:validate-readmes": "node scripts/validate-extension-readmes.mjs",
93
- "docs:sync": "npm run docs:validate-readmes && node scripts/sync-vitepress-readmes.mjs",
92
+ "docs:validate-readmes": "node scripts/validate-extension-readmes.mjs",
93
+ "docs:sync": "npm run docs:validate-readmes && node scripts/sync-vitepress-readmes.mjs",
94
94
  "docs:dev": "npm run docs:sync && vitepress dev docs --host 127.0.0.1",
95
95
  "docs:build": "npm run docs:sync && vitepress build docs",
96
96
  "docs:preview": "vitepress preview docs --host 127.0.0.1",
97
- "docs:check": "npm run docs:build && node scripts/vitepress-docs-smoke.mjs && node scripts/vitepress-browser-smoke.mjs",
98
- "test": "node --test",
99
- "test:browser": "node tests/browser/run.mjs && node tests/browser/physical-history.mjs && node tests/browser/heap-gate.mjs",
100
- "test:plugin-source": "node scripts/plugin-source-audit.mjs",
101
- "test:plugin-locales": "node scripts/plugin-locale-audit.mjs",
102
- "test:docs": "npm run docs:validate-readmes && npm run test:plugin-source && npm run test:plugin-locales && node scripts/documentation-contract-audit.mjs && node scripts/readme-smoke.mjs",
97
+ "docs:check": "npm run docs:build && node scripts/vitepress-docs-smoke.mjs && node scripts/vitepress-browser-smoke.mjs",
98
+ "test": "node --test",
99
+ "test:browser": "node tests/browser/run.mjs && node tests/browser/physical-history.mjs && node tests/browser/heap-gate.mjs",
100
+ "test:plugin-source": "node scripts/plugin-source-audit.mjs",
101
+ "test:plugin-locales": "node scripts/plugin-locale-audit.mjs",
102
+ "test:docs": "npm run docs:validate-readmes && npm run test:plugin-source && npm run test:plugin-locales && node scripts/documentation-contract-audit.mjs && node scripts/readme-smoke.mjs",
103
103
  "test:types": "node --test shared/declarationParity.test.js",
104
104
  "test:package": "node scripts/package-consumer-gate.mjs",
105
105
  "prepublishOnly": "npm run typecheck && npm test && npm run test:browser && npm run test:docs && npm run test:types && npm run test:package",
106
106
  "prepack": "npm run build"
107
107
  },
108
- "dependencies": {
109
- "@shelamkoff/carousel": "^1.0.0",
108
+ "dependencies": {
109
+ "@shelamkoff/carousel": "^1.0.0",
110
110
  "@shelamkoff/color-picker": "^1.0.0",
111
111
  "@shelamkoff/event-bus": "^1.0.0",
112
112
  "@shelamkoff/cropper": "^1.0.0",
113
- "@shelamkoff/expose": "^1.0.0"
113
+ "@shelamkoff/expose": "^1.0.0",
114
+ "@shelamkoff/masonry": "^1.0.0"
114
115
  },
115
116
  "devDependencies": {
116
117
  "@tabler/icons-vue": "^3.41.1",
@@ -135,7 +136,7 @@
135
136
  "type": "git",
136
137
  "url": "git+https://github.com/Shelamkoff/editor.git"
137
138
  },
138
- "homepage": "https://shelamkoff.github.io/editor/",
139
+ "homepage": "https://shelamkoff.github.io/editor/",
139
140
  "bugs": {
140
141
  "url": "https://github.com/Shelamkoff/editor/issues"
141
142
  },