Skip to content

Commit 2507fc8

Browse files
authored
feat(blazorui): add PdfReader component bitfoundation#8991 (bitfoundation#9078)
1 parent 8cbc4d0 commit 2507fc8

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

68 files changed

+5855
-39
lines changed

.github/workflows/bit.ci.yml

+2-2
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ jobs:
3636

3737
- name: Run BeforeBuildTasks
3838
continue-on-error: true # Error MSB4057, not all csproj files have BeforeBuildTasks target.
39-
run: dotnet build src/Bit-CI-release.sln -t:BeforeBuildTasks -m:1
39+
run: dotnet build src/Bit-CI-release.sln -t:BeforeBuildTasks -m:1 -f net8.0
4040

4141
- name: MSBuild prerelease
4242
run: dotnet build src/Bit-CI-release.sln
@@ -78,7 +78,7 @@ jobs:
7878

7979
- name: Run BeforeBuildTasks
8080
continue-on-error: true # Error MSB4057, not all csproj files have BeforeBuildTasks target.
81-
run: dotnet build src/Bit-CI.sln -t:BeforeBuildTasks -m:1
81+
run: dotnet build src/Bit-CI.sln -t:BeforeBuildTasks -m:1 -f net8.0
8282

8383
- name: Build
8484
run: dotnet build src/Bit-CI.sln -p:WarningLevel=0 -p:RunCodeAnalysis=false

.github/workflows/bit.full.ci.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -174,7 +174,7 @@ jobs:
174174
175175
- name: Run BeforeBuildTasks
176176
continue-on-error: true # Error MSB4057, not all csproj files have BeforeBuildTasks target.
177-
run: dotnet build src/Bit-CI-release.sln -t:BeforeBuildTasks -m:1
177+
run: dotnet build src/Bit-CI-release.sln -t:BeforeBuildTasks -m:1 -f net8.0
178178

179179
- name: Release build bit blazor ui + butil + bswup + besql + bup + code analyzers + source generators
180180
run: dotnet build src/Bit-CI-release.sln -c Release

src/BlazorUI/Bit.BlazorUI.Extras/Bit.BlazorUI.Extras.csproj

+3-3
Original file line numberDiff line numberDiff line change
@@ -58,9 +58,9 @@
5858
</ItemGroup>
5959

6060
<Target Name="BeforeBuildTasks" AfterTargets="CoreCompile" Condition="'$(TargetFramework)' == 'net8.0'">
61-
<CallTarget Targets="InstallNodejsDependencies"/>
62-
<CallTarget Targets="BuildJavaScript"/>
63-
<CallTarget Targets="BuildCss"/>
61+
<CallTarget Targets="InstallNodejsDependencies" />
62+
<CallTarget Targets="BuildJavaScript" />
63+
<CallTarget Targets="BuildCss" />
6464
</Target>
6565

6666
<Target Name="InstallNodejsDependencies" Inputs="package.json" Outputs="node_modules\.package-lock.json">

src/BlazorUI/Bit.BlazorUI.Extras/Components/Chart/BitChart.razor.cs

+5-5
Original file line numberDiff line numberDiff line change
@@ -122,15 +122,15 @@ protected override async Task OnAfterRenderAsync(bool firstRender)
122122
scripts.AddRange(DateAdapterScripts);
123123
}
124124

125-
await _js.InitChartJs(scripts);
125+
await _js.BitChartJsInitChartJs(scripts);
126126

127-
await _js.SetupChart(Config);
127+
await _js.BitChartJsSetupChart(Config);
128128

129129
await SetupCompletedCallback.InvokeAsync(this);
130130
}
131131
else
132132
{
133-
await _js.SetupChart(Config);
133+
await _js.BitChartJsSetupChart(Config);
134134
}
135135
}
136136

@@ -142,7 +142,7 @@ protected override async Task OnAfterRenderAsync(bool firstRender)
142142
/// </summary>
143143
public Task Update()
144144
{
145-
return _js.UpdateChart(Config).AsTask();
145+
return _js.BitChartJsUpdateChart(Config).AsTask();
146146
}
147147

148148
public async ValueTask DisposeAsync()
@@ -158,7 +158,7 @@ protected virtual async ValueTask DisposeAsync(bool disposing)
158158

