Skip to content

Commit f61d979

Browse files
committed
Rework package, palette and toolbox
1 parent a5ec93f commit f61d979

Some content is hidden

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

47 files changed

+4333
-1342
lines changed

@webwriter/app-desktop/src-tauri/tauri.conf.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@
3636
"execute": true,
3737
"open": ".*",
3838
"scope": [
39-
{"name": "bin/yarn", "args": true, "sidecar": true},
39+
{"name": "bin/pnpm", "args": true, "sidecar": true},
4040
{"name": "bin/esbuild", "args": true, "sidecar": true}
4141
]
4242
},
@@ -55,7 +55,7 @@
5555
"depends": []
5656
},
5757
"externalBin": [
58-
"bin/yarn",
58+
"bin/pnpm",
5959
"bin/esbuild"
6060
],
6161
"icon": [

@webwriter/core/index.html

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,14 +15,46 @@
1515
font-family: var(--sl-font-sans);
1616
overscroll-behavior: none;
1717
font-size: 1.1rem;
18+
min-height: 100vh;
1819
}
1920

2021
.sl-scroll-lock {
2122
position: fixed !important;
2223
}
24+
25+
body.loaded #icon {
26+
display: none;
27+
}
28+
29+
#icon {
30+
position: fixed;
31+
top: 50%;
32+
left: 50%;
33+
width: 150px;
34+
height: 150px;
35+
transform: translate(-50%, -50%);
36+
animation: load 1.5s infinite ease;
37+
}
38+
ww-app {
39+
z-index: 10;
40+
}
41+
@keyframes load {
42+
0% {
43+
opacity: 0;
44+
}
45+
50% {
46+
opacity: 1;
47+
}
48+
100% {
49+
opacity: 0;
50+
}
51+
}
2352
</style>
2453
</head>
2554
<body id="body">
55+
<div class="loader">
56+
</div>
57+
<img id="icon" src="app-icon-transparent.svg" />
2658
<script type="module">
2759
import {App} from "./view"
2860
</script>

@webwriter/core/localization/generated/de.ts

Lines changed: 17 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -141,7 +141,6 @@
141141
's38980f98cb07ceb8': `Speichere das aktive Dokument als Kopie`,
142142
's3914cb410fca44d4': `Importieren`,
143143
's3a6538ae341633f6': `Lokales Package bearbeiten`,
144-
's3ae67088bbefba98': `Pakete`,
145144
's3b3cfb9df7a16976': `Block-Text ausrichten`,
146145
's3b51dea3b9ac2507': `SVG-Zeichnung einfügen`,
147146
's3cb47df8290fa94c': `Option einfügen`,
@@ -210,7 +209,6 @@
210209
's70178e04a3b691b6': `Einstellungen öffnen`,
211210
's730182ad28374cda': `Objekt`,
212211
's739544d0c858c633': str`Oder ${0} hier ablegen`,
213-
's74099020a06276df': `Dateien werden beobachtet`,
214212
's7417792bbe720149': `Wiederholen`,
215213
's743f778233e42a3f': `Nebenbemerkung einfügen`,
216214
's75d83fc3f0cfab40': `Kopfzeile`,
@@ -366,7 +364,6 @@
366364
'se432a7c0c144d458': `Keine Pakete verfügbar`,
367365
'se47baf2fd16b9d2b': `Schablone`,
368366
'se58f06c2b0583ff7': `Koordinaten wählen`,
369-
'se59ef70a4d2cfbac': `Lade WebWriter...`,
370367
'se62385ac082368d2': `Auswahl als Zitatquelle markieren`,
371368
'se64f418b4e733b6c': `Ausgabe einfügen`,
372369
'se94aa491754e67ac': `Setze den Rand des auswählten Blocks`,
@@ -417,6 +414,23 @@
417414
'se6cdad455e2d8c02': `Insert a division`,
418415
'se6297163cac9d276': `Edit source`,
419416
's281d957112b10f12': `Edit the HTML of the document directly`,
417+
's2ced8e8fafb499f6': `Delete element`,
418+
's651f3a92741d9520': `Everything`,
419+
's54897f2764b0e4d0': `Install this widget package`,
420+
's1641ab440bf4daa4': `Update this widget package`,
421+
'sbd40f40cbadd38d5': `Remove this widget package`,
422+
's985f2db57913324b': `Manage packages`,
423+
'scdf536b65be39ec5': ` Create/import`,
424+
'sf2514d5dc78b1654': `Insert widget`,
425+
's1857db526dc4dcdd': `Create package`,
426+
'sd2addf69477cd4b4': `Import package`,
427+
's7de0061f53ba7472': `Error importing `,
428+
's99f110d27e30b289': `Title`,
429+
'sef73fe18e351eb35': `Keywords`,
430+
's63d894b1ddb06289': `Description`,
431+
's01d32b35baa3b676': `Author`,
432+
's17597a8bb4810524': `License`,
433+
'sdc48456f9a27ae02': `Generator`,
420434
'sef00c258bc1ecf1e': `This explorable has unsaved changes.`,
421435
};
422436

