This commit is contained in:
Mayel de Borniol 2024-03-31 10:53:20 +01:00
parent f9cc570a87
commit 85c38faab0
6 changed files with 170 additions and 101 deletions

View file

@ -1,41 +1,5 @@
## GENERAL
bonfire = "https://github.com/bonfire-networks/bonfire_spark#main"
bonfire_mailer = "https://github.com/bonfire-networks/bonfire_mailer#main"
bonfire_epics = "https://github.com/bonfire-networks/bonfire_epics#main"
bonfire_ecto = "https://github.com/bonfire-networks/bonfire_ecto#main"
bonfire_search = "https://github.com/bonfire-networks/bonfire_search#main"
bonfire_data_assort = "https://github.com/bonfire-networks/bonfire_data_assort"
bonfire_files = "https://github.com/bonfire-networks/bonfire_files#main"
bonfire_boundaries = "https://github.com/bonfire-networks/bonfire_boundaries#main"
bonfire_federate_activitypub = "https://github.com/bonfire-networks/bonfire_federate_activitypub#main"
bonfire_invite_links= "https://github.com/bonfire-networks/bonfire_invite_links#main"
## Flavour:CLASSIC
bonfire_data_access_control = "https://github.com/bonfire-networks/bonfire_data_access_control#main"
bonfire_data_activity_pub = "https://github.com/bonfire-networks/bonfire_data_activity_pub#main"
bonfire_data_identity = "https://github.com/bonfire-networks/bonfire_data_identity#main"
bonfire_data_social = "https://github.com/bonfire-networks/bonfire_data_social#main"
bonfire_data_edges = "https://github.com/bonfire-networks/bonfire_data_edges#main"
bonfire_me = "https://github.com/bonfire-networks/bonfire_me#main"
bonfire_social = "https://github.com/bonfire-networks/bonfire_social#main"
bonfire_social_graph = "https://github.com/bonfire-networks/bonfire_social_graph"
bonfire_posts = "https://github.com/bonfire-networks/bonfire_posts"
bonfire_messages = "https://github.com/bonfire-networks/bonfire_messages"
bonfire_ui_social = "https://github.com/bonfire-networks/bonfire_ui_social#main"
bonfire_ui_social_graph = "https://github.com/bonfire-networks/bonfire_ui_social_graph"
bonfire_ui_posts = "https://github.com/bonfire-networks/bonfire_ui_posts"
bonfire_ui_messages = "https://github.com/bonfire-networks/bonfire_ui_messages"
bonfire_ui_reactions = "https://github.com/bonfire-networks/bonfire_ui_reactions"
bonfire_ui_moderation = "https://github.com/bonfire-networks/bonfire_ui_moderation"
bonfire_ui_me = "https://github.com/bonfire-networks/bonfire_ui_me#main"
# bonfire_data_shared_user = "https://github.com/bonfire-networks/bonfire_data_shared_user#main"
bonfire_tag = "https://github.com/bonfire-networks/bonfire_tag#main"
bonfire_classify = "https://github.com/bonfire-networks/bonfire_classify#main"
# bonfire_editor_ck = "https://github.com/bonfire-networks/bonfire_editor_ck#main"
# bonfire_editor_quill = "https://github.com/bonfire-networks/bonfire_editor_quill#main"
bonfire_editor_milkdown = "https://github.com/bonfire-networks/bonfire_editor_milkdown"
## EXPERIMENTAL ##
bonfire_label = "https://github.com/bonfire-networks/bonfire_label#main"

View file