159159
try
160160
{
161-
await _js.RemoveChart(Config?.CanvasId);
161+
await _js.BitChartJsRemoveChart(Config?.CanvasId);
162162
}
163163
catch (JSDisconnectedException) { } // we can ignore this exception here
164164
}

src/BlazorUI/Bit.BlazorUI.Extras/Components/Chart/Interop/BitChartJsInterop.cs src/BlazorUI/Bit.BlazorUI.Extras/Components/Chart/JsInterop/BitChartJsInterop.cs

+18-16
Original file line numberDiff line numberDiff line change
@@ -20,12 +20,12 @@ internal static class BitChartJsInterop
2020
Converters = { new IsoDateTimeConverter() }
2121
};
2222

23-
public static ValueTask InitChartJs(this IJSRuntime jsRuntime, IEnumerable<string> scripts)
23+
public static ValueTask BitChartJsInitChartJs(this IJSRuntime jsRuntime, IEnumerable<string> scripts)
2424
{
2525
return jsRuntime.InvokeVoidAsync("BitBlazorUI.BitChart.initChartJs", scripts);
2626
}
2727

28-
public static ValueTask RemoveChart(this IJSRuntime jsRuntime, string canvasId)
28+
public static ValueTask BitChartJsRemoveChart(this IJSRuntime jsRuntime, string canvasId)
2929
{
3030
return jsRuntime.InvokeVoidAsync("BitBlazorUI.BitChart.removeChart", canvasId);
3131
}
@@ -36,13 +36,28 @@ public static ValueTask RemoveChart(this IJSRuntime jsRuntime, string canvasId)
3636
/// <param name="jsRuntime"></param>
3737
/// <param name="chartConfig">The config for the new chart.</param>
3838
/// <returns></returns>
39-
public static ValueTask<bool> SetupChart(this IJSRuntime jsRuntime, BitChartConfigBase chartConfig)
39+
public static ValueTask<bool> BitChartJsSetupChart(this IJSRuntime jsRuntime, BitChartConfigBase chartConfig)
4040
{
4141
var dynParam = StripNulls(chartConfig);
4242
Dictionary<string, object> param = ConvertExpandoObjectToDictionary(dynParam);
4343
return jsRuntime.InvokeAsync<bool>("BitBlazorUI.BitChart.setupChart", param);
4444
}
4545

46+
/// <summary>
47+
/// Update an existing chart. Make sure that the Chart with this <see cref="BitChartConfigBase.CanvasId"/> already exists.
48+
/// </summary>
49+
/// <param name="jsRuntime"></param>
50+
/// <param name="chartConfig">The updated config of the chart you want to update.</param>
51+
/// <returns></returns>
52+
public static ValueTask<bool> BitChartJsUpdateChart(this IJSRuntime jsRuntime, BitChartConfigBase chartConfig)
53+
{
54+
var dynParam = StripNulls(chartConfig);
55+
Dictionary<string, object> param = ConvertExpandoObjectToDictionary(dynParam);
56+
return jsRuntime.InvokeAsync<bool>("BitBlazorUI.BitChart.updateChart", param);
57+
}
58+
59+
60+
4661
/// <summary>
4762
/// This method is specifically used to convert an <see cref="ExpandoObject"/> with a Tree structure to a <c>Dictionary&lt;string, object&gt;</c>.
4863
/// </summary>
@@ -85,19 +100,6 @@ private static Dictionary<string, object> RecursivelyConvertIDictToDict(IDiction
85100
}
86101
);
87102

