@gilav21/shadcn-angular-rte 0.1.2 → 0.2.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/README.md +43 -27
- package/fesm2022/{gilav21-shadcn-angular-rte-docx-parser-B8BeJWtY.mjs → gilav21-shadcn-angular-rte-docx-parser-CdxuIlVT.mjs} +2 -2
- package/fesm2022/{gilav21-shadcn-angular-rte-docx-parser-B8BeJWtY.mjs.map → gilav21-shadcn-angular-rte-docx-parser-CdxuIlVT.mjs.map} +1 -1
- package/fesm2022/{gilav21-shadcn-angular-rte-gilav21-shadcn-angular-rte-CfjU_y-y.mjs → gilav21-shadcn-angular-rte-gilav21-shadcn-angular-rte-BFcfCqW4.mjs} +73 -6
- package/fesm2022/gilav21-shadcn-angular-rte-gilav21-shadcn-angular-rte-BFcfCqW4.mjs.map +1 -0
- package/fesm2022/gilav21-shadcn-angular-rte.mjs +1 -1
- package/package.json +6 -2
- package/schematics/collection.json +10 -0
- package/schematics/ng-add/index.cjs +169 -0
- package/schematics/ng-add/schema.json +13 -0
- package/styles.css +2 -0
- package/types/gilav21-shadcn-angular-rte.d.ts +6 -1
- package/types/gilav21-shadcn-angular-rte.d.ts.map +1 -1
- package/fesm2022/gilav21-shadcn-angular-rte-gilav21-shadcn-angular-rte-CfjU_y-y.mjs.map +0 -1
- package/theme.css +0 -159
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export { A as ACTION_ATTRS, a as ACTION_PARAMS, b as AddonSlotRegistry, D as DEFAULT_COLOR_PALETTE, c as DEFAULT_FONT_FAMILIES, d as DEFAULT_HIGHLIGHT_PALETTE, e as DEFAULT_LINK_SCHEMES, f as DEFAULT_TOOLBAR_ITEMS, g as DOCUMENT_IMPORT_ACCEPT, h as DOCX_MIME, E as EMPTINESS_FIXTURES, F as FIND_MAX_PAINTED_RECTS, j as FIND_MAX_QUERY_LENGTH, H as HEADER_BYTES, I as IMAGE_IMPORT_ACCEPT, k as INLINE_RULE_LOOKBEHIND, M as MAX_NESTING_DEPTH, P as PDF_MIME, l as PresetDialogComponent, m as PresetHoverCardComponent, R as RICH_TEXT_ACTIONS_SANITIZER_RULES, n as RICH_TEXT_AI_CONTEXT, o as RICH_TEXT_AI_LOCALES, p as RICH_TEXT_COLORS_LOCALES, q as RICH_TEXT_COLOR_BUTTON_CONTEXT, r as RICH_TEXT_EMOJI_CONTEXT, s as RICH_TEXT_EMOJI_LOCALES, t as RICH_TEXT_FILE_IMPORT_BUTTON_CONTEXT, u as RICH_TEXT_FILE_IMPORT_LOCALES, v as RICH_TEXT_HISTORY_LOCALES, w as RICH_TEXT_IMAGES_BUTTON_CONTEXT, x as RICH_TEXT_IMAGES_LOCALES, y as RICH_TEXT_LINKS_BUTTON_CONTEXT, z as RICH_TEXT_LINKS_LOCALES, B as RICH_TEXT_LOCALES, C as RICH_TEXT_MENTIONS_LOCALES, G as RICH_TEXT_OUTLINE_CONTEXT, J as RICH_TEXT_OUTLINE_LOCALES, K as RICH_TEXT_PROSE_CLASSES, L as RICH_TEXT_SHORTCUT_DEFINITIONS, N as RICH_TEXT_SLASH_COMMANDS_LOCALES, O as RICH_TEXT_TABLES_BUTTON_CONTEXT, Q as RICH_TEXT_TABLES_LOCALES, S as RICH_TEXT_TYPOGRAPHY_BUTTON_CONTEXT, T as RICH_TEXT_TYPOGRAPHY_LOCALES, U as RTE_FULL, V as RichTextActionsBindDirective, W as RichTextActionsDirective, X as RichTextAiChipComponent, Y as RichTextAiDirective, Z as RichTextAiPanelComponent, _ as RichTextAllowDirective, $ as RichTextAllowHost, a0 as RichTextColorsButtonComponent, a1 as RichTextColorsDirective, a2 as RichTextCommandRegistry, a3 as RichTextEditorAddonHost, a4 as RichTextEditorComponent, a5 as RichTextEmojiButtonComponent, a6 as RichTextEmojiDirective, a7 as RichTextFileImportButtonComponent, a8 as RichTextFileImportDirective, a9 as RichTextFileImportOverlayComponent, aa as RichTextHistoryDirective, ab as RichTextHistoryPanelComponent, ac as RichTextImageResizerComponent, ad as RichTextImagesButtonComponent, ae as RichTextImagesDirective, af as RichTextImagesOverlayComponent, ag as RichTextLinksButtonComponent, ah as RichTextLinksDirective, ai as RichTextLinksFormComponent, aj as RichTextMarkdownService, ak as RichTextMentionPopoverComponent, al as RichTextMentionsDirective, am as RichTextOutlineDirective, an as RichTextOutlinePanelComponent, ao as RichTextPasteNormalizerService, ap as RichTextSanitizerService, aq as RichTextSlashCommandsDirective, ar as RichTextSlashCommandsMenuComponent, as as RichTextTablesButtonComponent, at as RichTextTablesDirective, au as RichTextToolbarComponent, av as RichTextToolbarViewContext, aw as RichTextTypographyButtonComponent, ax as RichTextTypographyDirective, ay as TEXT_STYLE_OPTIONS, az as TOOLBAR_BUTTONS, aA as TRANSPARENT_PIXEL, aB as addonSetting, aC as anchorOverlay, aD as applyImageAlignment, aE as applyStarterStyle, aF as assertFlatParams, aG as bindRichTextActions, aH as blockquoteDepthOf, aI as buildDefaultSlashCommands, aJ as buildEntityInsertNode, aK as buildEntityRenderContext, aL as buildFindIndex, aM as buildLineIndex, aN as caretPosition, aO as classifyImport, aP as compileFindRegex, aQ as computeSeedStyleString, aR as containsCssUrl, aS as createImageElement, aT as cssFunctionCalls, aU as dataUrlToFile, aV as decodeCssEscapes, aW as detectTrigger, aX as directionOf, aY as dragHasSupportedDocument, aZ as extractCssUrls, a_ as flattenIntoRowText, a$ as hasUnsafeCssFunction, b0 as holdsNothing, b1 as hostOf, b2 as hoverCardAction, b3 as hoverCardHandlers, b4 as isCombinedOnElement, b5 as isHostAllowed, b6 as isHostBearingUrl, b7 as isInlineHoldingBlock, b8 as isLineOwner, b9 as isNestedList, ba as isPdfHeader, bb as isPhrasing, bc as isRichTextEmpty, bd as isSupportedDocumentFile, be as isZipHeader, bf as labelBlockedImages, bg as lastOwnInlineNode, bh as lineAbove, bi as lineBelow, bj as lineIsEmpty, bk as lineIsTextOnly, bl as lineKeepsItsElement, bm as lineOf, bn as lineOwnNodes, bo as lineTagIsFixed, bp as lineText, bq as linesBetween, br as linesMayJoin, bs as linkedPreviewDialogAction, bt as linkedPreviewDialogHandlers, bu as matchBlockInputRule, bv as matchInlineInputRule, bw as mountTopLayer, bx as nodeShowsNothing, by as normalizeHostEntry, bz as offsetToPosition, bA as openDialogAction, bB as openDialogHandlers, bC as parseImageSize, bD as placeCaretIn, bE as placeImageAtSelection, bF as positionAfterLine, bG as rangeShowsNothing, bH as readActions, bI as readFileAsDataUrl, bJ as remoteHostOf, bK as removeAction, bL as reportResourceDecisions, bM as resolveFromPage, bN as richTextHasMedia, bO as richTextMaxLength, bP as richTextMinWords, bQ as richTextRequired, bR as richTextVisibleText, bS as rowRunsOf, bT as selectTriggerRange, bU as separateListKinds, bV as simpleHash, bW as stripCssComments, bX as stripStyleIfMatches, bY as structureAround, bZ as validateActionId, b_ as validateActionParams, b$ as writeAction, c0 as writeCombined } from './gilav21-shadcn-angular-rte-gilav21-shadcn-angular-rte-
|
|
1
|
+
export { A as ACTION_ATTRS, a as ACTION_PARAMS, b as AddonSlotRegistry, D as DEFAULT_COLOR_PALETTE, c as DEFAULT_FONT_FAMILIES, d as DEFAULT_HIGHLIGHT_PALETTE, e as DEFAULT_LINK_SCHEMES, f as DEFAULT_TOOLBAR_ITEMS, g as DOCUMENT_IMPORT_ACCEPT, h as DOCX_MIME, E as EMPTINESS_FIXTURES, F as FIND_MAX_PAINTED_RECTS, j as FIND_MAX_QUERY_LENGTH, H as HEADER_BYTES, I as IMAGE_IMPORT_ACCEPT, k as INLINE_RULE_LOOKBEHIND, M as MAX_NESTING_DEPTH, P as PDF_MIME, l as PresetDialogComponent, m as PresetHoverCardComponent, R as RICH_TEXT_ACTIONS_SANITIZER_RULES, n as RICH_TEXT_AI_CONTEXT, o as RICH_TEXT_AI_LOCALES, p as RICH_TEXT_COLORS_LOCALES, q as RICH_TEXT_COLOR_BUTTON_CONTEXT, r as RICH_TEXT_EMOJI_CONTEXT, s as RICH_TEXT_EMOJI_LOCALES, t as RICH_TEXT_FILE_IMPORT_BUTTON_CONTEXT, u as RICH_TEXT_FILE_IMPORT_LOCALES, v as RICH_TEXT_HISTORY_LOCALES, w as RICH_TEXT_IMAGES_BUTTON_CONTEXT, x as RICH_TEXT_IMAGES_LOCALES, y as RICH_TEXT_LINKS_BUTTON_CONTEXT, z as RICH_TEXT_LINKS_LOCALES, B as RICH_TEXT_LOCALES, C as RICH_TEXT_MENTIONS_LOCALES, G as RICH_TEXT_OUTLINE_CONTEXT, J as RICH_TEXT_OUTLINE_LOCALES, K as RICH_TEXT_PROSE_CLASSES, L as RICH_TEXT_SHORTCUT_DEFINITIONS, N as RICH_TEXT_SLASH_COMMANDS_LOCALES, O as RICH_TEXT_TABLES_BUTTON_CONTEXT, Q as RICH_TEXT_TABLES_LOCALES, S as RICH_TEXT_TYPOGRAPHY_BUTTON_CONTEXT, T as RICH_TEXT_TYPOGRAPHY_LOCALES, U as RTE_FULL, V as RichTextActionsBindDirective, W as RichTextActionsDirective, X as RichTextAiChipComponent, Y as RichTextAiDirective, Z as RichTextAiPanelComponent, _ as RichTextAllowDirective, $ as RichTextAllowHost, a0 as RichTextColorsButtonComponent, a1 as RichTextColorsDirective, a2 as RichTextCommandRegistry, a3 as RichTextEditorAddonHost, a4 as RichTextEditorComponent, a5 as RichTextEmojiButtonComponent, a6 as RichTextEmojiDirective, a7 as RichTextFileImportButtonComponent, a8 as RichTextFileImportDirective, a9 as RichTextFileImportOverlayComponent, aa as RichTextHistoryDirective, ab as RichTextHistoryPanelComponent, ac as RichTextImageResizerComponent, ad as RichTextImagesButtonComponent, ae as RichTextImagesDirective, af as RichTextImagesOverlayComponent, ag as RichTextLinksButtonComponent, ah as RichTextLinksDirective, ai as RichTextLinksFormComponent, aj as RichTextMarkdownService, ak as RichTextMentionPopoverComponent, al as RichTextMentionsDirective, am as RichTextOutlineDirective, an as RichTextOutlinePanelComponent, ao as RichTextPasteNormalizerService, ap as RichTextSanitizerService, aq as RichTextSlashCommandsDirective, ar as RichTextSlashCommandsMenuComponent, as as RichTextTablesButtonComponent, at as RichTextTablesDirective, au as RichTextToolbarComponent, av as RichTextToolbarViewContext, aw as RichTextTypographyButtonComponent, ax as RichTextTypographyDirective, ay as TEXT_STYLE_OPTIONS, az as TOOLBAR_BUTTONS, aA as TRANSPARENT_PIXEL, aB as addonSetting, aC as anchorOverlay, aD as applyImageAlignment, aE as applyStarterStyle, aF as assertFlatParams, aG as bindRichTextActions, aH as blockquoteDepthOf, aI as buildDefaultSlashCommands, aJ as buildEntityInsertNode, aK as buildEntityRenderContext, aL as buildFindIndex, aM as buildLineIndex, aN as caretPosition, aO as classifyImport, aP as compileFindRegex, aQ as computeSeedStyleString, aR as containsCssUrl, aS as createImageElement, aT as cssFunctionCalls, aU as dataUrlToFile, aV as decodeCssEscapes, aW as detectTrigger, aX as directionOf, aY as dragHasSupportedDocument, aZ as extractCssUrls, a_ as flattenIntoRowText, a$ as hasUnsafeCssFunction, b0 as holdsNothing, b1 as hostOf, b2 as hoverCardAction, b3 as hoverCardHandlers, b4 as isCombinedOnElement, b5 as isHostAllowed, b6 as isHostBearingUrl, b7 as isInlineHoldingBlock, b8 as isLineOwner, b9 as isNestedList, ba as isPdfHeader, bb as isPhrasing, bc as isRichTextEmpty, bd as isSupportedDocumentFile, be as isZipHeader, bf as labelBlockedImages, bg as lastOwnInlineNode, bh as lineAbove, bi as lineBelow, bj as lineIsEmpty, bk as lineIsTextOnly, bl as lineKeepsItsElement, bm as lineOf, bn as lineOwnNodes, bo as lineTagIsFixed, bp as lineText, bq as linesBetween, br as linesMayJoin, bs as linkedPreviewDialogAction, bt as linkedPreviewDialogHandlers, bu as matchBlockInputRule, bv as matchInlineInputRule, bw as mountTopLayer, bx as nodeShowsNothing, by as normalizeHostEntry, bz as offsetToPosition, bA as openDialogAction, bB as openDialogHandlers, bC as parseImageSize, bD as placeCaretIn, bE as placeImageAtSelection, bF as positionAfterLine, bG as rangeShowsNothing, bH as readActions, bI as readFileAsDataUrl, bJ as remoteHostOf, bK as removeAction, bL as reportResourceDecisions, bM as resolveFromPage, bN as richTextHasMedia, bO as richTextMaxLength, bP as richTextMinWords, bQ as richTextRequired, bR as richTextVisibleText, bS as rowRunsOf, bT as selectTriggerRange, bU as separateListKinds, bV as simpleHash, bW as stripCssComments, bX as stripStyleIfMatches, bY as structureAround, bZ as validateActionId, b_ as validateActionParams, b$ as writeAction, c0 as writeCombined } from './gilav21-shadcn-angular-rte-gilav21-shadcn-angular-rte-BFcfCqW4.mjs';
|
|
2
2
|
//# sourceMappingURL=gilav21-shadcn-angular-rte.mjs.map
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@gilav21/shadcn-angular-rte",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.2.0",
|
|
4
4
|
"description": "Compiled Angular rich-text editor from shadcn-angular: base editor + all 13 addons (RTE_FULL). Same ui-* selectors and inputs as the CLI copy model.",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"repository": {
|
|
@@ -17,7 +17,7 @@
|
|
|
17
17
|
],
|
|
18
18
|
"sideEffects": false,
|
|
19
19
|
"exports": {
|
|
20
|
-
"./
|
|
20
|
+
"./styles.css": "./styles.css",
|
|
21
21
|
"./package.json": {
|
|
22
22
|
"default": "./package.json"
|
|
23
23
|
},
|
|
@@ -26,6 +26,10 @@
|
|
|
26
26
|
"default": "./fesm2022/gilav21-shadcn-angular-rte.mjs"
|
|
27
27
|
}
|
|
28
28
|
},
|
|
29
|
+
"schematics": "./schematics/collection.json",
|
|
30
|
+
"ng-add": {
|
|
31
|
+
"save": "dependencies"
|
|
32
|
+
},
|
|
29
33
|
"peerDependencies": {
|
|
30
34
|
"@angular/common": ">=20.0.0 <22.0.0",
|
|
31
35
|
"@angular/core": ">=20.0.0 <22.0.0",
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
{
|
|
2
|
+
"$schema": "../../../node_modules/@angular-devkit/schematics/collection-schema.json",
|
|
3
|
+
"schematics": {
|
|
4
|
+
"ng-add": {
|
|
5
|
+
"description": "Register the package stylesheet in angular.json.",
|
|
6
|
+
"factory": "./ng-add/index.cjs#ngAdd",
|
|
7
|
+
"schema": "./ng-add/schema.json"
|
|
8
|
+
}
|
|
9
|
+
}
|
|
10
|
+
}
|
|
@@ -0,0 +1,169 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* `ng add @gilav21/shadcn-angular-<package>` — registers the package's compiled
|
|
5
|
+
* stylesheet in angular.json, the only setup a package consumer needs.
|
|
6
|
+
*
|
|
7
|
+
* Shared verbatim by every compiled package (the stylesheet path is derived
|
|
8
|
+
* from the package's own name), and written against the plain schematic
|
|
9
|
+
* `Tree` / `context` contract so it needs no `@angular-devkit/*` dependency.
|
|
10
|
+
*/
|
|
11
|
+
|
|
12
|
+
const WORKSPACE_FILE = 'angular.json';
|
|
13
|
+
|
|
14
|
+
/** Builder targets whose `styles` option decides what CSS a project loads. */
|
|
15
|
+
const STYLED_TARGETS = ['build', 'test'];
|
|
16
|
+
|
|
17
|
+
/** @param {string} packageName */
|
|
18
|
+
function stylesheetFor(packageName) {
|
|
19
|
+
return `${packageName}/styles.css`;
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
/** @param {unknown} entry */
|
|
23
|
+
function entryPath(entry) {
|
|
24
|
+
if (typeof entry === 'string') return entry;
|
|
25
|
+
if (entry && typeof entry === 'object' && 'input' in entry) return String(entry.input);
|
|
26
|
+
return '';
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
/**
|
|
30
|
+
* The projects to configure: the one named, or every application.
|
|
31
|
+
* @param {Record<string, any>} projects
|
|
32
|
+
* @param {string | undefined} requested
|
|
33
|
+
*/
|
|
34
|
+
function targetProjects(projects, requested) {
|
|
35
|
+
if (requested) {
|
|
36
|
+
if (!projects[requested]) throw new Error(`Project "${requested}" does not exist in ${WORKSPACE_FILE}.`);
|
|
37
|
+
return [requested];
|
|
38
|
+
}
|
|
39
|
+
return Object.keys(projects).filter((name) => projects[name].projectType === 'application');
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
/**
|
|
43
|
+
* Prepends the stylesheet to one options block, unless it is already there.
|
|
44
|
+
* First in the list, so the app's own stylesheets load after it and win ties.
|
|
45
|
+
*
|
|
46
|
+
* @param {Record<string, any> | undefined} options a target's `options` or one configuration's
|
|
47
|
+
* @param {string} stylesheet
|
|
48
|
+
* @returns {boolean} whether anything changed
|
|
49
|
+
*/
|
|
50
|
+
function prependTo(options, stylesheet) {
|
|
51
|
+
if (!options || !Array.isArray(options.styles)) return false;
|
|
52
|
+
if (options.styles.some((entry) => entryPath(entry) === stylesheet)) return false;
|
|
53
|
+
options.styles = [stylesheet, ...options.styles];
|
|
54
|
+
return true;
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
/**
|
|
58
|
+
* Registers the stylesheet on one target: its `options`, plus every
|
|
59
|
+
* configuration that declares its OWN `styles`.
|
|
60
|
+
*
|
|
61
|
+
* @param {Record<string, any>} target one builder target (mutated)
|
|
62
|
+
* @param {string} stylesheet
|
|
63
|
+
* @param {string} label `<project>:<target>`
|
|
64
|
+
* @returns {string[]} labels that changed
|
|
65
|
+
*/
|
|
66
|
+
function registerOnTarget(target, stylesheet, label) {
|
|
67
|
+
const changed = [];
|
|
68
|
+
target.options ??= {};
|
|
69
|
+
target.options.styles ??= [];
|
|
70
|
+
if (prependTo(target.options, stylesheet)) changed.push(label);
|
|
71
|
+
|
|
72
|
+
for (const [configName, config] of Object.entries(target.configurations ?? {})) {
|
|
73
|
+
if (prependTo(config, stylesheet)) changed.push(`${label}:${configName}`);
|
|
74
|
+
}
|
|
75
|
+
return changed;
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
/**
|
|
79
|
+
* Registers the stylesheet on each project's build and test targets, and on
|
|
80
|
+
* every configuration that declares its OWN `styles`.
|
|
81
|
+
*
|
|
82
|
+
* Angular does not merge a configuration's `styles` into the target's — it
|
|
83
|
+
* replaces the list. So a `production` configuration that sets `styles` would
|
|
84
|
+
* build without the package stylesheet, and the failure is silent: an unstyled
|
|
85
|
+
* component in a production bundle, with no error anywhere.
|
|
86
|
+
*
|
|
87
|
+
* Idempotent, and a target with no `styles` at all gets the list created.
|
|
88
|
+
*
|
|
89
|
+
* @param {Record<string, any>} workspace parsed angular.json (mutated)
|
|
90
|
+
* @param {string} packageName
|
|
91
|
+
* @param {string} [project]
|
|
92
|
+
* @returns {string[]} `<project>:<target>` / `<project>:<target>:<configuration>` labels that changed
|
|
93
|
+
*/
|
|
94
|
+
function addStylesheet(workspace, packageName, project) {
|
|
95
|
+
const stylesheet = stylesheetFor(packageName);
|
|
96
|
+
const projects = workspace.projects ?? {};
|
|
97
|
+
const changed = [];
|
|
98
|
+
|
|
99
|
+
for (const name of targetProjects(projects, project)) {
|
|
100
|
+
const targets = projects[name].architect ?? projects[name].targets ?? {};
|
|
101
|
+
for (const targetName of STYLED_TARGETS) {
|
|
102
|
+
const target = targets[targetName];
|
|
103
|
+
if (target) changed.push(...registerOnTarget(target, stylesheet, `${name}:${targetName}`));
|
|
104
|
+
}
|
|
105
|
+
}
|
|
106
|
+
return changed;
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
/**
|
|
110
|
+
* Reads angular.json, or explains the one manual edit that replaces this
|
|
111
|
+
* schematic.
|
|
112
|
+
*
|
|
113
|
+
* The Angular CLI tolerates comments in angular.json; `JSON.parse` does not.
|
|
114
|
+
* Rather than re-implement JSON-with-comments — a parser with more edge cases
|
|
115
|
+
* (markers inside strings, escapes) than this whole schematic — an unparsable
|
|
116
|
+
* workspace fails with the exact edit to make by hand.
|
|
117
|
+
*
|
|
118
|
+
* @param {string} raw
|
|
119
|
+
* @param {string} stylesheet
|
|
120
|
+
*/
|
|
121
|
+
function parseWorkspace(raw, stylesheet) {
|
|
122
|
+
try {
|
|
123
|
+
return JSON.parse(raw);
|
|
124
|
+
} catch {
|
|
125
|
+
throw new Error(
|
|
126
|
+
`Could not read ${WORKSPACE_FILE} as JSON (comments are not supported here). ` +
|
|
127
|
+
`Add "${stylesheet}" to the "styles" array of your app's build and test targets by hand — ` +
|
|
128
|
+
'that is all this schematic does.',
|
|
129
|
+
);
|
|
130
|
+
}
|
|
131
|
+
}
|
|
132
|
+
|
|
133
|
+
/**
|
|
134
|
+
* The schematic body over an injected tree/logger, so it is testable without
|
|
135
|
+
* the Angular CLI.
|
|
136
|
+
*
|
|
137
|
+
* @param {{ exists(p: string): boolean, read(p: string): Buffer | null, overwrite(p: string, c: string): void }} tree
|
|
138
|
+
* @param {{ info(m: string): void, warn(m: string): void }} logger
|
|
139
|
+
* @param {string} packageName
|
|
140
|
+
* @param {string} [project]
|
|
141
|
+
*/
|
|
142
|
+
function runNgAdd(tree, logger, packageName, project) {
|
|
143
|
+
const stylesheet = stylesheetFor(packageName);
|
|
144
|
+
if (!tree.exists(WORKSPACE_FILE)) {
|
|
145
|
+
throw new Error(`No ${WORKSPACE_FILE} found. Add "${stylesheet}" to your app's styles manually.`);
|
|
146
|
+
}
|
|
147
|
+
|
|
148
|
+
const workspace = parseWorkspace(String(tree.read(WORKSPACE_FILE)), stylesheet);
|
|
149
|
+
const changed = addStylesheet(workspace, packageName, project);
|
|
150
|
+
if (changed.length === 0) {
|
|
151
|
+
logger.info(`${stylesheet} is already registered — nothing to do.`);
|
|
152
|
+
return;
|
|
153
|
+
}
|
|
154
|
+
|
|
155
|
+
tree.overwrite(WORKSPACE_FILE, `${JSON.stringify(workspace, null, 2)}\n`);
|
|
156
|
+
logger.info(`Added ${stylesheet} to ${changed.join(', ')}.`);
|
|
157
|
+
}
|
|
158
|
+
|
|
159
|
+
/** Schematic factory referenced by collection.json. */
|
|
160
|
+
function ngAdd(options) {
|
|
161
|
+
return (tree, context) => {
|
|
162
|
+
// Resolved at run time from the installed package, so one file serves every package.
|
|
163
|
+
const { name } = require('../../package.json');
|
|
164
|
+
runNgAdd(tree, context.logger, name, options?.project);
|
|
165
|
+
return tree;
|
|
166
|
+
};
|
|
167
|
+
}
|
|
168
|
+
|
|
169
|
+
module.exports = { addStylesheet, runNgAdd, ngAdd };
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
{
|
|
2
|
+
"$schema": "http://json-schema.org/schema",
|
|
3
|
+
"$id": "shadcn-angular-package-ng-add",
|
|
4
|
+
"title": "shadcn-angular package ng-add",
|
|
5
|
+
"type": "object",
|
|
6
|
+
"properties": {
|
|
7
|
+
"project": {
|
|
8
|
+
"type": "string",
|
|
9
|
+
"description": "The project to configure. Defaults to every application in the workspace.",
|
|
10
|
+
"$default": { "$source": "projectName" }
|
|
11
|
+
}
|
|
12
|
+
}
|
|
13
|
+
}
|