Skip to content

Commit fc55439

Browse files
authored
Merge pull request #83 from webwriter-app/develop-1.0
Develop 1.0
2 parents 12de7fd + 17d67b5 commit fc55439

Some content is hidden

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

108 files changed

+65741
-13504
lines changed

@webwriter/core/model/schemas/contentexpression.ts

Lines changed: 20 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -129,9 +129,15 @@ export const ContentExpression = Object.assign(z.string().transform<Expression>(
129129
parent
130130
}
131131
seen.set(expression.raw, result)
132-
const nodeContent = node.spec.content
133-
? seen.get(node.spec.content) ?? ContentExpression.resolve(schema, ContentExpression.parse(node.spec.content), result as any, seen)
134-
: undefined
132+
const seenContent = node.spec.content && seen.get(node.spec.content)
133+
let nodeContent = undefined
134+
if(!seenContent && node.spec.content) {
135+
seen.set(node.spec.content, result)
136+
nodeContent = ContentExpression.resolve(schema, ContentExpression.parse(node.spec.content), result as any, seen)
137+
}
138+
else {
139+
nodeContent = seen.get(node.spec.content)
140+
}
135141
return Object.assign(result, {content: nodeContent? [nodeContent]: undefined}) as any
136142
}
137143
else if(Array.isArray(content)) {
@@ -152,11 +158,18 @@ export const ContentExpression = Object.assign(z.string().transform<Expression>(
152158
return expression
153159
}
154160
},
155-
values(expression: ParentedExpression): ParentedExpression[] {
161+
values(expression: ParentedExpression, seen=new WeakSet()): ParentedExpression[] {
156162
const {content} = expression
157-
const values = !content || typeof content === "string"
158-
? []
159-
: content.flatMap(c => ContentExpression.values(c))
163+
let values
164+
if(seen.has(expression)) {
165+
values = [] as any
166+
}
167+
else {
168+
seen.add(expression)
169+
values = !content || typeof content === "string"
170+
? []
171+
: content.flatMap(c => ContentExpression.values(c, seen))
172+
}
160173
return [expression, ...values]
161174
}
162175
})

@webwriter/core/model/schemas/cssvalue.ts

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -178,10 +178,10 @@ export class CSSMathValue extends window.CSSMathValue {
178178
}
179179
}
180180