88-
/// <summary>
89-
/// Update an existing chart. Make sure that the Chart with this <see cref="BitChartConfigBase.CanvasId"/> already exists.
90-
/// </summary>
91-
/// <param name="jsRuntime"></param>
92-
/// <param name="chartConfig">The updated config of the chart you want to update.</param>
93-
/// <returns></returns>
94-
public static ValueTask<bool> UpdateChart(this IJSRuntime jsRuntime, BitChartConfigBase chartConfig)
95-
{
96-
var dynParam = StripNulls(chartConfig);
97-
Dictionary<string, object> param = ConvertExpandoObjectToDictionary(dynParam);
98-
return jsRuntime.InvokeAsync<bool>("BitBlazorUI.BitChart.updateChart", param);
99-
}
100-
101103
/// <summary>
102104
/// Returns an object that is equivalent to the given parameter but without any null members AND it preserves <see cref="IBitChartMethodHandler"/>s intact.
103105
/// <para>Preserving <see cref="IBitChartMethodHandler"/> members is important because they might be <see cref="BitChartDelegateHandler{T}"/> instances which contain
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,216 @@
1+
declare type AnnotationElementParameters = {
2+
data: Object;
3+
layer: HTMLDivElement;
4+
linkService: IPDFLinkService;
5+
downloadManager?: IDownloadManager | undefined;
6+
annotationStorage?: AnnotationStorage | undefined;
7+
/**
8+
* - Path for image resources, mainly
9+
* for annotation icons. Include trailing slash.
10+
*/
11+
imageResourcesPath?: string | undefined;
12+
renderForms: boolean;
13+
svgFactory: Object;
14+
enableScripting?: boolean | undefined;
15+
hasJSActions?: boolean | undefined;
16+
fieldObjects?: Object | undefined;
17+
};
18+
declare type AnnotationLayerParameters = {
19+
viewport: PageViewport;
20+
div: HTMLDivElement;
21+
annotations: any[];
22+
page: PDFPageProxy;
23+
linkService: IPDFLinkService;
24+
downloadManager?: IDownloadManager | undefined;
25+
annotationStorage?: AnnotationStorage | undefined;
26+
/**
27+
* - Path for image resources, mainly
28+
* for annotation icons. Include trailing slash.
29+
*/
30+
imageResourcesPath?: string | undefined;
31+
renderForms: boolean;
32+
/**
33+
* - Enable embedded script execution.
34+
*/
35+
enableScripting?: boolean | undefined;
36+
/**
37+
* - Some fields have JS actions.
38+
* The default value is `false`.
39+
*/
40+
hasJSActions?: boolean | undefined;
41+
fieldObjects?: {
42+
[x: string]: Object[];
43+
} | null | undefined;
44+
annotationCanvasMap?: Map<string, HTMLCanvasElement> | undefined;
45+
accessibilityManager?: TextAccessibilityManager | undefined;
46+
annotationEditorUIManager?: AnnotationEditorUIManager;
47+
structTreeLayer?: StructTreeLayerBuilder | undefined;
48+
};
49+
/**
50+
* @typedef {Object} AnnotationLayerParameters
51+
* @property {PageViewport} viewport
52+
* @property {HTMLDivElement} div
53+
* @property {Array} annotations
54+
* @property {PDFPageProxy} page
55+
* @property {IPDFLinkService} linkService
56+
* @property {IDownloadManager} [downloadManager]
57+
* @property {AnnotationStorage} [annotationStorage]
58+
* @property {string} [imageResourcesPath] - Path for image resources, mainly
59+
* for annotation icons. Include trailing slash.
60+
* @property {boolean} renderForms
61+
* @property {boolean} [enableScripting] - Enable embedded script execution.
62+
* @property {boolean} [hasJSActions] - Some fields have JS actions.
63+
* The default value is `false`.
64+
* @property {Object<string, Array<Object>> | null} [fieldObjects]
65+
* @property {Map<string, HTMLCanvasElement>} [annotationCanvasMap]
66+
* @property {TextAccessibilityManager} [accessibilityManager]
67+
* @property {AnnotationEditorUIManager} [annotationEditorUIManager]
68+
* @property {StructTreeLayerBuilder} [structTreeLayer]
69+
*/
70+
/**
71+
* Manage the layer containing all the annotations.
72+
*/
73+
declare class AnnotationLayer {
74+
constructor({ div, accessibilityManager, annotationCanvasMap, annotationEditorUIManager, page, viewport, structTreeLayer, }: {
75+
div: any;
76+
accessibilityManager: any;
77+
annotationCanvasMap: any;
78+
annotationEditorUIManager: any;
79+
page: any;
80+
viewport: any;
81+
structTreeLayer: any;
82+
});
83+
div: any;
84+
page: any;
85+
viewport: any;
86+
zIndex: number;
87+
_annotationEditorUIManager: any;
88+
popupShow: any[] | undefined;
89+
hasEditableAnnotations(): boolean;
90+
/**
91+
* Render a new annotation layer with all annotation elements.
92+
*
93+
* @param {AnnotationLayerParameters} params
94+
* @memberof AnnotationLayer
95+
*/
96+
render(params: AnnotationLayerParameters): Promise<void>;
97+
/**
98+
* Update the annotation elements on existing annotation layer.
99+
*
100+
* @param {AnnotationLayerParameters} viewport
101+
* @memberof AnnotationLayer
102+
*/
103+
update({ viewport }: AnnotationLayerParameters): void;
104+
getEditableAnnotations(): any[];
105+
getEditableAnnotation(id: any): any;
106+
}
107+
declare class FreeTextAnnotationElement extends AnnotationElement {
108+
constructor(parameters: any);
109+
textContent: any;
110+
textPosition: any;
111+
annotationEditorType: number;
112+
render(): HTMLElement | undefined;
113+
}
114+
declare class HighlightAnnotationElement extends AnnotationElement {
115+
constructor(parameters: any);
116+
annotationEditorType: number;
117+
render(): HTMLElement | undefined;
118+
}
119+
declare class InkAnnotationElement extends AnnotationElement {
120+
constructor(parameters: any);
121+
containerClassName: string;
122+
svgElementName: string;
123+
annotationEditorType: number;
124+
render(): HTMLElement | undefined;
125+
getElementsToTriggerPopup(): any[];
126+
}
127+
declare class StampAnnotationElement extends AnnotationElement {
128+
constructor(parameters: any);
129+
annotationEditorType: number;
130+
render(): HTMLElement | undefined;
131+
}
132+
import { AnnotationStorage } from "./annotation_storage.js";
133+
declare class AnnotationElement {
134+
static _hasPopupData({ titleObj, contentsObj, richText }: {
135+
titleObj: any;
136+
contentsObj: any;
137+
richText: any;
138+
}): boolean;
139+
constructor(parameters: any, { isRenderable, ignoreBorder, createQuadrilaterals, }?: {
140+
isRenderable?: boolean | undefined;
141+
ignoreBorder?: boolean | undefined;
142+
createQuadrilaterals?: boolean | undefined;
143+
});
144+
isRenderable: boolean;
145+
data: any;
146+
layer: any;
147+
linkService: any;
148+
downloadManager: any;
149+
imageResourcesPath: any;
150+
renderForms: any;
151+
svgFactory: any;
152+
annotationStorage: any;
153+
enableScripting: any;
154+
hasJSActions: any;
155+
_fieldObjects: any;
156+
parent: any;
157+
container: HTMLElement | undefined;
158+
get _isEditable(): any;
159+
get hasPopupData(): boolean;
160+
updateEdited(params: any): void;
161+
resetEdited(): void;
162+
/**
163+
* Create an empty container for the annotation's HTML element.
164+
*
165+
* @private
166+
* @param {boolean} ignoreBorder
167+
* @memberof AnnotationElement
168+
* @returns {HTMLElement} A section element.
169+
*/
170+
private _createContainer;
171+
setRotation(angle: any, container?: HTMLElement | undefined): void;
172+
get _commonActions(): any;
173+
_dispatchEventFromSandbox(actions: any, jsEvent: any): void;
174+
_setDefaultPropertiesFromJS(element: any): void;
175+
/**
176+
* Create quadrilaterals from the annotation's quadpoints.
177+
*
178+
* @private
179+
* @memberof AnnotationElement
180+
*/
181+
private _createQuadrilaterals;
182+
/**
183+
* Create a popup for the annotation's HTML element. This is used for
184+
* annotations that do not have a Popup entry in the dictionary, but
185+
* are of a type that works with popups (such as Highlight annotations).
186+
*
187+
* @private
188+
* @memberof AnnotationElement
189+
*/
190+
private _createPopup;
191+
/**
192+
* Render the annotation's HTML element(s).
193+
*
194+
* @public
195+
* @memberof AnnotationElement
196+
*/
197+
public render(): void;
198+
/**
199+
* @private
200+
* @returns {Array}
201+
*/
202+
private _getElementsByName;
203+
show(): void;
204+
hide(): void;
205+
/**
206+
* Get the HTML element(s) which can trigger a popup when clicked or hovered.
207+
*
208+
* @public
209+
* @memberof AnnotationElement
210+
* @returns {Array<HTMLElement>|HTMLElement} An array of elements or an
211+
* element.
212+
*/
213+
public getElementsToTriggerPopup(): Array<HTMLElement> | HTMLElement;
214+
addHighlightArea(): void;
215+
_editOnDoubleClick(): void;
216+
}

0 commit comments

Comments
 (0)