@ -4,7 +4,7 @@ This file was generated by the Surface compiler.
import { defaultValueCtx, editorViewOptionsCtx, Editor, editorViewCtx, commandsCtx, rootCtx } from '@milkdown/core';
import { $prose, replaceAll, insert} from '@milkdown/utils';
import { commonmark, wrapInHeadingCommand, toggleStrongCommand, toggleEmphasisCommand} from '@milkdown/preset-commonmark';
import { commonmark, wrapInHeadingCommand, toggleStrongCommand, toggleEmphasisCommand, remarkInlineLinkPlugin } from '@milkdown/preset-commonmark';
import {gfm} from "@milkdown/preset-gfm";
import { emoji } from '@milkdown/plugin-emoji';
import { listener, listenerCtx } from '@milkdown/plugin-listener';
@ -330,8 +330,7 @@ const createEditor = async (_this, hidden_input, composer$) => {
ctx.get(listenerCtx)
.markdownUpdated((ctx, markdown, prevMarkdown) => {
const transformedMarkdown = markdown
.replace(/!\[(.*?)\]\(.*?\)/g, '$1')
.replace(/\[(.*?)\]\(.*?\)/g, '$1');
.replace(/!\[(.*?)\]\(.*?\)/g, '$1');
hidden_input.value = transformedMarkdown;
console.log(hidden_input.value);
const inputEvent = new Event('input', {
@ -349,6 +348,7 @@ const createEditor = async (_this, hidden_input, composer$) => {
})
// .config(nord)
.use(commonmark)
.use(remarkInlineLinkPlugin)
.use(gfm)
.use(emoji)
.use(listener)

View file

@ -2,6 +2,10 @@
This file was generated by the Surface compiler.
*/
/*
This file was generated by the Surface compiler.
*/
let PreviewActivity = {
isTruncated(element) {
@ -18,24 +22,41 @@ let PreviewActivity = {
this.el.addEventListener("click", e => {
console.log("PreviewActivity clicked")
let trigger = this.el.querySelector('.open_preview_link')
let anchor = e.target.closest('a')
console.log(e.target)
// this was used to expand long posts by clicking on them, now replaced with a 'Read more' button
// let previewable_activity = e.target.closest('.previewable_activity')
// anchor == trigger || (!anchor && previewable_activity && ( previewable_activity.classList.contains('previewable_expanded') || this.isTruncated(previewable_activity.querySelector('.previewable_truncate')) == false)
let anchor = e.target.closest('a')
console.log(e.target)
// this was used to expand long posts by clicking on them, now replaced with a 'Read more' button
// let previewable_activity = e.target.closest('.previewable_activity')
// anchor == trigger || (!anchor && previewable_activity && ( previewable_activity.classList.contains('previewable_expanded') || this.isTruncated(previewable_activity.querySelector('.previewable_truncate')) == false)
if ((trigger || !window.liveSocket) && ((!anchor || anchor.classList.contains('preview_activity_link')) && !e.ctrlKey && !e.metaKey && (!window.getSelection().toString() || window.getSelection().toString() == "") && !e.target.closest('button') && !e.target.closest('figure') && !e.target.closest('.dropdown') && !e.target.closest('[data-id=activity_actions]')
)) {
let uri = this.el.dataset.href || (trigger !== undefined && trigger.getAttribute('href'))
if (window.liveSocket) {
)) {
let uri = this.el.dataset.href || (trigger !== undefined && trigger.getAttribute('href'))
if (window.liveSocket) {
if (!e.target.closest('#preview_content')) {
// if we're not already in preview_content (i.e. for feed in extra_contents, because it's in a different LV), don't use this and just redirect
console.log("fallback to navigate")
let uri = this.el.dataset.href || (trigger !== undefined && trigger.getAttribute('href'))
if (uri) {
this.pushEvent(
"navigate",
{ to: uri }
)
}
} else {
console.log("push event to load up the PreviewContent")
// const feed = document.querySelector(".feed")
const main = document.getElementById("inner")
const layout = document.getElementById("root")
const main = document.getElementById("inner")
const preview_content = document.getElementById("preview_content")
const extra_contents = document.getElementById("the_extra_contents")
let previous_scroll = null
console.log("push event to load up the PreviewContent")
this.pushEventTo(trigger, "open", {})
// this.pushEvent("Bonfire.Social.Feeds:open_activity", { id: this.el.dataset.id, permalink: uri })
@ -44,12 +65,16 @@ let PreviewActivity = {
previous_scroll = layout.scrollTop
}
if (preview_content) {
preview_content.classList.remove("hidden")
}
if (main) {
main.classList.add("hidden")
}
if (extra_contents) {
extra_contents.classList.add("hidden")
}
if (preview_content) {
preview_content.classList.remove("hidden")
}
if (uri) {
// console.log(uri)
@ -63,30 +88,33 @@ let PreviewActivity = {
}
e.preventDefault();
} else {
// fallback if not connected with live socket
if (uri) {
console.log(uri)
window.location = uri;
e.preventDefault();
} else {
console.log("No URL")
}
}
} else {
// fallback if not connected with live socket
if (uri) {
console.log(uri)
window.location = uri;
e.preventDefault();
} else {
console.log("No URL")
}
}
} else {
// e.preventDefault();
console.log("PreviewActivity: do not trigger preview in favour of another link or button's action (or opening in new tab)")
console.log(trigger)
console.log(window.liveSocket)
console.log(anchor)
console.log(anchor.classList)
// console.log(anchor.classList)
console.log(e.ctrlKey)
console.log(e.metaKey)
console.log(window.getSelection().toString())
@ -95,14 +123,14 @@ let PreviewActivity = {
console.log(e.target.closest('.dropdown'))
console.log(e.target.closest('[data-id=activity_actions]'))
// if (previewable_activity) { previewable_activity.classList.add("previewable_expanded") }
// if (previewable_activity) { previewable_activity.classList.add("previewable_expanded") }
return;
return;
}
}
})
}
@ -129,21 +157,44 @@ let PreviewActivity = {
// }
// }
let PreviewExtra = {
mounted() {
this.el.addEventListener("click", e => {
console.log("click - attempt showing extra preview")
e.preventDefault();
let ClosePreview = {
const preview_content = document.getElementById("preview_content")
const main = document.getElementById("inner")
if (main && preview_content) {
main.classList.add("hidden")
const the_preview_contents = document.getElementById("the_preview_contents")
if (the_preview_contents) { the_preview_contents.classList.add("hidden") }
const extra_contents = document.getElementById("extra_contents")
if (extra_contents) { extra_contents.classList.remove("hidden") }
preview_content.classList.add("!visible")
preview_content.classList.add("!h-auto")
preview_content.classList.remove("hidden")
} else {
console.log("fallback to navigate")
this.pushEvent(
"navigate",
{ to: this.el.dataset.to || "#unknown_to" }
)
}
})
}
}
let ClosePreview = {
mounted() {
const back = function () {
const layout = document.getElementById("root")
const main = document.getElementById("inner")
const preview_content = document.getElementById("preview_content")
if (preview_content) {
preview_content.classList.add("hidden")
}
const maybe_browser_back = function () {
if (history.state) {
location_before_preview = history.state["previous_url"]
previous_scroll = history.state["previous_scroll"]
main.classList.remove("hidden")
if (location_before_preview) {
history.pushState({}, '', location_before_preview)
}
@ -154,10 +205,38 @@ let ClosePreview = {
}
}
const close_or_back = function () {
const the_preview_contents = document.getElementById("the_preview_contents")
const the_extra_contents = document.getElementById("the_extra_contents")
if (the_preview_contents && the_extra_contents) {
console.log("click - attempt going back to extra content")
const extra_contents = document.getElementById("extra_contents")
the_preview_contents.classList.add("hidden")
extra_contents.classList.remove("hidden")
the_extra_contents.classList.remove("hidden")
} else {
if (the_extra_contents) {
console.log("click - attempt going back to main view")
const preview_content = document.getElementById("preview_content")
const main = document.getElementById("inner_inner") || document.getElementById("inner")
preview_content.classList.add("hidden")
main.classList.remove("hidden")
} else {
console.log("click - attempt browser back")
maybe_browser_back()
}
}
}
// close button
this.el.addEventListener("click", e => {
console.log("click - attempt going back")
back()
close_or_back()
})
// intercept browser "back" action
@ -169,10 +248,34 @@ let ClosePreview = {
console.log("qui")
// this.pushEvent("Bonfire.UI.Common.OpenPreviewLive:close", {})
back();
close_or_back();
})
}
}
export { PreviewActivity, ClosePreview }
let CloseAll = {
mounted() {
// close button
this.el.addEventListener("click", e => {
const the_preview_contents = document.getElementById("the_preview_contents")
const the_extra_contents = document.getElementById("the_extra_contents")
if (the_extra_contents || the_preview_contents) {
console.log("click - attempt going back to main view")
const main = document.getElementById("inner")
main.innerHTML = ""; // empty previous contents - TODO: show loading placeholder/animation? and skip if destination is existing view
const preview_content = document.getElementById("preview_content")
preview_content.classList.add("hidden")
main.classList.remove("hidden")
} else {
console.log("click - no preview open, stick to default action")
}
})
}
}
export { PreviewActivity, PreviewExtra, ClosePreview, CloseAll }

View file

@ -12,24 +12,26 @@ function ns(hooks, nameSpace) {
import * as c1 from "./Bonfire.Editor.Milkdown.hooks"
import * as c2 from "./Bonfire.UI.Common.ViewCodeLive.hooks"
import * as c3 from "./Bonfire.UI.Common.PreviewContentLive.hooks"
import * as c4 from "./Bonfire.UI.Common.NotificationLive.hooks"
import * as c5 from "./Bonfire.UI.Common.LoadMoreLive.hooks"
import * as c6 from "./Bonfire.UI.Common.ChangeLocaleLive.hooks"
import * as c7 from "./Bonfire.UI.Common.ChangeThemesLive.hooks"
import * as c8 from "./Bonfire.UI.Common.ComposerLive.hooks"
import * as c9 from "./Bonfire.UI.Social.Activity.DateAgoLive.hooks"
import * as c3 from "./Bonfire.UI.Common.LazyImage.hooks"
import * as c4 from "./Bonfire.UI.Common.PreviewContentLive.hooks"
import * as c5 from "./Bonfire.UI.Common.NotificationLive.hooks"
import * as c6 from "./Bonfire.UI.Common.LoadMoreLive.hooks"
import * as c7 from "./Bonfire.UI.Common.ChangeLocaleLive.hooks"
import * as c8 from "./Bonfire.UI.Common.ChangeThemesLive.hooks"
import * as c9 from "./Bonfire.UI.Common.ComposerLive.hooks"
import * as c10 from "./Bonfire.UI.Social.Activity.DateAgoLive.hooks"
let hooks = Object.assign(
ns(c1, "Bonfire.Editor.Milkdown"),
ns(c2, "Bonfire.UI.Common.ViewCodeLive"),
ns(c3, "Bonfire.UI.Common.PreviewContentLive"),
ns(c4, "Bonfire.UI.Common.NotificationLive"),
ns(c5, "Bonfire.UI.Common.LoadMoreLive"),
ns(c6, "Bonfire.UI.Common.ChangeLocaleLive"),
ns(c7, "Bonfire.UI.Common.ChangeThemesLive"),
ns(c8, "Bonfire.UI.Common.ComposerLive"),
ns(c9, "Bonfire.UI.Social.Activity.DateAgoLive")
ns(c3, "Bonfire.UI.Common.LazyImage"),
ns(c4, "Bonfire.UI.Common.PreviewContentLive"),
ns(c5, "Bonfire.UI.Common.NotificationLive"),
ns(c6, "Bonfire.UI.Common.LoadMoreLive"),
ns(c7, "Bonfire.UI.Common.ChangeLocaleLive"),
ns(c8, "Bonfire.UI.Common.ChangeThemesLive"),
ns(c9, "Bonfire.UI.Common.ComposerLive"),
ns(c10, "Bonfire.UI.Social.Activity.DateAgoLive")
)
export default hooks

View file

@ -378,7 +378,7 @@ defmodule Bonfire.Umbrella.MixProject do
"ecto.setup": ["ecto.create", "ecto.migrate"],
"ecto.migrate": ["bonfire.seeds"],
"ecto.reset": ["ecto.drop --force", "ecto.setup"],
test: ["ecto.create --quiet", "ecto.migrate --quiet", "test"],
"test.with-db": ["ecto.create --quiet", "ecto.migrate --quiet", "test"],
sobelow: ["cmd mix sobelow"]
]
end

View file

@ -1 +1 @@
Bonfire.Testing.configure_start_test()
Bonfire.Testing.configure_start_test(migrate: true)