@usememos/editor 26.10.19 → 26.10.20

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 CHANGED
@@ -267,7 +267,7 @@ const linkCards: Extension = {
267
267
 
268
268
  ### Theming
269
269
 
270
- `style.css` is two stylesheets: `base.css` holds the layout the editor needs and all spacing between blocks, and `theme.css` the default look. The default look is quiet and compact, like a rendered Markdown view: a 16px body with 24px lines, 8px between blocks, headings close to the body size, muted quotes and list markers, code blocks on a light panel with no border, and tables as a light grid with a shaded header row. Editing and read-only look the same; only the cursor on links and checkboxes changes. It has no border or background of its own, so it fits inside your own card, comment box or chat input.
270
+ `style.css` is two stylesheets: `base.css` holds the layout the editor needs and all spacing between blocks, and `theme.css` the default look. The default look is quiet and compact, like a rendered Markdown view: a 16px body with 24px lines, 8px between blocks, headings close to the body size, muted quotes and list markers, code blocks on a light panel with no border whose long lines scroll sideways rather than wrap, and tables as a light grid with a shaded header row and columns sized to their content. Editing and read-only look the same; only the cursor on links and checkboxes changes. It has no border or background of its own, so it fits inside your own card, comment box or chat input.
271
271
 
272
272
  Every color, font and size in `theme.css` is a CSS custom property (`--mbe-text`, `--mbe-accent`, `--mbe-font`, …). Set them with the `theme` option's tokens, with a color set for light and one for dark; colors you leave out keep the defaults:
273
273
 
package/dist/base.css CHANGED
@@ -236,7 +236,8 @@
236
236
  padding: 0;
237
237
  width: 12em;
238
238
  }
239
- :is(.mbe-root, .mbe-flow) > .mbe-code pre,
239
+ /* Code keeps its lines and scrolls sideways, as GitHub shows it; raw source wraps. */
240
+ :is(.mbe-root, .mbe-flow) > .mbe-code pre { white-space: pre; overflow-x: auto; tab-size: 2; }
240
241
  :is(.mbe-root, .mbe-flow) > pre.mbe-raw { white-space: pre-wrap; tab-size: 2; }
241
242
  /* Source mode: the document as plain text in the editor's font. */
242
243
  .mbe-root > .mbe-source { white-space: pre-wrap; tab-size: 4; overflow-wrap: anywhere; }
@@ -276,16 +277,19 @@
276
277
 
277
278
  /* Table */
278
279
  :is(.mbe-root, .mbe-flow) > .mbe-table { overflow-x: auto; }
279
- /* Columns fit their content and wrap at the editor's width; wider tables scroll. */
280
+ /* Columns fit their content and wrap at the editor's width, as GitHub lays
281
+ tables out; wider tables scroll. No column has a minimum width, so a long
282
+ column is not squeezed into wrapping by short ones. */
280
283
  :is(.mbe-root, .mbe-flow) > .mbe-table table { border-collapse: separate; border-spacing: 0; }
281
284
  :is(.mbe-root, .mbe-flow) > .mbe-table th,
282
285
  :is(.mbe-root, .mbe-flow) > .mbe-table td {
283
286
  padding: 4px 8px;
284
- min-width: 4em;
285
287
  vertical-align: top;
286
288
  text-align: start;
287
289
  outline: none;
288
290
  }
291
+ /* An empty cell keeps room to click into while editing. */
292
+ .mbe-root:not(.mbe-readonly) > .mbe-table :is(th, td).mbe-empty-content { min-width: 4em; }
289
293
 
290
294
  /* Blocks inside collapsible sections, after the block rules so it wins over their margins. */
291
295
  :is(.mbe-root, .mbe-flow) > [data-in-section] { margin-inline-start: calc(var(--mbe-section-depth, 0) * var(--mbe-indent-size)); }
package/dist/index.js CHANGED
@@ -7567,10 +7567,29 @@ function fill(doc) {
7567
7567
  return br;
7568
7568
  }
7569
7569
  var VOID_TAGS = /* @__PURE__ */ new Set(["area", "base", "br", "col", "embed", "hr", "img", "input", "link", "meta", "source", "track", "wbr"]);
7570
+ var HTML_PIECE = /<!--[\s\S]*?-->|<[^<>]*>/g;
7571
+ function splitHtmlSpans(inline3) {
7572
+ if (!inline3.some((s) => s.marks.includes("html"))) return inline3;
7573
+ const out = [];
7574
+ for (const span of normalizeInline(inline3)) {
7575
+ if (!span.marks.includes("html")) {
7576
+ out.push(span);
7577
+ continue;
7578
+ }
7579
+ let last = 0;
7580
+ for (const m of span.text.matchAll(HTML_PIECE)) {
7581
+ if (m.index > last) out.push({ ...span, text: span.text.slice(last, m.index) });
7582
+ out.push({ ...span, text: m[0] });
7583
+ last = m.index + m[0].length;
7584
+ }
7585
+ if (last < span.text.length) out.push({ ...span, text: span.text.slice(last) });
7586
+ }
7587
+ return out;
7588
+ }
7570
7589
  function htmlRuns(inline3) {
7571
7590
  const spans = [];
7572
7591
  let pos = 0;
7573
- for (const span of inline3) {
7592
+ for (const span of splitHtmlSpans(inline3)) {
7574
7593
  spans.push({ span, from: pos, to: pos + span.text.length });
7575
7594
  pos += span.text.length;
7576
7595
  }
@@ -7608,6 +7627,7 @@ function renderInline(inline3, parent, ctx, decorations, reveal, cell) {
7608
7627
  const doc = ctx.doc;
7609
7628
  const views = ctx.views;
7610
7629
  const viewed = views ? (span, from) => !!span.token && views.has(span.token) && !reveal?.has(tokenKey(cell, from)) : void 0;
7630
+ if (views?.has("html")) inline3 = splitHtmlSpans(inline3);
7611
7631
  const runs = views?.has("html") && inline3.some((s) => s.marks.includes("html")) ? htmlRuns(inline3).filter((run) => !reveal?.has(tokenKey(cell, run.from))) : [];
7612
7632
  const inRun = (from) => runs.some((run) => from >= run.from && from < run.to);
7613
7633
  const isHtml = (span) => span.marks.includes("html");