Skip to content

Commit

Permalink
feat: add link to loro
Browse files Browse the repository at this point in the history
  • Loading branch information
vincentdchan committed Dec 6, 2023
1 parent 10eceaf commit 6f7730f
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 6 deletions.
7 changes: 7 additions & 0 deletions packages/blocky-core/src/block/textBlock.ts
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,13 @@ export class TextBlock extends ContentBlock {
delta.insert(removeLineBreaks(childPtr.textContent), {
italic: true,
});
} else if (tagName === "A") {
const href = childPtr.getAttribute("href");
if (isString(href)) {
delta.insert(removeLineBreaks(childPtr.textContent), {
href,
});
}
} else if (converter.isContainerElement(childPtr)) {
const childElements = converter.parseContainerElement(childPtr);
childrenContainer.push(...childElements);
Expand Down
1 change: 1 addition & 0 deletions packages/blocky-example/app/loro/loroBlock.module.scss
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
width: 64px;
height: 64px;
margin-bottom: 16px;
cursor: pointer;
}

.buttons {
Expand Down
4 changes: 2 additions & 2 deletions packages/blocky-example/app/loro/loroBlock.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,9 @@ function LoroBlock(props: LoroBlockProps) {
}, []);
return (
<div className={styles.container}>
<div className={styles.icon}>
<a className={styles.icon} href="https://loro.dev/">
<img src="/LORO.svg" alt="" />
</div>
</a>
<div className={styles.buttons}>
<Button
variant="contained"
Expand Down
9 changes: 5 additions & 4 deletions packages/blocky-example/app/loro/loroExample.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -242,10 +242,11 @@ function LoroExample() {
if (!initDoc) {
console.log("init doc");
controller.pasteHTMLAtCursor(
`Loro is a high-performance CRDTs library. It's written in Rust and introduced to the browser via WASM, offering incredible performance.
Blocky can leverage Loro's data syncing capabilities. By using a simple plugin, you can sync the data of the Blocky editor with Loro.
You can edit this page, and the data will sync to the browser's storage with Loro’s encoding.
Once you reload the page, the data from the browser will be rendered again.
`<p><a href="https://loro.dev/">Loro</a> is a high-performance CRDTs library. It's written in Rust and introduced to the browser via WASM, offering incredible performance.
Blocky can leverage Loro's data syncing capabilities. By using a simple plugin, you can sync the data of the Blocky editor with Loro.</p>
<p>You can edit this page, and the data will sync to the browser's storage with Loro’s encoding.
Once you reload the page, the data from the browser will be rendered again.</p>
<p>The most exciting thing is that we can leverage the character of CRDT to implement collaborative editing. Click the blue button below to try collaborative editing between tabs!</p>
<div data-type="Loro">Loro</div>`
);
}
Expand Down

1 comment on commit 6f7730f

@vercel
Copy link

@vercel vercel bot commented on 6f7730f Dec 6, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.