text
stringlengths 2
104M
| meta
dict |
---|---|
# frozen_string_literal: true
require 'flickraw'
FlickRaw.api_key = Rails.configuration.flickr['api_key']
FlickRaw.shared_secret = Rails.configuration.flickr['shared_secret']
| {
"repo_name": "GSA/asis",
"stars": "30",
"repo_language": "Ruby",
"file_name": "500.html",
"mime_type": "text/html"
} |
# frozen_string_literal: true
# Be sure to restart your server when you modify this file.
# Configure sensitive parameters which will be filtered from the log file.
Rails.application.config.filter_parameters += [:password, :query]
| {
"repo_name": "GSA/asis",
"stars": "30",
"repo_language": "Ruby",
"file_name": "500.html",
"mime_type": "text/html"
} |
# Files in the config/locales directory are used for internationalization
# and are automatically loaded by Rails. If you want to use locales other
# than English, add the necessary files in this directory.
#
# To use the locales, use `I18n.t`:
#
# I18n.t 'hello'
#
# In views, this is aliased to just `t`:
#
# <%= t('hello') %>
#
# To use a different locale, set it with `I18n.locale`:
#
# I18n.locale = :es
#
# This would use the information in config/locales/es.yml.
#
# The following keys must be escaped otherwise they will not be retrieved by
# the default I18n backend:
#
# true, false, on, off, yes, no
#
# Instead, surround them with single quotes.
#
# en:
# 'true': 'foo'
#
# To learn more, please read the Rails Internationalization guide
# available at https://guides.rubyonrails.org/i18n.html.
en:
hello: "Hello world"
| {
"repo_name": "GSA/asis",
"stars": "30",
"repo_language": "Ruby",
"file_name": "500.html",
"mime_type": "text/html"
} |
# Import these from https://github.com/GSA/punchcard
gas | {
"repo_name": "GSA/asis",
"stars": "30",
"repo_language": "Ruby",
"file_name": "500.html",
"mime_type": "text/html"
} |
# Import these from https://github.com/GSA/punchcard
the | {
"repo_name": "GSA/asis",
"stars": "30",
"repo_language": "Ruby",
"file_name": "500.html",
"mime_type": "text/html"
} |
# Import these from https://github.com/GSA/punchcard
gas, petrol | {
"repo_name": "GSA/asis",
"stars": "30",
"repo_language": "Ruby",
"file_name": "500.html",
"mime_type": "text/html"
} |
<!DOCTYPE html>
<html>
<head>
<title>The page you were looking for doesn't exist (404)</title>
<style>
body {
background-color: #EFEFEF;
color: #2E2F30;
text-align: center;
font-family: arial, sans-serif;
}
div.dialog {
width: 25em;
margin: 4em auto 0 auto;
border: 1px solid #CCC;
border-right-color: #999;
border-left-color: #999;
border-bottom-color: #BBB;
border-top: #B00100 solid 4px;
border-top-left-radius: 9px;
border-top-right-radius: 9px;
background-color: white;
padding: 7px 4em 0 4em;
}
h1 {
font-size: 100%;
color: #730E15;
line-height: 1.5em;
}
body > p {
width: 33em;
margin: 0 auto 1em;
padding: 1em 0;
background-color: #F7F7F7;
border: 1px solid #CCC;
border-right-color: #999;
border-bottom-color: #999;
border-bottom-left-radius: 4px;
border-bottom-right-radius: 4px;
border-top-color: #DADADA;
color: #666;
box-shadow:0 3px 8px rgba(50, 50, 50, 0.17);
}
</style>
</head>
<body>
<!-- This file lives in public/404.html -->
<div class="dialog">
<h1>The page you were looking for doesn't exist.</h1>
<p>You may have mistyped the address or the page may have moved.</p>
</div>
<p>If you are the application owner check the logs for more information.</p>
</body>
</html>
| {
"repo_name": "GSA/asis",
"stars": "30",
"repo_language": "Ruby",
"file_name": "500.html",
"mime_type": "text/html"
} |
# See http://www.robotstxt.org/wc/norobots.html for documentation on how to use the robots.txt file
#
# To ban all spiders from the entire site uncomment the next two lines:
# User-agent: *
# Disallow: /
| {
"repo_name": "GSA/asis",
"stars": "30",
"repo_language": "Ruby",
"file_name": "500.html",
"mime_type": "text/html"
} |
<!DOCTYPE html>
<html>
<head>
<title>The change you wanted was rejected (422)</title>
<style>
body {
background-color: #EFEFEF;
color: #2E2F30;
text-align: center;
font-family: arial, sans-serif;
}
div.dialog {
width: 25em;
margin: 4em auto 0 auto;
border: 1px solid #CCC;
border-right-color: #999;
border-left-color: #999;
border-bottom-color: #BBB;
border-top: #B00100 solid 4px;
border-top-left-radius: 9px;
border-top-right-radius: 9px;
background-color: white;
padding: 7px 4em 0 4em;
}
h1 {
font-size: 100%;
color: #730E15;
line-height: 1.5em;
}
body > p {
width: 33em;
margin: 0 auto 1em;
padding: 1em 0;
background-color: #F7F7F7;
border: 1px solid #CCC;
border-right-color: #999;
border-bottom-color: #999;
border-bottom-left-radius: 4px;
border-bottom-right-radius: 4px;
border-top-color: #DADADA;
color: #666;
box-shadow:0 3px 8px rgba(50, 50, 50, 0.17);
}
</style>
</head>
<body>
<!-- This file lives in public/422.html -->
<div class="dialog">
<h1>The change you wanted was rejected.</h1>
<p>Maybe you tried to change something you didn't have access to.</p>
</div>
<p>If you are the application owner check the logs for more information.</p>
</body>
</html>
| {
"repo_name": "GSA/asis",
"stars": "30",
"repo_language": "Ruby",
"file_name": "500.html",
"mime_type": "text/html"
} |
<!DOCTYPE html>
<html>
<head>
<title>We're sorry, but something went wrong (500)</title>
<style>
body {
background-color: #EFEFEF;
color: #2E2F30;
text-align: center;
font-family: arial, sans-serif;
}
div.dialog {
width: 25em;
margin: 4em auto 0 auto;
border: 1px solid #CCC;
border-right-color: #999;
border-left-color: #999;
border-bottom-color: #BBB;
border-top: #B00100 solid 4px;
border-top-left-radius: 9px;
border-top-right-radius: 9px;
background-color: white;
padding: 7px 4em 0 4em;
}
h1 {
font-size: 100%;
color: #730E15;
line-height: 1.5em;
}
body > p {
width: 33em;
margin: 0 auto 1em;
padding: 1em 0;
background-color: #F7F7F7;
border: 1px solid #CCC;
border-right-color: #999;
border-bottom-color: #999;
border-bottom-left-radius: 4px;
border-bottom-right-radius: 4px;
border-top-color: #DADADA;
color: #666;
box-shadow:0 3px 8px rgba(50, 50, 50, 0.17);
}
</style>
</head>
<body>
<!-- This file lives in public/500.html -->
<div class="dialog">
<h1>We're sorry, but something went wrong.</h1>
</div>
<p>If you are the application owner check the logs for more information.</p>
</body>
</html>
| {
"repo_name": "GSA/asis",
"stars": "30",
"repo_language": "Ruby",
"file_name": "500.html",
"mime_type": "text/html"
} |
cordova-hooks
---
Warning: These are the first iterations of the scripts. They can definitely be optimized and enhanced.
Since you are using **cordova-cli**, this means you already have `node` and `npm` installed.
These scripts take advantage of shell commands, so in order to run these, you must install [`shelljs`](https://github.com/arturadib/shelljs):
`npm install -g shelljs`
Installation
---
Copy the files in their corresponding directories found under `.cordova/hooks` in your project root directory.
Usage
---
Whenever you execute a specific `cordova` command, the appropriate hook script will be executed at the proper time.
License
---
cordova-hooks is provided under the terms of the [Unlicense](http://unlicense.org) license.
| {
"repo_name": "cdibened/cordova-hooks",
"stars": "42",
"repo_language": "JavaScript",
"file_name": "setup_ios_assets.js",
"mime_type": "text/plain"
} |
#!/usr/bin/env node
var path = require( "path" ),
fs = require( "fs" ),
shell = require( "shelljs" ),
rootdir = process.argv[ 2 ],
config = require(rootdir + "/.cordova/config.json"),
iconroot = rootdir + "/assets/icon/android",
screenroot = rootdir + "/assets/screen/android",
androidroot = rootdir + "/platforms/android";
try {
fs.lstatSync( androidroot ).isDirectory();
}
catch( e ) {
console.log( "android platform does not exist. nothing to do here." );
process.exit(0);
}
// incase there are any spaces in the projectname
var projectname = config.name.replace(" ", "\\ ");
// for some reason, using shell.cp() would throw this error:
// "cp: copy File Sync: could not write to dest file (code=ENOENT)"
shell.exec( "cp -Rf " + iconroot + "/* " + androidroot + "/res", {silent:true} );
shell.exec( "cp -Rf " + screenroot + "/* " + androidroot + "/res", {silent:true} );
console.log( "Copied all android assets." );
process.exit(0);
| {
"repo_name": "cdibened/cordova-hooks",
"stars": "42",
"repo_language": "JavaScript",
"file_name": "setup_ios_assets.js",
"mime_type": "text/plain"
} |
#!/usr/bin/env node
var path = require( "path" ),
fs = require( "fs" ),
shell = require( "shelljs" ),
rootdir = process.argv[ 2 ],
config = require(rootdir + "/.cordova/config.json"),
iconroot = rootdir + "/assets/icon/ios",
screenroot = rootdir + "/assets/screen/ios",
iosroot = rootdir + "/platforms/ios";
try {
fs.lstatSync( iosroot ).isDirectory();
}
catch( e ) {
console.log( "ios platform does not exist. nothing to do here." );
process.exit(0);
}
// incase there are any spaces in the projectname
var projectname = config.name.replace(" ", "\\ ");
// for some reason, using shell.cp() would throw this error:
// "cp: copy File Sync: could not write to dest file (code=ENOENT)"
shell.exec( "cp -Rf " + iconroot + "/*" + " " + iosroot + "/" + projectname + "/Resources/icons/" );
shell.exec( "cp -Rf " + screenroot + "/*" + " " + iosroot + "/" + projectname + "/Resources/splash/" );
console.log( "Copied all ios assets." );
process.exit(0);
| {
"repo_name": "cdibened/cordova-hooks",
"stars": "42",
"repo_language": "JavaScript",
"file_name": "setup_ios_assets.js",
"mime_type": "text/plain"
} |
#!/usr/bin/env node
var path = require( "path" ),
fs = require( "fs" ),
shell = require( "shelljs" ),
rootdir = process.argv[ 2 ],
androidroot = rootdir + "/platforms/android",
iconroot = rootdir + "/assets/icon/android",
screenroot = rootdir + "/assets/screen/android";
try {
fs.lstatSync( androidroot ).isDirectory();
console.log( "android platform already exists. skipping." );
}
catch( e ) {
//icon renaming to phonegap Android directories and filenames
[ "", "-hdpi", "-ldpi", "-mdpi", "-xhdpi" ].forEach( function( item ) {
shell.mkdir( "-p", iconroot + "/drawable" + item );
shell.exec( "cp " + iconroot + "/*" + item + ".png " + iconroot + "/drawable" + item + "/icon.png", {silent:true} );
});
shell.rm( iconroot + "/*.png" );
//splashscreen renaming to phonegap Android directories and filenames
[ "", "-hdpi", "-ldpi", "-mdpi", "-xhdpi" ].forEach( function( item ) {
shell.mkdir( "-p", screenroot + "/drawable" + item );
shell.exec( "cp " + screenroot + "/*" + item + "-p*.png " + screenroot + "/drawable" + item + "/splash.png", {silent:true} );
shell.exec( "cp " + screenroot + "/*" + item + "-l*.png " + screenroot + "/drawable" + item + "/splash_landscape.png", {silent:true} );
});
shell.rm( screenroot + "/*.png" );
}
process.exit(0);
| {
"repo_name": "cdibened/cordova-hooks",
"stars": "42",
"repo_language": "JavaScript",
"file_name": "setup_ios_assets.js",
"mime_type": "text/plain"
} |
#!/usr/bin/env node
var path = require( "path" ),
fs = require( "fs" ),
shell = require( "shelljs" ),
rootdir = process.argv[ 2 ],
wwwroot = rootdir + "/www",
resroot = wwwroot + "/res";
console.log( process.argv );
try {
fs.lstatSync( rootdir + "/.done" );
console.log( "Initial setup already done." );
}
catch( e ) {
shell.exec( "mv " + resroot + " " + rootdir + "/assets", {silent:true} );
shell.exec( "rm -rf " + resroot + "/spec" + rootdir + "/assets", {silent:true} );
// remove the spec directory and file. really not needed in the project workspaces.
shell.rm( "-rf", [ wwwroot + "/spec", wwwroot + "/spec.html" ] );
shell.exec( "touch " + rootdir + "/.done", {silent:true} );
}
process.exit(0);
| {
"repo_name": "cdibened/cordova-hooks",
"stars": "42",
"repo_language": "JavaScript",
"file_name": "setup_ios_assets.js",
"mime_type": "text/plain"
} |
#!/usr/bin/env node
var path = require( "path" ),
fs = require( "fs" ),
shell = require( "shelljs" ),
rootdir = process.argv[ 2 ],
iosroot = rootdir + "/platforms/ios",
iconroot = rootdir + "/assets/icon/ios",
screenroot = rootdir + "/assets/screen/ios";
try {
fs.lstatSync( iosroot ).isDirectory();
console.log( "ios platform already exists. skipping.");
}
catch( e ) {
//icon renaming
shell.exec( "mv -f " + iconroot + "/icon-57.png" + " " + iconroot + "/icon.png", {silent:true} );
shell.exec( "mv -f " + iconroot + "/icon-57-2x.png" + " " + iconroot + "/[email protected]", {silent:true} );
shell.exec( "mv -f " + iconroot + "/icon-72-2x.png" + " " + iconroot + "/[email protected]", {silent:true} );
//splashscreen renaming
shell.exec( "mv -f " + screenroot + "/screen-ipad-landscape.png" + " " + screenroot + "/Default-Landscape~ipad.png", {silent:true} );
shell.exec( "mv -f " + screenroot + "/screen-ipad-portrait.png" + " " + screenroot + "/Default-Portrait~ipad.png", {silent:true} );
shell.exec( "mv -f " + screenroot + "/screen-ipad-landscape-2x.png" + " " + screenroot + "/Default-Landscape@2x~ipad.png", {silent:true} );
shell.exec( "mv -f " + screenroot + "/screen-ipad-portrait-2x.png" + " " + screenroot + "/Default-Portrait@2x~ipad.png", {silent:true} );
shell.exec( "mv -f " + screenroot + "/screen-iphone-portrait.png" + " " + screenroot + "/Default~iphone.png", {silent:true} );
shell.exec( "mv -f " + screenroot + "/screen-iphone-landscape.png" + " " + screenroot + "/Default-Landscape~iphone.png", {silent:true} );
shell.exec( "mv -f " + screenroot + "/screen-iphone-landscape-2x.png" + " " + screenroot + "/Default-Landscape@2x~iphone.png", {silent:true} );
shell.exec( "mv -f " + screenroot + "/screen-iphone-portrait-2x.png" + " " + screenroot + "/Default@2x~iphone.png", {silent:true} );
shell.exec( "mv -f " + screenroot + "/screen-iphone-portrait-568h-2x.png" + " " + screenroot + "/Default-568h@2x~iphone.png", {silent:true} );
}
process.exit(0);
| {
"repo_name": "cdibened/cordova-hooks",
"stars": "42",
"repo_language": "JavaScript",
"file_name": "setup_ios_assets.js",
"mime_type": "text/plain"
} |
# Configuration file for GasPot
[host]
tcp_ip = 0.0.0.0
tcp_port = 10001
buffer_size = 1024
# The 'products' section defines the product names to be used. Localize
# these in order to decrease honeypot suspicion.
[products]
product1 = SUPER
product2 = UNLEAD
product3 = DIESEL
product4 = PREMIUM
# The 'stations' section defines the names for gas stations. These
# should be localized for decreased suspicion of being a honeypot.
[stations]
list = [
'EXXON STATION\n 12 Fake St\n Anytown, MO 12346',
'FUEL COOP',
'SHELL STATION',
'AMOCO FUELS',
'MOBIL STATION',
'MARATHON GAS',
'CHEVRON STATION',
'CITGO FUELS',
'BP FUELS',
'PILOT TRUCK STOP',
'FLYING J TRUCK STOP',
'LOVES FUEL STATION',
'SINCLAIR FUEL',
'VICTORY OIL',
'CONOCO FUELS',
'76 OIL',
'TEXACO STATION',
'PETRO-CANADA',
'TOTAL PETROL',
'HEM PETROL',
'ARAL PETROL',
'OBERT 24h',
'AGIP PETROL',
'ROMPETROL STATION',
'PETRON STATION',
'CIRCLE K STATION',
'LUK OIL',
'MURPHY OIL', ]
[parameters]
decimal_separator = .
low_temperature = 50
high_temperature = 60
min_h2o = 0
max_h2o = 9
min_height = 25
max_height = 75
min_vol = 1000
max_vol = 9050
min_ullage = 3000
max_ullage = 9999
| {
"repo_name": "sjhilt/GasPot",
"stars": "116",
"repo_language": "Python",
"file_name": "README.md",
"mime_type": "text/plain"
} |
#######################################################################
# gaspot.py
#
# This is a 'honeypot' to record any commands that were provided to the
# system. This will record the connection, and if any attempts are made.
# This is a basic attempt, with lots of room for improvement.
#
# 03/24/21 - Changed to Python3 (finally)
#
# Authors: Kyle Wilhoit
# Stephen Hilt
#
########################################################################
import socket
import select
import datetime
import random
import configparser
import ast
import argparse
import os
import sys
# Argument parsing only takes care of a configuration file to be specified
parser = argparse.ArgumentParser()
parser.add_argument('--config', help='specify a configuration file to be read', required=False)
parser.add_argument('--log', help='specify a path to log to', required=False, default='all_attempts.log')
parser.add_argument('--quiet', help='be quiet; log only to the logfile and not STDOUT', dest='quiet', action='store_true')
parser.set_defaults(quiet=False)
args = parser.parse_args()
# Determine the configuration file to use
configuration_file = args.config if args.config else 'config.ini'
# Check if the configuration file actually exists; exit if not.
if not os.path.isfile(configuration_file):
print('Please specify a configuration file or rename config.ini.dist to config.ini!')
sys.exit(1)
# Reading configuration information
config = configparser.ConfigParser()
config.read(configuration_file)
# Set vars for connection information
TCP_IP = config.get('host', 'tcp_ip')
TCP_PORT = config.getint('host', 'tcp_port')
BUFFER_SIZE = config.get('host', 'buffer_size')
NOW = datetime.datetime.utcnow()
FILLSTART = NOW - datetime.timedelta(minutes=313)
FILLSTOP = NOW - datetime.timedelta(minutes=303)
# Get the localized decimal separator
DS = config.get('parameters', 'decimal_separator')
# Default Product names, changed based on config.ini file
PRODUCT1 = config.get('products', 'product1').ljust(22)
PRODUCT2 = config.get('products', 'product2').ljust(22)
PRODUCT3 = config.get('products', 'product3').ljust(22)
PRODUCT4 = config.get('products', 'product4').ljust(22)
# Create random Numbers for the volumes
#
# this will crate an initial Volume and then the second value based
# off the orig value.
min_vol = config.getint('parameters', 'min_vol')
max_vol = config.getint('parameters', 'max_vol')
Vol1 = random.randint(min_vol, max_vol)
vol1tc = random.randint(Vol1, Vol1+200)
Vol2 = random.randint(min_vol, max_vol)
vol2tc = random.randint(Vol2, Vol2+200)
Vol3 = random.randint(min_vol, max_vol)
vol3tc = random.randint(Vol3, Vol3+200)
Vol4 = random.randint(min_vol, max_vol)
vol4tc = random.randint(Vol4, Vol4+200)
# unfilled space ULLAGE
min_ullage = config.getint('parameters', 'min_ullage')
max_ullage = config.getint('parameters', 'max_ullage')
ullage1 = str(random.randint(min_ullage, max_ullage))
ullage2 = str(random.randint(min_ullage, max_ullage))
ullage3 = str(random.randint(min_ullage, max_ullage))
ullage4 = str(random.randint(min_ullage, max_ullage))
# Height of tank
min_height = config.getint('parameters', 'min_height')
max_height = config.getint('parameters', 'max_height')
height1 = str(random.randint(min_height, max_height)) + DS + str(random.randint(10, 99))
height2 = str(random.randint(min_height, max_height)) + DS + str(random.randint(10, 99))
height3 = str(random.randint(min_height, max_height)) + DS + str(random.randint(10, 99))
height4 = str(random.randint(min_height, max_height)) + DS + str(random.randint(10, 99))
# Water in tank, this is a variable that needs to be low
min_h2o = config.getint('parameters', 'min_h2o')
max_h2o = config.getint('parameters', 'max_h2o')
h2o1 = str(random.randint(min_h2o, max_h2o)) + DS + str(random.randint(10, 99))
h2o2 = str(random.randint(min_h2o, max_h2o)) + DS + str(random.randint(10, 99))
h2o3 = str(random.randint(min_h2o, max_h2o)) + DS + str(random.randint(10, 99))
h2o4 = str(random.randint(min_h2o, max_h2o)) + DS + str(random.randint(10, 99))
# Temperature of the tank, this will need to be between 50 - 60
low_temp = config.getint('parameters', 'low_temperature')
high_temp = config.getint('parameters', 'high_temperature')
temp1 = str(random.randint(low_temp, high_temp)) + DS + str(random.randint(10, 99))
temp2 = str(random.randint(low_temp, high_temp)) + DS + str(random.randint(10, 99))
temp3 = str(random.randint(low_temp, high_temp)) + DS + str(random.randint(10, 99))
temp4 = str(random.randint(low_temp, high_temp)) + DS + str(random.randint(10, 99))
# List for station name, add more names if you want to have this look less like a honeypot
# this should include a list of gas station names based on the country of demployement
station_name = ast.literal_eval(config.get("stations", "list"))
slength = len(station_name)
station = station_name[random.randint(0, slength-1)]
# This function is to set-up up the message to be sent upon a successful I20100 command being sent
# The final message is sent with a current date/time stamp inside of the main loop.
def I20100():
I20100_1 = '''
I20100
'''
I20100_2 = '''
''' + station + '''
IN-TANK INVENTORY
TANK PRODUCT VOLUME TC VOLUME ULLAGE HEIGHT WATER TEMP
1 '''+ PRODUCT1 + '''''' + str(Vol1) + ''' '''+ str(vol1tc) +''' '''+ ullage1 +''' '''+ height1 +''' '''+ h2o1 +''' '''+ temp1 +'''
2 '''+ PRODUCT2 + '''''' + str(Vol2) + ''' '''+ str(vol2tc) +''' '''+ ullage2 +''' '''+ height2 +''' '''+ h2o2 +''' '''+ temp2 +'''
3 '''+ PRODUCT3 + '''''' + str(Vol3) + ''' '''+ str(vol3tc) +''' '''+ ullage3 +''' '''+ height3 +''' '''+ h2o3 +''' '''+ temp3 +'''
4 '''+ PRODUCT4 + '''''' + str(Vol4) + ''' '''+ str(vol4tc) +''' '''+ ullage4 +''' '''+ height4 +''' '''+ h2o4 +''' '''+ temp4 +'''
'''
return I20100_1 + str(TIME.strftime('%m/%d/%Y %H:%M')) + I20100_2
###########################################################################
#
# Only one Tank is listed currently in the I20200 command
#
###########################################################################
def I20200():
I20200_1 = '''
I20200
'''
I20200_2 = '''
''' + station + '''
DELIVERY REPORT
T 1:'''+ PRODUCT1 +'''
INCREASE DATE / TIME GALLONS TC GALLONS WATER TEMP DEG F HEIGHT
END: '''+ str(FILLSTOP.strftime('%m/%d/%Y %H:%M')) +''' '''+ str(Vol1 + 300) +''' '''+ str(vol1tc + 300) +''' '''+ h2o1 +''' '''+ temp1 +''' '''+ height1 +'''
START: '''+ str(FILLSTART.strftime('%m/%d/%Y %H:%M')) +''' '''+ str(Vol1 - 300) +''' '''+ str(vol1tc - 300) +''' '''+ h2o1 +''' '''+ temp1 +''' '''+ str(float(height1) - 23) +'''
AMOUNT: '''+ str(Vol1)+''' '''+ str(vol1tc) +'''
'''
return I20200_1 + str(TIME.strftime('%m/%d/%Y %H:%M')) + I20200_2
###########################################################################
#
# I20300 In-Tank Leak Detect Report
#
###########################################################################
def I20300():
I20300_1 = '''
I20300
'''
I20300_2 = '''
''' + station + '''
TANK 1 '''+ PRODUCT1 +'''
TEST STATUS: OFF
LEAK DATA NOT AVAILABLE ON THIS TANK
TANK 2 '''+ PRODUCT2 +'''
TEST STATUS: OFF
LEAK DATA NOT AVAILABLE ON THIS TANK
TANK 3 '''+ PRODUCT3 +'''
TEST STATUS: OFF
LEAK DATA NOT AVAILABLE ON THIS TANK
TANK 4 '''+ PRODUCT4 +'''
TEST STATUS: OFF
LEAK DATA NOT AVAILABLE ON THIS TANK
'''
return I20300_1 + str(TIME.strftime('%m/%d/%Y %H:%M')) + I20300_2
###########################################################################
# Shift report command I20400 only one item in report at this time,
# but can always add more if needed
###########################################################################
def I20400():
I20400_1 = '''
I20400
'''
I20400_2 = '''
''' + station + '''
SHIFT REPORT
SHIFT 1 TIME: 12:00 AM
TANK PRODUCT
1 '''+ PRODUCT1 +''' VOLUME TC VOLUME ULLAGE HEIGHT WATER TEMP
SHIFT 1 STARTING VALUES ''' + str(Vol1) +''' '''+ str(vol1tc) +''' '''+ ullage1 +''' '''+ height1 +''' '''+ h2o1 +''' '''+ temp1 +'''
ENDING VALUES ''' + str(Vol1 + 940) +''' '''+ str(vol1tc + 886) +''' '''+ str(int(ullage1) + 345) +''' '''+ str(float(height1) + 53)+''' '''+ h2o1 +''' '''+ temp1 +'''
DELIVERY VALUE 0
TOTALS 940
'''
return I20400_1 + str(TIME.strftime('%m/%d/%Y %H:%M')) + I20400_2
###########################################################################
# I20500 In-Tank Status Report
###########################################################################
def I20500():
I20500_1 = '''
I20500
'''
I20500_2 = '''
''' + station + '''
TANK PRODUCT STATUS
1 '''+ PRODUCT1 +''' NORMAL
2 '''+ PRODUCT2 +''' HIGH WATER ALARM
HIGH WATER WARNING
3 '''+ PRODUCT3 +''' NORMAL
4 '''+ PRODUCT4 +''' NORMAL
'''
return I20500_1 + str(TIME.strftime('%m/%d/%Y %H:%M')) + I20500_2
def log(mesg, destinations):
now = datetime.datetime.utcnow()
prefix = now.strftime('%m/%d/%Y %H:%M') + ': '
for destination in destinations:
destination.write(prefix + mesg)
log_destinations = [ open(args.log, 'a') ]
if not args.quiet:
log_destinations.append(sys.stdout)
# create the socket, bind, and start listening for incoming connections
server_socket = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
server_socket.setblocking(0)
server_socket.bind((TCP_IP, TCP_PORT))
server_socket.listen(10)
#
# Infinite Loop to provide a connection available on port 10001
# This is the default port for the AVG's that were found online
# via R7's research.
#
#
active_sockets = [server_socket]
while True:
readable, writeable, errored = select.select(active_sockets, [], [], 5)
for conn in readable:
if conn is server_socket:
new_con, addr = server_socket.accept()
new_con.settimeout(30.0)
active_sockets.append(new_con)
else:
addr = conn.getpeername()
try:
# get current time in UTC
TIME = datetime.datetime.utcnow()
# write out initial connection
log("Connection from : %s\n" % addr[0], log_destinations)
# Get the initial data
response = conn.recv(4096)
# The connection has been closed
if not response:
active_sockets.remove(conn)
conn.close()
continue
while not (b'\n' in response or b'00' in response):
response += conn.recv(4096)
# if first value is not ^A then do nothing
# thanks John(achillean) for the help
if response[0:2] == b"^A":
cmd = response.decode(errors='replace')[2:8] # strip ^A and \n out
elif response[0:1] == b"\x01":
cmd = response.decode(errors='replace')[1:7]
else:
log("Non ^A Command Attempt from: %s\n" % addr[0], log_destinations)
conn.close()
active_sockets.remove(conn)
continue
# if response is less than 6, than do nothing
if len(response.decode(errors='replace')) < 6:
log("Invalid Command Attempt from: %s\n" % addr[0], log_destinations)
conn.close()
active_sockets.remove(conn)
continue
cmds = {"I20100" : I20100, "I20200" : I20200, "I20300" : I20300 , "I20400" : I20400, "I20500" : I20500}
if cmd in cmds:
log("Handling %s Command Attempt from: %s\n" % (cmd, addr[0]), log_destinations)
conn.send(cmds[cmd]().encode(errors='replace'))
elif cmd.startswith("S6020"):
# change the tank name
if cmd.startswith("S60201"):
# split string into two, the command, and the data
TEMP = response.split('S60201'.encode(errors='replace'))
# if length is less than two, print error
if len(TEMP) < 2:
conn.send("9999FF1B\n".encode(errors='replace'))
# Else the command was entered correctly and continue
else:
# Strip off the carrage returns and new lines
TEMP1 = TEMP[1].rstrip("\r\n".encode(errors='replace')).decode(errors='replace')
# if Length is less than 22
if len(TEMP1) < 22:
# pad the result to have 22 chars
PRODUCT1 = TEMP1.ljust(22)
elif len(TEMP1) > 22:
# else only print 22 chars if the result was longer
PRODUCT1 = TEMP1[:20] + " "
else:
# else it fits fine (22 chars)
PRODUCT1 = TEMP1
#log result
log("S60201: "+ TEMP1 +" Command Attempt from: %s\n" % addr[0], log_destinations)
# Follows format for S60201 for comments
elif cmd.startswith("S60202"):
TEMP = response.split('S60202'.encode(errors='replace'))
if len(TEMP) < 2:
conn.send("9999FF1B\n".encode(errors='replace'))
else:
TEMP1 = TEMP[1].rstrip("\r\n".encode(errors='replace')).decode(errors='replace')
if len(TEMP1) < 22:
PRODUCT2 = TEMP1.ljust(22)
elif len(TEMP1) > 22:
PRODUCT2 = TEMP1[:20] + " "
else:
PRODUCT2 = TEMP1
log("S60202: "+ TEMP1 +" Command Attempt from: %s\n" % addr[0], log_destinations)
# Follows format for S60201 for comments
elif cmd.startswith("S60203"):
TEMP = response.split('S60203'.encode(errors='replace'))
if len(TEMP) < 2:
conn.send("9999FF1B\n".encode(errors='replace'))
else:
TEMP1 = TEMP[1].rstrip("\r\n".encode(errors='replace')).decode(errors='replace')
if len(TEMP1) < 22:
PRODUCT3 = TEMP1.ljust(22)
elif len(TEMP1) > 22:
PRODUCT3 = TEMP1[:20] + " "
else:
PRODUCT3 = TEMP1
log("S60203: "+ TEMP1 +" Command Attempt from: %s\n" % addr[0], log_destinations)
# Follows format for S60201 for comments
elif cmd.startswith("S60204"):
TEMP = response.split('S60204'.encode(errors='replace'))
if len(TEMP) < 2:
conn.send("9999FF1B\n".encode(errors='replace'))
else:
TEMP1 = TEMP[1].rstrip("\r\n".encode(errors='replace')).decode(errors='replace')
if len(TEMP1) < 22:
PRODUCT4 = TEMP1.ljust(22)
elif len(TEMP1) > 22:
PRODUCT4 = TEMP1[:20] + " "
else:
PRODUCT4 = TEMP1
log("S60204: "+ TEMP1 +" Command Attempt from: %s\n" % addr[0], log_destinations)
# Follows format for S60201 for comments
elif cmd.startswith("S60200"):
TEMP = response.split('S60200'.encode(errors='replace'))
if len(TEMP) < 2:
# 9999 indicates that the command was not understood and
# FF1B is the checksum for the 9999
conn.send("9999FF1B\n".encode(errors='replace'))
else:
TEMP1 = TEMP[1].rstrip("\r\n".encode(errors='replace')).decode(errors='replace')
if len(TEMP1) < 22:
PRODUCT1 = TEMP1.ljust(22)
PRODUCT2 = TEMP1.ljust(22)
PRODUCT3 = TEMP1.ljust(22)
PRODUCT4 = TEMP1.ljust(22)
elif len(TEMP1) > 22:
PRODUCT1 = TEMP1[:20] + " "
PRODUCT2 = TEMP1[:20] + " "
PRODUCT3 = TEMP1[:20] + " "
PRODUCT4 = TEMP1[:20] + " "
else:
PRODUCT1 = TEMP1
PRODUCT2 = TEMP1
PRODUCT3 = TEMP1
PRODUCT4 = TEMP1
log("S60200: "+ TEMP1 +" Command Attempt from: %s\n" % addr[0], log_destinations)
else:
conn.send("9999FF1B\n".encode(errors='replace'))
# Else it is a currently unsupported command so print the error message found in the manual
# 9999 indicates that the command was not understood and FF1B is the checksum for the 9999
else:
conn.send("9999FF1B\n".encode(errors='replace'))
# log what was entered
log("Attempt from: %s\n" % addr[0], log_destinations)
log("Command Entered %s\n" % response, log_destinations)
except Exception as e:
print('Unknown Error: {}'.format(str(e)))
raise
except KeyboardInterrupt:
conn.close()
except select.error:
conn.close()
# close log files
for log in log_destinations:
log.close()
| {
"repo_name": "sjhilt/GasPot",
"stars": "116",
"repo_language": "Python",
"file_name": "README.md",
"mime_type": "text/plain"
} |
# GasPot
<p align="center">
<img src="https://github.com/RoseSecurity/GasPot/assets/72598486/bcecc38d-1258-4681-a94c-810e9715c328" width=50% height=50%>
</p>
GasPot is a honeypot that has been designed to simulate a Veeder Root Gaurdian AST. These Tank Gauges are common in the oil and gas industry for Gas Station tanks to help with Inventory of fuels. GasPot was designed to randomize as much as possible so no two instances look identical.
## Install
git clone https://github.com/sjhilt/GasPot.git
## Configure
GasPot will run as downloaded above with no modifications. Configuration is based on a config.ini file. To make sure that GasPot looks like no other GasPot system on the internet and to collect the best information you can change the products and stations in the configuration file.
1) Change the station names to match gas stations in the region of deployment of GasPot.
2) Change the product names to match the type of product that would be utlized in the region of deployment.
## Run GasPot
python3 GasPot.py
## Review Logs
All connections will be logged locally to the all_attempts.log file created in the directory that GasPot is ran from.
## Write up
http://www.trendmicro.com/vinfo/us/security/news/cybercrime-and-digital-threats/the-gaspot-experiment
| {
"repo_name": "sjhilt/GasPot",
"stars": "116",
"repo_language": "Python",
"file_name": "README.md",
"mime_type": "text/plain"
} |
# Courses
* [Cryptography](#cryptography)
* [CUDA](#cuda)
* [Python](#python)
## Cryptography
* [CS387 - Applied Cryptography](http://www.udacity.com/overview/Course/cs387)
## CUDA
* [CS344 - Introduction to Parallel Programming - Using CUDA to Harness the Power of GPUs](http://www.udacity.com/overview/Course/cs344/CourseRev/1)
## Python
* [An Introduction to Interactive Programming in Python](https://www.coursera.org/course/interactivepython)
| {
"repo_name": "fffaraz/awesome-courses",
"stars": "358",
"repo_language": "None",
"file_name": "temp2.txt",
"mime_type": "text/plain"
} |
- Codecademy: Here you can learn to code in languages like HTML, Javascript, CSS, Ruby on Rails and Python.
- Girl Develop: While female coders do exist, programming is still largely a male dominated field. Girl Develop is one of the many programs that aims to motivate women to enter this arena. It is a non profit organisation and gives instruction to women willing to learn.
- Stanford University’s Udacity: The Introduction to Computer Science course in this one is available online for free. See if it suits you.
- Code Racer: This is a multiplayer live coding game where one can learn to build websites in CSS and HTML. The more experienced ones can test how adept they are at coding.
- The Computer Clubhouse: This helps youngsters from low-income communities to learn how to express themselves creatively through new technologies. The program reportedly has more than 25,000 students working with their mentors every year.
- CoderDojo’s: This is a volunteer-driven program, where youngsters learn how to code and are taken on tours at tech firms along with talks by guest speakers.
- Code School: A wide range of programming languages, web tools and design software are offered in this online program.
- Treehouse: This is the parent website to Code Racer and has online video courses and exercises.
- Girls Who Code: This is a program providing instruction and mentoring in coding specifically to 13 to 17 year old girls.
- Black Girls Code: This is aimed at girls in the African American community who want to learn how to code.
| {
"repo_name": "fffaraz/awesome-courses",
"stars": "358",
"repo_language": "None",
"file_name": "temp2.txt",
"mime_type": "text/plain"
} |
Free Programming Courses
========================
List of free online programming/CS courses
# Sources
## Websites
* [Education Portal](http://education-portal.com/) - education-portal.com
* [MIT OpenCourseWare](http://ocw.mit.edu/) - ocw.mit.edu
* [Microsoft Virtual Academy](http://www.microsoftvirtualacademy.com/) - microsoftvirtualacademy.com
* [Online College Courses](http://www.onlinecourses.com/) - onlinecourses.com
* [Open Yale Courses](http://oyc.yale.edu/) - oyc.yale.edu
* [alison](http://alison.com/) - alison.com
* [codecademy](http://www.codecademy.com/) - codecademy.com
* [computerscienceforeveryone](http://www.computerscienceforeveryone.com/) computerscienceforeveryone.com
* [coursera](https://www.coursera.org/) - coursera.org
* [edx](https://www.edx.org/) - edx.org
* [iversity](https://iversity.org/) - iversity.org
* [khanacademy](https://www.khanacademy.org/) - khanacademy.org
* [openculture](http://www.openculture.com/computer_science_free_courses) - openculture.com/computer_science_free_courses
* [openhpi](https://openhpi.de/) - openhpi.de
* [openuniversity](http://www.openuniversity.edu/courses/global) - openuniversity.edu/courses/global
* [stanford online courses](http://online.stanford.edu/courses) - online.stanford.edu/courses
* [udacity](https://www.udacity.com/) - udacity.com
* [udemy](https://www.udemy.com/courses/) - udemy.com/courses
* [mongodb](https://university.mongodb.com/) - Free Online MongoDB Training
* [tutorialspoint](http://www.tutorialspoint.com/index.htm)
* [alison](http://alison.com/learn/Programming)
* [open source society university](https://ossu.firebaseapp.com/) - ossu.firebaseapp.com
* [reddit - learnprogramming](http://www.reddit.com/r/learnprogramming/)
* [reddit - /u/dhawal](http://www.reddit.com/user/dhawal)
* [class-central Computer Science](https://www.class-central.com/subject/cs)
## Etc.
* [The 25 Best Places To Take Free Online Computer Science Classes](http://www.edudemic.com/the-25-best-places-to-take-free-online-computer-science-classes/)
* [100 Free Online Courses On Computer Science](http://www.efytimes.com/e1/creativenews.asp?edid=140050)
* [Microsoft Research](http://research.microsoft.com/en-us/)
* [Microsoft Research Academic](http://academic.research.microsoft.com/)
* [Google Scholar](http://scholar.google.com/)
* [Research at Google](http://research.google.com/)
* [Research at Google - Publications](http://research.google.com/pubs/papers.html)
* [Research Publications at Facebook](https://www.facebook.com/publications)
* [arxiv](http://arxiv.org/list/cs/recent)
* [ieeexplore](http://ieeexplore.ieee.org/)
* [springer](http://link.springer.com/)
## Lists
* [prakhar1989/awesome-courses](https://github.com/prakhar1989/awesome-courses)
* [romulomourao/awesome-courses](https://github.com/romulomourao/awesome-courses)
* [open-source-society/computer-science](https://github.com/open-source-society/computer-science)
* [Developer-Y/cs-video-courses](https://github.com/Developer-Y/cs-video-courses)
* [chhantyal/influential-cs-books](https://github.com/chhantyal/influential-cs-books)
* [hackerkid/Mind-Expanding-Books](https://github.com/hackerkid/Mind-Expanding-Books)
## Persian / Farsi websites
* [daneshabad](http://daneshabad.com/) - daneshabad.com
* [darsnameh](http://www.darsnameh.com/) - darsnameh.com
* [faradars](http://faradars.org/)
* [farsi khanacademy](https://fa.khanacademy.org/) - fa.khanacademy.org
* [kelasedars](http://kelasedars.org/) - kelasedars.org
* [maktabkhooneh](http://maktabkhooneh.org/) - maktabkhooneh.org
* [mit-ocw.sbu.ac.ir](http://mit-ocw.sbu.ac.ir/) - mit-ocw.sbu.ac.ir
* [takhtesefid](http://takhtesefid.org/) - takhtesefid.org
* [webyad](http://www.webyad.com/) - webyad.com
* [ocw.sharif.edu](http://ocw.sharif.edu/) - ocw.sharif.edu
| {
"repo_name": "fffaraz/awesome-courses",
"stars": "358",
"repo_language": "None",
"file_name": "temp2.txt",
"mime_type": "text/plain"
} |
10 Websites To Learn Coding Interactively
1. Codecademy
Thanks to its helpful interface and well-structured courses, Codecademy is indisputably the most famous website to teach you to code interactively. You can make your pick amongst Web Fundamentals, PHP, JavaScript, jQuery, Python, Ruby and APIs.
Every lesson carries a panel which can explain the necessary code and instruction. Another panel lets you to try your hands on coding by writing acceptable code, then checking if you are doing the right thing. Don’t worry if you are making errors, as both instruction and code panels will warn you of errors, and provide hints.
2. Code Avengers
Take our words, Code Avengers is designed to make you fall in love with programming. Although, as of now it only offers HTML5, CSS3 and JavaScript courses, but every single course here is carefully designed to truly entertain you and level up your programming skills. It's almost like playing a game and the end of each lesson you literally get to play a mini game to release the stress that you have cumulated during the lesson.
You can also play with the code and immediately see how the changes impact. It carefully takes care of a beginner’s comfort.
3. Code School
After you finished courses in Codecademy or Code Avengers, and you are ready to step further, Code School is the right place to be at. Unlike other interactive learning sites, Code School provides you with more in-depth courses to help you expertise.
Overall, the courses are categorized into 4 main streams i.e. Ruby, JavaScript, HTML/CSS and iOS.
The courses are streamlined with excellent design and informative screencasts. And with the challenges provided after screencast, they provide hints and answers to help you try and learn.
Most of the offered courses are free, some of them will require you to spend $25/month to access the entire course including all screencasts and challenges, and also all other courses in Code School.
4. Treehouse
The courses at Treehouse are more project-oriented than language-oriented. So if you are a novice programmer who have a planned purpose like creating a website, or an application. This is the way to go.
For example, the Websites course is all about building a responsive website, interactive website or even WordPress theme – a very practical and efficient way to master related languages.
The courses at Treehouse are divided into different stages or modules, and after every first stage the learner will be invited to pay a monthly subscription fee of $25 to access all courses with 650+ videos, and an exclusive Treehouse Members Forum as a bonus.
Also if you are serious about your programming future, you could subscribe the $49 monthly plan to obtain in-depth interviews with leading industry pros and cutting-edge workshops.
5. LearnStreet
If you are someone who would rather go for cold hard codes instead of fancy playful designs, LearnStreet is your thing.
Currently the website offers JavaScript, Python and Ruby courses at beginner level. All you need to do is to click on the ‘Start Course’ button and you will start the lesson with an exercise, a code interpreter and a glossary panel of new programming terms.
LearnStreet adopts command prompt-styled code interpreters with human language to explain function and encourage you whenever possible, the kind of command prompt you want for your own local machine.
It's indeed a friendly, enjoyable and free website.
6. Udacity
Udacity is the combination of insightful video lectures and improved quizzes to achieve the interactive feel for students. So if you are someone who don’t like to read and who would like to listen from industry professionals like Google employees, this website is for you!
The website provides screencast from pros discussing the topics and instructions, then you will take either logic or programming quizzes to strengthen your understanding on a particular skill.
The website is known for providing more videos than any other site, and the instructors are either real-life professors or industry veterans.
Although one drawback here is that most of the courses offered are not much related to each other. So we will not recommend Udacity as a starting point, but it is indeed a virtual university to further up your study.
7. CodeHS
Most of the websites above were majorly dedicated to web development and computer science, but here at CodeHS your will get simple and fun game programming lessons, which will involve lessons on problem solving, JavaScript, animation, data structures, game design and puzzle challenges.
CodeHS helps you to think and solve a problem like a programmer right from its first course. The lessons are fun as you will learn how to use the code to move the dog and puzzles like picking up ball and building a towel.
Although other than its first course mentioned above, one will be required to sign up first with $25 per month to continue your learning journey, but trust us the amount is worth it if you are willing to learn basic game programming effectively.
8. Khan Academy
The courses at Khan Academy might not be as structured as CodeHS, but it definitely serves as an open playground for both novice and amateurs who are interested in learning drawing, animation and user interaction with code. It does not take you forward on any programming language in particular, but the code pattern it adopts can be applied anywhere, as a majority of languages share the similar programming pattern.
You can join the first Programming Basics course to watch and learn basic concepts, then explore the given code after the video tutorial to validate your doubts. In Khan Academy, you can also save your modification as a Spin-Off for everyone to enjoy and customize. You can imagine the community size and the lesson’s effectiveness as there have been hundreds of spin-offs just from one lesson in one course.
9. Scratch 2.0
Your think CodeHS and Khan Academy were too hardcore? Nothing to worry, we have something easier for the aspiring programmer in you and it’s called Scratch. Previously an offline software that allowed kids to create, upload and share their projects proudly, Scratch is now fully online with its 2.0 successor.
Although it’s not all about programming but it is a good combination of visual blocks of commands that tell assigned objects how to behave, such as telling the cat to move 10 steps, or yell ‘meow’ when it touches the owner’s leg.
By using this visual programming method, a programmers will form a habit of breaking a problem into smaller blocks, and solve them one by one logically.
10. SQLZOO
Structured Query Language (SQL) is a language which was designed with the pure intention of storing and retrieve data from a database. So you think the experience of learning the language can be full of boredom? We bring SQLZOO, which will let you to learn SQL happily with its interactive interface and smileys.
Since nothing too deep is there to explain for a straightforward language like SQL, the site simply ask you to replace the variables like city names or population number, and raise the difficulty from that level.
Although one drawback that we could think here is the lack of hints, answers and forum which can leave someone probably doomed if they fail to solve any one of the quizzes.
| {
"repo_name": "fffaraz/awesome-courses",
"stars": "358",
"repo_language": "None",
"file_name": "temp2.txt",
"mime_type": "text/plain"
} |
<!DOCTYPE html>
<html>
<head>
</head>
<body>
<h1>Yjs Demos</h1>
<ul>
<li><a href="./prosemirror/prosemirror.html">ProseMirror Binding</a></li>
<li><a href="./prosemirror-versions/prosemirror-versions.html">
ProseMirror Binding with Version History
</a></li>
<li><a href="./prosemirror-dat/prosemirror-dat.html">
Yjs + Dat Protocol Demo (with offline support and p2p sync using Dat)
</a></li>
<li><a href="./atlaskit/atlaskit.html">ProseMirror-Atlaskit Binding</a></li>
<li><a href="./quill/quill.html">Quill Binding</a></li>
<li><a href="./monaco/monaco.html">Monaco Binding</a></li>
<li><a href="./codemirror/codemirror.html">CodeMirror Binding</a></li>
<li><a href="./tiptap/dist/index.html">TipTap Binding</a></li>
</ul>
</body>
</html>
| {
"repo_name": "yjs/yjs-demos",
"stars": "521",
"repo_language": "JavaScript",
"file_name": "README.md",
"mime_type": "text/plain"
} |
web: npm start
| {
"repo_name": "yjs/yjs-demos",
"stars": "521",
"repo_language": "JavaScript",
"file_name": "README.md",
"mime_type": "text/plain"
} |
# Yjs Demos [](https://gitpod.io/#https://github.com/yjs/yjs-demos)
> A starting point for your own ideas - PRs welcome
We have a more complete [Getting Started Guide](https://docs.yjs.dev/getting-started/a-collaborative-editor) in our official documentation website.
* 3D model collaboration using the [Vertex Viewer](https://developer.vertexvis.com/). [Open Demo Site](https://collaboration.vertexvis.io/).
* Shared Editing using the [ProseMirror](http://prosemirror.net/) editor - [Open Directory](./prosemirror/)
* Shared Editing using the [ProseMirror](http://prosemirror.net/) editor with
versioning support - [Open Directory](./prosemirror-versions/)
* Shared Editing using the [Dat Protocol](https://dat.foundation/) - [Open Directory](./prosemirror-dat/)
* Shared Editing using the [Quill](https://quilljs.com/) editor - [Open Directory](./quill/)
* Shared Editing using the
[Atlassian Atlaskit](https://bitbucket.org/atlassian/atlaskit-mk-2/src/master/) editor - [Open Directory](./atlaskit/)
* Shared Editing using the [Monaco](https://microsoft.github.io/monaco-editor/)
editor - [Open Directory](./monaco/)
* Shared Editing using the [CodeMirror](https://codemirror.net/)
editor - [Open Directory](./codemirror/)
* Shared Editing using the [CodeMirror.next](https://codemirror.net/6/)
editor - [Open Directory](./codemirror.next/)
* Shared Editing using the [TipTap](https://tiptap.dev/)
editor - [Open Directory](./tiptap/)
## Getting Started
If you are new to Yjs and you just want to play around clone this repository and
use one of the demo directories that interests you the most.
```sh
git clone https://github.com/yjs/yjs-demos.git
cd yjs-demos/${demo-directory}
npm install
npm start
```
The demos use a public [`y-websocket`](https://github.com/yjs/y-websocket)
instance for communication. Try using one of the [other connection providers](https://docs.yjs.dev/ecosystem/connection-provider) or setting up
your own endpoint.
### (Un)License
The demos are released to the public domain - [Unlicense](./LICENSE).
| {
"repo_name": "yjs/yjs-demos",
"stars": "521",
"repo_language": "JavaScript",
"file_name": "README.md",
"mime_type": "text/plain"
} |
# This workflow will do a clean install of node dependencies, build the source code and run tests across different versions of node
# For more information see: https://help.github.com/actions/language-and-framework-guides/using-nodejs-with-github-actions
name: Node.js CI
on:
push:
branches: [ main ]
pull_request:
branches: [ main ]
jobs:
build:
runs-on: ubuntu-latest
strategy:
matrix:
node-version: [10.x, 12.x, 14.x, 15.x]
# See supported Node.js release schedule at https://nodejs.org/en/about/releases/
steps:
- uses: actions/checkout@v2
- name: Use Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v1
with:
node-version: ${{ matrix.node-version }}
- run: npm ci
- run: npm run build --if-present
- run: npm test
| {
"repo_name": "yjs/yjs-demos",
"stars": "521",
"repo_language": "JavaScript",
"file_name": "README.md",
"mime_type": "text/plain"
} |
/**
* @type {any}
*/
const WebSocket = require('ws')
const http = require('http')
const StaticServer = require('node-static').Server
const setupWSConnection = require('y-websocket/bin/utils.js').setupWSConnection
const production = process.env.PRODUCTION != null
const port = process.env.PORT || 8080
const staticServer = new StaticServer('../', { cache: production ? 3600 : false, gzip: production })
const server = http.createServer((request, response) => {
request.addListener('end', () => {
staticServer.serve(request, response)
}).resume()
})
const wss = new WebSocket.Server({ server })
wss.on('connection', (conn, req) => setupWSConnection(conn, req, { gc: req.url.slice(1) !== 'prosemirror-versions' }))
server.listen(port)
console.log(`Listening to http://localhost:${port} ${production ? '(production)' : ''}`)
| {
"repo_name": "yjs/yjs-demos",
"stars": "521",
"repo_language": "JavaScript",
"file_name": "README.md",
"mime_type": "text/plain"
} |
# demo-server
All yjs-demos connect to this server to exchange document updates. It combines the y-websocket server with an http server for the files in the root directory. Of course, you can choose any of the Yjs providers instead. This is just a demo server.
```sh
npm install
npm run build-all # Iterates through all demos and builds them.
npm start
```
| {
"repo_name": "yjs/yjs-demos",
"stars": "521",
"repo_language": "JavaScript",
"file_name": "README.md",
"mime_type": "text/plain"
} |
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8" />
<title>Yjs CodeMirror Example</title>
<script type="text/javascript" src="./dist/codemirror.bundle.js" async></script>
<link rel=stylesheet href="./codemirror.css" async defer>
<style>
.remote-caret {
position: relative;
border-left: 2px solid black;
margin-left: -1px;
margin-right: -1px;
box-sizing: border-box;
}
.remote-caret > div {
position: absolute;
top: -1.05em;
left: -2px;
font-size: .6em;
background-color: rgb(250, 129, 0);
font-family: serif;
font-style: normal;
font-weight: normal;
line-height: normal;
user-select: none;
color: white;
padding-left: 2px;
padding-right: 2px;
z-index: 3;
transition: opacity .3s ease-in-out;
}
.remote-caret.hide-name > div {
transition-delay: .7s;
opacity: 0;
}
.remote-caret:hover > div {
opacity: 1;
transition-delay: 0s;
}
</style>
</head>
<body>
<button type="button" id="y-connect-btn">Disconnect</button>
<p></p>
<p>
This is a demo of the <a href="https://github.com/yjs/yjs">Yjs</a> ⇔
<a href="https://codemirror.net">CodeMirror</a> binding:
<a href="https://github.com/yjs/y-codemirror">y-codemirror</a>.
</p>
<p>
The content of this editor is shared with every client that visits this
domain.
</p>
</body>
</html>
| {
"repo_name": "yjs/yjs-demos",
"stars": "521",
"repo_language": "JavaScript",
"file_name": "README.md",
"mime_type": "text/plain"
} |
/* BASICS */
.CodeMirror {
/* Set height, width, borders, and global font properties here */
font-family: monospace;
height: 300px;
color: black;
direction: ltr;
}
/* PADDING */
.CodeMirror-lines {
padding: 4px 0; /* Vertical padding around content */
}
.CodeMirror pre.CodeMirror-line,
.CodeMirror pre.CodeMirror-line-like {
padding: 0 4px; /* Horizontal padding of content */
}
.CodeMirror-scrollbar-filler, .CodeMirror-gutter-filler {
background-color: white; /* The little square between H and V scrollbars */
}
/* GUTTER */
.CodeMirror-gutters {
border-right: 1px solid #ddd;
background-color: #f7f7f7;
white-space: nowrap;
}
.CodeMirror-linenumbers {}
.CodeMirror-linenumber {
padding: 0 3px 0 5px;
min-width: 20px;
text-align: right;
color: #999;
white-space: nowrap;
}
.CodeMirror-guttermarker { color: black; }
.CodeMirror-guttermarker-subtle { color: #999; }
/* CURSOR */
.CodeMirror-cursor {
border-left: 1px solid black;
border-right: none;
width: 0;
}
/* Shown when moving in bi-directional text */
.CodeMirror div.CodeMirror-secondarycursor {
border-left: 1px solid silver;
}
.cm-fat-cursor .CodeMirror-cursor {
width: auto;
border: 0 !important;
background: #7e7;
}
.cm-fat-cursor div.CodeMirror-cursors {
z-index: 1;
}
.cm-fat-cursor .CodeMirror-line::selection,
.cm-fat-cursor .CodeMirror-line > span::selection,
.cm-fat-cursor .CodeMirror-line > span > span::selection { background: transparent; }
.cm-fat-cursor .CodeMirror-line::-moz-selection,
.cm-fat-cursor .CodeMirror-line > span::-moz-selection,
.cm-fat-cursor .CodeMirror-line > span > span::-moz-selection { background: transparent; }
.cm-fat-cursor { caret-color: transparent; }
@-moz-keyframes blink {
0% {}
50% { background-color: transparent; }
100% {}
}
@-webkit-keyframes blink {
0% {}
50% { background-color: transparent; }
100% {}
}
@keyframes blink {
0% {}
50% { background-color: transparent; }
100% {}
}
/* Can style cursor different in overwrite (non-insert) mode */
.CodeMirror-overwrite .CodeMirror-cursor {}
.cm-tab { display: inline-block; text-decoration: inherit; }
.CodeMirror-rulers {
position: absolute;
left: 0; right: 0; top: -50px; bottom: 0;
overflow: hidden;
}
.CodeMirror-ruler {
border-left: 1px solid #ccc;
top: 0; bottom: 0;
position: absolute;
}
/* DEFAULT THEME */
.cm-s-default .cm-header {color: blue;}
.cm-s-default .cm-quote {color: #090;}
.cm-negative {color: #d44;}
.cm-positive {color: #292;}
.cm-header, .cm-strong {font-weight: bold;}
.cm-em {font-style: italic;}
.cm-link {text-decoration: underline;}
.cm-strikethrough {text-decoration: line-through;}
.cm-s-default .cm-keyword {color: #708;}
.cm-s-default .cm-atom {color: #219;}
.cm-s-default .cm-number {color: #164;}
.cm-s-default .cm-def {color: #00f;}
.cm-s-default .cm-variable,
.cm-s-default .cm-punctuation,
.cm-s-default .cm-property,
.cm-s-default .cm-operator {}
.cm-s-default .cm-variable-2 {color: #05a;}
.cm-s-default .cm-variable-3, .cm-s-default .cm-type {color: #085;}
.cm-s-default .cm-comment {color: #a50;}
.cm-s-default .cm-string {color: #a11;}
.cm-s-default .cm-string-2 {color: #f50;}
.cm-s-default .cm-meta {color: #555;}
.cm-s-default .cm-qualifier {color: #555;}
.cm-s-default .cm-builtin {color: #30a;}
.cm-s-default .cm-bracket {color: #997;}
.cm-s-default .cm-tag {color: #170;}
.cm-s-default .cm-attribute {color: #00c;}
.cm-s-default .cm-hr {color: #999;}
.cm-s-default .cm-link {color: #00c;}
.cm-s-default .cm-error {color: #f00;}
.cm-invalidchar {color: #f00;}
.CodeMirror-composing { border-bottom: 2px solid; }
/* Default styles for common addons */
div.CodeMirror span.CodeMirror-matchingbracket {color: #0b0;}
div.CodeMirror span.CodeMirror-nonmatchingbracket {color: #a22;}
.CodeMirror-matchingtag { background: rgba(255, 150, 0, .3); }
.CodeMirror-activeline-background {background: #e8f2ff;}
/* STOP */
/* The rest of this file contains styles related to the mechanics of
the editor. You probably shouldn't touch them. */
.CodeMirror {
position: relative;
overflow: hidden;
background: white;
}
.CodeMirror-scroll {
overflow: scroll !important; /* Things will break if this is overridden */
/* 50px is the magic margin used to hide the element's real scrollbars */
/* See overflow: hidden in .CodeMirror */
margin-bottom: -50px; margin-right: -50px;
padding-bottom: 50px;
height: 100%;
outline: none; /* Prevent dragging from highlighting the element */
position: relative;
z-index: 0;
}
.CodeMirror-sizer {
position: relative;
border-right: 50px solid transparent;
}
/* The fake, visible scrollbars. Used to force redraw during scrolling
before actual scrolling happens, thus preventing shaking and
flickering artifacts. */
.CodeMirror-vscrollbar, .CodeMirror-hscrollbar, .CodeMirror-scrollbar-filler, .CodeMirror-gutter-filler {
position: absolute;
z-index: 6;
display: none;
outline: none;
}
.CodeMirror-vscrollbar {
right: 0; top: 0;
overflow-x: hidden;
overflow-y: scroll;
}
.CodeMirror-hscrollbar {
bottom: 0; left: 0;
overflow-y: hidden;
overflow-x: scroll;
}
.CodeMirror-scrollbar-filler {
right: 0; bottom: 0;
}
.CodeMirror-gutter-filler {
left: 0; bottom: 0;
}
.CodeMirror-gutters {
position: absolute; left: 0; top: 0;
min-height: 100%;
z-index: 3;
}
.CodeMirror-gutter {
white-space: normal;
height: 100%;
display: inline-block;
vertical-align: top;
margin-bottom: -50px;
}
.CodeMirror-gutter-wrapper {
position: absolute;
z-index: 4;
background: none !important;
border: none !important;
}
.CodeMirror-gutter-background {
position: absolute;
top: 0; bottom: 0;
z-index: 4;
}
.CodeMirror-gutter-elt {
position: absolute;
cursor: default;
z-index: 4;
}
.CodeMirror-gutter-wrapper ::selection { background-color: transparent }
.CodeMirror-gutter-wrapper ::-moz-selection { background-color: transparent }
.CodeMirror-lines {
cursor: text;
min-height: 1px; /* prevents collapsing before first draw */
}
.CodeMirror pre.CodeMirror-line,
.CodeMirror pre.CodeMirror-line-like {
/* Reset some styles that the rest of the page might have set */
-moz-border-radius: 0; -webkit-border-radius: 0; border-radius: 0;
border-width: 0;
background: transparent;
font-family: inherit;
font-size: inherit;
margin: 0;
white-space: pre;
word-wrap: normal;
line-height: inherit;
color: inherit;
z-index: 2;
position: relative;
overflow: visible;
-webkit-tap-highlight-color: transparent;
-webkit-font-variant-ligatures: contextual;
font-variant-ligatures: contextual;
}
.CodeMirror-wrap pre.CodeMirror-line,
.CodeMirror-wrap pre.CodeMirror-line-like {
word-wrap: break-word;
white-space: pre-wrap;
word-break: normal;
}
.CodeMirror-linebackground {
position: absolute;
left: 0; right: 0; top: 0; bottom: 0;
z-index: 0;
}
.CodeMirror-linewidget {
position: relative;
z-index: 2;
padding: 0.1px; /* Force widget margins to stay inside of the container */
}
.CodeMirror-widget {}
.CodeMirror-rtl pre { direction: rtl; }
.CodeMirror-code {
outline: none;
}
/* Force content-box sizing for the elements where we expect it */
.CodeMirror-scroll,
.CodeMirror-sizer,
.CodeMirror-gutter,
.CodeMirror-gutters,
.CodeMirror-linenumber {
-moz-box-sizing: content-box;
box-sizing: content-box;
}
.CodeMirror-measure {
position: absolute;
width: 100%;
height: 0;
overflow: hidden;
visibility: hidden;
}
.CodeMirror-cursor {
position: absolute;
pointer-events: none;
}
.CodeMirror-measure pre { position: static; }
div.CodeMirror-cursors {
visibility: hidden;
position: relative;
z-index: 3;
}
div.CodeMirror-dragcursors {
visibility: visible;
}
.CodeMirror-focused div.CodeMirror-cursors {
visibility: visible;
}
.CodeMirror-selected { background: #d9d9d9; }
.CodeMirror-focused .CodeMirror-selected { background: #d7d4f0; }
.CodeMirror-crosshair { cursor: crosshair; }
.CodeMirror-line::selection, .CodeMirror-line > span::selection, .CodeMirror-line > span > span::selection { background: #d7d4f0; }
.CodeMirror-line::-moz-selection, .CodeMirror-line > span::-moz-selection, .CodeMirror-line > span > span::-moz-selection { background: #d7d4f0; }
.cm-searching {
background-color: #ffa;
background-color: rgba(255, 255, 0, .4);
}
/* Used to force a border model for a node */
.cm-force-border { padding-right: .1px; }
@media print {
/* Hide the cursor when printing */
.CodeMirror div.CodeMirror-cursors {
visibility: hidden;
}
}
/* See issue #2901 */
.cm-tab-wrap-hack:after { content: ''; }
/* Help users use markselection to safely style text background */
span.CodeMirror-selectedtext { background: none; }
| {
"repo_name": "yjs/yjs-demos",
"stars": "521",
"repo_language": "JavaScript",
"file_name": "README.md",
"mime_type": "text/plain"
} |
/* eslint-env browser */
// @ts-ignore
import CodeMirror from 'codemirror'
import * as Y from 'yjs'
import { WebsocketProvider } from 'y-websocket'
import { CodemirrorBinding } from 'y-codemirror'
import 'codemirror/mode/javascript/javascript.js'
window.addEventListener('load', () => {
const ydoc = new Y.Doc()
const provider = new WebsocketProvider(
'wss://demos.yjs.dev',
'codemirror-demo-2',
ydoc
)
const ytext = ydoc.getText('codemirror')
const editorContainer = document.createElement('div')
editorContainer.setAttribute('id', 'editor')
document.body.insertBefore(editorContainer, null)
const editor = CodeMirror(editorContainer, {
mode: 'javascript',
lineNumbers: true
})
const binding = new CodemirrorBinding(ytext, editor, provider.awareness)
const connectBtn = /** @type {HTMLElement} */ (document.getElementById('y-connect-btn'))
connectBtn.addEventListener('click', () => {
if (provider.shouldConnect) {
provider.disconnect()
connectBtn.textContent = 'Connect'
} else {
provider.connect()
connectBtn.textContent = 'Disconnect'
}
})
// @ts-ignore
window.example = { provider, ydoc, ytext, binding, Y }
})
| {
"repo_name": "yjs/yjs-demos",
"stars": "521",
"repo_language": "JavaScript",
"file_name": "README.md",
"mime_type": "text/plain"
} |
const path = require('path')
module.exports = {
mode: 'development',
devtool: 'source-map',
entry: {
codemirror: './codemirror.js'
},
output: {
globalObject: 'self',
path: path.resolve(__dirname, './dist/'),
filename: '[name].bundle.js',
publicPath: '/codemirror/dist/'
},
devServer: {
contentBase: path.join(__dirname),
compress: true,
publicPath: '/dist/'
}
}
| {
"repo_name": "yjs/yjs-demos",
"stars": "521",
"repo_language": "JavaScript",
"file_name": "README.md",
"mime_type": "text/plain"
} |
# ProseMirror Demo
> [y-codemirror](https://docs.yjs.dev/ecosystem/editor-bindings/codemirror) / [y-websocket](https://docs.yjs.dev/ecosystem/connection-provider/y-websocket) / [Live Demo](https://demos.yjs.dev/codemirror/codemirror.html)
This is a demo of a [CodeMirror 5](https://codemirror.net/5) editor that was made collaborative with Yjs & y-codemirror. Note that CodeMirror 6 is now the latest release.
We use the [y-websocket](https://docs.yjs.dev/ecosystem/connection-provider) provider to share document updates through a server. There are many more providers available for Yjs - try switching to another provider. [See docs](https://docs.yjs.dev/ecosystem/connection-provider).
Also you could try addingh offline persistence to this demo. Wouldn't it be cool if document updates are persisted in the browser, so you can load your application load faster? Try it out: https://docs.yjs.dev/getting-started/allowing-offline-editing
## Quick Start
```sh
npm i
npm start
# Project is running at http://localhost:8080/
```
| {
"repo_name": "yjs/yjs-demos",
"stars": "521",
"repo_language": "JavaScript",
"file_name": "README.md",
"mime_type": "text/plain"
} |
module.exports = {
publicPath: process.env.NODE_ENV === 'production'
? '/tiptap/dist/'
: '/'
}
| {
"repo_name": "yjs/yjs-demos",
"stars": "521",
"repo_language": "JavaScript",
"file_name": "README.md",
"mime_type": "text/plain"
} |
# TipTap Demo
> [y-prosemirror](https://docs.yjs.dev/ecosystem/editor-bindings/prosemirror) / [y-websocket](https://docs.yjs.dev/ecosystem/connection-provider/y-websocket) / [Live Demo](https://demos.yjs.dev/tiptap/tiptap.html)
This is a demo of an [TipTap](https://tiptap.dev/) editor that was made collaborative with Yjs & y-prosemirror. Since TipTap is based on ProseMirror, we simply need to add y-prosemirror to the internal ProseMirror instance. Find out more about the prosemirror binding in our [Official Docs](https://docs.yjs.dev/ecosystem/editor-bindings/prosemirror).
We use the [y-websocket](https://docs.yjs.dev/ecosystem/connection-provider/y-websocket) provider to share document updates through a server. There are many more providers available for Yjs - try switching to another provider. [See docs](https://docs.yjs.dev/ecosystem/connection-provider).
Also you could try addingh offline persistence to this demo. Wouldn't it be cool if document updates are persisted in the browser, so you can load your application load faster? Try it out: https://docs.yjs.dev/getting-started/allowing-offline-editing
## Quick Start
```sh
npm i
npm start
# Project is running at http://localhost:8080/
```
| {
"repo_name": "yjs/yjs-demos",
"stars": "521",
"repo_language": "JavaScript",
"file_name": "README.md",
"mime_type": "text/plain"
} |
// @import "~variables";
$color-black: #000000;
$color-white: #ffffff;
$color-grey: #dddddd;
* {
margin: 0;
padding: 0;
box-sizing: border-box;
text-size-adjust: 100%;
-webkit-tap-highlight-color: rgba(0, 0, 0, 0);
-webkit-touch-callout: none;
-webkit-font-smoothing: antialiased;
-moz-osx-font-smoothing: grayscale;
text-rendering: optimizeLegibility;
&:focus {
outline: none;
}
}
*::before,
*::after {
box-sizing: border-box;
}
html {
font-family: 'Inter';
font-size: 18px;
color: $color-black;
line-height: 1.5;
}
body {
margin: 0;
}
a {
color: inherit;
}
h1,
h2,
h3,
p,
ul,
ol,
pre,
blockquote {
margin: 1rem 0;
&:first-child {
margin-top: 0;
}
&:last-child {
margin-bottom: 0;
}
}
h1,
h2,
h3 {
line-height: 1.3;
}
.button {
font-weight: bold;
display: inline-flex;
background: transparent;
border: 0;
color: $color-black;
padding: 0.2rem 0.5rem;
margin-right: 0.2rem;
border-radius: 3px;
cursor: pointer;
background-color: rgba($color-black, 0.1);
&:hover {
background-color: rgba($color-black, 0.15);
}
}
.message {
background-color: rgba($color-black, 0.05);
color: rgba($color-black, 0.7);
padding: 1rem;
border-radius: 6px;
margin-bottom: 1.5rem;
font-style: italic;
}
@import "./editor";
@import "./menubar";
@import "./yjs.scss"
| {
"repo_name": "yjs/yjs-demos",
"stars": "521",
"repo_language": "JavaScript",
"file_name": "README.md",
"mime_type": "text/plain"
} |
<template>
<div class="editor">
<editor-menu-bar :editor="editor" v-slot="{ commands, isActive }">
<div class="menubar">
<button
class="menubar__button"
:class="{ 'is-active': isActive.bold() }"
@click="commands.bold"
>
bold
</button>
<button
class="menubar__button"
:class="{ 'is-active': isActive.italic() }"
@click="commands.italic"
>
italic
</button>
<button
class="menubar__button"
:class="{ 'is-active': isActive.strike() }"
@click="commands.strike"
>
strike
</button>
<button
class="menubar__button"
:class="{ 'is-active': isActive.underline() }"
@click="commands.underline"
>
underline
</button>
<button
class="menubar__button"
:class="{ 'is-active': isActive.code() }"
@click="commands.code"
>
code
</button>
<button
class="menubar__button"
:class="{ 'is-active': isActive.paragraph() }"
@click="commands.paragraph"
>
paragraph
</button>
<button
class="menubar__button"
:class="{ 'is-active': isActive.heading({ level: 1 }) }"
@click="commands.heading({ level: 1 })"
>
H1
</button>
<button
class="menubar__button"
:class="{ 'is-active': isActive.heading({ level: 2 }) }"
@click="commands.heading({ level: 2 })"
>
H2
</button>
<button
class="menubar__button"
:class="{ 'is-active': isActive.heading({ level: 3 }) }"
@click="commands.heading({ level: 3 })"
>
H3
</button>
<button
class="menubar__button"
:class="{ 'is-active': isActive.bullet_list() }"
@click="commands.bullet_list"
>
ul
</button>
<button
class="menubar__button"
:class="{ 'is-active': isActive.ordered_list() }"
@click="commands.ordered_list"
>
ol
</button>
<button
class="menubar__button"
:class="{ 'is-active': isActive.blockquote() }"
@click="commands.blockquote"
>
quote
</button>
<button
class="menubar__button"
:class="{ 'is-active': isActive.code_block() }"
@click="commands.code_block"
>
code
</button>
<button
class="menubar__button"
@click="commands.horizontal_rule"
>
hr
</button>
<button
class="menubar__button"
@click="commands.undo"
>
undo
</button>
<button
class="menubar__button"
@click="commands.redo"
>
redo
</button>
</div>
</editor-menu-bar>
<editor-content class="editor__content" :editor="editor"/>
</div>
</template>
<style lang="scss">
@import './main.scss';
</style>
<script>
import { Editor, EditorContent, EditorMenuBar } from 'tiptap'
import { Blockquote, Bold, BulletList, Code, CodeBlock, HardBreak, Heading, History, HorizontalRule, Italic, Link, ListItem, OrderedList, Strike, TodoItem, TodoList, Underline } from 'tiptap-extensions'
import RealtimeExtension from './Realtime'
export default {
components: {
EditorContent,
EditorMenuBar,
},
data() {
return {
editor: new Editor({
extensions: [
new Blockquote(),
new BulletList(),
new CodeBlock(),
new HardBreak(),
new Heading({ levels: [1, 2, 3] }),
new HorizontalRule(),
new ListItem(),
new OrderedList(),
new TodoItem(),
new TodoList(),
new Link(),
new Bold(),
new Code(),
new Italic(),
new Strike(),
new Underline(),
new History(),
new RealtimeExtension(),
],
}),
}
},
beforeDestroy() {
this.editor.destroy()
},
}
</script>
| {
"repo_name": "yjs/yjs-demos",
"stars": "521",
"repo_language": "JavaScript",
"file_name": "README.md",
"mime_type": "text/plain"
} |
placeholder {
display: inline;
border: 1px solid #ccc;
color: #ccc;
}
placeholder:after {
content: "☁";
font-size: 200%;
line-height: 0.1;
font-weight: bold;
}
.ProseMirror img { max-width: 100px }
/* this is a rough fix for the first cursor position when the first paragraph is empty */
.ProseMirror > .ProseMirror-yjs-cursor:first-child {
margin-top: 16px;
}
.ProseMirror p:first-child, .ProseMirror h1:first-child, .ProseMirror h2:first-child, .ProseMirror h3:first-child, .ProseMirror h4:first-child, .ProseMirror h5:first-child, .ProseMirror h6:first-child {
margin-top: 16px
}
.ProseMirror-yjs-cursor {
position: absolute;
border-left: black;
border-left-style: solid;
border-left-width: 2px;
border-color: orange;
height: 1em;
word-break: normal;
pointer-events: none;
}
.ProseMirror-yjs-cursor > div {
position: relative;
top: -1.05em;
font-size: 13px;
background-color: rgb(250, 129, 0);
font-family: serif;
font-style: normal;
font-weight: normal;
line-height: normal;
user-select: none;
color: white;
padding-left: 2px;
padding-right: 2px;
}
#y-functions {
position: absolute;
top: 20px;
right: 20px;
}
#y-functions > * {
display: inline-block;
} | {
"repo_name": "yjs/yjs-demos",
"stars": "521",
"repo_language": "JavaScript",
"file_name": "README.md",
"mime_type": "text/plain"
} |
import { keymap } from 'prosemirror-keymap'
import { Extension } from 'tiptap'
import { redo, undo, yCursorPlugin, ySyncPlugin, yUndoPlugin } from 'y-prosemirror'
import { WebsocketProvider } from 'y-websocket'
import * as Y from 'yjs'
const ydoc = new Y.Doc()
const provider = new WebsocketProvider('wss://demos.yjs.dev', 'tiptap-demo', ydoc)
const type = ydoc.getXmlFragment('prosemirror')
export default class RealtimeExtension extends Extension {
get name () {
return 'realtime'
}
get plugins () {
return [
ySyncPlugin(type),
yCursorPlugin(provider.awareness),
yUndoPlugin(),
keymap({
'Mod-z': undo,
'Mod-y': redo,
'Mod-Shift-z': redo
})
]
}
}
| {
"repo_name": "yjs/yjs-demos",
"stars": "521",
"repo_language": "JavaScript",
"file_name": "README.md",
"mime_type": "text/plain"
} |
import Vue from 'vue'
import App from './App.vue'
Vue.config.productionTip = false
new Vue({
render: h => h(App)
}).$mount('#app')
| {
"repo_name": "yjs/yjs-demos",
"stars": "521",
"repo_language": "JavaScript",
"file_name": "README.md",
"mime_type": "text/plain"
} |
.editor {
position: relative;
max-width: 30rem;
margin: 0 auto 5rem auto;
&__content {
overflow-wrap: break-word;
word-wrap: break-word;
word-break: break-word;
* {
caret-color: currentColor;
}
pre {
padding: 0.7rem 1rem;
border-radius: 5px;
background: $color-black;
color: $color-white;
font-size: 0.8rem;
overflow-x: auto;
code {
display: block;
}
}
p code {
display: inline-block;
padding: 0 0.4rem;
border-radius: 5px;
font-size: 0.8rem;
font-weight: bold;
background: rgba($color-black, 0.1);
color: rgba($color-black, 0.8);
}
ul,
ol {
padding-left: 1rem;
}
li > p,
li > ol,
li > ul {
margin: 0;
}
a {
color: inherit;
}
blockquote {
border-left: 3px solid rgba($color-black, 0.1);
color: rgba($color-black, 0.8);
padding-left: 0.8rem;
font-style: italic;
p {
margin: 0;
}
}
img {
max-width: 100%;
border-radius: 3px;
}
table {
border-collapse: collapse;
table-layout: fixed;
width: 100%;
margin: 0;
overflow: hidden;
td, th {
min-width: 1em;
border: 2px solid $color-grey;
padding: 3px 5px;
vertical-align: top;
box-sizing: border-box;
position: relative;
> * {
margin-bottom: 0;
}
}
th {
font-weight: bold;
text-align: left;
}
.selectedCell:after {
z-index: 2;
position: absolute;
content: "";
left: 0; right: 0; top: 0; bottom: 0;
background: rgba(200, 200, 255, 0.4);
pointer-events: none;
}
.column-resize-handle {
position: absolute;
right: -2px; top: 0; bottom: 0;
width: 4px;
z-index: 20;
background-color: #adf;
pointer-events: none;
}
}
.tableWrapper {
margin: 1em 0;
overflow-x: auto;
}
.resize-cursor {
cursor: ew-resize;
cursor: col-resize;
}
}
}
| {
"repo_name": "yjs/yjs-demos",
"stars": "521",
"repo_language": "JavaScript",
"file_name": "README.md",
"mime_type": "text/plain"
} |
.menubar {
margin-bottom: 1rem;
transition: visibility 0.2s 0.4s, opacity 0.2s 0.4s;
&.is-hidden {
visibility: hidden;
opacity: 0;
}
&.is-focused {
visibility: visible;
opacity: 1;
transition: visibility 0.2s, opacity 0.2s;
}
&__button {
font-weight: bold;
display: inline-flex;
background: transparent;
border: 0;
color: $color-black;
padding: 0.2rem 0.5rem;
margin-right: 0.2rem;
border-radius: 3px;
cursor: pointer;
&:hover {
background-color: rgba($color-black, 0.05);
}
&.is-active {
background-color: rgba($color-black, 0.1);
}
}
span#{&}__button {
font-size: 13.3333px;
}
}
| {
"repo_name": "yjs/yjs-demos",
"stars": "521",
"repo_language": "JavaScript",
"file_name": "README.md",
"mime_type": "text/plain"
} |
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8"/>
<title>Yjs Atlaskit Example</title>
<script type="text/javascript" src="./dist/atlaskit.bundle.js" async></script>
<style>
placeholder {
display: inline;
border: 1px solid #ccc;
color: #ccc;
}
placeholder:after {
content: "☁";
font-size: 200%;
line-height: 0.1;
font-weight: bold;
}
.ProseMirror img { max-width: 100px }
/* this is a rough fix for the first cursor position when the first paragraph is empty */
.ProseMirror > .ProseMirror-yjs-cursor:first-child {
margin-top: 16px;
}
.ProseMirror p:first-child, .ProseMirror h1:first-child, .ProseMirror h2:first-child, .ProseMirror h3:first-child, .ProseMirror h4:first-child, .ProseMirror h5:first-child, .ProseMirror h6:first-child {
margin-top: 16px
}
.ProseMirror-yjs-cursor {
position: absolute;
border-left: black;
border-left-style: solid;
border-left-width: 2px;
border-color: orange;
height: 1em;
word-break: normal;
pointer-events: none;
}
.ProseMirror-yjs-cursor > div {
position: relative;
top: -1.05em;
font-size: 13px;
background-color: rgb(250, 129, 0);
font-family: serif;
font-style: normal;
font-weight: normal;
line-height: normal;
user-select: none;
color: white;
padding-left: 2px;
padding-right: 2px;
}
[ychange_state] {
position: relative;
}
[ychange_state]:hover::before {
content: attr(ychange_user);
background-color: #fa8100;
position: absolute;
top: -14px;
right: 0;
font-size: 12px;
padding: 0 2px;
border-radius: 3px 3px 0 0;
color: #fdfdfe;
user-select: none;
word-break: normal;
}
*[ychange_state='added'] {
background-color: #fa810069;
}
ychange[ychange_state='removed'] {
color: rgb(250, 129, 0);
text-decoration: line-through;
}
*:not(ychange)[ychange_state='removed'] {
background-color: #ff9494c9;
text-decoration: line-through;
}
img[ychange_state='removed'] {
padding: 2px;
}
#y-connect-btn {
position: absolute;
top: 20px;
right: 20px;
}
</style>
</head>
<body>
<button type="button" id="y-connect-btn">Disconnect</button>
<p></p>
<p>This is a demo of <a href="https://github.com/yjs/yjs">Yjs</a> ⇔ <a
href="https://atlaskit.atlassian.com/">Atlaskit Editor</a></p>
<p>The content of this editor is shared with every client that visits this
domain.</p>
<div id="editor"></div>
</body>
</html> | {
"repo_name": "yjs/yjs-demos",
"stars": "521",
"repo_language": "JavaScript",
"file_name": "README.md",
"mime_type": "text/plain"
} |
/* eslint-env browser */
import * as React from 'react'
import * as ReactDOM from 'react-dom'
import * as Y from 'yjs'
import { WebsocketProvider } from 'y-websocket'
import { ySyncPlugin, yCursorPlugin, yUndoPlugin, undo, redo } from 'y-prosemirror'
import { keymap } from 'prosemirror-keymap'
import {
Editor,
EditorContext,
ReactEditorView
} from '@atlaskit/editor-core'
window.addEventListener('load', () => {
const ydoc = new Y.Doc()
const provider = new WebsocketProvider('wss://demos.yjs.dev', 'atlaskit-demo', ydoc)
const yXmlFragment = ydoc.get('prosemirror-atlaskit', Y.XmlFragment)
const connectBtn = document.getElementById('y-connect-btn')
connectBtn.addEventListener('click', () => {
if (provider.shouldConnect) {
provider.disconnect()
connectBtn.textContent = 'Connect'
} else {
provider.connect()
connectBtn.textContent = 'Disconnect'
}
})
/**
* The Atlasian Editor does not provide a method to add custom ProseMirror plugins.
* This hack intercepts the generation of Atlassian edits so we can extend it.
*
* Ideally you would fork ProseMirror and add the Yjs plugin properly.
*/
const originalGetPlugins = ReactEditorView.prototype.getPlugins
ReactEditorView.prototype.getPlugins = function () {
return originalGetPlugins.apply(this, arguments).concat([{
name: 'yjs-plugin',
pmPlugins: function () {
return [
{
name: 'y-shared-content',
plugin: function (_a) {
return ySyncPlugin(yXmlFragment)
}
}, {
name: 'y-shared-cursors',
plugin: function (_a) {
return yCursorPlugin(provider.awareness)
}
}, {
name: 'y-undo-plugin',
plugin: yUndoPlugin
}, {
name: 'y-undo-keymaps',
plugin: () => keymap({
'Mod-z': undo,
'Mod-y': redo,
'Mod-Shift-z': redo
})
}
]
}
}])
}
class ExampleEditorFullPage extends React.Component {
render () {
return (
<Editor
defaultValue={this.props.defaultValue}
appearance='full-page'
allowCodeBlocks={{ enableKeybindingsForIDE: true }}
allowLists
allowBreakout
allowTextColor
allowTextAlignment
allowIndentation
allowTables={{
allowColumnResizing: true,
allowMergeCells: true,
allowNumberColumn: true,
allowBackgroundColor: true,
allowHeaderRow: true,
allowHeaderColumn: true,
permittedLayouts: 'all',
stickToolbarToBottom: true
}}
allowJiraIssue
allowUnsupportedContent
allowPanel
allowStatus
allowExtension={{
allowBreakout: true
}}
allowRule
allowDate
allowLayouts
allowDynamicTextSizing
placeholder='Write something...'
shouldFocus
disabled={false}
/>
)
}
}
ReactDOM.render(
<EditorContext>
<ExampleEditorFullPage />
</EditorContext>,
document.getElementById('editor')
)
window.example = { provider, ydoc, yXmlFragment }
})
| {
"repo_name": "yjs/yjs-demos",
"stars": "521",
"repo_language": "JavaScript",
"file_name": "README.md",
"mime_type": "text/plain"
} |
const path = require('path')
module.exports = {
mode: 'development',
devtool: 'source-map',
entry: {
atlaskit: './atlaskit.js'
},
output: {
path: path.resolve(__dirname, './dist'),
filename: '[name].bundle.js',
publicPath: '/atlaskit/dist/'
},
module: {
rules: [{
test: /\.(js|jsx)$/,
exclude: /node_modules/,
use: ['babel-loader']
}, {
test: /\.css$/,
use: ['style-loader', 'css-loader']
}]
},
resolve: {
extensions: ['*', '.js', '.jsx']
},
devServer: {
contentBase: path.join(__dirname),
compress: true,
publicPath: '/dist/'
}
}
| {
"repo_name": "yjs/yjs-demos",
"stars": "521",
"repo_language": "JavaScript",
"file_name": "README.md",
"mime_type": "text/plain"
} |
# Atlaskit Demo
> [y-prosemirror](https://docs.yjs.dev/ecosystem/editor-bindings/prosemirror) / [y-websocket](https://docs.yjs.dev/ecosystem/connection-provider/y-websocket) / [Live Demo](https://demos.yjs.dev/atlaskit/atlaskit.html)
This is a demo of an [Atlaskit](https://atlaskit.atlassian.com/) editor that was made collaborative with Yjs & y-prosemirror. Since Atlaskit is based on ProseMirror, we simply need to add y-prosemirror to the internal ProseMirror instance. Find out more about the prosemirror binding in our [Official Docs](https://docs.yjs.dev/ecosystem/editor-bindings/prosemirror).
We use the [y-websocket](https://docs.yjs.dev/ecosystem/connection-provider/y-websocket) provider to share document updates through a server. There are many more providers available for Yjs - try switching to another provider. [See docs](https://docs.yjs.dev/ecosystem/connection-provider).
Also you could try addingh offline persistence to this demo. Wouldn't it be cool if document updates are persisted in the browser, so you can load your application load faster? Try it out: https://docs.yjs.dev/getting-started/allowing-offline-editing
## Quick Start
```sh
npm i
npm start
# Project is running at http://localhost:8080/
```
| {
"repo_name": "yjs/yjs-demos",
"stars": "521",
"repo_language": "JavaScript",
"file_name": "README.md",
"mime_type": "text/plain"
} |
/* eslint-env browser */
import * as Y from 'yjs'
import { WebsocketProvider } from 'y-websocket'
import { ySyncPlugin, yCursorPlugin, yUndoPlugin, undo, redo } from 'y-prosemirror'
import { EditorState } from 'prosemirror-state'
import { EditorView } from 'prosemirror-view'
import { schema } from './schema.js'
import { exampleSetup } from 'prosemirror-example-setup'
import { keymap } from 'prosemirror-keymap'
window.addEventListener('load', () => {
const ydoc = new Y.Doc()
const provider = new WebsocketProvider('wss://demos.yjs.dev', 'prosemirror-demo', ydoc)
const yXmlFragment = ydoc.getXmlFragment('prosemirror')
const editor = document.createElement('div')
editor.setAttribute('id', 'editor')
const editorContainer = document.createElement('div')
editorContainer.insertBefore(editor, null)
const prosemirrorView = new EditorView(editor, {
state: EditorState.create({
schema,
plugins: [
ySyncPlugin(yXmlFragment),
yCursorPlugin(provider.awareness),
yUndoPlugin(),
keymap({
'Mod-z': undo,
'Mod-y': redo,
'Mod-Shift-z': redo
})
].concat(exampleSetup({ schema }))
})
})
document.body.insertBefore(editorContainer, null)
const connectBtn = /** @type {HTMLElement} */ (document.getElementById('y-connect-btn'))
connectBtn.addEventListener('click', () => {
if (provider.shouldConnect) {
provider.disconnect()
connectBtn.textContent = 'Connect'
} else {
provider.connect()
connectBtn.textContent = 'Disconnect'
}
})
// @ts-ignore
window.example = { provider, ydoc, yXmlFragment, prosemirrorView }
})
| {
"repo_name": "yjs/yjs-demos",
"stars": "521",
"repo_language": "JavaScript",
"file_name": "README.md",
"mime_type": "text/plain"
} |
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8"/>
<title>Yjs Prosemirror Example</title>
<script type="text/javascript" src="./dist/prosemirror.bundle.js" async></script>
<link rel=stylesheet href="./prosemirror.css" async defer>
<style>
placeholder {
display: inline;
border: 1px solid #ccc;
color: #ccc;
}
placeholder:after {
content: "☁";
font-size: 200%;
line-height: 0.1;
font-weight: bold;
}
.ProseMirror img { max-width: 100px }
/* this is a rough fix for the first cursor position when the first paragraph is empty */
.ProseMirror > .ProseMirror-yjs-cursor:first-child {
margin-top: 16px;
}
.ProseMirror p:first-child, .ProseMirror h1:first-child, .ProseMirror h2:first-child, .ProseMirror h3:first-child, .ProseMirror h4:first-child, .ProseMirror h5:first-child, .ProseMirror h6:first-child {
margin-top: 16px
}
/* This gives the remote user caret. The colors are automatically overwritten*/
.ProseMirror-yjs-cursor {
position: relative;
margin-left: -1px;
margin-right: -1px;
border-left: 1px solid black;
border-right: 1px solid black;
border-color: orange;
word-break: normal;
pointer-events: none;
}
/* This renders the username above the caret */
.ProseMirror-yjs-cursor > div {
position: absolute;
top: -1.05em;
left: -1px;
font-size: 13px;
background-color: rgb(250, 129, 0);
font-family: serif;
font-style: normal;
font-weight: normal;
line-height: normal;
user-select: none;
color: white;
padding-left: 2px;
padding-right: 2px;
white-space: nowrap;
}
#y-functions {
position: absolute;
top: 20px;
right: 20px;
}
#y-functions > * {
display: inline-block;
}
</style>
</head>
<body>
<div id="y-functions">
<div id="y-version"></div>
<button type="button" id="y-connect-btn">Disconnect</button>
</div>
<p></p>
<p>This is a demo of the <a href="https://github.com/yjs/yjs">Yjs</a> ⇔ <a href="http://prosemirror.net/">ProseMirror</a> binding: <a href="https://github.com/yjs/y-prosemirror">y-prosemirror</a>.</p>
<p>The content of this editor is shared with every client that visits this domain.</p>
</body>
</html>
| {
"repo_name": "yjs/yjs-demos",
"stars": "521",
"repo_language": "JavaScript",
"file_name": "README.md",
"mime_type": "text/plain"
} |
import { Schema } from 'prosemirror-model'
const brDOM = ['br']
const calcYchangeDomAttrs = (attrs, domAttrs = {}) => {
domAttrs = Object.assign({}, domAttrs)
if (attrs.ychange !== null) {
domAttrs.ychange_user = attrs.ychange.user
domAttrs.ychange_state = attrs.ychange.state
}
return domAttrs
}
// :: Object
// [Specs](#model.NodeSpec) for the nodes defined in this schema.
export const nodes = {
// :: NodeSpec The top level document node.
doc: {
content: 'block+'
},
// :: NodeSpec A plain paragraph textblock. Represented in the DOM
// as a `<p>` element.
paragraph: {
attrs: { ychange: { default: null } },
content: 'inline*',
group: 'block',
parseDOM: [{ tag: 'p' }],
toDOM (node) { return ['p', calcYchangeDomAttrs(node.attrs), 0] }
},
// :: NodeSpec A blockquote (`<blockquote>`) wrapping one or more blocks.
blockquote: {
attrs: { ychange: { default: null } },
content: 'block+',
group: 'block',
defining: true,
parseDOM: [{ tag: 'blockquote' }],
toDOM (node) { return ['blockquote', calcYchangeDomAttrs(node.attrs), 0] }
},
// :: NodeSpec A horizontal rule (`<hr>`).
horizontal_rule: {
attrs: { ychange: { default: null } },
group: 'block',
parseDOM: [{ tag: 'hr' }],
toDOM (node) {
return ['hr', calcYchangeDomAttrs(node.attrs)]
}
},
// :: NodeSpec A heading textblock, with a `level` attribute that
// should hold the number 1 to 6. Parsed and serialized as `<h1>` to
// `<h6>` elements.
heading: {
attrs: {
level: { default: 1 },
ychange: { default: null }
},
content: 'inline*',
group: 'block',
defining: true,
parseDOM: [{ tag: 'h1', attrs: { level: 1 } },
{ tag: 'h2', attrs: { level: 2 } },
{ tag: 'h3', attrs: { level: 3 } },
{ tag: 'h4', attrs: { level: 4 } },
{ tag: 'h5', attrs: { level: 5 } },
{ tag: 'h6', attrs: { level: 6 } }],
toDOM (node) { return ['h' + node.attrs.level, calcYchangeDomAttrs(node.attrs), 0] }
},
// :: NodeSpec A code listing. Disallows marks or non-text inline
// nodes by default. Represented as a `<pre>` element with a
// `<code>` element inside of it.
code_block: {
attrs: { ychange: { default: null } },
content: 'text*',
marks: '',
group: 'block',
code: true,
defining: true,
parseDOM: [{ tag: 'pre', preserveWhitespace: 'full' }],
toDOM (node) { return ['pre', calcYchangeDomAttrs(node.attrs), ['code', 0]] }
},
// :: NodeSpec The text node.
text: {
group: 'inline'
},
// :: NodeSpec An inline image (`<img>`) node. Supports `src`,
// `alt`, and `href` attributes. The latter two default to the empty
// string.
image: {
inline: true,
attrs: {
ychange: { default: null },
src: {},
alt: { default: null },
title: { default: null }
},
group: 'inline',
draggable: true,
parseDOM: [{
tag: 'img[src]',
getAttrs (dom) {
return {
src: dom.getAttribute('src'),
title: dom.getAttribute('title'),
alt: dom.getAttribute('alt')
}
}
}],
toDOM (node) {
const domAttrs = {
src: node.attrs.src,
title: node.attrs.title,
alt: node.attrs.alt
}
return ['img', calcYchangeDomAttrs(node.attrs, domAttrs)]
}
},
// :: NodeSpec A hard line break, represented in the DOM as `<br>`.
hard_break: {
inline: true,
group: 'inline',
selectable: false,
parseDOM: [{ tag: 'br' }],
toDOM () { return brDOM }
}
}
const emDOM = ['em', 0]; const strongDOM = ['strong', 0]; const codeDOM = ['code', 0]
// :: Object [Specs](#model.MarkSpec) for the marks in the schema.
export const marks = {
// :: MarkSpec A link. Has `href` and `title` attributes. `title`
// defaults to the empty string. Rendered and parsed as an `<a>`
// element.
link: {
attrs: {
href: {},
title: { default: null }
},
inclusive: false,
parseDOM: [{
tag: 'a[href]',
getAttrs (dom) {
return { href: dom.getAttribute('href'), title: dom.getAttribute('title') }
}
}],
toDOM (node) { return ['a', node.attrs, 0] }
},
// :: MarkSpec An emphasis mark. Rendered as an `<em>` element.
// Has parse rules that also match `<i>` and `font-style: italic`.
em: {
parseDOM: [{ tag: 'i' }, { tag: 'em' }, { style: 'font-style=italic' }],
toDOM () { return emDOM }
},
// :: MarkSpec A strong mark. Rendered as `<strong>`, parse rules
// also match `<b>` and `font-weight: bold`.
strong: {
parseDOM: [{ tag: 'strong' },
// This works around a Google Docs misbehavior where
// pasted content will be inexplicably wrapped in `<b>`
// tags with a font-weight normal.
{ tag: 'b', getAttrs: node => node.style.fontWeight !== 'normal' && null },
{ style: 'font-weight', getAttrs: value => /^(bold(er)?|[5-9]\d{2,})$/.test(value) && null }],
toDOM () { return strongDOM }
},
// :: MarkSpec Code font mark. Represented as a `<code>` element.
code: {
parseDOM: [{ tag: 'code' }],
toDOM () { return codeDOM }
},
ychange: {
attrs: {
user: { default: null },
state: { default: null }
},
inclusive: false,
parseDOM: [{ tag: 'ychange' }],
toDOM (node) {
return ['ychange', { ychange_user: node.attrs.user, ychange_state: node.attrs.state }, 0]
}
}
}
// :: Schema
// This schema rougly corresponds to the document schema used by
// [CommonMark](http://commonmark.org/), minus the list elements,
// which are defined in the [`prosemirror-schema-list`](#schema-list)
// module.
//
// To reuse elements from this schema, extend or read from its
// `spec.nodes` and `spec.marks` [properties](#model.Schema.spec).
export const schema = new Schema({ nodes, marks })
| {
"repo_name": "yjs/yjs-demos",
"stars": "521",
"repo_language": "JavaScript",
"file_name": "README.md",
"mime_type": "text/plain"
} |
.ProseMirror {
position: relative;
}
.ProseMirror {
word-wrap: break-word;
white-space: pre-wrap;
-webkit-font-variant-ligatures: none;
font-variant-ligatures: none;
}
.ProseMirror pre {
white-space: pre-wrap;
}
.ProseMirror li {
position: relative;
}
.ProseMirror-hideselection *::selection { background: transparent; }
.ProseMirror-hideselection *::-moz-selection { background: transparent; }
.ProseMirror-hideselection { caret-color: transparent; }
.ProseMirror-selectednode {
outline: 2px solid #8cf;
}
/* Make sure li selections wrap around markers */
li.ProseMirror-selectednode {
outline: none;
}
li.ProseMirror-selectednode:after {
content: "";
position: absolute;
left: -32px;
right: -2px; top: -2px; bottom: -2px;
border: 2px solid #8cf;
pointer-events: none;
}
.ProseMirror-textblock-dropdown {
min-width: 3em;
}
.ProseMirror-menu {
margin: 0 -4px;
line-height: 1;
}
.ProseMirror-tooltip .ProseMirror-menu {
width: -webkit-fit-content;
width: fit-content;
white-space: pre;
}
.ProseMirror-menuitem {
margin-right: 3px;
display: inline-block;
}
.ProseMirror-menuseparator {
border-right: 1px solid #ddd;
margin-right: 3px;
}
.ProseMirror-menu-dropdown, .ProseMirror-menu-dropdown-menu {
font-size: 90%;
white-space: nowrap;
}
.ProseMirror-menu-dropdown {
vertical-align: 1px;
cursor: pointer;
position: relative;
padding-right: 15px;
}
.ProseMirror-menu-dropdown-wrap {
padding: 1px 0 1px 4px;
display: inline-block;
position: relative;
}
.ProseMirror-menu-dropdown:after {
content: "";
border-left: 4px solid transparent;
border-right: 4px solid transparent;
border-top: 4px solid currentColor;
opacity: .6;
position: absolute;
right: 4px;
top: calc(50% - 2px);
}
.ProseMirror-menu-dropdown-menu, .ProseMirror-menu-submenu {
position: absolute;
background: white;
color: #666;
border: 1px solid #aaa;
padding: 2px;
}
.ProseMirror-menu-dropdown-menu {
z-index: 15;
min-width: 6em;
}
.ProseMirror-menu-dropdown-item {
cursor: pointer;
padding: 2px 8px 2px 4px;
}
.ProseMirror-menu-dropdown-item:hover {
background: #f2f2f2;
}
.ProseMirror-menu-submenu-wrap {
position: relative;
margin-right: -4px;
}
.ProseMirror-menu-submenu-label:after {
content: "";
border-top: 4px solid transparent;
border-bottom: 4px solid transparent;
border-left: 4px solid currentColor;
opacity: .6;
position: absolute;
right: 4px;
top: calc(50% - 4px);
}
.ProseMirror-menu-submenu {
display: none;
min-width: 4em;
left: 100%;
top: -3px;
}
.ProseMirror-menu-active {
background: #eee;
border-radius: 4px;
}
.ProseMirror-menu-active {
background: #eee;
border-radius: 4px;
}
.ProseMirror-menu-disabled {
opacity: .3;
}
.ProseMirror-menu-submenu-wrap:hover .ProseMirror-menu-submenu, .ProseMirror-menu-submenu-wrap-active .ProseMirror-menu-submenu {
display: block;
}
.ProseMirror-menubar {
border-top-left-radius: inherit;
border-top-right-radius: inherit;
position: relative;
min-height: 1em;
color: #666;
padding: 1px 6px;
top: 0; left: 0; right: 0;
border-bottom: 1px solid silver;
background: white;
z-index: 10;
-moz-box-sizing: border-box;
box-sizing: border-box;
overflow: visible;
}
.ProseMirror-icon {
display: inline-block;
line-height: .8;
vertical-align: -2px; /* Compensate for padding */
padding: 2px 8px;
cursor: pointer;
}
.ProseMirror-menu-disabled.ProseMirror-icon {
cursor: default;
}
.ProseMirror-icon svg {
fill: currentColor;
height: 1em;
}
.ProseMirror-icon span {
vertical-align: text-top;
}
.ProseMirror-gapcursor {
display: none;
pointer-events: none;
position: absolute;
}
.ProseMirror-gapcursor:after {
content: "";
display: block;
position: absolute;
top: -2px;
width: 20px;
border-top: 1px solid black;
animation: ProseMirror-cursor-blink 1.1s steps(2, start) infinite;
}
@keyframes ProseMirror-cursor-blink {
to {
visibility: hidden;
}
}
.ProseMirror-focused .ProseMirror-gapcursor {
display: block;
}
/* Add space around the hr to make clicking it easier */
.ProseMirror-example-setup-style hr {
padding: 2px 10px;
border: none;
margin: 1em 0;
}
.ProseMirror-example-setup-style hr:after {
content: "";
display: block;
height: 1px;
background-color: silver;
line-height: 2px;
}
.ProseMirror ul, .ProseMirror ol {
padding-left: 30px;
}
.ProseMirror blockquote {
padding-left: 1em;
border-left: 3px solid #eee;
margin-left: 0; margin-right: 0;
}
.ProseMirror-example-setup-style img {
cursor: default;
}
.ProseMirror-prompt {
background: white;
padding: 5px 10px 5px 15px;
border: 1px solid silver;
position: fixed;
border-radius: 3px;
z-index: 11;
box-shadow: -.5px 2px 5px rgba(0, 0, 0, .2);
}
.ProseMirror-prompt h5 {
margin: 0;
font-weight: normal;
font-size: 100%;
color: #444;
}
.ProseMirror-prompt input[type="text"],
.ProseMirror-prompt textarea {
background: #eee;
border: none;
outline: none;
}
.ProseMirror-prompt input[type="text"] {
padding: 0 4px;
}
.ProseMirror-prompt-close {
position: absolute;
left: 2px; top: 1px;
color: #666;
border: none; background: transparent; padding: 0;
}
.ProseMirror-prompt-close:after {
content: "✕";
font-size: 12px;
}
.ProseMirror-invalid {
background: #ffc;
border: 1px solid #cc7;
border-radius: 4px;
padding: 5px 10px;
position: absolute;
min-width: 10em;
}
.ProseMirror-prompt-buttons {
margin-top: 5px;
display: none;
}
#editor, .editor {
background: white;
color: black;
background-clip: padding-box;
border-radius: 4px;
border: 2px solid rgba(0, 0, 0, 0.2);
padding: 5px 0;
margin-bottom: 23px;
}
.ProseMirror p:first-child,
.ProseMirror h1:first-child,
.ProseMirror h2:first-child,
.ProseMirror h3:first-child,
.ProseMirror h4:first-child,
.ProseMirror h5:first-child,
.ProseMirror h6:first-child {
margin-top: 10px;
}
.ProseMirror {
padding: 4px 8px 4px 14px;
line-height: 1.2;
outline: none;
}
.ProseMirror p { margin-bottom: 1em }
| {
"repo_name": "yjs/yjs-demos",
"stars": "521",
"repo_language": "JavaScript",
"file_name": "README.md",
"mime_type": "text/plain"
} |
const path = require('path')
module.exports = {
mode: 'development',
devtool: 'source-map',
entry: {
prosemirror: './prosemirror.js'
},
output: {
globalObject: 'self',
path: path.resolve(__dirname, './dist/'),
filename: '[name].bundle.js',
publicPath: '/prosemirror/dist/'
},
devServer: {
contentBase: path.join(__dirname),
compress: true,
publicPath: '/dist/'
}
}
| {
"repo_name": "yjs/yjs-demos",
"stars": "521",
"repo_language": "JavaScript",
"file_name": "README.md",
"mime_type": "text/plain"
} |
# ProseMirror Demo
> [y-prosemirror](https://docs.yjs.dev/ecosystem/editor-bindings/prosemirror) / [y-websocket](https://docs.yjs.dev/ecosystem/connection-provider/y-websocket) / [Live Demo](https://demos.yjs.dev/prosemirror/prosemirror.html)
This is a demo of a [ProseMirror](https://prosemirror.net/) editor that was made collaborative with Yjs & y-prosemirror. This demo uses the [prosemirror-example-setup](https://github.com/ProseMirror/prosemirror-example-setup) as a configuration. Learn more about how you can build your own custom editor with ProseMirror in [their documentation](https://github.com/yjs/y-prosemirror/).
We use the [y-websocket](https://docs.yjs.dev/ecosystem/connection-provider/y-websocket) provider to share document updates through a server. There are many more providers available for Yjs - try switching to another provider. [See docs](https://docs.yjs.dev/ecosystem/connection-provider).
Also you could try addingh offline persistence to this demo. Wouldn't it be cool if document updates are persisted in the browser, so you can load your application load faster? Try it out: https://docs.yjs.dev/getting-started/allowing-offline-editing
## Quick Start
```sh
npm i
npm start
# Project is running at http://localhost:8080/
```
| {
"repo_name": "yjs/yjs-demos",
"stars": "521",
"repo_language": "JavaScript",
"file_name": "README.md",
"mime_type": "text/plain"
} |
/* eslint-env browser */
import * as Y from 'yjs'
import { WebsocketProvider } from 'y-websocket'
import { MonacoBinding } from 'y-monaco'
import * as monaco from 'monaco-editor'
// @ts-ignore
window.MonacoEnvironment = {
getWorkerUrl: function (moduleId, label) {
if (label === 'json') {
return '/monaco/dist/json.worker.bundle.js'
}
if (label === 'css') {
return '/monaco/dist/css.worker.bundle.js'
}
if (label === 'html') {
return '/monaco/dist/html.worker.bundle.js'
}
if (label === 'typescript' || label === 'javascript') {
return '/monaco/dist/ts.worker.bundle.js'
}
return '/monaco/dist/editor.worker.bundle.js'
}
}
window.addEventListener('load', () => {
const ydoc = new Y.Doc()
const provider = new WebsocketProvider('wss://demos.yjs.dev', 'monaco-demo', ydoc)
const ytext = ydoc.getText('monaco')
const editor = monaco.editor.create(/** @type {HTMLElement} */ (document.getElementById('monaco-editor')), {
value: '',
language: 'javascript',
theme: 'vs-dark'
})
const monacoBinding = new MonacoBinding(ytext, /** @type {monaco.editor.ITextModel} */ (editor.getModel()), new Set([editor]), provider.awareness)
const connectBtn = /** @type {HTMLElement} */ (document.getElementById('y-connect-btn'))
connectBtn.addEventListener('click', () => {
if (provider.shouldConnect) {
provider.disconnect()
connectBtn.textContent = 'Connect'
} else {
provider.connect()
connectBtn.textContent = 'Disconnect'
}
})
// @ts-ignore
window.example = { provider, ydoc, ytext, monacoBinding }
})
| {
"repo_name": "yjs/yjs-demos",
"stars": "521",
"repo_language": "JavaScript",
"file_name": "README.md",
"mime_type": "text/plain"
} |
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8"/>
<title>Yjs Monaco Example</title>
<style>
#monaco-editor {
width:100%;
height:600px;
border:1px solid #ccc;
}
.yRemoteSelection {
background-color: rgb(250, 129, 0, .5)
}
.yRemoteSelectionHead {
position: absolute;
border-left: orange solid 2px;
border-top: orange solid 2px;
border-bottom: orange solid 2px;
height: 100%;
box-sizing: border-box;
}
.yRemoteSelectionHead::after {
position: absolute;
content: ' ';
border: 3px solid orange;
border-radius: 4px;
left: -4px;
top: -5px;
}
</style>
</head>
<body>
<button type="button" id="y-connect-btn">Disconnect</button>
<p></p>
<p>This is a demo of the <a href="https://github.com/yjs/yjs">Yjs</a> ⇔ <a href="https://microsoft.github.io/monaco-editor/">Monaco</a> binding: <a href="https://github.com/yjs/y-monaco">y-monaco</a>.</p>
<p>The content of this editor is shared with every client that visits this domain.</p>
<div id="monaco-editor" />
<script type="text/javascript" src="./dist/monaco.bundle.js"></script>
</body>
</html>
| {
"repo_name": "yjs/yjs-demos",
"stars": "521",
"repo_language": "JavaScript",
"file_name": "README.md",
"mime_type": "text/plain"
} |
const path = require('path')
module.exports = {
mode: 'development',
devtool: 'source-map',
entry: {
monaco: './monaco.js',
// Package each language's worker and give these filenames in `getWorkerUrl`
'editor.worker': 'monaco-editor/esm/vs/editor/editor.worker.js',
'json.worker': 'monaco-editor/esm/vs/language/json/json.worker',
'css.worker': 'monaco-editor/esm/vs/language/css/css.worker',
'html.worker': 'monaco-editor/esm/vs/language/html/html.worker',
'ts.worker': 'monaco-editor/esm/vs/language/typescript/ts.worker'
},
output: {
globalObject: 'self',
path: path.resolve(__dirname, './dist/'),
filename: '[name].bundle.js',
publicPath: '/monaco/dist/'
},
module: {
rules: [{
test: /\.css$/,
use: ['style-loader', 'css-loader']
}, {
test: /\.ttf$/,
use: ['file-loader']
}]
},
devServer: {
contentBase: path.join(__dirname, '../'),
compress: true,
publicPath: '/monaco/dist/'
}
}
| {
"repo_name": "yjs/yjs-demos",
"stars": "521",
"repo_language": "JavaScript",
"file_name": "README.md",
"mime_type": "text/plain"
} |
# Monaco Demo
> [y-monaco](https://docs.yjs.dev/ecosystem/editor-bindings/monaco) / [y-websocket](https://docs.yjs.dev/ecosystem/connection-provider/y-websocket) / [Live Demo](https://demos.yjs.dev/monaco/monaco.html)
This is a demo of a [Monaco](https://microsoft.github.io/monaco-editor/) editor that was made collaborative with Yjs & `y-monaco`.
We use the [y-websocket](https://docs.yjs.dev/ecosystem/connection-provider/y-websocket) provider to share document updates through a server. There are many more providers available for Yjs - try switching to another provider. [See docs](https://docs.yjs.dev/ecosystem/connection-provider).
Also you could try adding offline persistence to this demo. Wouldn't it be cool if document updates were persisted in the browser so you could load your application load faster? Try it out: https://docs.yjs.dev/getting-started/allowing-offline-editing
## Quick Start
```sh
npm i
npm start
# Project is running at http://localhost:8080/
```
| {
"repo_name": "yjs/yjs-demos",
"stars": "521",
"repo_language": "JavaScript",
"file_name": "README.md",
"mime_type": "text/plain"
} |
/* eslint-env browser */
import * as Y from 'yjs'
import { WebsocketProvider } from 'y-websocket'
import { QuillBinding } from 'y-quill'
import Quill from 'quill'
import QuillCursors from 'quill-cursors'
Quill.register('modules/cursors', QuillCursors)
window.addEventListener('load', () => {
const ydoc = new Y.Doc()
const provider = new WebsocketProvider('wss://demos.yjs.dev', 'quill-demo-4', ydoc)
const ytext = ydoc.getText('quill')
const editorContainer = document.createElement('div')
editorContainer.setAttribute('id', 'editor')
document.body.insertBefore(editorContainer, null)
const editor = new Quill(editorContainer, {
modules: {
cursors: true,
toolbar: [
[{ header: [1, 2, false] }],
['bold', 'italic', 'underline'],
['image', 'code-block']
],
history: {
userOnly: true
}
},
placeholder: 'Start collaborating...',
theme: 'snow' // or 'bubble'
})
const binding = new QuillBinding(ytext, editor, provider.awareness)
/*
// Define user name and user name
// Check the quill-cursors package on how to change the way cursors are rendered
provider.awareness.setLocalStateField('user', {
name: 'Typing Jimmy',
color: 'blue'
})
*/
const connectBtn = document.getElementById('y-connect-btn')
connectBtn.addEventListener('click', () => {
if (provider.shouldConnect) {
provider.disconnect()
connectBtn.textContent = 'Connect'
} else {
provider.connect()
connectBtn.textContent = 'Disconnect'
}
})
// @ts-ignore
window.example = { provider, ydoc, ytext, binding, Y }
})
| {
"repo_name": "yjs/yjs-demos",
"stars": "521",
"repo_language": "JavaScript",
"file_name": "README.md",
"mime_type": "text/plain"
} |
#editor {
min-height: 500px;
} | {
"repo_name": "yjs/yjs-demos",
"stars": "521",
"repo_language": "JavaScript",
"file_name": "README.md",
"mime_type": "text/plain"
} |
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8"/>
<title>Yjs Quill Example</title>
<script type="text/javascript" src="./dist/quill.bundle.js" async></script>
<link rel=stylesheet href="./quill.css" async defer>
<link rel=stylesheet href="//cdn.quilljs.com/1.3.6/quill.snow.css" async
defer>
<link rel=stylesheet href="//cdnjs.cloudflare.com/ajax/libs/KaTeX/0.7.1/katex.min.css" async
defer>
<link rel=stylesheet href="//cdnjs.cloudflare.com/ajax/libs/highlight.js/9.12.0/styles/monokai-sublime.min.css" async
defer>
</head>
<body>
<button type="button" id="y-connect-btn">Disconnect</button>
<p></p>
<p>This is a demo of the <a href="https://github.com/yjs/yjs">Yjs</a> ⇔ <a href="https://quilljs.com/">Quill</a> binding: <a href="https://github.com/yjs/y-quill">y-quill</a>.</p>
<p>The content of this editor is shared with every client that visits this domain.</p>
</body>
</html>
| {
"repo_name": "yjs/yjs-demos",
"stars": "521",
"repo_language": "JavaScript",
"file_name": "README.md",
"mime_type": "text/plain"
} |
const path = require('path')
module.exports = {
mode: 'development',
devtool: 'source-map',
entry: {
quill: './quill.js'
},
output: {
globalObject: 'self',
path: path.resolve(__dirname, './dist/'),
filename: '[name].bundle.js',
publicPath: '/quill/dist/'
},
devServer: {
contentBase: path.join(__dirname),
compress: true,
publicPath: '/dist/'
}
}
| {
"repo_name": "yjs/yjs-demos",
"stars": "521",
"repo_language": "JavaScript",
"file_name": "README.md",
"mime_type": "text/plain"
} |
# Quill Demo
> [y-quill](https://docs.yjs.dev/ecosystem/editor-bindings/quill) / [y-websocket](https://docs.yjs.dev/ecosystem/connection-provider/y-websocket) / [Live Demo](https://demos.yjs.dev/quill/quill.html)
This is a demo of a [Quill](https://quilljs.com/) editor that was made collaborative with Yjs & y-quill. Learn more about how you can customize Quill in [their documentation](https://quilljs.com/).
We use the [y-websocket](https://docs.yjs.dev/ecosystem/connection-provider/y-websocket) provider to share document updates through a server. There are many more providers available for Yjs - try switching to another provider. [See docs](https://docs.yjs.dev/ecosystem/connection-provider).
Also you could try adding offline persistence to this demo. Wouldn't it be cool if document updates are persisted in the browser, so you can load your application faster? Try it out: https://docs.yjs.dev/getting-started/allowing-offline-editing
## Quick Start
```sh
npm i
npm start
# Project is running at http://localhost:8080/
```
| {
"repo_name": "yjs/yjs-demos",
"stars": "521",
"repo_language": "JavaScript",
"file_name": "README.md",
"mime_type": "text/plain"
} |
/* eslint-env browser */
import * as Y from 'yjs'
// @ts-ignore
import { yCollab, yUndoManagerKeymap } from 'y-codemirror.next'
import { WebsocketProvider } from 'y-websocket'
import { EditorState, EditorView, basicSetup } from '@codemirror/basic-setup'
import { keymap } from '@codemirror/view'
import { javascript } from '@codemirror/lang-javascript'
import * as random from 'lib0/random'
export const usercolors = [
{ color: '#30bced', light: '#30bced33' },
{ color: '#6eeb83', light: '#6eeb8333' },
{ color: '#ffbc42', light: '#ffbc4233' },
{ color: '#ecd444', light: '#ecd44433' },
{ color: '#ee6352', light: '#ee635233' },
{ color: '#9ac2c9', light: '#9ac2c933' },
{ color: '#8acb88', light: '#8acb8833' },
{ color: '#1be7ff', light: '#1be7ff33' }
]
export const userColor = usercolors[random.uint32() % usercolors.length]
const ydoc = new Y.Doc()
// const provider = new WebrtcProvider('codemirror6-demo-room', ydoc)
const provider = new WebsocketProvider(
'wss://demos.yjs.dev',
'codemirror.next-demo',
ydoc
)
const ytext = ydoc.getText('codemirror')
provider.awareness.setLocalStateField('user', {
name: 'Anonymous ' + Math.floor(Math.random() * 100),
color: userColor.color,
colorLight: userColor.light
})
const state = EditorState.create({
doc: ytext.toString(),
extensions: [
keymap.of([
...yUndoManagerKeymap
]),
basicSetup,
javascript(),
yCollab(ytext, provider.awareness)
// oneDark
]
})
const view = new EditorView({ state, parent: /** @type {HTMLElement} */ (document.querySelector('#editor')) })
// @ts-ignore
window.example = { provider, ydoc, ytext, view }
| {
"repo_name": "yjs/yjs-demos",
"stars": "521",
"repo_language": "JavaScript",
"file_name": "README.md",
"mime_type": "text/plain"
} |
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8" />
<title>Yjs CodeMirror Example</title>
<script type="text/javascript" src="./dist/codemirror.bundle.js" async></script>
<link rel=stylesheet href="https://codemirror.net/lib/codemirror.css" async defer>
<style>
.remote-caret {
position: relative;
border-left: 2px solid black;
margin-left: -1px;
margin-right: -1px;
box-sizing: border-box;
}
.remote-caret > div {
position: absolute;
top: -1.05em;
left: -2px;
font-size: .6em;
background-color: rgb(250, 129, 0);
font-family: serif;
font-style: normal;
font-weight: normal;
line-height: normal;
user-select: none;
color: white;
padding-left: 2px;
padding-right: 2px;
z-index: 3;
transition: opacity .3s ease-in-out;
}
.remote-caret.hide-name > div {
transition-delay: .7s;
opacity: 0;
}
.remote-caret:hover > div {
opacity: 1;
transition-delay: 0s;
}
</style>
</head>
<body>
<button type="button" id="y-connect-btn">Disconnect</button>
<p></p>
<p>
This is a demo of the <a href="https://github.com/yjs/yjs">Yjs</a> ⇔
<a href="https://codemirror.net/6/">CodeMirror 6</a> binding:
<a href="https://github.com/yjs/y-codemirror.next">y-codemirror.next</a>.
</p>
<p>
The content of this editor is shared with every client that visits this
domain.
</p>
<div id="editor">
</body>
</html>
| {
"repo_name": "yjs/yjs-demos",
"stars": "521",
"repo_language": "JavaScript",
"file_name": "README.md",
"mime_type": "text/plain"
} |
const path = require('path')
module.exports = {
mode: 'development',
devtool: 'source-map',
entry: {
codemirror: './codemirror.next.js'
},
output: {
globalObject: 'self',
path: path.resolve(__dirname, './dist/'),
filename: '[name].bundle.js',
publicPath: '/codemirror/dist/'
},
devServer: {
contentBase: path.join(__dirname),
compress: true,
publicPath: '/dist/'
}
}
| {
"repo_name": "yjs/yjs-demos",
"stars": "521",
"repo_language": "JavaScript",
"file_name": "README.md",
"mime_type": "text/plain"
} |
# CodeMirror6 Demo
> [y-codemirror.next](https://docs.yjs.dev/ecosystem/editor-bindings/codemirror.next) / [y-websocket](https://docs.yjs.dev/ecosystem/connection-provider/y-websocket) / [Live Demo](https://demos.yjs.dev/codemirror.next/codemirror.next.html)
This is a demo of a [CodeMirror 6](https://codemirror.net/) editor that was made collaborative with Yjs & y-codemirror.next.
We use the [y-websocket](https://docs.yjs.dev/ecosystem/connection-provider) provider to share document updates through a server. There are many more providers available for Yjs - try switching to another provider. [See docs](https://docs.yjs.dev/ecosystem/connection-provider).
Also you could try addingh offline persistence to this demo. Wouldn't it be cool if document updates are persisted in the browser, so you can load your application load faster? Try it out: https://docs.yjs.dev/getting-started/allowing-offline-editing
## Quick Start
```sh
npm i
npm start
# Project is running at http://localhost:8080/
```
| {
"repo_name": "yjs/yjs-demos",
"stars": "521",
"repo_language": "JavaScript",
"file_name": "README.md",
"mime_type": "text/plain"
} |
/* eslint-env browser */
import * as Y from 'yjs'
import { WebsocketProvider } from 'y-websocket'
import { ySyncPlugin, ySyncPluginKey, yCursorPlugin, yUndoPlugin, undo, redo } from 'y-prosemirror'
import { EditorState } from 'prosemirror-state'
import { EditorView } from 'prosemirror-view'
import { schema } from './schema.js'
import { exampleSetup } from 'prosemirror-example-setup'
import { keymap } from 'prosemirror-keymap'
import * as random from 'lib0/random.js'
import { html, render } from 'lit-html'
import * as dom from 'lib0/dom.js'
import * as pair from 'lib0/pair.js'
/**
* @typedef {Object} Version
* @property {number} date
* @property {Uint8Array} snapshot
* @property {number} clientID
*/
/**
* @param {Y.Doc} doc
*/
const addVersion = doc => {
const versions = doc.getArray('versions')
const prevVersion = versions.length === 0 ? null : versions.get(versions.length - 1)
const prevSnapshot = prevVersion === null ? Y.emptySnapshot : Y.decodeSnapshot(prevVersion.snapshot)
const snapshot = Y.snapshot(doc)
if (prevVersion != null) {
// account for the action of adding a version to ydoc
prevSnapshot.sv.set(prevVersion.clientID, /** @type {number} */ (prevSnapshot.sv.get(prevVersion.clientID)) + 1)
}
if (!Y.equalSnapshots(prevSnapshot, snapshot)) {
versions.push([{
date: new Date().getTime(),
snapshot: Y.encodeSnapshot(snapshot),
clientID: doc.clientID
}])
}
}
const liveTracking = /** @type {HTMLInputElement} */ (dom.element('input', [
pair.create('type', 'checkbox'),
pair.create('name', 'yjs-live-tracking'),
pair.create('value', 'Live Tracking ')
]))
const updateLiveTrackingState = editorstate => {
setTimeout(() => {
const syncState = ySyncPluginKey.getState(editorstate.state)
liveTracking.checked = syncState.prevSnapshot != null && syncState.snapshot == null
}, 500)
}
const renderVersion = (editorview, version, prevSnapshot) => {
editorview.dispatch(editorview.state.tr.setMeta(ySyncPluginKey, { snapshot: Y.decodeSnapshot(version.snapshot), prevSnapshot: prevSnapshot == null ? Y.emptySnapshot : Y.decodeSnapshot(prevSnapshot) }))
updateLiveTrackingState(editorview)
}
const unrenderVersion = editorview => {
const binding = ySyncPluginKey.getState(editorview.state).binding
if (binding != null) {
binding.unrenderSnapshot()
}
updateLiveTrackingState(editorview)
}
/**
* @param {EditorView} editorview
* @param {Version} version
* @param {Version|null} prevSnapshot
*/
const versionTemplate = (editorview, version, prevSnapshot) => html`<div class="version-list" @click=${e => renderVersion(editorview, version, prevSnapshot)}>${new Date(version.date).toLocaleString()}</div>`
const versionList = (editorview, doc) => {
const versions = doc.getArray('versions')
return html`<div>${versions.length > 0 ? versions.map((version, i) => versionTemplate(editorview, version, i > 0 ? versions.get(i - 1).snapshot : null)) : html`<div>No snapshots..</div>`}</div>`
}
const snapshotButton = doc => {
return html`<button @click=${(e) => addVersion(doc)}>Snapshot</button>`
}
/**
* @param {HTMLElement} parent
* @param {Y.Doc} doc
* @param {EditorView} editorview
*/
export const attachVersion = (parent, doc, editorview) => {
let open = false
const rerender = () => {
render(html`<div class="version-modal" ?hidden=${open}>${snapshotButton(doc)}${versionList(editorview, doc)}</div>`, vContainer)
}
updateLiveTrackingState(editorview)
liveTracking.addEventListener('click', e => {
if (liveTracking.checked) {
const versions = doc.getArray('versions')
const lastVersion = versions.length > 0 ? Y.decodeSnapshot(versions.get(versions.length - 1).snapshot) : Y.emptySnapshot
editorview.dispatch(editorview.state.tr.setMeta(ySyncPluginKey, { snapshot: null, prevSnapshot: lastVersion }))
} else {
unrenderVersion(editorview)
}
})
parent.insertBefore(liveTracking, null)
parent.insertBefore(dom.element('label', [
pair.create('for', 'yjs-live-tracking')
], [
dom.text('Live Tracking ')
]), null)
const btn = document.createElement('button')
btn.setAttribute('type', 'button')
btn.textContent = 'Versions'
btn.addEventListener('click', () => {
open = !open
unrenderVersion(editorview)
rerender()
})
const vContainer = document.createElement('div')
parent.insertBefore(btn, null)
parent.insertBefore(vContainer, null)
doc.getArray('versions').observe(rerender)
rerender()
}
const testUsers = [
{ username: 'Alice', color: '#ecd444', lightColor: '#ecd44433' },
{ username: 'Bob', color: '#ee6352', lightColor: '#ee635233' },
{ username: 'Max', color: '#6eeb83', lightColor: '#6eeb8333' }
]
const colors = [
{ light: '#ecd44433', dark: '#ecd444' },
{ light: '#ee635233', dark: '#ee6352' },
{ light: '#6eeb8333', dark: '#6eeb83' }
]
const user = random.oneOf(testUsers)
window.addEventListener('load', () => {
const ydoc = new Y.Doc()
const permanentUserData = new Y.PermanentUserData(ydoc)
permanentUserData.setUserMapping(ydoc, ydoc.clientID, user.username)
ydoc.gc = false
const provider = new WebsocketProvider('wss://demos.yjs.dev', 'prosemirror-versions-demo', ydoc)
const yXmlFragment = ydoc.get('prosemirror', Y.XmlFragment)
const editor = document.createElement('div')
editor.setAttribute('id', 'editor')
const editorContainer = document.createElement('div')
editorContainer.insertBefore(editor, null)
const prosemirrorView = new EditorView(editor, {
state: EditorState.create({
schema,
plugins: [
ySyncPlugin(yXmlFragment, { permanentUserData, colors }),
yCursorPlugin(provider.awareness),
yUndoPlugin(),
keymap({
'Mod-z': undo,
'Mod-y': redo,
'Mod-Shift-z': redo
})
].concat(exampleSetup({ schema }))
})
})
document.body.insertBefore(editorContainer, null)
attachVersion(document.getElementById('y-version'), ydoc, prosemirrorView)
const connectBtn = document.getElementById('y-connect-btn')
connectBtn.addEventListener('click', () => {
if (provider.shouldConnect) {
provider.disconnect()
connectBtn.textContent = 'Connect'
} else {
provider.connect()
connectBtn.textContent = 'Disconnect'
}
})
// @ts-ignore
window.example = { provider, ydoc, yXmlFragment, prosemirrorView }
})
| {
"repo_name": "yjs/yjs-demos",
"stars": "521",
"repo_language": "JavaScript",
"file_name": "README.md",
"mime_type": "text/plain"
} |
import { Schema } from 'prosemirror-model'
const brDOM = ['br']
const calcYChangeStyle = ychange => {
switch (ychange.type) {
case 'removed':
return `color:${ychange.color.dark}`
case 'added':
return `background-color:${ychange.color.light}`
case null:
return ''
}
}
const calcYchangeDomAttrs = (attrs, domAttrs = {}) => {
domAttrs = Object.assign({}, domAttrs)
if (attrs.ychange !== null) {
domAttrs.ychange_user = attrs.ychange.user
domAttrs.ychange_type = attrs.ychange.type
domAttrs.ychange_color = attrs.ychange.color.light
domAttrs.style = calcYChangeStyle(attrs.ychange)
}
return domAttrs
}
/**
* @param {any} ychange
* @param {Array<any>}
*/
const hoverWrapper = (ychange, els) =>
ychange === null ? els : [['span', { class: 'ychange-hover', style: `background-color:${ychange.color.dark}` }, ychange.user || 'Unknown'], ['span', ...els]]
// :: Object
// [Specs](#model.NodeSpec) for the nodes defined in this schema.
export const nodes = {
// :: NodeSpec The top level document node.
doc: {
content: 'block+'
},
// :: NodeSpec A plain paragraph textblock. Represented in the DOM
// as a `<p>` element.
paragraph: {
attrs: { ychange: { default: null } },
content: 'inline*',
group: 'block',
parseDOM: [{ tag: 'p' }],
toDOM (node) {
// only render changes if no child nodes
const renderChanges = node.content.size === 0
const attrs = renderChanges ? calcYchangeDomAttrs(node.attrs) : node.attrs
const defChildren = [0]
const children = renderChanges ? hoverWrapper(node.attrs.ychange, defChildren) : defChildren
return ['p', attrs, ...children]
}
},
// :: NodeSpec A blockquote (`<blockquote>`) wrapping one or more blocks.
blockquote: {
attrs: { ychange: { default: null } },
content: 'block+',
group: 'block',
defining: true,
parseDOM: [{ tag: 'blockquote' }],
toDOM (node) { return ['blockquote', calcYchangeDomAttrs(node.attrs), ...hoverWrapper(node.attrs.ychange, [0])] }
},
// :: NodeSpec A horizontal rule (`<hr>`).
horizontal_rule: {
attrs: { ychange: { default: null } },
group: 'block',
parseDOM: [{ tag: 'hr' }],
toDOM (node) {
return ['hr', calcYchangeDomAttrs(node.attrs), ...hoverWrapper(node.attrs.ychange, [])]
}
},
// :: NodeSpec A heading textblock, with a `level` attribute that
// should hold the number 1 to 6. Parsed and serialized as `<h1>` to
// `<h6>` elements.
heading: {
attrs: {
level: { default: 1 },
ychange: { default: null }
},
content: 'inline*',
group: 'block',
defining: true,
parseDOM: [{ tag: 'h1', attrs: { level: 1 } },
{ tag: 'h2', attrs: { level: 2 } },
{ tag: 'h3', attrs: { level: 3 } },
{ tag: 'h4', attrs: { level: 4 } },
{ tag: 'h5', attrs: { level: 5 } },
{ tag: 'h6', attrs: { level: 6 } }],
toDOM (node) { return ['h' + node.attrs.level, calcYchangeDomAttrs(node.attrs), ...hoverWrapper(node.attrs.ychange, [0])] }
},
// :: NodeSpec A code listing. Disallows marks or non-text inline
// nodes by default. Represented as a `<pre>` element with a
// `<code>` element inside of it.
code_block: {
attrs: { ychange: { default: null } },
content: 'text*',
marks: '',
group: 'block',
code: true,
defining: true,
parseDOM: [{ tag: 'pre', preserveWhitespace: 'full' }],
toDOM (node) { return ['pre', calcYchangeDomAttrs(node.attrs), ...hoverWrapper(node.attrs.ychange, [['code', 0]])] }
},
// :: NodeSpec The text node.
text: {
group: 'inline'
},
// :: NodeSpec An inline image (`<img>`) node. Supports `src`,
// `alt`, and `href` attributes. The latter two default to the empty
// string.
image: {
inline: true,
attrs: {
ychange: { default: null },
src: {},
alt: { default: null },
title: { default: null }
},
group: 'inline',
draggable: true,
parseDOM: [{
tag: 'img[src]',
getAttrs (dom) {
return {
src: dom.getAttribute('src'),
title: dom.getAttribute('title'),
alt: dom.getAttribute('alt')
}
}
}],
toDOM (node) {
const domAttrs = {
src: node.attrs.src,
title: node.attrs.title,
alt: node.attrs.alt
}
return ['img', calcYchangeDomAttrs(node.attrs, domAttrs), ...hoverWrapper(node.attrs.ychange, [])]
}
},
// :: NodeSpec A hard line break, represented in the DOM as `<br>`.
hard_break: {
inline: true,
group: 'inline',
selectable: false,
parseDOM: [{ tag: 'br' }],
toDOM () { return brDOM }
}
}
const emDOM = ['em', 0]; const strongDOM = ['strong', 0]; const codeDOM = ['code', 0]
// :: Object [Specs](#model.MarkSpec) for the marks in the schema.
export const marks = {
// :: MarkSpec A link. Has `href` and `title` attributes. `title`
// defaults to the empty string. Rendered and parsed as an `<a>`
// element.
link: {
attrs: {
href: {},
title: { default: null }
},
inclusive: false,
parseDOM: [{
tag: 'a[href]',
getAttrs (dom) {
return { href: dom.getAttribute('href'), title: dom.getAttribute('title') }
}
}],
toDOM (node) { return ['a', node.attrs, 0] }
},
// :: MarkSpec An emphasis mark. Rendered as an `<em>` element.
// Has parse rules that also match `<i>` and `font-style: italic`.
em: {
parseDOM: [{ tag: 'i' }, { tag: 'em' }, { style: 'font-style=italic' }],
toDOM () { return emDOM }
},
// :: MarkSpec A strong mark. Rendered as `<strong>`, parse rules
// also match `<b>` and `font-weight: bold`.
strong: {
parseDOM: [{ tag: 'strong' },
// This works around a Google Docs misbehavior where
// pasted content will be inexplicably wrapped in `<b>`
// tags with a font-weight normal.
{ tag: 'b', getAttrs: node => node.style.fontWeight !== 'normal' && null },
{ style: 'font-weight', getAttrs: value => /^(bold(er)?|[5-9]\d{2,})$/.test(value) && null }],
toDOM () { return strongDOM }
},
// :: MarkSpec Code font mark. Represented as a `<code>` element.
code: {
parseDOM: [{ tag: 'code' }],
toDOM () { return codeDOM }
},
ychange: {
attrs: {
user: { default: null },
type: { default: null },
color: { default: null }
},
inclusive: false,
parseDOM: [{ tag: 'ychange' }],
toDOM (node) {
return ['ychange', { ychange_user: node.attrs.user, ychange_type: node.attrs.type, style: calcYChangeStyle(node.attrs), ychange_color: node.attrs.color.light }, ...hoverWrapper(node.attrs, [0])]
}
}
}
// :: Schema
// This schema rougly corresponds to the document schema used by
// [CommonMark](http://commonmark.org/), minus the list elements,
// which are defined in the [`prosemirror-schema-list`](#schema-list)
// module.
//
// To reuse elements from this schema, extend or read from its
// `spec.nodes` and `spec.marks` [properties](#model.Schema.spec).
export const schema = new Schema({ nodes, marks })
| {
"repo_name": "yjs/yjs-demos",
"stars": "521",
"repo_language": "JavaScript",
"file_name": "README.md",
"mime_type": "text/plain"
} |
.ProseMirror {
position: relative;
}
.ProseMirror {
word-wrap: break-word;
white-space: pre-wrap;
-webkit-font-variant-ligatures: none;
font-variant-ligatures: none;
}
.ProseMirror pre {
white-space: pre-wrap;
}
.ProseMirror li {
position: relative;
}
.ProseMirror-hideselection *::selection { background: transparent; }
.ProseMirror-hideselection *::-moz-selection { background: transparent; }
.ProseMirror-hideselection { caret-color: transparent; }
.ProseMirror-selectednode {
outline: 2px solid #8cf;
}
/* Make sure li selections wrap around markers */
li.ProseMirror-selectednode {
outline: none;
}
li.ProseMirror-selectednode:after {
content: "";
position: absolute;
left: -32px;
right: -2px; top: -2px; bottom: -2px;
border: 2px solid #8cf;
pointer-events: none;
}
.ProseMirror-textblock-dropdown {
min-width: 3em;
}
.ProseMirror-menu {
margin: 0 -4px;
line-height: 1;
}
.ProseMirror-tooltip .ProseMirror-menu {
width: -webkit-fit-content;
width: fit-content;
white-space: pre;
}
.ProseMirror-menuitem {
margin-right: 3px;
display: inline-block;
}
.ProseMirror-menuseparator {
border-right: 1px solid #ddd;
margin-right: 3px;
}
.ProseMirror-menu-dropdown, .ProseMirror-menu-dropdown-menu {
font-size: 90%;
white-space: nowrap;
}
.ProseMirror-menu-dropdown {
vertical-align: 1px;
cursor: pointer;
position: relative;
padding-right: 15px;
}
.ProseMirror-menu-dropdown-wrap {
padding: 1px 0 1px 4px;
display: inline-block;
position: relative;
}
.ProseMirror-menu-dropdown:after {
content: "";
border-left: 4px solid transparent;
border-right: 4px solid transparent;
border-top: 4px solid currentColor;
opacity: .6;
position: absolute;
right: 4px;
top: calc(50% - 2px);
}
.ProseMirror-menu-dropdown-menu, .ProseMirror-menu-submenu {
position: absolute;
background: white;
color: #666;
border: 1px solid #aaa;
padding: 2px;
}
.ProseMirror-menu-dropdown-menu {
z-index: 15;
min-width: 6em;
}
.ProseMirror-menu-dropdown-item {
cursor: pointer;
padding: 2px 8px 2px 4px;
}
.ProseMirror-menu-dropdown-item:hover {
background: #f2f2f2;
}
.ProseMirror-menu-submenu-wrap {
position: relative;
margin-right: -4px;
}
.ProseMirror-menu-submenu-label:after {
content: "";
border-top: 4px solid transparent;
border-bottom: 4px solid transparent;
border-left: 4px solid currentColor;
opacity: .6;
position: absolute;
right: 4px;
top: calc(50% - 4px);
}
.ProseMirror-menu-submenu {
display: none;
min-width: 4em;
left: 100%;
top: -3px;
}
.ProseMirror-menu-active {
background: #eee;
border-radius: 4px;
}
.ProseMirror-menu-active {
background: #eee;
border-radius: 4px;
}
.ProseMirror-menu-disabled {
opacity: .3;
}
.ProseMirror-menu-submenu-wrap:hover .ProseMirror-menu-submenu, .ProseMirror-menu-submenu-wrap-active .ProseMirror-menu-submenu {
display: block;
}
.ProseMirror-menubar {
border-top-left-radius: inherit;
border-top-right-radius: inherit;
position: relative;
min-height: 1em;
color: #666;
padding: 1px 6px;
top: 0; left: 0; right: 0;
border-bottom: 1px solid silver;
background: white;
z-index: 10;
-moz-box-sizing: border-box;
box-sizing: border-box;
overflow: visible;
}
.ProseMirror-icon {
display: inline-block;
line-height: .8;
vertical-align: -2px; /* Compensate for padding */
padding: 2px 8px;
cursor: pointer;
}
.ProseMirror-menu-disabled.ProseMirror-icon {
cursor: default;
}
.ProseMirror-icon svg {
fill: currentColor;
height: 1em;
}
.ProseMirror-icon span {
vertical-align: text-top;
}
.ProseMirror-gapcursor {
display: none;
pointer-events: none;
position: absolute;
}
.ProseMirror-gapcursor:after {
content: "";
display: block;
position: absolute;
top: -2px;
width: 20px;
border-top: 1px solid black;
animation: ProseMirror-cursor-blink 1.1s steps(2, start) infinite;
}
@keyframes ProseMirror-cursor-blink {
to {
visibility: hidden;
}
}
.ProseMirror-focused .ProseMirror-gapcursor {
display: block;
}
/* Add space around the hr to make clicking it easier */
.ProseMirror-example-setup-style hr {
padding: 2px 10px;
border: none;
margin: 1em 0;
}
.ProseMirror-example-setup-style hr:after {
content: "";
display: block;
height: 1px;
background-color: silver;
line-height: 2px;
}
.ProseMirror ul, .ProseMirror ol {
padding-left: 30px;
}
.ProseMirror blockquote {
padding-left: 1em;
border-left: 3px solid #eee;
margin-left: 0; margin-right: 0;
}
.ProseMirror-example-setup-style img {
cursor: default;
}
.ProseMirror-prompt {
background: white;
padding: 5px 10px 5px 15px;
border: 1px solid silver;
position: fixed;
border-radius: 3px;
z-index: 11;
box-shadow: -.5px 2px 5px rgba(0, 0, 0, .2);
}
.ProseMirror-prompt h5 {
margin: 0;
font-weight: normal;
font-size: 100%;
color: #444;
}
.ProseMirror-prompt input[type="text"],
.ProseMirror-prompt textarea {
background: #eee;
border: none;
outline: none;
}
.ProseMirror-prompt input[type="text"] {
padding: 0 4px;
}
.ProseMirror-prompt-close {
position: absolute;
left: 2px; top: 1px;
color: #666;
border: none; background: transparent; padding: 0;
}
.ProseMirror-prompt-close:after {
content: "✕";
font-size: 12px;
}
.ProseMirror-invalid {
background: #ffc;
border: 1px solid #cc7;
border-radius: 4px;
padding: 5px 10px;
position: absolute;
min-width: 10em;
}
.ProseMirror-prompt-buttons {
margin-top: 5px;
display: none;
}
#editor, .editor {
background: white;
color: black;
background-clip: padding-box;
border-radius: 4px;
border: 2px solid rgba(0, 0, 0, 0.2);
padding: 5px 0;
margin-bottom: 23px;
}
.ProseMirror p:first-child,
.ProseMirror h1:first-child,
.ProseMirror h2:first-child,
.ProseMirror h3:first-child,
.ProseMirror h4:first-child,
.ProseMirror h5:first-child,
.ProseMirror h6:first-child {
margin-top: 10px;
}
.ProseMirror {
padding: 4px 8px 4px 14px;
line-height: 1.2;
outline: none;
}
.ProseMirror p { margin-bottom: 1em }
| {
"repo_name": "yjs/yjs-demos",
"stars": "521",
"repo_language": "JavaScript",
"file_name": "README.md",
"mime_type": "text/plain"
} |
#y-version {
position: relative;
}
.version-modal[hidden] {
display: none;
}
.version-modal:not([hidden]) {
position: absolute;
top: 30px;
right: 0;
width: 300px;
min-height: 300px;
height: fit-content;
z-index: 20;
background-color: white;
border: 1px solid #ccc;
border-radius: 11px;
border-top-right-radius: 0;
box-shadow: 0 3px 7px rgba(0, 0, 0, 0.3);
}
.version-modal > button {
position: absolute;
right: 0;
top: 0;
}
.version-list {
line-height: 30px;
padding: 0 8px;
cursor: pointer;
}
.version-list:hover {
background-color: #eee;
}
[ychange_type] {
position: relative;
}
.ychange-hover {
display: none;
}
*:hover > .ychange-hover {
display: inline;
position: absolute;
top: -14px;
left: 0;
font-size: 12px;
padding: 0 2px;
border-radius: 3px 3px 0 0;
color: #fdfdfe;
user-select: none;
word-break: normal;
}
ychange[ychange_type='removed'], p[ychange_type='removed'] {
text-decoration: line-through;
}
/*
p[ychange_type='removed'] > span > br {
display: none;
}
*/
*:not(ychange)[ychange_type='removed'] {
background-color: #ff5a56;
color: inherit !important;
}
img[ychange_type='removed'] {
padding: 2px;
}
| {
"repo_name": "yjs/yjs-demos",
"stars": "521",
"repo_language": "JavaScript",
"file_name": "README.md",
"mime_type": "text/plain"
} |
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8"/>
<title>Yjs Prosemirror Versions Example</title>
<script type="text/javascript" src="./dist/prosemirror-versions.bundle.js" async></script>
<link rel=stylesheet href="./prosemirror.css" async defer>
<link rel=stylesheet href="./version.css" async defer>
<style>
placeholder {
display: inline;
border: 1px solid #ccc;
color: #ccc;
}
placeholder:after {
content: "☁";
font-size: 200%;
line-height: 0.1;
font-weight: bold;
}
.ProseMirror img { max-width: 100px }
/* this is a rough fix for the first cursor position when the first paragraph is empty */
.ProseMirror > .ProseMirror-yjs-cursor:first-child {
margin-top: 16px;
}
.ProseMirror p:first-child, .ProseMirror h1:first-child, .ProseMirror h2:first-child, .ProseMirror h3:first-child, .ProseMirror h4:first-child, .ProseMirror h5:first-child, .ProseMirror h6:first-child {
margin-top: 16px
}
.ProseMirror-yjs-cursor {
position: absolute;
border-left: black;
border-left-style: solid;
border-left-width: 2px;
border-color: orange;
height: 1em;
word-break: normal;
pointer-events: none;
}
.ProseMirror-yjs-cursor > div {
position: relative;
top: -1.05em;
font-size: 13px;
background-color: rgb(250, 129, 0);
font-family: serif;
font-style: normal;
font-weight: normal;
line-height: normal;
user-select: none;
color: white;
padding-left: 2px;
padding-right: 2px;
}
#y-functions {
position: absolute;
top: 20px;
right: 20px;
}
#y-functions > * {
display: inline-block;
}
</style>
</head>
<body>
<div id="y-functions">
<div id="y-version"></div>
<button type="button" id="y-connect-btn">Disconnect</button>
</div>
<p></p>
<p>This is a demo of the <a href="https://github.com/yjs/yjs">Yjs</a> ⇔ <a href="http://prosemirror.net/">ProseMirror</a> binding: <a href="https://github.com/yjs/y-prosemirror">y-prosemirror</a>.</p>
<p>The content of this editor is shared with every client that visits this domain.</p>
</body>
</html>
| {
"repo_name": "yjs/yjs-demos",
"stars": "521",
"repo_language": "JavaScript",
"file_name": "README.md",
"mime_type": "text/plain"
} |
const path = require('path')
module.exports = {
mode: 'development',
devtool: 'source-map',
entry: {
'prosemirror-versions': './prosemirror-versions.js'
},
output: {
globalObject: 'self',
path: path.resolve(__dirname, './dist/'),
filename: '[name].bundle.js',
publicPath: '/prosemirror-versions/dist/'
},
devServer: {
contentBase: path.join(__dirname),
compress: true,
publicPath: '/dist/'
}
}
| {
"repo_name": "yjs/yjs-demos",
"stars": "521",
"repo_language": "JavaScript",
"file_name": "README.md",
"mime_type": "text/plain"
} |
# ProseMirror + Versions Demo
> [y-prosemirror](https://docs.yjs.dev/ecosystem/editor-bindings/prosemirror) / [y-websocket](https://docs.yjs.dev/ecosystem/connection-provider/y-websocket) / [Live Demo](https://demos.yjs.dev/prosemirror-versions/prosemirror-versions.html)
This is a demo of a [ProseMirror](https://prosemirror.net/) editor that was made collaborative with Yjs & y-prosemirror. This demo uses the [prosemirror-example-setup](https://github.com/ProseMirror/prosemirror-example-setup) as a configuration. Learn more about how you can build your own custom editor with ProseMirror in [their documentation](https://github.com/yjs/y-prosemirror/).
In this variation of the ProseMirror demo, we allow you to create versions and render the differences and highlight the changes by a unique user-color. When you enable "Live Tracking", your editor becomes unresponsive and you can see diff created from edits from other users happening in real-time. Click on a created snapshot to render the differences to the previous snapshot.
The snapshot API is very versatile and allows you to render the differences between any two snapshots. In this examples, we simply created a linear version history. But using the same API you can model branching & merging as well.
## Quick Start
```sh
npm i
npm start
# Project is running at http://localhost:8080/
```
| {
"repo_name": "yjs/yjs-demos",
"stars": "521",
"repo_language": "JavaScript",
"file_name": "README.md",
"mime_type": "text/plain"
} |
/* eslint-env browser */
import * as Y from 'yjs'
import { DatProvider } from 'y-dat'
import { ySyncPlugin, yCursorPlugin, yUndoPlugin, undo, redo } from 'y-prosemirror'
import { EditorState } from 'prosemirror-state'
import { EditorView } from 'prosemirror-view'
import { schema } from './schema.js'
import { exampleSetup } from 'prosemirror-example-setup'
import { keymap } from 'prosemirror-keymap'
window.addEventListener('load', () => {
const ydoc = new Y.Doc()
// Create new Archive if no key is specified.
// • In the browser, specify the parameter in the url as the location.hash: "localhost:8080#7b0d584fcdaf1de2e8c473393a31f52327793931e03b330f7393025146dc02fb"
const givenDatKey = location.hash.length > 1 ? location.hash.slice(1) : null
// @ts-ignore
const provider = new DatProvider(givenDatKey, ydoc)
const skey = provider.feed.key.toString('hex')
console.log(`Collaborating on ${skey} ${givenDatKey === null ? '(generated)' : '(from parameter)'}`)
location.hash = '#' + skey
const yXmlFragment = ydoc.getXmlFragment('prosemirror')
const editor = document.createElement('div')
editor.setAttribute('id', 'editor')
const editorContainer = document.createElement('div')
editorContainer.insertBefore(editor, null)
const prosemirrorView = new EditorView(editor, {
state: EditorState.create({
schema,
plugins: [
ySyncPlugin(yXmlFragment),
yCursorPlugin(provider.awareness),
yUndoPlugin(),
keymap({
'Mod-z': undo,
'Mod-y': redo,
'Mod-Shift-z': redo
})
].concat(exampleSetup({ schema }))
})
})
document.body.insertBefore(editorContainer, null)
// @ts-ignore
window.example = { provider, ydoc, yXmlFragment, prosemirrorView }
})
| {
"repo_name": "yjs/yjs-demos",
"stars": "521",
"repo_language": "JavaScript",
"file_name": "README.md",
"mime_type": "text/plain"
} |
import { Schema } from 'prosemirror-model'
const brDOM = ['br']
const calcYchangeDomAttrs = (attrs, domAttrs = {}) => {
domAttrs = Object.assign({}, domAttrs)
if (attrs.ychange !== null) {
domAttrs.ychange_user = attrs.ychange.user
domAttrs.ychange_state = attrs.ychange.state
}
return domAttrs
}
// :: Object
// [Specs](#model.NodeSpec) for the nodes defined in this schema.
export const nodes = {
// :: NodeSpec The top level document node.
doc: {
content: 'block+'
},
// :: NodeSpec A plain paragraph textblock. Represented in the DOM
// as a `<p>` element.
paragraph: {
attrs: { ychange: { default: null } },
content: 'inline*',
group: 'block',
parseDOM: [{ tag: 'p' }],
toDOM (node) { return ['p', calcYchangeDomAttrs(node.attrs), 0] }
},
// :: NodeSpec A blockquote (`<blockquote>`) wrapping one or more blocks.
blockquote: {
attrs: { ychange: { default: null } },
content: 'block+',
group: 'block',
defining: true,
parseDOM: [{ tag: 'blockquote' }],
toDOM (node) { return ['blockquote', calcYchangeDomAttrs(node.attrs), 0] }
},
// :: NodeSpec A horizontal rule (`<hr>`).
horizontal_rule: {
attrs: { ychange: { default: null } },
group: 'block',
parseDOM: [{ tag: 'hr' }],
toDOM (node) {
return ['hr', calcYchangeDomAttrs(node.attrs)]
}
},
// :: NodeSpec A heading textblock, with a `level` attribute that
// should hold the number 1 to 6. Parsed and serialized as `<h1>` to
// `<h6>` elements.
heading: {
attrs: {
level: { default: 1 },
ychange: { default: null }
},
content: 'inline*',
group: 'block',
defining: true,
parseDOM: [{ tag: 'h1', attrs: { level: 1 } },
{ tag: 'h2', attrs: { level: 2 } },
{ tag: 'h3', attrs: { level: 3 } },
{ tag: 'h4', attrs: { level: 4 } },
{ tag: 'h5', attrs: { level: 5 } },
{ tag: 'h6', attrs: { level: 6 } }],
toDOM (node) { return ['h' + node.attrs.level, calcYchangeDomAttrs(node.attrs), 0] }
},
// :: NodeSpec A code listing. Disallows marks or non-text inline
// nodes by default. Represented as a `<pre>` element with a
// `<code>` element inside of it.
code_block: {
attrs: { ychange: { default: null } },
content: 'text*',
marks: '',
group: 'block',
code: true,
defining: true,
parseDOM: [{ tag: 'pre', preserveWhitespace: 'full' }],
toDOM (node) { return ['pre', calcYchangeDomAttrs(node.attrs), ['code', 0]] }
},
// :: NodeSpec The text node.
text: {
group: 'inline'
},
// :: NodeSpec An inline image (`<img>`) node. Supports `src`,
// `alt`, and `href` attributes. The latter two default to the empty
// string.
image: {
inline: true,
attrs: {
ychange: { default: null },
src: {},
alt: { default: null },
title: { default: null }
},
group: 'inline',
draggable: true,
parseDOM: [{
tag: 'img[src]',
getAttrs (dom) {
return {
src: dom.getAttribute('src'),
title: dom.getAttribute('title'),
alt: dom.getAttribute('alt')
}
}
}],
toDOM (node) {
const domAttrs = {
src: node.attrs.src,
title: node.attrs.title,
alt: node.attrs.alt
}
return ['img', calcYchangeDomAttrs(node.attrs, domAttrs)]
}
},
// :: NodeSpec A hard line break, represented in the DOM as `<br>`.
hard_break: {
inline: true,
group: 'inline',
selectable: false,
parseDOM: [{ tag: 'br' }],
toDOM () { return brDOM }
}
}
const emDOM = ['em', 0]; const strongDOM = ['strong', 0]; const codeDOM = ['code', 0]
// :: Object [Specs](#model.MarkSpec) for the marks in the schema.
export const marks = {
// :: MarkSpec A link. Has `href` and `title` attributes. `title`
// defaults to the empty string. Rendered and parsed as an `<a>`
// element.
link: {
attrs: {
href: {},
title: { default: null }
},
inclusive: false,
parseDOM: [{
tag: 'a[href]',
getAttrs (dom) {
return { href: dom.getAttribute('href'), title: dom.getAttribute('title') }
}
}],
toDOM (node) { return ['a', node.attrs, 0] }
},
// :: MarkSpec An emphasis mark. Rendered as an `<em>` element.
// Has parse rules that also match `<i>` and `font-style: italic`.
em: {
parseDOM: [{ tag: 'i' }, { tag: 'em' }, { style: 'font-style=italic' }],
toDOM () { return emDOM }
},
// :: MarkSpec A strong mark. Rendered as `<strong>`, parse rules
// also match `<b>` and `font-weight: bold`.
strong: {
parseDOM: [{ tag: 'strong' },
// This works around a Google Docs misbehavior where
// pasted content will be inexplicably wrapped in `<b>`
// tags with a font-weight normal.
{ tag: 'b', getAttrs: node => node.style.fontWeight !== 'normal' && null },
{ style: 'font-weight', getAttrs: value => /^(bold(er)?|[5-9]\d{2,})$/.test(value) && null }],
toDOM () { return strongDOM }
},
// :: MarkSpec Code font mark. Represented as a `<code>` element.
code: {
parseDOM: [{ tag: 'code' }],
toDOM () { return codeDOM }
},
ychange: {
attrs: {
user: { default: null },
state: { default: null }
},
inclusive: false,
parseDOM: [{ tag: 'ychange' }],
toDOM (node) {
return ['ychange', { ychange_user: node.attrs.user, ychange_state: node.attrs.state }, 0]
}
}
}
// :: Schema
// This schema rougly corresponds to the document schema used by
// [CommonMark](http://commonmark.org/), minus the list elements,
// which are defined in the [`prosemirror-schema-list`](#schema-list)
// module.
//
// To reuse elements from this schema, extend or read from its
// `spec.nodes` and `spec.marks` [properties](#model.Schema.spec).
export const schema = new Schema({ nodes, marks })
| {
"repo_name": "yjs/yjs-demos",
"stars": "521",
"repo_language": "JavaScript",
"file_name": "README.md",
"mime_type": "text/plain"
} |
.ProseMirror {
position: relative;
}
.ProseMirror {
word-wrap: break-word;
white-space: pre-wrap;
-webkit-font-variant-ligatures: none;
font-variant-ligatures: none;
}
.ProseMirror pre {
white-space: pre-wrap;
}
.ProseMirror li {
position: relative;
}
.ProseMirror-hideselection *::selection { background: transparent; }
.ProseMirror-hideselection *::-moz-selection { background: transparent; }
.ProseMirror-hideselection { caret-color: transparent; }
.ProseMirror-selectednode {
outline: 2px solid #8cf;
}
/* Make sure li selections wrap around markers */
li.ProseMirror-selectednode {
outline: none;
}
li.ProseMirror-selectednode:after {
content: "";
position: absolute;
left: -32px;
right: -2px; top: -2px; bottom: -2px;
border: 2px solid #8cf;
pointer-events: none;
}
.ProseMirror-textblock-dropdown {
min-width: 3em;
}
.ProseMirror-menu {
margin: 0 -4px;
line-height: 1;
}
.ProseMirror-tooltip .ProseMirror-menu {
width: -webkit-fit-content;
width: fit-content;
white-space: pre;
}
.ProseMirror-menuitem {
margin-right: 3px;
display: inline-block;
}
.ProseMirror-menuseparator {
border-right: 1px solid #ddd;
margin-right: 3px;
}
.ProseMirror-menu-dropdown, .ProseMirror-menu-dropdown-menu {
font-size: 90%;
white-space: nowrap;
}
.ProseMirror-menu-dropdown {
vertical-align: 1px;
cursor: pointer;
position: relative;
padding-right: 15px;
}
.ProseMirror-menu-dropdown-wrap {
padding: 1px 0 1px 4px;
display: inline-block;
position: relative;
}
.ProseMirror-menu-dropdown:after {
content: "";
border-left: 4px solid transparent;
border-right: 4px solid transparent;
border-top: 4px solid currentColor;
opacity: .6;
position: absolute;
right: 4px;
top: calc(50% - 2px);
}
.ProseMirror-menu-dropdown-menu, .ProseMirror-menu-submenu {
position: absolute;
background: white;
color: #666;
border: 1px solid #aaa;
padding: 2px;
}
.ProseMirror-menu-dropdown-menu {
z-index: 15;
min-width: 6em;
}
.ProseMirror-menu-dropdown-item {
cursor: pointer;
padding: 2px 8px 2px 4px;
}
.ProseMirror-menu-dropdown-item:hover {
background: #f2f2f2;
}
.ProseMirror-menu-submenu-wrap {
position: relative;
margin-right: -4px;
}
.ProseMirror-menu-submenu-label:after {
content: "";
border-top: 4px solid transparent;
border-bottom: 4px solid transparent;
border-left: 4px solid currentColor;
opacity: .6;
position: absolute;
right: 4px;
top: calc(50% - 4px);
}
.ProseMirror-menu-submenu {
display: none;
min-width: 4em;
left: 100%;
top: -3px;
}
.ProseMirror-menu-active {
background: #eee;
border-radius: 4px;
}
.ProseMirror-menu-active {
background: #eee;
border-radius: 4px;
}
.ProseMirror-menu-disabled {
opacity: .3;
}
.ProseMirror-menu-submenu-wrap:hover .ProseMirror-menu-submenu, .ProseMirror-menu-submenu-wrap-active .ProseMirror-menu-submenu {
display: block;
}
.ProseMirror-menubar {
border-top-left-radius: inherit;
border-top-right-radius: inherit;
position: relative;
min-height: 1em;
color: #666;
padding: 1px 6px;
top: 0; left: 0; right: 0;
border-bottom: 1px solid silver;
background: white;
z-index: 10;
-moz-box-sizing: border-box;
box-sizing: border-box;
overflow: visible;
}
.ProseMirror-icon {
display: inline-block;
line-height: .8;
vertical-align: -2px; /* Compensate for padding */
padding: 2px 8px;
cursor: pointer;
}
.ProseMirror-menu-disabled.ProseMirror-icon {
cursor: default;
}
.ProseMirror-icon svg {
fill: currentColor;
height: 1em;
}
.ProseMirror-icon span {
vertical-align: text-top;
}
.ProseMirror-gapcursor {
display: none;
pointer-events: none;
position: absolute;
}
.ProseMirror-gapcursor:after {
content: "";
display: block;
position: absolute;
top: -2px;
width: 20px;
border-top: 1px solid black;
animation: ProseMirror-cursor-blink 1.1s steps(2, start) infinite;
}
@keyframes ProseMirror-cursor-blink {
to {
visibility: hidden;
}
}
.ProseMirror-focused .ProseMirror-gapcursor {
display: block;
}
/* Add space around the hr to make clicking it easier */
.ProseMirror-example-setup-style hr {
padding: 2px 10px;
border: none;
margin: 1em 0;
}
.ProseMirror-example-setup-style hr:after {
content: "";
display: block;
height: 1px;
background-color: silver;
line-height: 2px;
}
.ProseMirror ul, .ProseMirror ol {
padding-left: 30px;
}
.ProseMirror blockquote {
padding-left: 1em;
border-left: 3px solid #eee;
margin-left: 0; margin-right: 0;
}
.ProseMirror-example-setup-style img {
cursor: default;
}
.ProseMirror-prompt {
background: white;
padding: 5px 10px 5px 15px;
border: 1px solid silver;
position: fixed;
border-radius: 3px;
z-index: 11;
box-shadow: -.5px 2px 5px rgba(0, 0, 0, .2);
}
.ProseMirror-prompt h5 {
margin: 0;
font-weight: normal;
font-size: 100%;
color: #444;
}
.ProseMirror-prompt input[type="text"],
.ProseMirror-prompt textarea {
background: #eee;
border: none;
outline: none;
}
.ProseMirror-prompt input[type="text"] {
padding: 0 4px;
}
.ProseMirror-prompt-close {
position: absolute;
left: 2px; top: 1px;
color: #666;
border: none; background: transparent; padding: 0;
}
.ProseMirror-prompt-close:after {
content: "✕";
font-size: 12px;
}
.ProseMirror-invalid {
background: #ffc;
border: 1px solid #cc7;
border-radius: 4px;
padding: 5px 10px;
position: absolute;
min-width: 10em;
}
.ProseMirror-prompt-buttons {
margin-top: 5px;
display: none;
}
#editor, .editor {
background: white;
color: black;
background-clip: padding-box;
border-radius: 4px;
border: 2px solid rgba(0, 0, 0, 0.2);
padding: 5px 0;
margin-bottom: 23px;
}
.ProseMirror p:first-child,
.ProseMirror h1:first-child,
.ProseMirror h2:first-child,
.ProseMirror h3:first-child,
.ProseMirror h4:first-child,
.ProseMirror h5:first-child,
.ProseMirror h6:first-child {
margin-top: 10px;
}
.ProseMirror {
padding: 4px 8px 4px 14px;
line-height: 1.2;
outline: none;
}
.ProseMirror p { margin-bottom: 1em }
| {
"repo_name": "yjs/yjs-demos",
"stars": "521",
"repo_language": "JavaScript",
"file_name": "README.md",
"mime_type": "text/plain"
} |
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8"/>
<title>Yjs Prosemirror Dat Example</title>
<script type="text/javascript" src="./dist/prosemirror.bundle.js" async></script>
<link rel=stylesheet href="./prosemirror.css" async defer>
<style>
placeholder {
display: inline;
border: 1px solid #ccc;
color: #ccc;
}
placeholder:after {
content: "☁";
font-size: 200%;
line-height: 0.1;
font-weight: bold;
}
.ProseMirror img { max-width: 100px }
/* this is a rough fix for the first cursor position when the first paragraph is empty */
.ProseMirror > .ProseMirror-yjs-cursor:first-child {
margin-top: 16px;
}
.ProseMirror p:first-child, .ProseMirror h1:first-child, .ProseMirror h2:first-child, .ProseMirror h3:first-child, .ProseMirror h4:first-child, .ProseMirror h5:first-child, .ProseMirror h6:first-child {
margin-top: 16px
}
/* This gives the remote user caret. The colors are automatically overwritten*/
.ProseMirror-yjs-cursor {
position: relative;
margin-left: -1px;
margin-right: -1px;
border-left: 1px solid black;
border-right: 1px solid black;
border-color: orange;
word-break: normal;
pointer-events: none;
}
/* This renders the username above the caret */
.ProseMirror-yjs-cursor > div {
position: absolute;
top: -1.05em;
left: -1px;
font-size: 13px;
background-color: rgb(250, 129, 0);
font-family: serif;
font-style: normal;
font-weight: normal;
line-height: normal;
user-select: none;
color: white;
padding-left: 2px;
padding-right: 2px;
white-space: nowrap;
}
#y-functions {
position: absolute;
top: 20px;
right: 20px;
}
#y-functions > * {
display: inline-block;
}
</style>
</head>
<body>
<div id="y-functions">
<div id="y-version"></div>
</div>
<p></p>
<p>This is a demo of the <a href="https://github.com/yjs/yjs">Yjs</a> ⇔ <a href="http://prosemirror.net/">ProseMirror</a> binding: <a href="https://github.com/yjs/y-prosemirror">y-prosemirror</a>.</p>
<p>The content of this editor is shared with every client that visits this domain.</p>
</body>
</html>
| {
"repo_name": "yjs/yjs-demos",
"stars": "521",
"repo_language": "JavaScript",
"file_name": "README.md",
"mime_type": "text/plain"
} |
const path = require('path')
module.exports = {
mode: 'development',
devtool: 'source-map',
entry: {
prosemirror: './prosemirror.js'
},
output: {
globalObject: 'self',
path: path.resolve(__dirname, './dist/'),
filename: '[name].bundle.js',
publicPath: '/prosemirror/dist/'
},
devServer: {
contentBase: path.join(__dirname),
compress: true,
publicPath: '/dist/'
},
resolve: {
alias: {
fs: 'graceful-fs'
}
}
}
| {
"repo_name": "yjs/yjs-demos",
"stars": "521",
"repo_language": "JavaScript",
"file_name": "README.md",
"mime_type": "text/plain"
} |
# ProseMirror + Dat Demo
> [y-prosemirror](https://docs.yjs.dev/ecosystem/editor-bindings/prosemirror) / [y-dat](https://docs.yjs.dev/ecosystem/connection-provider/y-hyper) / [Live Demo](https://demos.yjs.dev/prosemirror/prosemirror.html)
This is a demo of a [ProseMirror](https://prosemirror.net/) editor that was made collaborative with Yjs & y-prosemirror. This demo uses the [prosemirror-example-setup](https://github.com/ProseMirror/prosemirror-example-setup) as a configuration. Learn more about how you can build your own custom editor with ProseMirror in [their documentation](https://github.com/yjs/y-prosemirror/).
In this variation of the ProseMirror demo, we use [y-dat](https://docs.yjs.dev/ecosystem/connection-provider/y-hyper) as a synchronization protocol (aka the provider). [Hyper](https://hypercore-protocol.org/) (previously known as [Dat](https://dat.foundation/)) is a distributed append-only log that allows you to build encrypted peer-to-peer applications without a central server.
This demo already supports offline editing since y-dat persists document updates in the local browser.
## Quick Start
```sh
npm i
npm start
# Project is running at http://localhost:8080/
```
| {
"repo_name": "yjs/yjs-demos",
"stars": "521",
"repo_language": "JavaScript",
"file_name": "README.md",
"mime_type": "text/plain"
} |
# Hexo Configuration
## Docs: https://hexo.io/docs/configuration.html
## Source: https://github.com/hexojs/hexo/
# Site
title: Webpack Performance
subtitle: 专注于 Webpack 相关工具、性能和优化的博客
description: Webpack, React, Performance, APM, ESLint
author: wyvernnot
language: zh
timezone: Asia/Shanghai
# URL
## If your site is put in a subdirectory, set url as 'http://yoursite.com/child' and root as '/child/'
url: http://webpack-performance.com
root: /
permalink: :year/:month/:day/:title/
permalink_defaults:
# Directory
source_dir: source
public_dir: docs
tag_dir: tags
archive_dir: archives
category_dir: categories
code_dir: downloads/code
i18n_dir: :lang
skip_render:
# Writing
new_post_name: :year-:month-:day-:title.md # File name of new posts
default_layout: post
titlecase: false # Transform title into titlecase
external_link: true # Open external links in new tab
filename_case: 0
render_drafts: false
post_asset_folder: true
relative_link: false
future: true
highlight:
enable: true
line_number: true
auto_detect: false
tab_replace:
# Category & Tag
default_category: uncategorized
category_map:
tag_map:
# Date / Time format
## Hexo uses Moment.js to parse and display date
## You can customize the date format as defined in
## http://momentjs.com/docs/#/displaying/format/
date_format: YYYY-MM-DD
time_format: HH:mm:ss
# Pagination
## Set per_page to 0 to disable pagination
per_page: 10
pagination_dir: page
# Extensions
## Plugins: https://hexo.io/plugins/
## Themes: https://hexo.io/themes/
theme: landscape
# Deployment
## Docs: https://hexo.io/docs/deployment.html
deploy:
type: git
repo: [email protected]:wyvernnot/webpack_performance.git
branch: gh-pages
| {
"repo_name": "longtian/webpack_performance",
"stars": "79",
"repo_language": "JavaScript",
"file_name": "2016-08-29-jenkins.md",
"mime_type": "text/plain"
} |
# Webpack Performance
> 专注于 Webpack 相关工具、性能和优化的博客
http://webpack-performance.com/
[示例代码](./examples)
| {
"repo_name": "longtian/webpack_performance",
"stars": "79",
"repo_language": "JavaScript",
"file_name": "2016-08-29-jenkins.md",
"mime_type": "text/plain"
} |
module.exports = function(grunt){
grunt.initConfig({
gitclone: {
fontawesome: {
options: {
repository: 'https://github.com/FortAwesome/Font-Awesome.git',
directory: 'tmp/fontawesome'
},
},
fancybox: {
options: {
repository: 'https://github.com/fancyapps/fancyBox.git',
directory: 'tmp/fancybox'
}
}
},
copy: {
fontawesome: {
expand: true,
cwd: 'tmp/fontawesome/fonts/',
src: ['**'],
dest: 'source/css/fonts/'
},
fancybox: {
expand: true,
cwd: 'tmp/fancybox/source/',
src: ['**'],
dest: 'source/fancybox/'
}
},
_clean: {
tmp: ['tmp'],
fontawesome: ['source/css/fonts'],
fancybox: ['source/fancybox']
}
});
require('load-grunt-tasks')(grunt);
grunt.renameTask('clean', '_clean');
grunt.registerTask('fontawesome', ['gitclone:fontawesome', 'copy:fontawesome', '_clean:tmp']);
grunt.registerTask('fancybox', ['gitclone:fancybox', 'copy:fancybox', '_clean:tmp']);
grunt.registerTask('default', ['gitclone', 'copy', '_clean:tmp']);
grunt.registerTask('clean', ['_clean']);
}; | {
"repo_name": "longtian/webpack_performance",
"stars": "79",
"repo_language": "JavaScript",
"file_name": "2016-08-29-jenkins.md",
"mime_type": "text/plain"
} |
# Header
menu:
Home: /
Archives: /archives
rss: /atom.xml
# Content
excerpt_link: Read More
fancybox: true
# Sidebar
sidebar: right
widgets:
- category
- tag
- tagcloud
- archive
- recent_posts
# display widgets at the bottom of index pages (pagination == 2)
index_widgets:
# - category
# - tagcloud
# - archive
# widget behavior
archive_type: 'monthly'
show_count: false
# Miscellaneous
google_analytics:
favicon: /favicon.png
twitter:
google_plus:
fb_admins:
fb_app_id:
| {
"repo_name": "longtian/webpack_performance",
"stars": "79",
"repo_language": "JavaScript",
"file_name": "2016-08-29-jenkins.md",
"mime_type": "text/plain"
} |
# Landscape
A brand new default theme for [Hexo].
- [Preview](http://hexo.io/hexo-theme-landscape/)
## Installation
### Install
``` bash
$ git clone https://github.com/hexojs/hexo-theme-landscape.git themes/landscape
```
**Landscape requires Hexo 2.4 and above.**
### Enable
Modify `theme` setting in `_config.yml` to `landscape`.
### Update
``` bash
cd themes/landscape
git pull
```
## Configuration
``` yml
# Header
menu:
Home: /
Archives: /archives
rss: /atom.xml
# Content
excerpt_link: Read More
fancybox: true
# Sidebar
sidebar: right
widgets:
- category
- tag
- tagcloud
- archives
- recent_posts
# Miscellaneous
google_analytics:
favicon: /favicon.png
twitter:
google_plus:
```
- **menu** - Navigation menu
- **rss** - RSS link
- **excerpt_link** - "Read More" link at the bottom of excerpted articles. `false` to hide the link.
- **fancybox** - Enable [Fancybox]
- **sidebar** - Sidebar style. You can choose `left`, `right`, `bottom` or `false`.
- **widgets** - Widgets displaying in sidebar
- **google_analytics** - Google Analytics ID
- **favicon** - Favicon path
- **twitter** - Twiiter ID
- **google_plus** - Google+ ID
## Features
### Fancybox
Landscape uses [Fancybox] to showcase your photos. You can use Markdown syntax or fancybox tag plugin to add your photos.
```

{% fancybox img_url [img_thumbnail] [img_caption] %}
```
### Sidebar
You can put your sidebar in left side, right side or bottom of your site by editing `sidebar` setting.
Landscape provides 5 built-in widgets:
- category
- tag
- tagcloud
- archives
- recent_posts
All of them are enabled by default. You can edit them in `widget` setting.
## Development
### Requirements
- [Grunt] 0.4+
- Hexo 2.4+
### Grunt tasks
- **default** - Download [Fancybox] and [Font Awesome].
- **fontawesome** - Only download [Font Awesome].
- **fancybox** - Only download [Fancybox].
- **clean** - Clean temporarily files and downloaded files.
[Hexo]: http://zespia.tw/hexo/
[Fancybox]: http://fancyapps.com/fancybox/
[Font Awesome]: http://fontawesome.io/
[Grunt]: http://gruntjs.com/
| {
"repo_name": "longtian/webpack_performance",
"stars": "79",
"repo_language": "JavaScript",
"file_name": "2016-08-29-jenkins.md",
"mime_type": "text/plain"
} |
var rUrl = /((([A-Za-z]{3,9}:(?:\/\/)?)(?:[-;:&=\+\$,\w]+@)?[A-Za-z0-9.-]+|(?:www.|[-;:&=\+\$,\w]+@)[A-Za-z0-9.-]+)((?:\/[\+~%\/.\w-_]*)?\??(?:[-\+=&;%@.\w_]*)#?(?:[.\!\/\\w]*))?)/;
/**
* Fancybox tag
*
* Syntax:
* {% fancybox /path/to/image [/path/to/thumbnail] [title] %}
*/
hexo.extend.tag.register('fancybox', function(args){
var original = args.shift(),
thumbnail = '';
if (args.length && rUrl.test(args[0])){
thumbnail = args.shift();
}
var title = args.join(' ');
return '<a class="fancybox" href="' + original + '" title="' + title + '">' +
'<img src="' + (thumbnail || original) + '" alt="' + title + '">'
'</a>' +
(title ? '<span class="caption">' + title + '</span>' : '');
}); | {
"repo_name": "longtian/webpack_performance",
"stars": "79",
"repo_language": "JavaScript",
"file_name": "2016-08-29-jenkins.md",
"mime_type": "text/plain"
} |
<%- partial('_partial/head') %>
<body>
<div id="container">
<div id="wrap">
<%- partial('_partial/header', null, {cache: !config.relative_link}) %>
<div class="outer">
<section id="main"><%- body %></section>
<% if (theme.sidebar && theme.sidebar !== 'bottom'){ %>
<%- partial('_partial/sidebar', null, {cache: !config.relative_link}) %>
<% } %>
</div>
<%- partial('_partial/footer', null, {cache: !config.relative_link}) %>
</div>
<%- partial('_partial/mobile-nav', null, {cache: !config.relative_link}) %>
<%- partial('_partial/after-footer') %>
</div>
</body>
</html> | {
"repo_name": "longtian/webpack_performance",
"stars": "79",
"repo_language": "JavaScript",
"file_name": "2016-08-29-jenkins.md",
"mime_type": "text/plain"
} |
<aside id="sidebar"<% if (theme.sidebar === 'bottom'){ %> class="outer"<% } %>>
<% theme.widgets.forEach(function(widget){ %>
<%- partial('_widget/' + widget) %>
<% }) %>
</aside> | {
"repo_name": "longtian/webpack_performance",
"stars": "79",
"repo_language": "JavaScript",
"file_name": "2016-08-29-jenkins.md",
"mime_type": "text/plain"
} |
<footer id="footer">
<% if (theme.sidebar === 'bottom'){ %>
<%- partial('_partial/sidebar') %>
<% } %>
<div class="outer">
<div id="footer-info" class="inner">
© <%= date(new Date(), 'YYYY') %> <%= config.author || config.title %><br>
<%= __('powered_by') %> <a href="http://hexo.io/" target="_blank">Hexo</a>
</div>
</div>
</footer> | {
"repo_name": "longtian/webpack_performance",
"stars": "79",
"repo_language": "JavaScript",
"file_name": "2016-08-29-jenkins.md",
"mime_type": "text/plain"
} |
<header id="header">
<div id="banner"></div>
<div id="header-outer" class="outer">
<div id="header-title" class="inner">
<h1 id="logo-wrap">
<a href="<%- url_for() %>" id="logo"><%= config.title %></a>
</h1>
<% if (theme.subtitle){ %>
<h2 id="subtitle-wrap">
<a href="<%- url_for() %>" id="subtitle"><%= theme.subtitle %></a>
</h2>
<% } %>
</div>
<div id="header-inner" class="inner">
<nav id="main-nav">
<a id="main-nav-toggle" class="nav-icon"></a>
<% for (var i in theme.menu){ %>
<a class="main-nav-link" href="<%- url_for(theme.menu[i]) %>"><%= i %></a>
<% } %>
</nav>
<nav id="sub-nav">
<% if (theme.rss){ %>
<a id="nav-rss-link" class="nav-icon" href="<%- theme.rss %>" title="<%= __('rss_feed') %>"></a>
<% } %>
<a id="nav-search-btn" class="nav-icon" title="<%= __('search') %>"></a>
</nav>
<div id="search-form-wrap">
<%- search_form({button: ''}) %>
</div>
</div>
</div>
</header>
<a href="https://github.com/wyvernnot/webpack_performance">
<img style="position: absolute; top: 0; right: 0; border: 0;" src="https://camo.githubusercontent.com/652c5b9acfaddf3a9c326fa6bde407b87f7be0f4/68747470733a2f2f73332e616d617a6f6e6177732e636f6d2f6769746875622f726962626f6e732f666f726b6d655f72696768745f6f72616e67655f6666373630302e706e67" alt="Fork me on GitHub" data-canonical-src="https://s3.amazonaws.com/github/ribbons/forkme_right_orange_ff7600.png">
</a>
| {
"repo_name": "longtian/webpack_performance",
"stars": "79",
"repo_language": "JavaScript",
"file_name": "2016-08-29-jenkins.md",
"mime_type": "text/plain"
} |
<article id="<%= post.layout %>-<%= post.slug %>" class="article article-type-<%= post.layout %>" itemscope itemprop="blogPost">
<div class="article-meta">
<%- partial('post/date', {class_name: 'article-date', date_format: null}) %>
<%- partial('post/category') %>
</div>
<div class="article-inner">
<%- partial('post/gallery') %>
<% if (post.link || post.title){ %>
<header class="article-header">
<%- partial('post/title', {class_name: 'article-title'}) %>
</header>
<% } %>
<div class="article-entry" itemprop="articleBody">
<% if (post.excerpt && index){ %>
<%- post.excerpt %>
<% if (theme.excerpt_link){ %>
<p class="article-more-link">
<a href="<%- url_for(post.path) %>#more"><%= theme.excerpt_link %></a>
</p>
<% } %>
<% } else { %>
<%- post.content %>
<% } %>
</div>
<footer class="article-footer">
<a data-url="<%- post.permalink %>" data-id="<%= post._id %>" class="article-share-link"><%= __('share') %></a>
<% if (post.comments && config.disqus_shortname){ %>
<a href="<%- post.permalink %>#disqus_thread" class="article-comment-link"><%= __('comment') %></a>
<% } %>
<%- partial('post/tag') %>
</footer>
</div>
<% if (!index){ %>
<%- partial('post/nav') %>
<% } %>
</article>
<% if (!index && post.comments && config.disqus_shortname){ %>
<section id="comments">
<div id="disqus_thread">
<noscript>Please enable JavaScript to view the <a href="//disqus.com/?ref_noscript">comments powered by Disqus.</a></noscript>
</div>
</section>
<% } %> | {
"repo_name": "longtian/webpack_performance",
"stars": "79",
"repo_language": "JavaScript",
"file_name": "2016-08-29-jenkins.md",
"mime_type": "text/plain"
} |
<nav id="mobile-nav">
<% for (var i in theme.menu){ %>
<a href="<%- url_for(theme.menu[i]) %>" class="mobile-nav-link"><%= i %></a>
<% } %>
</nav> | {
"repo_name": "longtian/webpack_performance",
"stars": "79",
"repo_language": "JavaScript",
"file_name": "2016-08-29-jenkins.md",
"mime_type": "text/plain"
} |
<% if (pagination == 2){ %>
<% page.posts.each(function(post){ %>
<%- partial('article', {post: post, index: true}) %>
<% }) %>
<% } else { %>
<% var last; %>
<% page.posts.each(function(post, i){ %>
<% var year = post.date.year(); %>
<% if (last != year){ %>
<% if (last != null){ %>
</div></section>
<% } %>
<% last = year; %>
<section class="archives-wrap">
<div class="archive-year-wrap">
<a href="<%- url_for(config.archive_dir + '/' + year) %>" class="archive-year"><%= year %></a>
</div>
<div class="archives">
<% } %>
<%- partial('archive-post', {post: post, even: i % 2 == 0}) %>
<% }) %>
<% if (page.posts.length){ %>
</div></section>
<% } %>
<% } %>
<% if (page.total > 1){ %>
<nav id="page-nav">
<%- paginator({
prev_text: "« __('prev')",
next_text: "__('next') »"
}) %>
</nav>
<% } %> | {
"repo_name": "longtian/webpack_performance",
"stars": "79",
"repo_language": "JavaScript",
"file_name": "2016-08-29-jenkins.md",
"mime_type": "text/plain"
} |
<% if (config.disqus_shortname){ %>
<script>
var disqus_shortname = '<%= config.disqus_shortname %>';
<% if (page.permalink){ %>
var disqus_url = '<%= page.permalink %>';
<% } %>
(function(){
var dsq = document.createElement('script');
dsq.type = 'text/javascript';
dsq.async = true;
dsq.src = '//' + disqus_shortname + '.disqus.com/<% if (page.comments) { %>embed.js<% } else { %>count.js<% } %>';
(document.getElementsByTagName('head')[0] || document.getElementsByTagName('body')[0]).appendChild(dsq);
})();
</script>
<% } %>
<script src="//cdn.staticfile.org/jquery/2.2.1/jquery.min.js"></script>
<% if (theme.fancybox){ %>
<%- css('fancybox/jquery.fancybox') %>
<%- js('fancybox/jquery.fancybox.pack') %>
<% } %>
<%- js('js/script') %>
| {
"repo_name": "longtian/webpack_performance",
"stars": "79",
"repo_language": "JavaScript",
"file_name": "2016-08-29-jenkins.md",
"mime_type": "text/plain"
} |
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<%
var title = page.title;
if (is_archive()){
title = __('archive_a');
if (is_month()){
title += ': ' + page.year + '/' + page.month;
} else if (is_year()){
title += ': ' + page.year;
}
} else if (is_category()){
title = __('category') + ': ' + page.category;
} else if (is_tag()){
title = __('tag') + ': ' + page.tag;
}
%>
<title><% if (title){ %><%= title %> | <% } %><%= config.title %></title>
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
<%- open_graph({twitter_id: theme.twitter, google_plus: theme.google_plus, fb_admins: theme.fb_admins, fb_app_id: theme.fb_app_id}) %>
<% if (theme.rss){ %>
<link rel="alternate" href="<%- theme.rss %>" title="<%= config.title %>" type="application/atom+xml">
<% } %>
<% if (theme.favicon){ %>
<link rel="icon" href="<%- theme.favicon %>">
<% } %>
<% if (config.highlight.enable){ %>
<link href="//fonts.useso.com/css?family=Source+Code+Pro" rel="stylesheet" type="text/css">
<% } %>
<%- css('css/style') %>
<%- partial('google-analytics') %>
<meta name="google-site-verification" content="Yym0OXhjbARq7mKIWaYfRkXiEEYQ39mNiRfVk-EHLAo" />
</head>
| {
"repo_name": "longtian/webpack_performance",
"stars": "79",
"repo_language": "JavaScript",
"file_name": "2016-08-29-jenkins.md",
"mime_type": "text/plain"
} |
<!-- Google Tag Manager -->
<noscript><iframe src="//www.googletagmanager.com/ns.html?id=GTM-5P79DZ"
height="0" width="0" style="display:none;visibility:hidden"></iframe></noscript>
<script>(function(w,d,s,l,i){w[l]=w[l]||[];w[l].push({'gtm.start':
new Date().getTime(),event:'gtm.js'});var f=d.getElementsByTagName(s)[0],
j=d.createElement(s),dl=l!='dataLayer'?'&l='+l:'';j.async=true;j.src=
'//www.googletagmanager.com/gtm.js?id='+i+dl;f.parentNode.insertBefore(j,f);
})(window,document,'script','dataLayer','GTM-5P79DZ');</script>
<!-- End Google Tag Manager -->
| {
"repo_name": "longtian/webpack_performance",
"stars": "79",
"repo_language": "JavaScript",
"file_name": "2016-08-29-jenkins.md",
"mime_type": "text/plain"
} |
<article class="archive-article archive-type-<%= post.layout %>">
<div class="archive-article-inner">
<header class="archive-article-header">
<%- partial('post/date', {class_name: 'archive-article-date', date_format: 'MMM D'}) %>
<%- partial('post/title', {class_name: 'archive-article-title'}) %>
</header>
</div>
</article> | {
"repo_name": "longtian/webpack_performance",
"stars": "79",
"repo_language": "JavaScript",
"file_name": "2016-08-29-jenkins.md",
"mime_type": "text/plain"
} |
<% if (post.tags && post.tags.length){ %>
<%- list_tags(post.tags, {
show_count: false,
class: 'article-tag'
}) %>
<% } %> | {
"repo_name": "longtian/webpack_performance",
"stars": "79",
"repo_language": "JavaScript",
"file_name": "2016-08-29-jenkins.md",
"mime_type": "text/plain"
} |
<% if (post.photos && post.photos.length){ %>
<div class="article-gallery">
<div class="article-gallery-photos">
<% post.photos.forEach(function(photo, i){ %>
<a class="article-gallery-img fancybox" href="<%- url_for(photo) %>" rel="gallery_<%= post._id %>">
<img src="<%- url_for(photo) %>" itemprop="image">
</a>
<% }) %>
</div>
</div>
<% } %> | {
"repo_name": "longtian/webpack_performance",
"stars": "79",
"repo_language": "JavaScript",
"file_name": "2016-08-29-jenkins.md",
"mime_type": "text/plain"
} |
<% if (post.categories && post.categories.length){ %>
<div class="article-category">
<%- list_categories(post.categories, {
show_count: false,
class: 'article-category',
style: 'none',
separator: '►'
}) %>
</div>
<% } %> | {
"repo_name": "longtian/webpack_performance",
"stars": "79",
"repo_language": "JavaScript",
"file_name": "2016-08-29-jenkins.md",
"mime_type": "text/plain"
} |
<a href="<%- url_for(post.path) %>" class="<%= class_name %>">
<time datetime="<%= date_xml(post.date) %>" itemprop="datePublished"><%= date(post.date, date_format) %></time>
</a> | {
"repo_name": "longtian/webpack_performance",
"stars": "79",
"repo_language": "JavaScript",
"file_name": "2016-08-29-jenkins.md",
"mime_type": "text/plain"
} |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.