Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Feature/next.js #69, #62 #86

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 60 commits into from
Apr 3, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
60 commits
Select commit Hold shift + click to select a range
9e8c399
chore:build front
HMarzban Mar 17, 2023
fae59de
refactor: wrapping content with new heading #80
HMarzban Mar 21, 2023
92a0b2e
refactor: find preve heading pos
HMarzban Mar 21, 2023
fd3fbb8
feat: suggest a creative placeholder
HMarzban Mar 21, 2023
8fe6674
refactor: remove unnecessary log
HMarzban Mar 21, 2023
642cf0c
refactor: unused function
HMarzban Mar 21, 2023
8f7f13c
feat: add loading & #76
HMarzban Mar 21, 2023
ad9af7d
chore:build front
HMarzban Mar 21, 2023
1237f5b
feat: setting for section break #83
HMarzban Mar 22, 2023
a8bfe0c
feat: toc like like file explorer #78
HMarzban Mar 24, 2023
59a0185
fix: insert pos for wraping content with heading
HMarzban Mar 24, 2023
c5fa2ad
chore:build front
HMarzban Mar 24, 2023
1166b8b
fix: update meta tag path
HMarzban Mar 24, 2023
6f82e6f
chore:build front
HMarzban Mar 24, 2023
c38f51c
fix: assign heading id for first heading section
HMarzban Mar 24, 2023
62c1798
fix: remove unnecessary logs
HMarzban Mar 24, 2023
ef07b56
chore:build front
HMarzban Mar 24, 2023
50bf285
fix: h1 section break setting
HMarzban Mar 27, 2023
6b0b3d9
refactor: enhance store meta data into indexdb #77
HMarzban Mar 27, 2023
86e864c
chore: check .env file exists
HMarzban Mar 27, 2023
fc8ab4f
chore:build front
HMarzban Mar 27, 2023
f676f00
chore: check .env
HMarzban Mar 27, 2023
2a0facf
chore:build front
HMarzban Mar 27, 2023
4035faa
chore: check .env
HMarzban Mar 27, 2023
6d13098
chore:build front
HMarzban Mar 27, 2023
bef9e88
chore: yarn build
HMarzban Mar 27, 2023
72207c5
chore:build front
HMarzban Mar 27, 2023
779de51
chore: fix dir build
HMarzban Mar 27, 2023
f48b03c
chore:build front
HMarzban Mar 27, 2023
f7d50a5
chore: fix dir build
HMarzban Mar 27, 2023
ae5b566
chore:build front
HMarzban Mar 27, 2023
08b433c
chore:build front
HMarzban Mar 27, 2023
8ad2972
chore: build front
HMarzban Mar 27, 2023
5b1db9e
fix: concat string url
HMarzban Mar 27, 2023
c6345de
chore:build front
HMarzban Mar 27, 2023
5a4d9dd
chore: update dependencies
HMarzban Mar 27, 2023
712e2a4
chore: yarn install --force
HMarzban Mar 27, 2023
3ebdd8a
chore:build front
HMarzban Mar 27, 2023
f724f0d
chore: build front
HMarzban Mar 27, 2023
54aba44
chore: log fetch data
HMarzban Mar 27, 2023
5f79a19
chore:build front
HMarzban Mar 27, 2023
d832778
refactor: set credentials to header
HMarzban Mar 27, 2023
ae884ff
chore:build front
HMarzban Mar 27, 2023
6fa8043
refactor: replace fetch with axios
HMarzban Mar 27, 2023
e6591d0
chore:build front
HMarzban Mar 27, 2023
7b0ac53
chore:build front
HMarzban Mar 27, 2023
154460d
chore: build front
HMarzban Mar 27, 2023
df39204
chore: build front
HMarzban Mar 27, 2023
c63b61d
refactor: wrong url
HMarzban Mar 27, 2023
4bf6ecf
chore:build front
HMarzban Mar 27, 2023
0f8d82f
chore: build front
HMarzban Mar 27, 2023
75a8759
chore: build fron
HMarzban Mar 27, 2023
90854bc
chore:build front
HMarzban Mar 27, 2023
504d026
chore: build front
HMarzban Mar 27, 2023
c1ef38a
chore: build front
HMarzban Mar 27, 2023
b51a9da
chore:build front
HMarzban Mar 17, 2023
0830c24
chore:build front back
HMarzban Mar 27, 2023
64645ef
migrate: next.js v13.2.4 & tiptap v2.0.1
shayanmemarzade Apr 3, 2023
d53edb6
fix: remove yarn.lock
shayanmemarzade Apr 3, 2023
ab62e44
Merge branch 'dev' into feature/next.js
HMarzban Apr 3, 2023
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions 2 packages/next.js/.env.example
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
NEXT_PUBLIC_PROVIDER_URL='ws://localhost:2300/collaboration'
NEXT_PUBLIC_RESTAPI_URL='http://localhost:2300/api'
48 changes: 48 additions & 0 deletions 48 packages/next.js/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
# See https://help.github.com/articles/ignoring-files/ for more about ignoring files.