@webwriter/core/model/environment/index.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -137,7 +137,7 @@ export type Environment = {
137137
Dialog: DialogAPI,
138138
bundle: (args?: string[]) => Promise<{data: string}>,
139139
search: (text: string, params?: {size?: number, from?: number, quality?: number, popularity?: number, maintenance?: number}, searchEndpoint?: string) => Promise<SearchResults>,
140-
pm: (command: string, commandArgs?: string[], json?: boolean, cwd?: string) => Promise<Object | string>,
140+
pm: (command: string, commandArgs?: string[], cwd?: string) => Promise<Object | string>,
141141
watch: (paths: string | string[], cb?: (event: WatchEvent) => void, options?: {recursive?: boolean, delayMs?: number}) => Promise<() => void>
142142
getSystemFonts: () => Promise<string[]>,
143143
createWindow: (url?: string, options?: WindowOptions & {label?: string, hideOnClose?: boolean}) => Promise<void>,

@webwriter/core/model/environment/tauri.ts

Lines changed: 33 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -134,7 +134,6 @@ export const Dialog: DialogAPI = {promptRead, promptWrite, confirm}
134134
export const HTTP: HTTPAPI = {
135135
async request({url, method, headers, body, onProgress, timeout}) {
136136
const response = await fetch(url, {method, headers, body: body? Body.bytes(body[0] as any): undefined, timeout, responseType: ResponseType.Binary})
137-
console.log(response)
138137
return {
139138
url: response.url,
140139
method,
@@ -149,7 +148,8 @@ export const HTTP: HTTPAPI = {
149148

150149
/** Runs the CLI command `esbuild [args]`. */
151150
export async function bundle(args: string[] = []) {
152-
const output = await Command.sidecar("bin/esbuild", args).execute()
151+
const output = await Command.sidecar("bin/esbuild", [...args]).execute()
152+
console.info(`[TAURI] > esbuild ${args.join(" ")}`)
153153
if(output.code !== 0) {
154154
throw Error(output.stderr)
155155
}
@@ -159,22 +159,38 @@ export async function bundle(args: string[] = []) {
159159
}
160160

161161
/** Search using npm's registry API (https://github.com/npm/registry/blob/master/docs/REGISTRY-API.md). Uses the registry API since the CLI doesn't support search qualifiers such as tags. */
162-
export async function search(text: string, params?: {size?: number, from?: number, quality?: number, popularity?: number, maintenance?: number}, searchEndpoint="https://registry.npmjs.com/-/v1/search") {
162+
export async function search(text: string, params?: {size?: number, quality?: number, popularity?: number, maintenance?: number}, searchEndpoint="https://registry.npmjs.com/-/v1/search") {
163163
const allParams = {text, ...{size: 250, ...params}}
164-
const url = new URL(searchEndpoint)
165-
Object.entries(allParams).forEach(([k, v]) => v? url.searchParams.append(k, v.toString()): null)
166-
const result = await window.fetch(url.href)
167-
return result.ok
168-
? result.json()
169-
: new Error(`${result.status} ${result.statusText}`)
164+
const baseURL = new URL(searchEndpoint)
165+
Object.entries(allParams).forEach(([k, v]) => v? baseURL.searchParams.append(k, v.toString()): null)
166+
let from = 0
167+
let total = Number.POSITIVE_INFINITY
168+
let objects: any[] = []
169+
let time = undefined
170+
do {
171+
let url = new URL(baseURL.href)
172+
url.searchParams.set("from", String(from))
173+
const result = await window.fetch(baseURL)
174+
if(result.ok) {
175+
const body = await result.json()
176+
from += params?.size ?? 250
177+
total = body.total
178+
time = body.time
179+
objects = objects.concat(body.objects)
180+
}
181+
else {
182+
return new Error(`${result.status} ${result.statusText}`)
183+
}
184+
} while(from < total)
185+
return {objects, total, time}
170186
}
171187

172-
/** Runs the CLI command `npm [commandArgs]`. By default, this passes the `--json` flag. Optionally, you can disable `json` or set a directory to change to with `cwd`. */
173-
export async function pm(command: string, commandArgs: string[] = [], json=true, cwd?: string) {
174-
const cmdArgs = [command, ...(json ? ["--json"]: []), ...commandArgs]
188+
/** Runs the CLI command `pnpm [commandArgs]`. */
189+
export async function pm(command: string, commandArgs: string[] = [], cwd?: string) {
190+
const cmdArgs = [command, ...commandArgs]
175191
const opts = cwd? {cwd}: {}
176-
console.info(`[TAURI] ${cwd? cwd: await appDir()}> bin/yarn ${[...cmdArgs, "--mutex file"].join(" ")}`)
177-
const output = await Command.sidecar("bin/yarn", [...cmdArgs, "--mutex file"], opts).execute()
192+
console.info(`[TAURI] ${cwd? cwd: await appDir()}> pnpm ${cmdArgs.join(" ")}`)
193+
const output = await Command.sidecar("bin/pnpm", cmdArgs, opts).execute()
178194
if(output.stderr) {
179195
const err = output.stderr.split("\n").map((e: any) => {
180196
try {
@@ -185,6 +201,7 @@ export async function pm(command: string, commandArgs: string[] = [], json=true,
185201
}
186202
})
187203
const errors = err.filter((e: any) => e?.type === "error")
204+
console.log(err)
188205
const warnings = err.filter((e: any) => e?.type === "warning")
189206
warnings.forEach((w: any) => console.warn(w.data))
190207
if(err?.some((e: any) => e?.type === "error")) {
@@ -195,7 +212,8 @@ export async function pm(command: string, commandArgs: string[] = [], json=true,
195212
let result = output.stdout
196213
try {
197214
result = JSON.parse(output.stdout)
198-
} catch(e) {}
215+
} catch(e) {
216+
}
199217
return result
200218
}
201219
}

@webwriter/core/model/marshal/html.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -44,9 +44,9 @@ export async function docToBundle(doc: Node, head: Node, bundle: Environment["bu
4444
const serializer = DOMSerializer.fromSchema(doc.type.schema)
4545
serializer.serializeFragment(doc.content, {document: html}, html.body)
4646

47-
html.querySelectorAll("[data-widget]").forEach(w => w.removeAttribute("editable"))
47+
html.querySelectorAll(".ww-widget").forEach(w => w.removeAttribute("contenteditable"))
4848

49-
console.log(html.querySelectorAll("[data-widget]"))
49+
console.log(html.querySelectorAll(".ww-widget"))
5050

5151
const allWidgetTypes = [...new Set(Object.values(doc.type.schema.nodes)
5252
.filter(node => node.spec["widget"])
@@ -173,5 +173,5 @@ export async function serialize(explorable: Node, head: Node, bundle: Environmen
173173
}
174174

175175
export const label = "WebWriter File"
176-
export const extensions = ["ww.html", "html"]
176+
export const extensions = ["html", "ww.html"]
177177
export const isBinary = false

0 commit comments

Comments
 (0)