Skip to content

Commit

Permalink
Fix #919 - Card content not rendering
Browse files Browse the repository at this point in the history
  • Loading branch information
mgmeyers committed Apr 16, 2024
1 parent b198e3c commit 9c97dfe
Show file tree
Hide file tree
Showing 4 changed files with 31 additions and 92 deletions.
33 changes: 19 additions & 14 deletions src/components/MarkdownRenderer/MarkdownRenderer.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -119,13 +119,6 @@ export class MarkdownRenderer extends ObsidianRenderer {
const entry = entries.first().contentBoxSize[0];
if (entry.blockSize === 0) return;

if (
this.lastWidth >= 0 &&
(this.lastWidth !== entry.inlineSize || this.lastHeight !== entry.blockSize)
) {
this.renderer.onResize();
}

if (this.wrapperEl) {
const rect = this.wrapperEl.getBoundingClientRect();
if (this.lastRefHeight === -1 || rect.height > 0) {
Expand Down Expand Up @@ -225,6 +218,17 @@ export class MarkdownRenderer extends ObsidianRenderer {
el.append(containerEl);
}
}

displayAllChildren() {
const { renderer } = this;
const { sizerEl, pusherEl, previewEl, sections } = renderer;

(sizerEl as HTMLElement).setChildrenInPlace([pusherEl, ...sections.map((s: any) => s.el)]);

sizerEl.style.minHeight = '';
pusherEl.style.marginBottom = '0';
previewEl.scrollTop = 0;
}
}

const q = new PQueue({ concurrency: 50 });
Expand Down Expand Up @@ -269,11 +273,15 @@ export const MarkdownPreviewRenderer = memo(function MarkdownPreviewRenderer({
preview.wrapperEl = elRef.current;
preview.set(processed);
markRef.current = new Mark(preview.renderer.previewEl);

view.previewCache.set(entityId, preview);

setRendered(true);
await new Promise((res) => setTimeout(res));
await new Promise<void>((res) => {
preview.renderer.onRendered(() => {
preview.displayAllChildren();
res();
});
});
},
{ priority: priority ?? 0 }
);
Expand All @@ -282,11 +290,8 @@ export const MarkdownPreviewRenderer = memo(function MarkdownPreviewRenderer({
useEffect(() => {
const preview = renderer.current;
if (!rendered || processed === preview.renderer.text) return;
const el = elRef.current;
if (el) {
preview.migrate(el);
}
renderer.current.set(processed);
if (elRef.current) preview.migrate(elRef.current);
preview.set(processed);
}, [rendered, processed]);

useEffect(() => {
Expand Down
13 changes: 2 additions & 11 deletions src/dnd/managers/ScrollManager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -61,19 +61,8 @@ export class ScrollManager {
this.parent = parent;
this.activeScroll = new Map();
this.observerHandlers = new Map();

//
// this.pollForNodes(getScrollEl);
}

// pollForNodes(getScrollEl: () => HTMLElement | null) {
// if (!getScrollEl() || (this.parent && !this.parent.observerHandlers)) {
// this.dndManager.win.requestAnimationFrame(() => this.pollForNodes(getScrollEl));
// } else {
// this.initNodes(getScrollEl());
// }
// }

initNodes(scrollEl: HTMLElement) {
this.scrollEl = scrollEl;
this.scrollEl.dataset.hitboxid = this.instanceId;
Expand Down Expand Up @@ -135,6 +124,8 @@ export class ScrollManager {
}

destroy() {
if (!this.scrollEl && !this.observer) return;

this.observerQueue.length = 0;
this.handleEntityUnregistration();
this.observer.disconnect();
Expand Down
40 changes: 5 additions & 35 deletions src/styles.less
Original file line number Diff line number Diff line change
Expand Up @@ -719,6 +719,11 @@ button.kanban-plugin__new-item-button {

.kanban-plugin__meta-value,
.kanban-plugin__markdown-preview-wrapper {
white-space: pre-wrap;
white-space: break-spaces;
word-break: break-word;
overflow-wrap: anywhere;

.markdown-preview-view {
--file-margins: 0;
}
Expand Down Expand Up @@ -1115,41 +1120,6 @@ button.kanban-plugin__cancel-action-button {

/* Inputs */

.kanban-plugin__grow-wrap {
width: 100%;
display: grid;
}
.kanban-plugin__grow-wrap::after {
content: attr(data-replicated-value) ' ';
white-space: pre-wrap;
visibility: hidden;
}
.kanban-plugin__grow-wrap > textarea {
resize: none;
overflow: hidden;
tab-size: 2;
}

.kanban-plugin__grow-wrap > textarea:focus {
border: none;
box-shadow: none;
}

.kanban-plugin__grow-wrap > textarea,
.kanban-plugin__grow-wrap::after {
/* Identical styling required! */
border: none;
border-radius: 0;
padding: 0;
font: inherit;
line-height: var(--line-height-tight);
grid-area: 1 / 1 / 2 / 2;
font-size: 0.875rem;
overflow: hidden;
overflow-wrap: break-word;
white-space: pre-wrap;
}

.kanban-plugin__autocomplete {
font-size: 0.875rem;
border: 1px solid var(--background-modifier-border);
Expand Down
37 changes: 5 additions & 32 deletions styles.css

Large diffs are not rendered by default.

0 comments on commit 9c97dfe

Please sign in to comment.