@gridify/editors 0.0.0-stage → 1.0.0-rc.1
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 +163 -0
- package/README.md +140 -2
- package/fesm2022/gridify-editors.mjs +2332 -0
- package/package.json +24 -3
- package/types/gridify-editors.d.ts +1781 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,163 @@
|
|
|
1
|
+
# GRIDIFY STUDIO SOFTWARE LICENSE AGREEMENT
|
|
2
|
+
|
|
3
|
+
**Version 1.0 — Effective Date: November 2026**
|
|
4
|
+
|
|
5
|
+
**Licensor:** Gridify Softworks s.r.o., Czech Republic
|
|
6
|
+
|
|
7
|
+
**Product:** Gridify Studio (including the Gridify Designer integrated application)
|
|
8
|
+
|
|
9
|
+
**Official Portal:** https://gridify.dev
|
|
10
|
+
|
|
11
|
+
### IMPORTANT NOTICE — PLEASE READ CAREFULLY
|
|
12
|
+
|
|
13
|
+
BY DOWNLOADING, INSTALLING, COPYING, ACCESSING, OR OTHERWISE USING GRIDIFY STUDIO OR THE GRIDIFY DESIGNER (COLLECTIVELY, THE "SOFTWARE"), YOU ("LICENSEE") AGREE TO BE BOUND BY THE TERMS OF THIS SOFTWARE LICENSE AGREEMENT ("AGREEMENT") ENTERED INTO WITH GRIDIFY SOFTWORKS S.R.O. ("LICENSOR"). IF YOU DO NOT AGREE TO THE TERMS, DO NOT INSTALL, COPY, OR USE THE SOFTWARE.
|
|
14
|
+
|
|
15
|
+
### 1. DEFINITIONS
|
|
16
|
+
|
|
17
|
+
* **"Licensor"** means **Gridify Softworks s.r.o.**, a limited liability company organized and existing under the laws of the Czech Republic.
|
|
18
|
+
|
|
19
|
+
* **"Software"** means the Gridify Studio platform and SDK, comprising runtime libraries, Angular UI components, docking containers, directives, themes, documentation, interactive tutorials, sample applications, and the **Gridify Designer** integrated visual application.
|
|
20
|
+
|
|
21
|
+
* **"Gridify Designer"** means the integrated visual RAD application provided with the Software, featuring unified, switchable editing environments including, but not limited to, the Layout Editor, Ribbon Editor, and Form Editor.
|
|
22
|
+
|
|
23
|
+
* **"Designated Developer"** means an identified individual software engineer, contractor, or architect employed or retained by Licensee who actively integrates, programs, builds, or designs applications utilizing the Software. Build servers, continuous integration systems, testers, and end users of Licensee's applications who do not write code with the Software are not Designated Developers.
|
|
24
|
+
|
|
25
|
+
* **"Community Edition"** means the free runtime packages and accompanying Gridify Designer application distributed for community, educational, and public web use.
|
|
26
|
+
|
|
27
|
+
* **"Public Web Application"** means a web-based application freely and publicly accessible over the open Internet without mandatory commercial subscription fees, paywalls, or closed member access controls. A free registration or sign-in that is open to anyone does not by itself make an application non-public. An application that displays advertising, solicits donations, sells goods or services, or is otherwise monetized is not a Public Web Application.
|
|
28
|
+
|
|
29
|
+
* **"Internal / Commercial Application"** means any software deployed within a corporate intranet, internal network, private VPN, multi-tenant B2B SaaS platform, or behind paid customer login walls, and any software that generates revenue or serves commercial purposes, regardless of whether its source code is published under an open-source license.
|
|
30
|
+
|
|
31
|
+
* **"Production Deployment"** means making an application built with the Software available to its intended users, internal or external, or using it in Licensee's operations. Development, test, and demonstration environments used only by Licensee's developers and testers are not Production Deployments.
|
|
32
|
+
|
|
33
|
+
* **"Covered Versions"** means the versions of the Software released by Licensor during an active commercial subscription (Section 2.3) or during the Pilot Period (Section 2.2), as applicable.
|
|
34
|
+
|
|
35
|
+
* **"Order Form"** means an ordering document, quotation, digital checkout confirmation, registration form, or invoice issued by Licensor or its authorized reseller specifying the purchased license tier, developer capacity, term, selected options, and applicable fees.
|
|
36
|
+
|
|
37
|
+
* **"Pilot Period"** means a period of twelve (12) consecutive months starting from the date an official Pilot License Key or written authorization is issued by Licensor.
|
|
38
|
+
|
|
39
|
+
### 2. LICENSING TIERS & GRANT OF RIGHTS
|
|
40
|
+
|
|
41
|
+
#### 2.1 Community Edition
|
|
42
|
+
|
|
43
|
+
* **Grant of License:** Subject to continuous compliance with this Agreement, Licensor grants Licensee a worldwide, non-exclusive, royalty-free, revocable license to access, integrate, and use the complete Software—comprising runtime packages and the unrestricted, fully functional **Gridify Designer** application with all editing modules—solely for the following permitted purposes:
|
|
44
|
+
|
|
45
|
+
1. Open-source software projects distributed under an OSI-approved license. This purpose covers the development and the public distribution of such projects. The deployment or use of an application, including an open-source one, by a company or other commercial organization for its internal operations or for commercial purposes is an Internal / Commercial Application and requires a commercial license. An open-source project that uses or includes the Software shall state that the Software is licensed under this Agreement and not under the project's own open-source license.
|
|
46
|
+
|
|
47
|
+
2. Non-commercial, educational, academic, and public institutional purposes (such as public libraries, museums, or state schools, including their internal systems and networks), and personal non-commercial projects.
|
|
48
|
+
|
|
49
|
+
3. Freely accessible, non-monetized Public Web Applications.
|
|
50
|
+
|
|
51
|
+
4. **Evaluation:** Any person or organization, including a team of developers at a company, may install the Software, try it out, build prototypes, and develop applications with it for an evaluation period of ninety (90) days per project, counted from the first use of the Software in that project. Evaluation never includes a Production Deployment. A commercial license under Section 2.2 or 2.3 is required at the end of the evaluation period or from the first Production Deployment of an Internal / Commercial Application, whichever comes first. Licensor may extend the evaluation period in writing. Upon registration, Licensor issues a free evaluation key valid for ninety (90) days, which suppresses the Community notice of the Software during the evaluation; without an evaluation key, or after it expires, the Software displays the Community notice in the browser console. An evaluation key does not authorize any Production Deployment.
|
|
52
|
+
|
|
53
|
+
* **Unrestricted Tooling:** Under the Community Edition, Gridify Designer is provided with full feature availability, including layout arrangement, ribbon authoring, form design, and code generation routines, subject only to the operational scopes defined herein.
|
|
54
|
+
|
|
55
|
+
* **Term & Revocation:** The Community Edition license remains effective only for as long as Licensee satisfies the qualifying criteria above. Licensor reserves the right to revoke or condition this license if the scope of use is breached or mischaracterized.
|
|
56
|
+
|
|
57
|
+
* **Restrictions:** The Community Edition may **not** be deployed behind private corporate intranets, closed enterprise workstations, internal business portals, or within commercial revenue-generating SaaS systems without an active commercial license tier. This restriction does not apply to the internal systems of the public institutions under item 2 above.
|
|
58
|
+
|
|
59
|
+
#### 2.2 Commercial Pilot License (1-Year Term)
|
|
60
|
+
|
|
61
|
+
* **Grant of License:** Subject to registration and verification by Licensor, Licensor grants Licensee a worldwide, non-exclusive, fully functional commercial license for the number of Designated Developers stated in its pilot authorization (the Pilot License Key or the written authorization of Licensor) to integrate, use Gridify Designer, and deploy Gridify Studio in production environments for a fixed term of twelve (12) consecutive months ("Pilot Period").
|
|
62
|
+
|
|
63
|
+
* **Selection:** Licensor selects the pilot participants at its sole discretion. It may limit the number of Designated Developers of a pilot license, or decline an application, without giving reasons.
|
|
64
|
+
|
|
65
|
+
* **Fees:** $0 USD for the initial Pilot Period.
|
|
66
|
+
|
|
67
|
+
* **Scope of Use:** Licensee is authorized to:
|
|
68
|
+
|
|
69
|
+
1. Use the complete Gridify Designer application (Layout, Ribbon, and Form editing modules) to design and generate production application code.
|
|
70
|
+
|
|
71
|
+
2. Integrate Gridify Studio into proprietary enterprise applications, internal corporate intranets, and VPN-restricted environments.
|
|
72
|
+
|
|
73
|
+
3. Deploy resulting applications into live commercial production.
|
|
74
|
+
|
|
75
|
+
* **Pilot Commitments:** In consideration of the zero-cost commercial pilot authorization, Licensee agrees to:
|
|
76
|
+
|
|
77
|
+
1. Register using a verified organizational corporate domain.
|
|
78
|
+
|
|
79
|
+
2. Provide reasonable technical feedback, architectural compatibility notes, and bug reports during the Pilot Period.
|
|
80
|
+
|
|
81
|
+
3. **Marketing & Reference (Optional):** Where Licensee affirmatively opts in via the applicable Order Form, registration form checkbox, or written communication, Licensee grants Licensor the non-exclusive right to reference Licensee as an early adopter (including corporate logo display on Licensor's website and marketing assets, subject to Licensee's standard trademark guidelines). If Licensee does not opt in, or requests anonymity, Licensor shall treat Licensee's participation as confidential.
|
|
82
|
+
|
|
83
|
+
* **Expiration & Continuity:** Upon expiration of the Pilot Period, the Covered Versions released during the Pilot Period remain licensed to Licensee perpetually: Licensee may continue to use them to develop, maintain, build, and deploy its applications, including in live commercial production, without time limit, and no remote deactivation or kill-switch applies. Versions released after the Pilot Period, updates to Gridify Designer, technical support, and access to private registry feeds require one of the commercial license tiers under Section 2.3.
|
|
84
|
+
|
|
85
|
+
#### 2.3 Commercial Production License Tiers
|
|
86
|
+
|
|
87
|
+
Subject to the timely payment of the applicable license subscription fees specified in the relevant Order Form, invoice, or current pricing schedule published on Licensor's official website (`gridify.dev`), Licensor grants Licensee a commercial, non-exclusive, non-transferable license to use the Software within internal and commercial production environments according to the designated capacity tier:
|
|
88
|
+
|
|
89
|
+
* **Tier A — Single or Small Team License:**
|
|
90
|
+
|
|
91
|
+
Authorizes **one (1) to five (5)** Designated Developers within Licensee's organization to develop, build, and utilize the Software and Gridify Designer across Licensee's applications. Each Designated Developer seat may be reassigned to another developer within the same organization no more than once every thirty (30) days.
|
|
92
|
+
|
|
93
|
+
* **Tier B — Large Team License:**
|
|
94
|
+
|
|
95
|
+
Authorizes **six (6) to nine (9)** Designated Developers within Licensee's organization to develop, build, and utilize the Software and Gridify Designer across Licensee's applications.
|
|
96
|
+
|
|
97
|
+
* **Tier C — Corporate License:**
|
|
98
|
+
|
|
99
|
+
Authorizes **ten (10) to twenty-five (25)** Designated Developers within Licensee's organization to develop, build, and utilize the Software and Gridify Designer across Licensee's applications.
|
|
100
|
+
|
|
101
|
+
* **Tier D — Enterprise Site License:**
|
|
102
|
+
|
|
103
|
+
Authorizes **twenty-six (26) or more (unlimited)** developers within the purchasing legal entity to utilize the Software and Gridify Designer. Covers unlimited internal systems, corporate intranets, private clouds, and commercial customer-facing web applications without per-seat tracking, administrative developer caps, or seat compliance audits. The fee of Tier D is agreed individually in the relevant Order Form.
|
|
104
|
+
|
|
105
|
+
**Commercial Terms:** Commercial subscriptions renew on an annual basis unless cancelled or modified in accordance with the applicable Order Form.
|
|
106
|
+
|
|
107
|
+
**Perpetual Use of Covered Versions:** Every version of the Software released while Licensee's subscription is active remains licensed to Licensee perpetually, also after the subscription ends: Licensee may continue to use such versions to develop, maintain, build, and deploy its applications without time limit, within the capacity of the tier it held. Versions released after the end of the subscription require an active subscription.
|
|
108
|
+
|
|
109
|
+
**License Key:** For each commercial or pilot license, Licensor issues a license key that identifies the license and covers its Covered Versions. An evaluation key (Section 2.1, item 4) is valid until its stated last day only. Licensee shall use the key only in its own applications covered by the license, and shall not remove, alter, or circumvent the license key check of the Software or the notices it writes.
|
|
110
|
+
|
|
111
|
+
### 3. SOURCE CODE ADD-ON & SOURCE CODE ESCROW
|
|
112
|
+
|
|
113
|
+
1. **Eligibility & Grant:** The Source Code Add-On is available exclusively as an optional add-on for Licensees holding an active **Tier D (Enterprise Site License)**. Upon payment of the applicable fee specified in the relevant Order Form, Licensor grants Licensee a non-exclusive license to inspect, audit, debug, customize, and internally recompile the complete, unminified TypeScript, SCSS, and build source files of the runtime libraries, the Angular UI components, the editors, and Gridify Designer (the **"Source Code Package"**). The documentation, the interactive tutorials, and the sample applications are part of the Software in the form in which Licensor publishes them and are not part of the Source Code Package.
|
|
114
|
+
|
|
115
|
+
2. **Internal Audit & Continuity:** The source code package is intended strictly for internal corporate compliance, independent security auditing, architectural continuity (escrow equivalence), and internal application tailoring.
|
|
116
|
+
|
|
117
|
+
3. **Strict Anti-Distribution & Non-Compete:** Licensee shall NOT under any circumstances:
|
|
118
|
+
|
|
119
|
+
* Publicly distribute, disclose, publish, sublicense, assign, sell, or circulate the source code, in whole or in part, modified or unmodified.
|
|
120
|
+
|
|
121
|
+
* Use the source code to train machine learning models, or to design, market, or distribute any UI component library, docking engine, visual designer, or RAD toolkit that directly or indirectly competes with Gridify Studio or Gridify Designer.
|
|
122
|
+
|
|
123
|
+
4. **Source Code Escrow (Tiers C and D):** Licensees holding an active **Tier C (Corporate License)** or **Tier D (Enterprise Site License)** may request, upon payment of the applicable fee specified in the relevant Order Form, that Licensor deposit the Source Code Package with an independent escrow agent under a separate escrow agreement between Licensor, Licensee, and the agent. Licensor updates the deposit at least with every major version released while Licensee's subscription is active. The deposited source code is released to Licensee only upon a release event defined in the escrow agreement, such as Licensor's insolvency or liquidation, or the discontinuation of the Software without a successor. Upon release, Licensee may use the source code solely to maintain, build, and deploy its own applications covered by its license, subject to items 2 and 3 of this Section.
|
|
124
|
+
|
|
125
|
+
### 4. PRIVACY, TELEMETRY & SECURITY GUARANTEE
|
|
126
|
+
|
|
127
|
+
* **No Kill-Switch:** Gridify Studio and Gridify Designer contain no logical time-bombs, expiring build locks, remote deactivation triggers, or administrative backdoors.
|
|
128
|
+
|
|
129
|
+
* **Zero Telemetry / Air-Gapped Ready:** The Software does not transmit telemetry, tracking analytics, runtime usage statistics, or application metadata to Licensor's servers. It is fully qualified for closed, air-gapped corporate intranets and security-hardened environments.
|
|
130
|
+
|
|
131
|
+
### 5. INTELLECTUAL PROPERTY & OWNERSHIP
|
|
132
|
+
|
|
133
|
+
* **Ownership by Licensor:** Licensor retains all worldwide rights, titles, and interests (including copyrights, patents, trademarks, and trade secrets) in and to Gridify Studio, the Gridify Designer application, runtime engines, and documentation. Licensee acquires only the limited license rights expressly granted herein.
|
|
134
|
+
|
|
135
|
+
* **Ownership by Licensee:** Licensee retains sole and exclusive ownership of any custom application logic, user data, visual designs, schemas, and source code generated by Licensee through the use of Gridify Designer.
|
|
136
|
+
|
|
137
|
+
### 6. TECHNICAL SUPPORT & MAINTENANCE DISCLAIMER
|
|
138
|
+
|
|
139
|
+
* **Best-Effort Support:** Technical support is provided on a commercially reasonable, best-effort basis primarily via asynchronous digital communication (email, support ticketing portal, or designated developer channels).
|
|
140
|
+
|
|
141
|
+
* **No Fixed Response SLA:** Licensor does not warrant, promise, or contractually guarantee fixed response times (hourly or daily), around-the-clock availability, or uninterrupted support desk operations. Support operations observe standard business hours in the Czech Republic, excluding statutory public holidays and reasonable, scheduled leaves or business interruptions.
|
|
142
|
+
|
|
143
|
+
* **No Resolution Guarantee:** Licensor agrees to investigate reproducible technical issues in good faith. However, Licensor makes no guarantee that every reported issue, defect, or platform discrepancy can or will be resolved, or that patches will be released within a defined timeframe. The provision of technical workarounds, configuration recommendations, architectural guidance, or documenting a planned update in a future release roadmap shall fully satisfy Licensor's support obligations.
|
|
144
|
+
|
|
145
|
+
* **Exclusions:** Licensor is under no obligation to debug, refactor, or diagnose issues stemming from third-party libraries, host browser memory limitations, customer-side change detection conflicts, unhandled memory leaks in user code, or architectural misuse of the Software.
|
|
146
|
+
|
|
147
|
+
### 7. DISCLAIMER OF WARRANTIES & LIMITATION OF LIABILITY
|
|
148
|
+
|
|
149
|
+
* **Disclaimer:** EXCEPT AS EXPRESSLY SET FORTH IN A SEPARATE WRITTEN ENTERPRISE AGREEMENT OR ORDER FORM, THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED.
|
|
150
|
+
|
|
151
|
+
* **Limitation of Liability:** IN NO EVENT SHALL LICENSOR BE LIABLE FOR ANY INDIRECT, SPECIAL, INCIDENTAL, PUNITIVE, OR CONSEQUENTIAL DAMAGES (INCLUDING LOSS OF PROFITS, LOSS OF DATA, OR BUSINESS INTERRUPTION) ARISING OUT OF OR IN CONNECTION WITH THIS AGREEMENT.
|
|
152
|
+
|
|
153
|
+
* **Liability Cap:** LICENSOR’S AGGREGATE CUMULATIVE LIABILITY UNDER THIS AGREEMENT SHALL BE STRICTLY LIMITED BASED ON THE LICENSE TIER UTILIZED:
|
|
154
|
+
|
|
155
|
+
1. **For Paid Commercial Licenses (Tiers A, B, C, and D):** Licensor's total aggregate liability shall not exceed the actual license subscription fees paid by Licensee to Licensor for the Software during the twelve (12) months preceding the event giving rise to the claim.
|
|
156
|
+
|
|
157
|
+
2. **For Commercial Pilot Licenses:** Licensor's total aggregate liability arising out of or related to the Pilot Period shall not exceed an aggregate amount of **$100 USD**.
|
|
158
|
+
|
|
159
|
+
3. **For Community Edition:** To the maximum extent permitted by applicable law, Licensor's total financial liability under the Community Edition is **ZERO ($0.00 USD)**. Licensor shall have no financial liability, warranty obligations, or indemnification duties whatsoever toward any Licensee utilizing the free Community Edition.
|
|
160
|
+
|
|
161
|
+
### 8. GOVERNING LAW & JURISDICTION
|
|
162
|
+
|
|
163
|
+
This Agreement is governed by and construed in accordance with the laws of the Czech Republic and the European Union, without regard to conflict of law principles. The United Nations Convention on Contracts for the International Sale of Goods (CISG) shall not apply. Any disputes arising hereunder shall be submitted to the exclusive jurisdiction of the competent courts of the Czech Republic.
|
package/README.md
CHANGED
|
@@ -1,3 +1,141 @@
|
|
|
1
|
-
#
|
|
1
|
+
# @gridify/editors
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
The editors of Gridify as Angular components: the **Ribbon editor**, the **Layout editor** and the **Form editor** of Gridify Designer. Each editor is a standalone component that brings its own state, its own menus and its own frame; put it on a page of your application and it fills the place you give it.
|
|
4
|
+
|
|
5
|
+
| Component | Selector | It edits |
|
|
6
|
+
| -------------- | --------------- | ----------------------------------------------------------------------------------------------- |
|
|
7
|
+
| `RibbonEditor` | `ribbon-editor` | a ribbon (tabs, groups, buttons, menus) as JSON that `gfyLoadRibbon` of `@gridify/studio` reads |
|
|
8
|
+
| `LayoutEditor` | `layout-editor` | a layout of the docking engine (panels, tabs, sizes) as JSON for `defaultLayout` |
|
|
9
|
+
| `FormEditor` | `form-editor` | a form layout (rows, cells, fields) as JSON that `gfyLoadFormLayout` reads |
|
|
10
|
+
|
|
11
|
+
## License
|
|
12
|
+
|
|
13
|
+
The editors are Gridify Designer, a part of Gridify Studio: they follow its license agreement, the file `LICENSE` of this package. The Community edition has the editors in full; a commercial application needs a Commercial license (https://www.gridify.dev).
|
|
14
|
+
|
|
15
|
+
## Install
|
|
16
|
+
|
|
17
|
+
```
|
|
18
|
+
npm i @gridify/studio @gridify/editors
|
|
19
|
+
```
|
|
20
|
+
|
|
21
|
+
The editors use the library `@gridify/studio` (a peer dependency of the same version) and Angular 21 or 22.
|
|
22
|
+
|
|
23
|
+
The global styles of the library (themes, density, text styles) go once into the styles of the application:
|
|
24
|
+
|
|
25
|
+
```scss
|
|
26
|
+
@use '@gridify/studio/styles';
|
|
27
|
+
```
|
|
28
|
+
|
|
29
|
+
## Use
|
|
30
|
+
|
|
31
|
+
```ts
|
|
32
|
+
import {Component} from '@angular/core';
|
|
33
|
+
import {LayoutEditor} from '@gridify/editors';
|
|
34
|
+
|
|
35
|
+
@Component({
|
|
36
|
+
selector: 'app-layouts',
|
|
37
|
+
imports: [LayoutEditor],
|
|
38
|
+
template: `<layout-editor hosted />`,
|
|
39
|
+
styles: `
|
|
40
|
+
:host {
|
|
41
|
+
display: block;
|
|
42
|
+
height: 100vh;
|
|
43
|
+
}
|
|
44
|
+
`,
|
|
45
|
+
})
|
|
46
|
+
export class Layouts {}
|
|
47
|
+
```
|
|
48
|
+
|
|
49
|
+
- `hosted`: the application brings its own header (its name, the theme and the density); the editor leaves them out and fills its place. Without it the editor shows them itself, as when it runs alone.
|
|
50
|
+
- `files`: the files of a project, see below. Without it the editor opens a file of the computer (Open file…) and offers the document for download (Download the file).
|
|
51
|
+
- `sample`: the id of a sample of its File > Samples that the editor starts with when it has nothing else to show (no document that Auto save kept): `showcase` (the ribbon of a text editor), `ide` (a workbench with a shell), `contact` (a contact form). Without it the Ribbon and the Layout editor start empty and the Form editor with the contact form.
|
|
52
|
+
- An editor keeps its document in the browser when the user turns Auto save on (File menu).
|
|
53
|
+
- The title in the middle of the menu bar names the document: its file of the project, or where it came from (`New layout`, `Sample: …`, the name of a file of the computer, `From the clipboard`), with a dot while it has changes that were not saved.
|
|
54
|
+
- To load an editor only when it is shown: `import('@gridify/editors').then(api => api.LayoutEditor)` and `*ngComponentOutlet`.
|
|
55
|
+
- The editors speak English.
|
|
56
|
+
|
|
57
|
+
## The files of a project
|
|
58
|
+
|
|
59
|
+
Give an editor a place where the files of your project are (the assets of the application: its layouts, forms and ribbons), and its File menu gets **Open from the project…** (Ctrl+O), **Save** (Ctrl+S) and
|
|
60
|
+
**Save as…** (Ctrl+Shift+S); Open file… and Download the file stay. Nothing of it is on until you give one.
|
|
61
|
+
|
|
62
|
+
```ts
|
|
63
|
+
import {Component} from '@angular/core';
|
|
64
|
+
import {LayoutEditor, gfyHttpFiles} from '@gridify/editors';
|
|
65
|
+
|
|
66
|
+
@Component({
|
|
67
|
+
selector: 'app-layouts',
|
|
68
|
+
imports: [LayoutEditor],
|
|
69
|
+
template: `<layout-editor hosted [files]="files" />`,
|
|
70
|
+
})
|
|
71
|
+
export class Layouts {
|
|
72
|
+
readonly files = gfyHttpFiles({url: 'http://localhost:4300/files'});
|
|
73
|
+
}
|
|
74
|
+
```
|
|
75
|
+
|
|
76
|
+
What the editor does with it:
|
|
77
|
+
|
|
78
|
+
- The dialog of the files shows the folders of the place and the `.json` files in them (a folder is listed when it is opened; a name with a dot in front is left out).
|
|
79
|
+
- A document that is opened from the place, or saved into it, belongs to that file: the title in the middle of the menu bar names it, with a dot while it has changes that were not saved. **Save** writes it back there, and only while
|
|
80
|
+
the file is still the version that was read: a file that was changed or removed in the meantime is asked about (Overwrite, or Cancel). A document that belongs to no file (a new one, a sample, a file of the
|
|
81
|
+
computer) asks where it goes, as Save as… does; Save as… onto a file that is there asks to replace it. Download the file of a document that belongs to a file is a copy: the document stays changed until
|
|
82
|
+
Save writes it into its file.
|
|
83
|
+
- A place is known by its `id` (without one, by its `label`): the document belongs to its file in any place with the same id, so you may give a new object for the same place, and a place with another id
|
|
84
|
+
does not have it. The editor that the application takes away and shows again keeps the file of its document, and a save that ends in between ends in it. With Auto save on, the file a document belongs to
|
|
85
|
+
is kept with it and comes back with it after a reload.
|
|
86
|
+
|
|
87
|
+
### `GfyEditorFiles`
|
|
88
|
+
|
|
89
|
+
A place is any object with these members; the paths are relative to its root, with `/` between the names (`layouts/main.json`), and `''` is the root folder. The editors never give a path with `..`, an
|
|
90
|
+
empty name or `\`.
|
|
91
|
+
|
|
92
|
+
| Member | What it does |
|
|
93
|
+
| ------------------------------ | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
|
|
94
|
+
| `id` | Optional: what tells this place from the others (without it: the label). Give two places that may have the same label (two folders of the same name) ids of their own. |
|
|
95
|
+
| `label` | The name of the place in the dialogs and the status bar (the name of the folder, the address of the server). |
|
|
96
|
+
| `list(folder)` | `Promise<{name, kind: 'file' \| 'folder'}[]>`: what is in a folder. The editor sorts it and shows the `.json` files. |
|
|
97
|
+
| `read(path)` | `Promise<{text, version}>`: the text of a file, and what tells this content from another (an ETag, the time of the last change and the size); `version: null` when the place does not know. |
|
|
98
|
+
| `write(path, text, condition)` | `Promise<{version}>`: writes the file (and makes it when there is none). `{ifVersion}`: only while the file is that version; `{ifAbsent: true}`: only where there is no file; without a condition: in any case. |
|
|
99
|
+
|
|
100
|
+
A condition that does not hold is refused with `GfyEditorFileConflict` (`throw new GfyEditorFileConflict(path)`); any other error is shown to the user with its message.
|
|
101
|
+
|
|
102
|
+
### A folder of this computer
|
|
103
|
+
|
|
104
|
+
```ts
|
|
105
|
+
import {gfyLocalFolderFiles, gfyLocalFolderSupported, gfyPickLocalFolder} from '@gridify/editors';
|
|
106
|
+
|
|
107
|
+
if (gfyLocalFolderSupported()) {
|
|
108
|
+
const folder = await gfyPickLocalFolder('my-app'); // from a click; null when the user closes the dialog
|
|
109
|
+
if (folder) files.set(gfyLocalFolderFiles(folder, {id: crypto.randomUUID()}));
|
|
110
|
+
}
|
|
111
|
+
```
|
|
112
|
+
|
|
113
|
+
The File System Access API: Chrome, Edge and the other browsers of Chromium, on HTTPS or localhost (Firefox and Safari do not have it). The browser asks the user for the folder and for the permission to
|
|
114
|
+
read and write it; a system folder is refused. The handle can be kept in IndexedDB for the next visit (it cannot be written as text): after a reload it has no permission, and the first list, read or write
|
|
115
|
+
asks the browser for it again, so that one comes from a click. The version of a file is the time of its last change and its size. The browser does not say where a folder is, so the place is named
|
|
116
|
+
by the folder (`label`, or `{label}` of your own) and two folders of the same name are one place unless they get ids of their own (`{id}`): give the folder an id when the user chooses it, and keep it with
|
|
117
|
+
the handle.
|
|
118
|
+
|
|
119
|
+
### A server
|
|
120
|
+
|
|
121
|
+
`gfyHttpFiles({url, label?, id?, headers?, credentials?, fetch?})` talks to a server that keeps the files (`url`: an address, or a path of the server of the page such as `/api/files`; a query of it goes with
|
|
122
|
+
every request; the address is also the id of the place):
|
|
123
|
+
|
|
124
|
+
| Request | Answer |
|
|
125
|
+
| ---------------------------------------------------------------------- | --------------------------------------------------------------------------------------------- |
|
|
126
|
+
| `GET <url>/list?path=<folder>` | `200` with JSON: `[{"name": "main.json", "kind": "file"}, {"name": "old", "kind": "folder"}]` |
|
|
127
|
+
| `GET <url>/file?path=<path>` | `200` with the text of the file, and its version in the header `ETag` |
|
|
128
|
+
| `PUT <url>/file?path=<path>`, the text as the body (`text/plain`) | `200` or `201` with the new `ETag` |
|
|
129
|
+
| … with `If-Match: <version>` (Save) or `If-None-Match: *` (a new file) | `412` when the file is not that version, or is there already: the editor asks the user |
|
|
130
|
+
|
|
131
|
+
Any other answer is an error, shown with its status and the start of its body. `headers` (an object, or a function asked for every request) carries a token, `credentials: 'include'` sends the cookies to a
|
|
132
|
+
server of another origin. A server of another origin allows the origin of the page (CORS): the methods `GET` and `PUT`, the headers `Content-Type`, `If-Match` and `If-None-Match`, and
|
|
133
|
+
`Access-Control-Expose-Headers: ETag`, without which the browser hides the version and the editors write without the check (the console says so once). A page on the internet that calls a server on your computer
|
|
134
|
+
(`http://localhost`) is asked about by the browser first (Chrome asks the user for the access to the local network).
|
|
135
|
+
|
|
136
|
+
A server that writes files is a tool for development: let it write only into the folder of the assets (no `..`, no link that leads out of it), only the files of the editors (`.json`), only for your
|
|
137
|
+
origin, and only on your computer. Gridify Designer has such a server for a folder of the computer.
|
|
138
|
+
|
|
139
|
+
**Help > Files…** of every editor says all this to the user: the choices, what each is good for and in which browsers, the requests of a server of its own and what it has to allow, a whole server in
|
|
140
|
+
Node.js to copy (`node files-server.mjs src/assets`: the requests above, the `.json` files of one folder only, JSON only, a write only over the version that was read, only `localhost` and the page of
|
|
141
|
+
Gridify Designer), and how to connect it.
|