181-
CSSMathValue.parse
182-
183181
export class CSSPercentageValue extends CSSUnitValue {
184182

183+
static units = ["%"]
184+
185185
constructor(value: number) {
186186
super(value, "percent")
187187
}
@@ -201,6 +201,8 @@ export class CSSPercentageValue extends CSSUnitValue {
201201
}
202202

203203
export class CSSIntegerValue extends CSSUnitValue {
204+
205+
static units = []
204206

205207
constructor(value: number) {
206208
super(value, "number")
@@ -224,6 +226,8 @@ export class CSSIntegerValue extends CSSUnitValue {
224226
}
225227

226228
export class CSSNumberValue extends CSSUnitValue {
229+
230+
static units = []
227231

228232
constructor(value: number) {
229233
super(value, "number")
@@ -244,6 +248,8 @@ export class CSSNumberValue extends CSSUnitValue {
244248
}
245249

246250
export class CSSFlexValue extends CSSUnitValue {
251+
252+
static units = ["fr"]
247253

248254
constructor(value: number) {
249255
super(value, "fr")
@@ -265,7 +271,7 @@ export class CSSFlexValue extends CSSUnitValue {
265271

266272
export class CSSLengthValue extends CSSUnitValue {
267273

268-
static units = ["cap", "ch", "em", "ex", "ic", "lh", "rcap", "rch", "rem", "rex", "ric", "rlh", "vh", "vw", "vmax", "vmin", "vb", "vi", "cqw", "cqh", "cqi", "cqb", "cqmin", "cqmax", "px", "cm", "mm", "Q", "in", "pc", "pt"] as const
274+
static units = ["px", "pt", "cm", "mm", "em", "rem", "ch", "ex", "ic", "lh", "rcap", "rch", "rex", "ric", "rlh", "vh", "vw", "vmax", "vmin", "vb", "vi", "cap", "cqw", "cqh", "cqi", "cqb", "cqmin", "cqmax", "Q", "in", "pc", "pt"] as const
269275

270276
constructor(value: number, unit: typeof CSSLengthValue["units"][number]) {
271277
super(value, unit)

@webwriter/core/model/schemas/resource/index.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -48,12 +48,12 @@ export function createEditorStateConfig(packages: Package[]) {
4848
formPlugin(),
4949
modalPlugin(),
5050
stylePlugin(),
51-
tablePlugin(),
5251
mathPlugin(),
5352
phrasingPlugin(),
5453
svgPlugin(),
5554
// deprecatedPlugin(),
5655
widgetPlugin(packages),
56+
tablePlugin(),
5757
basePlugin(),
5858
grammarPlugin(),
5959
]);
@@ -100,7 +100,7 @@ const ResourceSchema = z.object({
100100
value: z.any(),
101101
schema: z.instanceof(Schema),
102102
})
103-
.transform(async ({ value, schema }) => {
103+
.transform(async ({ value, schema }) => { // @ts-ignore
104104
for (const parse of Object.values(marshal).map(({ parse }) => parse)) {
105105
try {
106106
return await parse(value, schema);

@webwriter/core/model/schemas/resource/plugins/base.css

Lines changed: 102 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,30 @@ html::-webkit-scrollbar-button:vertical:single-button:increment:disabled {
6767
outline: none;
6868
}
6969

70+
html.ww-all-selected:not(.ww-empty) {
71+
& body {
72+
border: 1px solid var(--sl-color-primary-400);
73+
74+
&::after {
75+
content: "";
76+
display: block;
77+
position: absolute;
78+
top: 0;
79+
left: 0;
80+
width: 100%;
81+
height: 100%;
82+
background: var(--sl-color-primary-400);
83+
opacity: 10%;
84+
pointer-events: none;
85+
}
86+
}
87+
88+
& ::selection {
89+
background: transparent !important;
90+
caret-color: transparent !important;
91+
}
92+
}
93+
7094
a:not([href]) {
7195
text-decoration: underline;
7296
color: #0000ee;
@@ -83,6 +107,12 @@ body {
83107
caret-color: currentColor;
84108
}
85109

110+
@media screen and (min-width: 1130px) and (max-width: 1360px) {
111+
body {
112+
margin-left: 0;
113+
}
114+
}
115+
86116
figure:hover {
87117
position: relative;
88118
}
@@ -275,7 +305,7 @@ html:is(.ww-key-ctrl, .ww-key-meta) body * {
275305
.ww-cutting,
276306
.ww-deleting,
277307
html:is(.ww-key-ctrl, .ww-key-meta) body *
278-
)::before {
308+
):not(html):not(tr)::before {
279309
content: "";
280310
position: absolute;
281311
right: -20px;
@@ -440,27 +470,69 @@ body > .ww-widget::after {
440470
transition: background-color 0.1s ease;
441471
}
442472

443-
body > p:first-child {
444-
margin-top: 0;
473+
body > .ProseMirror-gapcursor:first-child {
474+
margin-bottom: 0;
445475
}
446476

447-
table .ProseMirror-gapcursor {
448-
border: 2px dashed var(--sl-color-primary-600);
449-
display: table-cell;
450-
min-width: 1em;
451-
padding: 3px 5px;
452-
vertical-align: top;
453-
box-sizing: border-box;
454-
position: relative;
455-
height: 100%;
477+
table, tbody, tr {
478+
overflow: visible !important;
456479
}
457480

458-
table .ProseMirror-gapcursor::after {
459-
border-top: none;
460-
border-left: 1px solid black;
461-
width: 2px;
462-
height: 1em;
463-
position: static;
481+
table tr {
482+
overflow: visible;
483+
}
484+
485+
@keyframes blink {
486+
50% {
487+
opacity: 0.0;
488+
}
489+
}
490+
table :is(thead, tbody, tfoot) > tr:has(+ .ProseMirror-gapcursor) {
491+
anchor-name: --table-row;
492+
}
493+
494+
table :is(thead, tbody, tfoot) > .ProseMirror-gapcursor {
495+
display: inline;
496+
position: absolute;
497+
top: anchor(--table-row top);
498+
right: anchor(--table-row right);
499+
height: -1px;
500+
position-anchor: --table-row;
501+
502+
&::after {
503+
display: block;
504+
content: "";
505+
height: calc(1lh + 6px);
506+
width: 2px;
507+
background: currentColor;
508+
z-index: 10;
509+
animation: blink 1s step-end 0s infinite;
510+
clip-path: unset;
511+
margin-left: 2px;
512+
margin-top: 2px;
513+
}
514+
}
515+
516+
.ProseMirror-gapcursor + tr td {
517+
border-top: none !important;
518+
}
519+
520+
table .selectedCell {
521+
background: var(--sl-color-primary-200) !important;
522+
}
523+
524+
tr {
525+
container-type: inline-size;
526+
container-name: table-row;
527+
}
528+
529+
td:is(:empty, :has(.ProseMirror-trailingBreak)) {
530+
height: 1lh;
531+
aspect-ratio: 1;
532+
}
533+
534+
thead, tbody, tfoot {
535+
border-left: none !important;
464536
}
465537

466538
.ProseMirror ::selection:not(.ProseMirror-selectednode) {
@@ -469,6 +541,16 @@ table .ProseMirror-gapcursor::after {
469541
z-index: 2147483647;
470542
}
471543

544+
html.ww-cutting ::selection {
545+
background-color: var(--sl-color-warning-300);
546+
}
547+
548+
549+
html.ww-deleting ::selection {
550+
background-color: var(--sl-color-danger-300);
551+
}
552+
553+
472554
abbr {
473555
text-decoration: underline 1px dotted currentColor;
474556
}
@@ -707,7 +789,7 @@ body:has(.ww-fullscreen) > :not(.ww-fullscreen) {
707789
display: none !important;
708790
}
709791

710-
@media only screen and (min-width: 1300px) {
792+
@media only screen and (min-width: 1130px) {
711793
.ww-widget::part(options) {
712794
position: fixed;
713795
width: var(--ww-toolbox-action-width);
@@ -750,4 +832,4 @@ body:has(.ww-fullscreen) > :not(.ww-fullscreen) {
750832
.ProseMirror[data-empty]::before {
751833
display: none;
752834
}
753-
}
835+
}

@webwriter/core/model/schemas/resource/plugins/form.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ export const formPlugin = () => ({
1717
tag: "button",
1818
content: "phrasing*",
1919
group: "flow interactive listed labelable submittable formassociated palpable inlinecontainer",
20+
atom: true,
2021
attrs: {
2122
autofocus: {default: undefined},
2223
disabled: {default: undefined},
@@ -34,6 +35,7 @@ export const formPlugin = () => ({
3435
input: HTMLElementSpec({
3536
tag: "input",
3637
group: "flow listed submittable resettable formassociated labelable palpable",
38+
atom: true,
3739
attrs: {
3840
accept: {default: undefined},
3941
alt: {default: undefined},
@@ -71,6 +73,7 @@ export const formPlugin = () => ({
7173
textarea: HTMLElementSpec({
7274
tag: "textarea",
7375
group: "flow listed submittable resettable formassociated labelable palpable",
76+
atom: true,
7477
attrs: {
7578
autocapitalize: {default: undefined},
7679
autocomplete: {default: undefined},
@@ -96,6 +99,7 @@ export const formPlugin = () => ({
9699
select: {
97100
tag: "select",
98101
group: "flow interactive listed labelable resettable submittable formassociated",
102+
atom: true,
99103
attrs: {
100104
autocomplete: {default: undefined},
101105
autofocus: {default: undefined},
@@ -113,6 +117,7 @@ export const formPlugin = () => ({
113117
meter: {
114118
tag: "meter",
115119
group: "flow labelable palpable",
120+
atom: true,
116121
content: "phrasing*",
117122
attrs: {
118123
value: {default: undefined},
@@ -218,6 +223,7 @@ export const formPlugin = () => ({
218223
tag: "progress",
219224
group: "flow labelable palpable containerinline",
220225
content: "phrasing*",
226+
atom: true,
221227
attrs: {
222228
max: {default: undefined},
223229
value: {default: undefined}

@webwriter/core/model/schemas/resource/plugins/index.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ export interface SchemaPlugin<
2323
nodes?: { [key in N]: NodeSpec };
2424
marks?: { [key in M]: MarkSpec };
2525
topNode?: N;
26-
plugin?: Plugin<PS>;
26+
plugin?: Plugin<PS> | Plugin<PS>[];
2727
keymap?:
2828
| ((schema: Schema) => Record<string, Command>)
2929
| Record<string, Command>;
@@ -82,7 +82,7 @@ export function configFromSchemaPlugins(
8282
history(),
8383
gapCursor(),
8484
// virtualCursor(),
85-
...schemaPlugins.filter((p) => p.plugin).map((p) => p.plugin!),
85+
...schemaPlugins.filter((p) => p.plugin).flatMap((p) => p.plugin!),
8686
];
8787
return { schema, doc, plugins };
8888
}

@webwriter/core/model/schemas/resource/plugins/math.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ export function MathMLElementSpec({tag, content, marks, group, inline, atom, att
4646
}
4747
}
4848

49-
const MATHML_TAGS = [
49+
export const MATHML_TAGS = [
5050
"mtext",
5151
"annotation",
5252
"annotation-xml",

@webwriter/core/model/schemas/resource/plugins/style.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ export function parseStyleAttrs(dom: HTMLElement | string) {
4141
}
4242

4343
export function getStyleValues(state: EditorState, view: EditorView & {window: Window}, key: string) {
44-
if(!view || view.isDestroyed) {
44+
if(!view || view.isDestroyed || !view.dom) {
4545
return []
4646
}
4747
const values = new Set<string>()

0 commit comments

Comments
 (0)