Trên GitHub, slab/delta-elixir đã đạt 376 sao, ngôn ngữ Elixir. Elixir implementation of Delta, the JSON format for describing rich-text content and their changes
Tóm tắt dựng từ metadata GitHub của chính dự án — chưa có bài review TopGit. Trang sẽ tự động cập nhật khi bài review đầy đủ được xuất bản.
VÌ SAO CHƯA CÓ REVIEW
TopGit viết bài đầy đủ cho repo có nhiều sao nhất và được yêu cầu nhiều nhất. Trang này là snapshot trong thời gian chờ — xem README gốc ở tab READ ME.
Simple yet expressive format to describe documents' contents and changes 🗃
Deltas are a simple, yet expressive format that can be used to describe contents and changes.
The format is a strict subset of JSON, is human readable, and easily parsible by machines.
Deltas can describe any rich-text document, includes all text and formatting information,
without the ambiguity and complexity of HTML.
The Delta format is suitable for Operational Transform and can be used in real-time,
collaborative document editors (e.g. Slab, Google Docs). A walkthough of the motivation and
design thinking behind Deltas are on Designing the Delta Format.
See the Documentation.
Installation
Add delta to your project dependencies in mix.exs:
def deps do
[{:delta, "~> 0.4.1"}]
end
Usage
A Delta is made up of a list of operations, which describe changes to a document. These can be
insert, delete or retain. These operations do not take an index, but instead describe the
change at the current index. Retains are used to "keep" parts of the document.
Quick Example
alias Delta.Op
# Document with text "Gandalf the Grey", with "Gandalf" bolded
# and "Grey" in grey
delta = [
Op.insert("Gandalf", %{"bold" => true}),
Op.insert(" the "),
Op.insert("Grey", %{"color" => "#ccc"}),
]
# Define change intended to be applied to above:
# Keep the first 12 characters, delete the next 4,
# and insert a white "White"
death = [
Op.retain(12),
Op.delete(4),
Op.insert("White", %{"color" => "#fff"}),
]
# Applying the change:
Delta.compose(delta, death)
# => [
# %{"insert" => "Gandalf", "attributes" => %{"bold" => true}},
# %{"insert" => " the "},
# %{"insert" => "White", "attributes" => %{"color" => "#fff"}},
# ]
Operations
Insert
Insert operations have an insert key defined. A String value represents inserting text. Any
other type represents inserting an embed (however only one level of object comparison will be
performed for equality).
In both cases of text and embeds, an optional attributes key can be defined with a map to
describe additonal formatting information. Formats can be changed by the retain operation.
# Insert a text
Op.insert("Some Text")
# Insert a bolded text
Op.insert("Bolded Text", %{"bold" => true})
# Insert a link
Op.insert("Google", %{"link" => "https://google.com"})
# Insert an embed
Op.insert(%{"image" => "https://app.com/logo.png"}, %{"alt" => "App Logo"})
# Insert another embed
Op.insert(%{"video" => "https://www.youtube.com/watch?v=dQw4w9WgXcQ"}, %{"width" => 420, "height" => 315})
Delete
Delete operations have a positive integer delete key defined representing the number of
characters to delete. All embeds have a length of 1.
# Delete the next 10 characters
Op.delete(10)
Retain
Retain operations have a positive integer retain key defined representing the number of
characters to keep (other libraries might use the name keep or skip). An optional attributes
key can be defined with a map to describe formatting changes to the character range. A
value of nil in the attributes map represents removal of that key.
Note: It is not necessary to retain the last characters of a document as this is implied.
# Keep the next 5 characters
Op.retain(5)
# Keep and bold the next 5 characters
Op.retain(5, %{"bold" => true})
# Keep and unbold the next 5 characters
Op.retain(5, %{"bold" => nil})
Operational Transform
Operational Transform (OT) is a technology for building collabortive experiences, and is
especially useful in application sharing and building real-time document editors that support
multi-user collaboration (e.g. Google Docs, Slab).
Delta supports OT out of the box and can be very useful in employing Operational Transform
techniques in Elixir. It supports the following properties:
Compose
Returns a new Delta that is equivalent to applying the operations of one Delta, followed
by another Delta:
a = [Op.insert("abc")]
b = [Op.retain(1), Op.delete(1)]
Delta.compose(a, b)
# => [%{"insert" => "ac"}]
Transform
Transforms given delta against another's operations. This accepts an optional priority
argument (default: false), used to break ties. If true, the first delta takes priority
over other, that is, its actions are considered to happen "first."
Note that even though delete operations support attributes, it is only safe to
use transform with deletes that don't have them.
Invert
Returns an inverted delta that has the opposite effect of against a base document delta.
That is base |> Delta.compose(change) |> Delta.compose(inverted) == base.
Trang TopGit này là một snapshot — tab "Readme" hiển thị nguyên văn README của repo (đã bỏ link, giữ ảnh). Repo GitHub ở github.com/slab/delta-elixir là nguồn chính thức.
slab/delta-elixir có những chủ đề gì?
GitHub topics của slab/delta-elixir: "collaboration", "concurrency", "consistency-models", "distributed-systems", "elixir", "operational-transform", "quill-delta", "real-time". TopGit xếp repo vào nhóm mã nguồn mở.
slab/delta-elixir có phải mã nguồn mở không?
TopGit chưa ghi nhận license cho slab/delta-elixir. Phần lớn repo public trên GitHub là mã nguồn mở, nhưng điều khoản khác nhau từng repo — mở file LICENSE để xác nhận.
slab/delta-elixir có trang demo không?
Dự án có trang chủ ở https://slab.com/blog/announcing-delta-for-elixir/. Tab "Readme" ở trang này thường có ảnh chụp và hướng dẫn bắt đầu nhanh.
slab/delta-elixir còn đang phát triển không?
Commit gần nhất trên slab/delta-elixir là 4 tháng trước (theo timestamp GitHub). Repo có 15 fork — một chỉ báo về mức độ quan tâm của cộng đồng.
Đọc đầy đủ README ở tab phía trên.
Vẫn đang phân vân về delta-elixir?
Một cú bấm sẽ gửi câu hỏi kèm trang này cho AI — xem AI nói gì về delta-elixir.