@codeauradev/ngx-wind-editor 1.0.0 → 1.0.2

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.
@@ -1,184 +0,0 @@
1
- :host {
2
- display: block;
3
- min-width: 0;
4
- }
5
-
6
- .wind-frame {
7
- position: relative;
8
- min-width: 0;
9
- }
10
-
11
- .wind-doc {
12
- min-height: 12rem;
13
- padding: 1rem 1.15rem 1.5rem;
14
- outline: none;
15
- color: var(--color-stone-900, #1c1917);
16
- font-family: var(--font-serif, Georgia, "Iowan Old Style", "Palatino Linotype", serif);
17
- font-size: 1.0625rem;
18
- line-height: 1.65;
19
- caret-color: var(--color-teal-700, #0f766e);
20
- overflow-wrap: anywhere;
21
- }
22
-
23
- .wind-doc > * + * {
24
- margin-top: 0.75rem;
25
- }
26
-
27
- .wind-doc p,
28
- .wind-doc h1,
29
- .wind-doc h2,
30
- .wind-doc h3,
31
- .wind-doc blockquote,
32
- .wind-doc pre,
33
- .wind-doc li {
34
- margin: 0;
35
- }
36
-
37
- .wind-doc h1,
38
- .wind-doc h2,
39
- .wind-doc h3 {
40
- font-family: var(--font-sans, ui-sans-serif, system-ui, sans-serif);
41
- line-height: 1.2;
42
- letter-spacing: -0.03em;
43
- color: var(--color-stone-950, #0c0a09);
44
- }
45
-
46
- .wind-doc h1 { font-size: 1.875rem; font-weight: 600; }
47
- .wind-doc h2 { font-size: 1.5rem; font-weight: 600; }
48
- .wind-doc h3 { font-size: 1.25rem; font-weight: 600; }
49
-
50
- .wind-doc blockquote {
51
- border-left: 2px solid var(--color-teal-700, #0f766e);
52
- padding-left: 0.9rem;
53
- color: var(--color-stone-600, #57534e);
54
- }
55
-
56
- .wind-doc ul,
57
- .wind-doc ol {
58
- margin: 0;
59
- padding-left: 1.25rem;
60
- }
61
-
62
- .wind-doc li + li {
63
- margin-top: 0.25rem;
64
- }
65
-
66
- .wind-doc pre {
67
- overflow-x: auto;
68
- border-radius: 0.6rem;
69
- background: color-mix(in oklab, var(--color-stone-900, #1c1917) 6%, transparent);
70
- padding: 0.8rem 0.9rem;
71
- font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
72
- font-size: 0.875rem;
73
- line-height: 1.55;
74
- white-space: pre-wrap;
75
- }
76
-
77
- .wind-doc pre code {
78
- font: inherit;
79
- background: none;
80
- padding: 0;
81
- }
82
-
83
- .wind-doc a {
84
- color: var(--color-teal-800, #115e59);
85
- text-decoration: underline;
86
- text-underline-offset: 2px;
87
- }
88
-
89
- .wind-doc code {
90
- border-radius: 0.3rem;
91
- background: color-mix(in oklab, var(--color-stone-900, #1c1917) 8%, transparent);
92
- padding: 0.05em 0.3em;
93
- font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
94
- font-size: 0.88em;
95
- }
96
-
97
- .wind-doc img {
98
- display: block;
99
- max-width: 100%;
100
- border-radius: 0.6rem;
101
- }
102
-
103
- .wind-doc figure {
104
- margin: 0;
105
- }
106
-
107
- .wind-doc hr {
108
- border: 0;
109
- border-top: 1px solid var(--color-stone-300, #d6d3d1);
110
- margin: 0.25rem 0;
111
- }
112
-
113
- .wind-doc [data-atomic].is-selected {
114
- outline: 2px solid var(--color-teal-700, #0f766e);
115
- outline-offset: 3px;
116
- border-radius: 0.4rem;
117
- }
118
-
119
- .wind-doc[data-empty='true'] > p[data-placeholder]:before {
120
- content: attr(data-placeholder);
121
- float: left;
122
- height: 0;
123
- pointer-events: none;
124
- color: var(--color-stone-400, #a8a29e);
125
- }
126
-
127
- .wind-carets {
128
- position: absolute;
129
- inset: 0;
130
- pointer-events: none;
131
- overflow: hidden;
132
- }
133
-
134
- .wind-caret,
135
- .wind-remote {
136
- position: absolute;
137
- pointer-events: none;
138
- }
139
-
140
- .wind-caret {
141
- width: 2px;
142
- background: var(--peer);
143
- border-radius: 1px;
144
- }
145
-
146
- .wind-caret i {
147
- position: absolute;
148
- top: -1.15rem;
149
- left: -1px;
150
- border-radius: 0.3rem;
151
- background: var(--peer);
152
- color: white;
153
- padding: 0.05rem 0.3rem;
154
- font-family: var(--font-sans, ui-sans-serif, system-ui, sans-serif);
155
- font-size: 0.65rem;
156
- font-style: normal;
157
- line-height: 1.3;
158
- letter-spacing: 0.01em;
159
- white-space: nowrap;
160
- }
161
-
162
- .wind-remote {
163
- background: color-mix(in oklab, var(--peer) 32%, transparent);
164
- border-radius: 0.1rem;
165
- }
166
-
167
- .wind-frame.is-readonly .wind-doc {
168
- caret-color: transparent;
169
- }
170
-
171
- .dark .wind-doc {
172
- color: var(--color-stone-100, #f5f5f4);
173
- caret-color: var(--color-teal-300, #5eead4);
174
- }
175
- .dark .wind-doc h1,
176
- .dark .wind-doc h2,
177
- .dark .wind-doc h3 { color: var(--color-stone-50, #fafaf9); }
178
- .dark .wind-doc blockquote { color: var(--color-stone-400, #a8a29e); }
179
- .dark .wind-doc a { color: var(--color-teal-300, #5eead4); }
180
- .dark .wind-doc hr { border-top-color: var(--color-stone-700, #44403c); }
181
- .dark .wind-doc pre,
182
- .dark .wind-doc code {
183
- background: color-mix(in oklab, white 8%, transparent);
184
- }
package/dist/package.json DELETED
@@ -1,48 +0,0 @@
1
- {
2
- "name": "@codeauradev/ngx-wind-editor",
3
- "version": "1.0.0",
4
- "description": "WYSIWYG HTML editor for Angular 22, styled with Tailwind CSS v4.",
5
- "keywords": [
6
- "angular",
7
- "angular22",
8
- "wysiwyg",
9
- "rich-text",
10
- "editor",
11
- "tailwindcss",
12
- "ngx"
13
- ],
14
- "license": "MIT",
15
- "publishConfig": {
16
- "access": "public"
17
- },
18
- "sideEffects": [
19
- "*.css",
20
- "styles.css"
21
- ],
22
- "type": "module",
23
- "module": "fesm2022/codeauradev-ngx-wind-editor.mjs",
24
- "typings": "types/codeauradev-ngx-wind-editor.d.ts",
25
- "exports": {
26
- ".": {
27
- "types": "./types/codeauradev-ngx-wind-editor.d.ts",
28
- "default": "./fesm2022/codeauradev-ngx-wind-editor.mjs"
29
- },
30
- "./styles.css": "./ngx-wind-editor.css",
31
- "./package.json": {
32
- "default": "./package.json"
33
- }
34
- },
35
- "peerDependencies": {
36
- "@angular/core": "^22.0.0",
37
- "tailwindcss": "^4.0.0"
38
- },
39
- "peerDependenciesMeta": {
40
- "tailwindcss": {
41
- "optional": true
42
- }
43
- },
44
- "dependencies": {
45
- "tslib": "^2.8.1",
46
- "yjs": "^13.6.27"
47
- }
48
- }
package/ng-package.json DELETED
@@ -1,15 +0,0 @@
1
- {
2
- "$schema": "./node_modules/ng-packagr/ng-package.schema.json",
3
- "dest": "./dist",
4
- "allowedNonPeerDependencies": ["yjs"],
5
- "lib": {
6
- "entryFile": "src/public-api.ts"
7
- },
8
- "assets": [
9
- {
10
- "input": "src/styles",
11
- "glob": "**/*.css",
12
- "output": "."
13
- }
14
- ]
15
- }
@@ -1,11 +0,0 @@
1
- import { readFileSync, writeFileSync } from 'node:fs';
2
-
3
- const file = 'dist/package.json';
4
- const pkg = JSON.parse(readFileSync(file, 'utf8'));
5
- delete pkg.main;
6
- delete pkg.types;
7
- pkg.exports = {
8
- ...pkg.exports,
9
- './styles.css': './ngx-wind-editor.css',
10
- };
11
- writeFileSync(file, JSON.stringify(pkg, null, 2) + '\n');
package/src/catalog.ts DELETED
@@ -1,27 +0,0 @@
1
- import type { SlashChoice } from './session';
2
-
3
- export interface SlashItem {
4
- id: SlashChoice;
5
- label: string;
6
- hint: string;
7
- keys: string;
8
- }
9
-
10
- export const SLASH_ITEMS: readonly SlashItem[] = [
11
- { id: 'paragraph', label: 'Text', hint: 'Plain paragraph', keys: 'p text paragraph' },
12
- { id: 'h1', label: 'Heading 1', hint: 'Large title', keys: 'h1 heading title' },
13
- { id: 'h2', label: 'Heading 2', hint: 'Section', keys: 'h2 heading' },
14
- { id: 'h3', label: 'Heading 3', hint: 'Subsection', keys: 'h3 heading' },
15
- { id: 'bullet', label: 'Bullet list', hint: 'Unordered', keys: 'ul list bullet' },
16
- { id: 'ordered', label: 'Numbered list', hint: 'Ordered', keys: 'ol list number' },
17
- { id: 'quote', label: 'Quote', hint: 'Blockquote', keys: 'quote blockquote' },
18
- { id: 'code', label: 'Code', hint: 'Monospace block', keys: 'code pre' },
19
- { id: 'rule', label: 'Divider', hint: 'Horizontal rule', keys: 'hr rule divider line' },
20
- { id: 'image', label: 'Image', hint: 'From a URL', keys: 'img image picture' },
21
- ];
22
-
23
- export function filterSlash(query: string): SlashItem[] {
24
- const needle = query.trim().toLowerCase();
25
- if (!needle) return [...SLASH_ITEMS];
26
- return SLASH_ITEMS.filter((item) => `${item.label} ${item.keys}`.toLowerCase().includes(needle));
27
- }
package/src/delta.ts DELETED
@@ -1,115 +0,0 @@
1
- import type { Delta, DeltaOp, TextAttrs } from './types';
2
-
3
- const MARK_KEYS = ['bold', 'italic', 'underline', 'strike', 'code', 'href'] as const;
4
-
5
- export function packAttrs(attrs: TextAttrs | null | undefined): TextAttrs | undefined {
6
- if (!attrs) return undefined;
7
- const out: TextAttrs = {};
8
- if (attrs.bold) out.bold = true;
9
- if (attrs.italic) out.italic = true;
10
- if (attrs.underline) out.underline = true;
11
- if (attrs.strike) out.strike = true;
12
- if (attrs.code) out.code = true;
13
- if (typeof attrs.href === 'string' && attrs.href.length > 0) out.href = attrs.href;
14
- return Object.keys(out).length > 0 ? out : undefined;
15
- }
16
-
17
- export function attrsEqual(a: TextAttrs | undefined, b: TextAttrs | undefined): boolean {
18
- const left = packAttrs(a) ?? {};
19
- const right = packAttrs(b) ?? {};
20
- return MARK_KEYS.every((key) => left[key] === right[key]);
21
- }
22
-
23
- export function mergeDelta(delta: Delta): Delta {
24
- const out: Delta = [];
25
- for (const op of delta) {
26
- if (!op.insert) continue;
27
- const prev = out[out.length - 1];
28
- if (prev && attrsEqual(prev.attributes, op.attributes)) prev.insert += op.insert;
29
- else out.push({ insert: op.insert, attributes: packAttrs(op.attributes) });
30
- }
31
- return out;
32
- }
33
-
34
- export function deltaLength(delta: Delta): number {
35
- return delta.reduce((sum, op) => sum + op.insert.length, 0);
36
- }
37
-
38
- export function deltaToText(delta: Delta): string {
39
- return delta.map((op) => op.insert).join('');
40
- }
41
-
42
- export function sliceDelta(delta: Delta, start: number, end: number): Delta {
43
- const out: DeltaOp[] = [];
44
- let pos = 0;
45
- for (const op of delta) {
46
- const len = op.insert.length;
47
- const from = Math.max(start, pos);
48
- const to = Math.min(end, pos + len);
49
- if (to > from) {
50
- out.push({ insert: op.insert.slice(from - pos, to - pos), attributes: packAttrs(op.attributes) });
51
- }
52
- pos += len;
53
- }
54
- return out;
55
- }
56
-
57
- /** Attributes that apply to a caret sitting at `index` (the character before it). */
58
- export function attrsAt(delta: Delta, index: number): TextAttrs {
59
- if (index <= 0 || delta.length === 0) return {};
60
- let pos = 0;
61
- for (const op of delta) {
62
- const len = op.insert.length;
63
- if (index <= pos + len) return { ...(packAttrs(op.attributes) ?? {}) };
64
- pos += len;
65
- }
66
- return { ...(packAttrs(delta[delta.length - 1]?.attributes) ?? {}) };
67
- }
68
-
69
- export function commonEdges(prev: string, next: string): { start: number; prevEnd: number; nextEnd: number } {
70
- let start = 0;
71
- const limit = Math.min(prev.length, next.length);
72
- while (start < limit && prev[start] === next[start]) start += 1;
73
- let prevEnd = prev.length;
74
- let nextEnd = next.length;
75
- while (prevEnd > start && nextEnd > start && prev[prevEnd - 1] === next[nextEnd - 1]) {
76
- prevEnd -= 1;
77
- nextEnd -= 1;
78
- }
79
- return { start, prevEnd, nextEnd };
80
- }
81
-
82
- interface GraphemePart {
83
- index: number;
84
- segment: string;
85
- }
86
-
87
- interface GraphemeSegmenter {
88
- segment(input: string): Iterable<GraphemePart>;
89
- }
90
-
91
- /** Local shape so the build does not depend on the ES2022 Intl lib. */
92
- function graphemeSegmenter(): GraphemeSegmenter | null {
93
- const intl = Intl as typeof Intl & {
94
- Segmenter?: new (locales?: string, options?: { granularity?: 'grapheme' }) => GraphemeSegmenter;
95
- };
96
- if (typeof intl.Segmenter !== 'function') return null;
97
- return new intl.Segmenter(undefined, { granularity: 'grapheme' });
98
- }
99
-
100
- export function graphemeBefore(text: string, offset: number): number {
101
- if (offset <= 0) return 0;
102
- const segmenter = graphemeSegmenter();
103
- if (!segmenter) return offset - 1;
104
- let last = 0;
105
- for (const part of segmenter.segment(text.slice(0, offset))) last = part.index;
106
- return last;
107
- }
108
-
109
- export function graphemeAfter(text: string, offset: number): number {
110
- if (offset >= text.length) return text.length;
111
- const segmenter = graphemeSegmenter();
112
- if (!segmenter) return offset + 1;
113
- const part = segmenter.segment(text.slice(offset))[Symbol.iterator]().next().value;
114
- return offset + (part?.segment.length ?? 1);
115
- }