@domternal/vanilla 0.7.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.
- package/LICENSE +21 -0
- package/README.md +44 -0
- package/dist/bubble-menu/index.d.ts +2 -0
- package/dist/bubble-menu/index.d.ts.map +1 -0
- package/dist/editor/index.d.ts +2 -0
- package/dist/editor/index.d.ts.map +1 -0
- package/dist/emoji-picker/index.d.ts +2 -0
- package/dist/emoji-picker/index.d.ts.map +1 -0
- package/dist/floating-menu/index.d.ts +2 -0
- package/dist/floating-menu/index.d.ts.map +1 -0
- package/dist/index.d.ts +871 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +2822 -0
- package/dist/index.js.map +1 -0
- package/dist/notion-color-picker/index.d.ts +2 -0
- package/dist/notion-color-picker/index.d.ts.map +1 -0
- package/dist/shared/eventTarget.d.ts +22 -0
- package/dist/shared/eventTarget.d.ts.map +1 -0
- package/dist/shared/iconRenderer.d.ts +20 -0
- package/dist/shared/iconRenderer.d.ts.map +1 -0
- package/dist/shared/index.d.ts +6 -0
- package/dist/shared/index.d.ts.map +1 -0
- package/dist/shared/isBrowser.d.ts +13 -0
- package/dist/shared/isBrowser.d.ts.map +1 -0
- package/dist/shared/pluginKey.d.ts +14 -0
- package/dist/shared/pluginKey.d.ts.map +1 -0
- package/dist/shared/types.d.ts +15 -0
- package/dist/shared/types.d.ts.map +1 -0
- package/dist/toolbar/index.d.ts +2 -0
- package/dist/toolbar/index.d.ts.map +1 -0
- package/package.json +50 -0
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Helpers for typed event subscription over `EventTarget`.
|
|
3
|
+
*
|
|
4
|
+
* Each `@domternal/vanilla` class extends the platform `EventTarget` and
|
|
5
|
+
* dispatches `CustomEvent` instances. Consumers can use the platform
|
|
6
|
+
* `addEventListener('eventName', handler)` directly, OR call `subscribe()`
|
|
7
|
+
* which returns an unsubscribe function and narrows the detail type.
|
|
8
|
+
*
|
|
9
|
+
* Usage:
|
|
10
|
+
* ```ts
|
|
11
|
+
* import { subscribe } from '@domternal/vanilla';
|
|
12
|
+
*
|
|
13
|
+
* const off = subscribe<{ isOpen: boolean }>(picker, 'openchange', (detail) => {
|
|
14
|
+
* console.log(detail.isOpen);
|
|
15
|
+
* });
|
|
16
|
+
* off(); // remove listener
|
|
17
|
+
* ```
|
|
18
|
+
*
|
|
19
|
+
* Each class JSDoc lists the events it emits + the shape of `detail`.
|
|
20
|
+
*/
|
|
21
|
+
export declare function subscribe<TDetail = unknown>(target: EventTarget, type: string, listener: (detail: TDetail) => void): () => void;
|
|
22
|
+
//# sourceMappingURL=eventTarget.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"eventTarget.d.ts","sourceRoot":"","sources":["../../src/shared/eventTarget.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;GAmBG;AAKH,wBAAgB,SAAS,CAAC,OAAO,GAAG,OAAO,EACzC,MAAM,EAAE,WAAW,EACnB,IAAI,EAAE,MAAM,EACZ,QAAQ,EAAE,CAAC,MAAM,EAAE,OAAO,KAAK,IAAI,GAClC,MAAM,IAAI,CAQZ"}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import type { IconSet } from '@domternal/core';
|
|
2
|
+
/**
|
|
3
|
+
* Resolve and inject an icon's SVG string into a host element.
|
|
4
|
+
*
|
|
5
|
+
* Why innerHTML is safe here: icons come from the `defaultIcons` lookup
|
|
6
|
+
* table (Phosphor SVG strings shipped with core) or from a consumer-provided
|
|
7
|
+
* `IconSet` object. Both are trusted by contract - they are constants in
|
|
8
|
+
* source code, not user input. This matches the React (`dangerouslySetInnerHTML`),
|
|
9
|
+
* Angular (`bypassSecurityTrustHtml`), and Vue (`v-html`) patterns.
|
|
10
|
+
*
|
|
11
|
+
* Consumer responsibility (documented in README): never pass user-controlled
|
|
12
|
+
* strings as icon values in your IconSet.
|
|
13
|
+
*/
|
|
14
|
+
export declare function renderIconInto(hostEl: HTMLElement, iconKey: string | undefined, icons: IconSet | undefined): void;
|
|
15
|
+
/**
|
|
16
|
+
* Resolve an icon's SVG string without injection. Useful when caller
|
|
17
|
+
* builds the final DOM tree (e.g. via document.createElement chain).
|
|
18
|
+
*/
|
|
19
|
+
export declare function resolveIcon(iconKey: string | undefined, icons: IconSet | undefined): string;
|
|
20
|
+
//# sourceMappingURL=iconRenderer.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"iconRenderer.d.ts","sourceRoot":"","sources":["../../src/shared/iconRenderer.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,iBAAiB,CAAC;AAE/C;;;;;;;;;;;GAWG;AACH,wBAAgB,cAAc,CAC5B,MAAM,EAAE,WAAW,EACnB,OAAO,EAAE,MAAM,GAAG,SAAS,EAC3B,KAAK,EAAE,OAAO,GAAG,SAAS,GACzB,IAAI,CASN;AAED;;;GAGG;AACH,wBAAgB,WAAW,CACzB,OAAO,EAAE,MAAM,GAAG,SAAS,EAC3B,KAAK,EAAE,OAAO,GAAG,SAAS,GACzB,MAAM,CAGR"}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
export { isBrowser, assertBrowser } from './isBrowser.js';
|
|
2
|
+
export { createPluginKey } from './pluginKey.js';
|
|
3
|
+
export { renderIconInto, resolveIcon } from './iconRenderer.js';
|
|
4
|
+
export { subscribe } from './eventTarget.js';
|
|
5
|
+
export type { CustomContentOption } from './types.js';
|
|
6
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/shared/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,aAAa,EAAE,MAAM,gBAAgB,CAAC;AAC1D,OAAO,EAAE,eAAe,EAAE,MAAM,gBAAgB,CAAC;AACjD,OAAO,EAAE,cAAc,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AAChE,OAAO,EAAE,SAAS,EAAE,MAAM,kBAAkB,CAAC;AAC7C,YAAY,EAAE,mBAAmB,EAAE,MAAM,YAAY,CAAC"}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* SSR-safe environment check.
|
|
3
|
+
*
|
|
4
|
+
* `@domternal/vanilla` classes construct DOM nodes and attach listeners on
|
|
5
|
+
* `document` / `window`. During SSR (Astro/Nuxt/Next.js build), the module
|
|
6
|
+
* may be imported but constructors must NOT run server-side.
|
|
7
|
+
*
|
|
8
|
+
* Class constructors call `assertBrowser()` early - throws a clear error
|
|
9
|
+
* if invoked outside a browser environment.
|
|
10
|
+
*/
|
|
11
|
+
export declare const isBrowser: boolean;
|
|
12
|
+
export declare function assertBrowser(className: string): void;
|
|
13
|
+
//# sourceMappingURL=isBrowser.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"isBrowser.d.ts","sourceRoot":"","sources":["../../src/shared/isBrowser.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AACH,eAAO,MAAM,SAAS,EAAE,OAC0C,CAAC;AAEnE,wBAAgB,aAAa,CAAC,SAAS,EAAE,MAAM,GAAG,IAAI,CAQrD"}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { PluginKey } from '@domternal/core';
|
|
2
|
+
/**
|
|
3
|
+
* Create a unique PluginKey with collision-free suffix.
|
|
4
|
+
*
|
|
5
|
+
* Two instances of the same wrapper class mounted in the same editor (rare
|
|
6
|
+
* but supported) need distinct keys to avoid ProseMirror plugin clashes.
|
|
7
|
+
*
|
|
8
|
+
* Why crypto.randomUUID + Math.random fallback: matches the framework
|
|
9
|
+
* wrapper convention (angular, react, vue all use this pattern as of
|
|
10
|
+
* commit fbef072). SSR may share Math.random seed across mount cycles,
|
|
11
|
+
* giving collisions; crypto.randomUUID is collision-free by spec.
|
|
12
|
+
*/
|
|
13
|
+
export declare function createPluginKey(prefix: string): PluginKey;
|
|
14
|
+
//# sourceMappingURL=pluginKey.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"pluginKey.d.ts","sourceRoot":"","sources":["../../src/shared/pluginKey.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;AAE5C;;;;;;;;;;GAUG;AACH,wBAAgB,eAAe,CAAC,MAAM,EAAE,MAAM,GAAG,SAAS,CAKzD"}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Shared option types reused across @domternal/vanilla components.
|
|
3
|
+
*/
|
|
4
|
+
/**
|
|
5
|
+
* Custom content slot - pass a pre-built DOM tree the wrapper appends
|
|
6
|
+
* into its host instead of rendering the default UI.
|
|
7
|
+
*
|
|
8
|
+
* The DOM you pass stays YOURS. The wrapper does NOT mutate it after
|
|
9
|
+
* construction and does NOT clean up event handlers on it during destroy.
|
|
10
|
+
* Manage its lifecycle yourself.
|
|
11
|
+
*/
|
|
12
|
+
export interface CustomContentOption {
|
|
13
|
+
customContent?: HTMLElement;
|
|
14
|
+
}
|
|
15
|
+
//# sourceMappingURL=types.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/shared/types.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH;;;;;;;GAOG;AACH,MAAM,WAAW,mBAAmB;IAClC,aAAa,CAAC,EAAE,WAAW,CAAC;CAC7B"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/toolbar/index.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,CAAC"}
|
package/package.json
ADDED
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@domternal/vanilla",
|
|
3
|
+
"version": "0.7.0",
|
|
4
|
+
"description": "Polished DOM components for the Domternal rich-text editor. Use in Astro, Svelte, Solid, plain HTML.",
|
|
5
|
+
"author": "https://github.com/ThomasNowHere",
|
|
6
|
+
"license": "MIT",
|
|
7
|
+
"type": "module",
|
|
8
|
+
"sideEffects": false,
|
|
9
|
+
"exports": {
|
|
10
|
+
".": {
|
|
11
|
+
"@domternal/source": "./src/index.ts",
|
|
12
|
+
"import": {
|
|
13
|
+
"types": "./dist/index.d.ts",
|
|
14
|
+
"default": "./dist/index.js"
|
|
15
|
+
}
|
|
16
|
+
}
|
|
17
|
+
},
|
|
18
|
+
"files": [
|
|
19
|
+
"dist"
|
|
20
|
+
],
|
|
21
|
+
"peerDependencies": {
|
|
22
|
+
"@domternal/core": ">=0.7.0",
|
|
23
|
+
"@domternal/extension-block-menu": ">=0.7.0"
|
|
24
|
+
},
|
|
25
|
+
"keywords": [
|
|
26
|
+
"vanilla",
|
|
27
|
+
"dom",
|
|
28
|
+
"astro",
|
|
29
|
+
"svelte",
|
|
30
|
+
"prosemirror",
|
|
31
|
+
"editor",
|
|
32
|
+
"rich-text",
|
|
33
|
+
"domternal"
|
|
34
|
+
],
|
|
35
|
+
"repository": {
|
|
36
|
+
"type": "git",
|
|
37
|
+
"url": "git+https://github.com/domternal/domternal.git",
|
|
38
|
+
"directory": "packages/vanilla"
|
|
39
|
+
},
|
|
40
|
+
"bugs": {
|
|
41
|
+
"url": "https://github.com/domternal/domternal/issues"
|
|
42
|
+
},
|
|
43
|
+
"homepage": "https://domternal.dev",
|
|
44
|
+
"scripts": {
|
|
45
|
+
"build": "tsup",
|
|
46
|
+
"dev": "tsup --watch",
|
|
47
|
+
"lint": "eslint src",
|
|
48
|
+
"typecheck": "tsc --noEmit"
|
|
49
|
+
}
|
|
50
|
+
}
|