# dependencies
/node_modules
/.pnp
.pnp.js

# testing
/coverage

# next.js
/.next/
/out/

# production
/build

# misc
.DS_Store
*.pem

# debug
npm-debug.log*
yarn-debug.log*
yarn-error.log*

# local env files
.env*.local
.env*.production

# vercel
.vercel

# typescript
*.tsbuildinfo
next-env.d.ts

# next-pwa
/public/precache.*.*.js
/public/sw.js
/public/workbox-*.js
/public/worker-*.js
/public/fallback-*.js
/public/precache.*.*.js.map
/public/sw.js.map
/public/workbox-*.js.map
/public/worker-*.js.map
/public/fallback-*.js
23 changes: 23 additions & 0 deletions 23 packages/next.js/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
# Progressive Web App Example

This example uses [`next-pwa`](https://github.com/shadowwalker/next-pwa) to create a progressive web app (PWA) powered by [Workbox](https://developers.google.com/web/tools/workbox/).

## Deploy your own

Deploy the example using [Vercel](https://vercel.com?utm_source=github&utm_medium=readme&utm_campaign=next-example):

[![Deploy with Vercel](https://vercel.com/button)](https://vercel.com/new/git/external?repository-url=https://github.com/vercel/next.js/tree/canary/examples/progressive-web-app&project-name=progressive-web-app&repository-name=progressive-web-app)

## How to use

Execute [`create-next-app`](https://github.com/vercel/next.js/tree/canary/packages/create-next-app) with [npm](https://docs.npmjs.com/cli/init), [Yarn](https://yarnpkg.com/lang/en/docs/cli/create/), or [pnpm](https://pnpm.io) to bootstrap the example:

```bash
npx create-next-app --example progressive-web-app progressive-web-app
# or
yarn create next-app --example progressive-web-app progressive-web-app
# or
pnpm create next-app --example progressive-web-app progressive-web-app
```

Deploy it to the cloud with [Vercel](https://vercel.com/new?utm_source=github&utm_medium=readme&utm_campaign=next-example) ([Documentation](https://nextjs.org/docs/deployment)).
21 changes: 21 additions & 0 deletions 21 packages/next.js/components/Button.jsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
const Button = ({ children, style, onClick: click, loading, className }) => {
return (
<button className={'w-full text-center flex justify-center items-center px-4 py-2 leading-6 border rounded-md transition ease-in-out duration-150' + className}
disabled={loading}
style={style}
type="button"
onClick={click}>
{loading
? <>
<svg className="animate-spin -ml-1 mr-3 h-5 w-5 " fill="none" viewBox="0 0 24 24" xmlns="http://www.w3.org/2000/svg">
<circle className="opacity-25" cx="12" cy="12" r="10" stroke="currentColor" strokeWidth="4"></circle>
<path className="opacity-75" d="M4 12a8 8 0 018-8V0C5.373 0 0 5.373 0 12h4zm2 5.291A7.962 7.962 0 014 12H0c0 3.042 1.135 5.824 3 7.938l3-2.647z" fill="currentColor"></path>
</svg>
Processing...
</>
: children}
</button>
)
}

export default Button
37 changes: 37 additions & 0 deletions 37 packages/next.js/components/Counter.jsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@

import { useEffect, useRef, useState } from 'react'

const Counter = ({ seconds, callback, stopTimer }) => {
const [timeLeft, setTimeLeft] = useState(+seconds)
const intervalRef = useRef()

useEffect(() => {
intervalRef.current = setInterval(() => {
setTimeLeft((t) => t - 1)
}, 1000)

return () => {
console.log('aklsdlaks;dlk close')
clearInterval(intervalRef.current)
}
}, [])

// useEffect(() => {
// console.log("stopTimer changed", stopTimer)
// }, [stopTimer])

useEffect(() => {
if (timeLeft <= 0) {
clearInterval(intervalRef.current)
if (callback) callback()
}
}, [timeLeft])

return (
<>
<div>{timeLeft}s</div>
</>
)
}

export default Counter
98 changes: 98 additions & 0 deletions 98 packages/next.js/components/ReloadPrompt.jsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,98 @@
import React, { useState, useEffect } from 'react'
import Counter from './Counter'
const intervalMS = 1000 * 60 // 1min

const PwaUpdater = () => {
const wb = window?.workbox

const [isOpen, setIsOpen] = useState(false);
const onConfirmActivate = () => wb.messageSkipWaiting();


if (typeof window !== 'undefined' && 'serviceWorker' in navigator && window.workbox !== undefined) {

useEffect(() => {

console.log("ReloadPrompt", wb)
// add event listeners to handle any of PWA lifecycle event
// https://developers.google.com/web/tools/workbox/reference-docs/latest/module-workbox-window.Workbox#events
wb.addEventListener('installed', event => {
console.log(`Event ${event.type} is triggered.`)
console.log(event)
})

wb.addEventListener('controlling', event => {
console.log(`Event ${event.type} is triggered.`)
console.log(event)
window.location.reload();
})

wb.addEventListener('activated', event => {
console.log(`Event ${event.type} is triggered.`)
console.log(event)
})

// A common UX pattern for progressive web apps is to show a banner when a service worker has updated and waiting to install.
// NOTE: MUST set skipWaiting to false in next.config.js pwa object
// https://developers.google.com/web/tools/workbox/guides/advanced-recipes#offer_a_page_reload_for_users
const promptNewVersionAvailable = event => {
console.log("promptNewVersionAvailable", event)
// `event.wasWaitingBeforeRegister` will be false if this is the first time the updated service worker is waiting.
// When `event.wasWaitingBeforeRegister` is true, a previously updated service worker is still waiting.
// You may want to customize the UI prompt accordingly.
if (confirm('A newer version of this web app is available, reload to update?')) {
wb.addEventListener('controlling', event => {
// window.location.reload()
console.log("new version is available")
})

// Send a message to the waiting service worker, instructing it to activate.
// wb.messageSkipWaiting()
} else {
console.log(
'User rejected to reload the web app, keep using old version. New version will be automatically load when user open the app next time.'
)
}
}

// wb.addEventListener('waiting', promptNewVersionAvailable)
wb.addEventListener('waiting', () => setIsOpen(true));
wb.register();

// ISSUE - this is not working as expected, why?
// I could only make message event listenser work when I manually add this listenser into sw.js file
wb.addEventListener('message', event => {
console.log(`Event ${event.type} is triggered.`)
console.log(event)
})

}, []);

}


return (
<div className={`${isOpen? 'visible': 'hidden'} fixed bottom-2 left-2 p-3 z-50 rounded-md shadow bg-white`}>
<p>
Hey, a new version is available! Please click below to update.
</p>
<div className='pt-2 flex'>
<button
className="border outline mr-2 px-3 py-1 outline-none rounded-md bg-blue-500 text-white hover:bg-blue-600"
onClick={onConfirmActivate}
>
Reload and update
</button>
<button
className="border outline mr-2 px-3 py-1 outline-none rounded-md hover:bg-slate-500 hover:text-white"
onClick={() => setIsOpen(false)}
>
Cancel
</button>
</div>

</div>
);
}

export default PwaUpdater;
56 changes: 56 additions & 0 deletions 56 packages/next.js/components/TipTap/OnlineIndicator.jsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
import React, { useState, useEffect } from 'react'

import { OfflineCloud, OnlineCloud } from '../icons/Icons'

const OnlineIndicator = () => {
const [isOnline, setIsOnline] = useState(false)
const [showStatus, setShowStatus] = useState(true)


useEffect(() => {
const handleOnlineStatus = () => {
setIsOnline(true)
setShowStatus(true)
}
const handleOfflineStatus = () => {
setIsOnline(false)
setShowStatus(true)
}

window.addEventListener('online', handleOnlineStatus)
window.addEventListener('offline', handleOfflineStatus)

return () => {
window.removeEventListener('online', handleOnlineStatus)
window.removeEventListener('offline', handleOfflineStatus)
}
}, [])

useEffect(() => {
if (showStatus) {
const timer = setTimeout(() => {
setShowStatus(false)
}, 5000)

return () => clearTimeout(timer)
}
}, [showStatus])

return (
<div className=''>
{showStatus && (
<div className={` flex align-baseline justify-center status ${isOnline ? 'online' : 'offline'}`}>
{isOnline
? <span className='flex align-baseline justify-center text-xs font-medium text-gray-500'>
<OnlineCloud className="mr-2" /> Saved to docsplus
</span>
: <span className='flex align-baseline justify-center text-xs font-medium text-gray-500'>
<OfflineCloud className="mr-2"/>Working offline
</span>}
</div>
)}
</div>
)
}

export default OnlineIndicator
72 changes: 72 additions & 0 deletions 72 packages/next.js/components/TipTap/PadTitle.jsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
import Link from 'next/link'

import { useMutation, useQueryClient } from '@tanstack/react-query'

import {
DocsPlus
} from '../icons/Icons'

import OnlineIndicator from './OnlineIndicator'

const PadTitle = ({ docTitle, docId,docSlug, provider }) => {
const queryClient = useQueryClient()

const { isLoading, isSuccess, mutate } = useMutation({
mutationKey: ['updateDocumentMetadata'],
mutationFn: ({ title, docId }) => {
// NOTE: This is a hack to get the correct URL in the build time
const url = `${process.env.NEXT_PUBLIC_RESTAPI_URL}/documents/${docId.split('.').at(-1)}`


return fetch(url, {
method: 'PUT',
headers: {
'Content-Type': 'application/json'
},
body: JSON.stringify({ title })
})
.then(res => res.json())
},
onSuccess: (data) => {
queryClient.setQueryData(['getDocumentMetadataByDocName'], data)
}
})

const saveData = (e) => {
if (e.target.innerText === docTitle) return
mutate({
title: e.target.innerText,
docId: docId.split('.').at(-1)
})
}


return (
<div className='flex flex-row items-center'>
<div className='padLog'>
<Link href="/">
<DocsPlus size="34" />
</Link>
</div>
<div className='ml-3'>
{isLoading
? 'Loading...'
: <div dangerouslySetInnerHTML={{ __html: docTitle }}
contentEditable
className="border border-transparent px-2 py-0 rounded-sm text-lg font-medium min-w-[14rem] hover:border-slate-300" type="text"
onBlur={saveData}
onKeyDown={(e) => {
if (event.key === 'Enter') {
e.preventDefault()
e.target.blur()
}
}}
>
</div>}
</div>
<OnlineIndicator/>
</div>
)
}

export default PadTitle
Loading
Morty Proxy This is a proxified and sanitized view of the page, visit original site.